Skip to contentSkip to conversation

Enable/Disable NVMe quirks via module parameter

PATCH Applied Maurizio Lombardi 3 participants 4 messages Feb 4 – Feb 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover Enable/Disable NVMe quirks via module parameter

Recently, some of our customers were very vocal about wanting an easy way to enable or disable specific nvme quirks.

I recall that during the ALPSS conference this topic has been briefly discussed, and it was proposed to use the generic PCI sysfs "new_id" entry to manipulate the quirks.

However, in some cases a quirk may prevent the system from properly booting, the kernel may hang or fail to mount the root
filesystem before the system reaches a state where new_id can be written, this makes this solution not exactly user-friendly for end users.

In particular, boot-time hangs have been reported involving the bogus_nid quirk.

Therefore, I have been asked to re-propose this module parameter approach with a few modifications suggested by Daniel Wagner.

# dmesg | grep nvme
[    0.000000] Command line: root=/dev/vda1 console=ttyS0,115200n8 nvme.quirks=1b36:0010:^bogus_nxid
[    6.732692] nvme: unrecognized quirk bogus_nxid
# cat /sys/devices/pci0000:00/0000:00:05.0/nvme/nvme1/quirks
bogus_nid
# dmesg | grep nvme
[    0.000000] Command line: root=/dev/vda1 console=ttyS0,115200n8 nvme.quirks=1b36:0010:^bogus_nid,no_apst
# cat /sys/devices/pci0000:00/0000:00:05.0/nvme/nvme0/quirks                                                                                                                                             
no_apst

Maurizio Lombardi (1):
nvme: add support for dynamic quirk configuration via module parameter

 .../admin-guide/kernel-parameters.txt         |  13 ++
 drivers/nvme/host/pci.c                       | 162 ++++++++++++++++++
 2 files changed, 175 insertions(+)
Signature · 1 line
2.52.0
#1 lore raw

PATCH v3 1/1 nvme: add support for dynamic quirk configuration via module parameter

Introduce support for enabling or disabling specific NVMe quirks at module load time through the quirks module parameter.
This mechanism allows users to apply known quirks dynamically based on the device's PCI vendor and device IDs, without requiring to add hardcoded entries in the driver and recompiling the kernel.

While the generic PCI new_id sysfs interface exists for dynamic configuration, it is insufficient for scenarios where the system fails to boot (for example, this has been reported to happen because of the bogus_nid quirk). The new_id attribute is writable only after the system has booted and sysfs is mounted.

The quirks parameter accepts a list of quirk specifications separated by a '-' character in the following format:

<VID>:<DID>:<quirk_names>[-<VID>:<DID>:<quirk_names>-..]

Each quirk is represented by its name and can be prefixed with ^ to indicate that the quirk should be disabled; quirk names are separated by a ',' character.

Example: enable BOGUS_NID and BROKEN_MSI, disable DEALLOCATE_ZEROES:

   $ modprobe nvme quirks=7170:2210:bogus_nid,broken_msi,^deallocate_zeroes

---

V3: some small code style fixes, no functional changes

V2: split quirk_param_set() to increase readability.
Prefer post-increments.
Remove braces where it makes sense.
Avoid the BIT() macro.
Use nvme_pci_ prefix for global variables.
Break overly long lines, use 75-chars length consistently set 0444 perms to quirks param to prevent the user from changing it

 .../admin-guide/kernel-parameters.txt         |  13 ++
 drivers/nvme/host/pci.c                       | 162 ++++++++++++++++++
 2 files changed, 175 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +13 -0
index 1058f2a6d6a8..cb689fcfbc6f 100644
@@ -74,6 +74,7 @@
 	TPM	TPM drivers are enabled.
 	UMS	USB Mass Storage support is enabled.
 	USB	USB support is enabled.
+	NVME	NVMe support is enabled
 	USBHID	USB Human Interface Device support is enabled.
 	V4L	Video For Linux support is enabled.
 	VGA	The VGA console has been enabled.
@@ -4706,6 +4707,18 @@ Kernel parameters
 			This can be set from sysctl after boot.
 			See Documentation/admin-guide/sysctl/vm.rst for details.
 
+	nvme.quirks=    [NVME] A list of quirk entries to augment the built-in
+			nvme quirk list. List entries are separated by a
+			'-' character.
+			Each entry has the form VendorID:ProductID:quirk_names.
+			The IDs are 4-digits hex numbers and quirk_names is a
+			list of quirk names separated by commas. A quirk name
+			can be prefixed by '^', meaning that the specified
+			quirk must be disabled.
+
+			Example:
+			nvme.quirks=7710:2267:bogus_nid,^identify_cns-9900:7711:broken_msi
+
 	ohci1394_dma=early	[HW,EARLY] enable debugging via the ohci1394 driver.
 			See Documentation/core-api/debugging-via-ohci1394.rst for more
 			info.
drivers/nvme/host/pci.c +162 -0

198 lines not on this page · raw message

Signature · 1 line
2.52.0
maintainer Applied
#3 lore raw

Re: [PATCH V3 1/1] nvme: add support for dynamic quirk configuration via module parameter

In reply to Maurizio Lombardi
Quoted 17 lines · Maurizio Lombardi

Introduce support for enabling or disabling specific NVMe quirks at module load time through the quirks module parameter.
This mechanism allows users to apply known quirks dynamically based on the device's PCI vendor and device IDs, without requiring to add hardcoded entries in the driver and recompiling the kernel.

While the generic PCI new_id sysfs interface exists for dynamic configuration, it is insufficient for scenarios where the system fails to boot (for example, this has been reported to happen because of the bogus_nid quirk). The new_id attribute is writable only after the system has booted and sysfs is mounted.

The quirks parameter accepts a list of quirk specifications separated by a '-' character in the following format:

<VID>:<DID>:<quirk_names>[-<VID>:<DID>:<quirk_names>-..]

Quoted 7 lines

Each quirk is represented by its name and can be prefixed with ^ to indicate that the quirk should be disabled; quirk names are separated by a ',' character.

Example: enable BOGUS_NID and BROKEN_MSI, disable DEALLOCATE_ZEROES:

   $ modprobe nvme quirks=7170:2210:bogus_nid,broken_msi,^deallocate_zeroes

Thanks, applied to nvme-7.0.