From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: linux-pci@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Christian König" <christian.koenig@amd.com>,
"Michał Winiarski" <michal.winiarski@intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
amd-gfx@lists.freedesktop.org, "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>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Michael J . Ruhl" <mjruhl@habana.ai>,
"Andi Shyti" <andi.shyti@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH v3 10/11] drm/amdgpu: Use pci_rebar_get_max_size()
Date: Wed, 22 Oct 2025 16:33:30 +0300 [thread overview]
Message-ID: <20251022133331.4357-11-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20251022133331.4357-1-ilpo.jarvinen@linux.intel.com>
Use pci_rebar_get_max_size() from PCI core to simplify code in
amdgpu_device_resize_fb_bar().
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a77000c2e0bb..f2c4f6996c23 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1673,9 +1673,9 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
int rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size);
struct pci_bus *root;
struct resource *res;
+ int max_size, r;
unsigned int i;
u16 cmd;
- int r;
if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT))
return 0;
@@ -1721,8 +1721,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
return 0;
/* Limit the BAR size to what is available */
- rbar_size = min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1,
- rbar_size);
+ max_size = pci_rebar_get_max_size(adev->pdev, 0);
+ if (max_size < 0)
+ return 0;
+ rbar_size = min(max_size, rbar_size);
/* Disable memory decoding while we change the BAR addresses and size */
pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd);
--
2.39.5
next prev parent reply other threads:[~2025-10-23 7:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 13:33 [PATCH v3 00/11] PCI: Resizable BAR improvements Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 01/11] PCI: Move Resizable BAR code into rebar.c Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 02/11] PCI: Cleanup pci_rebar_bytes_to_size() and move " Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 03/11] PCI: Move pci_rebar_size_to_bytes() and export it Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 04/11] PCI: Improve Resizable BAR functions kernel doc Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 05/11] PCI: Add pci_rebar_size_supported() helper Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 06/11] drm/i915/gt: Use pci_rebar_size_supported() Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 07/11] drm/xe/vram: Use PCI rebar helpers in resize_vram_bar() Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 08/11] PCI: Add pci_rebar_get_max_size() Ilpo Järvinen
2025-10-22 13:33 ` [PATCH v3 09/11] drm/xe/vram: Use pci_rebar_get_max_size() Ilpo Järvinen
2025-10-22 13:33 ` Ilpo Järvinen [this message]
2025-10-22 13:33 ` [PATCH v3 11/11] PCI: Convert BAR sizes bitmasks to u64 Ilpo Järvinen
2025-10-23 21:29 ` [PATCH v3 00/11] PCI: Resizable BAR improvements Bjorn Helgaas
2025-10-23 22:02 ` Lucas De Marchi
2025-10-23 22:13 ` Bjorn Helgaas
2025-10-24 10:39 ` 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=20251022133331.4357-11-ilpo.jarvinen@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andi.shyti@linux.intel.com \
--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=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=michal.winiarski@intel.com \
--cc=mjruhl@habana.ai \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--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