AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Salt <devspam@moreofthesa.me.uk>
To: amd-gfx@lists.freedesktop.org
Cc: Darren Salt <devspam@moreofthesa.me.uk>
Subject: [PATCH 7/7] amdgpu: allow overriding of the GPU's list of supported BAR sizes
Date: Fri, 11 Dec 2020 00:55:06 +0000	[thread overview]
Message-ID: <20201211005506.4554-8-devspam@moreofthesa.me.uk> (raw)
In-Reply-To: <20201211005506.4554-1-devspam@moreofthesa.me.uk>

Some cards don't advertise a BAR size which covers all of the VRAM.

Mine, a Sapphire RX 5600 XT Pulse, advertises only 256MB, 512MB and 1GB.
Despite this, it works fine with the full 6GB visible via an 8GB BAR.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 8 ++++----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index c844e2a8500a..a64a9ac92ac1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -201,7 +201,7 @@ static const bool __maybe_unused no_system_mem_limit;
 
 extern int amdgpu_tmz;
 extern int amdgpu_reset_method;
-extern bool amdgpu_resize_bar;
+extern int amdgpu_resize_bar;
 extern int amdgpu_max_bar_size;
 
 #ifdef CONFIG_DRM_AMDGPU_SI
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b6c5ee490cbf..0f04686ed6c0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1114,6 +1114,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
 	u16 cmd;
 	int r;
 	bool nospc = false;
+	const bool force = amdgpu_resize_bar == 2;
 
 	if (!amdgpu_resize_bar)
 		return 0;
@@ -1175,10 +1176,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
 		/* Skip this size if it isn't advertised.
 		 * This avoids pci_resize_resources returning -EINVAL for that reason.
 		 */
-		if (!(available_sizes & BIT(rbar_size)))
+		if (!force && !(available_sizes & BIT(rbar_size)))
 			continue;
 
-		r = pci_resize_resource(adev->pdev, 0, rbar_size);
+		r = pci_resize_resource(adev->pdev, 0, rbar_size, force);
 		if (r == 0) {
 			dev_dbg(adev->dev, "Succeeded in resizing to %lluMB.",
 			        pci_rebar_size_to_bytes(rbar_size) >> 20);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 0542843c7d63..468ca3725890 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -161,7 +161,7 @@ int amdgpu_force_asic_type = -1;
 int amdgpu_tmz;
 int amdgpu_reset_method = -1; /* auto */
 int amdgpu_num_kcq = -1;
-bool amdgpu_resize_bar = true;
+int amdgpu_resize_bar = 1;
 int amdgpu_max_bar_size = -1;
 
 struct amdgpu_mgpu_info mgpu_info = {
@@ -810,12 +810,12 @@ MODULE_PARM_DESC(num_kcq, "number of kernel compute queue user want to setup (8
 module_param_named(num_kcq, amdgpu_num_kcq, int, 0444);
 
 /**
- * DOC: resize_bar (bool)
+ * DOC: resize_bar (int)
  * Control whether FB BAR should be resized.
  * Enabled by default.
  */
-module_param_named(resize_bar, amdgpu_resize_bar, bool, 0444);
-MODULE_PARM_DESC(resize_bar, "Controls whether the FB BAR should be resized (default = true).");
+module_param_named(resize_bar, amdgpu_resize_bar, int, 0444);
+MODULE_PARM_DESC(resize_bar, "Controls whether the FB BAR should be resized (0 = off, 1 = on (default), 2 = override the GPU's supported sizes).");
 
 /**
  * DOC: max_bar_size (int)
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

      parent reply	other threads:[~2020-12-11  0:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11  0:54 [PATCH 0/7] amdgpu, pci: improved BAR resizing support Darren Salt
2020-12-11  0:55 ` [PATCH 1/7] pci: export PCI BAR size-reading functions Darren Salt
2020-12-11  9:07   ` Christian König
2020-12-11  0:55 ` [PATCH 2/7] pci: add BAR bytes->size helper & expose size->bytes helper Darren Salt
2020-12-11  0:55 ` [PATCH 3/7] amdgpu: resize BAR0 to the maximum available size, even if it doesn't cover VRAM (v2) Darren Salt
2020-12-11 16:42   ` Christian König
2020-12-11 17:31     ` Darren Salt
2020-12-11 19:06       ` Alex Deucher
2020-12-14  8:12       ` Christian König
2020-12-14 15:46         ` Darren Salt
2020-12-14 20:44           ` Christian König
2020-12-11  0:55 ` [PATCH 4/7] amdgpu: module option controlling whether BAR0 resizing is done Darren Salt
2020-12-11  9:09   ` Christian König
2020-12-11  0:55 ` [PATCH 5/7] amdgpu: limit maximum FB BAR size when attempting to enlarge Darren Salt
2020-12-11  0:55 ` [PATCH 6/7] pci: allow for overriding the list of advertised BAR sizes Darren Salt
2020-12-11  0:55 ` Darren Salt [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=20201211005506.4554-8-devspam@moreofthesa.me.uk \
    --to=devspam@moreofthesa.me.uk \
    --cc=amd-gfx@lists.freedesktop.org \
    /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