Commit 292e50dd authored by Stephen M. Cameron's avatar Stephen M. Cameron Committed by Jens Axboe

cciss: save pdev pointer in per hba structure early to avoid passing it around so much.

cciss: save pdev pointer in per hba structure early to avoid passing it around so much.
Signed-off-by: default avatarStephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent 373b45f7
...@@ -199,8 +199,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol, ...@@ -199,8 +199,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
sector_t total_size, sector_t total_size,
unsigned int block_size, InquiryData_struct *inq_buff, unsigned int block_size, InquiryData_struct *inq_buff,
drive_info_struct *drv); drive_info_struct *drv);
static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, static void __devinit cciss_interrupt_mode(ctlr_info_t *, __u32);
__u32);
static void start_io(ctlr_info_t *h); static void start_io(ctlr_info_t *h);
static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
__u8 page_code, unsigned char scsi3addr[], __u8 page_code, unsigned char scsi3addr[],
...@@ -3933,8 +3932,7 @@ cciss_put_controller_into_performant_mode(ctlr_info_t *h) ...@@ -3933,8 +3932,7 @@ cciss_put_controller_into_performant_mode(ctlr_info_t *h)
* controllers that are capable. If not, we use IO-APIC mode. * controllers that are capable. If not, we use IO-APIC mode.
*/ */
static void __devinit cciss_interrupt_mode(ctlr_info_t *c, static void __devinit cciss_interrupt_mode(ctlr_info_t *c, __u32 board_id)
struct pci_dev *pdev, __u32 board_id)
{ {
#ifdef CONFIG_PCI_MSI #ifdef CONFIG_PCI_MSI
int err; int err;
...@@ -3948,8 +3946,8 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c, ...@@ -3948,8 +3946,8 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
(board_id == 0x40820E11) || (board_id == 0x40830E11)) (board_id == 0x40820E11) || (board_id == 0x40830E11))
goto default_int_mode; goto default_int_mode;
if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { if (pci_find_capability(c->pdev, PCI_CAP_ID_MSIX)) {
err = pci_enable_msix(pdev, cciss_msix_entries, 4); err = pci_enable_msix(c->pdev, cciss_msix_entries, 4);
if (!err) { if (!err) {
c->intr[0] = cciss_msix_entries[0].vector; c->intr[0] = cciss_msix_entries[0].vector;
c->intr[1] = cciss_msix_entries[1].vector; c->intr[1] = cciss_msix_entries[1].vector;
...@@ -3968,8 +3966,8 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c, ...@@ -3968,8 +3966,8 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
goto default_int_mode; goto default_int_mode;
} }
} }
if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { if (pci_find_capability(c->pdev, PCI_CAP_ID_MSI)) {
if (!pci_enable_msi(pdev)) { if (!pci_enable_msi(c->pdev)) {
c->msi_vector = 1; c->msi_vector = 1;
} else { } else {
printk(KERN_WARNING "cciss: MSI init failed\n"); printk(KERN_WARNING "cciss: MSI init failed\n");
...@@ -3978,11 +3976,11 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c, ...@@ -3978,11 +3976,11 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
default_int_mode: default_int_mode:
#endif /* CONFIG_PCI_MSI */ #endif /* CONFIG_PCI_MSI */
/* if we get here we're going to use the default interrupt mode */ /* if we get here we're going to use the default interrupt mode */
c->intr[PERF_MODE_INT] = pdev->irq; c->intr[PERF_MODE_INT] = c->pdev->irq;
return; return;
} }
static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) static int __devinit cciss_pci_init(ctlr_info_t *c)
{ {
ushort subsystem_vendor_id, subsystem_device_id, command; ushort subsystem_vendor_id, subsystem_device_id, command;
__u32 board_id, scratchpad = 0; __u32 board_id, scratchpad = 0;
...@@ -3992,8 +3990,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -3992,8 +3990,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
int i, prod_index, err; int i, prod_index, err;
__u32 trans_offset; __u32 trans_offset;
subsystem_vendor_id = pdev->subsystem_vendor; subsystem_vendor_id = c->pdev->subsystem_vendor;
subsystem_device_id = pdev->subsystem_device; subsystem_device_id = c->pdev->subsystem_device;
board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) |
subsystem_vendor_id); subsystem_vendor_id);
...@@ -4006,7 +4004,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4006,7 +4004,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
} }
prod_index = i; prod_index = i;
if (prod_index == ARRAY_SIZE(products)) { if (prod_index == ARRAY_SIZE(products)) {
dev_warn(&pdev->dev, dev_warn(&c->pdev->dev,
"unrecognized board ID: 0x%08lx, ignoring.\n", "unrecognized board ID: 0x%08lx, ignoring.\n",
(unsigned long) board_id); (unsigned long) board_id);
return -ENODEV; return -ENODEV;
...@@ -4014,20 +4012,20 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4014,20 +4012,20 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
/* check to see if controller has been disabled */ /* check to see if controller has been disabled */
/* BEFORE trying to enable it */ /* BEFORE trying to enable it */
(void)pci_read_config_word(pdev, PCI_COMMAND, &command); (void)pci_read_config_word(c->pdev, PCI_COMMAND, &command);
if (!(command & 0x02)) { if (!(command & 0x02)) {
printk(KERN_WARNING printk(KERN_WARNING
"cciss: controller appears to be disabled\n"); "cciss: controller appears to be disabled\n");
return -ENODEV; return -ENODEV;
} }
err = pci_enable_device(pdev); err = pci_enable_device(c->pdev);
if (err) { if (err) {
printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); printk(KERN_ERR "cciss: Unable to Enable PCI device\n");
return err; return err;
} }
err = pci_request_regions(pdev, "cciss"); err = pci_request_regions(c->pdev, "cciss");
if (err) { if (err) {
printk(KERN_ERR "cciss: Cannot obtain PCI resources, " printk(KERN_ERR "cciss: Cannot obtain PCI resources, "
"aborting\n"); "aborting\n");
...@@ -4035,19 +4033,19 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4035,19 +4033,19 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
} }
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
printk("command = %x\n", command); printk(KERN_INFO "command = %x\n", command);
printk("irq = %x\n", pdev->irq); printk(KERN_INFO "irq = %x\n", c->pdev->irq);
printk("board_id = %x\n", board_id); printk(KERN_INFO "board_id = %x\n", board_id);
#endif /* CCISS_DEBUG */ #endif /* CCISS_DEBUG */
/* If the kernel supports MSI/MSI-X we will try to enable that functionality, /* If the kernel supports MSI/MSI-X we will try to enable that functionality,
* else we use the IO-APIC interrupt assigned to us by system ROM. * else we use the IO-APIC interrupt assigned to us by system ROM.
*/ */
cciss_interrupt_mode(c, pdev, board_id); cciss_interrupt_mode(c, board_id);
/* find the memory BAR */ /* find the memory BAR */
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) if (pci_resource_flags(c->pdev, i) & IORESOURCE_MEM)
break; break;
} }
if (i == DEVICE_COUNT_RESOURCE) { if (i == DEVICE_COUNT_RESOURCE) {
...@@ -4056,7 +4054,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4056,7 +4054,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
goto err_out_free_res; goto err_out_free_res;
} }
c->paddr = pci_resource_start(pdev, i); /* addressing mode bits c->paddr = pci_resource_start(c->pdev, i); /* addressing mode bits
* already removed * already removed
*/ */
...@@ -4086,7 +4084,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4086,7 +4084,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
printk("cfg base address = %x\n", cfg_base_addr); printk("cfg base address = %x\n", cfg_base_addr);
#endif /* CCISS_DEBUG */ #endif /* CCISS_DEBUG */
cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); cfg_base_addr_index = find_PCI_BAR_index(c->pdev, cfg_base_addr);
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
printk("cfg base address index = %llx\n", printk("cfg base address index = %llx\n",
(unsigned long long)cfg_base_addr_index); (unsigned long long)cfg_base_addr_index);
...@@ -4101,12 +4099,12 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4101,12 +4099,12 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
printk("cfg offset = %llx\n", (unsigned long long)cfg_offset); printk("cfg offset = %llx\n", (unsigned long long)cfg_offset);
#endif /* CCISS_DEBUG */ #endif /* CCISS_DEBUG */
c->cfgtable = remap_pci_mem(pci_resource_start(pdev, c->cfgtable = remap_pci_mem(pci_resource_start(c->pdev,
cfg_base_addr_index) + cfg_base_addr_index) +
cfg_offset, sizeof(CfgTable_struct)); cfg_offset, sizeof(CfgTable_struct));
/* Find performant mode table. */ /* Find performant mode table. */
trans_offset = readl(&(c->cfgtable->TransMethodOffset)); trans_offset = readl(&(c->cfgtable->TransMethodOffset));
c->transtable = remap_pci_mem(pci_resource_start(pdev, c->transtable = remap_pci_mem(pci_resource_start(c->pdev,
cfg_base_addr_index) + cfg_offset+trans_offset, cfg_base_addr_index) + cfg_offset+trans_offset,
sizeof(*c->transtable)); sizeof(*c->transtable));
c->board_id = board_id; c->board_id = board_id;
...@@ -4173,9 +4171,11 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4173,9 +4171,11 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG); dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
dma_prefetch |= 0x8000; dma_prefetch |= 0x8000;
writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG); writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG);
pci_read_config_dword(pdev, PCI_COMMAND_PARITY, &dma_refetch); pci_read_config_dword(c->pdev, PCI_COMMAND_PARITY,
&dma_refetch);
dma_refetch |= 0x1; dma_refetch |= 0x1;
pci_write_config_dword(pdev, PCI_COMMAND_PARITY, dma_refetch); pci_write_config_dword(c->pdev, PCI_COMMAND_PARITY,
dma_refetch);
} }
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
...@@ -4189,7 +4189,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) ...@@ -4189,7 +4189,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
* Deliberately omit pci_disable_device(): it does something nasty to * Deliberately omit pci_disable_device(): it does something nasty to
* Smart Array controllers that pci_enable_device does not undo * Smart Array controllers that pci_enable_device does not undo
*/ */
pci_release_regions(pdev); pci_release_regions(c->pdev);
return err; return err;
} }
...@@ -4466,17 +4466,18 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, ...@@ -4466,17 +4466,18 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
i = alloc_cciss_hba(); i = alloc_cciss_hba();
if (i < 0) if (i < 0)
return -1; return -1;
hba[i]->pdev = pdev;
hba[i]->busy_initializing = 1; hba[i]->busy_initializing = 1;
INIT_HLIST_HEAD(&hba[i]->cmpQ); INIT_HLIST_HEAD(&hba[i]->cmpQ);
INIT_HLIST_HEAD(&hba[i]->reqQ); INIT_HLIST_HEAD(&hba[i]->reqQ);
mutex_init(&hba[i]->busy_shutting_down); mutex_init(&hba[i]->busy_shutting_down);
if (cciss_pci_init(hba[i], pdev) != 0) if (cciss_pci_init(hba[i]) != 0)
goto clean_no_release_regions; goto clean_no_release_regions;
sprintf(hba[i]->devname, "cciss%d", i); sprintf(hba[i]->devname, "cciss%d", i);
hba[i]->ctlr = i; hba[i]->ctlr = i;
hba[i]->pdev = pdev;
init_completion(&hba[i]->scan_wait); init_completion(&hba[i]->scan_wait);
......
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