From d9c37390c4f02153188a64a7a89fa6798dc3ffc2 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 3 Mar 2011 17:59:32 -0800 Subject: isci: preallocate remote devices Until we synchronize against device removal this limits the damage of use after free bugs to the driver's own objects. Unless we implement reference counting we need to ensure at least a subset of a remote device is valid at all times. We follow the lead of other libsas drivers that also preallocate devices. This also enforces maximum remote device accounting at the lldd layer, but the core may still run out of RNC's before we hit this limit. Signed-off-by: Dan Williams --- drivers/scsi/isci/host.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/isci/host.c') diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 8d255666a657..ae5d46022073 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c @@ -378,8 +378,7 @@ static void __iomem *smu_base(struct isci_host *isci_host) int isci_host_init(struct isci_host *isci_host) { - int err = 0; - int index = 0; + int err = 0, i; enum sci_status status; struct scic_sds_controller *controller; union scic_oem_parameters scic_oem_params; @@ -509,13 +508,19 @@ int isci_host_init(struct isci_host *isci_host) if (!isci_host->dma_pool) return -ENOMEM; - for (index = 0; index < SCI_MAX_PORTS; index++) - isci_port_init(&isci_host->isci_ports[index], - isci_host, - index); + for (i = 0; i < SCI_MAX_PORTS; i++) + isci_port_init(&isci_host->isci_ports[i], isci_host, i); - for (index = 0; index < SCI_MAX_PHYS; index++) - isci_phy_init(&isci_host->phys[index], isci_host, index); + for (i = 0; i < SCI_MAX_PHYS; i++) + isci_phy_init(&isci_host->phys[i], isci_host, i); + + for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { + struct isci_remote_device *idev = idev_by_id(isci_host, i); + + INIT_LIST_HEAD(&idev->reqs_in_process); + INIT_LIST_HEAD(&idev->node); + spin_lock_init(&idev->state_lock); + } return 0; } -- cgit v1.2.3