Skip to contentSkip to conversation

natsemi: fix for PPC 44x platforms

PATCH In review Sergei Shtylyov 2 participants 2 messages Apr 8, 2008 – Apr 12, 2008

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

PATCH 1/1 natsemi: fix for PPC 44x platforms

The driver stores the the PCI resource address into 'unsigned long' variable before calling ioremap() on it. This warrants kernel oops when the registers are accessed on PPC 44x platforms which (being 32-bit) have PCI memory space mapped beyond 4 GB.

The arch/ppc/ kernel has a fixup in ioremap() that creates an illusion of the PCI I/O and memory resources are mapped below 4 GB, but arch/powerpc/ code got rid of this trick, having instead CONFIG_RESOURCES_64BIT enabled.

---
This is the same issue as the one that has been recently addressed by commits 3c34ac36ac1084e571ef9b6fb1d6a5b10ccc1fd0 (e1000: Fix for 32 bits platforms with 64 bits resources) and c976816b6e901341ec3c4653147316c15549a1c4 (siimage: fix kernel oops on PPC 44x). The patch has only been compile tested though...

 drivers/net/natsemi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/natsemi.c +4 -3
Index: linux-2.6/drivers/net/natsemi.c
===================================================================
@@ -786,7 +786,8 @@ static int __devinit natsemi_probe1 (str
 	struct netdev_private *np;
 	int i, option, irq, chip_idx = ent->driver_data;
 	static int find_cnt = -1;
-	unsigned long iostart, iosize;
+	resource_size_t iostart;
+	unsigned long iosize;
 	void __iomem *ioaddr;
 	const int pcibar = 1; /* PCI base address register */
 	int prev_eedata;
@@ -946,9 +947,9 @@ static int __devinit natsemi_probe1 (str
 		goto err_create_file;
 
 	if (netif_msg_drv(np)) {
-		printk(KERN_INFO "natsemi %s: %s at %#08lx "
+		printk(KERN_INFO "natsemi %s: %s at %#08llx "
 		       "(%s), %s, IRQ %d",
-		       dev->name, natsemi_pci_info[chip_idx].name, iostart,
+		       dev->name, natsemi_pci_info[chip_idx].name, (u64)iostart,
 		       pci_name(np->pci_dev), print_mac(mac, dev->dev_addr), irq);
 		if (dev->if_port == PORT_TP)
 			printk(", port TP.\n");
#1 lore raw
Quoted 35 lines · Sergei Shtylyov

The driver stores the the PCI resource address into 'unsigned long' variable before calling ioremap() on it. This warrants kernel oops when the registers are accessed on PPC 44x platforms which (being 32-bit) have PCI memory space mapped beyond 4 GB.

The arch/ppc/ kernel has a fixup in ioremap() that creates an illusion of the PCI I/O and memory resources are mapped below 4 GB, but arch/powerpc/ code got rid of this trick, having instead CONFIG_RESOURCES_64BIT enabled.

---
This is the same issue as the one that has been recently addressed by commits 3c34ac36ac1084e571ef9b6fb1d6a5b10ccc1fd0 (e1000: Fix for 32 bits platforms with 64 bits resources) and c976816b6e901341ec3c4653147316c15549a1c4 (siimage: fix kernel oops on PPC 44x). The patch has only been compile tested though...

 drivers/net/natsemi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/net/natsemi.c
===================================================================

drivers/net/natsemi.c +2 -1
@@ -786,7 +786,8 @@ static int __devinit natsemi_probe1 (str
 	struct netdev_private *np;
 	int i, option, irq, chip_idx = ent->driver_data;
 	static int find_cnt = -1;
-	unsigned long iostart, iosize;
+	resource_size_t iostart;
+	unsigned long iosize;
 	void __iomem *ioaddr;
 	const int pcibar = 1; /* PCI base address register */
 	int prev_eedata;

drivers/net/natsemi.c static int __devinit natsemi_probe1 (str · line 954

Quoted 10 lines
drivers/net/natsemi.c +2 -2
@@ -946,9 +947,9 @@ static int __devinit natsemi_probe1 (str
 		goto err_create_file;
 
 	if (netif_msg_drv(np)) {
-		printk(KERN_INFO "natsemi %s: %s at %#08lx "
+		printk(KERN_INFO "natsemi %s: %s at %#08llx "
 		       "(%s), %s, IRQ %d",
-		       dev->name, natsemi_pci_info[chip_idx].name, iostart,
+		       dev->name, natsemi_pci_info[chip_idx].name, (u64)iostart,
 		       pci_name(np->pci_dev), print_mac(mac, dev->dev_addr), irq);
 		if (dev->if_port == PORT_TP)

ACK, with the cast fixed (to long long)