diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-05-27 16:12:46 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-27 13:01:02 -0400 |
commit | 55c06c7171f63aaac1f9009729d1cb5107fa0626 (patch) | |
tree | c43a05724bdc114e50b95d9d33e6ea4a1c0106e8 /drivers/scsi/hpsa.c | |
parent | 1db90ea239b85479daedb978ea2f0a61776f074f (diff) |
[SCSI] hpsa: save pdev pointer in per hba structure early to avoid passing it around so much.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r-- | drivers/scsi/hpsa.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index c016426b31b2..d6f897016e24 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -3209,8 +3209,7 @@ static int find_PCI_BAR_index(struct pci_dev *pdev, unsigned long pci_bar_addr) | |||
3209 | * controllers that are capable. If not, we use IO-APIC mode. | 3209 | * controllers that are capable. If not, we use IO-APIC mode. |
3210 | */ | 3210 | */ |
3211 | 3211 | ||
3212 | static void __devinit hpsa_interrupt_mode(struct ctlr_info *h, | 3212 | static void __devinit hpsa_interrupt_mode(struct ctlr_info *h, u32 board_id) |
3213 | struct pci_dev *pdev, u32 board_id) | ||
3214 | { | 3213 | { |
3215 | #ifdef CONFIG_PCI_MSI | 3214 | #ifdef CONFIG_PCI_MSI |
3216 | int err; | 3215 | int err; |
@@ -3223,9 +3222,9 @@ static void __devinit hpsa_interrupt_mode(struct ctlr_info *h, | |||
3223 | (board_id == 0x40800E11) || | 3222 | (board_id == 0x40800E11) || |
3224 | (board_id == 0x40820E11) || (board_id == 0x40830E11)) | 3223 | (board_id == 0x40820E11) || (board_id == 0x40830E11)) |
3225 | goto default_int_mode; | 3224 | goto default_int_mode; |
3226 | if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { | 3225 | if (pci_find_capability(h->pdev, PCI_CAP_ID_MSIX)) { |
3227 | dev_info(&pdev->dev, "MSIX\n"); | 3226 | dev_info(&h->pdev->dev, "MSIX\n"); |
3228 | err = pci_enable_msix(pdev, hpsa_msix_entries, 4); | 3227 | err = pci_enable_msix(h->pdev, hpsa_msix_entries, 4); |
3229 | if (!err) { | 3228 | if (!err) { |
3230 | h->intr[0] = hpsa_msix_entries[0].vector; | 3229 | h->intr[0] = hpsa_msix_entries[0].vector; |
3231 | h->intr[1] = hpsa_msix_entries[1].vector; | 3230 | h->intr[1] = hpsa_msix_entries[1].vector; |
@@ -3235,29 +3234,29 @@ static void __devinit hpsa_interrupt_mode(struct ctlr_info *h, | |||
3235 | return; | 3234 | return; |
3236 | } | 3235 | } |
3237 | if (err > 0) { | 3236 | if (err > 0) { |
3238 | dev_warn(&pdev->dev, "only %d MSI-X vectors " | 3237 | dev_warn(&h->pdev->dev, "only %d MSI-X vectors " |
3239 | "available\n", err); | 3238 | "available\n", err); |
3240 | goto default_int_mode; | 3239 | goto default_int_mode; |
3241 | } else { | 3240 | } else { |
3242 | dev_warn(&pdev->dev, "MSI-X init failed %d\n", | 3241 | dev_warn(&h->pdev->dev, "MSI-X init failed %d\n", |
3243 | err); | 3242 | err); |
3244 | goto default_int_mode; | 3243 | goto default_int_mode; |
3245 | } | 3244 | } |
3246 | } | 3245 | } |
3247 | if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { | 3246 | if (pci_find_capability(h->pdev, PCI_CAP_ID_MSI)) { |
3248 | dev_info(&pdev->dev, "MSI\n"); | 3247 | dev_info(&h->pdev->dev, "MSI\n"); |
3249 | if (!pci_enable_msi(pdev)) | 3248 | if (!pci_enable_msi(h->pdev)) |
3250 | h->msi_vector = 1; | 3249 | h->msi_vector = 1; |
3251 | else | 3250 | else |
3252 | dev_warn(&pdev->dev, "MSI init failed\n"); | 3251 | dev_warn(&h->pdev->dev, "MSI init failed\n"); |
3253 | } | 3252 | } |
3254 | default_int_mode: | 3253 | default_int_mode: |
3255 | #endif /* CONFIG_PCI_MSI */ | 3254 | #endif /* CONFIG_PCI_MSI */ |
3256 | /* if we get here we're going to use the default interrupt mode */ | 3255 | /* if we get here we're going to use the default interrupt mode */ |
3257 | h->intr[PERF_MODE_INT] = pdev->irq; | 3256 | h->intr[PERF_MODE_INT] = h->pdev->irq; |
3258 | } | 3257 | } |
3259 | 3258 | ||
3260 | static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | 3259 | static int __devinit hpsa_pci_init(struct ctlr_info *h) |
3261 | { | 3260 | { |
3262 | ushort subsystem_vendor_id, subsystem_device_id, command; | 3261 | ushort subsystem_vendor_id, subsystem_device_id, command; |
3263 | u32 board_id, scratchpad = 0; | 3262 | u32 board_id, scratchpad = 0; |
@@ -3267,8 +3266,8 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3267 | u32 trans_offset; | 3266 | u32 trans_offset; |
3268 | int i, prod_index, err; | 3267 | int i, prod_index, err; |
3269 | 3268 | ||
3270 | subsystem_vendor_id = pdev->subsystem_vendor; | 3269 | subsystem_vendor_id = h->pdev->subsystem_vendor; |
3271 | subsystem_device_id = pdev->subsystem_device; | 3270 | subsystem_device_id = h->pdev->subsystem_device; |
3272 | board_id = (((u32) (subsystem_device_id << 16) & 0xffff0000) | | 3271 | board_id = (((u32) (subsystem_device_id << 16) & 0xffff0000) | |
3273 | subsystem_vendor_id); | 3272 | subsystem_vendor_id); |
3274 | 3273 | ||
@@ -3282,7 +3281,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3282 | prod_index--; | 3281 | prod_index--; |
3283 | if (subsystem_vendor_id != PCI_VENDOR_ID_HP || | 3282 | if (subsystem_vendor_id != PCI_VENDOR_ID_HP || |
3284 | !hpsa_allow_any) { | 3283 | !hpsa_allow_any) { |
3285 | dev_warn(&pdev->dev, "unrecognized board ID:" | 3284 | dev_warn(&h->pdev->dev, "unrecognized board ID:" |
3286 | " 0x%08lx, ignoring.\n", | 3285 | " 0x%08lx, ignoring.\n", |
3287 | (unsigned long) board_id); | 3286 | (unsigned long) board_id); |
3288 | return -ENODEV; | 3287 | return -ENODEV; |
@@ -3291,41 +3290,42 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3291 | /* check to see if controller has been disabled | 3290 | /* check to see if controller has been disabled |
3292 | * BEFORE trying to enable it | 3291 | * BEFORE trying to enable it |
3293 | */ | 3292 | */ |
3294 | (void)pci_read_config_word(pdev, PCI_COMMAND, &command); | 3293 | (void)pci_read_config_word(h->pdev, PCI_COMMAND, &command); |
3295 | if (!(command & 0x02)) { | 3294 | if (!(command & 0x02)) { |
3296 | dev_warn(&pdev->dev, "controller appears to be disabled\n"); | 3295 | dev_warn(&h->pdev->dev, "controller appears to be disabled\n"); |
3297 | return -ENODEV; | 3296 | return -ENODEV; |
3298 | } | 3297 | } |
3299 | 3298 | ||
3300 | err = pci_enable_device(pdev); | 3299 | err = pci_enable_device(h->pdev); |
3301 | if (err) { | 3300 | if (err) { |
3302 | dev_warn(&pdev->dev, "unable to enable PCI device\n"); | 3301 | dev_warn(&h->pdev->dev, "unable to enable PCI device\n"); |
3303 | return err; | 3302 | return err; |
3304 | } | 3303 | } |
3305 | 3304 | ||
3306 | err = pci_request_regions(pdev, "hpsa"); | 3305 | err = pci_request_regions(h->pdev, "hpsa"); |
3307 | if (err) { | 3306 | if (err) { |
3308 | dev_err(&pdev->dev, "cannot obtain PCI resources, aborting\n"); | 3307 | dev_err(&h->pdev->dev, |
3308 | "cannot obtain PCI resources, aborting\n"); | ||
3309 | return err; | 3309 | return err; |
3310 | } | 3310 | } |
3311 | 3311 | ||
3312 | /* If the kernel supports MSI/MSI-X we will try to enable that, | 3312 | /* If the kernel supports MSI/MSI-X we will try to enable that, |
3313 | * else we use the IO-APIC interrupt assigned to us by system ROM. | 3313 | * else we use the IO-APIC interrupt assigned to us by system ROM. |
3314 | */ | 3314 | */ |
3315 | hpsa_interrupt_mode(h, pdev, board_id); | 3315 | hpsa_interrupt_mode(h, board_id); |
3316 | 3316 | ||
3317 | /* find the memory BAR */ | 3317 | /* find the memory BAR */ |
3318 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 3318 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
3319 | if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) | 3319 | if (pci_resource_flags(h->pdev, i) & IORESOURCE_MEM) |
3320 | break; | 3320 | break; |
3321 | } | 3321 | } |
3322 | if (i == DEVICE_COUNT_RESOURCE) { | 3322 | if (i == DEVICE_COUNT_RESOURCE) { |
3323 | dev_warn(&pdev->dev, "no memory BAR found\n"); | 3323 | dev_warn(&h->pdev->dev, "no memory BAR found\n"); |
3324 | err = -ENODEV; | 3324 | err = -ENODEV; |
3325 | goto err_out_free_res; | 3325 | goto err_out_free_res; |
3326 | } | 3326 | } |
3327 | 3327 | ||
3328 | h->paddr = pci_resource_start(pdev, i); /* addressing mode bits | 3328 | h->paddr = pci_resource_start(h->pdev, i); /* addressing mode bits |
3329 | * already removed | 3329 | * already removed |
3330 | */ | 3330 | */ |
3331 | 3331 | ||
@@ -3339,7 +3339,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3339 | msleep(HPSA_BOARD_READY_POLL_INTERVAL_MSECS); | 3339 | msleep(HPSA_BOARD_READY_POLL_INTERVAL_MSECS); |
3340 | } | 3340 | } |
3341 | if (scratchpad != HPSA_FIRMWARE_READY) { | 3341 | if (scratchpad != HPSA_FIRMWARE_READY) { |
3342 | dev_warn(&pdev->dev, "board not ready, timed out.\n"); | 3342 | dev_warn(&h->pdev->dev, "board not ready, timed out.\n"); |
3343 | err = -ENODEV; | 3343 | err = -ENODEV; |
3344 | goto err_out_free_res; | 3344 | goto err_out_free_res; |
3345 | } | 3345 | } |
@@ -3347,20 +3347,20 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3347 | /* get the address index number */ | 3347 | /* get the address index number */ |
3348 | cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET); | 3348 | cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET); |
3349 | cfg_base_addr &= (u32) 0x0000ffff; | 3349 | cfg_base_addr &= (u32) 0x0000ffff; |
3350 | cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); | 3350 | cfg_base_addr_index = find_PCI_BAR_index(h->pdev, cfg_base_addr); |
3351 | if (cfg_base_addr_index == -1) { | 3351 | if (cfg_base_addr_index == -1) { |
3352 | dev_warn(&pdev->dev, "cannot find cfg_base_addr_index\n"); | 3352 | dev_warn(&h->pdev->dev, "cannot find cfg_base_addr_index\n"); |
3353 | err = -ENODEV; | 3353 | err = -ENODEV; |
3354 | goto err_out_free_res; | 3354 | goto err_out_free_res; |
3355 | } | 3355 | } |
3356 | 3356 | ||
3357 | cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET); | 3357 | cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET); |
3358 | h->cfgtable = remap_pci_mem(pci_resource_start(pdev, | 3358 | h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, |
3359 | cfg_base_addr_index) + cfg_offset, | 3359 | cfg_base_addr_index) + cfg_offset, |
3360 | sizeof(h->cfgtable)); | 3360 | sizeof(h->cfgtable)); |
3361 | /* Find performant mode table. */ | 3361 | /* Find performant mode table. */ |
3362 | trans_offset = readl(&(h->cfgtable->TransMethodOffset)); | 3362 | trans_offset = readl(&(h->cfgtable->TransMethodOffset)); |
3363 | h->transtable = remap_pci_mem(pci_resource_start(pdev, | 3363 | h->transtable = remap_pci_mem(pci_resource_start(h->pdev, |
3364 | cfg_base_addr_index)+cfg_offset+trans_offset, | 3364 | cfg_base_addr_index)+cfg_offset+trans_offset, |
3365 | sizeof(*h->transtable)); | 3365 | sizeof(*h->transtable)); |
3366 | 3366 | ||
@@ -3392,7 +3392,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3392 | (readb(&h->cfgtable->Signature[1]) != 'I') || | 3392 | (readb(&h->cfgtable->Signature[1]) != 'I') || |
3393 | (readb(&h->cfgtable->Signature[2]) != 'S') || | 3393 | (readb(&h->cfgtable->Signature[2]) != 'S') || |
3394 | (readb(&h->cfgtable->Signature[3]) != 'S')) { | 3394 | (readb(&h->cfgtable->Signature[3]) != 'S')) { |
3395 | dev_warn(&pdev->dev, "not a valid CISS config table\n"); | 3395 | dev_warn(&h->pdev->dev, "not a valid CISS config table\n"); |
3396 | err = -ENODEV; | 3396 | err = -ENODEV; |
3397 | goto err_out_free_res; | 3397 | goto err_out_free_res; |
3398 | } | 3398 | } |
@@ -3434,11 +3434,12 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) | |||
3434 | } | 3434 | } |
3435 | 3435 | ||
3436 | #ifdef HPSA_DEBUG | 3436 | #ifdef HPSA_DEBUG |
3437 | print_cfg_table(&pdev->dev, h->cfgtable); | 3437 | print_cfg_table(&h->pdev->dev, h->cfgtable); |
3438 | #endif /* HPSA_DEBUG */ | 3438 | #endif /* HPSA_DEBUG */ |
3439 | 3439 | ||
3440 | if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) { | 3440 | if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) { |
3441 | dev_warn(&pdev->dev, "unable to get board into simple mode\n"); | 3441 | dev_warn(&h->pdev->dev, |
3442 | "unable to get board into simple mode\n"); | ||
3442 | err = -ENODEV; | 3443 | err = -ENODEV; |
3443 | goto err_out_free_res; | 3444 | goto err_out_free_res; |
3444 | } | 3445 | } |
@@ -3449,7 +3450,7 @@ err_out_free_res: | |||
3449 | * Deliberately omit pci_disable_device(): it does something nasty to | 3450 | * Deliberately omit pci_disable_device(): it does something nasty to |
3450 | * Smart Array controllers that pci_enable_device does not undo | 3451 | * Smart Array controllers that pci_enable_device does not undo |
3451 | */ | 3452 | */ |
3452 | pci_release_regions(pdev); | 3453 | pci_release_regions(h->pdev); |
3453 | return err; | 3454 | return err; |
3454 | } | 3455 | } |
3455 | 3456 | ||
@@ -3507,17 +3508,17 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev, | |||
3507 | if (!h) | 3508 | if (!h) |
3508 | return -ENOMEM; | 3509 | return -ENOMEM; |
3509 | 3510 | ||
3511 | h->pdev = pdev; | ||
3510 | h->busy_initializing = 1; | 3512 | h->busy_initializing = 1; |
3511 | INIT_HLIST_HEAD(&h->cmpQ); | 3513 | INIT_HLIST_HEAD(&h->cmpQ); |
3512 | INIT_HLIST_HEAD(&h->reqQ); | 3514 | INIT_HLIST_HEAD(&h->reqQ); |
3513 | rc = hpsa_pci_init(h, pdev); | 3515 | rc = hpsa_pci_init(h); |
3514 | if (rc != 0) | 3516 | if (rc != 0) |
3515 | goto clean1; | 3517 | goto clean1; |
3516 | 3518 | ||
3517 | sprintf(h->devname, "hpsa%d", number_of_controllers); | 3519 | sprintf(h->devname, "hpsa%d", number_of_controllers); |
3518 | h->ctlr = number_of_controllers; | 3520 | h->ctlr = number_of_controllers; |
3519 | number_of_controllers++; | 3521 | number_of_controllers++; |
3520 | h->pdev = pdev; | ||
3521 | 3522 | ||
3522 | /* configure PCI DMA stuff */ | 3523 | /* configure PCI DMA stuff */ |
3523 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); | 3524 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); |