mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Kai Ruhnau <kai@tragetaschen.dyndns.org>,
	Loic Prylli <loic@myri.com>, Robert Hancock <hancockr@shaw.ca>,
	Jeff Garzik <jeff@garzik.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	gregkh@suse.de, linux-pci <linux-pci@atrey.karlin.mff.cuni.cz>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Martin Mares <mj@ucw.cz>, Matthew Wilcox <matthew@wil.cx>
Subject: Re: [Patch v2] Make PCI extended config space (MMCONFIG) a driver opt-in
Date: Fri, 28 Dec 2007 13:34:51 +0300	[thread overview]
Message-ID: <20071228103451.GA28694@jurassic.park.msu.ru> (raw)
In-Reply-To: <alpine.LNX.1.00.0712280036330.13593@iabervon.org>

On Fri, Dec 28, 2007 at 01:07:09AM -0500, Daniel Barkalow wrote:
> So would always using conf1 for the non-extended space (unless the 
> platform only uses mmconfig), or at least for the first 64 bytes. I'd bet 
> all the subtle bugs are in the first few words, anyway. (With blatant bugs 
> in the rest, of course, where we want to blacklist busses and devices)

Yes. Though limiting conf1 to the first 64 bytes is simply not worth
a pain - we would still have to deal with buses that are unreachable
via mmconf.

Always using legacy configuration mechanism for the legacy config space
and extended mechanism (mmconf) for the extended config space is a simple
and very logical approach. It's supposed to resolve *all* known mmconf
problems. And it still allows per-device quirks (tweaking dev->cfg_size).
And it does *remove* code, not add anything new/untested.

Signed-off-by: Ivan Kokshaysky <ink@jurassic.park.msu.ru>

Ivan.

 arch/x86/pci/mmconfig-shared.c |   35 -----------------------------------
 arch/x86/pci/mmconfig_32.c     |   22 +++++++++-------------
 arch/x86/pci/mmconfig_64.c     |   22 ++++++++++------------
 arch/x86/pci/pci.h             |    7 -------
 4 files changed, 19 insertions(+), 67 deletions(-)

diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index 4df637e..6b521d3 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -22,42 +22,9 @@
 #define MMCONFIG_APER_MIN	(2 * 1024*1024)
 #define MMCONFIG_APER_MAX	(256 * 1024*1024)
 
-DECLARE_BITMAP(pci_mmcfg_fallback_slots, 32*PCI_MMCFG_MAX_CHECK_BUS);
-
 /* Indicate if the mmcfg resources have been placed into the resource table. */
 static int __initdata pci_mmcfg_resources_inserted;
 
-/* K8 systems have some devices (typically in the builtin northbridge)
-   that are only accessible using type1
-   Normally this can be expressed in the MCFG by not listing them
-   and assigning suitable _SEGs, but this isn't implemented in some BIOS.
-   Instead try to discover all devices on bus 0 that are unreachable using MM
-   and fallback for them. */
-static void __init unreachable_devices(void)
-{
-	int i, bus;
-	/* Use the max bus number from ACPI here? */
-	for (bus = 0; bus < PCI_MMCFG_MAX_CHECK_BUS; bus++) {
-		for (i = 0; i < 32; i++) {
-			unsigned int devfn = PCI_DEVFN(i, 0);
-			u32 val1, val2;
-
-			pci_conf1_read(0, bus, devfn, 0, 4, &val1);
-			if (val1 == 0xffffffff)
-				continue;
-
-			if (pci_mmcfg_arch_reachable(0, bus, devfn)) {
-				raw_pci_ops->read(0, bus, devfn, 0, 4, &val2);
-				if (val1 == val2)
-					continue;
-			}
-			set_bit(i + 32 * bus, pci_mmcfg_fallback_slots);
-			printk(KERN_NOTICE "PCI: No mmconfig possible on device"
-			       " %02x:%02x\n", bus, i);
-		}
-	}
-}
-
 static const char __init *pci_mmcfg_e7520(void)
 {
 	u32 win;
@@ -270,8 +237,6 @@ void __init pci_mmcfg_init(int type)
 		return;
 
 	if (pci_mmcfg_arch_init()) {
-		if (type == 1)
-			unreachable_devices();
 		if (known_bridge)
 			pci_mmcfg_insert_resources(IORESOURCE_BUSY);
 		pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c
index 1bf5816..7b75e65 100644
--- a/arch/x86/pci/mmconfig_32.c
+++ b/arch/x86/pci/mmconfig_32.c
@@ -30,10 +30,6 @@ static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
 	struct acpi_mcfg_allocation *cfg;
 	int cfg_num;
 
-	if (seg == 0 && bus < PCI_MMCFG_MAX_CHECK_BUS &&
-	    test_bit(PCI_SLOT(devfn) + 32*bus, pci_mmcfg_fallback_slots))
-		return 0;
-
 	for (cfg_num = 0; cfg_num < pci_mmcfg_config_num; cfg_num++) {
 		cfg = &pci_mmcfg_config[cfg_num];
 		if (cfg->pci_segment == seg &&
@@ -68,13 +64,16 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
 	u32 base;
 
 	if ((bus > 255) || (devfn > 255) || (reg > 4095)) {
-		*value = -1;
+err:		*value = -1;
 		return -EINVAL;
 	}
 
+	if (reg < 256)
+		return pci_conf1_read(seg,bus,devfn,reg,len,value);
+
 	base = get_base_addr(seg, bus, devfn);
 	if (!base)
-		return pci_conf1_read(seg,bus,devfn,reg,len,value);
+		goto err;
 
 	spin_lock_irqsave(&pci_config_lock, flags);
 
@@ -105,9 +104,12 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
 	if ((bus > 255) || (devfn > 255) || (reg > 4095))
 		return -EINVAL;
 
+	if (reg < 256)
+		return pci_conf1_write(seg,bus,devfn,reg,len,value);
+
 	base = get_base_addr(seg, bus, devfn);
 	if (!base)
-		return pci_conf1_write(seg,bus,devfn,reg,len,value);
+		return -EINVAL;
 
 	spin_lock_irqsave(&pci_config_lock, flags);
 
@@ -134,12 +136,6 @@ static struct pci_raw_ops pci_mmcfg = {
 	.write =	pci_mmcfg_write,
 };
 
-int __init pci_mmcfg_arch_reachable(unsigned int seg, unsigned int bus,
-				    unsigned int devfn)
-{
-	return get_base_addr(seg, bus, devfn) != 0;
-}
-
 int __init pci_mmcfg_arch_init(void)
 {
 	printk(KERN_INFO "PCI: Using MMCONFIG\n");
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index 4095e4d..c4cf318 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -40,9 +40,7 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus)
 static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
 {
 	char __iomem *addr;
-	if (seg == 0 && bus < PCI_MMCFG_MAX_CHECK_BUS &&
-		test_bit(32*bus + PCI_SLOT(devfn), pci_mmcfg_fallback_slots))
-		return NULL;
+
 	addr = get_virt(seg, bus);
 	if (!addr)
 		return NULL;
@@ -56,13 +54,16 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
 
 	/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
 	if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) {
-		*value = -1;
+err:		*value = -1;
 		return -EINVAL;
 	}
 
+	if (reg < 256)
+		return pci_conf1_read(seg,bus,devfn,reg,len,value);
+
 	addr = pci_dev_base(seg, bus, devfn);
 	if (!addr)
-		return pci_conf1_read(seg,bus,devfn,reg,len,value);
+		goto err;
 
 	switch (len) {
 	case 1:
@@ -88,9 +89,12 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
 	if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095)))
 		return -EINVAL;
 
+	if (reg < 256)
+		return pci_conf1_write(seg,bus,devfn,reg,len,value);
+
 	addr = pci_dev_base(seg, bus, devfn);
 	if (!addr)
-		return pci_conf1_write(seg,bus,devfn,reg,len,value);
+		return -EINVAL;
 
 	switch (len) {
 	case 1:
@@ -126,12 +130,6 @@ static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg)
 	return addr;
 }
 
-int __init pci_mmcfg_arch_reachable(unsigned int seg, unsigned int bus,
-				    unsigned int devfn)
-{
-	return pci_dev_base(seg, bus, devfn) != NULL;
-}
-
 int __init pci_mmcfg_arch_init(void)
 {
 	int i;
diff --git a/arch/x86/pci/pci.h b/arch/x86/pci/pci.h
index ac56d39..36cb44c 100644
--- a/arch/x86/pci/pci.h
+++ b/arch/x86/pci/pci.h
@@ -98,13 +98,6 @@ extern void pcibios_sort(void);
 
 /* pci-mmconfig.c */
 
-/* Verify the first 16 busses. We assume that systems with more busses
-   get MCFG right. */
-#define PCI_MMCFG_MAX_CHECK_BUS 16
-extern DECLARE_BITMAP(pci_mmcfg_fallback_slots, 32*PCI_MMCFG_MAX_CHECK_BUS);
-
-extern int __init pci_mmcfg_arch_reachable(unsigned int seg, unsigned int bus,
-					   unsigned int devfn);
 extern int __init pci_mmcfg_arch_init(void);
 
 /*

  reply	other threads:[~2007-12-28 10:34 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.m7tRTz/ymu3iMyLTO2aF1Tvaw24@ifi.uio.no>
     [not found] ` <fa.XrRLIuL4juNAXXaMPF3iY8FyWW8@ifi.uio.no>
     [not found]   ` <fa.gv3MUHxQvd7EaG/0hhC9IzBvIlA@ifi.uio.no>
2007-12-27 17:59     ` Robert Hancock
2007-12-27 19:47       ` Arjan van de Ven
     [not found]   ` <fa.H0fcNl3b6xVBwzWUgT72M4K6KOU@ifi.uio.no>
2007-12-27 18:15     ` Robert Hancock
2007-12-27 18:30       ` Kai Ruhnau
2007-12-27 18:58       ` Linus Torvalds
2007-12-27 21:10         ` Loic Prylli
2007-12-27 21:21           ` Matthew Wilcox
2007-12-27 21:37           ` Linus Torvalds
2007-12-27 21:46             ` Linus Torvalds
2007-12-27 22:18               ` Kai Ruhnau
2007-12-28  4:27                 ` Daniel Barkalow
2007-12-28  5:32                   ` Linus Torvalds
2007-12-28  6:07                     ` Daniel Barkalow
2007-12-28 10:34                       ` Ivan Kokshaysky [this message]
2007-12-28 16:14                         ` Arjan van de Ven
2007-12-28 16:38                           ` Ivan Kokshaysky
2007-12-28 17:40                             ` Loic Prylli
2007-12-28 21:12                               ` Ivan Kokshaysky
2008-01-13  6:01                                 ` Matthew Wilcox
2008-01-13  7:19                                   ` Loic Prylli
2007-12-28  5:31                 ` Benjamin Herrenschmidt
2007-12-27 21:59             ` Kai Ruhnau
2007-12-28  5:27             ` Benjamin Herrenschmidt
2007-12-28  5:29             ` Benjamin Herrenschmidt
2007-12-28  5:37               ` Linus Torvalds
2007-12-28  6:06                 ` Benjamin Herrenschmidt
2007-12-28 19:14                   ` Loic Prylli
2007-12-28 20:42                     ` Benjamin Herrenschmidt
2007-12-28  0:18         ` Robert Hancock
     [not found] <fa.2KorSXroIUtdRjFJWJwy49QuIYk@ifi.uio.no>
     [not found] ` <fa.KgDY4hzBogAL+o607R+LHzW+HTc@ifi.uio.no>
     [not found]   ` <fa.xzH/eH5b6vCHpOD31Cq2nyq6z/k@ifi.uio.no>
     [not found]     ` <fa.EPUIDYIoxtDNcRrL9p3fAkr80Lo@ifi.uio.no>
     [not found]       ` <fa.uPoC9dcdekzy7g8QYFyuwelukiQ@ifi.uio.no>
     [not found]         ` <fa.O9WUKjAu+MfGg712w8Y4HkQ7GIo@ifi.uio.no>
2008-01-13  1:56           ` Robert Hancock
     [not found]   ` <fa.y9bLGEm23C6rL/wz7kMpKYF67oM@ifi.uio.no>
     [not found]     ` <fa.S+otiE5kNySVMlhUagdf/n9GRIc@ifi.uio.no>
     [not found]       ` <fa.OH5C/OjPYJXn8kSOHV/09piVz0E@ifi.uio.no>
     [not found]         ` <fa.jj0GkdAagaR3CLapBSdT1psD3Ps@ifi.uio.no>
     [not found]           ` <fa.EgRiN/duILxBcenHk7dQyC+rldw@ifi.uio.no>
2008-01-14 23:59             ` Robert Hancock
2007-12-25 11:26 Arjan van de Ven
2007-12-27 11:52 ` Jeff Garzik
2007-12-27 14:09   ` Arjan van de Ven
2007-12-27 17:52   ` Linus Torvalds
2008-01-11 19:02 ` Greg KH
2008-01-11 19:09   ` Arjan van de Ven
2008-01-11 19:14     ` Greg KH
2008-01-11 19:28   ` Matthew Wilcox
2008-01-11 19:40     ` Arjan van de Ven
2008-01-11 19:45       ` Greg KH
2008-01-11 19:49         ` Matthew Wilcox
2008-01-11 19:58           ` Linus Torvalds
2008-01-11 20:17             ` Matthew Wilcox
2008-01-11 20:27               ` Linus Torvalds
2008-01-11 20:42                 ` Matthew Wilcox
2008-01-11 21:12                   ` Linus Torvalds
2008-01-11 21:17                     ` Matthew Wilcox
2008-01-11 21:28                       ` Linus Torvalds
2008-01-11 21:38                         ` Matthew Wilcox
2008-01-11 23:58                           ` Ivan Kokshaysky
2008-01-12  0:17                             ` Jesse Barnes
2008-01-12  0:26                             ` Greg KH
2008-01-12 14:40                               ` Ivan Kokshaysky
2008-01-12 15:46                                 ` Arjan van de Ven
2008-01-12 16:23                                   ` Ivan Kokshaysky
2008-01-12 17:45                                 ` Arjan van de Ven
2008-01-12 18:17                                   ` Matthew Wilcox
2008-01-12 21:49                                   ` Ivan Kokshaysky
2008-01-12 23:01                                     ` Arjan van de Ven
2008-01-13  0:12                                       ` Tony Camuso
2008-01-13  0:40                                         ` Arjan van de Ven
2008-01-13  1:36                                           ` Tony Camuso
2008-01-13  4:42                                             ` Arjan van de Ven
2008-01-13  4:47                                               ` Matthew Wilcox
2008-01-13  6:43                                                 ` Jeff Garzik
2008-01-13 12:43                                               ` Tony Camuso
2008-01-13 17:03                                                 ` Arjan van de Ven
2008-01-13 21:28                                                   ` Tony Camuso
2008-01-14  0:54                                                     ` Alan Cox
2008-01-14  1:33                                                       ` Arjan van de Ven
2008-01-14  3:29                                                         ` Tony Camuso
2008-01-14  5:05                                                           ` Arjan van de Ven
2008-01-14 13:01                                                             ` Tony Camuso
2008-01-14 14:46                                                               ` Arjan van de Ven
2008-01-14 15:23                                                                 ` Tony Camuso
2008-01-14 16:01                                                                   ` Arjan van de Ven
2008-01-14 16:08                                                                     ` Tony Camuso
2008-01-14  9:11                                                         ` Alan Cox
2008-01-14  5:20                                                       ` Linus Torvalds
2008-01-13 18:23                                   ` Loic Prylli
2008-01-13 18:41                                     ` Arjan van de Ven
2008-01-13 20:43                                       ` Matthew Wilcox
2008-01-13 21:18                                         ` Loic Prylli
2008-01-13 20:51                                       ` Loic Prylli
2008-01-13  7:08                                 ` Benjamin Herrenschmidt
2008-01-13  7:24                                   ` Matthew Wilcox
2008-01-13  7:58                                     ` Matthew Wilcox
2008-01-13 17:01                                     ` Arjan van de Ven
2008-01-14 22:52                                       ` Matthew Wilcox
2008-01-14 23:04                                         ` Adrian Bunk
2008-01-15 16:00                                           ` Loic Prylli
2008-01-15 17:46                                             ` Greg KH
2008-01-15 17:56                                               ` Matthew Wilcox
2008-01-15 19:27                                                 ` Tony Camuso
2008-01-15 19:38                                                   ` Linus Torvalds
2008-01-15 19:40                                                     ` Matthew Wilcox
2008-01-15 22:12                                                     ` Loic Prylli
2008-01-19 16:58                                                 ` Grant Grundler
2008-01-28 18:32                                                   ` Tony Camuso
2008-01-28 20:44                                                     ` Greg KH
2008-01-28 22:31                                                       ` Matthew Wilcox
2008-01-28 22:53                                                         ` Greg KH
2008-01-29  2:56                                                           ` Matthew Wilcox
2008-01-29  3:05                                                       ` Arjan van de Ven
2008-01-29  3:18                                                         ` Matthew Wilcox
2008-01-29 13:19                                                           ` Greg KH
2008-01-29 14:15                                                             ` Tony Camuso
2008-01-29 14:47                                                               ` Arjan van de Ven
2008-01-29 15:15                                                                 ` Tony Camuso
2008-01-29 15:29                                                                   ` Arjan van de Ven
2008-01-29 16:26                                                                     ` Tony Camuso
2008-01-29 23:57                                                                     ` Matthew Wilcox
2008-01-30  2:30                                                                       ` Tony Camuso
2008-01-30  3:45                                                             ` Matthew Wilcox
2008-01-30 15:15                                                               ` Ivan Kokshaysky
2008-01-30 15:42                                                                 ` Arjan van de Ven
2008-01-30 20:14                                                                   ` Ivan Kokshaysky
2008-01-31  5:51                                                             ` Jesse Barnes
2008-01-11 19:54   ` Arjan van de Ven
2008-01-11 20:55     ` Greg KH
2008-01-15 12:58 ` Øyvind Vågen Jægtnes

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=20071228103451.GA28694@jurassic.park.msu.ru \
    --to=ink@jurassic.park.msu.ru \
    --cc=arjan@infradead.org \
    --cc=barkalow@iabervon.org \
    --cc=benh@kernel.crashing.org \
    --cc=gregkh@suse.de \
    --cc=hancockr@shaw.ca \
    --cc=jeff@garzik.org \
    --cc=kai@tragetaschen.dyndns.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=loic@myri.com \
    --cc=matthew@wil.cx \
    --cc=mj@ucw.cz \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®