Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/nvme/nvme_ctrlr.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
static void nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr); | static void nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr); | ||||
static int | static int | ||||
nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr) | nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr) | ||||
{ | { | ||||
ctrlr->resource_id = PCIR_BAR(0); | ctrlr->resource_id = PCIR_BAR(0); | ||||
ctrlr->resource = bus_alloc_resource(ctrlr->dev, SYS_RES_MEMORY, | ctrlr->resource = bus_alloc_resource_any(ctrlr->dev, SYS_RES_MEMORY, | ||||
&ctrlr->resource_id, 0, ~0, 1, RF_ACTIVE); | &ctrlr->resource_id, RF_ACTIVE); | ||||
if(ctrlr->resource == NULL) { | if(ctrlr->resource == NULL) { | ||||
nvme_printf(ctrlr, "unable to allocate pci resource\n"); | nvme_printf(ctrlr, "unable to allocate pci resource\n"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
ctrlr->bus_tag = rman_get_bustag(ctrlr->resource); | ctrlr->bus_tag = rman_get_bustag(ctrlr->resource); | ||||
ctrlr->bus_handle = rman_get_bushandle(ctrlr->resource); | ctrlr->bus_handle = rman_get_bushandle(ctrlr->resource); | ||||
ctrlr->regs = (struct nvme_registers *)ctrlr->bus_handle; | ctrlr->regs = (struct nvme_registers *)ctrlr->bus_handle; | ||||
/* | /* | ||||
* The NVMe spec allows for the MSI-X table to be placed behind | * The NVMe spec allows for the MSI-X table to be placed behind | ||||
* BAR 4/5, separate from the control/doorbell registers. Always | * BAR 4/5, separate from the control/doorbell registers. Always | ||||
* try to map this bar, because it must be mapped prior to calling | * try to map this bar, because it must be mapped prior to calling | ||||
* pci_alloc_msix(). If the table isn't behind BAR 4/5, | * pci_alloc_msix(). If the table isn't behind BAR 4/5, | ||||
* bus_alloc_resource() will just return NULL which is OK. | * bus_alloc_resource() will just return NULL which is OK. | ||||
*/ | */ | ||||
ctrlr->bar4_resource_id = PCIR_BAR(4); | ctrlr->bar4_resource_id = PCIR_BAR(4); | ||||
ctrlr->bar4_resource = bus_alloc_resource(ctrlr->dev, SYS_RES_MEMORY, | ctrlr->bar4_resource = bus_alloc_resource_any(ctrlr->dev, SYS_RES_MEMORY, | ||||
&ctrlr->bar4_resource_id, 0, ~0, 1, RF_ACTIVE); | &ctrlr->bar4_resource_id, RF_ACTIVE); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
nvme_ctrlr_construct_admin_qpair(struct nvme_controller *ctrlr) | nvme_ctrlr_construct_admin_qpair(struct nvme_controller *ctrlr) | ||||
{ | { | ||||
struct nvme_qpair *qpair; | struct nvme_qpair *qpair; | ||||
▲ Show 20 Lines • Show All 1,143 Lines • Show Last 20 Lines |