Page MenuHomeFreeBSD

D56994.id179929.diff
No OneTemporary

D56994.id179929.diff

diff --git a/sys/dev/nvme/nvme_if.m b/sys/dev/nvme/nvme_if.m
--- a/sys/dev/nvme/nvme_if.m
+++ b/sys/dev/nvme/nvme_if.m
@@ -12,6 +12,14 @@
#include "dev/nvme/nvme_private.h"
};
+CODE {
+ static bool
+ default_is_storage_device(device_t dev)
+ {
+ return (true);
+ }
+}
+
#
# A new namespace is now available
#
@@ -53,3 +61,10 @@
void *page; /* Contents of the page */
uint32_t page_len; /* Length of the page */
};
+
+#
+# is this device a storage device or not.
+#
+METHOD bool is_storage_device {
+ device_t dev;
+} default default_is_storage_device;
diff --git a/sys/dev/nvme/nvme_pci.c b/sys/dev/nvme/nvme_pci.c
--- a/sys/dev/nvme/nvme_pci.c
+++ b/sys/dev/nvme/nvme_pci.c
@@ -38,11 +38,15 @@
#include "nvme_private.h"
+#include "nvme_if.h"
+
static int nvme_pci_probe(device_t);
static int nvme_pci_attach(device_t);
static int nvme_pci_detach(device_t);
static int nvme_pci_suspend(device_t);
static int nvme_pci_resume(device_t);
+static bool nvme_pci_is_storage_device(device_t);
+
static int nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr);
@@ -54,6 +58,7 @@
DEVMETHOD(device_suspend, nvme_pci_suspend),
DEVMETHOD(device_resume, nvme_pci_resume),
DEVMETHOD(device_shutdown, nvme_shutdown),
+ DEVMETHOD(nvme_is_storage_device, nvme_pci_is_storage_device),
DEVMETHOD_END
};
@@ -421,3 +426,13 @@
ctrlr = DEVICE2SOFTC(dev);
return (nvme_ctrlr_resume(ctrlr));
}
+
+static bool
+nvme_pci_is_storage_device(device_t dev)
+{
+ /*
+ * NVMHCI 1.0 interfaces are the only devices that
+ * have namespaces with LBA ranges.
+ */
+ return (pci_get_progif(dev) == PCIP_STORAGE_NVM_ENTERPRISE_NVMHCI_1_0);
+}
diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c
--- a/sys/dev/nvme/nvme_sim.c
+++ b/sys/dev/nvme/nvme_sim.c
@@ -324,6 +324,9 @@
if (nvme_use_nvd)
return (ENXIO);
+ if (!NVME_IS_STORAGE_DEVICE(device_get_parent(dev)))
+ return (ENXIO);
+
device_set_desc(dev, "nvme cam");
return (BUS_PROBE_DEFAULT);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 9, 4:49 AM (2 m, 29 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37804371
Default Alt Text
D56994.id179929.diff (2 KB)

Event Timeline