Page MenuHomeFreeBSD

USB4 host reset (& writing to router config space)
Needs ReviewPublic

Authored by obiwac on Mar 22 2025, 1:45 AM.
Tags
Referenced Files
Unknown Object (File)
Tue, Apr 28, 4:02 AM
Unknown Object (File)
Mon, Apr 27, 1:37 PM
Unknown Object (File)
Mon, Apr 27, 5:03 AM
Unknown Object (File)
Sun, Apr 19, 9:55 PM
Unknown Object (File)
Sun, Apr 19, 9:13 PM
Unknown Object (File)
Fri, Apr 17, 11:01 AM
Unknown Object (File)
Tue, Apr 14, 8:03 PM
Unknown Object (File)
Tue, Apr 14, 10:41 AM
Subscribers

Details

Summary

Get host interface version (either 1.0 or 2.0) and reset accordingly.

This required support for writing to router config space.

Test Plan

Tested on AMD Pink Sardine controller (1022:1668/9), which is host interface version 1.0. It would be nice to try this out on version 2.0, but unfortunately I don't have the hardware to do this as it is fairly new.

This does require the D49451 patch to work on Pink Sardine.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 72335
Build 69218: arc lint + arc unit

Event Timeline

sys/dev/thunderbolt/nhi.c
272

Why not NHI_SLPR_WAIT_US? C_HARDCLOCK? Why?

sys/dev/thunderbolt/nhi.c
272

NHI_SLPR_WAIT_US is for the time between us setting SLP and the router setting SLPR. This is the same number but a different value defined elsewhere in the spec. Including these constants in this patch is a mistake, they're not used. Will remove.

As for C_HARDCLOCK, I don't know, I had copied this line from another driver assuming it was the same. Will learn about this.

adrian added inline comments.
sys/dev/thunderbolt/tbcfg_reg.h
68

Looking at this change, and yeah i downloaded the 2025 spec from here:

https://usb.org/document-library/usb4r-specification-v20

  • config read request is 6.4.2.3, read response is 6.4.2.4 (the section above this one in the source)
  • 6.4.2.5 is clear about the crc being after "write size", not a fixed location like this.
  • having 0 entry field and then a fixed size field afterwards feels wrong? ;-)

So I think this change isn't correct?

sys/dev/thunderbolt/tbcfg_reg.h
68

config read request is 6.4.2.3, read response is 6.4.2.4 (the section above this one in the source)

Yeah there's a typo in the struct tb_cfg_read_resp comment actually, it should be read response not request.

So I think this change isn't correct?

I can't remember why I made it an actual member, I think probably because it doesn't make a functional difference and maybe thought it could be useful to sizeof the crc. But i agree it is a bit bizarre so I'll revert it back to being a comment.

what do i need to check in dmesg / pciconf to see if i have something that can test this?

what do i need to check in dmesg / pciconf to see if i have something that can test this?

you should have a generic USB4 NHI controller (listed in pciconf), that is class 0x0c0340. If it is AMD, you probably need to apply D52862 first though