amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: amd-gfx@lists.freedesktop.org
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Felix Kuehling" <Felix.Kuehling@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: [PATCH 07/17] drm/amdgpu/gmc: add new helper to get the FB size used by pre-OS console
Date: Thu, 30 Jul 2020 16:04:04 -0400	[thread overview]
Message-ID: <20200730200414.40485-8-alexander.deucher@amd.com> (raw)
In-Reply-To: <20200730200414.40485-1-alexander.deucher@amd.com>

This adds a new gmc callback to get the size reserved by the pre-OS
console and provides a helper function for use by gmc IP drivers.

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 43 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 +++
 2 files changed, 48 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 21d2c8543f85..fc9e18aaa76e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -27,6 +27,7 @@
 #include <linux/io-64-nonatomic-lo-hi.h>
 
 #include "amdgpu.h"
+#include "amdgpu_gmc.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_xgmi.h"
 
@@ -431,3 +432,45 @@ void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
 		WREG32(reg, tmp);
 	}
 }
+
+void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
+{
+	unsigned size;
+
+	/*
+	 * TODO:
+	 * Currently there is a bug where some memory client outside
+	 * of the driver writes to first 8M of VRAM on S3 resume,
+	 * this overrides GART which by default gets placed in first 8M and
+	 * causes VM_FAULTS once GTT is accessed.
+	 * Keep the stolen memory reservation until the while this is not solved.
+	 */
+	switch (adev->asic_type) {
+	case CHIP_VEGA10:
+	case CHIP_RAVEN:
+	case CHIP_ARCTURUS:
+	case CHIP_RENOIR:
+		adev->gmc.keep_stolen_vga_memory = true;
+		break;
+	default:
+		adev->gmc.keep_stolen_vga_memory = false;
+		break;
+	}
+
+	if (!amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_DCE))
+		size = 0;
+	else
+		size = amdgpu_gmc_get_vbios_fb_size(adev);
+
+	/* set to 0 if the pre-OS buffer uses up most of vram */
+	if ((adev->gmc.real_vram_size - size) < (8 * 1024 * 1024))
+		size = 0;
+
+	if (size > AMDGPU_VBIOS_VGA_ALLOCATION) {
+		adev->gmc.stolen_vga_size = AMDGPU_VBIOS_VGA_ALLOCATION;
+		adev->gmc.stolen_extended_size = size - adev->gmc.stolen_vga_size;
+	} else {
+		adev->gmc.stolen_vga_size = size;
+		adev->gmc.stolen_extended_size = 0;
+	}
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 8f4af955d72c..c2a85d0b1546 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -131,6 +131,8 @@ struct amdgpu_gmc_funcs {
 	void (*get_vm_pte)(struct amdgpu_device *adev,
 			   struct amdgpu_bo_va_mapping *mapping,
 			   uint64_t *flags);
+	/* get the amount of memory used by the vbios for pre-OS console */
+	unsigned int (*get_vbios_fb_size)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_xgmi {
@@ -253,6 +255,7 @@ struct amdgpu_gmc {
 #define amdgpu_gmc_map_mtype(adev, flags) (adev)->gmc.gmc_funcs->map_mtype((adev),(flags))
 #define amdgpu_gmc_get_vm_pde(adev, level, dst, flags) (adev)->gmc.gmc_funcs->get_vm_pde((adev), (level), (dst), (flags))
 #define amdgpu_gmc_get_vm_pte(adev, mapping, flags) (adev)->gmc.gmc_funcs->get_vm_pte((adev), (mapping), (flags))
+#define amdgpu_gmc_get_vbios_fb_size(adev) (adev)->gmc.gmc_funcs->get_vbios_fb_size((adev))
 
 /**
  * amdgpu_gmc_vram_full_visible - Check if full VRAM is visible through the BAR
@@ -307,4 +310,6 @@ extern void
 amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
 			      bool enable);
 
+void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev);
+
 #endif
-- 
2.25.4

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

  parent reply	other threads:[~2020-07-30 20:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 20:03 [PATCH 00/17] rework stolen pre-OS fb allocation handling (v3) Alex Deucher
2020-07-30 20:03 ` [PATCH 01/17] drm/amdgpu: handle bo size 0 in amdgpu_bo_create_kernel_at (v2) Alex Deucher
2020-07-30 20:03 ` [PATCH 02/17] drm/amdgpu: use create_at for the stolen pre-OS buffer Alex Deucher
2020-07-30 20:04 ` [PATCH 03/17] drm/amdgpu: use a define for the memory size of the vga emulator Alex Deucher
2020-07-30 20:04 ` [PATCH 04/17] drm/amdgpu: move stolen vga bo from amdgpu to amdgpu.gmc Alex Deucher
2020-07-30 20:04 ` [PATCH 05/17] drm/amdgpu: move keep stolen memory check into gmc core Alex Deucher
2020-07-30 20:04 ` [PATCH 06/17] drm/amdgpu: add support for extended stolen vga memory Alex Deucher
2020-07-30 20:04 ` Alex Deucher [this message]
2020-07-30 20:04 ` [PATCH 08/17] drm/amdgpu/gmc6: switch to using amdgpu_gmc_get_vbios_allocations Alex Deucher
2020-07-30 20:04 ` [PATCH 09/17] drm/amdgpu/gmc7: " Alex Deucher
2020-07-30 20:04 ` [PATCH 10/17] drm/amdgpu/gmc8: " Alex Deucher
2020-07-30 20:04 ` [PATCH 11/17] drm/amdgpu/gmc9: " Alex Deucher
2020-07-30 20:04 ` [PATCH 12/17] drm/amdgpu/gmc10: " Alex Deucher
2020-07-30 20:04 ` [PATCH 13/17] drm/amdgpu: drop the CPU pointers for the stolen vga bos Alex Deucher
2020-07-30 20:04 ` [PATCH 14/17] drm/amdgpu/gmc: disable keep_stolen_vga_memory on arcturus Alex Deucher
2020-07-30 20:04 ` [PATCH 15/17] drm/amdgpu: move stolen memory from gmc to mman Alex Deucher
2020-07-30 20:04 ` [PATCH 16/17] drm/amdgpu: move IP discovery data " Alex Deucher
2020-07-30 20:04 ` [PATCH 17/17] drm/amdgpu: move vram usage by vbios to mman (v2) Alex Deucher
2020-07-31  6:45   ` Christian König
  -- strict thread matches above, loose matches on Subject: below --
2020-07-29 17:34 [PATCH 00/17] rework stolen pre-OS fb allocation handling (v2) Alex Deucher
2020-07-29 17:34 ` [PATCH 07/17] drm/amdgpu/gmc: add new helper to get the FB size used by pre-OS console Alex Deucher

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=20200730200414.40485-8-alexander.deucher@amd.com \
    --to=alexdeucher@gmail.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.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).