<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="Microsoft YaHei UI, Microsoft YaHei, ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;">Do we need to add check for <span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;">adev->pm.smu_prv_buffer_size
before calling</span></span></font></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;">pp_reserve_vram_for_smu()? I mean maybe for <span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;">dev->pm.smu_prv_buffer_size
==0, there is no need to proceed <span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;">pp_reserve_vram_for_smu.</span></span></span><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><br>
</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Regards,</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: "Microsoft YaHei UI", "Microsoft YaHei", ΢ÈíÑźÚ, SimSun, ËÎÌå, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Evan</span></span></span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>·¢¼þÈË:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> ´ú±í Rex Zhu <Rex.Zhu@amd.com><br>
<b>·¢ËÍʱ¼ä:</b> 2018Äê4ÔÂ13ÈÕ 16:19:13<br>
<b>ÊÕ¼þÈË:</b> amd-gfx@lists.freedesktop.org<br>
<b>³ËÍ:</b> Zhu, Rex<br>
<b>Ö÷Ìâ:</b> [PATCH 1/2] drm/amdgpu: Reserved vram for smu to save debug info.</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44 +++++++++++++++++++++++++++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 2 ++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++++<br>
drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 36 ++++++++++++++++++++++<br>
5 files changed, 89 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
index c688361..5ef0bc8 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
@@ -129,6 +129,7 @@<br>
extern int amdgpu_compute_multipipe;<br>
extern int amdgpu_gpu_recovery;<br>
extern int amdgpu_emu_mode;<br>
+extern uint amdgpu_smu_memory_pool_size;<br>
<br>
#ifdef CONFIG_DRM_AMDGPU_SI<br>
extern int amdgpu_si_support;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
index 1762eb4..bcbbd23 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
@@ -690,6 +690,8 @@ void amdgpu_device_gart_location(struct amdgpu_device *adev,<br>
{<br>
u64 size_af, size_bf;<br>
<br>
+ mc->gart_size += adev->pm.smu_prv_buffer_size;<br>
+<br>
size_af = adev->gmc.mc_mask - mc->vram_end;<br>
size_bf = mc->vram_start;<br>
if (size_bf > size_af) {<br>
@@ -907,6 +909,46 @@ static void amdgpu_device_check_vm_size(struct amdgpu_device *adev)<br>
}<br>
}<br>
<br>
+static void amdgpu_device_check_smu_prv_buffer_size(struct amdgpu_device *adev)<br>
+{<br>
+ struct sysinfo si;<br>
+ bool is_os_64 = (sizeof(void *) == 8) ? true : false;<br>
+ uint64_t total_memory;<br>
+ uint64_t dram_size_seven_GB = 0x1B8000000;<br>
+ uint64_t dram_size_three_GB = 0xB8000000;<br>
+<br>
+ if (amdgpu_smu_memory_pool_size == 0)<br>
+ return;<br>
+<br>
+ if (!is_os_64) {<br>
+ DRM_WARN("Not 64-bit OS, feature not supported\n");<br>
+ goto def_value;<br>
+ }<br>
+ si_meminfo(&si);<br>
+ total_memory = (uint64_t)si.totalram * si.mem_unit;<br>
+<br>
+ if ((amdgpu_smu_memory_pool_size == 1) ||<br>
+ (amdgpu_smu_memory_pool_size == 2)) {<br>
+ if (total_memory < dram_size_three_GB)<br>
+ goto def_value1;<br>
+ } else if ((amdgpu_smu_memory_pool_size == 4) ||<br>
+ (amdgpu_smu_memory_pool_size == 8)) {<br>
+ if (total_memory < dram_size_seven_GB)<br>
+ goto def_value1;<br>
+ } else {<br>
+ DRM_WARN("Smu memory pool size not supported\n");<br>
+ goto def_value;<br>
+ }<br>
+ adev->pm.smu_prv_buffer_size = amdgpu_smu_memory_pool_size << 28;<br>
+<br>
+ return;<br>
+<br>
+def_value1:<br>
+ DRM_WARN("No enough system memory\n");<br>
+def_value:<br>
+ adev->pm.smu_prv_buffer_size = 0;<br>
+}<br>
+<br>
/**<br>
* amdgpu_device_check_arguments - validate module params<br>
*<br>
@@ -948,6 +990,8 @@ static void amdgpu_device_check_arguments(struct amdgpu_device *adev)<br>
amdgpu_vm_fragment_size = -1;<br>
}<br>
<br>
+ amdgpu_device_check_smu_prv_buffer_size(adev);<br>
+<br>
amdgpu_device_check_vm_size(adev);<br>
<br>
amdgpu_device_check_block_size(adev);<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h<br>
index b8c5177..19d8bf5 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h<br>
@@ -445,6 +445,8 @@ struct amdgpu_pm {<br>
uint32_t pcie_gen_mask;<br>
uint32_t pcie_mlw_mask;<br>
struct amd_pp_display_configuration pm_display_cfg;/* set by dc */<br>
+ uint32_t smu_prv_buffer_size;<br>
+ struct amdgpu_bo *smu_prv_buffer;<br>
};<br>
<br>
#define R600_SSTU_DFLT 0<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br>
index 0b19482..5c0567a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br>
@@ -132,6 +132,7 @@<br>
int amdgpu_compute_multipipe = -1;<br>
int amdgpu_gpu_recovery = -1; /* auto */<br>
int amdgpu_emu_mode = 0;<br>
+uint amdgpu_smu_memory_pool_size = 0;<br>
<br>
MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");<br>
module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);<br>
@@ -316,6 +317,11 @@<br>
module_param_named(cik_support, amdgpu_cik_support, int, 0444);<br>
#endif<br>
<br>
+MODULE_PARM_DESC(smu_memory_pool_size,<br>
+ "reserve gtt for smu debug usage, 0 = disable,"<br>
+ "0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte");<br>
+module_param_named(smu_memory_pool_size, amdgpu_smu_memory_pool_size, uint, 0444);<br>
+<br>
static const struct pci_device_id pciidlist[] = {<br>
#ifdef CONFIG_DRM_AMDGPU_SI<br>
{0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
index 66c49b8..0cdfa41 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
@@ -145,6 +145,39 @@ static int pp_hw_fini(void *handle)<br>
return 0;<br>
}<br>
<br>
+static void pp_reserve_vram_for_smu(struct amdgpu_device *adev)<br>
+{<br>
+ int r = -EINVAL;<br>
+ void *cpu_ptr = NULL;<br>
+ uint64_t gpu_addr;<br>
+ struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;<br>
+<br>
+ if (amdgpu_bo_create_kernel(adev, adev->pm.smu_prv_buffer_size,<br>
+ PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,<br>
+ &adev->pm.smu_prv_buffer,<br>
+ &gpu_addr,<br>
+ &cpu_ptr)) {<br>
+ DRM_ERROR("amdgpu: failed to create smu prv buffer \n");<br>
+ return;<br>
+ }<br>
+<br>
+ if (hwmgr->hwmgr_func->notify_cac_buffer_info)<br>
+ r = hwmgr->hwmgr_func->notify_cac_buffer_info(hwmgr,<br>
+ lower_32_bits((unsigned long)cpu_ptr),<br>
+ upper_32_bits((unsigned long)cpu_ptr),<br>
+ lower_32_bits(gpu_addr),<br>
+ upper_32_bits(gpu_addr),<br>
+ adev->pm.smu_prv_buffer_size);<br>
+<br>
+ if (r) {<br>
+ amdgpu_bo_free_kernel(&adev->pm.smu_prv_buffer, NULL, NULL);<br>
+ adev->pm.smu_prv_buffer = NULL;<br>
+ DRM_ERROR("amdgpu: failed to notify SMU buffer address.\n");<br>
+ }<br>
+<br>
+ return;<br>
+}<br>
+<br>
static int pp_late_init(void *handle)<br>
{<br>
struct amdgpu_device *adev = handle;<br>
@@ -156,6 +189,7 @@ static int pp_late_init(void *handle)<br>
AMD_PP_TASK_COMPLETE_INIT, NULL);<br>
mutex_unlock(&hwmgr->smu_lock);<br>
}<br>
+ pp_reserve_vram_for_smu(adev);<br>
return 0;<br>
}<br>
<br>
@@ -163,6 +197,8 @@ static void pp_late_fini(void *handle)<br>
{<br>
struct amdgpu_device *adev = handle;<br>
<br>
+ if (adev->pm.smu_prv_buffer)<br>
+ amdgpu_bo_free_kernel(&adev->pm.smu_prv_buffer, NULL, NULL);<br>
amd_powerplay_destroy(adev);<br>
}<br>
<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>