James/Linux-scsi, The following patch modifies the megaraid_sas driver to select the lowest memory bar available so the driver will work in SR-IOV VF environments where the memory bar mapping changes. Signed-off-by: Adam Radford <aradford@xxxxxxxxx> Note: The patch has been included in-line below, and also as an attachment in case Gmail hoses the patch. diff -Naur linux-2.6.37-rc5.old/drivers/scsi/megaraid/megaraid_sas_base.c linux-2.6.37-rc5.new/drivers/scsi/megaraid/megaraid_sas_base.c --- linux-2.6.37-rc5.old/drivers/scsi/megaraid/megaraid_sas_base.c 2010-12-14 16:15:22.000000000 -0800 +++ linux-2.6.37-rc5.new/drivers/scsi/megaraid/megaraid_sas_base.c 2010-12-14 16:18:40.000000000 -0800 @@ -3236,21 +3236,14 @@ u32 tmp_sectors; struct megasas_register_set __iomem *reg_set; struct megasas_ctrl_info *ctrl_info; - /* - * Map the message registers - */ - if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1078GEN2) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0079GEN2)) { - instance->base_addr = pci_resource_start(instance->pdev, 1); - } else { - instance->base_addr = pci_resource_start(instance->pdev, 0); - } + unsigned long bar_list; - if (pci_request_selected_regions(instance->pdev, - pci_select_bars(instance->pdev, IORESOURCE_MEM), - "megasas: LSI")) { + /* Find first memory bar */ + bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); + 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, + "megasas: LSI")) { printk(KERN_DEBUG "megasas: IO memory region busy!\n"); return -EBUSY; } @@ -3411,8 +3404,7 @@ iounmap(instance->reg_set); fail_ioremap: - pci_release_selected_regions(instance->pdev, - pci_select_bars(instance->pdev, IORESOURCE_MEM)); + pci_release_selected_regions(instance->pdev, instance->bar); return -EINVAL; } @@ -3432,8 +3424,7 @@ iounmap(instance->reg_set); - pci_release_selected_regions(instance->pdev, - pci_select_bars(instance->pdev, IORESOURCE_MEM)); + pci_release_selected_regions(instance->pdev, instance->bar); } /** diff -Naur linux-2.6.37-rc5.old/drivers/scsi/megaraid/megaraid_sas.h linux-2.6.37-rc5.new/drivers/scsi/megaraid/megaraid_sas.h --- linux-2.6.37-rc5.old/drivers/scsi/megaraid/megaraid_sas.h 2010-12-14 16:15:22.000000000 -0800 +++ linux-2.6.37-rc5.new/drivers/scsi/megaraid/megaraid_sas.h 2010-12-14 16:19:23.000000000 -0800 @@ -1338,6 +1338,7 @@ u8 msi_flag; struct msix_entry msixentry; + unsigned long bar; }; enum {
Attachment:
megaraid_sas.patch4
Description: Binary data