linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
	mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org,
	Jeremy Linton <jeremy.linton@arm.com>,
	Ali Saidi <alisaidi@amazon.com>,
	David Woodhouse <dwmw@amazon.co.uk>
Subject: Re: arm64 PCI resource allocation issue
Date: Thu, 4 Aug 2022 12:36:41 +0200	[thread overview]
Message-ID: <YuuhOdV09R+K5ui/@lpieralisi> (raw)
In-Reply-To: <204dda77248a7c95787e27fc7a382f514341c88e.camel@kernel.crashing.org>

On Tue, Aug 02, 2022 at 02:07:00PM +1000, Benjamin Herrenschmidt wrote:

[...]

> The case back then was that there existed some (how many ? there was
> one real example if I remember correctly) bogus firwmares that came out
> of UEFI with too small windows. We could just quirk those ....

There is just one way to discover "how many" unfortunately, quirking
those can be more problematic than it seems.

[...]

> The alternative here would be to use ad-hock kludges for such system
> devices, to "register" the addresses early, and have some kind of hook
> in the PCI code that keeps track of them as they get remapped.

That's what x86 does AFAICS (pcibios_save_fw_addr()), even though
it is used in a different scope (ie revert to FW address if the
resource allocation fails).

> If we want this, I would propose (happy to provide the implementation
> but let's discuss the design first) something along the line of a
> generic mechanism to "register" such a system device, which would add
> it to a list. That list would be scanned on PCI device discovery for
> BAR address matches, and the pci_dev/BAR# added to the entry (that or
> put a pointer to the entry into pci_dev for speed/efficiency).
> 
> The difficulty is how is that update propagated:
> 
> This is of course fiddly. For example, the serial info is passed via
> two different ways, one being earlycon (and probably the easiest to
> track), the other one an ASCII string passed to
> add_preferred_console(), which would require more significant hackery
> (the code dealing with console mathing is a gothic horror).
> 
> Also if such a system device is in continuous use during the boot
> process (UART ?) it needs to be "updated" as soon as possible after the
> BARs (and parent BARs) have been also updated (in fact this is
> generally why PCI debug dies horribly when using PCI based UARTs).
> Maybe an (optional) callback that earlycon can add ?
> 
> Additionally, this would only work if such system devices are
> "registered" before they get remapped... 
> 
> Another approach would be to have pci_dev keep a copy of the original
> resources (at least for the primary BARs) and provide an accessor for
> use by things like earlycon or 8250 to compare against these, though
> that doesn't solve the problem of promptly "updating" drivers for
> system devices.
> 
> Opinions ?

You may also want to look into IORESOURCE_PCI_FIXED even though the
last time I looked into I found some broken logic (basically the
immutable/"fixed" BAR resources should obviously take into account the
PCI tree hierarchy - upstream bridges, etc., which I don't think
IORESOURCE_PCI_FIXED does - how it works remains a bit of
a mystery for me).

Lorenzo

  parent reply	other threads:[~2022-08-04 10:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02  4:07 arm64 PCI resource allocation issue Benjamin Herrenschmidt
2022-08-02  7:46 ` Ard Biesheuvel
2022-08-02  9:18   ` [EXTERNAL]arm64 " David Woodhouse
2022-08-03  2:32     ` Benjamin Herrenschmidt
2022-08-03  2:31   ` arm64 " Benjamin Herrenschmidt
2022-08-04 10:36 ` Lorenzo Pieralisi [this message]
2022-08-04 23:51   ` Benjamin Herrenschmidt
2022-08-15 23:02     ` Benjamin Herrenschmidt

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=YuuhOdV09R+K5ui/@lpieralisi \
    --to=lpieralisi@kernel.org \
    --cc=alisaidi@amazon.com \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=dwmw@amazon.co.uk \
    --cc=jeremy.linton@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mark.rutland@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 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).