All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] PCI: Allocate prefetch mmio resource first when possible
       [not found] <CA+2TWzXvZrVZDJA-KkuUVuCP8kwX3GENL_rTf=_dZ_HBqJUArw@mail.gmail.com>
@ 2014-01-09  0:24 ` Bjorn Helgaas
  2014-01-09 20:44   ` Yinghai Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Helgaas @ 2014-01-09  0:24 UTC (permalink / raw
  To: threeTigers Lin
  Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Li Zefan,
	Yinghai Lu

[+cc Yinghai]

On Wed, Jan 8, 2014 at 11:17 AM, threeTigers Lin
<threeflytigers@gmail.com> wrote:
> From f7a37ed1c61b5939ccef810e28b25ecf3bfa9077 Mon Sep 17 00:00:00 2001
> From: linmuhui <linmuhui@huawei.com>
> Date: Thu, 9 Jan 2014 01:03:12 +0800
> Subject: [PATCH] PCI: Allocate prefetch mmio resource first when possible

This patch is not in the standard format and does not apply cleanly.
See Documentation/SubmittingPatches.

> Hi Bjorn,
>
> PCI bus resources will be set up at pci_bridge_check_ranges() or
> pci_read_bridge_bases(). In both cases, we can find that the PCI bus'
> non-pref mmio will be assigned to bus->resource[1] and pref mmio will be
> assigned to bus->resource[2]. So, in the scenario that we need to allocate
> pref resources from PCI bus such as hotplug operation, the bus' non-pref
> mmio will be quickly eaten up first if we try to allocate bus resources in
> the order from bus->resource[0] to bus->resource[PCI_BRIDGE_RESOURCE_NUM -
> 1] in the function pci_bus_alloc_resource(), even though there is enough
> pref mmio resource of the bus. This may lead to the later requester who want
> to allocate non-pref mmio cannot allocate the resource from the bus. So, I
> think the order of allocating PCI bus resources in function
> pci_bus_alloc_resource() should be changed to try pref mmio first when
> possible.

Don't we do this already?  The code in __pci_assign_resource() looks
like it should prefer an exact prefetching match.

If that code doesn't work, we should fix it there.  I don't want to
fiddle with pci_bus_for_each_resource() for this -- that's a really
arcane place to hide such a fix.

Bjorn

> Signed-off-by: Lin Muhui <linmuhui@huawei.com>
> ---
>  include/linux/pci.h |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 1084a15..238df8f 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1064,7 +1064,8 @@ void pci_bus_remove_resources(struct pci_bus *bus);
>
>  #define pci_bus_for_each_resource(bus, res, i)                         \
>         for (i = 0;                                                     \
> -           (res = pci_bus_resource_n(bus, i)) || i <
> PCI_BRIDGE_RESOURCE_NUM; \
> +           (res = pci_bus_resource_n(bus, (i < PCI_BRIDGE_RESOURCE_NUM ?
> (PCI_BRIDGE_RESOURCE_NUM - 1 - i) : i)))\
> +                                        || i < PCI_BRIDGE_RESOURCE_NUM; \
>              i++)
>
>  int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
> --
> 1.7.1
>

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

* Re: [PATCH] PCI: Allocate prefetch mmio resource first when possible
  2014-01-09  0:24 ` [PATCH] PCI: Allocate prefetch mmio resource first when possible Bjorn Helgaas
@ 2014-01-09 20:44   ` Yinghai Lu
  0 siblings, 0 replies; 2+ messages in thread
From: Yinghai Lu @ 2014-01-09 20:44 UTC (permalink / raw
  To: Bjorn Helgaas
  Cc: threeTigers Lin, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, Li Zefan

On Wed, Jan 8, 2014 at 4:24 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> [+cc Yinghai]
>
> On Wed, Jan 8, 2014 at 11:17 AM, threeTigers Lin
> <threeflytigers@gmail.com> wrote:
>> From f7a37ed1c61b5939ccef810e28b25ecf3bfa9077 Mon Sep 17 00:00:00 2001
>> From: linmuhui <linmuhui@huawei.com>
>> Date: Thu, 9 Jan 2014 01:03:12 +0800
>> Subject: [PATCH] PCI: Allocate prefetch mmio resource first when possible
>
> This patch is not in the standard format and does not apply cleanly.
> See Documentation/SubmittingPatches.
>
>> Hi Bjorn,
>>
>> PCI bus resources will be set up at pci_bridge_check_ranges() or
>> pci_read_bridge_bases(). In both cases, we can find that the PCI bus'
>> non-pref mmio will be assigned to bus->resource[1] and pref mmio will be
>> assigned to bus->resource[2]. So, in the scenario that we need to allocate
>> pref resources from PCI bus such as hotplug operation, the bus' non-pref
>> mmio will be quickly eaten up first if we try to allocate bus resources in
>> the order from bus->resource[0] to bus->resource[PCI_BRIDGE_RESOURCE_NUM -
>> 1] in the function pci_bus_alloc_resource(), even though there is enough
>> pref mmio resource of the bus. This may lead to the later requester who want
>> to allocate non-pref mmio cannot allocate the resource from the bus. So, I
>> think the order of allocating PCI bus resources in function
>> pci_bus_alloc_resource() should be changed to try pref mmio first when
>> possible.
>
> Don't we do this already?  The code in __pci_assign_resource() looks
> like it should prefer an exact prefetching match.
>
> If that code doesn't work, we should fix it there.  I don't want to
> fiddle with pci_bus_for_each_resource() for this -- that's a really
> arcane place to hide such a fix.

Looks like he was trying to do sorting work like we try to do with
root bus resource before, but with new patches in pci/resource, we do
NOT need to do that anymore.

Hi, Lin,

Can you check linus/master + pci/next + pci/resource

and

http://patchwork.ozlabs.org/patch/303740/
PCI: Try best to allocate pref mmio 64bit above 4g

would fix the problem in your setup?

Thanks

Yinghai

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

end of thread, other threads:[~2014-01-09 20:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CA+2TWzXvZrVZDJA-KkuUVuCP8kwX3GENL_rTf=_dZ_HBqJUArw@mail.gmail.com>
2014-01-09  0:24 ` [PATCH] PCI: Allocate prefetch mmio resource first when possible Bjorn Helgaas
2014-01-09 20:44   ` Yinghai Lu

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.