Commit 30c7c6df authored by Ben Collins's avatar Ben Collins Committed by Ben Hutchings

megaraid: Use resource_size_t for PCI resources, not long

commit 11f8a7b3 upstream.

The assumption that sizeof(long) >= sizeof(resource_size_t) can lead to
truncation of the PCI resource address, meaning this driver didn't work
on 32-bit systems with 64-bit PCI adressing ranges.
Signed-off-by: default avatarBen Collins <ben.c@servergy.com>
Acked-by: default avatarSumit Saxena <sumit.saxena@lsi.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent c8d446a0
...@@ -1295,7 +1295,6 @@ struct megasas_instance { ...@@ -1295,7 +1295,6 @@ struct megasas_instance {
u32 *reply_queue; u32 *reply_queue;
dma_addr_t reply_queue_h; dma_addr_t reply_queue_h;
unsigned long base_addr;
struct megasas_register_set __iomem *reg_set; struct megasas_register_set __iomem *reg_set;
struct megasas_pd_list pd_list[MEGASAS_MAX_PD]; struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
......
...@@ -3499,6 +3499,7 @@ static int megasas_init_fw(struct megasas_instance *instance) ...@@ -3499,6 +3499,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
u32 max_sectors_1; u32 max_sectors_1;
u32 max_sectors_2; u32 max_sectors_2;
u32 tmp_sectors, msix_enable; u32 tmp_sectors, msix_enable;
resource_size_t base_addr;
struct megasas_register_set __iomem *reg_set; struct megasas_register_set __iomem *reg_set;
struct megasas_ctrl_info *ctrl_info; struct megasas_ctrl_info *ctrl_info;
unsigned long bar_list; unsigned long bar_list;
...@@ -3507,14 +3508,14 @@ static int megasas_init_fw(struct megasas_instance *instance) ...@@ -3507,14 +3508,14 @@ static int megasas_init_fw(struct megasas_instance *instance)
/* Find first memory bar */ /* Find first memory bar */
bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
instance->bar = find_first_bit(&bar_list, sizeof(unsigned long)); instance->bar = find_first_bit(&bar_list, sizeof(unsigned long));
instance->base_addr = pci_resource_start(instance->pdev, instance->bar);
if (pci_request_selected_regions(instance->pdev, instance->bar, if (pci_request_selected_regions(instance->pdev, instance->bar,
"megasas: LSI")) { "megasas: LSI")) {
printk(KERN_DEBUG "megasas: IO memory region busy!\n"); printk(KERN_DEBUG "megasas: IO memory region busy!\n");
return -EBUSY; return -EBUSY;
} }
instance->reg_set = ioremap_nocache(instance->base_addr, 8192); base_addr = pci_resource_start(instance->pdev, instance->bar);
instance->reg_set = ioremap_nocache(base_addr, 8192);
if (!instance->reg_set) { if (!instance->reg_set) {
printk(KERN_DEBUG "megasas: Failed to map IO mem\n"); printk(KERN_DEBUG "megasas: Failed to map IO mem\n");
......
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