All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"oe5hpm@gmail.com" <oe5hpm@gmail.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Richard Henderson <rth@twiddle.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	David Howells <dhowells@redhat.com>,
	Russell King <linux@arm.linux.org.uk>,
	Tony Luck <tony.luck@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Ingo Molnar <mingo@redhat.com>, Michal Simek <monstr@monstr.eu>,
	Chris Zankel <chris@zankel.net>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: trouble with PCI: Call pci_read_bridge_bases() from core instead of arch code
Date: Tue, 15 Sep 2015 14:07:17 -0700	[thread overview]
Message-ID: <55F88885.9070707@roeck-us.net> (raw)
In-Reply-To: <CAE9FiQXrr2w5=QRpP9kL=xE4djwCz80wTPn1SA93Wg_u=6Tp3Q@mail.gmail.com>

On 09/15/2015 01:17 PM, Yinghai Lu wrote:
> On Tue, Sep 15, 2015 at 9:51 AM, Guenter Roeck <linux@roeck-us.net> wrote:
>> On 09/15/2015 09:30 AM, Lorenzo Pieralisi wrote:
>>
>> It looks like me and Yinghai disagree how the problem I was trying to fix
>> should be handled, I don't understand Yinghai's concerns, and unfortunately
>> I just don't have the time I would need to get a better understanding.
>> It is fine with me to revert your patch and abandon mine.
>
> I put one simplified version in one my branch.
>
> https://git.kernel.org/cgit/linux/kernel/git/yinghai/linux-yinghai.git/patch/?id=cdf4bfbc1ce12d826abd49a8987eb3ca7e129332
>
> and will sent that later if needed.
>
>>From cdf4bfbc1ce12d826abd49a8987eb3ca7e129332 Mon Sep 17 00:00:00 2001
> From: Guenter Roeck <linux@roeck-us.net>

Yinghai,

that isn't really my patch, so you should not send it under my name.

Thanks,
Guenter

> Date: Tue, 15 Sep 2015 12:59:11 -0700
> Subject: PCI: Only try to assign io port only for root bus that support it
>
> The PCI subsystem always assumes that I/O is supported on root bus and
> tries to assign an I/O window to each child bus even if that is not the
> case.
>
> This may result in messages such as:
>
>    pcieport 0000:02:00.0: res[7]=[io  0x1000-0x0fff] get_res_add_size
> add_size 1000
>    pcieport 0000:02:00.0: BAR 7: no space for [io  size 0x1000]
>    pcieport 0000:02:00.0: BAR 7: failed to assign [io  size 0x1000]
>
> for each bridge port, even if root does not support I/O in the first place.
>
> To avoid this message, check if root bus supports I/O, then child bus
> will inherit the setting from parent bus, and later during sizing and
> assigning, check that bus flags and skip those resources.
>
> [bhelgaas: reverse sense of new pci_bus_flags_t value]
> [yinghai: only check root bus io port, and use flag on sizing and assigning]
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c4c6947..5d946bd 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -339,6 +339,9 @@ static void pci_read_bridge_io(struct pci_bus *child)
>    struct pci_bus_region region;
>    struct resource *res;
>
> + if (!(child->bus_flags & PCI_BUS_FLAGS_ROOT_SUPPORTS_IO))
> + return;
> +
>    io_mask = PCI_IO_RANGE_MASK;
>    io_granularity = 0x1000;
>    if (dev->io_window_1k) {
> @@ -2126,6 +2129,8 @@ struct pci_bus *pci_create_root_bus(struct
> device *parent, int bus,
>    } else
>    bus_addr[0] = '\0';
>    dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
> + if (resource_type(res) == IORESOURCE_IO)
> + b->bus_flags |= PCI_BUS_FLAGS_ROOT_SUPPORTS_IO;
>    }
>
>    resource_list_for_each_entry(window, &bridge->windows) {
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 9d5e415..8ee5d17 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -223,6 +223,10 @@ static void pdev_assign_resources_prepare(struct
> pci_dev *dev,
>    if (r->flags & IORESOURCE_PCI_FIXED)
>    continue;
>
> + if ((r->flags & IORESOURCE_IO) &&
> +    !(dev->bus->bus_flags & PCI_BUS_FLAGS_ROOT_SUPPORTS_IO))
> + continue;
> +
>    if (resource_disabled(r) || r->parent)
>    continue;
>
> @@ -1178,6 +1182,11 @@ static void pbus_size_io(struct pci_bus *bus,
> resource_size_t min_size,
>    min_size = 0;
>    }
>
> + if (!(bus->bus_flags & PCI_BUS_FLAGS_ROOT_SUPPORTS_IO)) {
> + b_res->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED;
> + return;
> + }
> +
>    min_align = window_alignment(bus, IORESOURCE_IO);
>    list_for_each_entry(dev, &bus->devices, bus_list) {
>    int i;
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 5ed9bf1..790c534 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -193,6 +193,7 @@ typedef unsigned short __bitwise pci_bus_flags_t;
>   enum pci_bus_flags {
>    PCI_BUS_FLAGS_NO_MSI   = (__force pci_bus_flags_t) 1,
>    PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
> + PCI_BUS_FLAGS_ROOT_SUPPORTS_IO = (__force pci_bus_flags_t) 4,
>   };
>
>   /* These values come from the PCI Express Spec */
>


  reply	other threads:[~2015-09-15 21:07 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02  9:51 trouble with PCI: Call pci_read_bridge_bases() from core instead of arch code oe5hpm
2015-09-02 17:47 ` Lorenzo Pieralisi
2015-09-02 20:32   ` Bjorn Helgaas
2015-09-03 10:01     ` Lorenzo Pieralisi
2015-09-03 16:21       ` Bjorn Helgaas
2015-09-03 17:57         ` Lorenzo Pieralisi
2015-09-04 14:19         ` Lorenzo Pieralisi
2015-09-04 16:00           ` Yinghai Lu
2015-09-04 16:44             ` Lorenzo Pieralisi
2015-09-04 23:53               ` Yinghai Lu
2015-09-07  9:12                 ` Lorenzo Pieralisi
2015-09-14 10:09                   ` Lorenzo Pieralisi
2015-09-14 16:05                     ` Yinghai Lu
2015-09-14 16:28                       ` Lorenzo Pieralisi
2015-09-14 17:36                         ` Yinghai Lu
2015-09-14 23:58                           ` Yinghai Lu
2015-09-15  9:46                             ` Lorenzo Pieralisi
2015-09-15 15:57                               ` Bjorn Helgaas
2015-09-15 16:30                                 ` Lorenzo Pieralisi
2015-09-15 16:51                                   ` Guenter Roeck
2015-09-15 19:25                                     ` Bjorn Helgaas
2015-09-15 20:26                                       ` Yinghai Lu
2015-09-16  8:58                                       ` Lorenzo Pieralisi
2015-09-15 20:17                                     ` Yinghai Lu
2015-09-15 21:07                                       ` Guenter Roeck [this message]
2015-09-15 21:12                                         ` Yinghai Lu
2015-09-09 11:32                 ` Lorenzo Pieralisi
2015-09-09 16:59                   ` Yinghai Lu
2015-09-09 17:22                     ` Yinghai Lu
2015-09-09 17:38                       ` Lorenzo Pieralisi
2015-09-03 10:03     ` oe5hpm
2015-09-03 10:30       ` oe5hpm
2015-09-03 10:51         ` Lorenzo Pieralisi

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=55F88885.9070707@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=chris@zankel.net \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=jejb@parisc-linux.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mingo@redhat.com \
    --cc=monstr@monstr.eu \
    --cc=mpe@ellerman.id.au \
    --cc=oe5hpm@gmail.com \
    --cc=ralf@linux-mips.org \
    --cc=rth@twiddle.net \
    --cc=tony.luck@intel.com \
    --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 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.