Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Sergei Miroshnichenko <s.miroshnichenko@yadro.com>
To: "christian.koenig@amd.com" <christian.koenig@amd.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Cc: "David.Laight@ACULAB.COM" <David.Laight@ACULAB.COM>,
	"rajatja@google.com" <rajatja@google.com>,
	"ardb@kernel.org" <ardb@kernel.org>,
	"helgaas@kernel.org" <helgaas@kernel.org>,
	"linux@yadro.com" <linux@yadro.com>, "sr@denx.de" <sr@denx.de>,
	"lukas@wunner.de" <lukas@wunner.de>,
	"andy.lavr@gmail.com" <andy.lavr@gmail.com>
Subject: Re: [PATCH v8 00/24] PCI: Allow BAR movement during boot and hotplug
Date: Mon, 4 May 2020 09:30:18 +0000	[thread overview]
Message-ID: <5278f3e1fbdafa92b4b44effb64c443bbbf0852e.camel@yadro.com> (raw)
In-Reply-To: <7cd27165-0d30-0ef1-dde3-104c9878bd37@amd.com>

Hello Christian,

On Tue, 2020-04-28 at 14:59 +0200, Christian König wrote:
> Well that is a really nice surprise. Just FYI the situation with GPUs
> is 
> essentially this:
> 
> a) The BAR to access video memory with the CPU is by default only
> 256MB 
> in size for backward compatibility with 32bit Windows 7 and older.
> 
> b) Modern GPUs easily have 16GB of video memory, but most of that
> used 
> to be accessed only rarely by the CPU. Unfortunately this has
> changed 
> recently by getting more modern graphics APIs in userspace (Vulkan).
> 
> c) Both NVidia as well as AMD used to have a mechanism to map
> different 
> stuff into the 256MB window, but AMD dropped this ability quite some 
> time ago because it was rather inefficient.
> 
> d) Instead for hard of the last 5 years AMD implements the PCI
> standard 
> for dynamic BAR resizing. So what we do is to extend the 256MB BAR
> into 
> 16GB (or whatever is needed) once the OS is started and the driver
> loads.
> 
> The problem with this approach is that sometimes bridges can't be 
> reconfigured and BARs resized because we have other BARs currently
> in 
> use under the same bridge.
> 
> So long story short you have fixed my BAR resizing problem with this 
> patchset as well :D
> 

Thanks for introducing to this problem, it is not yet covered by
this code, so I'll modify the pci_resize_resource(): let it try as
it does now, and if that didn't work - try pci_rescan_bus(), which
moves BARs.

To test this, do I need to trigger a BAR resizing manually, or
drm/amdgpu will do it automatically during init?

May these resized BAR change their start address during init?

> Am 27.04.20 um 20:23 schrieb Sergei Miroshnichenko:
> > ...
> > 
> > Drivers indicate their support of the feature by implementing the
> > new hooks
> > .rescan_prepare() and .rescan_done() in the struct pci_driver. If a
> > driver
> > doesn't yet support the feature, BARs of its devices will be
> > considered as
> > immovable and handled in the same way as resources with the
> > PCI_FIXED flag:
> > they are guaranteed to remain untouched.
> 
> Could we let rescan_prepare() optionally return an error and then 
> consider the BARs in question not movable for the current rescan? 
> Alternatively would it be allowed in the implementation of the 
> rescan_prepare() callback to update the PCI_FIXED flags on the BARs?
> 
> Problem is that we can't know beforehand if a BAR is currently in use
> or 
> not or if we can block the uses until the rescan is completed.

I guess one more optional hook may be added to the pci_driver:

  bool (*bar_fixed)(struct pci_dev *dev, struct resource *res);

So a driver can mark some BARs as fixed, and some - as movable, in
runtime, depending on current conditions.

If rescan_prepare() and rescan_done() hooks are set, but bar_fixed()
isn't, consider every BAR as movable. If bar_fixed() is set and returns
false, the driver must not use it between rescan_prepare() and
rescan_done().

Best regards,
Serge

  reply	other threads:[~2020-05-04  9:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 18:23 [PATCH v8 00/24] PCI: Allow BAR movement during boot and hotplug Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 01/24] PCI: Fix race condition in pci_enable/disable_device() Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 02/24] PCI: Ensure a bridge has I/O and MEM access for hot-added devices Sergei Miroshnichenko
2020-04-29  6:30   ` kbuild test robot
2020-04-27 18:23 ` [PATCH v8 03/24] PCI: hotplug: Initial support of the movable BARs feature Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 04/24] PCI: Add version of release_child_resources() aware of fixed BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 05/24] PCI: hotplug: Fix reassigning the released BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 06/24] PCI: hotplug: Recalculate every bridge window during rescan Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 07/24] PCI: hotplug: Don't allow hot-added devices to steal resources Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 08/24] PCI: Reassign BARs if BIOS/bootloader had assigned not all of them Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 09/24] PCI: hotplug: Try to reassign movable BARs only once Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 10/24] PCI: hotplug: Calculate fixed parts of bridge windows Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 11/24] PCI: Include fixed BARs into the bus size calculating Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 12/24] PCI: hotplug: movable BARs: Compute limits for relocated bridge windows Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 13/24] PCI: Make sure bridge windows include their fixed BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 14/24] PCI: hotplug: Add support of fixed BARs to pci_assign_resource() Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 15/24] PCI: hotplug: Sort fixed BARs before assignment Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 16/24] x86/PCI/ACPI: Fix up PCIBIOS_MIN_MEM if value computed from e820 is invalid Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 17/24] PCI: hotplug: Configure MPS after manual bus rescan Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 18/24] PCI: hotplug: Don't disable the released bridge windows immediately Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 19/24] PCI: pciehp: Trigger a domain rescan on hp events when enabled movable BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 20/24] PCI: Don't claim fixed BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 21/24] PCI: hotplug: Don't reserve bus space when enabled movable BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 22/24] PCI: hotplug: Enable the movable BARs feature by default Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 23/24] PCI/portdrv: Declare support of movable BARs Sergei Miroshnichenko
2020-04-27 18:23 ` [PATCH v8 24/24] nvme-pci: Handle " Sergei Miroshnichenko
2020-04-28 12:59 ` [PATCH v8 00/24] PCI: Allow BAR movement during boot and hotplug Christian König
2020-05-04  9:30   ` Sergei Miroshnichenko [this message]
2020-08-10 22:21 ` Bjorn Helgaas

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=5278f3e1fbdafa92b4b44effb64c443bbbf0852e.camel@yadro.com \
    --to=s.miroshnichenko@yadro.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=andy.lavr@gmail.com \
    --cc=ardb@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@yadro.com \
    --cc=lukas@wunner.de \
    --cc=rajatja@google.com \
    --cc=sr@denx.de \
    /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