All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	PCI <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH] PCI: decline to resize resources if boot config must be preserved
Date: Wed, 13 Jan 2021 10:55:57 +0100	[thread overview]
Message-ID: <CAMj1kXHLPvaQ74fnDCfz-5ZSmCjkeZddiq+C-nd_Xmh2k-x1bg@mail.gmail.com> (raw)
In-Reply-To: <20210112224919.GA1859692@bjorn-Precision-5520>

On Tue, 12 Jan 2021 at 23:49, Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Sat, Jan 09, 2021 at 10:53:53AM +0100, Ard Biesheuvel wrote:
> > The _DSM #5 method in the ACPI host bridge object tells us whether the
> > OS is permitted to deviate from the resource assignment configured by
> > the firmware. If this is not the case, we should not permit drivers to
> > resize BARs on the fly. So make pci_resize_resource() take this into
> > account.
> >
> > Cc: <stable@vger.kernel.org> # v5.4+
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> Capitalized subject to match convention and applied to pci/resource
> for v5.11, thanks!
>
> Is there an email, bug report, etc that prompted this change?
>

No, I was just reviewing the recent Tianocore changes to perform BAR
resizing before resource assignment even takes places, which is
obviously a more appropriate time to do it, as it does not require the
OS to modify the firmware configuration at all. This reminded me of
_DSM #5 and the fact that the OS may not even be permitted to make any
changes.


> > ---
> >  drivers/pci/setup-res.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
> > index 43eda101fcf4..3b38be081e93 100644
> > --- a/drivers/pci/setup-res.c
> > +++ b/drivers/pci/setup-res.c
> > @@ -410,10 +410,16 @@ EXPORT_SYMBOL(pci_release_resource);
> >  int pci_resize_resource(struct pci_dev *dev, int resno, int size)
> >  {
> >       struct resource *res = dev->resource + resno;
> > +     struct pci_host_bridge *host;
> >       int old, ret;
> >       u32 sizes;
> >       u16 cmd;
> >
> > +     /* Check if we must preserve the firmware's resource assignment */
> > +     host = pci_find_host_bridge(dev->bus);
> > +     if (host->preserve_config)
> > +             return -ENOTSUPP;
> > +
> >       /* Make sure the resource isn't assigned before resizing it. */
> >       if (!(res->flags & IORESOURCE_UNSET))
> >               return -EBUSY;
> > --
> > 2.17.1
> >

      reply	other threads:[~2021-01-13  9:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09  9:53 [PATCH] PCI: decline to resize resources if boot config must be preserved Ard Biesheuvel
2021-01-12 22:49 ` Bjorn Helgaas
2021-01-13  9:55   ` Ard Biesheuvel [this message]

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=CAMj1kXHLPvaQ74fnDCfz-5ZSmCjkeZddiq+C-nd_Xmh2k-x1bg@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    /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.