From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Simon Richter" <Simon.Richter@hogyros.de>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
amd-gfx@lists.freedesktop.org,
"Bjorn Helgaas" <bhelgaas@google.com>,
"David Airlie" <airlied@gmail.com>,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
intel-xe@lists.freedesktop.org,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
linux-pci@vger.kernel.org,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Michał Winiarski" <michal.winiarski@intel.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 8/9] drm/amdgpu: Remove driver side BAR release before resize
Date: Tue, 11 Nov 2025 14:56:08 +0200 (EET) [thread overview]
Message-ID: <10b095b5-f433-3bfc-c1c9-5da7db560696@linux.intel.com> (raw)
In-Reply-To: <fd7fdf61-cb08-4dfc-ba7a-a8a5b7eb9fda@amd.com>
[-- Attachment #1: Type: text/plain, Size: 4172 bytes --]
On Tue, 11 Nov 2025, Christian König wrote:
> On 11/11/25 12:08, Ilpo Järvinen wrote:
> > On Tue, 11 Nov 2025, Christian König wrote:
> >
> >> Sorry for the late reply I'm really busy at the moment.
> >>
> >> On 10/28/25 18:35, Ilpo Järvinen wrote:
> >>> PCI core handles releasing device's resources and their rollback in
> >>> case of failure of a BAR resizing operation. Releasing resource prior
> >>> to calling pci_resize_resource() prevents PCI core from restoring the
> >>> BARs as they were.
> >>
> >> I've intentionally didn't do it this way because at least on AMD HW we
> >> could only release the VRAM and doorbell BAR (both 64bit), but not the
> >> register BAR (32bit only).
> >>
> >> This patch set looks like the right thing in general, but which BARs are
> >> now released by pci_resize_resource()?
> >>
> >> If we avoid releasing the 32bit BAR as well then that should work,
> >> otherwise we will probably cause problems.
> >
> > After these changes, pci_resize_resource() releases BARs that share the
> > bridge window with the BAR to be resized. So the answer depends on the
> > upstream bridge.
> >
> > However, amdgpu_device_resize_fb_bar() also checks that root bus has a
> > resource with a 64-bit address. That won't tell what the nearest bridge
> > has though. Maybe that check should be converted to check the resources of
> > the nearest bus instead? It would make it impossible to have the
> > 32-bit resource share the bridge window with the 64-bit resources so the
> > resize would be safe.
>
> Mhm, I don't think that will work.
>
>
> I've added the check for the root bus to avoid a couple of issues during
> resize, but checking the nearest bridge would block a whole bunch of use
> cases and isn't even 100% save.
>
> See one use case of this is that all the BARs of the device start in the
> same 32bit bridge window (or a mixture of 64bit and 32bit window).
"32bit bridge window" is ambiguous. There are non-prefetchable and
prefetchable bridge windows, out of which the latter can be 64-bit as
well. Which one you're talking about?
If a 64-bit prefetchable window exists, pbus_size_mem() nor
__pci_assign_resource() would not have produced such a configuration where
they're put into the same bridge window, even before the commit
ae88d0b9c57f ("PCI: Use pbus_select_window_for_type() during mem window
sizing") (I think). Now pbus_size_mem() certainly doesn't.
> What we have is that BAR 0 and 2 are 64bit BARs which can (after some
> preparation) move around freely. But IIRC BAR 4 are the legacy I/O ports
> and BAR 5 is the 32bit MMIO registers (don't nail me on that, could be
> just the other way around).
>
> Especially that 32bit MMIO BAR *can't* move! Not only because it is
> 32bit, but also because the amdgpu driver as well as the HW itself
> through the VGA emulation, as well as the EFI/VESA/VBIOS code might
> reference its absolute address.
So if the 64-bit check is replaced with this:
+ /* Check if the parent bridge has a 64-bit (pref) memory resource */
+ res = pci_resource_n(adev->pdev, 0)->parent;
+ /* Trying to resize is pointless without a window above 4GB */
+ if (!(res->flags & IORESOURCE_MEM_64))
return 0;
...I don't think it's possible for 32-bit resource to share that window
under _any_ circumstance.
If you say that ->parent somehow points to a non-IORESOURCE_MEM_64 window
at this point, you're implying allocation for the 64-bit prefetchable
window was tried and failed, and __pci_assign_resource() then used one of
its fallbacks.
Are you saying that "some preparation" includes making room for that
64-bit prefetchable window that failed to assign earlier as I cannot see
how else it would ever get assigned so that the 64-bit BARs could be moved
there?
> Could we give pci_resize_resource() a mask of BARs which are save to
> release?
It is possible.
> Or maybe a flag to indicate that it can only free up 64bit BARs?
>
> Regards,
> Christian.
>
> >
> > Thanks a lot for checking this out!
> >
>
--
i.
next prev parent reply other threads:[~2025-11-11 12:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 17:35 [PATCH 0/9] PCI: BAR resizing fix/rework Ilpo Järvinen
2025-10-28 17:35 ` [PATCH 1/9] PCI: Prevent resource tree corruption when BAR resize fails Ilpo Järvinen
2025-10-29 23:36 ` Bjorn Helgaas
2025-10-30 8:22 ` Ilpo Järvinen
2025-11-10 22:59 ` Bjorn Helgaas
2025-10-28 17:35 ` [PATCH 2/9] PCI/IOV: Adjust ->barsz[] when changing BAR size Ilpo Järvinen
2025-11-13 16:29 ` Bjorn Helgaas
2025-11-13 16:35 ` Ilpo Järvinen
2025-11-13 16:57 ` Bjorn Helgaas
2025-11-13 21:02 ` Bjorn Helgaas
2025-10-28 17:35 ` [PATCH 3/9] PCI: Change pci_dev variable from 'bridge' to 'dev' Ilpo Järvinen
2025-10-28 17:35 ` [PATCH 4/9] PCI: Try BAR resize even when no window was released Ilpo Järvinen
2025-10-28 17:35 ` [PATCH 5/9] PCI: Fix restoring BARs on BAR resize rollback path Ilpo Järvinen
2025-10-28 17:35 ` [PATCH 6/9] drm/xe: Remove driver side BAR release before resize Ilpo Järvinen
2025-10-28 21:24 ` Lucas De Marchi
2025-10-30 14:37 ` Lucas De Marchi
2025-10-28 17:35 ` [PATCH 7/9] drm/i915: " Ilpo Järvinen
2025-11-10 22:53 ` Bjorn Helgaas
2025-10-28 17:35 ` [PATCH 8/9] drm/amdgpu: " Ilpo Järvinen
2025-11-10 22:54 ` Bjorn Helgaas
2025-11-11 9:08 ` Christian König
2025-11-11 11:08 ` Ilpo Järvinen
2025-11-11 12:08 ` Christian König
2025-11-11 12:56 ` Ilpo Järvinen [this message]
2025-11-11 15:07 ` Christian König
2025-11-11 15:52 ` Ilpo Järvinen
2025-11-11 23:30 ` Liu, Monk
2025-10-28 17:35 ` [PATCH 9/9] PCI: Prevent restoring assigned resources Ilpo Järvinen
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=10b095b5-f433-3bfc-c1c9-5da7db560696@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Simon.Richter@hogyros.de \
--cc=airlied@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=michal.winiarski@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
/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