Yuri Pankov wrote:
I have tried booting latest -current snapshot on 2019 macbook pro 16, and noticed that nvme driver didn't attach, as class reported is 0x018002 and not 0x010802 that we expect in nvme_pci.c.

The following linux changes seem to be related:
https://github.com/torvalds/linux/commit/66341331ba0d2de4ff421cdc401a1e34de50502a https://github.com/torvalds/linux/commit/d38e9f04ebf667d9cb8185b45bff747485f1d3e9

I have tried adding the exact PCI IDs, but that also fails as number of msix vectors seems to be 0 in nvme_ctrlr_setup_interrupts() and nvme_ctrlr_configure_intx() fails with "unable to allocate shared IRQ".

Any hints on how to proceed here?

So it looks like we need to fallback to MSI if we failed to enable MSI-X. With the attached patch we still fail to attach the target device (as below) most likely due to the quirks needed as seen in linux driver, but it's definitely a start:

nvme0: CREATE IO CQ (05) sqid:0 cid:15 nsid:0 cdw10:00800001 cdw11:00010003
nvme0: INVALID_FIELD (00/02) sqid:0 cid:15 cdw0:0
nvme0: nvme_create_io_cq failed!
diff --git a/sys/dev/nvme/nvme_pci.c b/sys/dev/nvme/nvme_pci.c
index 448bfda6a718..e609967b53fe 100644
--- a/sys/dev/nvme/nvme_pci.c
+++ b/sys/dev/nvme/nvme_pci.c
@@ -90,6 +90,7 @@ static struct _pcsid
        { 0x05401c5f,           0, 0, "Memblaze Pblaze4", 
QUIRK_DELAY_B4_CHK_RDY },
        { 0xa821144d,           0, 0, "Samsung PM1725", QUIRK_DELAY_B4_CHK_RDY 
},
        { 0xa822144d,           0, 0, "Samsung PM1725a", QUIRK_DELAY_B4_CHK_RDY 
},
+       { 0x2005106b,           0, 0, "ANS2 NVMe Controller" },
        { 0x00000000,           0, 0, NULL  }
 };
 
@@ -267,7 +268,7 @@ nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr)
 
        force_intx = 0;
        TUNABLE_INT_FETCH("hw.nvme.force_intx", &force_intx);
-       if (force_intx || pci_msix_count(dev) < 2) {
+       if (force_intx) {
                nvme_ctrlr_configure_intx(ctrlr);
                return;
        }
@@ -297,9 +298,14 @@ nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr)
        /* One vector for per core I/O queue, plus one vector for admin queue. 
*/
        num_vectors_requested = num_io_queues + 1;
        num_vectors_allocated = num_vectors_requested;
+
+       /* Try MSI-X */
        if (pci_alloc_msix(dev, &num_vectors_allocated) != 0) {
-               nvme_ctrlr_configure_intx(ctrlr);
-               return;
+               /* MSI-X failed, try MSI */
+               if (pci_alloc_msi(dev, &num_vectors_allocated) != 0) {
+                       nvme_ctrlr_configure_intx(ctrlr);
+                       return;
+               }
        }
        if (num_vectors_allocated < 2) {
                pci_release_msi(dev);
_______________________________________________
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to