public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Hellstrom <daniel@gaisler.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ram Pai <linuxram@us.ibm.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Clemens Ladisch <clemens@ladisch.de>,
	Yinghai Lu <yinghai@kernel.org>,
	Kristoffer Glembo <kristoffer@gaisler.com>
Subject: Re: [PATCH 1/4] PCI: refactor io size calculation code
Date: Mon, 11 Apr 2011 16:53:55 +0200	[thread overview]
Message-ID: <4DA31603.6070308@gaisler.com> (raw)
In-Reply-To: <BANLkTikqB2tr-jNTaqVtTpBkH5O1iYQS-Q@mail.gmail.com>

Linus Torvalds wrote:

>On Mon, Apr 11, 2011 at 6:18 AM, Daniel Hellstrom <daniel@gaisler.com> wrote:
>  
>
>>In commit 13583b16592a ("PCI: refactor io size calculation code"):
>>    
>>
>>>refactor  code  that  calculates  the  io  size in pbus_size_io()
>>>and pbus_mem_io() into separate functions.
>>>
>>>Signed-off-by: Ram Pai <linuxram@xxxxxxxxxx>
>>>---
>>>drivers/pci/setup-bus.c |   66
>>>++++++++++++++++++++++++++++++-----------------
>>>1 files changed, 42 insertions(+), 24 deletions(-)
>>>
>>>diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
>>>index 66cb8f4..2121215 100644
>>>--- a/drivers/pci/setup-bus.c
>>>+++ b/drivers/pci/setup-bus.c
>>>@@ -404,6 +404,43 @@ static struct resource *find_free_bus_resource(struct
>>>pci_bus *bus, unsigned lon
>>>       return NULL;
>>>}
>>>
>>>      
>>>
>>...
>>
>>    
>>
>>>+
>>>+static resource_size_t calculate_memsize(resource_size_t size,
>>>+               resource_size_t min_size,
>>>+               resource_size_t size1,
>>>+               resource_size_t old_size,
>>>+               resource_size_t align)
>>>+{
>>>+       if (size < min_size)
>>>+               size = min_size;
>>>+       if (old_size == 1 )
>>>+               old_size = 0;
>>>+       if (size < old_size)
>>>+               size = old_size;
>>>+       size = ALIGN(size + size1, align);
>>>+       return size;
>>>+}
>>>+
>>>/* Sizing the IO windows of the PCI-PCI bridge is trivial,
>>>  since these windows have 4K granularity and the IO ranges
>>>  of non-bridge PCI devices are limited to 256 bytes.
>>>
>>>
>>>      
>>>
>>...
>>
>>    
>>
>>>@@ -516,14 +542,6 @@ static int pbus_size_mem(struct pci_bus *bus,
>>>unsigned long mask,
>>>                       mem64_mask &= r->flags & IORESOURCE_MEM_64;
>>>               }
>>>       }
>>>-       if (size < min_size)
>>>-               size = min_size;
>>>-       old_size = resource_size(b_res);
>>>-       if (old_size == 1)
>>>-               old_size = 0;
>>>-       if (size < old_size)
>>>-               size = old_size;
>>>-
>>>       align = 0;
>>>       min_align = 0;
>>>       for (order = 0; order <= max_order; order++) {
>>>@@ -537,7 +555,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned
>>>long mask,
>>>                       min_align = align1 >> 1;
>>>               align += aligns[order];
>>>       }
>>>-       size = ALIGN(size, min_align);
>>>+       size = calculate_memsize(size, min_size, 0, resource_size(b_res),
>>>align);
>>>
>>>      
>>>
>>On my SPARC32/LEON4 PCI system I get overlapped areas, double mapped
>>resources. Some BARs on PCIBUS0 are in the same non-prefetchable memory
>>range as the secondary bus PCIBUS1. Changing align to min_align in the above
>>call to calculate_memsize() fixes the problem, and the memory allocation is
>>the same as with 2.6.36.4 kernel.
>>
>>I belive this is just a typo.
>>    
>>
>
>It does seem that way. The original code used 'min_align' and 'align'
>itself is meaningless in that place.
>  
>
Agree.

>Can you confirm that the patch you talk about as fixing things is the attached?
>
>                  Linus
>  
>
Yes, the below patch works on the system that triggered the problem 
before. The last min_align was added in a later patch, I missed it 
initially.

Thanks,
Daniel

>------------------------------------------------------------------------
>
> drivers/pci/setup-bus.c |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
>index 89d0a6a88df7..ebf51ad1b714 100644
>--- a/drivers/pci/setup-bus.c
>+++ b/drivers/pci/setup-bus.c
>@@ -676,10 +676,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
> 			min_align = align1 >> 1;
> 		align += aligns[order];
> 	}
>-	size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), align);
>+	size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
> 	size1 = !add_size ? size :
> 		calculate_memsize(size, min_size+add_size, 0,
>-				resource_size(b_res), align);
>+				resource_size(b_res), min_align);
> 	if (!size0 && !size1) {
> 		if (b_res->start || b_res->end)
> 			dev_info(&bus->self->dev, "disabling bridge window "
>  
>


  reply	other threads:[~2011-04-11 14:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 13:18 [PATCH 1/4] PCI: refactor io size calculation code Daniel Hellstrom
2011-04-11 14:42 ` Linus Torvalds
2011-04-11 14:53   ` Daniel Hellstrom [this message]
2011-04-11 15:59   ` Ram Pai
  -- strict thread matches above, loose matches on Subject: below --
2011-02-15  1:43 [PATCH 0/4] PCI: preallocate resource patch series Ram Pai
2011-02-15  1:43 ` [PATCH 1/4] PCI: refactor io size calculation code Ram Pai

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=4DA31603.6070308@gaisler.com \
    --to=daniel@gaisler.com \
    --cc=clemens@ladisch.de \
    --cc=kristoffer@gaisler.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=yinghai@kernel.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