Re: [patch] pci: revert "PCI: remove transparent bridge sizing"

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Wednesday, March 26, 2008 - 2:41 pm

On Wed, 26 Mar 2008, Ivan Kokshaysky wrote:
...

Hmm. This makes the code look totally nonsensical.

It seems to come from the fact that we had a very odd way to check bogus 
resources (namely "start == end"), but your code makes it _really_ hard to 
see what is going on.

In fact, I think the old code was buggy too, because we actually *do* have 
single-byte resources where start == end, as showb by google:

	PCI: Ignore bogus resource 1 [3f6:3f6] of Symphony Labs SL82c105
	PCI: Ignore bogus resource 3 [376:376] of Symphony Labs SL82c105

where that resource actually looks valid, and should have a single byte 
alignment! Admittedly I think it was created with a quirk (can you get 
that kind of resource from actually _probing_ a PCI device?) but I do 
think that a single-byte resource is valid.

So I wonder if we shouldn't just make this a bit more readable and also a 
bit more explicit with something like the appended..

NOTE! This will also consider a bridge resource at 0 to be an invalid 
resource (since now the alignment will be zero), which is a bit odd and 
makes me worry a bit. I wouldn't be surprised if some non-PC architectures 
have PCI bridges at zero. But maybe they should be (or already are?) 
marked IORESOURCE_PCI_FIXED?

Ben - the obvious "odd PCI bus resources" architecture would be POWER. Any 
commentary?

		Linus

---
 drivers/pci/setup-res.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 4be7ccf..048ed77 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -211,6 +211,20 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
 EXPORT_SYMBOL_GPL(pci_assign_resource_fixed);
 #endif
 
+static inline resource_size_t get_resource_alignment(int resno, struct resource *r)
+{
+	resource_size_t start = r->start, end = r->end;
+	resource_size_t alignment = 0;
+
+	/* End == start == 0 - invalid resource */
+	if (end && start <= end) {
+		alignment = end - start - 1;
+		if (resno >= PCI_BRIDGE_RESOURCES)
+			alignment = start;
+	}
+	return alignment;
+}
+
 /* Sort resources by alignment */
 void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
 {
@@ -226,10 +240,10 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
 		if (r->flags & IORESOURCE_PCI_FIXED)
 			continue;
 
-		r_align = r->end - r->start;
-		
-		if (!(r->flags) || r->parent)
+		if (!r->flags || r->parent)
 			continue;
+
+		r_align = get_resource_alignment(i, r);
 		if (!r_align) {
 			printk(KERN_WARNING "PCI: Ignore bogus resource %d "
 				"[%llx:%llx] of %s\n",
@@ -237,7 +251,6 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
 				(unsigned long long)r->end, pci_name(dev));
 			continue;
 		}
-		r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start;
 		for (list = head; ; list = list->next) {
 			resource_size_t align = 0;
 			struct resource_list *ln = list->next;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.25-rc6-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Fri Mar 21, 6:59 pm)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Jeff Garzik, (Fri Mar 21, 7:52 pm)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Andrew Morton, (Fri Mar 21, 10:33 pm)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Ingo Molnar, (Sat Mar 22, 4:11 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Ingo Molnar, (Sat Mar 22, 4:15 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Heiko Carstens, (Sat Mar 22, 9:32 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Sat Mar 22, 10:53 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Sat Mar 22, 10:56 am)
Re: ohci1394 problem (MMIO broken) (was 2.6.25-rc6-git6: R ..., Rafael J. Wysocki, (Sat Mar 22, 10:58 am)
Re: ohci1394 problem (MMIO broken) (was 2.6.25-rc6-git6: R ..., Benjamin Herrenschmidt, (Tue Mar 25, 4:33 pm)
Re: ohci1394 problem (MMIO broken) (was 2.6.25-rc6-git6: R ..., Benjamin Herrenschmidt, (Tue Mar 25, 5:12 pm)
Re: ohci1394 problem (MMIO broken) (was 2.6.25-rc6-git6: R ..., Benjamin Herrenschmidt, (Tue Mar 25, 8:39 pm)
Re: ohci1394 problem (MMIO broken) (was 2.6.25-rc6-git6: R ..., Benjamin Herrenschmidt, (Wed Mar 26, 5:17 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Adrian Bunk, (Wed Mar 26, 10:02 am)
Re: [patch] pci: revert "PCI: remove transparent bridge si ..., Linus Torvalds, (Wed Mar 26, 2:41 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 2:57 pm)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Wed Mar 26, 3:11 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 3:27 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 3:29 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 3:54 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 4:17 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 4:18 pm)
Re: ohci1394 problem (MMIO broken) (was 2.6.25-rc6-git6: R ..., Benjamin Herrenschmidt, (Wed Mar 26, 4:25 pm)
Re: [patch] pci: revert &quot;PCI: remove transparent bridge si ..., Benjamin Herrenschmidt, (Wed Mar 26, 4:45 pm)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Romano Giannetti, (Thu Mar 27, 3:18 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Linus Torvalds, (Mon Mar 31, 11:21 am)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Tino Keitel, (Mon Mar 31, 2:04 pm)
Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24, Tino Keitel, (Mon Mar 31, 2:26 pm)
2.6.25-rc7/8: Another resume regression, Mark Lord, (Thu Apr 3, 12:06 pm)
Re: 2.6.25-rc7/8: Another resume regression, Mark Lord, (Fri Apr 4, 7:27 pm)
Re: 2.6.25-rc7/8: Another resume regression, Rafael J. Wysocki, (Mon Apr 7, 3:51 am)
Re: 2.6.25-rc7/8: Another resume regression, Mark Lord, (Mon Apr 7, 8:51 am)
Re: 2.6.25-rc7/8: Another resume regression, Rafael J. Wysocki, (Mon Apr 7, 10:40 am)
Re: 2.6.25-rc7/8: Another resume regression, Mark Lord, (Tue Apr 8, 8:35 am)