From 1f2e77c5590babdf745ac4bbf36f49a7c2b881db Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Mon, 12 Sep 2005 11:49:39 -0700 Subject: [PATCH] Fix for Sun GEM, no reports of it making a difference (used on PCs?) may consider dropping from -stable. --- queue/series | 1 + ...ngem-enable-and-map-pci-rom-properly.patch | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 queue/sungem-enable-and-map-pci-rom-properly.patch diff --git a/queue/series b/queue/series index e69b17f1a4c..fc1f0d384d6 100644 --- a/queue/series +++ b/queue/series @@ -1,2 +1,3 @@ forcedeth-init-link-settings-in-nv_open.patch hpt366-write-dword-not-byte-for-ROM-resource.patch +sungem-enable-and-map-pci-rom-properly.patch diff --git a/queue/sungem-enable-and-map-pci-rom-properly.patch b/queue/sungem-enable-and-map-pci-rom-properly.patch new file mode 100644 index 00000000000..3c902417c3b --- /dev/null +++ b/queue/sungem-enable-and-map-pci-rom-properly.patch @@ -0,0 +1,81 @@ +From stable-bounces@linux.kernel.org Sun Sep 11 14:09:08 2005 +Date: Sun, 11 Sep 2005 14:08:59 -0700 (PDT) +From: Linus Torvalds +To: stable@kernel.org +Cc: +Subject: Sun GEM ethernet: enable and map PCI ROM properly + +From: Linus Torvalds + +This same patch was reported to fix the MAC address detection on sunhme +(next patch). Most people seem to be running this on Sparcs or PPC +machines, where we get the MAC address from their respective firmware +rather than from the (previously broken) ROM mapping routines. + +Signed-off-by: Linus Torvalds +Signed-off-by: Chris Wright + drivers/net/sungem.c | 36 ++++++++++++++---------------------- + 1 files changed, 14 insertions(+), 22 deletions(-) + +Index: linux-2.6.13.y/drivers/net/sungem.c +=================================================================== +--- linux-2.6.13.y.orig/drivers/net/sungem.c ++++ linux-2.6.13.y/drivers/net/sungem.c +@@ -2816,7 +2816,7 @@ static int gem_ioctl(struct net_device * + + #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) + /* Fetch MAC address from vital product data of PCI ROM. */ +-static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) ++static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) + { + int this_offset; + +@@ -2837,35 +2837,27 @@ static void find_eth_addr_in_vpd(void __ + + for (i = 0; i < 6; i++) + dev_addr[i] = readb(p + i); +- break; ++ return 1; + } ++ return 0; + } + + static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) + { +- u32 rom_reg_orig; +- void __iomem *p; +- +- if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { +- if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) +- goto use_random; +- } +- +- pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); +- pci_write_config_dword(pdev, pdev->rom_base_reg, +- rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); ++ size_t size; ++ void __iomem *p = pci_map_rom(pdev, &size); + +- p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); +- if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) +- find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); ++ if (p) { ++ int found; + +- if (p != NULL) +- iounmap(p); +- +- pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); +- return; ++ found = readb(p) == 0x55 && ++ readb(p + 1) == 0xaa && ++ find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); ++ pci_unmap_rom(pdev, p); ++ if (found) ++ return; ++ } + +-use_random: + /* Sun MAC prefix then 3 random bytes. */ + dev_addr[0] = 0x08; + dev_addr[1] = 0x00; -- 2.47.3