git: 67873a4fcabf - stable/13 - nvd: For AHCI attached devices, report ahci bridge

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Fri, 21 Jan 2022 18:50:32 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=67873a4fcabfd9f9dbd95be978df535209d8cc84

commit 67873a4fcabfd9f9dbd95be978df535209d8cc84
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-12-06 17:23:14 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-01-21 18:49:57 +0000

    nvd: For AHCI attached devices, report ahci bridge
    
    When an NVME device is attached via a AHCI controller, we have no access
    to its config space. So instead of information about the nvme drive
    itself, return info about the AHCI controller as the next best
    thing. Since the Intel Hardware RAID support looks at these values, this
    likely is best.
    
    Sponsored by:           Netflix
    Reviewed by:            mav
    Differential Revision:  https://reviews.freebsd.org/D33286
    
    (cherry picked from commit b8194f37666768dac35a0e1105c41242aad9b2d0)
---
 sys/dev/nvd/nvd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c
index 061304471905..ea44458885d2 100644
--- a/sys/dev/nvd/nvd.c
+++ b/sys/dev/nvd/nvd.c
@@ -484,6 +484,13 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
 	    NVME_MODEL_NUMBER_LENGTH);
 	strlcpy(disk->d_descr, descr, sizeof(descr));
 
+	/*
+	 * For devices that are reported as children of the AHCI controller,
+	 * which has no access to the config space for this controller, report
+	 * the AHCI controller's data.
+	 */
+	if (ctrlr->ctrlr->quirks & QUIRK_AHCI)
+		dev = device_get_parent(dev);
 	disk->d_hba_vendor = pci_get_vendor(dev);
 	disk->d_hba_device = pci_get_device(dev);
 	disk->d_hba_subvendor = pci_get_subvendor(dev);