aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/nvme/nvme_qpair.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2021-08-31 17:34:48 +0000
committerAlexander Motin <mav@FreeBSD.org>2021-09-07 01:24:54 +0000
commit0e6969a0f4e25fe8c271c75dd19a0e73ec4c6c98 (patch)
treef10405593b77585e352ba47d0a634979817cd393 /sys/dev/nvme/nvme_qpair.c
parentd9cacf0b66c3b43417c39552903f010c9f3c32de (diff)
nvme(4): Add MSI and single MSI-X support.
If we can't allocate more MSI-X vectors, accept using single shared. If we can't allocate any MSI-X, try to allocate 2 MSI vectors, but accept single shared. If still no luck, fall back to shared INTx. This provides maximal flexibility in some limited scenarios. For example, vmd(4) does not support INTx and can handle only limited number of MSI/MSI-X vectors without sharing. MFC after: 1 week (cherry picked from commit e3bdf3da769a55f0944d9c337bb4d91b6435f02c)
Diffstat (limited to 'sys/dev/nvme/nvme_qpair.c')
-rw-r--r--sys/dev/nvme/nvme_qpair.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 4402d1000e67..eea87e299d3d 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -652,7 +652,7 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair)
}
static void
-nvme_qpair_msix_handler(void *arg)
+nvme_qpair_msi_handler(void *arg)
{
struct nvme_qpair *qpair = arg;
@@ -670,7 +670,7 @@ nvme_qpair_construct(struct nvme_qpair *qpair,
uint8_t *queuemem, *prpmem, *prp_list;
int i, err;
- qpair->vector = ctrlr->msix_enabled ? qpair->id : 0;
+ qpair->vector = ctrlr->msi_count > 1 ? qpair->id : 0;
qpair->num_entries = num_entries;
qpair->num_trackers = num_trackers;
qpair->ctrlr = ctrlr;
@@ -795,7 +795,7 @@ nvme_qpair_construct(struct nvme_qpair *qpair,
qpair->num_entries, M_NVME, DOMAINSET_PREF(qpair->domain),
M_ZERO | M_WAITOK);
- if (ctrlr->msix_enabled) {
+ if (ctrlr->msi_count > 1) {
/*
* MSI-X vector resource IDs start at 1, so we add one to
* the queue's vector to get the corresponding rid to use.
@@ -804,10 +804,14 @@ nvme_qpair_construct(struct nvme_qpair *qpair,
qpair->res = bus_alloc_resource_any(ctrlr->dev, SYS_RES_IRQ,
&qpair->rid, RF_ACTIVE);
+ if (qpair->res == NULL) {
+ nvme_printf(ctrlr, "unable to allocate MSI\n");
+ goto out;
+ }
if (bus_setup_intr(ctrlr->dev, qpair->res,
INTR_TYPE_MISC | INTR_MPSAFE, NULL,
- nvme_qpair_msix_handler, qpair, &qpair->tag) != 0) {
- nvme_printf(ctrlr, "unable to setup intx handler\n");
+ nvme_qpair_msi_handler, qpair, &qpair->tag) != 0) {
+ nvme_printf(ctrlr, "unable to setup MSI\n");
goto out;
}
if (qpair->id == 0) {