/[linux-patches]/genpatches-2.6/tags/2.6.13-4/1018_2_sungem-enable-and-map-pci-rom-properly.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.13-4/1018_2_sungem-enable-and-map-pci-rom-properly.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 168 - (show annotations) (download)
Sun Sep 18 11:19:29 2005 UTC (8 years, 9 months ago) by dsd
File size: 2615 byte(s)
2.6.13-4 release
1 From stable-bounces@linux.kernel.org Sun Sep 11 14:09:08 2005
2 Date: Sun, 11 Sep 2005 14:08:59 -0700 (PDT)
3 From: Linus Torvalds <torvalds@osdl.org>
4 To: stable@kernel.org
5 Cc:
6 Subject: Sun GEM ethernet: enable and map PCI ROM properly
7
8 From: Linus Torvalds <torvalds@g5.osdl.org>
9
10 This same patch was reported to fix the MAC address detection on sunhme
11 (next patch). Most people seem to be running this on Sparcs or PPC
12 machines, where we get the MAC address from their respective firmware
13 rather than from the (previously broken) ROM mapping routines.
14
15 Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 Signed-off-by: Chris Wright <chrisw@osdl.org>
17 ---
18 drivers/net/sungem.c | 36 ++++++++++++++----------------------
19 1 files changed, 14 insertions(+), 22 deletions(-)
20
21 Index: linux-2.6.13.y/drivers/net/sungem.c
22 ===================================================================
23 --- linux-2.6.13.y.orig/drivers/net/sungem.c
24 +++ linux-2.6.13.y/drivers/net/sungem.c
25 @@ -2816,7 +2816,7 @@ static int gem_ioctl(struct net_device *
26
27 #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC))
28 /* Fetch MAC address from vital product data of PCI ROM. */
29 -static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
30 +static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
31 {
32 int this_offset;
33
34 @@ -2837,35 +2837,27 @@ static void find_eth_addr_in_vpd(void __
35
36 for (i = 0; i < 6; i++)
37 dev_addr[i] = readb(p + i);
38 - break;
39 + return 1;
40 }
41 + return 0;
42 }
43
44 static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr)
45 {
46 - u32 rom_reg_orig;
47 - void __iomem *p;
48 -
49 - if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) {
50 - if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0)
51 - goto use_random;
52 - }
53 -
54 - pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig);
55 - pci_write_config_dword(pdev, pdev->rom_base_reg,
56 - rom_reg_orig | PCI_ROM_ADDRESS_ENABLE);
57 + size_t size;
58 + void __iomem *p = pci_map_rom(pdev, &size);
59
60 - p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024));
61 - if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa)
62 - find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
63 + if (p) {
64 + int found;
65
66 - if (p != NULL)
67 - iounmap(p);
68 -
69 - pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig);
70 - return;
71 + found = readb(p) == 0x55 &&
72 + readb(p + 1) == 0xaa &&
73 + find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
74 + pci_unmap_rom(pdev, p);
75 + if (found)
76 + return;
77 + }
78
79 -use_random:
80 /* Sun MAC prefix then 3 random bytes. */
81 dev_addr[0] = 0x08;
82 dev_addr[1] = 0x00;

  ViewVC Help
Powered by ViewVC 1.1.20