git: 8aa560491cfa - main - nvme: Fix sim unit number to match nvme device
Date: Wed, 18 Feb 2026 16:55:12 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=8aa560491cfad7953c7c089f4847951e867ef47c
commit 8aa560491cfad7953c7c089f4847951e867ef47c
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-02-17 21:08:46 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-02-18 16:40:06 +0000
nvme: Fix sim unit number to match nvme device
The CAM sim unit numbner should match the nvme device number. We need
this to match unit numbers in some wiring scenarios. For example:
hint.nvme.0.at="UEFI:PciRoot(0x3)/Pci(0x1,0x1)/Pci(0x0,0x0)"
hint.nvme.1.at="UEFI:PciRoot(0x3)/Pci(0x1,0x2)/Pci(0x0,0x0)"
hint.nvme.2.at="UEFI:PciRoot(0x3)/Pci(0x1,0x3)/Pci(0x0,0x0)"
hint.nvme.3.at="UEFI:PciRoot(0x3)/Pci(0x1,0x4)/Pci(0x0,0x0)"
hint.scbus.33.at="nvme0"
hint.nda.0.at="scbus33"
hint.scbus.34.at="nvme1"
hint.nda.1.at="scbus34"
hint.scbus.35.at="nvme2"
hint.nda.2.at="scbus35"
hint.scbus.36.at="nvme3"
hint.nda.3.at="scbus36"
If the devices that are nvme0 and nvme3 are the only ones populated, you
still want them associated with nda0 and nda3.
The nvme_sim device changes meant we were passing the wrong device's
unit number to cam_sim_alloc. This fixes the problem.
Sponsored by: Netflix
---
sys/dev/nvme/nvme_sim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c
index a59823847c39..f7db4a9ff4fb 100644
--- a/sys/dev/nvme/nvme_sim.c
+++ b/sys/dev/nvme/nvme_sim.c
@@ -343,7 +343,7 @@ nvme_sim_attach(device_t dev)
sc->s_ctrlr = ctrlr;
sc->s_sim = cam_sim_alloc(nvme_sim_action, nvme_sim_poll,
- "nvme", sc, device_get_unit(dev),
+ "nvme", sc, device_get_unit(ctrlr->dev),
NULL, max_trans, max_trans, devq);
if (sc->s_sim == NULL) {
device_printf(dev, "Failed to allocate a sim\n");