From nobody Wed Jun 17 15:05:19 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ggRxC4HmKz6hVGf for ; Wed, 17 Jun 2026 15:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ggRxC38gwz43t4 for ; Wed, 17 Jun 2026 15:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781708719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/6Xp0Kj+wJfs6jNFHHWj2SRCD7LbFCjbRRYQyrxE/N8=; b=TI+cE2Vl2YvyELmhGh8P0g4ZVVosQZRPExwUAXaF/QR8iC06JyWEk5k5aAKk+Csq24Z5si obzV0v0jV5t9snxyB036ClqZ/IYEQRAwnToA23rnFmqHk7hzH+IfEsGRltrr4jyKdWdv3i rXTOjV5D5FZtdqc3SCXpeJfuc5buCWZ6Rx0FF5zbG9467ZLdu6ivNEnlH8bPQgrzrfvXgT 0tDa7idSl/VYS0D5lftfR35HKumRNgNNpihlmlKg3wlMb/qGv1w9Hs7SI8w+PH7bWvziIJ huBk8tK6hrd5UieMSRw8xol0URT72ibDZh9fXzZrXK/IPTGTkAcgQfSC599Cwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781708719; a=rsa-sha256; cv=none; b=YSNozBFBUbHayA6qRgXNF7EtBLg+2UpjaFKVrNCbdEM3V0leKxtJq6IfovQgVPSkNPo+os wIYzrfRpcBcGtmW1Cx32SurxY3cLBkWV+YNwzRjQy1T9K+evI1pLFD34T/a8yqxPwqBkCj LJjRFw4gFqk34sdS/TB17n3QpfpFj57fNDiyBeZpFIEPrrnQ6GVaV5TWCGd5Vgdre8bapO O6q8g+elP90ghFfQKDZ0FY1BtuLyHtTeounPyUC4tA7ZlBspc2JSg9IVHc8b/AfehZk5W2 1NEP67oLg3rKWgedR7oF4Nqj8AIQUr26FjBwp+a65A3oFvGobSmm/ccuRKMAbg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781708719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/6Xp0Kj+wJfs6jNFHHWj2SRCD7LbFCjbRRYQyrxE/N8=; b=QgFCSbtQdXlij3+sdKOjystP17qKPbM4e4SBGDhKruiA0pRWA456Vk6LFKP2lR2i6M3XqB 4iiBT4/n1PfbVU2K8YLlOaQysk+I8aY/bTlhqkLepk+1rwcDKYmPnHcVYZntflZbNdllsJ AVKbxx1KtunGk4UdvwdmPlMuDKe5K8r0a6oxPoqadpMIQp3692E5AhSWbLl09yyUBqFk/n BXbcgzp/lMlnAkP0iVbIwC28rjvUCgrHEgMwdAVJrd/Qgx1RFf3pj8/RrnRl/r/88MHRJ5 fR62eGQS3p5bO7WlGcJCfJApFBxO6nroY+EEWruUjbaowntByrf+zD3FPJIjcA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4ggRxC2TrMz2D8 for ; Wed, 17 Jun 2026 15:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3e162 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 17 Jun 2026 15:05:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 949804c81909 - main - nvme: Use newbus to ask if a device is storage List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 949804c819096b40210e0b0729e54ba10b79c2e8 Auto-Submitted: auto-generated Date: Wed, 17 Jun 2026 15:05:19 +0000 Message-Id: <6a32b7af.3e162.34185707@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=949804c819096b40210e0b0729e54ba10b79c2e8 commit 949804c819096b40210e0b0729e54ba10b79c2e8 Author: Warner Losh AuthorDate: 2026-06-17 15:03:31 +0000 Commit: Warner Losh CommitDate: 2026-06-17 15:03:31 +0000 nvme: Use newbus to ask if a device is storage As NVMe is in more places, it has a variety of attachments. On non PCI busses, we assume we're a storage device. For PCI, we look at the interface ID. Add newbus glue to make this happen. Sponsored by: Netflix Discussed with: jhb Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D56994 --- sys/dev/nvme/nvme_if.m | 15 +++++++++++++++ sys/dev/nvme/nvme_pci.c | 15 +++++++++++++++ sys/dev/nvme/nvme_sim.c | 3 +++ 3 files changed, 33 insertions(+) diff --git a/sys/dev/nvme/nvme_if.m b/sys/dev/nvme/nvme_if.m index 5a06ff112f4c..9705aeb7ce0b 100644 --- a/sys/dev/nvme/nvme_if.m +++ b/sys/dev/nvme/nvme_if.m @@ -12,6 +12,14 @@ HEADER { #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 @@ METHOD int handle_aen { 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 index 0566b227ad7c..8389c7535c3d 100644 --- 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 @@ static device_method_t nvme_pci_methods[] = { 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 @@ nvme_pci_resume(device_t dev) 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 index 89cdd0903b39..8f6cef4109f0 100644 --- a/sys/dev/nvme/nvme_sim.c +++ b/sys/dev/nvme/nvme_sim.c @@ -324,6 +324,9 @@ nvme_sim_probe(device_t dev) 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); }