Skip to content

Commit 3776541

Browse files
avasquez01James Bottomley
authored andcommitted
[SCSI] qla2xxx: Fix for 32-bit platforms with 64-bit resources.
The driver stores the contents of PCI resources into unsigned long's before ioremapping. This breaks on 32-bit platforms which support 64-bit MMIO resources. Correct code by removing the temporary variables used during MMIO PIO mapping and using resource_size_t where applicable. Also correct a small typo in a printk() where the wrong region number was displayed. Signed-off-by: Andrew Vasquez <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 43ef058 commit 3776541

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,8 +2271,7 @@ typedef struct scsi_qla_host {
22712271

22722272
int bars;
22732273
device_reg_t __iomem *iobase; /* Base I/O address */
2274-
unsigned long pio_address;
2275-
unsigned long pio_length;
2274+
resource_size_t pio_address;
22762275
#define MIN_IOBASE_LEN 0x100
22772276

22782277
/* ISP ring lock, rings, and indexes */

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,8 +1479,7 @@ qla2x00_set_isp_flags(scsi_qla_host_t *ha)
14791479
static int
14801480
qla2x00_iospace_config(scsi_qla_host_t *ha)
14811481
{
1482-
unsigned long pio, pio_len, pio_flags;
1483-
unsigned long mmio, mmio_len, mmio_flags;
1482+
resource_size_t pio;
14841483

14851484
if (pci_request_selected_regions(ha->pdev, ha->bars,
14861485
QLA2XXX_DRIVER_NAME)) {
@@ -1495,10 +1494,8 @@ qla2x00_iospace_config(scsi_qla_host_t *ha)
14951494

14961495
/* We only need PIO for Flash operations on ISP2312 v2 chips. */
14971496
pio = pci_resource_start(ha->pdev, 0);
1498-
pio_len = pci_resource_len(ha->pdev, 0);
1499-
pio_flags = pci_resource_flags(ha->pdev, 0);
1500-
if (pio_flags & IORESOURCE_IO) {
1501-
if (pio_len < MIN_IOBASE_LEN) {
1497+
if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) {
1498+
if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) {
15021499
qla_printk(KERN_WARNING, ha,
15031500
"Invalid PCI I/O region size (%s)...\n",
15041501
pci_name(ha->pdev));
@@ -1511,28 +1508,23 @@ qla2x00_iospace_config(scsi_qla_host_t *ha)
15111508
pio = 0;
15121509
}
15131510
ha->pio_address = pio;
1514-
ha->pio_length = pio_len;
15151511

15161512
skip_pio:
15171513
/* Use MMIO operations for all accesses. */
1518-
mmio = pci_resource_start(ha->pdev, 1);
1519-
mmio_len = pci_resource_len(ha->pdev, 1);
1520-
mmio_flags = pci_resource_flags(ha->pdev, 1);
1521-
1522-
if (!(mmio_flags & IORESOURCE_MEM)) {
1514+
if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) {
15231515
qla_printk(KERN_ERR, ha,
1524-
"region #0 not an MMIO resource (%s), aborting\n",
1516+
"region #1 not an MMIO resource (%s), aborting\n",
15251517
pci_name(ha->pdev));
15261518
goto iospace_error_exit;
15271519
}
1528-
if (mmio_len < MIN_IOBASE_LEN) {
1520+
if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) {
15291521
qla_printk(KERN_ERR, ha,
15301522
"Invalid PCI mem region size (%s), aborting\n",
15311523
pci_name(ha->pdev));
15321524
goto iospace_error_exit;
15331525
}
15341526

1535-
ha->iobase = ioremap(mmio, MIN_IOBASE_LEN);
1527+
ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN);
15361528
if (!ha->iobase) {
15371529
qla_printk(KERN_ERR, ha,
15381530
"cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));

0 commit comments

Comments
 (0)