aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/cciss.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/cciss.c')
-rw-r--r--drivers/block/cciss.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 665a470310a9..b79ce8e960f8 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -199,8 +199,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
199 sector_t total_size, 199 sector_t total_size,
200 unsigned int block_size, InquiryData_struct *inq_buff, 200 unsigned int block_size, InquiryData_struct *inq_buff,
201 drive_info_struct *drv); 201 drive_info_struct *drv);
202static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, 202static void __devinit cciss_interrupt_mode(ctlr_info_t *, __u32);
203 __u32);
204static void start_io(ctlr_info_t *h); 203static void start_io(ctlr_info_t *h);
205static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, 204static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
206 __u8 page_code, unsigned char scsi3addr[], 205 __u8 page_code, unsigned char scsi3addr[],
@@ -3933,8 +3932,7 @@ clean_up:
3933 * controllers that are capable. If not, we use IO-APIC mode. 3932 * controllers that are capable. If not, we use IO-APIC mode.
3934 */ 3933 */
3935 3934
3936static void __devinit cciss_interrupt_mode(ctlr_info_t *c, 3935static void __devinit cciss_interrupt_mode(ctlr_info_t *c, __u32 board_id)
3937 struct pci_dev *pdev, __u32 board_id)
3938{ 3936{
3939#ifdef CONFIG_PCI_MSI 3937#ifdef CONFIG_PCI_MSI
3940 int err; 3938 int err;
@@ -3948,8 +3946,8 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
3948 (board_id == 0x40820E11) || (board_id == 0x40830E11)) 3946 (board_id == 0x40820E11) || (board_id == 0x40830E11))
3949 goto default_int_mode; 3947 goto default_int_mode;
3950 3948
3951 if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { 3949 if (pci_find_capability(c->pdev, PCI_CAP_ID_MSIX)) {
3952 err = pci_enable_msix(pdev, cciss_msix_entries, 4); 3950 err = pci_enable_msix(c->pdev, cciss_msix_entries, 4);
3953 if (!err) { 3951 if (!err) {
3954 c->intr[0] = cciss_msix_entries[0].vector; 3952 c->intr[0] = cciss_msix_entries[0].vector;
3955 c->intr[1] = cciss_msix_entries[1].vector; 3953 c->intr[1] = cciss_msix_entries[1].vector;
@@ -3968,8 +3966,8 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
3968 goto default_int_mode; 3966 goto default_int_mode;
3969 } 3967 }
3970 } 3968 }
3971 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { 3969 if (pci_find_capability(c->pdev, PCI_CAP_ID_MSI)) {
3972 if (!pci_enable_msi(pdev)) { 3970 if (!pci_enable_msi(c->pdev)) {
3973 c->msi_vector = 1; 3971 c->msi_vector = 1;
3974 } else { 3972 } else {
3975 printk(KERN_WARNING "cciss: MSI init failed\n"); 3973 printk(KERN_WARNING "cciss: MSI init failed\n");
@@ -3978,11 +3976,11 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
3978default_int_mode: 3976default_int_mode:
3979#endif /* CONFIG_PCI_MSI */ 3977#endif /* CONFIG_PCI_MSI */
3980 /* if we get here we're going to use the default interrupt mode */ 3978 /* if we get here we're going to use the default interrupt mode */
3981 c->intr[PERF_MODE_INT] = pdev->irq; 3979 c->intr[PERF_MODE_INT] = c->pdev->irq;
3982 return; 3980 return;
3983} 3981}
3984 3982
3985static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) 3983static int __devinit cciss_pci_init(ctlr_info_t *c)
3986{ 3984{
3987 ushort subsystem_vendor_id, subsystem_device_id, command; 3985 ushort subsystem_vendor_id, subsystem_device_id, command;
3988 __u32 board_id, scratchpad = 0; 3986 __u32 board_id, scratchpad = 0;
@@ -3992,8 +3990,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3992 int i, prod_index, err; 3990 int i, prod_index, err;
3993 __u32 trans_offset; 3991 __u32 trans_offset;
3994 3992
3995 subsystem_vendor_id = pdev->subsystem_vendor; 3993 subsystem_vendor_id = c->pdev->subsystem_vendor;
3996 subsystem_device_id = pdev->subsystem_device; 3994 subsystem_device_id = c->pdev->subsystem_device;
3997 board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | 3995 board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) |
3998 subsystem_vendor_id); 3996 subsystem_vendor_id);
3999 3997
@@ -4006,7 +4004,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
4006 } 4004 }
4007 prod_index = i; 4005 prod_index = i;
4008 if (prod_index == ARRAY_SIZE(products)) { 4006 if (prod_index == ARRAY_SIZE(products)) {
4009 dev_warn(&pdev->dev, 4007 dev_warn(&c->pdev->dev,
4010 "unrecognized board ID: 0x%08lx, ignoring.\n", 4008 "unrecognized board ID: 0x%08lx, ignoring.\n",
4011 (unsigned long) board_id); 4009 (unsigned long) board_id);
4012 return -ENODEV; 4010 return -ENODEV;
@@ -4014,20 +4012,20 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
4014 4012
4015 /* check to see if controller has been disabled */ 4013 /* check to see if controller has been disabled */
4016 /* BEFORE trying to enable it */ 4014 /* BEFORE trying to enable it */
4017 (void)pci_read_config_word(pdev, PCI_COMMAND, &command); 4015 (void)pci_read_config_word(c->pdev, PCI_COMMAND, &command);
4018 if (!(command & 0x02)) { 4016 if (!(command & 0x02)) {
4019 printk(KERN_WARNING 4017 printk(KERN_WARNING
4020 "cciss: controller appears to be disabled\n"); 4018 "cciss: controller appears to be disabled\n");
4021 return -ENODEV; 4019 return -ENODEV;
4022 } 4020 }
4023 4021
4024 err = pci_enable_device(pdev); 4022 err = pci_enable_device(c->pdev);
4025 if (err) { 4023 if (err) {
4026 printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); 4024 printk(KERN_ERR "cciss: Unable to Enable PCI device\n");
4027 return err; 4025 return err;
4028 } 4026 }
4029 4027
4030 err = pci_request_regions(pdev, "cciss"); 4028 err = pci_request_regions(c->pdev, "cciss");
4031 if (err) { 4029 if (err) {
4032 printk(KERN_ERR "cciss: Cannot obtain PCI resources, " 4030 printk(KERN_ERR "cciss: Cannot obtain PCI resources, "
4033 "aborting\n"); 4031 "aborting\n");
@@ -4035,19 +4033,19 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
4035 } 4033 }
4036 4034
4037#ifdef CCISS_DEBUG 4035#ifdef CCISS_DEBUG
4038 printk("command = %x\n", command); 4036 printk(KERN_INFO "command = %x\n", command);
4039 printk("irq = %x\n", pdev->irq); 4037 printk(KERN_INFO "irq = %x\n", c->pdev->irq);
4040 printk("board_id = %x\n", board_id); 4038 printk(KERN_INFO "board_id = %x\n", board_id);
4041#endif /* CCISS_DEBUG */ 4039#endif /* CCISS_DEBUG */
4042 4040
4043/* If the kernel supports MSI/MSI-X we will try to enable that functionality, 4041/* If the kernel supports MSI/MSI-X we will try to enable that functionality,
4044 * else we use the IO-APIC interrupt assigned to us by system ROM. 4042 * else we use the IO-APIC interrupt assigned to us by system ROM.
4045 */ 4043 */
4046 cciss_interrupt_mode(c, pdev, board_id); 4044 cciss_interrupt_mode(c, board_id);
4047 4045
4048 /* find the memory BAR */ 4046 /* find the memory BAR */
4049 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 4047 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
4050 if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) 4048 if (pci_resource_flags(c->pdev, i) & IORESOURCE_MEM)
4051 break; 4049 break;
4052 } 4050 }
4053 if (i == DEVICE_COUNT_RESOURCE) { 4051 if (i == DEVICE_COUNT_RESOURCE) {
@@ -4056,7 +4054,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
4056 goto err_out_free_res; 4054 goto err_out_free_res;
4057 } 4055 }
4058 4056
4059 c->paddr = pci_resource_start(pdev, i); /* addressing mode bits 4057 c->paddr = pci_resource_start(c->pdev, i); /* addressing mode bits
4060 * already removed 4058 * already removed
4061 */ 4059 */
4062 4060
@@ -4086,7 +4084,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
4086#ifdef CCISS_DEBUG 4084#ifdef CCISS_DEBUG
4087 printk("cfg base address = %x\n", cfg_base_addr); 4085 printk("cfg base address = %x\n", cfg_base_addr);
4088#endif /* CCISS_DEBUG */ 4086#endif /* CCISS_DEBUG */
4089 cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); 4087 cfg_base_addr_index = find_PCI_BAR_index(c->pdev, cfg_base_addr);
4090#ifdef CCISS_DEBUG 4088#ifdef CCISS_DEBUG
4091 printk("cfg base address index = %llx\n", 4089 printk("cfg base address index = %llx\n",
4092 (unsigned long long)cfg_base_addr_index); 4090 (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#ifdef CCISS_DEBUG 4099#ifdef CCISS_DEBUG
4102 printk("cfg offset = %llx\n", (unsigned long long)cfg_offset); 4100 printk("cfg offset = %llx\n", (unsigned long long)cfg_offset);
4103#endif /* CCISS_DEBUG */ 4101#endif /* CCISS_DEBUG */
4104 c->cfgtable = remap_pci_mem(pci_resource_start(pdev, 4102 c->cfgtable = remap_pci_mem(pci_resource_start(c->pdev,
4105 cfg_base_addr_index) + 4103 cfg_base_addr_index) +
4106 cfg_offset, sizeof(CfgTable_struct)); 4104 cfg_offset, sizeof(CfgTable_struct));
4107 /* Find performant mode table. */ 4105 /* Find performant mode table. */
4108 trans_offset = readl(&(c->cfgtable->TransMethodOffset)); 4106 trans_offset = readl(&(c->cfgtable->TransMethodOffset));
4109 c->transtable = remap_pci_mem(pci_resource_start(pdev, 4107 c->transtable = remap_pci_mem(pci_resource_start(c->pdev,
4110 cfg_base_addr_index) + cfg_offset+trans_offset, 4108 cfg_base_addr_index) + cfg_offset+trans_offset,
4111 sizeof(*c->transtable)); 4109 sizeof(*c->transtable));
4112 c->board_id = board_id; 4110 c->board_id = board_id;
@@ -4173,9 +4171,11 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
4173 dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG); 4171 dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
4174 dma_prefetch |= 0x8000; 4172 dma_prefetch |= 0x8000;
4175 writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG); 4173 writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG);
4176 pci_read_config_dword(pdev, PCI_COMMAND_PARITY, &dma_refetch); 4174 pci_read_config_dword(c->pdev, PCI_COMMAND_PARITY,
4175 &dma_refetch);
4177 dma_refetch |= 0x1; 4176 dma_refetch |= 0x1;
4178 pci_write_config_dword(pdev, PCI_COMMAND_PARITY, dma_refetch); 4177 pci_write_config_dword(c->pdev, PCI_COMMAND_PARITY,
4178 dma_refetch);
4179 } 4179 }
4180 4180
4181#ifdef CCISS_DEBUG 4181#ifdef CCISS_DEBUG
@@ -4189,7 +4189,7 @@ err_out_free_res:
4189 * Deliberately omit pci_disable_device(): it does something nasty to 4189 * Deliberately omit pci_disable_device(): it does something nasty to
4190 * Smart Array controllers that pci_enable_device does not undo 4190 * Smart Array controllers that pci_enable_device does not undo
4191 */ 4191 */
4192 pci_release_regions(pdev); 4192 pci_release_regions(c->pdev);
4193 return err; 4193 return err;
4194} 4194}
4195 4195
@@ -4466,17 +4466,18 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
4466 i = alloc_cciss_hba(); 4466 i = alloc_cciss_hba();
4467 if (i < 0) 4467 if (i < 0)
4468 return -1; 4468 return -1;
4469
4470 hba[i]->pdev = pdev;
4469 hba[i]->busy_initializing = 1; 4471 hba[i]->busy_initializing = 1;
4470 INIT_HLIST_HEAD(&hba[i]->cmpQ); 4472 INIT_HLIST_HEAD(&hba[i]->cmpQ);
4471 INIT_HLIST_HEAD(&hba[i]->reqQ); 4473 INIT_HLIST_HEAD(&hba[i]->reqQ);
4472 mutex_init(&hba[i]->busy_shutting_down); 4474 mutex_init(&hba[i]->busy_shutting_down);
4473 4475
4474 if (cciss_pci_init(hba[i], pdev) != 0) 4476 if (cciss_pci_init(hba[i]) != 0)
4475 goto clean_no_release_regions; 4477 goto clean_no_release_regions;
4476 4478
4477 sprintf(hba[i]->devname, "cciss%d", i); 4479 sprintf(hba[i]->devname, "cciss%d", i);
4478 hba[i]->ctlr = i; 4480 hba[i]->ctlr = i;
4479 hba[i]->pdev = pdev;
4480 4481
4481 init_completion(&hba[i]->scan_wait); 4482 init_completion(&hba[i]->scan_wait);
4482 4483