linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: keep resource size during alignment reordering
@ 2015-05-29  5:40 Yinghai Lu
  2015-05-29 21:16 ` Bjorn Helgaas
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yinghai Lu @ 2015-05-29  5:40 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu, Wei Yang, Benjamin Herrenschmidt

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.
During update the resource before reordering, it does not calculate
resource end correctly.

We need to keep the original resource size before updating start.
otherwise we will smaller size during updating end.

Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 drivers/pci/setup-bus.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/pci/setup-bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/setup-bus.c
+++ linux-2.6/drivers/pci/setup-bus.c
@@ -428,9 +428,10 @@ static void __assign_resources_sorted(st
 		 * consistent.
 		 */
 		if (add_align > dev_res->res->start) {
+			resource_size_t r_size = resource_size(dev_res->res);
+
 			dev_res->res->start = add_align;
-			dev_res->res->end = add_align +
-				            resource_size(dev_res->res);
+			dev_res->res->end = add_align + r_size - 1;
 
 			list_for_each_entry(dev_res2, head, list) {
 				align = pci_resource_alignment(dev_res2->dev,

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

* Re: [PATCH] PCI: keep resource size during alignment reordering
  2015-05-29  5:40 [PATCH] PCI: keep resource size during alignment reordering Yinghai Lu
@ 2015-05-29 21:16 ` Bjorn Helgaas
  2015-05-30  5:46   ` Yinghai Lu
  2015-06-01  2:25 ` Wei Yang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2015-05-29 21:16 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, Wei Yang, Benjamin Herrenschmidt

On Thu, May 28, 2015 at 10:40:00PM -0700, Yinghai Lu wrote:
> 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.
> During update the resource before reordering, it does not calculate
> resource end correctly.
> 
> We need to keep the original resource size before updating start.
> otherwise we will smaller size during updating end.
> 
> Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

I already merged this fix for the same commit:

http://lkml.kernel.org/r/1432016657-16816-1-git-send-email-weiyang@linux.vnet.ibm.com

Is this a separate fix for a different problem?  Is it a fix for the same
problem, just implemented differently?

I'd like Wei's ack for this just to make sure we don't get things mixed up.

Wei's first fix is on my for-linus branch:

https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=for-linus&id=a6b65983dabceb7ccb1801ee7f5bd421c2704d16

> ---
>  drivers/pci/setup-bus.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/pci/setup-bus.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/setup-bus.c
> +++ linux-2.6/drivers/pci/setup-bus.c
> @@ -428,9 +428,10 @@ static void __assign_resources_sorted(st
>  		 * consistent.
>  		 */
>  		if (add_align > dev_res->res->start) {
> +			resource_size_t r_size = resource_size(dev_res->res);
> +
>  			dev_res->res->start = add_align;
> -			dev_res->res->end = add_align +
> -				            resource_size(dev_res->res);
> +			dev_res->res->end = add_align + r_size - 1;
>  
>  			list_for_each_entry(dev_res2, head, list) {
>  				align = pci_resource_alignment(dev_res2->dev,

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

* Re: [PATCH] PCI: keep resource size during alignment reordering
  2015-05-29 21:16 ` Bjorn Helgaas
@ 2015-05-30  5:46   ` Yinghai Lu
  0 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2015-05-30  5:46 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Wei Yang, Benjamin Herrenschmidt

On Fri, May 29, 2015 at 2:16 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Thu, May 28, 2015 at 10:40:00PM -0700, Yinghai Lu wrote:
>> 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.
>> During update the resource before reordering, it does not calculate
>> resource end correctly.
>>
>> We need to keep the original resource size before updating start.
>> otherwise we will smaller size during updating end.
...
> I already merged this fix for the same commit:
>
> http://lkml.kernel.org/r/1432016657-16816-1-git-send-email-weiyang@linux.vnet.ibm.com
>
> Is this a separate fix for a different problem?  Is it a fix for the same
> problem, just implemented differently?

It is a separate fix for different problem.
We should keep the size while changing the alignement.

Thanks

Yinghai

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

* Re: [PATCH] PCI: keep resource size during alignment reordering
  2015-05-29  5:40 [PATCH] PCI: keep resource size during alignment reordering Yinghai Lu
  2015-05-29 21:16 ` Bjorn Helgaas
@ 2015-06-01  2:25 ` Wei Yang
  2015-06-01 23:07 ` Bjorn Helgaas
  2015-06-05 19:38 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Wei Yang @ 2015-06-01  2:25 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Bjorn Helgaas, linux-pci, Wei Yang, Benjamin Herrenschmidt

On Thu, May 28, 2015 at 10:40:00PM -0700, Yinghai Lu wrote:
>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.
>During update the resource before reordering, it does not calculate
>resource end correctly.
>
>We need to keep the original resource size before updating start.
>otherwise we will smaller size during updating end.
>
>Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
>Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
>Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Acked-by: Wei Yang <weiyang@linux.vnet.ibm.com>


Thanks Yinghai,

I have tested this on Power8, your code is correct. :-)

>
>---
> drivers/pci/setup-bus.c |    5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
>Index: linux-2.6/drivers/pci/setup-bus.c
>===================================================================
>--- linux-2.6.orig/drivers/pci/setup-bus.c
>+++ linux-2.6/drivers/pci/setup-bus.c
>@@ -428,9 +428,10 @@ static void __assign_resources_sorted(st
> 		 * consistent.
> 		 */
> 		if (add_align > dev_res->res->start) {
>+			resource_size_t r_size = resource_size(dev_res->res);
>+
> 			dev_res->res->start = add_align;
>-			dev_res->res->end = add_align +
>-				            resource_size(dev_res->res);
>+			dev_res->res->end = add_align + r_size - 1;
>
> 			list_for_each_entry(dev_res2, head, list) {
> 				align = pci_resource_alignment(dev_res2->dev,

-- 
Richard Yang
Help you, Help me


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

* Re: [PATCH] PCI: keep resource size during alignment reordering
  2015-05-29  5:40 [PATCH] PCI: keep resource size during alignment reordering Yinghai Lu
  2015-05-29 21:16 ` Bjorn Helgaas
  2015-06-01  2:25 ` Wei Yang
@ 2015-06-01 23:07 ` Bjorn Helgaas
  2015-06-05 19:38 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2015-06-01 23:07 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, Wei Yang, Benjamin Herrenschmidt

On Thu, May 28, 2015 at 10:40:00PM -0700, Yinghai Lu wrote:
> 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.
> During update the resource before reordering, it does not calculate
> resource end correctly.
> 
> We need to keep the original resource size before updating start.
> otherwise we will smaller size during updating end.
> 
> Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Applied with Wei's ack to for-linus for v4.1, thanks!

> ---
>  drivers/pci/setup-bus.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/pci/setup-bus.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/setup-bus.c
> +++ linux-2.6/drivers/pci/setup-bus.c
> @@ -428,9 +428,10 @@ static void __assign_resources_sorted(st
>  		 * consistent.
>  		 */
>  		if (add_align > dev_res->res->start) {
> +			resource_size_t r_size = resource_size(dev_res->res);
> +
>  			dev_res->res->start = add_align;
> -			dev_res->res->end = add_align +
> -				            resource_size(dev_res->res);
> +			dev_res->res->end = add_align + r_size - 1;
>  
>  			list_for_each_entry(dev_res2, head, list) {
>  				align = pci_resource_alignment(dev_res2->dev,

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

* Re: [PATCH] PCI: keep resource size during alignment reordering
  2015-05-29  5:40 [PATCH] PCI: keep resource size during alignment reordering Yinghai Lu
                   ` (2 preceding siblings ...)
  2015-06-01 23:07 ` Bjorn Helgaas
@ 2015-06-05 19:38 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2015-06-05 19:38 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, Wei Yang, Benjamin Herrenschmidt

On Thu, May 28, 2015 at 10:40:00PM -0700, Yinghai Lu wrote:
> 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.
> During update the resource before reordering, it does not calculate
> resource end correctly.
> 
> We need to keep the original resource size before updating start.
> otherwise we will smaller size during updating end.
> 
> Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

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


PCI: Preserve resource size during alignment reordering

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

In __assign_resources_sorted(), we changed dev_res->res->start, then used
resource_start() (which depends on res->start), so the recomputed res->end
was completely bogus.  Even if we'd had the correct size, the end would
have been off by one.

Preserve the resource size when we adjust its alignment.

[bhelgaas: changelog]
Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Wei Yang <weiyang@linux.vnet.ibm.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-29  5:40 [PATCH] PCI: keep resource size during alignment reordering Yinghai Lu
2015-05-29 21:16 ` Bjorn Helgaas
2015-05-30  5:46   ` Yinghai Lu
2015-06-01  2:25 ` Wei Yang
2015-06-01 23:07 ` Bjorn Helgaas
2015-06-05 19:38 ` 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).