Linux USB
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Enable to set DbC strings through sysfs
@ 2025-10-07 21:38 Łukasz Bartosik
  2025-10-07 21:38 ` [PATCH v2 1/4] xhci: dbc: prepare to expose " Łukasz Bartosik
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Łukasz Bartosik @ 2025-10-07 21:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Łukasz Bartosik

From: Łukasz Bartosik <ukaszb@chromium.org>

This patchset enables setting DbC serial number,
product name and manufacturer name through sysfs.

Testing performed with this patchset:

1.DbC is enabled and enumerates on host side with the following
default values of product, manufactuer and serial values:
"
[496803.112431] usb 2-4: new SuperSpeed USB device number 106 using xhci_hcd
[496803.128540] usb 2-4: LPM exit latency is zeroed, disabling LPM.
[496803.129387] usb 2-4: New USB device found, idVendor=18d1, idProduct=0010, bcdDevice= 0.10
[496803.130173] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[496803.130858] usb 2-4: Product: Linux USB Debug Target
[496803.131343] usb 2-4: Manufacturer: Linux Foundation
[496803.131821] usb 2-4: SerialNumber: 0001
```

View default DbC values in sysfs:
"
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
Linux USB Debug Target
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
Linux Foundation
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
0001
"

2. Try to set product, manufacturer and serial to empty:

echo disable > /sys/bus/pci/devices/0000:00:14.0/dbc
echo "" > /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
echo "" > /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
echo "" > /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial  
echo enable > /sys/bus/pci/devices/0000:00:14.0/dbc

Verify through sysfs empty values were not set:
"
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
Linux USB Debug Target
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
Linux Foundation
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
0001
"

Verify DbC enumerates with default values:
"
[206723.036606] usb 2-3: new SuperSpeed USB device number 52 using xhci_hcd
[206723.056594] usb 2-3: LPM exit latency is zeroed, disabling LPM.
[206723.057795] usb 2-3: New USB device found, idVendor=18d1, idProduct=0010, bcdDevice= 0.10
[206723.058592] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[206723.059289] usb 2-3: Product: Linux USB Debug Target
[206723.059796] usb 2-3: Manufacturer: Linux Foundation
[206723.060284] usb 2-3: SerialNumber: 0001
"


3. Update product, manufacturer and serial values:

echo disable > /sys/bus/pci/devices/0000:00:14.0/dbc
echo "A" > /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
echo "B" > /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
echo "C" > /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
echo enable > /sys/bus/pci/devices/0000:00:14.0/dbc

Verify through sysfs new values were set:
"
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
A
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
B
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
C
"

Verify DbC enumerates with new values:
"
[222501.763069] usb 2-3: new SuperSpeed USB device number 66 using xhci_hcd
[222501.786948] usb 2-3: LPM exit latency is zeroed, disabling LPM.
[222501.801052] usb 2-3: New USB device found, idVendor=18d1, idProduct=0010, bcdDevice= 0.10
[222501.801857] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[222501.802556] usb 2-3: Product: A
[222501.802958] usb 2-3: Manufacturer: B
[222501.803329] usb 2-3: SerialNumber: C
"



4. Update product, manufacturer and serial values:

echo disable > /sys/bus/pci/devices/0000:00:14.0/dbc
echo "New_product_name" > /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
echo "New_manufacturer_name" > /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
echo "ABCDEF123456" > /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
echo enable > /sys/bus/pci/devices/0000:00:14.0/dbc

Verify through sysfs new values were set:
"
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
New_product_name
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
New_manufacturer_name
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
ABCDEF123456
"

Verify DbC enumerates with new values:
"
[222740.958461] usb 2-3: new SuperSpeed USB device number 67 using xhci_hcd
[222740.974545] usb 2-3: LPM exit latency is zeroed, disabling LPM.
[222740.975442] usb 2-3: New USB device found, idVendor=18d1, idProduct=0010, bcdDevice= 0.10
[222740.976236] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[222740.976929] usb 2-3: Product: New_product_name
[222740.977372] usb 2-3: Manufacturer: New_manufacturer_name
[222740.977896] usb 2-3: SerialNumber: ABCDEF123456
"


5. Try to update product, manufacturer and serial values with new values longer
than maximum 63 characters (half of USB_MAX_STRING_LEN):

echo disable > /sys/bus/pci/devices/0000:00:14.0/dbc
echo "AAAAAAAAA_BBBBBBBBB_CCCCCCCCC_DDDDDDDDD_EEEEEEEEE_FFFFFFFFF_GGGG" > /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct                   
echo "HHHHHHHHH_IIIIIIIII_JJJJJJJJJ_KKKKKKKKK_LLLLLLLLL_MMMMMMMMM_NNNN" > /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer              
echo "OOOOOOOOO_PPPPPPPPP_RRRRRRRRR_SSSSSSSSS_TTTTTTTTT_WWWWWWWWW_YYYY" > /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial  
echo enable > /sys/bus/pci/devices/0000:00:14.0/dbc

Verify through sysfs new values were not set:
"
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
New_product_name
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
New_manufacturer_name
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
ABCDEF123456
"

Verify DbC enumerates with previous values:
"
[497908.814834] usb 2-4: new SuperSpeed USB device number 108 using xhci_hcd
[497908.831057] usb 2-4: LPM exit latency is zeroed, disabling LPM.
[497908.844994] usb 2-4: New USB device found, idVendor=18d1, idProduct=0010, bcdDevice= 0.10
[497908.845797] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[497908.846482] usb 2-4: Product: New_product_name
[497908.846965] usb 2-4: Manufacturer: New_manufacturer_name
[497908.847505] usb 2-4: SerialNumber: ABCDEF123456
"


6. Update product, manufacturer and serial values with new values
whose length is maximum 63 characters (half of USB_MAX_STRING_LEN):

echo disable > /sys/bus/pci/devices/0000:00:14.0/dbc
echo "AAAAAAAAA_BBBBBBBBB_CCCCCCCCC_DDDDDDDDD_EEEEEEEEE_FFFFFFFFF_GGG" > /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct                    
echo "HHHHHHHHH_IIIIIIIII_JJJJJJJJJ_KKKKKKKKK_LLLLLLLLL_MMMMMMMMM_NNN" > /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer               
echo "OOOOOOOOO_PPPPPPPPP_RRRRRRRRR_SSSSSSSSS_TTTTTTTTT_WWWWWWWWW_YYY" > /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial  
echo enable > /sys/bus/pci/devices/0000:00:14.0/dbc

Verify through sysfs new values were set:
"
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iProduct
AAAAAAAAA_BBBBBBBBB_CCCCCCCCC_DDDDDDDDD_EEEEEEEEE_FFFFFFFFF_GGG
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iManufacturer
HHHHHHHHH_IIIIIIIII_JJJJJJJJJ_KKKKKKKKK_LLLLLLLLL_MMMMMMMMM_NNN
cat /sys/bus/pci/devices/0000:00:14.0/dbc_iSerial
OOOOOOOOO_PPPPPPPPP_RRRRRRRRR_SSSSSSSSS_TTTTTTTTT_WWWWWWWWW_YYY
"

Verify DbC enumerates with new values:
"
[499856.473572] usb 2-4: new SuperSpeed USB device number 119 using xhci_hcd
[499856.489786] usb 2-4: LPM exit latency is zeroed, disabling LPM.
[499856.492080] usb 2-4: New USB device found, idVendor=18d1, idProduct=0010, bcdDevice= 0.10
[499856.492871] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[499856.493624] usb 2-4: Product: AAAAAAAAA_BBBBBBBBB_CCCCCCCCC_DDDDDDDDD_EEEEEEEEE_FFFFFFFFF_GGG
[499856.494445] usb 2-4: Manufacturer: HHHHHHHHH_IIIIIIIII_JJJJJJJJJ_KKKKKKKKK_LLLLLLLLL_MMMMMMMMM_NNN
[499856.495307] usb 2-4: SerialNumber: OOOOOOOOO_PPPPPPPPP_RRRRRRRRR_SSSSSSSSS_TTTTTTTTT_WWWWWWWWW_YYY
"



7. Repeat steps 2-6 with passing -n option to each echo command to prevent outputting the trailing newline



Changes in V2:
- Documented new sysfs entries
- Fixed *_store functions to handle correctly case when there
is no trailing newline

Łukasz Bartosik (4):
  xhci: dbc: prepare to expose strings through sysfs
  xhci: dbc: allow to set serial number through sysfs
  xhci: dbc: allow to set product name through sysfs
  xhci: dbc: allow to set manufacturer name through sysfs

 .../testing/sysfs-bus-pci-drivers-xhci_hcd    |  36 +++
 drivers/usb/host/xhci-dbgcap.c                | 252 +++++++++++++-----
 drivers/usb/host/xhci-dbgcap.h                |  24 +-
 3 files changed, 237 insertions(+), 75 deletions(-)

-- 
2.51.0.710.ga91ca5db03-goog


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-10-13 22:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 21:38 [PATCH v2 0/4] Enable to set DbC strings through sysfs Łukasz Bartosik
2025-10-07 21:38 ` [PATCH v2 1/4] xhci: dbc: prepare to expose " Łukasz Bartosik
2025-10-10 11:09   ` Mathias Nyman
2025-10-11 11:22     ` Łukasz Bartosik
2025-10-11 17:13       ` Alan Stern
2025-10-12 15:57         ` Łukasz Bartosik
2025-10-13  8:12           ` Mathias Nyman
2025-10-13  8:18       ` Mathias Nyman
2025-10-07 21:39 ` [PATCH v2 2/4] xhci: dbc: allow to set serial number " Łukasz Bartosik
2025-10-08 11:20   ` Greg Kroah-Hartman
2025-10-08 21:14     ` Łukasz Bartosik
2025-10-07 21:39 ` [PATCH v2 3/4] xhci: dbc: allow to set product name " Łukasz Bartosik
2025-10-13  9:01   ` Mathias Nyman
2025-10-13 22:19     ` Łukasz Bartosik
2025-10-13 22:27       ` Mathias Nyman
2025-10-07 21:39 ` [PATCH v2 4/4] xhci: dbc: allow to set manufacturer " Łukasz Bartosik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox