Skip to contentSkip to conversation

ioremap?

PATCH Brian Murphy 2 participants 4 messages May 29, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

In three files/drivers I have had problems with physical addresses not being ioremapped. I include my patch to fix things up and request comments. How come others don't have similar problems?

/Brian

ide/ide-dma.c +2 -1
@@ -741,7 +741,8 @@
 	if (hwif->mate && hwif->mate->dma_base) {
 		dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8);
 	} else {
-		dma_base = pci_resource_start(dev, 4);
+		dma_base = ioremap(pci_resource_start(dev, 4), 
+				pci_resource_len(dev, 4));
 		if (!dma_base) {
 			printk("%s: dma_base is invalid (0x%04lx)\n", name, dma_base);
 			dma_base = 0;
ide/ide-pci.c +4 -2
@@ -716,8 +716,10 @@
 		if (IDE_PCI_DEVID_EQ(d->devid, DEVID_HPT366) && (port) && (class_rev < 0x03))
 			return;
 		if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE || (dev->class & (port ? 4 : 1)) != 0) {
-			ctl  = dev->resource[(2*port)+1].start;
-			base = dev->resource[2*port].start;
+			ctl = ioremap(pci_resource_start(dev, (2*port)+1), 
+			              pci_resource_len(dev, (2*port)+1));
+			base = ioremap(pci_resource_start(dev, 2*port), 
+			              pci_resource_len(dev, 2*port));
 			if (!(ctl & PCI_BASE_ADDRESS_IO_MASK) ||
 			    !(base & PCI_BASE_ADDRESS_IO_MASK)) {
 				printk("%s: IO baseregs (BIOS) are reported as MEM, report to <[email protected]>.\n", d->name);
net/pcnet32.c +2 -1
@@ -494,7 +494,8 @@
     }
     pci_set_master(pdev);
 
-    ioaddr = pci_resource_start (pdev, 0);
+    ioaddr = ioremap(pci_resource_start (pdev, 0),
+		    pci_resource_len (pdev, 0));
     printk(KERN_INFO "    ioaddr=%#08lx  resource_flags=%#08lx\n", ioaddr, pci_resource_flags (pdev, 0));
     if (!ioaddr) {
         printk (KERN_ERR "no PCI IO resources, aborting\n");
#1 lore raw

Looks like those are for io (inb, outb, etc.) not mem (readb, writeb, etc.). io addresses shouldn't be ioremapped.

Regards,
Brad

----- Original Message -----
From: "Brian Murphy" <[email protected]>
To: "linux-mips" <[email protected]>
Sent: Wednesday, May 29, 2002 8:33 AM
Subject: ioremap?

Quoted 8 lines

In three files/drivers I have had problems with physical addresses not being ioremapped.
I include my patch to fix things up and request comments. How come others don't have similar
problems?

/Brian

----------------------------------------------------------------------------
----

Quoted 15 lines
ide/ide-dma.c 2002/05/29 11:49:14 renamed from ide/ide-dma.c 2001/10/19 01:24:24 1.9 +2 -1
@@ -741,7 +741,8 @@
  if (hwif->mate && hwif->mate->dma_base) {
  dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8);
  } else {
- dma_base = pci_resource_start(dev, 4);
+ dma_base = ioremap(pci_resource_start(dev, 4),
+ pci_resource_len(dev, 4));
  if (!dma_base) {
  printk("%s: dma_base is invalid (0x%04lx)\n", name, dma_base);
  dma_base = 0;

ide/ide-pci.c 2002/05/29 11:49:15 line 716

Quoted 1 line
ide/ide-pci.c 2002/05/29 11:49:15 renamed from ide/ide-pci.c 2001/11/19 13:53:59 1.20 +0 -0
@@ -716,8 +716,10 @@
  if (IDE_PCI_DEVID_EQ(d->devid, DEVID_HPT366) && (port) && (class_rev <

0x03))

ide/ide-pci.c 2002/05/29 11:49:15 line 718

Quoted 2 lines
ide/ide-pci.c 2002/05/29 11:49:15 renamed from ide/ide-pci.c 2001/11/19 13:53:59 1.20 +0 -0
  return;
  if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE || (dev->class & (port ?

4 : 1)) != 0) {

ide/ide-pci.c 2002/05/29 11:49:15 line 725

Quoted 9 lines
ide/ide-pci.c 2002/05/29 11:49:15 renamed from ide/ide-pci.c 2001/11/19 13:53:59 1.20 +4 -2
- ctl  = dev->resource[(2*port)+1].start;
- base = dev->resource[2*port].start;
+ ctl = ioremap(pci_resource_start(dev, (2*port)+1),
+               pci_resource_len(dev, (2*port)+1));
+ base = ioremap(pci_resource_start(dev, 2*port),
+               pci_resource_len(dev, 2*port));
  if (!(ctl & PCI_BASE_ADDRESS_IO_MASK) ||
      !(base & PCI_BASE_ADDRESS_IO_MASK)) {
  printk("%s: IO baseregs (BIOS) are reported as MEM, report to

<[email protected]>.\n", d->name);

net/pcnet32.c 2002/05/29 11:49:18 line 499

Quoted 10 lines
net/pcnet32.c 2002/05/29 11:49:18 renamed from net/pcnet32.c 2002/02/26 05:59:35 1.33.2.1 +2 -1
@@ -494,7 +494,8 @@
     }
     pci_set_master(pdev);
 
-    ioaddr = pci_resource_start (pdev, 0);
+    ioaddr = ioremap(pci_resource_start (pdev, 0),
+     pci_resource_len (pdev, 0));
     printk(KERN_INFO "    ioaddr=%#08lx  resource_flags=%#08lx\n",

ioaddr, pci_resource_flags (pdev, 0));

Quoted 4 lines
net/pcnet32.c 2002/05/29 11:49:18 renamed from net/pcnet32.c 2002/02/26 05:59:35 1.33.2.1 +0 -0
     if (!ioaddr) {
         printk (KERN_ERR "no PCI IO resources, aborting\n");
#2 lore raw
Quoted 3 lines · Bradley D. LaRonde

Looks like those are for io (inb, outb, etc.) not mem (readb, writeb, etc.). io addresses shouldn't be ioremapped.

O.K. I have now used set_io_port_base to set the base address to KSEG1. What should be ioremapped then?

/Brian

#3 lore raw

----- Original Message -----
From: "Brian Murphy" <[email protected]>
Cc: "linux-mips" <[email protected]>
Sent: Wednesday, May 29, 2002 1:05 PM
Subject: Re: ioremap?

Quoted 3 lines
Quoted 1 line · Bradley D. LaRonde

Looks like those are for io (inb, outb, etc.) not mem (readb, writeb,

etc.).

Quoted 4 lines
Quoted 2 lines

io addresses shouldn't be ioremapped.

O.K. I have now used set_io_port_base to set the base address to KSEG1. What should be ioremapped then?

Any address passed to readb, writeb, etc. For example, a PCI mem resource address.

Regards,
Brad