All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: break when finding the first smaller resource
@ 2015-05-19  6:24 Wei Yang
  2015-05-27 16:58 ` Bjorn Helgaas
  2015-06-05 19:36 ` Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yang @ 2015-05-19  6:24 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Wei Yang

In commit d74b9027a4da(PCI: Consider additional PF's IOV BAR alignment in
sizing and assigning), it stores additional alignment in realloc_head and
take this into consideration for assignment.

After getting the additional alignment, it will re-order the head list to
make sure resources with bigger alignment is ahead of the resources with
smaller assignment in the head list. To make it happen, it iterate on the
head list and find a smaller alignment resource and insert ahead of it.
This should be done for the first occurrence, while the code now will
iterate on the whole list.

This patch fixes this behavior by break when finding the first smaller
resource in the head list.

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
 drivers/pci/setup-bus.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 4fd0cac..aa281d9 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -435,9 +435,11 @@ static void __assign_resources_sorted(struct list_head *head,
 			list_for_each_entry(dev_res2, head, list) {
 				align = pci_resource_alignment(dev_res2->dev,
 							       dev_res2->res);
-				if (add_align > align)
+				if (add_align > align) {
 					list_move_tail(&dev_res->list,
 						       &dev_res2->list);
+					break;
+				}
 			}
                }
 
-- 
1.7.9.5


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

* Re: [PATCH] PCI: break when finding the first smaller resource
  2015-05-19  6:24 [PATCH] PCI: break when finding the first smaller resource Wei Yang
@ 2015-05-27 16:58 ` Bjorn Helgaas
  2015-06-05 19:36 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2015-05-27 16:58 UTC (permalink / raw)
  To: Wei Yang; +Cc: linux-pci

On Tue, May 19, 2015 at 02:24:17PM +0800, Wei Yang wrote:
> In commit d74b9027a4da(PCI: Consider additional PF's IOV BAR alignment in
> sizing and assigning), it stores additional alignment in realloc_head and
> take this into consideration for assignment.
> 
> After getting the additional alignment, it will re-order the head list to
> make sure resources with bigger alignment is ahead of the resources with
> smaller assignment in the head list. To make it happen, it iterate on the
> head list and find a smaller alignment resource and insert ahead of it.
> This should be done for the first occurrence, while the code now will
> iterate on the whole list.
> 
> This patch fixes this behavior by break when finding the first smaller
> resource in the head list.
> 
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>

Applied to for-linus for v4.1, thanks.

> ---
>  drivers/pci/setup-bus.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 4fd0cac..aa281d9 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -435,9 +435,11 @@ static void __assign_resources_sorted(struct list_head *head,
>  			list_for_each_entry(dev_res2, head, list) {
>  				align = pci_resource_alignment(dev_res2->dev,
>  							       dev_res2->res);
> -				if (add_align > align)
> +				if (add_align > align) {
>  					list_move_tail(&dev_res->list,
>  						       &dev_res2->list);
> +					break;
> +				}
>  			}
>                 }
>  
> -- 
> 1.7.9.5
> 

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

* Re: [PATCH] PCI: break when finding the first smaller resource
  2015-05-19  6:24 [PATCH] PCI: break when finding the first smaller resource Wei Yang
  2015-05-27 16:58 ` Bjorn Helgaas
@ 2015-06-05 19:36 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2015-06-05 19:36 UTC (permalink / raw)
  To: Wei Yang; +Cc: linux-pci

On Tue, May 19, 2015 at 02:24:17PM +0800, Wei Yang wrote:
> In commit d74b9027a4da(PCI: Consider additional PF's IOV BAR alignment in
> sizing and assigning), it stores additional alignment in realloc_head and
> take this into consideration for assignment.
> 
> After getting the additional alignment, it will re-order the head list to
> make sure resources with bigger alignment is ahead of the resources with
> smaller assignment in the head list. To make it happen, it iterate on the
> head list and find a smaller alignment resource and insert ahead of it.
> This should be done for the first occurrence, while the code now will
> iterate on the whole list.
> 
> This patch fixes this behavior by break when finding the first smaller
> resource in the head list.
> 
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>

I applied this with the following changelog, included here so search
engines can find the original thread:


PCI: Fix IOV resource sorting by alignment requirement

In d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing
and assigning"), it stores additional alignment in realloc_head and takes
this into consideration for assignment.

After getting the additional alignment, it reorders the head list so
resources with bigger alignment are ahead of resources with smaller
alignment.  It does this by iterating over the head list and inserting
ahead of any resource with smaller alignment.  This should be done for the
first occurrence, but the code currently iterates over the whole list.

Fix this by terminating the loop when we find the first smaller resource in
the head list.

[bhelgaas: changelog]
Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

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

end of thread, other threads:[~2015-06-05 19:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19  6:24 [PATCH] PCI: break when finding the first smaller resource Wei Yang
2015-05-27 16:58 ` Bjorn Helgaas
2015-06-05 19:36 ` Bjorn Helgaas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.