Commit 4e570309e80f7c7a532fe0074e74df26ff8ef5d2

Authored by Bjorn Helgaas
Committed by Linus Torvalds
1 parent c33ac89bc7

[PATCH] CCISS: request all PCI resources

We should call pci_request_regions() to claim all resources the device
decodes.  Previously, we claimed only the I/O port range.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
Acked-by: Mike Miller <mike.miller@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 2 changed files with 18 additions and 46 deletions Side-by-side Diff

drivers/block/cciss.c
... ... @@ -2638,16 +2638,6 @@
2638 2638 }
2639 2639 #endif /* CCISS_DEBUG */
2640 2640  
2641   -static void release_io_mem(ctlr_info_t *c)
2642   -{
2643   - /* if IO mem was not protected do nothing */
2644   - if( c->io_mem_addr == 0)
2645   - return;
2646   - release_region(c->io_mem_addr, c->io_mem_length);
2647   - c->io_mem_addr = 0;
2648   - c->io_mem_length = 0;
2649   -}
2650   -
2651 2641 static int find_PCI_BAR_index(struct pci_dev *pdev,
2652 2642 unsigned long pci_bar_addr)
2653 2643 {
2654 2644  
2655 2645  
... ... @@ -2762,37 +2752,19 @@
2762 2752 return err;
2763 2753 }
2764 2754  
  2755 + err = pci_request_regions(pdev, "cciss");
  2756 + if (err) {
  2757 + printk(KERN_ERR "cciss: Cannot obtain PCI resources, "
  2758 + "aborting\n");
  2759 + goto err_out_disable_pdev;
  2760 + }
  2761 +
2765 2762 subsystem_vendor_id = pdev->subsystem_vendor;
2766 2763 subsystem_device_id = pdev->subsystem_device;
2767 2764 board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) |
2768 2765 subsystem_vendor_id);
2769 2766  
2770   - /* search for our IO range so we can protect it */
2771   - for(i=0; i<DEVICE_COUNT_RESOURCE; i++)
2772   - {
2773   - /* is this an IO range */
2774   - if( pci_resource_flags(pdev, i) & 0x01 ) {
2775   - c->io_mem_addr = pci_resource_start(pdev, i);
2776   - c->io_mem_length = pci_resource_end(pdev, i) -
2777   - pci_resource_start(pdev, i) +1;
2778 2767 #ifdef CCISS_DEBUG
2779   - printk("IO value found base_addr[%d] %lx %lx\n", i,
2780   - c->io_mem_addr, c->io_mem_length);
2781   -#endif /* CCISS_DEBUG */
2782   - /* register the IO range */
2783   - if(!request_region( c->io_mem_addr,
2784   - c->io_mem_length, "cciss"))
2785   - {
2786   - printk(KERN_WARNING "cciss I/O memory range already in use addr=%lx length=%ld\n",
2787   - c->io_mem_addr, c->io_mem_length);
2788   - c->io_mem_addr= 0;
2789   - c->io_mem_length = 0;
2790   - }
2791   - break;
2792   - }
2793   - }
2794   -
2795   -#ifdef CCISS_DEBUG
2796 2768 printk("command = %x\n", command);
2797 2769 printk("irq = %x\n", pdev->irq);
2798 2770 printk("board_id = %x\n", board_id);
... ... @@ -2826,7 +2798,7 @@
2826 2798 if (scratchpad != CCISS_FIRMWARE_READY) {
2827 2799 printk(KERN_WARNING "cciss: Board not ready. Timed out.\n");
2828 2800 err = -ENODEV;
2829   - goto err_out_disable_pdev;
  2801 + goto err_out_free_res;
2830 2802 }
2831 2803  
2832 2804 /* get the address index number */
2833 2805  
... ... @@ -2842,9 +2814,8 @@
2842 2814 #endif /* CCISS_DEBUG */
2843 2815 if (cfg_base_addr_index == -1) {
2844 2816 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
2845   - release_io_mem(c);
2846 2817 err = -ENODEV;
2847   - goto err_out_disable_pdev;
  2818 + goto err_out_free_res;
2848 2819 }
2849 2820  
2850 2821 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
... ... @@ -2872,7 +2843,7 @@
2872 2843 " to access the Smart Array controller %08lx\n",
2873 2844 (unsigned long)board_id);
2874 2845 err = -ENODEV;
2875   - goto err_out_disable_pdev;
  2846 + goto err_out_free_res;
2876 2847 }
2877 2848 if ( (readb(&c->cfgtable->Signature[0]) != 'C') ||
2878 2849 (readb(&c->cfgtable->Signature[1]) != 'I') ||
... ... @@ -2881,7 +2852,7 @@
2881 2852 {
2882 2853 printk("Does not appear to be a valid CISS config table\n");
2883 2854 err = -ENODEV;
2884   - goto err_out_disable_pdev;
  2855 + goto err_out_free_res;
2885 2856 }
2886 2857  
2887 2858 #ifdef CONFIG_X86
2888 2859  
... ... @@ -2926,10 +2897,13 @@
2926 2897 printk(KERN_WARNING "cciss: unable to get board into"
2927 2898 " simple mode\n");
2928 2899 err = -ENODEV;
2929   - goto err_out_disable_pdev;
  2900 + goto err_out_free_res;
2930 2901 }
2931 2902 return 0;
2932 2903  
  2904 +err_out_free_res:
  2905 + pci_release_regions(pdev);
  2906 +
2933 2907 err_out_disable_pdev:
2934 2908 pci_disable_device(pdev);
2935 2909 return err;
... ... @@ -3276,7 +3250,6 @@
3276 3250 clean2:
3277 3251 unregister_blkdev(hba[i]->major, hba[i]->devname);
3278 3252 clean1:
3279   - release_io_mem(hba[i]);
3280 3253 hba[i]->busy_initializing = 0;
3281 3254 free_hba(i);
3282 3255 return(-1);
... ... @@ -3322,7 +3295,6 @@
3322 3295 pci_disable_msi(hba[i]->pdev);
3323 3296 #endif /* CONFIG_PCI_MSI */
3324 3297  
3325   - pci_set_drvdata(pdev, NULL);
3326 3298 iounmap(hba[i]->vaddr);
3327 3299 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */
3328 3300 unregister_blkdev(hba[i]->major, hba[i]->devname);
... ... @@ -3349,7 +3321,9 @@
3349 3321 #ifdef CONFIG_CISS_SCSI_TAPE
3350 3322 kfree(hba[i]->scsi_rejects.complete);
3351 3323 #endif
3352   - release_io_mem(hba[i]);
  3324 + pci_release_regions(pdev);
  3325 + pci_disable_device(pdev);
  3326 + pci_set_drvdata(pdev, NULL);
3353 3327 free_hba(i);
3354 3328 }
3355 3329  
drivers/block/cciss.h
... ... @@ -60,8 +60,6 @@
60 60 __u32 board_id;
61 61 void __iomem *vaddr;
62 62 unsigned long paddr;
63   - unsigned long io_mem_addr;
64   - unsigned long io_mem_length;
65 63 CfgTable_struct __iomem *cfgtable;
66 64 int interrupts_enabled;
67 65 int major;