[PATCH] nvme-pci: expose active quirks in sysfs

Maurizio Lombardi mlombard at redhat.com
Tue Oct 28 07:29:16 PDT 2025


Currently, there is no straightforward way for a user to inspect
the quirks value from userspace.
Add a new read-only sysfs attribute "quirks";
reading this file will display the hexadecimal
value of the ctrl->quirks bitmask for the given NVMe device.

Signed-off-by: Maurizio Lombardi <mlombard at redhat.com>
---
 drivers/nvme/host/pci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index c916176bd9f0..de9febd32e83 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2497,6 +2497,15 @@ static ssize_t cmbsz_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(cmbsz);
 
+static ssize_t quirks_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev));
+
+	return sysfs_emit(buf, "0x%08lx\n", ndev->ctrl.quirks);
+}
+static DEVICE_ATTR_RO(quirks);
+
 static ssize_t hmb_show(struct device *dev, struct device_attribute *attr,
 			char *buf)
 {
@@ -2557,6 +2566,7 @@ static struct attribute *nvme_pci_attrs[] = {
 	&dev_attr_cmbloc.attr,
 	&dev_attr_cmbsz.attr,
 	&dev_attr_hmb.attr,
+	&dev_attr_quirks.attr,
 	NULL,
 };
 
-- 
2.47.3




More information about the Linux-nvme mailing list