Commit 815759ed authored by Duncan Laurie's avatar Duncan Laurie Committed by chrome-bot
Browse files

Support multiple nvme controllers



In order to support having a "backup" nvme location (for error
handling cases where the device at root port 0 is not found) we
need to be able to support multiple controllers with this driver,
so allocate the cleanup structure instead of using a static variable.

Also clean up the error messages during probing so it is clear what
device is being looked for since they may not be expected to exist.

BUG=b:35581264
TEST=verify logs without any device:
NVMe device not found @ 01:00:00
Updating storage controller failed.
PCIe bridge not found @ 00:1c:04
Updating storage controller failed.

Change-Id: Icd280e1143ac9dec428e890868b83bc11571e4f4
Signed-off-by: default avatarDuncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/592554

Reviewed-by: default avatarAaron Durbin <adurbin@chromium.org>
Reviewed-by: default avatarFurquan Shaikh <furquan@chromium.org>
parent fc56877d
......@@ -100,6 +100,11 @@ static int board_setup(void)
NvmeCtrlr *nvme = new_nvme_ctrlr(PCI_DEV(0, 0x1c, 4));
list_insert_after(&nvme->ctrlr.list_node, &fixed_block_dev_controllers);
/* Backup NVMe Root Port in case WiFi device is missing */
NvmeCtrlr *nvme_backup = new_nvme_ctrlr(PCI_DEV(0, 0x1c, 0));
list_insert_after(&nvme_backup->ctrlr.list_node,
&fixed_block_dev_controllers);
/* Speaker amp is Maxim 98927 codec on I2C4 */
DesignwareI2c *i2c4 =
new_pci_designware_i2c(PCI_DEV(0, 0x19, 2), 400000, 120);
......
......@@ -788,7 +788,9 @@ static int nvme_ctrlr_init(BlockDevCtrlrOps *me)
uint8_t header_type = pci_read_config8(dev, REG_HEADER_TYPE);
header_type &= 0x7f;
if (header_type != HEADER_TYPE_BRIDGE) {
status = NVME_UNSUPPORTED;
status = NVME_NOT_FOUND;
printf("PCIe bridge not found @ %02x:%02x:%02x\n",
PCI_BUS(dev), PCI_SLOT(dev), PCI_FUNC(dev));
goto exit;
}
......@@ -797,7 +799,9 @@ static int nvme_ctrlr_init(BlockDevCtrlrOps *me)
bus = (bus >> 8) & 0xff;
dev = PCI_DEV(bus, 0, 0);
if (!is_nvme_ctrlr(dev)) {
status = NVME_UNSUPPORTED;
status = NVME_NOT_FOUND;
printf("NVMe device not found @ %02x:%02x:%02x\n",
PCI_BUS(dev), PCI_SLOT(dev), PCI_FUNC(dev));
goto exit;
}
......@@ -980,13 +984,7 @@ static int nvme_shutdown(struct CleanupFunc *cleanup, CleanupType type)
NvmeCtrlr *new_nvme_ctrlr(pcidev_t dev)
{
NvmeCtrlr *ctrlr = xzalloc(sizeof(*ctrlr));
static CleanupFunc cleanup = {
&nvme_shutdown,
CleanupOnHandoff | CleanupOnLegacy,
NULL
};
assert(cleanup.data == NULL);
CleanupFunc *cleanup = xzalloc(sizeof(*cleanup));
printf("New NVMe Controller %p @ %02x:%02x:%02x\n",
ctrlr, PCI_BUS(dev),PCI_SLOT(dev),PCI_FUNC(dev));
......@@ -994,8 +992,11 @@ NvmeCtrlr *new_nvme_ctrlr(pcidev_t dev)
ctrlr->ctrlr.ops.update = &nvme_ctrlr_init;
ctrlr->ctrlr.need_update = 1;
ctrlr->dev = dev;
cleanup.data = (void *)ctrlr;
list_insert_after(&cleanup.list_node, &cleanup_funcs);
cleanup->cleanup = &nvme_shutdown;
cleanup->types = CleanupOnHandoff | CleanupOnLegacy;
cleanup->data = ctrlr;
list_insert_after(&cleanup->list_node, &cleanup_funcs);
return ctrlr;
}
......@@ -68,12 +68,13 @@
#define writel_with_flush(a,b) do { writel(a, b); readl(b); } while (0)
typedef int NVME_STATUS;
#define NVME_SUCCESS 0
#define NVME_UNSUPPORTED -1
#define NVME_DEVICE_ERROR -2
#define NVME_SUCCESS 0
#define NVME_UNSUPPORTED -1
#define NVME_DEVICE_ERROR -2
#define NVME_OUT_OF_RESOURCES -3
#define NVME_TIMEOUT -4
#define NVME_TIMEOUT -4
#define NVME_INVALID_PARAMETER -5
#define NVME_NOT_FOUND -6
#define NVME_ERROR(err) ((err) < 0?1:0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment