linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch 1/1] x86 pci: Add option to not assign BAR's if not already assigned
@ 2010-05-12 18:14 Mike Travis
  2010-05-13 18:56 ` Bjorn Helgaas
                   ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Mike Travis @ 2010-05-12 18:14 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin
  Cc: x86, Jesse Barnes, Bjorn Helgaas, Jacob Pan, Tejun Heo,
	Mike Habeck, LKML

Subject: [Patch 1/1] x86 pci: Add option to not assign BAR's if not already assigned
From: Mike Habeck <habeck@sgi.com>

The Linux kernel assigns BARs that a BIOS did not assign, most likely
to handle broken BIOSes that didn't enumerate the devices correctly.
On UV the BIOS purposely doesn't assign I/O BARs for certain devices/
drivers we know don't use them (examples, LSI SAS, Qlogic FC, ...).
We purposely don't assign these I/O BARs because I/O Space is a very
limited resource.  There is only 64k of I/O Space, and in a PCIe
topology that space gets divided up into 4k chucks (this is due to
the fact that a pci-to-pci bridge's I/O decoder is aligned at 4k)...
Thus a system can have at most 16 cards with I/O BARs: (64k / 4k = 16)

SGI needs to scale to >16 devices with I/O BARs.  So by not assigning
I/O BARs on devices we know don't use them, we can do that (iff the
kernel doesn't go and assign these BARs that the BIOS purposely didn't
assign).

This patch will not assign a resource to a device BAR if that BAR was
not assigned by the BIOS, and the kernel cmdline option 'pci=nobar'
was specified.   This patch is closely modeled after the 'pci=norom'
option that currently exists in the tree.

Signed-off-by: Mike Habeck <habeck@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
 Documentation/kernel-parameters.txt |    2 ++
 arch/x86/include/asm/pci_x86.h      |    1 +
 arch/x86/pci/common.c               |   20 ++++++++++++++++++++
 3 files changed, 23 insertions(+)

--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -1935,6 +1935,8 @@ and is between 256 and 4096 characters.
 		norom		[X86] Do not assign address space to
 				expansion ROMs that do not already have
 				BIOS assigned address ranges.
+		nobar		[X86] Do not assign address space to the
+				BARs that weren't assigned by the BIOS.
 		irqmask=0xMMMM	[X86] Set a bit mask of IRQs allowed to be
 				assigned automatically to PCI devices. You can
 				make the kernel exclude IRQs of your ISA cards
--- linux.orig/arch/x86/include/asm/pci_x86.h
+++ linux/arch/x86/include/asm/pci_x86.h
@@ -30,6 +30,7 @@
 #define PCI_HAS_IO_ECS		0x40000
 #define PCI_NOASSIGN_ROMS	0x80000
 #define PCI_ROOT_NO_CRS		0x100000
+#define PCI_NOASSIGN_BARS	0x200000
 
 extern unsigned int pci_probe;
 extern unsigned long pirq_table_addr;
--- linux.orig/arch/x86/pci/common.c
+++ linux/arch/x86/pci/common.c
@@ -125,6 +125,23 @@ void __init dmi_check_skip_isa_align(voi
 static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
 {
 	struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE];
+	struct resource *bar_r;
+	int bar;
+
+	if (pci_probe & PCI_NOASSIGN_BARS) {
+		/*
+		* If the BIOS did not assign the BAR, zero out the
+		* resource so the kernel doesn't attmept to assign
+		* it later on in pci_assign_unassigned_resources
+		*/
+		for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) {
+			bar_r = &dev->resource[bar];
+			if (bar_r->start == 0 && bar_r->end != 0) {
+				bar_r->flags = 0;
+				bar_r->end = 0;
+			}
+		}
+	}
 
 	if (pci_probe & PCI_NOASSIGN_ROMS) {
 		if (rom_r->parent)
@@ -509,6 +526,9 @@ char * __devinit  pcibios_setup(char *st
 	} else if (!strcmp(str, "norom")) {
 		pci_probe |= PCI_NOASSIGN_ROMS;
 		return NULL;
+	} else if (!strcmp(str, "nobar")) {
+		pci_probe |= PCI_NOASSIGN_BARS;
+		return NULL;
 	} else if (!strcmp(str, "assign-busses")) {
 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
 		return NULL;

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2010-06-09 14:23 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-12 18:14 [Patch 1/1] x86 pci: Add option to not assign BAR's if not already assigned Mike Travis
2010-05-13 18:56 ` Bjorn Helgaas
2010-05-13 19:08   ` H. Peter Anvin
2010-05-13 19:12   ` Mike Travis
2010-05-13 19:13     ` Mike Travis
2010-05-13 19:54     ` Bjorn Helgaas
2010-05-13 20:27       ` Mike Habeck
2010-05-13 19:38   ` Mike Habeck
2010-05-13 20:02     ` Bjorn Helgaas
2010-05-13 20:09       ` H. Peter Anvin
2010-05-14 22:25       ` Jesse Barnes
2010-05-14 22:34         ` Mike Travis
2010-05-14 22:35           ` H. Peter Anvin
2010-05-14 22:40             ` Mike Travis
2010-05-15  2:25               ` Mike Travis
2010-05-14 22:47           ` Jesse Barnes
2010-05-14 22:59             ` Mike Travis
2010-05-14 23:06               ` Jesse Barnes
2010-05-14 23:23                 ` Mike Travis
2010-05-14 23:33                   ` Jesse Barnes
2010-05-14 23:40                     ` H. Peter Anvin
2010-05-15  0:02                       ` Jesse Barnes
2010-05-14 23:20             ` H. Peter Anvin
2010-05-14 23:28               ` Jesse Barnes
2010-05-14 23:32                 ` H. Peter Anvin
2010-05-14 23:34                   ` Jesse Barnes
2010-05-14 23:39                     ` H. Peter Anvin
2010-05-15  0:00                       ` Jesse Barnes
2010-05-15  0:14                         ` H. Peter Anvin
2010-05-13 20:36     ` Yinghai Lu
2010-05-13 20:34       ` H. Peter Anvin
2010-05-13 18:58 ` Bjorn Helgaas
2010-05-28 16:53 ` Mike Travis
2010-05-28 17:00   ` H. Peter Anvin
2010-05-28 17:10     ` Mike Travis
2010-05-28 19:28       ` Jesse Barnes
2010-05-28 20:04       ` H. Peter Anvin
2010-05-31 11:12         ` Mike Travis
2010-05-31 16:36           ` H. Peter Anvin
2010-06-01 22:49           ` Bjorn Helgaas
2010-06-02  7:31             ` H. Peter Anvin
2010-06-02 15:45               ` Bjorn Helgaas
2010-06-02 15:47                 ` H. Peter Anvin
2010-06-02 15:53                   ` Jesse Barnes
2010-06-09  0:53                     ` H. Peter Anvin
2010-06-09  1:26                       ` Jesse Barnes
2010-06-09 14:23                         ` Mike Habeck
2010-06-02 15:53             ` Mike Habeck
2010-06-02 16:40               ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).