public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Chris Wright <chrisw@osdl.org>
Subject: [PATCH 3/9] [PATCH] Fix PCI ROM mapping
Date: Wed, 07 Sep 2005 18:28:45 -0700	[thread overview]
Message-ID: <20050908012855.845291000@localhost.localdomain> (raw)
In-Reply-To: 20050908012842.299637000@localhost.localdomain

[-- Attachment #1: fix-pci-rom-mapping.patch --]
[-- Type: text/plain, Size: 2387 bytes --]

-stable review patch.  If anyone has any  objections, please let us know.
------------------

This fixes a problem with pci_map_rom() which doesn't properly
update the ROM BAR value with the address thas allocated for it by the
PCI code. This problem, among other, breaks boot on Mac laptops.

It'ss a new version based on Linus latest one with better error
checking.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Chris Wright <chrisw@osdl.org>
---
 drivers/pci/rom.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

Index: linux-2.6.13.y/drivers/pci/rom.c
===================================================================
--- linux-2.6.13.y.orig/drivers/pci/rom.c
+++ linux-2.6.13.y/drivers/pci/rom.c
@@ -21,13 +21,21 @@
  * between the ROM and other resources, so enabling it may disable access
  * to MMIO registers or other card memory.
  */
-static void pci_enable_rom(struct pci_dev *pdev)
+static int pci_enable_rom(struct pci_dev *pdev)
 {
+	struct resource *res = pdev->resource + PCI_ROM_RESOURCE;
+	struct pci_bus_region region;
 	u32 rom_addr;
 
+	if (!res->flags)
+		return -1;
+
+	pcibios_resource_to_bus(pdev, &region, res);
 	pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
-	rom_addr |= PCI_ROM_ADDRESS_ENABLE;
+	rom_addr &= ~PCI_ROM_ADDRESS_MASK;
+	rom_addr |= region.start | PCI_ROM_ADDRESS_ENABLE;
 	pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
+	return 0;
 }
 
 /**
@@ -71,19 +79,21 @@ void __iomem *pci_map_rom(struct pci_dev
 	} else {
 		if (res->flags & IORESOURCE_ROM_COPY) {
 			*size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
-			return (void __iomem *)pci_resource_start(pdev, PCI_ROM_RESOURCE);
+			return (void __iomem *)pci_resource_start(pdev,
+							     PCI_ROM_RESOURCE);
 		} else {
 			/* assign the ROM an address if it doesn't have one */
-			if (res->parent == NULL)
-				pci_assign_resource(pdev, PCI_ROM_RESOURCE);
-
+			if (res->parent == NULL &&
+			    pci_assign_resource(pdev,PCI_ROM_RESOURCE))
+				return NULL;
 			start = pci_resource_start(pdev, PCI_ROM_RESOURCE);
 			*size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
 			if (*size == 0)
 				return NULL;
 
 			/* Enable ROM space decodes */
-			pci_enable_rom(pdev);
+			if (pci_enable_rom(pdev))
+				return NULL;
 		}
 	}
 

--

  parent reply	other threads:[~2005-09-08  1:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-08  1:28 [PATCH 0/9] -stable review Chris Wright
2005-09-08  1:28 ` [PATCH 1/9] [PATCH] Kconfig: saa7134-dvb must select tda1004x Chris Wright
2005-09-08  1:28 ` [PATCH 2/9] [PATCH] aacraid: 2.6.13 aacraid bad BUG_ON fix Chris Wright
2005-09-08  1:28 ` Chris Wright [this message]
2005-09-08  1:28 ` [PATCH 4/9] [PATCH] x86: pci_assign_unassigned_resources() update Chris Wright
2005-09-08  1:28 ` [PATCH 5/9] [NET]: 2.6.13 breaks libpcap (and tcpdump) Chris Wright
2005-09-08  1:28 ` [PATCH 6/9] [CRYPTO] Fix boundary check in standard multi-block cipher processors Chris Wright
2005-09-08  1:28 ` [PATCH 7/9] [RTC]: Use SA_SHIRQ in sparc specific code Chris Wright
2005-09-08  1:28 ` [PATCH 8/9] [IPV4]: Reassembly trim not clearing CHECKSUM_HW Chris Wright
2005-09-08  1:28 ` [PATCH 9/9] [PATCH] 32bit sendmsg() flaw (CAN-2005-2490) Chris Wright
2005-09-09  6:37   ` Chris Wright
2005-09-09  6:43 ` [PATCH 10/9] raw_sendmsg DoS (CAN-2005-2492) Chris Wright
2005-09-09 12:13 ` [PATCH 0/9] -stable review Henrik Persson
2005-09-09 16:05   ` Chris Wright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050908012855.845291000@localhost.localdomain \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=benh@kernel.crashing.org \
    --cc=chuckw@quantumlinux.com \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox