[PATCH] drm/amd/display: Enable fast plane updates on DCN3.2 and above when state->allow_modeset = true

2023-10-06 Thread Tianci Yin
From: tiancyin 

[why]
When cursor moves across screen boarder, lag cursor observed,
since subvp settings need to sync up with vblank, that cause
cursor updates being delayed.

[how]
Enable fast plane updates on DCN3.2 to fix it.

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index c21726bdbca2..25a0bd314fe5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -9879,6 +9879,7 @@ static bool should_reset_plane(struct drm_atomic_state 
*state,
struct drm_plane *other;
struct drm_plane_state *old_other_state, *new_other_state;
struct drm_crtc_state *new_crtc_state;
+   struct amdgpu_device *adev = drm_to_adev(plane->dev);
int i;
 
/*
@@ -9886,7 +9887,7 @@ static bool should_reset_plane(struct drm_atomic_state 
*state,
 * enough to determine when we need to reset all the planes on
 * the stream.
 */
-   if (state->allow_modeset)
+   if (adev->ip_versions[DCE_HWIP][0] < IP_VERSION(3, 2, 0) && 
state->allow_modeset)
return true;
 
/* Exit early if we know that we're adding or removing the plane. */
-- 
2.34.1



[PATCH] drm/amd/display: fix dm irq error message in gpu recover

2023-02-07 Thread Tianci Yin
From: tiancyin 

[Why]
Variable adev->crtc_irq.num_types was initialized as the value of
adev->mode_info.num_crtc at early_init stage, later at hw_init stage,
the num_crtc changed due to the display pipe harvest on some SKUs,
but the num_types was not updated accordingly, that cause below error
in gpu recover.

  *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3

[How]
Defer the initialization of num_types to eliminate the error logs.

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b31cfda30ff9..506699c0d316 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4226,6 +4226,8 @@ static int amdgpu_dm_initialize_drm_device(struct 
amdgpu_device *adev)
/* Update the actual used number of crtc */
adev->mode_info.num_crtc = adev->dm.display_indexes_num;
 
+   amdgpu_dm_set_irq_funcs(adev);
+
link_cnt = dm->dc->caps.max_links;
if (amdgpu_dm_mode_config_init(dm->adev)) {
DRM_ERROR("DM: Failed to initialize mode config\n");
@@ -4714,8 +4716,6 @@ static int dm_early_init(void *handle)
break;
}
 
-   amdgpu_dm_set_irq_funcs(adev);
-
if (adev->mode_info.funcs == NULL)
adev->mode_info.funcs = _display_funcs;
 
-- 
2.34.1



[PATCH] drm/amd/display: Align num_crtc to max_streams

2023-02-06 Thread Tianci Yin
From: tiancyin 

[Why]
Display pipe might be harvested on some SKUs, that cause the
adev->mode_info.num_crtc mismatch with the usable crtc number,
then below error dmesgs observed after GPU recover.

  *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
  *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3

[How]
The max_streams is limited number after pipe fuse, align num_crtc
to max_streams to eliminate the error logs.

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b31cfda30ff9..87ec2574cc09 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4285,6 +4285,9 @@ static int amdgpu_dm_initialize_drm_device(struct 
amdgpu_device *adev)
break;
}
 
+   /* Adjust the crtc number according to the DCN pipe fuse. */
+   adev->mode_info.num_crtc = dm->dc->caps.max_streams;
+
for (i = 0; i < dm->dc->caps.max_streams; i++)
if (amdgpu_dm_crtc_init(dm, mode_info->planes[i], i)) {
DRM_ERROR("KMS: Failed to initialize crtc\n");
-- 
2.34.1



[PATCH] drm/amd/display: Disable migration to ensure consistency of per-CPU variable

2023-02-05 Thread Tianci Yin
From: tiancyin 

[why]
Since the variable fpu_recursion_depth is per-CPU type, it has one copy
on each CPU, thread migration causes data consistency issue, then the
call trace shows up. And preemption disabling can't prevent migration.

[how]
Disable migration to ensure consistency of fpu_recursion_depth.

Signed-off-by: tiancyin 
---
 amdgpu_dm/dc_fpu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/amdgpu_dm/dc_fpu.c b/amdgpu_dm/dc_fpu.c
index 1743ca0a36..c42aa947c9 100644
--- a/amdgpu_dm/dc_fpu.c
+++ b/amdgpu_dm/dc_fpu.c
@@ -89,6 +89,7 @@ void dc_fpu_begin(const char *function_name, const int line)
 
if (*pcpu == 1) {
 #if defined(CONFIG_X86)
+   migrate_disable();
kernel_fpu_begin();
 #elif defined(CONFIG_PPC64)
if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
@@ -129,6 +130,7 @@ void dc_fpu_end(const char *function_name, const int line)
if (*pcpu <= 0) {
 #if defined(CONFIG_X86)
kernel_fpu_end();
+   migrate_enable();
 #elif defined(CONFIG_PPC64)
if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
disable_kernel_vsx();
-- 
2.34.1



[PATCH] drm/amd/display: Fix a gsl leak on dcn20

2022-09-07 Thread Tianci Yin
From: tiancyin 

[why]
When the new pipe_ctx holds a valid gsl_group, the old code logic will
overwrite it unconditionally, this cause the new pipe_ctx's gsl_group
have no chance to be released, i.e. the gsl_group leaked.

[how]
Don't overwrite the new pipe_ctx's gsl_group, if it holds a valid
gsl_group, meantime release the old_pipe_ctx's gsl_group.

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
index cf439ed270de..92ef58068b4b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -1720,8 +1720,12 @@ void dcn20_program_front_end_for_ctx(
struct pipe_ctx *pipe_ctx = >res_ctx.pipe_ctx[i];
struct pipe_ctx *old_pipe_ctx = 
>current_state->res_ctx.pipe_ctx[i];
 
-   if (pipe_ctx->stream == old_pipe_ctx->stream)
-   pipe_ctx->stream_res.gsl_group = 
old_pipe_ctx->stream_res.gsl_group;
+   if (pipe_ctx->stream == old_pipe_ctx->stream) {
+   if (pipe_ctx->stream_res.gsl_group == 0)
+   pipe_ctx->stream_res.gsl_group = 
old_pipe_ctx->stream_res.gsl_group;
+   else if (old_pipe_ctx->stream_res.gsl_group >0)
+   dcn20_setup_gsl_group_as_lock(dc, old_pipe_ctx, 
false);
+   }
}
 
if (dc->hwss.program_triplebuffer != NULL && dc->debug.enable_tri_buf) {
-- 
2.25.1



[PATCH] drm/amd/vcn: fix an error msg on vcn 3.0

2022-03-27 Thread Tianci Yin
From: tiancyin 

Some video card has more than one vcn instance, passing 0 to
vcn_v3_0_pause_dpg_mode is incorrect.

Error msg:
Register(1) [mmUVD_POWER_STATUS] failed to reach value
0x0001 != 0x0002

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index e1cca0a10653..cb5f0a12333f 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -1488,7 +1488,7 @@ static int vcn_v3_0_stop_dpg_mode(struct amdgpu_device 
*adev, int inst_idx)
struct dpg_pause_state state = {.fw_based = VCN_DPG_STATE__UNPAUSE};
uint32_t tmp;
 
-   vcn_v3_0_pause_dpg_mode(adev, 0, );
+   vcn_v3_0_pause_dpg_mode(adev, inst_idx, );
 
/* Wait for power status to be 1 */
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1,
-- 
2.25.1



[PATCH] drm/amdgpu/vcn: improve vcn dpg stop procedure

2022-03-23 Thread Tianci Yin
Prior to disabling dpg, VCN need unpausing dpg mode, or VCN will hang in
S3 resuming.

Signed-off-by: Tianci Yin 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index b16c56aa2d22..0d590183328f 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -1480,8 +1480,11 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device 
*adev)
 
 static int vcn_v3_0_stop_dpg_mode(struct amdgpu_device *adev, int inst_idx)
 {
+   struct dpg_pause_state state = {.fw_based = VCN_DPG_STATE__UNPAUSE};
uint32_t tmp;
 
+   vcn_v3_0_pause_dpg_mode(adev, 0, );
+
/* Wait for power status to be 1 */
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1,
UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
-- 
2.25.1



[PATCH] drm/amdgpu/vcn: fix vcn ring test failure in igt reload test

2022-03-14 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
On Renoir, vcn ring test failed on the second time insmod in the reload
test. After invetigation, it proves that vcn only can disable dpg under
dpg unpause mode (dpg unpause mode is default for dec only, dpg pause
mode is for dec/enc).

[how]
unpause dpg in dpg stopping procedure.

Change-Id: If6ec3af694e1d6b63ebce386a563f03ca6d291c1
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
index 319ac8ea434b..6e0972cd1f2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
@@ -1098,8 +1098,10 @@ static int vcn_v2_0_start(struct amdgpu_device *adev)
 
 static int vcn_v2_0_stop_dpg_mode(struct amdgpu_device *adev)
 {
+   struct dpg_pause_state state = {.fw_based = VCN_DPG_STATE__UNPAUSE};
uint32_t tmp;
 
+   vcn_v2_0_pause_dpg_mode(adev, 0, );
/* Wait for power status to be 1 */
SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 1,
UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
-- 
2.25.1



[PATCH] drm/amd: fix gfx hang on renoir in IGT reload test

2022-03-10 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
CP hangs in igt reloading test on renoir, more precisely, hangs on the
second time insmod.

[how]
mode2 reset can make it recover, and mode2 reset only effects gfx core,
dcn and the screen will not be impacted.

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 496c4a6e23ac..f0713c027ed5 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -853,6 +853,11 @@ static bool soc15_need_reset_on_init(struct amdgpu_device 
*adev)
 {
u32 sol_reg;
 
+   /* CP hangs in IGT reloading test on RN, reset to WA */
+   if(adev->asic_type == CHIP_RENOIR) {
+   return true;
+   }
+
/* Just return false for soc15 GPUs.  Reset does not seem to
 * be necessary.
 */
-- 
2.25.1



[PATCH] drm/amd/display: fix dp kvm can't light up

2022-03-07 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
The DP KVM failed to light up, since the lttpr_mode is not reset to
default value when failed to read LTTPR capabilities, and the
variable max_link_rate retains a initial value zero, this cause variable
link_rate be assigned to an error value zero, consquently pixel_clock
get wrong value zero, and kvm can't light up.

[how]
Reset lttpr_mode to default value when failed to read LTTPR
capabilities, so that the link_rate fallbacks to the minimum rate that
supported by link encoder and sink.

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 5688b15ca9e6..f9ae06103241 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -5101,6 +5101,7 @@ bool dp_retrieve_lttpr_cap(struct dc_link *link)
sizeof(lttpr_dpcd_data));
if (status != DC_OK) {
DC_LOG_DP2("%s: Read LTTPR caps data failed.\n", 
__func__);
+   link->lttpr_mode = LTTPR_MODE_NON_LTTPR;
return false;
}
 
-- 
2.25.1



[PATCH] drm/amdgpu: Fix an error message in rmmod

2022-01-25 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In rmmod procedure, kfd sends cp a dequeue request, but the
request does not get response, then an error message "cp
queue pipe 4 queue 0 preemption failed" printed.

[how]
Performing kfd suspending after disabling gfxoff can fix it.

Change-Id: I0453f28820542d4a5ab26e38fb5b87ed76ce6930
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b75d67f644e5..77e9837ba342 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2720,11 +2720,11 @@ static int amdgpu_device_ip_fini_early(struct 
amdgpu_device *adev)
}
}
 
-   amdgpu_amdkfd_suspend(adev, false);
-
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
 
+   amdgpu_amdkfd_suspend(adev, false);
+
/* Workaroud for ASICs need to disable SMC first */
amdgpu_device_smu_fini_early(adev);
 
-- 
2.25.1



[PATCH] drm/amdgpu: enable DCN for navi10 headless SKU

2020-11-05 Thread Tianci Yin
From: "Tianci.Yin" 

There is a NULL pointer crash when DCN disabled on headless SKU.
On normal SKU, the variable adev->ddev.mode_config.funcs is
initialized in dm_hw_init(), and it is fine to access it in
amdgpu_device_resume(). But on headless SKU, DCN is disabled,
the funcs variable is not initialized, then crash arises.
Enable DCN to fix this issue.

Change-Id: I33bc30210e3420e60ceb59175e39855d00b05b06
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index e33d8022cc32..67375b2948f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -535,8 +535,7 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
-   else if (amdgpu_device_has_dc_support(adev) &&
-!nv_is_headless_sku(adev->pdev))
+   else if (amdgpu_device_has_dc_support(adev))
amdgpu_device_ip_block_add(adev, _ip_block);
 #endif
amdgpu_device_ip_block_add(adev, _v10_0_ip_block);
-- 
2.25.1

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


[PATCH] drm/amdgpu: fix NULL pointer crash on navi10 headless SKU

2020-10-30 Thread Tianci Yin
From: "Tianci.Yin" 

The crash caused by the NULL pointer of
adev->ddev.mode_config.funcs in drm_kms_helper_hotplug_event(),
but this function should not be called on headless SKU.

Fix the mismatch between the return value of
amdgpu_device_has_dc_support() and the real DCN supporting
state to avoid calling to drm_kms_helper_hotplug_event()
in amdgpu_device_resume().

Change-Id: I3a3d387e6ab5b774abb3911ea1bf6de60797759d
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 10 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/nv.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/nv.h |  1 +
 6 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index ba65d4f2ab67..f0183271456f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1090,7 +1090,7 @@ void amdgpu_device_indirect_wreg64(struct amdgpu_device 
*adev,
   u32 pcie_index, u32 pcie_data,
   u32 reg_addr, u64 reg_data);
 
-bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type);
+bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type, struct 
pci_dev *pdev);
 bool amdgpu_device_has_dc_support(struct amdgpu_device *adev);
 
 int emu_soc_asic_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 1fe850e0a94d..323ed69032a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2960,11 +2960,12 @@ static void amdgpu_device_detect_sriov_bios(struct 
amdgpu_device *adev)
  * amdgpu_device_asic_has_dc_support - determine if DC supports the asic
  *
  * @asic_type: AMD asic type
+ * @pdev: pointer to pci_dev instance
  *
  * Check if there is DC (new modesetting infrastructre) support for an asic.
  * returns true if DC has support, false if not.
  */
-bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
+bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type, struct 
pci_dev *pdev)
 {
switch (asic_type) {
 #if defined(CONFIG_DRM_AMD_DC)
@@ -3000,9 +3001,14 @@ bool amdgpu_device_asic_has_dc_support(enum 
amd_asic_type asic_type)
case CHIP_VEGA20:
 #if defined(CONFIG_DRM_AMD_DC_DCN)
case CHIP_RAVEN:
+   return amdgpu_dc != 0;
case CHIP_NAVI10:
case CHIP_NAVI14:
case CHIP_NAVI12:
+   if (nv_is_headless_sku(pdev))
+   return false;
+   else
+   return amdgpu_dc != 0;
case CHIP_RENOIR:
 #endif
 #if defined(CONFIG_DRM_AMD_DC_DCN3_0)
@@ -3033,7 +3039,7 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device 
*adev)
if (amdgpu_sriov_vf(adev) || adev->enable_virtual_display)
return false;
 
-   return amdgpu_device_asic_has_dc_support(adev->asic_type);
+   return amdgpu_device_asic_has_dc_support(adev->asic_type, adev->pdev);
 }
 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 9e92d2a070ac..97014458d7de 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -516,7 +516,7 @@ uint32_t amdgpu_display_supported_domains(struct 
amdgpu_device *adev,
 */
if ((bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) &&
amdgpu_bo_support_uswc(bo_flags) &&
-   amdgpu_device_asic_has_dc_support(adev->asic_type)) {
+   amdgpu_device_asic_has_dc_support(adev->asic_type, adev->pdev)) {
switch (adev->asic_type) {
case CHIP_CARRIZO:
case CHIP_STONEY:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 4b78ecfd35f7..b23110241267 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1117,7 +1117,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
bool supports_atomic = false;
 
if (!amdgpu_virtual_display &&
-   amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
+   amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK, pdev))
supports_atomic = true;
 
if ((flags & AMD_EXP_HW_SUPPORT) && !amdgpu_exp_hw_support) {
diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 026e0a8fd526..97446ae75b0b 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -493,7 +493,7 @@ void nv_set_virt_ops(struct amdgpu_device *adev)
adev->virt.ops = _nv_virt_ops;
 }
 
-static bool nv_is_headless_sku(struct pci_dev *pdev)
+bool nv_is_headless_sku(struct 

[PATCH 2/2] drm/amdgpu: disable DCN and VCN for navi10 blockchain SKU(v3)

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

The blockchain SKU has no display and video support, remove them.

Change-Id: I419cfae8b00125f3bff18c0a8cd92f3266d5f04a
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index ce787489aaeb..26702c85caf8 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -497,6 +497,14 @@ void nv_set_virt_ops(struct amdgpu_device *adev)
adev->virt.ops = _nv_virt_ops;
 }
 
+bool nv_is_blockchain_sku(struct pci_dev *pdev)
+{
+   if (pdev->device == 0x731E &&
+   (pdev->revision == 0xC6 || pdev->revision == 0xC7))
+   return true;
+   return false;
+}
+
 int nv_set_ip_blocks(struct amdgpu_device *adev)
 {
int r;
@@ -530,7 +538,8 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
-   else if (amdgpu_device_has_dc_support(adev))
+   else if (amdgpu_device_has_dc_support(adev) &&
+!nv_is_blockchain_sku(adev->pdev))
amdgpu_device_ip_block_add(adev, _ip_block);
 #endif
amdgpu_device_ip_block_add(adev, _v10_0_ip_block);
@@ -538,7 +547,8 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
!amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _v11_0_ip_block);
-   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
+   if (!nv_is_blockchain_sku(adev->pdev))
+   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
if (adev->enable_mes)
amdgpu_device_ip_block_add(adev, _v10_1_ip_block);
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: add DID for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

Change-Id: I58129e3aa88369c85929e4dde002cf43c3ff288a
Reviewed-by: Guchun Chen 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 564336c2ee66..13723914fa9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1066,6 +1066,7 @@ static const struct pci_device_id pciidlist[] = {
{0x1002, 0x7319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
+   {0x1002, 0x731E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
/* Navi14 */
{0x1002, 0x7340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
-- 
2.17.1

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


[PATCH 2/3] drm/amdgpu: disable DCN for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

The blockchain SKU has no display support, remove it.

Change-Id: Ia83bef1499708dfd0113fe2dbb3eb4143452c1cd
Reviewed-by: Guchun Chen 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 28 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 +-
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f8f3e375c93e..3c63fb8904de 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1051,7 +1051,8 @@ void amdgpu_device_indirect_wreg64(struct amdgpu_device 
*adev,
   u32 pcie_index, u32 pcie_data,
   u32 reg_addr, u64 reg_data);
 
-bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type);
+bool amdgpu_device_asic_is_blockchain_sku(struct pci_dev *pdev);
+bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type, struct 
pci_dev *pdev);
 bool amdgpu_device_has_dc_support(struct amdgpu_device *adev);
 
 int emu_soc_asic_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c567f20b9d1f..5dd05e72ed9e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2954,15 +2954,32 @@ static void amdgpu_device_detect_sriov_bios(struct 
amdgpu_device *adev)
}
 }
 
+/**
+ * amdgpu_device_asic_is_blockchain_sku - determine if the asic is blockchain
+ * SKU
+ *
+ * @pdev: pointer to pci_dev instance
+ *
+ * returns true if the asic is blockchain SKU, false if not.
+ */
+bool amdgpu_device_asic_is_blockchain_sku(struct pci_dev *pdev)
+{
+   if (pdev->device == 0x731E &&
+   (pdev->revision == 0xC6 || pdev->revision == 0xC7))
+   return true;
+   return false;
+}
+
 /**
  * amdgpu_device_asic_has_dc_support - determine if DC supports the asic
  *
  * @asic_type: AMD asic type
+ * @pdev: pointer to pci_dev instance
  *
  * Check if there is DC (new modesetting infrastructre) support for an asic.
  * returns true if DC has support, false if not.
  */
-bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
+bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type, struct 
pci_dev *pdev)
 {
switch (asic_type) {
 #if defined(CONFIG_DRM_AMD_DC)
@@ -2999,6 +3016,13 @@ bool amdgpu_device_asic_has_dc_support(enum 
amd_asic_type asic_type)
 #if defined(CONFIG_DRM_AMD_DC_DCN)
case CHIP_RAVEN:
case CHIP_NAVI10:
+   if (amdgpu_device_asic_is_blockchain_sku(pdev)) {
+   DRM_INFO("(%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X) has 
no dc support.\n",
+amdgpu_asic_name[asic_type], pdev->vendor, 
pdev->device,
+pdev->subsystem_vendor, 
pdev->subsystem_device, pdev->revision);
+   return false;
+   }
+   return amdgpu_dc != 0;
case CHIP_NAVI14:
case CHIP_NAVI12:
case CHIP_RENOIR:
@@ -3031,7 +3055,7 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device 
*adev)
if (amdgpu_sriov_vf(adev) || adev->enable_virtual_display)
return false;
 
-   return amdgpu_device_asic_has_dc_support(adev->asic_type);
+   return amdgpu_device_asic_has_dc_support(adev->asic_type, adev->pdev);
 }
 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 9e92d2a070ac..97014458d7de 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -516,7 +516,7 @@ uint32_t amdgpu_display_supported_domains(struct 
amdgpu_device *adev,
 */
if ((bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) &&
amdgpu_bo_support_uswc(bo_flags) &&
-   amdgpu_device_asic_has_dc_support(adev->asic_type)) {
+   amdgpu_device_asic_has_dc_support(adev->asic_type, adev->pdev)) {
switch (adev->asic_type) {
case CHIP_CARRIZO:
case CHIP_STONEY:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 13723914fa9f..97fda825e0d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1109,7 +1109,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
bool supports_atomic = false;
 
if (!amdgpu_virtual_display &&
-   amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
+   amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK, pdev))
supports_atomic = true;
 
if ((flags & AMD_EXP_HW_SUPPORT) && !amdgpu_exp_hw_support) {
-- 
2.17.1


[PATCH 1/3] drm/amdgpu: add DID for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

Change-Id: I58129e3aa88369c85929e4dde002cf43c3ff288a
Reviewed-by: Guchun Chen 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 564336c2ee66..13723914fa9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1066,6 +1066,7 @@ static const struct pci_device_id pciidlist[] = {
{0x1002, 0x7319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
+   {0x1002, 0x731E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
/* Navi14 */
{0x1002, 0x7340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
-- 
2.17.1

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


[PATCH 3/3] drm/amdgpu: disable VCN for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

The blockchain SKU has no VCN support, remove it.

Change-Id: I26fbdabdf67aada24c5aebef999ee8b5f9c0bfe2
Reviewed-by: Guchun Chen 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index ce787489aaeb..bf28d7547237 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -538,7 +538,8 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
!amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _v11_0_ip_block);
-   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
+   if (!amdgpu_device_asic_is_blockchain_sku(adev->pdev))
+   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
if (adev->enable_mes)
amdgpu_device_ip_block_add(adev, _v10_1_ip_block);
-- 
2.17.1

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


[PATCH 2/3] drm/amdgpu: disable DCN for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

The blockchain SKU has no display support, so the DCN ip
block should be disabled. Add DID/RID as display
supporting dependence, it potentially disable DCN block.

Change-Id: Ia83bef1499708dfd0113fe2dbb3eb4143452c1cd
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 20 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 +-
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f8f3e375c93e..04e906386b5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1051,7 +1051,7 @@ void amdgpu_device_indirect_wreg64(struct amdgpu_device 
*adev,
   u32 pcie_index, u32 pcie_data,
   u32 reg_addr, u64 reg_data);
 
-bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type);
+bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type, struct 
pci_dev *pdev);
 bool amdgpu_device_has_dc_support(struct amdgpu_device *adev);
 
 int emu_soc_asic_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c567f20b9d1f..fa522cffdd64 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2958,11 +2958,12 @@ static void amdgpu_device_detect_sriov_bios(struct 
amdgpu_device *adev)
  * amdgpu_device_asic_has_dc_support - determine if DC supports the asic
  *
  * @asic_type: AMD asic type
+ * @pdev: pointer of pci_dev instance
  *
  * Check if there is DC (new modesetting infrastructre) support for an asic.
  * returns true if DC has support, false if not.
  */
-bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
+bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type, struct 
pci_dev *pdev)
 {
switch (asic_type) {
 #if defined(CONFIG_DRM_AMD_DC)
@@ -2998,7 +2999,6 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type 
asic_type)
case CHIP_VEGA20:
 #if defined(CONFIG_DRM_AMD_DC_DCN)
case CHIP_RAVEN:
-   case CHIP_NAVI10:
case CHIP_NAVI14:
case CHIP_NAVI12:
case CHIP_RENOIR:
@@ -3011,6 +3011,20 @@ bool amdgpu_device_asic_has_dc_support(enum 
amd_asic_type asic_type)
 #endif
return amdgpu_dc != 0;
 #endif
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+   case CHIP_NAVI10:
+   if (pdev->device == 0x731E &&
+   (pdev->revision == 0xC6 ||
+pdev->revision == 0xC7)) {
+   DRM_INFO("(%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X) has 
no dc support.\n",
+amdgpu_asic_name[asic_type], pdev->vendor, 
pdev->device,
+pdev->subsystem_vendor, 
pdev->subsystem_device, pdev->revision);
+   return false;
+   } else {
+   return amdgpu_dc != 0;
+   }
+#endif
+
default:
if (amdgpu_dc > 0)
DRM_INFO("Display Core has been requested via kernel 
parameter "
@@ -3031,7 +3045,7 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device 
*adev)
if (amdgpu_sriov_vf(adev) || adev->enable_virtual_display)
return false;
 
-   return amdgpu_device_asic_has_dc_support(adev->asic_type);
+   return amdgpu_device_asic_has_dc_support(adev->asic_type, adev->pdev);
 }
 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 9e92d2a070ac..97014458d7de 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -516,7 +516,7 @@ uint32_t amdgpu_display_supported_domains(struct 
amdgpu_device *adev,
 */
if ((bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) &&
amdgpu_bo_support_uswc(bo_flags) &&
-   amdgpu_device_asic_has_dc_support(adev->asic_type)) {
+   amdgpu_device_asic_has_dc_support(adev->asic_type, adev->pdev)) {
switch (adev->asic_type) {
case CHIP_CARRIZO:
case CHIP_STONEY:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 13723914fa9f..97fda825e0d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1109,7 +1109,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
bool supports_atomic = false;
 
if (!amdgpu_virtual_display &&
-   amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
+   amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK, pdev))
supports_atomic = true;
 
if ((flags & AMD_EXP_HW_SUPPORT) && !amdgpu_exp_hw_support) {

[PATCH 3/3] drm/amdgpu: disable VCN for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

The blockchain SKU has no VCN support, remove it.

Change-Id: I26fbdabdf67aada24c5aebef999ee8b5f9c0bfe2
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index ce787489aaeb..ffe4c2b3ea5f 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -538,7 +538,10 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
!amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _v11_0_ip_block);
-   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
+   if (adev->pdev->device != 0x731E ||
+   (adev->pdev->revision != 0xC6 &&
+adev->pdev->revision != 0xC7))
+   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
if (adev->enable_mes)
amdgpu_device_ip_block_add(adev, _v10_1_ip_block);
-- 
2.17.1

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


[PATCH 1/3] drm/amdgpu: add DID for navi10 blockchain SKU

2020-10-21 Thread Tianci Yin
From: "Tianci.Yin" 

Change-Id: I58129e3aa88369c85929e4dde002cf43c3ff288a
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 564336c2ee66..13723914fa9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1066,6 +1066,7 @@ static const struct pci_device_id pciidlist[] = {
{0x1002, 0x7319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
+   {0x1002, 0x731E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
{0x1002, 0x731F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
/* Navi14 */
{0x1002, 0x7340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu: reconfigure spm golden settings on Navi1x after GFXOFF exit(v3)

2020-08-06 Thread Tianci Yin
From: "Tianci.Yin" 

On Navi1x, the SPM golden settings are lost after GFXOFF
enter/exit, so reconfigure the golden settings after GFXOFF
exit.

Change-Id: I9358ba9c65f241c36f8a35916170b19535148ee9
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 8eff0173360d..9e133fd0372d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -571,8 +571,14 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool 
enable)
if (enable && !adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) 
{
schedule_delayed_work(>gfx.gfx_off_delay_work, 
GFX_OFF_DELAY_ENABLE);
} else if (!enable && adev->gfx.gfx_off_state) {
-   if (!amdgpu_dpm_set_powergating_by_smu(adev, 
AMD_IP_BLOCK_TYPE_GFX, false))
+   if (!amdgpu_dpm_set_powergating_by_smu(adev, 
AMD_IP_BLOCK_TYPE_GFX, false)) {
adev->gfx.gfx_off_state = false;
+
+   if (adev->gfx.funcs->init_spm_golden) {
+   dev_dbg(adev->dev, "GFXOFF is disabled, re-init 
SPM golden settings\n");
+   amdgpu_gfx_init_spm_golden(adev);
+   }
+   }
}
 
mutex_unlock(>gfx.gfx_off_mutex);
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: add interface amdgpu_gfx_init_spm_golden for Navi1x

2020-08-06 Thread Tianci Yin
From: "Tianci.Yin" 

On Navi1x, the SPM golden settings are lost after GFXOFF
enter/exit, so reconfiguration is needed. Make the
configuration code as an interface for future use.

Change-Id: I172f3dc7f59da69b0364052dcad75a9c9aab019e
Reviewed-by: Luben Tuikov 
Reviewed-by: Feifei Xu 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 34 ++---
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 1e7a2b0997c5..a611e78dd4ba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -216,6 +216,7 @@ struct amdgpu_gfx_funcs {
int (*ras_error_inject)(struct amdgpu_device *adev, void *inject_if);
int (*query_ras_error_count) (struct amdgpu_device *adev, void 
*ras_error_status);
void (*reset_ras_error_count) (struct amdgpu_device *adev);
+   void (*init_spm_golden)(struct amdgpu_device *adev);
 };
 
 struct sq_work {
@@ -324,6 +325,7 @@ struct amdgpu_gfx {
 #define amdgpu_gfx_get_gpu_clock_counter(adev) 
(adev)->gfx.funcs->get_gpu_clock_counter((adev))
 #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) 
(adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance))
 #define amdgpu_gfx_select_me_pipe_q(adev, me, pipe, q, vmid) 
(adev)->gfx.funcs->select_me_pipe_q((adev), (me), (pipe), (q), (vmid))
+#define amdgpu_gfx_init_spm_golden(adev) 
(adev)->gfx.funcs->init_spm_golden((adev))
 
 /**
  * amdgpu_gfx_create_bitmask - create a bitmask
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index db9f1e89a0f8..da21ad04ac0f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3307,6 +3307,29 @@ static void gfx_v10_0_set_kiq_pm4_funcs(struct 
amdgpu_device *adev)
adev->gfx.kiq.pmf = _v10_0_kiq_pm4_funcs;
 }
 
+static void gfx_v10_0_init_spm_golden_registers(struct amdgpu_device *adev)
+{
+   switch (adev->asic_type) {
+   case CHIP_NAVI10:
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_0_nv10,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_0_nv10));
+   break;
+   case CHIP_NAVI14:
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_1_nv14,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_1_nv14));
+   break;
+   case CHIP_NAVI12:
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_1_2_nv12,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_1_2_nv12));
+   break;
+   default:
+   break;
+   }
+}
+
 static void gfx_v10_0_init_golden_registers(struct amdgpu_device *adev)
 {
switch (adev->asic_type) {
@@ -3317,9 +3340,6 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_0_nv10,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_0_nv10));
-   soc15_program_register_sequence(adev,
-   
golden_settings_gc_rlc_spm_10_0_nv10,
-   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_0_nv10));
break;
case CHIP_NAVI14:
soc15_program_register_sequence(adev,
@@ -3328,9 +3348,6 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_1_nv14,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_1_nv14));
-   soc15_program_register_sequence(adev,
-   
golden_settings_gc_rlc_spm_10_1_nv14,
-   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_1_nv14));
break;
case CHIP_NAVI12:
soc15_program_register_sequence(adev,
@@ -3339,9 +3356,6 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_1_2_nv12,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_1_2_nv12));
-   soc15_program_register_sequence(adev,
-   

[PATCH 1/2] drm/amdgpu: add interface amdgpu_gfx_init_spm_golden for Navi1x

2020-07-27 Thread Tianci Yin
From: "Tianci.Yin" 

On Navi1x, the SPM golden settings will be lost after GFXOFF enter/exit,
reconfiguration is needed. Make the configuration code as an interface for
future use.

Change-Id: I172f3dc7f59da69b0364052dcad75a9c9aab019e
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 34 ++---
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 1e7a2b0997c5..a611e78dd4ba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -216,6 +216,7 @@ struct amdgpu_gfx_funcs {
int (*ras_error_inject)(struct amdgpu_device *adev, void *inject_if);
int (*query_ras_error_count) (struct amdgpu_device *adev, void 
*ras_error_status);
void (*reset_ras_error_count) (struct amdgpu_device *adev);
+   void (*init_spm_golden)(struct amdgpu_device *adev);
 };
 
 struct sq_work {
@@ -324,6 +325,7 @@ struct amdgpu_gfx {
 #define amdgpu_gfx_get_gpu_clock_counter(adev) 
(adev)->gfx.funcs->get_gpu_clock_counter((adev))
 #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) 
(adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance))
 #define amdgpu_gfx_select_me_pipe_q(adev, me, pipe, q, vmid) 
(adev)->gfx.funcs->select_me_pipe_q((adev), (me), (pipe), (q), (vmid))
+#define amdgpu_gfx_init_spm_golden(adev) 
(adev)->gfx.funcs->init_spm_golden((adev))
 
 /**
  * amdgpu_gfx_create_bitmask - create a bitmask
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index db9f1e89a0f8..da21ad04ac0f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3307,6 +3307,29 @@ static void gfx_v10_0_set_kiq_pm4_funcs(struct 
amdgpu_device *adev)
adev->gfx.kiq.pmf = _v10_0_kiq_pm4_funcs;
 }
 
+static void gfx_v10_0_init_spm_golden_registers(struct amdgpu_device *adev)
+{
+   switch (adev->asic_type) {
+   case CHIP_NAVI10:
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_0_nv10,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_0_nv10));
+   break;
+   case CHIP_NAVI14:
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_1_nv14,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_1_nv14));
+   break;
+   case CHIP_NAVI12:
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_1_2_nv12,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_1_2_nv12));
+   break;
+   default:
+   break;
+   }
+}
+
 static void gfx_v10_0_init_golden_registers(struct amdgpu_device *adev)
 {
switch (adev->asic_type) {
@@ -3317,9 +3340,6 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_0_nv10,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_0_nv10));
-   soc15_program_register_sequence(adev,
-   
golden_settings_gc_rlc_spm_10_0_nv10,
-   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_0_nv10));
break;
case CHIP_NAVI14:
soc15_program_register_sequence(adev,
@@ -3328,9 +3348,6 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_1_nv14,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_1_nv14));
-   soc15_program_register_sequence(adev,
-   
golden_settings_gc_rlc_spm_10_1_nv14,
-   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_1_nv14));
break;
case CHIP_NAVI12:
soc15_program_register_sequence(adev,
@@ -3339,9 +3356,6 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_1_2_nv12,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_1_2_nv12));
-   soc15_program_register_sequence(adev,
-   
golden_settings_gc_rlc_spm_10_1_2_nv12,
-

[PATCH 2/2] drm/amdgpu: reconfigure spm golden settings on Navi1x after GFXOFF exit

2020-07-27 Thread Tianci Yin
From: "Tianci.Yin" 

On Navi1x, the SPM golden settings will be lost after GFXOFF enter/exit,
reconfigure the golden settings after GFXOFF exit.

Change-Id: I9358ba9c65f241c36f8a35916170b19535148ee9
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 55463e7a11e2..5da0436d41e0 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1309,6 +1309,7 @@ static int smu_enable_umd_pstate(void *handle,
 
struct smu_context *smu = (struct smu_context*)(handle);
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
+   struct amdgpu_device *adev = smu->adev;
 
if (!smu->is_apu && !smu_dpm_ctx->dpm_context)
return -EINVAL;
@@ -1324,6 +1325,16 @@ static int smu_enable_umd_pstate(void *handle,
amdgpu_device_ip_set_clockgating_state(smu->adev,
   
AMD_IP_BLOCK_TYPE_GFX,
   
AMD_CG_STATE_UNGATE);
+
+   if (adev->asic_type >= CHIP_NAVI10 &&
+   adev->asic_type <= CHIP_NAVI12 &&
+   (adev->pm.pp_feature & PP_GFXOFF_MASK)) {
+   if (adev->gfx.funcs->init_spm_golden) {
+   dev_dbg(adev->dev,"GFXOFF exited, 
re-init SPM golden settings\n");
+   amdgpu_gfx_init_spm_golden(adev);
+   } else
+   dev_warn(adev->dev,"Callback 
init_spm_golden is NULL\n");
+   }
}
} else {
/* exit umd pstate, restore level, enable gfx cg*/
-- 
2.17.1

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


[PATCH] drm/amdgpu: temporarily read bounding box from gpu_info fw for navi12

2020-06-02 Thread Tianci Yin
From: "Tianci.Yin" 

The bounding box is still needed by Navi12, temporarily read it from gpu_info
firmware. Should be droped when DAL no longer needs it.

Change-Id: Ifc330ec860f9b0665134a81df2fc80ca91c41a33
Reviewed-by: Alex Deucher 
Reviewed-by: Xiaojie Yuan 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 15de344438d2..1df28b7bf22e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1537,7 +1537,14 @@ static int amdgpu_device_parse_gpu_info_fw(struct 
amdgpu_device *adev)
 
if (adev->discovery_bin) {
amdgpu_discovery_get_gfx_info(adev);
-   return 0;
+
+   /*
+* FIXME: The bounding box is still needed by Navi12, so
+* temporarily read it from gpu_info firmware. Should be droped
+* when DAL no longer needs it.
+*/
+   if (adev->asic_type != CHIP_NAVI12)
+   return 0;
}
 
switch (adev->asic_type) {
@@ -1627,6 +1634,12 @@ static int amdgpu_device_parse_gpu_info_fw(struct 
amdgpu_device *adev)
(const struct gpu_info_firmware_v1_0 
*)(adev->firmware.gpu_info_fw->data +

le32_to_cpu(hdr->header.ucode_array_offset_bytes));
 
+   /*
+* Should be droped when DAL no longer needs it.
+*/
+   if (adev->asic_type == CHIP_NAVI12)
+   goto parse_soc_bounding_box;
+
adev->gfx.config.max_shader_engines = 
le32_to_cpu(gpu_info_fw->gc_num_se);
adev->gfx.config.max_cu_per_sh = 
le32_to_cpu(gpu_info_fw->gc_num_cu_per_sh);
adev->gfx.config.max_sh_per_se = 
le32_to_cpu(gpu_info_fw->gc_num_sh_per_se);
@@ -1655,6 +1668,7 @@ static int amdgpu_device_parse_gpu_info_fw(struct 
amdgpu_device *adev)
le32_to_cpu(gpu_info_fw->num_packer_per_sc);
}
 
+parse_soc_bounding_box:
/*
 * soc bounding box info is not integrated in disocovery table,
 * we always need to parse it from gpu info firmware if needed.
-- 
2.17.1

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


[PATCH] drm/amdgpu: add SPM golden settings for Navi10(v2)

2020-04-06 Thread Tianci Yin
From: "Tianci.Yin" 

Add RLC_SPM golden settings

Change-Id: I616e127171293d915cb3a05dee02f51cec8d8f6f
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1059 
 1 file changed, 1059 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 70edbbf84338..19d9bdba0453 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -138,6 +138,1062 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_0_nv10[] =
/* Pending on emulation bring up */
 };
 
+static const struct soc15_reg_golden golden_settings_gc_rlc_spm_10_0_nv10[] =
+{
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xe000, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x28),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0x9),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_ADDR, 
0x, 0x8),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_DATA, 
0x, 0x1b),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x1),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_ADDR, 
0x, 0x8),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x1),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_DATA, 
0x, 0x1b),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x20),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xe),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0xc8),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0xcc),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0xd0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0xd4),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x24),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x24),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x4),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0x11),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x8),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 
0x, 0xf),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 
0x, 0x0),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0),
+   

[PATCH] drm/amdgpu: add SPM golden settings for Navi10

2020-04-02 Thread Tianci Yin
From: "Tianci.Yin" 

Add RLC_SPM golden settings

Change-Id: I616e127171293d915cb3a05dee02f51cec8d8f6f
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c|9 +
 .../gpu/drm/amd/amdgpu/golden_gc_spm_10_1_0.h | 1058 +
 2 files changed, 1067 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/golden_gc_spm_10_1_0.h

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 70edbbf84338..7c96a894ad37 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -48,6 +48,7 @@
 #include "v10_structs.h"
 #include "gfx_v10_0.h"
 #include "nbio_v2_3.h"
+#include "golden_gc_spm_10_1_0.h"
 
 /**
  * Navi10 has two graphic rings to share each graphic pipe.
@@ -138,6 +139,11 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_0_nv10[] =
/* Pending on emulation bring up */
 };
 
+static const struct soc15_reg_golden golden_settings_gc_rlc_spm_10_0_nv10[] =
+{
+   GOLDEN_GC_SPM_10_1_0
+};
+
 static const struct soc15_reg_golden golden_settings_gc_10_1_1[] =
 {
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0x, 
0x003c0014),
@@ -388,6 +394,9 @@ static void gfx_v10_0_init_golden_registers(struct 
amdgpu_device *adev)
soc15_program_register_sequence(adev,
golden_settings_gc_10_0_nv10,
(const 
u32)ARRAY_SIZE(golden_settings_gc_10_0_nv10));
+   soc15_program_register_sequence(adev,
+   
golden_settings_gc_rlc_spm_10_0_nv10,
+   (const 
u32)ARRAY_SIZE(golden_settings_gc_rlc_spm_10_0_nv10));
break;
case CHIP_NAVI14:
soc15_program_register_sequence(adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/golden_gc_spm_10_1_0.h 
b/drivers/gpu/drm/amd/amdgpu/golden_gc_spm_10_1_0.h
new file mode 100644
index ..e65af4a6fcdd
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/golden_gc_spm_10_1_0.h
@@ -0,0 +1,1058 @@
+#ifndef __GOLDEN_GC_SPM_10_1_0_H__
+#define __GOLDEN_GC_SPM_10_1_0_H__
+
+#define GOLDEN_GC_SPM_10_1_0 \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xe000, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0x28), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 0x, 
0x9), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_ADDR, 0x, 
0x8), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_DATA, 0x, 
0x1b), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x1), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_ADDR, 0x, 
0x8), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x1), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_SE_SAMPLEDELAY_IND_DATA, 0x, 
0x1b), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0x20), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 0x, 
0xe), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0xc8), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 0x, 
0xf), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0xcc), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 0x, 
0xf), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0xd0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 0x, 
0xf), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0xd4), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_DATA, 0x, 
0xf), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_GFX_INDEX, 0xff, 0x0), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_GLB_SAMPLEDELAY_IND_ADDR, 0x, 
0x24), \
+SOC15_REG_GOLDEN_VALUE(GC, 0, 

[PATCH] drm/amdgpu: fix size validation failure in large buffer creation

2020-03-20 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
When GTT domain size is smaller than VRAM, if APP apply a very large
buffer whose size is larger than GTT but smaller than VRAM, the size
validation will fail.

[how]
Validate VRAM domain size at first place, then GTT domain.

Change-Id: Ic1d31b9b0a4939e6bba0241ff79ae9aa2225ee05
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 84745f9e7408..bab134b6369f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -464,21 +464,21 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device 
*adev,
 {
struct ttm_mem_type_manager *man = NULL;
 
-   /*
-* If GTT is part of requested domains the check must succeed to
-* allow fall back to GTT
-*/
-   if (domain & AMDGPU_GEM_DOMAIN_GTT) {
-   man = >mman.bdev.man[TTM_PL_TT];
+   if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
+   man = >mman.bdev.man[TTM_PL_VRAM];
 
if (size < (man->size << PAGE_SHIFT))
return true;
-   else
+   else if (!(domain & AMDGPU_GEM_DOMAIN_GTT))
goto fail;
}
 
-   if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
-   man = >mman.bdev.man[TTM_PL_VRAM];
+   /*
+* If GTT is part of requested domains the check must succeed to
+* allow fall back to GTT
+*/
+   if (domain & AMDGPU_GEM_DOMAIN_GTT) {
+   man = >mman.bdev.man[TTM_PL_TT];
 
if (size < (man->size << PAGE_SHIFT))
return true;
-- 
2.17.1

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


[PATCH] drm/amdgpu: disable 3D pipe 1 on Navi1x

2020-03-01 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
CP firmware decide to skip setting the state for 3D pipe 1 for Navi1x as there
is no use case.

[how]
Disable 3D pipe 1 on Navi1x.

Change-Id: I6898bdfe31d4e7908bd9bcfa82b6a75e118e8727
Reviewed-by: Hawking Zhang 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 97 ++
 1 file changed, 51 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 760fe2ebe799..f348512eb8c3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -52,7 +52,7 @@
  * 1. Primary ring
  * 2. Async ring
  */
-#define GFX10_NUM_GFX_RINGS2
+#define GFX10_NUM_GFX_RINGS_NV1X   1
 #define GFX10_MEC_HPD_SIZE 2048
 
 #define F32_CE_PROGRAM_RAM_SIZE65536
@@ -1305,7 +1305,7 @@ static int gfx_v10_0_sw_init(void *handle)
case CHIP_NAVI14:
case CHIP_NAVI12:
adev->gfx.me.num_me = 1;
-   adev->gfx.me.num_pipe_per_me = 2;
+   adev->gfx.me.num_pipe_per_me = 1;
adev->gfx.me.num_queue_per_pipe = 1;
adev->gfx.mec.num_mec = 2;
adev->gfx.mec.num_pipe_per_mec = 4;
@@ -2711,18 +2711,20 @@ static int gfx_v10_0_cp_gfx_start(struct amdgpu_device 
*adev)
amdgpu_ring_commit(ring);
 
/* submit cs packet to copy state 0 to next available state */
-   ring = >gfx.gfx_ring[1];
-   r = amdgpu_ring_alloc(ring, 2);
-   if (r) {
-   DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
-   return r;
-   }
-
-   amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0));
-   amdgpu_ring_write(ring, 0);
+   if (adev->gfx.num_gfx_rings > 1) {
+   /* maximum supported gfx ring is 2 */
+   ring = >gfx.gfx_ring[1];
+   r = amdgpu_ring_alloc(ring, 2);
+   if (r) {
+   DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
+   return r;
+   }
 
-   amdgpu_ring_commit(ring);
+   amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0));
+   amdgpu_ring_write(ring, 0);
 
+   amdgpu_ring_commit(ring);
+   }
return 0;
 }
 
@@ -2819,39 +2821,41 @@ static int gfx_v10_0_cp_gfx_resume(struct amdgpu_device 
*adev)
mutex_unlock(>srbm_mutex);
 
/* Init gfx ring 1 for pipe 1 */
-   mutex_lock(>srbm_mutex);
-   gfx_v10_0_cp_gfx_switch_pipe(adev, PIPE_ID1);
-   ring = >gfx.gfx_ring[1];
-   rb_bufsz = order_base_2(ring->ring_size / 8);
-   tmp = REG_SET_FIELD(0, CP_RB1_CNTL, RB_BUFSZ, rb_bufsz);
-   tmp = REG_SET_FIELD(tmp, CP_RB1_CNTL, RB_BLKSZ, rb_bufsz - 2);
-   WREG32_SOC15(GC, 0, mmCP_RB1_CNTL, tmp);
-   /* Initialize the ring buffer's write pointers */
-   ring->wptr = 0;
-   WREG32_SOC15(GC, 0, mmCP_RB1_WPTR, lower_32_bits(ring->wptr));
-   WREG32_SOC15(GC, 0, mmCP_RB1_WPTR_HI, upper_32_bits(ring->wptr));
-   /* Set the wb address wether it's enabled or not */
-   rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
-   WREG32_SOC15(GC, 0, mmCP_RB1_RPTR_ADDR, lower_32_bits(rptr_addr));
-   WREG32_SOC15(GC, 0, mmCP_RB1_RPTR_ADDR_HI, upper_32_bits(rptr_addr) &
-   CP_RB1_RPTR_ADDR_HI__RB_RPTR_ADDR_HI_MASK);
-   wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
-   WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_ADDR_LO,
-   lower_32_bits(wptr_gpu_addr));
-   WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_ADDR_HI,
-   upper_32_bits(wptr_gpu_addr));
-
-   mdelay(1);
-   WREG32_SOC15(GC, 0, mmCP_RB1_CNTL, tmp);
-
-   rb_addr = ring->gpu_addr >> 8;
-   WREG32_SOC15(GC, 0, mmCP_RB1_BASE, rb_addr);
-   WREG32_SOC15(GC, 0, mmCP_RB1_BASE_HI, upper_32_bits(rb_addr));
-   WREG32_SOC15(GC, 0, mmCP_RB1_ACTIVE, 1);
-
-   gfx_v10_0_cp_gfx_set_doorbell(adev, ring);
-   mutex_unlock(>srbm_mutex);
-
+   if (adev->gfx.num_gfx_rings > 1) {
+   mutex_lock(>srbm_mutex);
+   gfx_v10_0_cp_gfx_switch_pipe(adev, PIPE_ID1);
+   /* maximum supported gfx ring is 2 */
+   ring = >gfx.gfx_ring[1];
+   rb_bufsz = order_base_2(ring->ring_size / 8);
+   tmp = REG_SET_FIELD(0, CP_RB1_CNTL, RB_BUFSZ, rb_bufsz);
+   tmp = REG_SET_FIELD(tmp, CP_RB1_CNTL, RB_BLKSZ, rb_bufsz - 2);
+   WREG32_SOC15(GC, 0, mmCP_RB1_CNTL, tmp);
+   /* Initialize the ring buffer's write pointers */
+   ring->wptr = 0;
+   WREG32_SOC15(GC, 0, mmCP_RB1_WPTR, lower_32_bits(ring->wptr));
+   WREG32_SOC15(GC, 0, mmCP_RB1_WPTR_HI, 
upper_32_bits(ring->wptr));
+   /* Set the wb address wether it's enabled or not */
+   rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
+   

[PATCH 2/2] Revert "drm/amdgpu: fix modprobe failure of the secondary GPU when GDDR6 training enabled(V5)"

2020-01-20 Thread Tianci Yin
From: "Tianci.Yin" 

This reverts commit 2ad857d7b82081736c078997ba0542acfdd50099.

The patch will be replaced with a better solution, revert it.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 -
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 27 +
 2 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 86267baca07c..d3c27a3c43f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,11 +60,6 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
-/*
- * Default stolen memory size, 1024 * 768 * 4
- */
-#define AMDGPU_STOLEN_BIST_TRAINING_DEFAULT_SIZE   0x30ULL
-
 struct firmware;
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 86f4ffe408e7..0c5bf3bd640f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -641,12 +641,7 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
-   /*
-* Can't free the stolen VGA memory when it might be used for memory
-* training again.
-*/
-   if (!adev->fw_vram_usage.mem_train_support)
-   amdgpu_bo_late_init(adev);
+   amdgpu_bo_late_init(adev);
 
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
@@ -830,19 +825,6 @@ static int gmc_v10_0_sw_init(void *handle)
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
 
-   /*
-* In dual GPUs scenario, stolen_size is assigned to zero on the
-* secondary GPU, since there is no pre-OS console using that memory.
-* Then the bottom region of VRAM was allocated as GTT, unfortunately a
-* small region of bottom VRAM was encroached by UMC firmware during
-* GDDR6 BIST training, this cause page fault.
-* The page fault can be fixed by forcing stolen_size to 3MB, then the
-* bottom region of VRAM was allocated as stolen memory, GTT corruption
-* avoid.
-*/
-   adev->gmc.stolen_size = max(adev->gmc.stolen_size,
-   AMDGPU_STOLEN_BIST_TRAINING_DEFAULT_SIZE);
-
/* Memory manager */
r = amdgpu_bo_init(adev);
if (r)
@@ -882,13 +864,6 @@ static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 static int gmc_v10_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   void *stolen_vga_buf;
-
-   /*
-* Free the stolen memory if it wasn't already freed in late_init
-* because of memory training.
-*/
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 
amdgpu_vm_manager_fini(adev);
gmc_v10_0_gart_fini(adev);
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: fix VRAM partially encroached issue in GDDR6 memory training(V2)

2020-01-20 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In GDDR6 BIST training, a certain mount of bottom VRAM will be encroached by
UMC, that causes problems(like GTT corrupted and page fault observed).

[how]
Saving the content of this bottom VRAM to system memory before training, and
restoring it after training to avoid VRAM corruption.

Change-Id: I04a8a6e8e63b3619f7c693fe67883b229cbf3c53
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 36 ++---
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 3265487b859f..611021514c52 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -172,6 +172,8 @@ struct psp_dtm_context {
 #define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942
 #define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES  0x1000
 #define GDDR6_MEM_TRAINING_OFFSET  0x8000
+/*Define the VRAM size that will be encroached by BIST training.*/
+#define GDDR6_MEM_TRAINING_ENCROACHED_SIZE 0x200
 
 enum psp_memory_training_init_flag {
PSP_MEM_TRAIN_NOT_SUPPORT   = 0x0,
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 685dd9754c67..ac173d2eb809 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -971,10 +971,13 @@ static int psp_v11_0_memory_training_init(struct 
psp_context *psp)
  */
 static int psp_v11_0_memory_training(struct psp_context *psp, uint32_t ops)
 {
-   int ret;
-   uint32_t p2c_header[4];
struct psp_memory_training_context *ctx = >mem_train_ctx;
uint32_t *pcache = (uint32_t*)ctx->sys_cache;
+   struct amdgpu_device *adev = psp->adev;
+   uint32_t p2c_header[4];
+   uint32_t sz;
+   void *buf;
+   int ret;
 
if (ctx->init == PSP_MEM_TRAIN_NOT_SUPPORT) {
DRM_DEBUG("Memory training is not supported.\n");
@@ -989,7 +992,7 @@ static int psp_v11_0_memory_training(struct psp_context 
*psp, uint32_t ops)
return 0;
}
 
-   amdgpu_device_vram_access(psp->adev, ctx->p2c_train_data_offset, 
p2c_header, sizeof(p2c_header), false);
+   amdgpu_device_vram_access(adev, ctx->p2c_train_data_offset, p2c_header, 
sizeof(p2c_header), false);
DRM_DEBUG("sys_cache[%08x,%08x,%08x,%08x] 
p2c_header[%08x,%08x,%08x,%08x]\n",
  pcache[0], pcache[1], pcache[2], pcache[3],
  p2c_header[0], p2c_header[1], p2c_header[2], p2c_header[3]);
@@ -1026,11 +1029,38 @@ static int psp_v11_0_memory_training(struct psp_context 
*psp, uint32_t ops)
DRM_DEBUG("Memory training ops:%x.\n", ops);
 
if (ops & PSP_MEM_TRAIN_SEND_LONG_MSG) {
+   /*
+* Long traing will encroach certain mount of bottom VRAM,
+* saving the content of this bottom VRAM to system memory
+* before training, and restoring it after training to avoid
+* VRAM corruption.
+*/
+   sz = GDDR6_MEM_TRAINING_ENCROACHED_SIZE;
+
+   if (adev->gmc.visible_vram_size < sz || 
!adev->mman.aper_base_kaddr) {
+   DRM_ERROR("visible_vram_size %llx or aper_base_kaddr %p 
is not initialized.\n",
+ adev->gmc.visible_vram_size,
+ adev->mman.aper_base_kaddr);
+   return -EINVAL;
+   }
+
+   buf = vmalloc(sz);
+   if (!buf) {
+   DRM_ERROR("failed to allocate system memory.\n");
+   return -ENOMEM;
+   }
+
+   memcpy_fromio(buf, adev->mman.aper_base_kaddr, sz);
ret = psp_v11_0_memory_training_send_msg(psp, 
PSP_BL__DRAM_LONG_TRAIN);
if (ret) {
DRM_ERROR("Send long training msg failed.\n");
+   vfree(buf);
return ret;
}
+
+   memcpy_toio(adev->mman.aper_base_kaddr, buf, sz);
+   adev->nbio.funcs->hdp_flush(adev, NULL);
+   vfree(buf);
}
 
if (ops & PSP_MEM_TRAIN_SAVE) {
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu: fix VRAM partially encroached issue in GDDR6 memory training

2020-01-20 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In GDDR6 BIST training, a certain mount of bottom VRAM will be encroached by
UMC, that causes problems(like GTT corrupted and page fault observed).

[how]
Saving the content of this bottom VRAM to system memory before training, and
restoring it after training to avoid VRAM corruption.

Change-Id: I04a8a6e8e63b3619f7c693fe67883b229cbf3c53
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 32 -
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 3265487b859f..611021514c52 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -172,6 +172,8 @@ struct psp_dtm_context {
 #define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942
 #define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES  0x1000
 #define GDDR6_MEM_TRAINING_OFFSET  0x8000
+/*Define the VRAM size that will be encroached by BIST training.*/
+#define GDDR6_MEM_TRAINING_ENCROACHED_SIZE 0x200
 
 enum psp_memory_training_init_flag {
PSP_MEM_TRAIN_NOT_SUPPORT   = 0x0,
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 685dd9754c67..51011b661ba8 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -972,7 +972,10 @@ static int psp_v11_0_memory_training_init(struct 
psp_context *psp)
 static int psp_v11_0_memory_training(struct psp_context *psp, uint32_t ops)
 {
int ret;
+   void *buf;
+   uint32_t sz;
uint32_t p2c_header[4];
+   struct amdgpu_device *adev = psp->adev;
struct psp_memory_training_context *ctx = >mem_train_ctx;
uint32_t *pcache = (uint32_t*)ctx->sys_cache;
 
@@ -989,7 +992,7 @@ static int psp_v11_0_memory_training(struct psp_context 
*psp, uint32_t ops)
return 0;
}
 
-   amdgpu_device_vram_access(psp->adev, ctx->p2c_train_data_offset, 
p2c_header, sizeof(p2c_header), false);
+   amdgpu_device_vram_access(adev, ctx->p2c_train_data_offset, p2c_header, 
sizeof(p2c_header), false);
DRM_DEBUG("sys_cache[%08x,%08x,%08x,%08x] 
p2c_header[%08x,%08x,%08x,%08x]\n",
  pcache[0], pcache[1], pcache[2], pcache[3],
  p2c_header[0], p2c_header[1], p2c_header[2], p2c_header[3]);
@@ -1026,11 +1029,38 @@ static int psp_v11_0_memory_training(struct psp_context 
*psp, uint32_t ops)
DRM_DEBUG("Memory training ops:%x.\n", ops);
 
if (ops & PSP_MEM_TRAIN_SEND_LONG_MSG) {
+   /*
+* Long traing will encroach certain mount of bottom VRAM,
+* saving the content of this bottom VRAM to system memory
+* before training, and restoring it after training to avoid
+* VRAM corruption.
+*/
+   sz = GDDR6_MEM_TRAINING_ENCROACHED_SIZE;
+
+   if (adev->gmc.visible_vram_size < sz || 
!adev->mman.aper_base_kaddr) {
+   DRM_ERROR("visible_vram_size %llx or aper_base_kaddr %p 
is not initialized.\n",
+ adev->gmc.visible_vram_size,
+ adev->mman.aper_base_kaddr);
+   return -EINVAL;
+   }
+
+   buf = vmalloc(sz);
+   if (!buf) {
+   DRM_ERROR("failed to allocate system memory.\n");
+   return -ENOMEM;
+   }
+
+   memcpy_fromio(buf, adev->mman.aper_base_kaddr, sz);
ret = psp_v11_0_memory_training_send_msg(psp, 
PSP_BL__DRAM_LONG_TRAIN);
if (ret) {
DRM_ERROR("Send long training msg failed.\n");
+   vfree(buf);
return ret;
}
+
+   memcpy_toio(adev->mman.aper_base_kaddr, buf, sz);
+   adev->nbio.funcs->hdp_flush(adev, NULL);
+   vfree(buf);
}
 
if (ops & PSP_MEM_TRAIN_SAVE) {
-- 
2.17.1

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


[PATCH 1/2] Revert "drm/amdgpu: fix modprobe failure of the secondary GPU when GDDR6 training enabled(V5)"

2020-01-20 Thread Tianci Yin
From: "Tianci.Yin" 

This reverts commit 2ad857d7b82081736c078997ba0542acfdd50099.

The patch will be replaced with a better solution, revert it.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 -
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 27 +
 2 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 86267baca07c..d3c27a3c43f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,11 +60,6 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
-/*
- * Default stolen memory size, 1024 * 768 * 4
- */
-#define AMDGPU_STOLEN_BIST_TRAINING_DEFAULT_SIZE   0x30ULL
-
 struct firmware;
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 86f4ffe408e7..0c5bf3bd640f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -641,12 +641,7 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
-   /*
-* Can't free the stolen VGA memory when it might be used for memory
-* training again.
-*/
-   if (!adev->fw_vram_usage.mem_train_support)
-   amdgpu_bo_late_init(adev);
+   amdgpu_bo_late_init(adev);
 
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
@@ -830,19 +825,6 @@ static int gmc_v10_0_sw_init(void *handle)
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
 
-   /*
-* In dual GPUs scenario, stolen_size is assigned to zero on the
-* secondary GPU, since there is no pre-OS console using that memory.
-* Then the bottom region of VRAM was allocated as GTT, unfortunately a
-* small region of bottom VRAM was encroached by UMC firmware during
-* GDDR6 BIST training, this cause page fault.
-* The page fault can be fixed by forcing stolen_size to 3MB, then the
-* bottom region of VRAM was allocated as stolen memory, GTT corruption
-* avoid.
-*/
-   adev->gmc.stolen_size = max(adev->gmc.stolen_size,
-   AMDGPU_STOLEN_BIST_TRAINING_DEFAULT_SIZE);
-
/* Memory manager */
r = amdgpu_bo_init(adev);
if (r)
@@ -882,13 +864,6 @@ static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 static int gmc_v10_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   void *stolen_vga_buf;
-
-   /*
-* Free the stolen memory if it wasn't already freed in late_init
-* because of memory training.
-*/
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 
amdgpu_vm_manager_fini(adev);
gmc_v10_0_gart_fini(adev);
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu/gfx10: update gfx golden settings

2020-01-14 Thread Tianci Yin
From: "Tianci.Yin" 

remove registers: mmSPI_CONFIG_CNTL
add registers: mmSPI_CONFIG_CNTL_1

Change-Id: I8d1c5d0a0553d60a6e419d6acb9750e5b2634e49
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index d72b60f997c8..4f6ffaf3f9be 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -121,7 +121,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0x0800, 
0x0820),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070104),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x001f, 
0x00070104),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ALU_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ARB_CONFIG, 0x0100, 0x0130),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0x, 
0x),
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu/gfx10: update gfx golden settings for navi14

2020-01-14 Thread Tianci Yin
From: "Tianci.Yin" 

remove registers: mmSPI_CONFIG_CNTL
add registers: mmSPI_CONFIG_CNTL_1

Change-Id: I0bbaeca184e7dc85463d6c5740151d6ba1b08c06
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 4f6ffaf3f9be..3c9082b1eea9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -169,7 +169,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0x0800, 
0x0820),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070105),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x001f, 
0x00070105),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ALU_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ARB_CONFIG, 0x0133, 0x0130),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0x, 
0x),
-- 
2.17.1

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


[PATCH] drm/amdgpu: fix modprobe failure of the secondary GPU when GDDR6 training enabled(V5)

2020-01-12 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In dual GPUs scenario, stolen_size is assigned to zero on the secondary GPU,
since there is no pre-OS console using that memory. Then the bottom region of
VRAM was allocated as GTT, unfortunately a small region of bottom VRAM was
encroached by UMC firmware during GDDR6 BIST training, this cause page fault.

[how]
Forcing stolen_size to 3MB, then the bottom region of VRAM was
allocated as stolen memory, GTT corruption avoid.

Change-Id: I310a72ba0402994defbe50839842a8edb025a868
Reviewed-by: Christian König 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 +
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 27 -
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index c91dd602d5f1..ede4a0ea0c84 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,6 +60,11 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
+/*
+ * Default stolen memory size, 1024 * 768 * 4
+ */
+#define AMDGPU_STOLEN_BIST_TRAINING_DEFAULT_SIZE   0x30ULL
+
 struct firmware;
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 5ad89bb6f3ba..04017057f8ca 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -566,7 +566,12 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
-   amdgpu_bo_late_init(adev);
+   /*
+* Can't free the stolen VGA memory when it might be used for memory
+* training again.
+*/
+   if (!adev->fw_vram_usage.mem_train_support)
+   amdgpu_bo_late_init(adev);
 
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
@@ -750,6 +755,19 @@ static int gmc_v10_0_sw_init(void *handle)
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
 
+   /*
+* In dual GPUs scenario, stolen_size is assigned to zero on the
+* secondary GPU, since there is no pre-OS console using that memory.
+* Then the bottom region of VRAM was allocated as GTT, unfortunately a
+* small region of bottom VRAM was encroached by UMC firmware during
+* GDDR6 BIST training, this cause page fault.
+* The page fault can be fixed by forcing stolen_size to 3MB, then the
+* bottom region of VRAM was allocated as stolen memory, GTT corruption
+* avoid.
+*/
+   adev->gmc.stolen_size = max(adev->gmc.stolen_size,
+   AMDGPU_STOLEN_BIST_TRAINING_DEFAULT_SIZE);
+
/* Memory manager */
r = amdgpu_bo_init(adev);
if (r)
@@ -789,6 +807,13 @@ static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 static int gmc_v10_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   void *stolen_vga_buf;
+
+   /*
+* Free the stolen memory if it wasn't already freed in late_init
+* because of memory training.
+*/
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 
amdgpu_vm_manager_fini(adev);
gmc_v10_0_gart_fini(adev);
-- 
2.17.1

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


[PATCH] drm/amdgpu: fix modprobe failure of the secondary GPU when GDDR6 training enabled(V4)

2020-01-09 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In dual GPUs scenario, stolen_size is assigned to zero on the secondary GPU,
since there is no pre-OS console using that memory. Then the bottom region of
VRAM was allocated as GTT, unfortunately a small region of bottom VRAM was
encroached by UMC firmware during GDDR6 BIST training, this cause page fault.

[how]
Forcing stolen_size to 3MB, then the bottom region of VRAM was
allocated as stolen memory, GTT corruption avoid.

Change-Id: I310a72ba0402994defbe50839842a8edb025a868
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 +
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 27 -
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index c91dd602d5f1..e4b2f9bcaeb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,6 +60,11 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
+/*
+ * Default stolen memory size, 1024 * 768 * 4
+ */
+#define AMDGPU_STOLEN_VGA_DEFAULT_SIZE 0x30ULL
+
 struct firmware;
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 5ad89bb6f3ba..14961f1ebfab 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -566,7 +566,12 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
-   amdgpu_bo_late_init(adev);
+   /*
+* Can't free the stolen VGA memory when it might be used for memory
+* training again.
+*/
+   if (!adev->fw_vram_usage.mem_train_support)
+   amdgpu_bo_late_init(adev);
 
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
@@ -750,6 +755,19 @@ static int gmc_v10_0_sw_init(void *handle)
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
 
+   /*
+* In dual GPUs scenario, stolen_size is assigned to zero on the
+* secondary GPU, since there is no pre-OS console using that memory.
+* Then the bottom region of VRAM was allocated as GTT, unfortunately a
+* small region of bottom VRAM was encroached by UMC firmware during
+* GDDR6 BIST training, this cause page fault.
+* The page fault can be fixed by forcing stolen_size to 3MB, then the
+* bottom region of VRAM was allocated as stolen memory, GTT corruption
+* avoid.
+*/
+   adev->gmc.stolen_size = max(adev->gmc.stolen_size,
+   AMDGPU_STOLEN_VGA_DEFAULT_SIZE);
+
/* Memory manager */
r = amdgpu_bo_init(adev);
if (r)
@@ -789,6 +807,13 @@ static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 static int gmc_v10_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   void *stolen_vga_buf;
+
+   /*
+* Free the stolen memory if it wasn't already freed in late_init
+* because of memory training.
+*/
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 
amdgpu_vm_manager_fini(adev);
gmc_v10_0_gart_fini(adev);
-- 
2.17.1

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


[PATCH] drm/amdgpu: fix modprobe failure of the secondary GPU when GDDR6 training enabled(V3)

2020-01-09 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In dual GPUs scenario, stolen_size is assigned to zero on the secondary GPU,
since there is no pre-OS console using that memory. Then the bottom region of
VRAM was allocated as GTT, unfortunately a small region of bottom VRAM was
encroached by UMC firmware during GDDR6 BIST training, this cause page fault.

[how]
Forcing stolen_size to 3MB, then the bottom region of VRAM was
allocated as stolen memory, GTT corruption avoid.

Change-Id: I310a72ba0402994defbe50839842a8edb025a868
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 +
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 27 +
 2 files changed, 32 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index c91dd602d5f1..e4b2f9bcaeb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,6 +60,11 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
+/*
+ * Default stolen memory size, 1024 * 768 * 4
+ */
+#define AMDGPU_STOLEN_VGA_DEFAULT_SIZE 0x30ULL
+
 struct firmware;
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 7dc8c068c62a..b95add93d6b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -566,6 +566,13 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
+   /*
+* Can't free the stolen VGA memory when it might be used for memory
+* training again.
+*/
+   if (!adev->fw_vram_usage.mem_train_support)
+   amdgpu_bo_late_init(adev);
+
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
return r;
@@ -757,6 +764,19 @@ static int gmc_v10_0_sw_init(void *handle)
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
 
+   /*
+* In dual GPUs scenario, stolen_size is assigned to zero on the
+* secondary GPU, since there is no pre-OS console using that memory.
+* Then the bottom region of VRAM was allocated as GTT, unfortunately a
+* small region of bottom VRAM was encroached by UMC firmware during
+* GDDR6 BIST training, this cause page fault.
+* The page fault can be fixed by forcing stolen_size to 3MB, then the
+* bottom region of VRAM was allocated as stolen memory, GTT corruption
+* avoid.
+*/
+   adev->gmc.stolen_size = max(adev->gmc.stolen_size,
+   AMDGPU_STOLEN_VGA_DEFAULT_SIZE);
+
/* Memory manager */
r = amdgpu_bo_init(adev);
if (r)
@@ -796,6 +816,13 @@ static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 static int gmc_v10_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   void *stolen_vga_buf;
+
+   /*
+* Free the stolen memory if it wasn't already freed in late_init
+* because of memory training.
+*/
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 
amdgpu_vm_manager_fini(adev);
gmc_v10_0_gart_fini(adev);
-- 
2.17.1

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


[PATCH] drm/amdgpu: fix modprobe failure of the secondary GPU when GDDR6 training enabled(V2)

2020-01-09 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In dual GPUs scenario, stolen_size is assigned to zero on the secondary GPU,
since there is no pre-OS console using that memory. Then the bottom region of
VRAM was allocated as GTT, unfortunately a small region of bottom VRAM was
encroached by UMC firmware during GDDR6 BIST training, this cause page fault.

[how]
Forcing stolen_size to 3MB, then the bottom region of VRAM was
allocated as stolen memory, GTT corruption avoid.

Change-Id: I310a72ba0402994defbe50839842a8edb025a868
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 +
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 28 +
 2 files changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index c91dd602d5f1..e4b2f9bcaeb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,6 +60,11 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
+/*
+ * Default stolen memory size, 1024 * 768 * 4
+ */
+#define AMDGPU_STOLEN_VGA_DEFAULT_SIZE 0x30ULL
+
 struct firmware;
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 7dc8c068c62a..0e0fdf7596eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -566,6 +566,13 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
+   /*
+* Can't free the stolen VGA memory when it might be used for memory
+* training again.
+*/
+   if (!adev->fw_vram_usage.mem_train_support)
+   amdgpu_bo_late_init(adev);
+
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
return r;
@@ -757,6 +764,19 @@ static int gmc_v10_0_sw_init(void *handle)
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
 
+   /*
+* In dual GPUs scenario, stolen_size is assigned to zero on the
+* secondary GPU, since there is no pre-OS console using that memory.
+* Then the bottom region of VRAM was allocated as GTT, unfortunately a
+* small region of bottom VRAM was encroached by UMC firmware during
+* GDDR6 BIST training, this cause page fault.
+* The page fault can be fixed by forcing stolen_size to 3MB, then the
+* bottom region of VRAM was allocated as stolen memory, GTT corruption
+* avoid.
+*/
+   adev->gmc.stolen_size = max(adev->gmc.stolen_size,
+   AMDGPU_STOLEN_VGA_DEFAULT_SIZE);
+
/* Memory manager */
r = amdgpu_bo_init(adev);
if (r)
@@ -796,6 +816,14 @@ static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 static int gmc_v10_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   void *stolen_vga_buf;
+
+   /*
+* Free the stolen VGA memory when it might be used for memory training.
+*/
+   if (adev->fw_vram_usage.mem_train_support)
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL,
+ _vga_buf);
 
amdgpu_vm_manager_fini(adev);
gmc_v10_0_gart_fini(adev);
-- 
2.17.1

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


[PATCH] drm/amdgpu: fix modprobe failure of the 2nd GPU when GDDR6 training enabled

2020-01-08 Thread Tianci Yin
From: "Tianci.Yin" 

[why]
In dual GPUs scenario, stolen_size is assigned to zero on the 2nd GPU,
then the bottom region of VRAM was allocated as GTT, unfortunately
a small region of bottom VRAM was encroached by UMC firmware during
GDDR6 BIST training, this cause pagefault.

[how]
Forcing stolen_size to 3MB, then the bottom region of VRAM was
allocated as stolen memory, GTT corruption avoid.
The stolen memory of the 2nd GPU will be free in late_init phase,
no memory wasted.

Change-Id: Icd0ad7de41333282949bb1e3e676c6c307ddd081
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  6 ++
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 21 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index c91dd602d5f1..440b793316df 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -60,6 +60,11 @@
  */
 #define AMDGPU_GMC_FAULT_TIMEOUT   5000ULL
 
+/*
+ * Default stolen memory size, 1024 * 768 * 4
+ */
+#define AMDGPU_STOLEN_VGA_DEFAULT_SIZE 0x30
+
 struct firmware;
 
 /*
@@ -192,6 +197,7 @@ struct amdgpu_gmc {
uint32_tsrbm_soft_reset;
boolprt_warning;
uint64_tstolen_size;
+   boolstolen_temp_reserved;
/* apertures */
u64 shared_aperture_start;
u64 shared_aperture_end;
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 7dc8c068c62a..0c96b67d6ca7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -566,6 +566,11 @@ static int gmc_v10_0_late_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
 
+   if (adev->gmc.stolen_temp_reserved) {
+   amdgpu_bo_late_init(adev);
+   adev->gmc.stolen_temp_reserved = false;
+   }
+
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
if (r)
return r;
@@ -756,6 +761,22 @@ static int gmc_v10_0_sw_init(void *handle)
return r;
 
adev->gmc.stolen_size = gmc_v10_0_get_vbios_fb_size(adev);
+   /*
+* In dual GPUs scenario, stolen_size is assigned to zero on the 2nd 
GPU,
+* then the bottom region of VRAM was allocated as GTT, unfortunately
+* a small region of bottom VRAM was encroached by UMC firmware during
+* GDDR6 BIST training, this cause pagefault.
+* The page fault can be fixed by forcing stolen_size to 3MB, then the 
bottom
+* region of VRAM was allocated as stolen memory, GTT corruption avoid.
+* The stolen memory of the 2nd GPU will be free in late_init phase,
+* no memory wasted.
+*/
+   if (adev->fw_vram_usage.mem_train_support &&
+   adev->gmc.stolen_size == 0) {
+   adev->gmc.stolen_size = AMDGPU_STOLEN_VGA_DEFAULT_SIZE;
+   adev->gmc.stolen_temp_reserved = true;
+   } else
+   adev->gmc.stolen_temp_reserved = false;
 
/* Memory manager */
r = amdgpu_bo_init(adev);
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training(V4)

2019-12-19 Thread Tianci Yin
From: "Tianci.Yin" 

The method of getting fb_loc changed from parsing VBIOS to
taking certain offset from top of VRAM

Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c  |  2 +-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 38 ++-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 10 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  7 
 drivers/gpu/drm/amd/include/atomfirmware.h| 14 ---
 7 files changed, 23 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363b1d71..fa2cf8e7bc07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {
struct amdgpu_bo *reserved_bo;
void *va;
 
-   /* Offset on the top of VRAM, used as c2p write buffer.
+   /* GDDR6 training support flag.
*/
-   u64 mem_train_fb_loc;
bool mem_train_support;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 9ba80d828876..fdd52d86a4d7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -2022,7 +2022,7 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
if (adev->is_atom_fw) {
amdgpu_atomfirmware_scratch_regs_init(adev);
amdgpu_atomfirmware_allocate_fb_scratch(adev);
-   ret = amdgpu_atomfirmware_get_mem_train_fb_loc(adev);
+   ret = amdgpu_atomfirmware_get_mem_train_info(adev);
if (ret) {
DRM_ERROR("Failed to get mem train fb location.\n");
return ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index ff4eb96bdfb5..58f9d8c3a17a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -525,16 +525,12 @@ static int gddr6_mem_train_support(struct amdgpu_device 
*adev)
return ret;
 }
 
-int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
+int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev)
 {
struct atom_context *ctx = adev->mode_info.atom_context;
-   unsigned char *bios = ctx->bios;
-   struct vram_reserve_block *reserved_block;
-   int index, block_number;
+   int index;
uint8_t frev, crev;
uint16_t data_offset, size;
-   uint32_t start_address_in_kb;
-   uint64_t offset;
int ret;
 
adev->fw_vram_usage.mem_train_support = false;
@@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct 
amdgpu_device *adev)
return -EINVAL;
}
 
-   reserved_block = (struct vram_reserve_block *)
-   (bios + data_offset + sizeof(struct atom_common_table_header));
-   block_number = ((unsigned int)size - sizeof(struct 
atom_common_table_header))
-   / sizeof(struct vram_reserve_block);
-   reserved_block += (block_number > 0) ? block_number-1 : 0;
-   DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb 
drv.\n",
- block_number,
- le32_to_cpu(reserved_block->start_address_in_kb),
- le16_to_cpu(reserved_block->used_by_firmware_in_kb),
- le16_to_cpu(reserved_block->used_by_driver_in_kb));
-   if (reserved_block->used_by_firmware_in_kb > 0) {
-   start_address_in_kb = 
le32_to_cpu(reserved_block->start_address_in_kb);
-   offset = (uint64_t)start_address_in_kb * ONE_KiB;
-   if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
-   offset -= ONE_MiB;
-   }
-
-   offset &= ~(ONE_MiB - 1);
-   adev->fw_vram_usage.mem_train_fb_loc = offset;
-   adev->fw_vram_usage.mem_train_support = true;
-   DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);
-   ret = 0;
-   } else {
-   DRM_ERROR("used_by_firmware_in_kb is 0!\n");
-   ret = -EINVAL;
-   }
-
-   return ret;
+   adev->fw_vram_usage.mem_train_support = true;
+   return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
index f871af5ea6f3..434fe2fa0089 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
@@ -31,7 +31,7 @@ void amdgpu_atomfirmware_scratch_regs_init(struct 
amdgpu_device *adev);
 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,

[PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation(V2)

2019-12-19 Thread Tianci Yin
From: "Tianci.Yin" 

IP discovery TMR(occupied the top VRAM with size DISCOVERY_TMR_SIZE)
has been reserved, and the p2c buffer is in the range of this TMR, so
the p2c buffer reservation is unnecessary.

Change-Id: Ib1f2f2b4a1f3869c03ffe22e2836cdbee17ba99f
Reviewed-by: Kevin Wang 
Reviewed-by: Xiaojie Yuan 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 5f8fd3e3535b..3265487b859f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -202,7 +202,6 @@ struct psp_memory_training_context {
 
/*vram offset of the p2c training data*/
u64 p2c_train_data_offset;
-   struct amdgpu_bo *p2c_bo;
 
/*vram offset of the c2p training data*/
u64 c2p_train_data_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 1515413fd356..1aab4e349bc8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1681,9 +1681,6 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct 
amdgpu_device *adev)
amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
ctx->c2p_bo = NULL;
 
-   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
-   ctx->p2c_bo = NULL;
-
return 0;
 }
 
@@ -1722,17 +1719,6 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
  ctx->p2c_train_data_offset,
  ctx->c2p_train_data_offset);
 
-   ret = amdgpu_bo_create_kernel_at(adev,
-ctx->p2c_train_data_offset,
-ctx->train_data_size,
-AMDGPU_GEM_DOMAIN_VRAM,
->p2c_bo,
-NULL);
-   if (ret) {
-   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
-   goto Err_out;
-   }
-
ret = amdgpu_bo_create_kernel_at(adev,
 ctx->c2p_train_data_offset,
 ctx->train_data_size,
@@ -1741,15 +1727,12 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
 NULL);
if (ret) {
DRM_ERROR("alloc c2p_bo failed(%d)!\n", ret);
-   goto Err_out;
+   amdgpu_ttm_training_reserve_vram_fini(adev);
+   return ret;
}
 
ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
return 0;
-
-Err_out:
-   amdgpu_ttm_training_reserve_vram_fini(adev);
-   return ret;
 }
 
 /**
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation(V2)

2019-12-18 Thread Tianci Yin
From: "Tianci.Yin" 

IP discovery TMR(occupied the top VRAM with size DISCOVERY_TMR_SIZE)
has been reserved, and the p2c buffer is in the range of this TMR, so
the p2c buffer reservation is unnecessary.

Change-Id: Ib1f2f2b4a1f3869c03ffe22e2836cdbee17ba99f
Reviewed-by: Kevin Wang 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 5f8fd3e3535b..3265487b859f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -202,7 +202,6 @@ struct psp_memory_training_context {
 
/*vram offset of the p2c training data*/
u64 p2c_train_data_offset;
-   struct amdgpu_bo *p2c_bo;
 
/*vram offset of the c2p training data*/
u64 c2p_train_data_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ec84acdd43a2..60f17e989014 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1681,9 +1681,6 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct 
amdgpu_device *adev)
amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
ctx->c2p_bo = NULL;
 
-   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
-   ctx->p2c_bo = NULL;
-
return 0;
 }
 
@@ -1725,17 +1722,6 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
  ctx->p2c_train_data_offset,
  ctx->c2p_train_data_offset);
 
-   ret = amdgpu_bo_create_kernel_at(adev,
-ctx->p2c_train_data_offset,
-ctx->train_data_size,
-AMDGPU_GEM_DOMAIN_VRAM,
->p2c_bo,
-NULL);
-   if (ret) {
-   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
-   goto Err_out;
-   }
-
ret = amdgpu_bo_create_kernel_at(adev,
 ctx->c2p_train_data_offset,
 ctx->train_data_size,
@@ -1744,15 +1730,12 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
 NULL);
if (ret) {
DRM_ERROR("alloc c2p_bo failed(%d)!\n", ret);
-   goto Err_out;
+   amdgpu_ttm_training_reserve_vram_fini(adev);
+   return ret;
}
 
ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
return 0;
-
-Err_out:
-   amdgpu_ttm_training_reserve_vram_fini(adev);
-   return ret;
 }
 
 /**
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training(V3)

2019-12-18 Thread Tianci Yin
From: "Tianci.Yin" 

The method of getting fb_loc changed from parsing VBIOS to
taking certain offset from top of VRAM

Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c  |  2 +-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 38 ++-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 13 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  7 
 drivers/gpu/drm/amd/include/atomfirmware.h| 14 ---
 7 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363b1d71..fa2cf8e7bc07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {
struct amdgpu_bo *reserved_bo;
void *va;
 
-   /* Offset on the top of VRAM, used as c2p write buffer.
+   /* GDDR6 training support flag.
*/
-   u64 mem_train_fb_loc;
bool mem_train_support;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 9ba80d828876..fdd52d86a4d7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -2022,7 +2022,7 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
if (adev->is_atom_fw) {
amdgpu_atomfirmware_scratch_regs_init(adev);
amdgpu_atomfirmware_allocate_fb_scratch(adev);
-   ret = amdgpu_atomfirmware_get_mem_train_fb_loc(adev);
+   ret = amdgpu_atomfirmware_get_mem_train_info(adev);
if (ret) {
DRM_ERROR("Failed to get mem train fb location.\n");
return ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index ff4eb96bdfb5..58f9d8c3a17a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -525,16 +525,12 @@ static int gddr6_mem_train_support(struct amdgpu_device 
*adev)
return ret;
 }
 
-int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
+int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev)
 {
struct atom_context *ctx = adev->mode_info.atom_context;
-   unsigned char *bios = ctx->bios;
-   struct vram_reserve_block *reserved_block;
-   int index, block_number;
+   int index;
uint8_t frev, crev;
uint16_t data_offset, size;
-   uint32_t start_address_in_kb;
-   uint64_t offset;
int ret;
 
adev->fw_vram_usage.mem_train_support = false;
@@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct 
amdgpu_device *adev)
return -EINVAL;
}
 
-   reserved_block = (struct vram_reserve_block *)
-   (bios + data_offset + sizeof(struct atom_common_table_header));
-   block_number = ((unsigned int)size - sizeof(struct 
atom_common_table_header))
-   / sizeof(struct vram_reserve_block);
-   reserved_block += (block_number > 0) ? block_number-1 : 0;
-   DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb 
drv.\n",
- block_number,
- le32_to_cpu(reserved_block->start_address_in_kb),
- le16_to_cpu(reserved_block->used_by_firmware_in_kb),
- le16_to_cpu(reserved_block->used_by_driver_in_kb));
-   if (reserved_block->used_by_firmware_in_kb > 0) {
-   start_address_in_kb = 
le32_to_cpu(reserved_block->start_address_in_kb);
-   offset = (uint64_t)start_address_in_kb * ONE_KiB;
-   if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
-   offset -= ONE_MiB;
-   }
-
-   offset &= ~(ONE_MiB - 1);
-   adev->fw_vram_usage.mem_train_fb_loc = offset;
-   adev->fw_vram_usage.mem_train_support = true;
-   DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);
-   ret = 0;
-   } else {
-   DRM_ERROR("used_by_firmware_in_kb is 0!\n");
-   ret = -EINVAL;
-   }
-
-   return ret;
+   adev->fw_vram_usage.mem_train_support = true;
+   return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
index f871af5ea6f3..434fe2fa0089 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
@@ -31,7 +31,7 @@ void amdgpu_atomfirmware_scratch_regs_init(struct 
amdgpu_device *adev);
 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
  

[PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training(V2)

2019-12-18 Thread Tianci Yin
From: "Tianci.Yin" 

The method of getting fb_loc changed from parsing VBIOS to
taking certain offset from top of VRAM

Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c  |  2 +-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 38 ++-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |  6 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  7 
 drivers/gpu/drm/amd/include/atomfirmware.h| 14 ---
 7 files changed, 19 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363b1d71..fa2cf8e7bc07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {
struct amdgpu_bo *reserved_bo;
void *va;
 
-   /* Offset on the top of VRAM, used as c2p write buffer.
+   /* GDDR6 training support flag.
*/
-   u64 mem_train_fb_loc;
bool mem_train_support;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 9ba80d828876..fdd52d86a4d7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -2022,7 +2022,7 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
if (adev->is_atom_fw) {
amdgpu_atomfirmware_scratch_regs_init(adev);
amdgpu_atomfirmware_allocate_fb_scratch(adev);
-   ret = amdgpu_atomfirmware_get_mem_train_fb_loc(adev);
+   ret = amdgpu_atomfirmware_get_mem_train_info(adev);
if (ret) {
DRM_ERROR("Failed to get mem train fb location.\n");
return ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index ff4eb96bdfb5..58f9d8c3a17a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -525,16 +525,12 @@ static int gddr6_mem_train_support(struct amdgpu_device 
*adev)
return ret;
 }
 
-int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
+int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev)
 {
struct atom_context *ctx = adev->mode_info.atom_context;
-   unsigned char *bios = ctx->bios;
-   struct vram_reserve_block *reserved_block;
-   int index, block_number;
+   int index;
uint8_t frev, crev;
uint16_t data_offset, size;
-   uint32_t start_address_in_kb;
-   uint64_t offset;
int ret;
 
adev->fw_vram_usage.mem_train_support = false;
@@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct 
amdgpu_device *adev)
return -EINVAL;
}
 
-   reserved_block = (struct vram_reserve_block *)
-   (bios + data_offset + sizeof(struct atom_common_table_header));
-   block_number = ((unsigned int)size - sizeof(struct 
atom_common_table_header))
-   / sizeof(struct vram_reserve_block);
-   reserved_block += (block_number > 0) ? block_number-1 : 0;
-   DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb 
drv.\n",
- block_number,
- le32_to_cpu(reserved_block->start_address_in_kb),
- le16_to_cpu(reserved_block->used_by_firmware_in_kb),
- le16_to_cpu(reserved_block->used_by_driver_in_kb));
-   if (reserved_block->used_by_firmware_in_kb > 0) {
-   start_address_in_kb = 
le32_to_cpu(reserved_block->start_address_in_kb);
-   offset = (uint64_t)start_address_in_kb * ONE_KiB;
-   if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
-   offset -= ONE_MiB;
-   }
-
-   offset &= ~(ONE_MiB - 1);
-   adev->fw_vram_usage.mem_train_fb_loc = offset;
-   adev->fw_vram_usage.mem_train_support = true;
-   DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);
-   ret = 0;
-   } else {
-   DRM_ERROR("used_by_firmware_in_kb is 0!\n");
-   ret = -EINVAL;
-   }
-
-   return ret;
+   adev->fw_vram_usage.mem_train_support = true;
+   return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
index f871af5ea6f3..434fe2fa0089 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
@@ -31,7 +31,7 @@ void amdgpu_atomfirmware_scratch_regs_init(struct 
amdgpu_device *adev);
 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
int *vram_width, int 

[PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation(V2)

2019-12-18 Thread Tianci Yin
From: "Tianci.Yin" 

IP discovery TMR(occupied the top VRAM with size DISCOVERY_TMR_SIZE)
has been reserved, and the p2c buffer is in the range of this TMR, so
the p2c buffer reservation is unnecessary.

Change-Id: Ib1f2f2b4a1f3869c03ffe22e2836cdbee17ba99f
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 5f8fd3e3535b..3265487b859f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -202,7 +202,6 @@ struct psp_memory_training_context {
 
/*vram offset of the p2c training data*/
u64 p2c_train_data_offset;
-   struct amdgpu_bo *p2c_bo;
 
/*vram offset of the c2p training data*/
u64 c2p_train_data_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ce5cb854bdb9..476ea4a4dc03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1681,9 +1681,6 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct 
amdgpu_device *adev)
amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
ctx->c2p_bo = NULL;
 
-   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
-   ctx->p2c_bo = NULL;
-
return 0;
 }
 
@@ -1718,17 +1715,6 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
  ctx->p2c_train_data_offset,
  ctx->c2p_train_data_offset);
 
-   ret = amdgpu_bo_create_kernel_at(adev,
-ctx->p2c_train_data_offset,
-ctx->train_data_size,
-AMDGPU_GEM_DOMAIN_VRAM,
->p2c_bo,
-NULL);
-   if (ret) {
-   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
-   goto Err_out;
-   }
-
ret = amdgpu_bo_create_kernel_at(adev,
 ctx->c2p_train_data_offset,
 ctx->train_data_size,
@@ -1737,15 +1723,12 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
 NULL);
if (ret) {
DRM_ERROR("alloc c2p_bo failed(%d)!\n", ret);
-   goto Err_out;
+   amdgpu_ttm_training_reserve_vram_fini(adev);
+   return ret;
}
 
ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
return 0;
-
-Err_out:
-   amdgpu_ttm_training_reserve_vram_fini(adev);
-   return ret;
 }
 
 /**
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training

2019-12-17 Thread Tianci Yin
From: "Tianci.Yin" 

The method of getting fb_loc changed from parsing VBIOS to
taking certain offset from top of VRAM

Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  3 +-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 36 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |  6 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  7 
 drivers/gpu/drm/amd/include/atomfirmware.h| 14 
 5 files changed, 16 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363b1d71..fa2cf8e7bc07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {
struct amdgpu_bo *reserved_bo;
void *va;
 
-   /* Offset on the top of VRAM, used as c2p write buffer.
+   /* GDDR6 training support flag.
*/
-   u64 mem_train_fb_loc;
bool mem_train_support;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index ff4eb96bdfb5..009cb0b03d13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -528,13 +528,9 @@ static int gddr6_mem_train_support(struct amdgpu_device 
*adev)
 int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
 {
struct atom_context *ctx = adev->mode_info.atom_context;
-   unsigned char *bios = ctx->bios;
-   struct vram_reserve_block *reserved_block;
-   int index, block_number;
+   int index;
uint8_t frev, crev;
uint16_t data_offset, size;
-   uint32_t start_address_in_kb;
-   uint64_t offset;
int ret;
 
adev->fw_vram_usage.mem_train_support = false;
@@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct 
amdgpu_device *adev)
return -EINVAL;
}
 
-   reserved_block = (struct vram_reserve_block *)
-   (bios + data_offset + sizeof(struct atom_common_table_header));
-   block_number = ((unsigned int)size - sizeof(struct 
atom_common_table_header))
-   / sizeof(struct vram_reserve_block);
-   reserved_block += (block_number > 0) ? block_number-1 : 0;
-   DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb 
drv.\n",
- block_number,
- le32_to_cpu(reserved_block->start_address_in_kb),
- le16_to_cpu(reserved_block->used_by_firmware_in_kb),
- le16_to_cpu(reserved_block->used_by_driver_in_kb));
-   if (reserved_block->used_by_firmware_in_kb > 0) {
-   start_address_in_kb = 
le32_to_cpu(reserved_block->start_address_in_kb);
-   offset = (uint64_t)start_address_in_kb * ONE_KiB;
-   if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
-   offset -= ONE_MiB;
-   }
-
-   offset &= ~(ONE_MiB - 1);
-   adev->fw_vram_usage.mem_train_fb_loc = offset;
-   adev->fw_vram_usage.mem_train_support = true;
-   DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);
-   ret = 0;
-   } else {
-   DRM_ERROR("used_by_firmware_in_kb is 0!\n");
-   ret = -EINVAL;
-   }
-
-   return ret;
+   adev->fw_vram_usage.mem_train_support = true;
+   return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 2ff63d0414c9..ce5cb854bdb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1705,7 +1705,11 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
return 0;
}
 
-   ctx->c2p_train_data_offset = adev->fw_vram_usage.mem_train_fb_loc;
+   ctx->c2p_train_data_offset = adev->gmc.mc_vram_size;
+   if ((ctx->c2p_train_data_offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
+   ctx->c2p_train_data_offset -= ONE_MiB;
+   }
+   ctx->c2p_train_data_offset &= ~(ONE_MiB - 1);
ctx->p2c_train_data_offset = (adev->gmc.mc_vram_size - 
GDDR6_MEM_TRAINING_OFFSET);
ctx->train_data_size = GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index f1ebd424510c..19eb3e8456c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -66,6 +66,13 @@ struct amdgpu_copy_mem {
unsigned long   offset;
 };
 
+/* Definitions for constance */
+enum amdgpu_internal_constants
+{
+   ONE_KiB = 0x400,
+   ONE_MiB = 0x10,
+};
+
 extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
 extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
 
diff --git 

[PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation(V2)

2019-12-17 Thread Tianci Yin
From: "Tianci.Yin" 

IP discovery TMR(occupied the top VRAM with size DISCOVERY_TMR_SIZE)
has been reserved, and the p2c buffer is in the range of this TMR, so
the p2c buffer reservation is unnecessary.

Change-Id: Ib1f2f2b4a1f3869c03ffe22e2836cdbee17ba99f
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 5f8fd3e3535b..3265487b859f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -202,7 +202,6 @@ struct psp_memory_training_context {
 
/*vram offset of the p2c training data*/
u64 p2c_train_data_offset;
-   struct amdgpu_bo *p2c_bo;
 
/*vram offset of the c2p training data*/
u64 c2p_train_data_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ce5cb854bdb9..476ea4a4dc03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1681,9 +1681,6 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct 
amdgpu_device *adev)
amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
ctx->c2p_bo = NULL;
 
-   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
-   ctx->p2c_bo = NULL;
-
return 0;
 }
 
@@ -1718,17 +1715,6 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
  ctx->p2c_train_data_offset,
  ctx->c2p_train_data_offset);
 
-   ret = amdgpu_bo_create_kernel_at(adev,
-ctx->p2c_train_data_offset,
-ctx->train_data_size,
-AMDGPU_GEM_DOMAIN_VRAM,
->p2c_bo,
-NULL);
-   if (ret) {
-   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
-   goto Err_out;
-   }
-
ret = amdgpu_bo_create_kernel_at(adev,
 ctx->c2p_train_data_offset,
 ctx->train_data_size,
@@ -1737,15 +1723,12 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
 NULL);
if (ret) {
DRM_ERROR("alloc c2p_bo failed(%d)!\n", ret);
-   goto Err_out;
+   amdgpu_ttm_training_reserve_vram_fini(adev);
+   return ret;
}
 
ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
return 0;
-
-Err_out:
-   amdgpu_ttm_training_reserve_vram_fini(adev);
-   return ret;
 }
 
 /**
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation

2019-12-17 Thread Tianci Yin
From: "Tianci.Yin" 

IP discovery TMR(occupied the top VRAM with size DISCOVERY_TMR_SIZE)
has been reserved, and the p2c buffer is in the range of this TMR, so
the p2c buffer reservation is unnecessary.

Change-Id: Ib1f2f2b4a1f3869c03ffe22e2836cdbee17ba99f
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 --
 2 files changed, 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 5f8fd3e3535b..3265487b859f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -202,7 +202,6 @@ struct psp_memory_training_context {
 
/*vram offset of the p2c training data*/
u64 p2c_train_data_offset;
-   struct amdgpu_bo *p2c_bo;
 
/*vram offset of the c2p training data*/
u64 c2p_train_data_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ce5cb854bdb9..6f0ad1d1d4d7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1681,9 +1681,6 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct 
amdgpu_device *adev)
amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
ctx->c2p_bo = NULL;
 
-   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
-   ctx->p2c_bo = NULL;
-
return 0;
 }
 
@@ -1718,17 +1715,6 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
  ctx->p2c_train_data_offset,
  ctx->c2p_train_data_offset);
 
-   ret = amdgpu_bo_create_kernel_at(adev,
-ctx->p2c_train_data_offset,
-ctx->train_data_size,
-AMDGPU_GEM_DOMAIN_VRAM,
->p2c_bo,
-NULL);
-   if (ret) {
-   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
-   goto Err_out;
-   }
-
ret = amdgpu_bo_create_kernel_at(adev,
 ctx->c2p_train_data_offset,
 ctx->train_data_size,
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training

2019-12-17 Thread Tianci Yin
From: "Tianci.Yin" 

The method of getting fb_loc changed from parsing VBIOS to
taking certain offset from top of VRAM

Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  3 +-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 36 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |  6 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  7 
 drivers/gpu/drm/amd/include/atomfirmware.h| 14 
 5 files changed, 16 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363b1d71..fa2cf8e7bc07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {
struct amdgpu_bo *reserved_bo;
void *va;
 
-   /* Offset on the top of VRAM, used as c2p write buffer.
+   /* GDDR6 training support flag.
*/
-   u64 mem_train_fb_loc;
bool mem_train_support;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index ff4eb96bdfb5..009cb0b03d13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -528,13 +528,9 @@ static int gddr6_mem_train_support(struct amdgpu_device 
*adev)
 int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
 {
struct atom_context *ctx = adev->mode_info.atom_context;
-   unsigned char *bios = ctx->bios;
-   struct vram_reserve_block *reserved_block;
-   int index, block_number;
+   int index;
uint8_t frev, crev;
uint16_t data_offset, size;
-   uint32_t start_address_in_kb;
-   uint64_t offset;
int ret;
 
adev->fw_vram_usage.mem_train_support = false;
@@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct 
amdgpu_device *adev)
return -EINVAL;
}
 
-   reserved_block = (struct vram_reserve_block *)
-   (bios + data_offset + sizeof(struct atom_common_table_header));
-   block_number = ((unsigned int)size - sizeof(struct 
atom_common_table_header))
-   / sizeof(struct vram_reserve_block);
-   reserved_block += (block_number > 0) ? block_number-1 : 0;
-   DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb 
drv.\n",
- block_number,
- le32_to_cpu(reserved_block->start_address_in_kb),
- le16_to_cpu(reserved_block->used_by_firmware_in_kb),
- le16_to_cpu(reserved_block->used_by_driver_in_kb));
-   if (reserved_block->used_by_firmware_in_kb > 0) {
-   start_address_in_kb = 
le32_to_cpu(reserved_block->start_address_in_kb);
-   offset = (uint64_t)start_address_in_kb * ONE_KiB;
-   if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
-   offset -= ONE_MiB;
-   }
-
-   offset &= ~(ONE_MiB - 1);
-   adev->fw_vram_usage.mem_train_fb_loc = offset;
-   adev->fw_vram_usage.mem_train_support = true;
-   DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);
-   ret = 0;
-   } else {
-   DRM_ERROR("used_by_firmware_in_kb is 0!\n");
-   ret = -EINVAL;
-   }
-
-   return ret;
+   adev->fw_vram_usage.mem_train_support = true;
+   return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 2ff63d0414c9..ce5cb854bdb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1705,7 +1705,11 @@ static int amdgpu_ttm_training_reserve_vram_init(struct 
amdgpu_device *adev)
return 0;
}
 
-   ctx->c2p_train_data_offset = adev->fw_vram_usage.mem_train_fb_loc;
+   ctx->c2p_train_data_offset = adev->gmc.mc_vram_size;
+   if ((ctx->c2p_train_data_offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
+   ctx->c2p_train_data_offset -= ONE_MiB;
+   }
+   ctx->c2p_train_data_offset &= ~(ONE_MiB - 1);
ctx->p2c_train_data_offset = (adev->gmc.mc_vram_size - 
GDDR6_MEM_TRAINING_OFFSET);
ctx->train_data_size = GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index f1ebd424510c..19eb3e8456c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -66,6 +66,13 @@ struct amdgpu_copy_mem {
unsigned long   offset;
 };
 
+/* Definitions for constance */
+enum amdgpu_internal_constants
+{
+   ONE_KiB = 0x400,
+   ONE_MiB = 0x10,
+};
+
 extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
 extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
 
diff --git 

[PATCH 1/2] drm/amdgpu/gfx10: update gfx golden settings

2019-12-11 Thread Tianci Yin
From: "Tianci.Yin" 

add registers: mmPA_SC_BINNER_TIMEOUT_COUNTER and mmPA_SC_ENHANCE_2

Change-Id: I23dabb0e706af0b5376f9749200832e894944eca
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index d1e0a07060bd..e5637a6efb05 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -114,8 +114,10 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CGTT_SCLK_CTRL, 0x1000, 
0x1100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CTRL2, 0x, 0x1402002f),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CTRL3, 0x9fff, 0x1188),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_TIMEOUT_COUNTER, 
0x, 0x0800),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fff, 0x0809),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0x0040, 
0x0444),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0x0800, 
0x0820),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070104),
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu/gfx10: update gfx golden settings for navi14

2019-12-11 Thread Tianci Yin
From: "Tianci.Yin" 

add registers: mmPA_SC_BINNER_TIMEOUT_COUNTER and mmPA_SC_ENHANCE_2

Change-Id: I1fc3fb481b2d9edc482a32497242a8be6cd6b8d7
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index e5637a6efb05..8cdef79de9d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -162,8 +162,10 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CGTT_SCLK_CTRL, 0x0fff, 
0x1100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CTRL2, 0x, 0x1402002f),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CTRL3, 0xbfff, 0x0188),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_TIMEOUT_COUNTER, 
0x, 0x0800),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fff, 0x0809),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0x0040, 
0x0444),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0x0800, 
0x0820),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070105),
-- 
2.17.1

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


[PATCH] drm/amdgpu/gfx10: update gfx golden settings for navi12

2019-12-10 Thread Tianci Yin
From: "Tianci.Yin" 

add registers: mmSPI_CONFIG_CNTL
update registers: mmDB_DEBUG4 and mmUTCL1_CTRL

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index db9b8bfb1c3c..557ebf317b5e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -185,7 +185,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_2[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG, 0x, 0x2000),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0x, 0x0420),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG3, 0x, 0x0200),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0x, 0x0480),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0x, 0x0490),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DFSM_TILES_IN_FLIGHT, 0x, 
0x003f),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_LAST_OF_BURST_CONFIG, 0x, 
0x03860204),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCR_GENERAL_CNTL, 0x1ff0, 
0x0500),
@@ -205,12 +205,13 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_2[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0x0820, 
0x0820),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070104),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ALU_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ARB_CONFIG, 0x0133, 0x0130),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfff7, 0x0103),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CNTL, 0xffdf80ff, 0x479c0010),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0x, 0x0080)
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0x, 0x00c0)
 };
 
 static const struct soc15_reg_golden golden_settings_gc_10_1_nv14[] =
-- 
2.17.1

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


[PATCH 1/2] drm/amdgpu/gfx10: update gfx golden settings

2019-12-10 Thread Tianci Yin
From: "Tianci.Yin" 

add registers: mmSPI_CONFIG_CNTL

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index ed630d37c32c..f3324fa4e194 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -114,6 +114,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0x0040, 
0x0444),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070104),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ALU_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ARB_CONFIG, 0x0100, 0x0130),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0x, 
0x),
-- 
2.17.1

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


[PATCH 2/2] drm/amdgpu/gfx10: update gfx golden settings for navi14

2019-12-10 Thread Tianci Yin
From: "Tianci.Yin" 

add registers: mmSPI_CONFIG_CNTL

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index f3324fa4e194..db9b8bfb1c3c 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -160,6 +160,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0x0040, 
0x0444),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0xff0f, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0x, 0x3101),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL, 0x001f, 
0x00070105),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ALU_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ARB_CONFIG, 0x0133, 0x0130),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0x, 
0x),
-- 
2.17.1

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


[PATCH 3/3] drm/amdgpu/gfx10: update gfx golden settings for navi12

2019-10-24 Thread Tianci Yin
From: "Tianci.Yin" 

update registers: mmCGTT_SPI_CLK_CTRL

Change-Id: I35fb25be1340d8c062e0e5bfff642009a00d52cf
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 22d0fade9c71..d126d66cb781 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -179,7 +179,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_2[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0x003e001f, 
0x003c0014),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0x8fff, 
0x8100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0x0fff, 
0x0100),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xff7f0fff, 
0xc100),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xff7f0fff, 
0x0d000100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xcfff, 
0x6100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x0fff, 
0x4100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0x8fff, 
0x8100),
-- 
2.17.1

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

[PATCH 1/3] drm/amdgpu/gfx10: update gfx golden settings

2019-10-24 Thread Tianci Yin
From: "Tianci.Yin" 

update registers: mmCGTT_SPI_CLK_CTRL

Change-Id: Ic64d532c61adfdeb681903f1133d9b353579ac55
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index ac43b1af69e3..11e863c4c40b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -93,7 +93,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1[] =
 {
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0x, 
0x00400014),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_CPF_CLK_CTRL, 0xfcff8fff, 
0xf8000100),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xc000, 
0xc100),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xcd00, 
0x0d000100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0x6ff0, 
0x6100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x4000, 
0x4100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0x8fff, 
0x8100),
-- 
2.17.1

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

[PATCH] drm/amdgpu/psp: add psp memory training implementation(v3)

2019-10-15 Thread Tianci Yin
From: "Tianci.Yin" 

add memory training implementation code to save resume time.

Change-Id: I625794a780b11d824ab57ef39cc33b872c6dc6c9
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |   9 ++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 161 
 3 files changed, 171 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 8704f93cabf2..c2b776fd82b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -151,6 +151,7 @@ extern uint amdgpu_sdma_phase_quantum;
 extern char *amdgpu_disable_cu;
 extern char *amdgpu_virtual_display;
 extern uint amdgpu_pp_feature_mask;
+extern uint amdgpu_force_long_training;
 extern int amdgpu_job_hang_limit;
 extern int amdgpu_lbpw;
 extern int amdgpu_compute_multipipe;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index da7cbee25c61..c7d086569acb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -127,6 +127,7 @@ char *amdgpu_disable_cu = NULL;
 char *amdgpu_virtual_display = NULL;
 /* OverDrive(bit 14) disabled by default*/
 uint amdgpu_pp_feature_mask = 0xbfff;
+uint amdgpu_force_long_training = 0;
 int amdgpu_job_hang_limit = 0;
 int amdgpu_lbpw = -1;
 int amdgpu_compute_multipipe = -1;
@@ -390,6 +391,14 @@ module_param_named(sched_hw_submission, 
amdgpu_sched_hw_submission, int, 0444);
 MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))");
 module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, uint, 0444);
 
+/**
+ * DOC: forcelongtraining (uint)
+ * Force long memory training in resume.
+ * The default is zero, indicates short training in resume.
+ */
+MODULE_PARM_DESC(forcelongtraining, "force memory long training");
+module_param_named(forcelongtraining, amdgpu_force_long_training, uint, 0444);
+
 /**
  * DOC: pcie_gen_cap (uint)
  * Override PCIE gen speed capabilities. See the CAIL flags in 
drivers/gpu/drm/amd/include/amd_pcie.h.
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 2ba0f68ced10..19339de0cf12 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -58,6 +58,8 @@ MODULE_FIRMWARE("amdgpu/arcturus_ta.bin");
 #define mmRLC_GPM_UCODE_DATA_NV10  0x5b62
 #define mmSDMA0_UCODE_ADDR_NV100x5880
 #define mmSDMA0_UCODE_DATA_NV100x5881
+/* memory training timeout define */
+#define MEM_TRAIN_SEND_MSG_TIMEOUT_US  300
 
 static int psp_v11_0_init_microcode(struct psp_context *psp)
 {
@@ -902,6 +904,162 @@ static int psp_v11_0_rlc_autoload_start(struct 
psp_context *psp)
return psp_rlc_autoload_start(psp);
 }
 
+static int psp_v11_0_memory_training_send_msg(struct psp_context *psp, int msg)
+{
+   int ret;
+   int i;
+   uint32_t data_32;
+   int max_wait;
+   struct amdgpu_device *adev = psp->adev;
+
+   data_32 = (psp->mem_train_ctx.c2p_train_data_offset >> 20);
+   WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36, data_32);
+   WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35, msg);
+
+   max_wait = MEM_TRAIN_SEND_MSG_TIMEOUT_US / adev->usec_timeout;
+   for (i = 0; i < max_wait; i++) {
+   ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, 
mmMP0_SMN_C2PMSG_35),
+  0x8000, 0x8000, false);
+   if (ret == 0)
+   break;
+   }
+   if (i < max_wait)
+   ret = 0;
+   else
+   ret = -ETIME;
+
+   DRM_DEBUG("%s training %s, cost %d * %dms.\n",
+ (msg == PSP_BL__DRAM_SHORT_TRAIN) ? "short" : "long",
+ (ret == 0) ? "succeed" : "failed",
+ i, adev->usec_timeout/1000);
+   return ret;
+}
+
+static void psp_v11_0_memory_training_fini(struct psp_context *psp)
+{
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
+   kfree(ctx->sys_cache);
+   ctx->sys_cache = NULL;
+}
+
+static int psp_v11_0_memory_training_init(struct psp_context *psp)
+{
+   int ret;
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   if (ctx->init != PSP_MEM_TRAIN_RESERVE_SUCCESS) {
+   DRM_DEBUG("memory training is not supported!\n");
+   return 0;
+   }
+
+   ctx->sys_cache = kzalloc(ctx->train_data_size, GFP_KERNEL);
+   if (ctx->sys_cache == NULL) {
+   DRM_ERROR("alloc mem_train_ctx.sys_cache failed!\n");
+   ret = -ENOMEM;
+   goto Err_out;
+   }
+
+   
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
+ ctx->train_data_size,
+ ctx->p2c_train_data_offset,
+ 

[PATCH 7/8] drm/amdgpu: reserve vram for memory training(v3)

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

memory training using specific fixed vram segment, reserve these
segments before anyone may allocate it.

Change-Id: I1436755813a565608a2857a683f535377620a637
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 95 +
 1 file changed, 95 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 2e85a5154f87..56782b3ed933 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1667,6 +1667,92 @@ static int amdgpu_ttm_fw_reserve_vram_init(struct 
amdgpu_device *adev)
  >fw_vram_usage.va);
 }
 
+/*
+ * Memoy training reservation functions
+ */
+
+/**
+ * amdgpu_ttm_training_reserve_vram_fini - free memory training reserved vram
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * free memory training reserved vram if it has been reserved.
+ */
+static int amdgpu_ttm_training_reserve_vram_fini(struct amdgpu_device *adev)
+{
+   struct psp_memory_training_context *ctx = >psp.mem_train_ctx;
+
+   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
+   if (ctx->c2p_bo) {
+   amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
+   ctx->c2p_bo = NULL;
+   }
+
+   if (ctx->p2c_bo) {
+   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
+   ctx->p2c_bo = NULL;
+   }
+
+   return 0;
+}
+
+/**
+ * amdgpu_ttm_training_reserve_vram_init - create bo vram reservation from 
memory training
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * create bo vram reservation from memory training.
+ */
+static int amdgpu_ttm_training_reserve_vram_init(struct amdgpu_device *adev)
+{
+   int ret;
+   struct psp_memory_training_context *ctx = >psp.mem_train_ctx;
+
+   memset(ctx, 0, sizeof(*ctx));
+   if (!adev->fw_vram_usage.mem_train_support) {
+   DRM_DEBUG("memory training does not support!\n");
+   return 0;
+   }
+
+   ctx->c2p_train_data_offset = adev->fw_vram_usage.mem_train_fb_loc;
+   ctx->p2c_train_data_offset = (adev->gmc.mc_vram_size - 
GDDR6_MEM_TRAINING_OFFSET);
+   ctx->train_data_size = GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;
+
+   
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
+ ctx->train_data_size,
+ ctx->p2c_train_data_offset,
+ ctx->c2p_train_data_offset);
+
+   ret = amdgpu_bo_create_kernel_at(adev,
+ctx->p2c_train_data_offset,
+ctx->train_data_size,
+AMDGPU_GEM_DOMAIN_VRAM,
+>p2c_bo,
+NULL);
+   if (ret) {
+   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
+   goto Err_out;
+   }
+
+   ret = amdgpu_bo_create_kernel_at(adev,
+ctx->c2p_train_data_offset,
+ctx->train_data_size,
+AMDGPU_GEM_DOMAIN_VRAM,
+>c2p_bo,
+NULL);
+   if (ret) {
+   DRM_ERROR("alloc c2p_bo failed(%d)!\n", ret);
+   goto Err_out;
+   }
+
+   ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
+   return 0;
+
+Err_out:
+   amdgpu_ttm_training_reserve_vram_fini(adev);
+   return ret;
+}
+
 /**
  * amdgpu_ttm_init - Init the memory management (ttm) as well as various
  * gtt/vram related fields.
@@ -1740,6 +1826,14 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
return r;
}
 
+   /*
+*The reserved vram for memory training must be pinned to the specified
+*place on the VRAM, so reserve it early.
+*/
+   r = amdgpu_ttm_training_reserve_vram_init(adev);
+   if (r)
+   return r;
+
/* allocate memory as required for VGA
 * This is used for VGA emulation and pre-OS scanout buffers to
 * avoid display artifacts while transitioning between pre-OS
@@ -1842,6 +1936,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
return;
 
amdgpu_ttm_debugfs_fini(adev);
+   amdgpu_ttm_training_reserve_vram_fini(adev);
amdgpu_ttm_fw_reserve_vram_fini(adev);
if (adev->mman.aper_base_kaddr)
iounmap(adev->mman.aper_base_kaddr);
-- 
2.17.1

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

[PATCH 8/8] drm/amdgpu/psp: add psp memory training implementation

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

add memory training implementation code to save resume time.

Change-Id: I625794a780b11d824ab57ef39cc33b872c6dc6c9
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |   9 ++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 159 
 3 files changed, 169 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 8704f93cabf2..c2b776fd82b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -151,6 +151,7 @@ extern uint amdgpu_sdma_phase_quantum;
 extern char *amdgpu_disable_cu;
 extern char *amdgpu_virtual_display;
 extern uint amdgpu_pp_feature_mask;
+extern uint amdgpu_force_long_training;
 extern int amdgpu_job_hang_limit;
 extern int amdgpu_lbpw;
 extern int amdgpu_compute_multipipe;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index da7cbee25c61..c7d086569acb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -127,6 +127,7 @@ char *amdgpu_disable_cu = NULL;
 char *amdgpu_virtual_display = NULL;
 /* OverDrive(bit 14) disabled by default*/
 uint amdgpu_pp_feature_mask = 0xbfff;
+uint amdgpu_force_long_training = 0;
 int amdgpu_job_hang_limit = 0;
 int amdgpu_lbpw = -1;
 int amdgpu_compute_multipipe = -1;
@@ -390,6 +391,14 @@ module_param_named(sched_hw_submission, 
amdgpu_sched_hw_submission, int, 0444);
 MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))");
 module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, uint, 0444);
 
+/**
+ * DOC: forcelongtraining (uint)
+ * Force long memory training in resume.
+ * The default is zero, indicates short training in resume.
+ */
+MODULE_PARM_DESC(forcelongtraining, "force memory long training");
+module_param_named(forcelongtraining, amdgpu_force_long_training, uint, 0444);
+
 /**
  * DOC: pcie_gen_cap (uint)
  * Override PCIE gen speed capabilities. See the CAIL flags in 
drivers/gpu/drm/amd/include/amd_pcie.h.
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 2ba0f68ced10..b7efaa3e913c 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -902,6 +902,162 @@ static int psp_v11_0_rlc_autoload_start(struct 
psp_context *psp)
return psp_rlc_autoload_start(psp);
 }
 
+static int psp_v11_0_memory_training_send_msg(struct psp_context *psp, int msg)
+{
+   int ret = 0;
+   int i = 0;
+   uint32_t data_32 = 0;
+   struct amdgpu_device *adev = psp->adev;
+
+   data_32 = (psp->mem_train_ctx.c2p_train_data_offset >> 20);
+   WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36, data_32);
+   WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35, msg);
+
+   /*max 5s*/
+   while (i < 50) {
+   ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, 
mmMP0_SMN_C2PMSG_35),
+  0x8000, 0x8000, false);
+   if (ret == 0)
+   break;
+   i++;
+   }
+   DRM_DEBUG("%s training %s, cost %d * %dms.\n",
+ (msg == PSP_BL__DRAM_SHORT_TRAIN) ? "short" : "long",
+ (ret == 0) ? "succeed" : "failed",
+ i, adev->usec_timeout/1000);
+   return ret;
+}
+
+static int psp_v11_0_memory_training_fini(struct psp_context *psp)
+{
+   int ret = 0;
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
+   if(ctx->sys_cache) {
+   kfree(ctx->sys_cache);
+   ctx->sys_cache = NULL;
+   }
+
+   return ret;
+}
+
+static int psp_v11_0_memory_training_init(struct psp_context *psp)
+{
+   int ret = 0;
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   if(ctx->init != PSP_MEM_TRAIN_RESERVE_SUCCESS) {
+   DRM_DEBUG("memory training does not support!\n");
+   return 0;
+   }
+
+   ctx->sys_cache = kzalloc(ctx->train_data_size, GFP_KERNEL);
+   if(ctx->sys_cache == NULL) {
+   DRM_ERROR("alloc mem_train_ctx.sys_cache failed(%d)!\n", ret);
+   ret = -ENOMEM;
+   goto Err_out;
+   }
+
+   
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
+ ctx->train_data_size,
+ ctx->p2c_train_data_offset,
+ ctx->c2p_train_data_offset);
+   ctx->init = PSP_MEM_TRAIN_INIT_SUCCESS;
+   return 0;
+
+Err_out:
+   psp_v11_0_memory_training_fini(psp);
+   return ret;
+}
+
+/*
+ * save and restore proces
+ */
+static int psp_v11_0_memory_training(struct psp_context *psp, uint32_t ops)
+{
+   int ret = 0;
+   uint32_t p2c_header[4];
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+   uint32_t 

[PATCH 5/8] drm/amdgpu/atomfirmware: add memory training related helper functions(v3)

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

parse firmware to get memory training capability and fb location.

Change-Id: I147c1d48e255e0191be4beb1ad6b637da607bf75
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |   8 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c  |   5 +
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 136 ++
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h  |   1 +
 4 files changed, 150 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 64a43b65a197..8704f93cabf2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -291,6 +291,9 @@ struct amdgpu_ip_block_version {
const struct amd_ip_funcs *funcs;
 };
 
+#define HW_REV(_Major, _Minor, _Rev) \
+   uint32_t) (_Major)) << 16) | ((uint32_t) (_Minor) << 8) | 
((uint32_t) (_Rev)))
+
 struct amdgpu_ip_block {
struct amdgpu_ip_block_status status;
const struct amdgpu_ip_block_version *version;
@@ -633,6 +636,11 @@ struct amdgpu_fw_vram_usage {
u64 size;
struct amdgpu_bo *reserved_bo;
void *va;
+
+   /* Offset on the top of VRAM, used as c2p write buffer.
+   */
+   u64 mem_train_fb_loc;
+   bool mem_train_support;
 };
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 1c9d40f97a9b..72232fccf61a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -2038,6 +2038,11 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
if (adev->is_atom_fw) {
amdgpu_atomfirmware_scratch_regs_init(adev);
amdgpu_atomfirmware_allocate_fb_scratch(adev);
+   ret = amdgpu_atomfirmware_get_mem_train_fb_loc(adev);
+   if (ret) {
+   DRM_ERROR("Failed to get mem train fb location.\n");
+   return ret;
+   }
} else {
amdgpu_atombios_scratch_regs_init(adev);
amdgpu_atombios_allocate_fb_scratch(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index 39fd8ae5a822..ff4eb96bdfb5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -27,6 +27,7 @@
 #include "amdgpu_atomfirmware.h"
 #include "atom.h"
 #include "atombios.h"
+#include "soc15_hw_ip.h"
 
 bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device 
*adev)
 {
@@ -462,3 +463,138 @@ int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device 
*adev)
}
return -EINVAL;
 }
+
+/*
+ * Check if VBIOS supports GDDR6 training data save/restore
+ */
+static bool gddr6_mem_train_vbios_support(struct amdgpu_device *adev)
+{
+   uint16_t data_offset;
+   int index;
+
+   index = 
get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
+   firmwareinfo);
+   if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, 
NULL,
+ NULL, NULL, _offset)) {
+   struct atom_firmware_info_v3_1 *firmware_info =
+   (struct atom_firmware_info_v3_1 
*)(adev->mode_info.atom_context->bios +
+  data_offset);
+
+   DRM_DEBUG("atom firmware capability:0x%08x.\n",
+ le32_to_cpu(firmware_info->firmware_capability));
+
+   if (le32_to_cpu(firmware_info->firmware_capability) &
+   ATOM_FIRMWARE_CAP_ENABLE_2STAGE_BIST_TRAINING)
+   return true;
+   }
+
+   return false;
+}
+
+static int gddr6_mem_train_support(struct amdgpu_device *adev)
+{
+   int ret;
+   uint32_t major, minor, revision, hw_v;
+
+   if (gddr6_mem_train_vbios_support(adev)) {
+   amdgpu_discovery_get_ip_version(adev, MP0_HWID, , , 
);
+   hw_v = HW_REV(major, minor, revision);
+   /*
+* treat 0 revision as a special case since register for MP0 
and MMHUB is missing
+* for some Navi10 A0, preventing driver from discovering the 
hwip information since
+* none of the functions will be initialized, it should not 
cause any problems
+*/
+   switch (hw_v) {
+   case HW_REV(11, 0, 0):
+   case HW_REV(11, 0, 5):
+   ret = 1;
+   break;
+   default:
+   DRM_ERROR("memory training vbios supports but psp 
hw(%08x)"
+ " doesn't support!\n", hw_v);
+   ret = -1;
+   break;
+   }
+   } else {
+   ret = 0;
+   hw_v = -1;
+   

[PATCH 2/8] drm/amdgpu: add a generic fb accessing helper function(v3)

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

add a generic helper function for accessing framebuffer via MMIO

Change-Id: I4baa0aa53c93a94c2eff98c6211a61f369239982
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 30 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 +---
 3 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 7fa8e438f679..64a43b65a197 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -992,6 +992,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 void amdgpu_device_fini(struct amdgpu_device *adev);
 int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev);
 
+void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
+  uint32_t *buf, size_t size, bool write);
 uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg,
uint32_t acc_flags);
 void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 598158e95ec1..13cc3aa52b8f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -154,6 +154,36 @@ bool amdgpu_device_is_px(struct drm_device *dev)
return false;
 }
 
+/**
+ * VRAM access helper functions.
+ *
+ * amdgpu_device_vram_access - read/write a buffer in vram
+ *
+ * @adev: amdgpu_device pointer
+ * @pos: offset of the buffer in vram
+ * @buf: virtual address of the buffer in system memory
+ * @size: read/write size, sizeof(@buf) must > @size
+ * @write: true - write to vram, otherwise - read from vram
+ */
+void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
+  uint32_t *buf, size_t size, bool write)
+{
+   uint64_t last;
+   unsigned long flags;
+
+   last = size - 4;
+   for (last += pos; pos <= last; pos += 4) {
+   spin_lock_irqsave(>mmio_idx_lock, flags);
+   WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)pos) | 0x8000);
+   WREG32_NO_KIQ(mmMM_INDEX_HI, pos >> 31);
+   if (write)
+   WREG32_NO_KIQ(mmMM_DATA, *buf++);
+   else
+   *buf++ = RREG32_NO_KIQ(mmMM_DATA);
+   spin_unlock_irqrestore(>mmio_idx_lock, flags);
+   }
+}
+
 /*
  * MMIO register access helper functions.
  */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index ddd8364102a2..f95092741c38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -134,20 +134,10 @@ static int hw_id_map[MAX_HWIP] = {
 
 static int amdgpu_discovery_read_binary(struct amdgpu_device *adev, uint8_t 
*binary)
 {
-   uint32_t *p = (uint32_t *)binary;
uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
uint64_t pos = vram_size - DISCOVERY_TMR_SIZE;
-   unsigned long flags;
-
-   while (pos < vram_size) {
-   spin_lock_irqsave(>mmio_idx_lock, flags);
-   WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)pos) | 0x8000);
-   WREG32_NO_KIQ(mmMM_INDEX_HI, pos >> 31);
-   *p++ = RREG32_NO_KIQ(mmMM_DATA);
-   spin_unlock_irqrestore(>mmio_idx_lock, flags);
-   pos += 4;
-   }
 
+   amdgpu_device_vram_access(adev, pos, (uint32_t *)binary, 
DISCOVERY_TMR_SIZE, false);
return 0;
 }
 
-- 
2.17.1

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

[PATCH 6/8] drm/amdgpu: add psp memory training callbacks and macro

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

add interface for memory training.

Change-Id: Ibb6d1d24eb651df796bc2bb3419a44937af60242
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 18 
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 55 +
 2 files changed, 73 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 37ffed5e2171..b996b5bc5804 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -88,6 +88,17 @@ static int psp_sw_init(void *handle)
return ret;
}
 
+   ret = psp_mem_training_init(psp);
+   if (ret) {
+   DRM_ERROR("Failed to initliaze memory training!\n");
+   return ret;
+   }
+   ret = psp_mem_training(psp, PSP_MEM_TRAIN_COLD_BOOT);
+   if (ret) {
+   DRM_ERROR("Failed to process memory training!\n");
+   return ret;
+   }
+
return 0;
 }
 
@@ -95,6 +106,7 @@ static int psp_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+   psp_mem_training_fini(>psp);
release_firmware(adev->psp.sos_fw);
adev->psp.sos_fw = NULL;
release_firmware(adev->psp.asd_fw);
@@ -1608,6 +1620,12 @@ static int psp_resume(void *handle)
 
DRM_INFO("PSP is resuming...\n");
 
+   ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);
+   if (ret) {
+   DRM_ERROR("Failed to process memory training!\n");
+   return ret;
+   }
+
mutex_lock(>firmware.mutex);
 
ret = psp_hw_start(psp);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 7dd9ae7dbbe4..c6f17d6310d6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -49,6 +49,8 @@ enum psp_bootloader_cmd {
PSP_BL__LOAD_SYSDRV = 0x1,
PSP_BL__LOAD_SOSDRV = 0x2,
PSP_BL__LOAD_KEY_DATABASE   = 0x8,
+   PSP_BL__DRAM_LONG_TRAIN = 0x10,
+   PSP_BL__DRAM_SHORT_TRAIN= 0x20,
 };
 
 enum psp_ring_type
@@ -111,6 +113,9 @@ struct psp_funcs
struct ta_ras_trigger_error_input *info);
int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr);
int (*rlc_autoload_start)(struct psp_context *psp);
+   int (*mem_training_init)(struct psp_context *psp);
+   int (*mem_training_fini)(struct psp_context *psp);
+   int (*mem_training)(struct psp_context *psp, uint32_t ops);
 };
 
 #define AMDGPU_XGMI_MAX_CONNECTED_NODES64
@@ -161,6 +166,49 @@ struct psp_dtm_context {
void*dtm_shared_buf;
 };
 
+#define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942
+#define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES  0x1000
+#define GDDR6_MEM_TRAINING_OFFSET  0x8000
+
+enum psp_memory_training_init_flag {
+   PSP_MEM_TRAIN_NOT_SUPPORT   = 0x0,
+   PSP_MEM_TRAIN_SUPPORT   = 0x1,
+   PSP_MEM_TRAIN_INIT_FAILED   = 0x2,
+   PSP_MEM_TRAIN_RESERVE_SUCCESS   = 0x4,
+   PSP_MEM_TRAIN_INIT_SUCCESS  = 0x8,
+};
+
+enum psp_memory_training_ops {
+   PSP_MEM_TRAIN_SEND_LONG_MSG = 0x1,
+   PSP_MEM_TRAIN_SAVE  = 0x2,
+   PSP_MEM_TRAIN_RESTORE   = 0x4,
+   PSP_MEM_TRAIN_SEND_SHORT_MSG= 0x8,
+   PSP_MEM_TRAIN_COLD_BOOT = PSP_MEM_TRAIN_SEND_LONG_MSG,
+   PSP_MEM_TRAIN_RESUME= PSP_MEM_TRAIN_SEND_SHORT_MSG,
+};
+
+struct psp_memory_training_context {
+   /*training data size*/
+   u64 train_data_size;
+   /*
+* sys_cache
+* cpu virtual address
+* system memory buffer that used to store the training data.
+*/
+   void *sys_cache;
+
+   /*vram offset of the p2c training data*/
+   u64 p2c_train_data_offset;
+   struct amdgpu_bo *p2c_bo;
+
+   /*vram offset of the c2p training data*/
+   u64 c2p_train_data_offset;
+   struct amdgpu_bo *c2p_bo;
+
+   enum psp_memory_training_init_flag init;
+   u32 training_cnt;
+};
+
 struct psp_context
 {
struct amdgpu_device*adev;
@@ -239,6 +287,7 @@ struct psp_context
struct psp_hdcp_context hdcp_context;
struct psp_dtm_context  dtm_context;
struct mutexmutex;
+   struct psp_memory_training_context mem_train_ctx;
 };
 
 struct amdgpu_psp_funcs {
@@ -281,6 +330,12 @@ struct amdgpu_psp_funcs {
(psp)->funcs->xgmi_set_topology_info((psp), (num_device), 
(topology)) : -EINVAL)
 #define psp_rlc_autoload(psp) \
((psp)->funcs->rlc_autoload_start ? 
(psp)->funcs->rlc_autoload_start((psp)) : 0)
+#define psp_mem_training_init(psp) \
+   ((psp)->funcs->mem_training_init ? 
(psp)->funcs->mem_training_init((psp)) : 0)

[PATCH 4/8] drm/amdgpu: update atomfirmware header with memory training related members(v3)

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

add new vram_reserve_block structure and atomfirmware_internal_constants 
enumeration

Change-Id: I6ba642ecd7ad94250162ae5c322ed8d85de9c35a
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/include/atomfirmware.h | 27 +-
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h 
b/drivers/gpu/drm/amd/include/atomfirmware.h
index e88541d67aa0..dd7cbc00a0aa 100644
--- a/drivers/gpu/drm/amd/include/atomfirmware.h
+++ b/drivers/gpu/drm/amd/include/atomfirmware.h
@@ -492,12 +492,13 @@ struct atom_firmware_info_v3_1
 /* Total 32bit cap indication */
 enum atombios_firmware_capability
 {
-  ATOM_FIRMWARE_CAP_FIRMWARE_POSTED = 0x0001,
-  ATOM_FIRMWARE_CAP_GPU_VIRTUALIZATION  = 0x0002,
-  ATOM_FIRMWARE_CAP_WMI_SUPPORT  = 0x0040,
-  ATOM_FIRMWARE_CAP_HWEMU_ENABLE  = 0x0080,
-  ATOM_FIRMWARE_CAP_HWEMU_UMC_CFG = 0x0100,
-  ATOM_FIRMWARE_CAP_SRAM_ECC  = 0x0200,
+   ATOM_FIRMWARE_CAP_FIRMWARE_POSTED = 0x0001,
+   ATOM_FIRMWARE_CAP_GPU_VIRTUALIZATION  = 0x0002,
+   ATOM_FIRMWARE_CAP_WMI_SUPPORT  = 0x0040,
+   ATOM_FIRMWARE_CAP_HWEMU_ENABLE  = 0x0080,
+   ATOM_FIRMWARE_CAP_HWEMU_UMC_CFG = 0x0100,
+   ATOM_FIRMWARE_CAP_SRAM_ECC  = 0x0200,
+   ATOM_FIRMWARE_CAP_ENABLE_2STAGE_BIST_TRAINING  = 0x0400,
 };
 
 enum atom_cooling_solution_id{
@@ -671,6 +672,20 @@ struct vram_usagebyfirmware_v2_1
   uint16_t  used_by_driver_in_kb; 
 };
 
+/* This is part of vram_usagebyfirmware_v2_1 */
+struct vram_reserve_block
+{
+   uint32_t start_address_in_kb;
+   uint16_t used_by_firmware_in_kb;
+   uint16_t used_by_driver_in_kb;
+};
+
+/* Definitions for constance */
+enum atomfirmware_internal_constants
+{
+   ONE_KiB = 0x400,
+   ONE_MiB = 0x10,
+};
 
 /* 
   ***
-- 
2.17.1

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

[PATCH 1/8] drm/amdgpu: update amdgpu_discovery to handle revision

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

update amdgpu_discovery to get IP revision.

Change-Id: If8152103d03b58e1dc0f32db63625e290f5f08a0
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 71198c5318e1..ddd8364102a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -333,7 +333,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device 
*adev)
 }
 
 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
-   int *major, int *minor)
+   int *major, int *minor, int *revision)
 {
struct binary_header *bhdr;
struct ip_discovery_header *ihdr;
@@ -369,6 +369,8 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device 
*adev, int hw_id,
*major = ip->major;
if (minor)
*minor = ip->minor;
+   if (revision)
+   *revision = ip->revision;
return 0;
}
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 
1);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
index 5a6693d7d269..ba78e15d9b05 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
@@ -30,7 +30,7 @@ int amdgpu_discovery_init(struct amdgpu_device *adev);
 void amdgpu_discovery_fini(struct amdgpu_device *adev);
 int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev);
 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
-int *major, int *minor);
+int *major, int *minor, int *revision);
 int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev);
 
 #endif /* __AMDGPU_DISCOVERY__ */
-- 
2.17.1

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

[PATCH 3/8] drm/amdgpu: introduce psp_v11_0_is_sos_alive interface(v2)

2019-10-13 Thread Tianci Yin
From: "Tianci.Yin" 

introduce psp_v11_0_is_sos_alive func for common use.

Change-Id: Iee0a6dd924d6a4b164eb751c0bec49fcb7d79483
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 04318cfd50a8..2ba0f68ced10 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -206,18 +206,26 @@ static int psp_v11_0_init_microcode(struct psp_context 
*psp)
return err;
 }
 
+static bool psp_v11_0_is_sos_alive(struct psp_context *psp)
+{
+   struct amdgpu_device *adev = psp->adev;
+   uint32_t sol_reg;
+
+   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
+
+   return sol_reg != 0x0;
+}
+
 static int psp_v11_0_bootloader_load_kdb(struct psp_context *psp)
 {
int ret;
uint32_t psp_gfxdrv_command_reg = 0;
struct amdgpu_device *adev = psp->adev;
-   uint32_t sol_reg;
 
/* Check tOS sign of life register to confirm sys driver and sOS
 * are already been loaded.
 */
-   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-   if (sol_reg) {
+   if (psp_v11_0_is_sos_alive(psp)) {
psp->sos_fw_version = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_58);
dev_info(adev->dev, "sos fw version = 0x%x.\n", 
psp->sos_fw_version);
return 0;
@@ -253,13 +261,11 @@ static int psp_v11_0_bootloader_load_sysdrv(struct 
psp_context *psp)
int ret;
uint32_t psp_gfxdrv_command_reg = 0;
struct amdgpu_device *adev = psp->adev;
-   uint32_t sol_reg;
 
/* Check sOS sign of life register to confirm sys driver and sOS
 * are already been loaded.
 */
-   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-   if (sol_reg) {
+   if (psp_v11_0_is_sos_alive(psp)) {
psp->sos_fw_version = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_58);
dev_info(adev->dev, "sos fw version = 0x%x.\n", 
psp->sos_fw_version);
return 0;
@@ -297,13 +303,11 @@ static int psp_v11_0_bootloader_load_sos(struct 
psp_context *psp)
int ret;
unsigned int psp_gfxdrv_command_reg = 0;
struct amdgpu_device *adev = psp->adev;
-   uint32_t sol_reg;
 
/* Check sOS sign of life register to confirm sys driver and sOS
 * are already been loaded.
 */
-   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-   if (sol_reg)
+   if (psp_v11_0_is_sos_alive(psp))
return 0;
 
/* Wait for bootloader to signify that is ready having bit 31 of 
C2PMSG_35 set to 1 */
-- 
2.17.1

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

[PATCH 8/8] drm/amdgpu/psp: add psp memory training implementation

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

add memory training implementation code to save resume time.

Change-Id: I625794a780b11d824ab57ef39cc33b872c6dc6c9
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |   9 ++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 171 
 3 files changed, 181 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index e3d715c31ac9..03c5c18bb51e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -151,6 +151,7 @@ extern uint amdgpu_sdma_phase_quantum;
 extern char *amdgpu_disable_cu;
 extern char *amdgpu_virtual_display;
 extern uint amdgpu_pp_feature_mask;
+extern uint amdgpu_force_long_training;
 extern int amdgpu_job_hang_limit;
 extern int amdgpu_lbpw;
 extern int amdgpu_compute_multipipe;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 5985bd79216d..f03dcc5d185d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -127,6 +127,7 @@ char *amdgpu_disable_cu = NULL;
 char *amdgpu_virtual_display = NULL;
 /* OverDrive(bit 14) disabled by default*/
 uint amdgpu_pp_feature_mask = 0xbfff;
+uint amdgpu_force_long_training = 0;
 int amdgpu_job_hang_limit = 0;
 int amdgpu_lbpw = -1;
 int amdgpu_compute_multipipe = -1;
@@ -390,6 +391,14 @@ module_param_named(sched_hw_submission, 
amdgpu_sched_hw_submission, int, 0444);
 MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))");
 module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, uint, 0444);
 
+/**
+ * DOC: forcelongtraining (uint)
+ * Force long memory training in resume.
+ * The default is zero, indicates short training in resume.
+ */
+MODULE_PARM_DESC(forcelongtraining, "force memory long training");
+module_param_named(forcelongtraining, amdgpu_force_long_training, uint, 0444);
+
 /**
  * DOC: pcie_gen_cap (uint)
  * Override PCIE gen speed capabilities. See the CAIL flags in 
drivers/gpu/drm/amd/include/amd_pcie.h.
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 2ba0f68ced10..074f23c846cb 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -902,6 +902,174 @@ static int psp_v11_0_rlc_autoload_start(struct 
psp_context *psp)
return psp_rlc_autoload_start(psp);
 }
 
+static int psp_v11_0_memory_training_send_msg(struct psp_context *psp, int msg)
+{
+   int ret = 0;
+   int i = 0;
+   uint32_t data_32 = 0;
+   struct amdgpu_device *adev = psp->adev;
+
+   data_32 = (psp->mem_train_ctx.c2p_train_data_offset >> 20);
+   WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36, data_32);
+   WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35, msg);
+
+   /*max 5s*/
+   while (i < 50) {
+   ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, 
mmMP0_SMN_C2PMSG_35),
+  0x8000, 0x8000, false);
+   if (ret == 0)
+   break;
+   i++;
+   }
+   DRM_DEBUG("%s training %s, cost %d * %dms.\n",
+ (msg == PSP_BL__DRAM_SHORT_TRAIN) ? "short" : "long",
+ (ret == 0) ? "succeed" : "failed",
+ i, adev->usec_timeout/1000);
+   return ret;
+}
+
+static int psp_v11_0_memory_training_fini(struct psp_context *psp)
+{
+   int ret = 0;
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
+   if(ctx->sys_cache) {
+   kfree(ctx->sys_cache);
+   ctx->sys_cache = NULL;
+   }
+
+   return ret;
+}
+
+static int psp_v11_0_memory_training_init(struct psp_context *psp)
+{
+   int ret = 0;
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   if(ctx->init != PSP_MEM_TRAIN_RESERVE_SUCCESS) {
+   DRM_DEBUG("memory training does not support!\n");
+   return 0;
+   }
+
+   ctx->sys_cache = kzalloc(ctx->train_data_size, GFP_KERNEL);
+   if(ctx->sys_cache == NULL) {
+   DRM_ERROR("alloc mem_train_ctx.sys_cache failed(%d)!\n", ret);
+   ret = -ENOMEM;
+   goto err_out;
+   }
+
+   
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
+ ctx->train_data_size,
+ ctx->p2c_train_data_offset,
+ ctx->c2p_train_data_offset);
+   ctx->init = PSP_MEM_TRAIN_INIT_SUCCESS;
+   return 0;
+
+err_out:
+   psp_v11_0_memory_training_fini(psp);
+   return ret;
+}
+
+/*
+ * save and restore proces
+ */
+static int psp_v11_0_memory_training(struct psp_context *psp, uint32_t ops)
+{
+   int ret = 0;
+   uint32_t p2c_header[4];
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+   uint32_t 

[PATCH 6/8] drm/amdgpu: add psp memory training callbacks and macro

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

add interface for memory training.

Change-Id: Ibb6d1d24eb651df796bc2bb3419a44937af60242
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 18 
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 55 +
 2 files changed, 73 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 37ffed5e2171..b996b5bc5804 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -88,6 +88,17 @@ static int psp_sw_init(void *handle)
return ret;
}
 
+   ret = psp_mem_training_init(psp);
+   if (ret) {
+   DRM_ERROR("Failed to initliaze memory training!\n");
+   return ret;
+   }
+   ret = psp_mem_training(psp, PSP_MEM_TRAIN_COLD_BOOT);
+   if (ret) {
+   DRM_ERROR("Failed to process memory training!\n");
+   return ret;
+   }
+
return 0;
 }
 
@@ -95,6 +106,7 @@ static int psp_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+   psp_mem_training_fini(>psp);
release_firmware(adev->psp.sos_fw);
adev->psp.sos_fw = NULL;
release_firmware(adev->psp.asd_fw);
@@ -1608,6 +1620,12 @@ static int psp_resume(void *handle)
 
DRM_INFO("PSP is resuming...\n");
 
+   ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);
+   if (ret) {
+   DRM_ERROR("Failed to process memory training!\n");
+   return ret;
+   }
+
mutex_lock(>firmware.mutex);
 
ret = psp_hw_start(psp);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 7dd9ae7dbbe4..c6f17d6310d6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -49,6 +49,8 @@ enum psp_bootloader_cmd {
PSP_BL__LOAD_SYSDRV = 0x1,
PSP_BL__LOAD_SOSDRV = 0x2,
PSP_BL__LOAD_KEY_DATABASE   = 0x8,
+   PSP_BL__DRAM_LONG_TRAIN = 0x10,
+   PSP_BL__DRAM_SHORT_TRAIN= 0x20,
 };
 
 enum psp_ring_type
@@ -111,6 +113,9 @@ struct psp_funcs
struct ta_ras_trigger_error_input *info);
int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr);
int (*rlc_autoload_start)(struct psp_context *psp);
+   int (*mem_training_init)(struct psp_context *psp);
+   int (*mem_training_fini)(struct psp_context *psp);
+   int (*mem_training)(struct psp_context *psp, uint32_t ops);
 };
 
 #define AMDGPU_XGMI_MAX_CONNECTED_NODES64
@@ -161,6 +166,49 @@ struct psp_dtm_context {
void*dtm_shared_buf;
 };
 
+#define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942
+#define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES  0x1000
+#define GDDR6_MEM_TRAINING_OFFSET  0x8000
+
+enum psp_memory_training_init_flag {
+   PSP_MEM_TRAIN_NOT_SUPPORT   = 0x0,
+   PSP_MEM_TRAIN_SUPPORT   = 0x1,
+   PSP_MEM_TRAIN_INIT_FAILED   = 0x2,
+   PSP_MEM_TRAIN_RESERVE_SUCCESS   = 0x4,
+   PSP_MEM_TRAIN_INIT_SUCCESS  = 0x8,
+};
+
+enum psp_memory_training_ops {
+   PSP_MEM_TRAIN_SEND_LONG_MSG = 0x1,
+   PSP_MEM_TRAIN_SAVE  = 0x2,
+   PSP_MEM_TRAIN_RESTORE   = 0x4,
+   PSP_MEM_TRAIN_SEND_SHORT_MSG= 0x8,
+   PSP_MEM_TRAIN_COLD_BOOT = PSP_MEM_TRAIN_SEND_LONG_MSG,
+   PSP_MEM_TRAIN_RESUME= PSP_MEM_TRAIN_SEND_SHORT_MSG,
+};
+
+struct psp_memory_training_context {
+   /*training data size*/
+   u64 train_data_size;
+   /*
+* sys_cache
+* cpu virtual address
+* system memory buffer that used to store the training data.
+*/
+   void *sys_cache;
+
+   /*vram offset of the p2c training data*/
+   u64 p2c_train_data_offset;
+   struct amdgpu_bo *p2c_bo;
+
+   /*vram offset of the c2p training data*/
+   u64 c2p_train_data_offset;
+   struct amdgpu_bo *c2p_bo;
+
+   enum psp_memory_training_init_flag init;
+   u32 training_cnt;
+};
+
 struct psp_context
 {
struct amdgpu_device*adev;
@@ -239,6 +287,7 @@ struct psp_context
struct psp_hdcp_context hdcp_context;
struct psp_dtm_context  dtm_context;
struct mutexmutex;
+   struct psp_memory_training_context mem_train_ctx;
 };
 
 struct amdgpu_psp_funcs {
@@ -281,6 +330,12 @@ struct amdgpu_psp_funcs {
(psp)->funcs->xgmi_set_topology_info((psp), (num_device), 
(topology)) : -EINVAL)
 #define psp_rlc_autoload(psp) \
((psp)->funcs->rlc_autoload_start ? 
(psp)->funcs->rlc_autoload_start((psp)) : 0)
+#define psp_mem_training_init(psp) \
+   ((psp)->funcs->mem_training_init ? 
(psp)->funcs->mem_training_init((psp)) : 0)

[PATCH 7/8] drm/amdgpu: reserve vram for memory training

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

memory training using specific fixed vram segment, reserve these
segments before anyone may allocate it.

Change-Id: I1436755813a565608a2857a683f535377620a637
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 96 +
 1 file changed, 96 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 9da6350a4ba2..42d0fcb98382 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1667,6 +1667,93 @@ static int amdgpu_ttm_fw_reserve_vram_init(struct 
amdgpu_device *adev)
  >fw_vram_usage.va);
 }
 
+/*
+ * Memoy training reservation functions
+ */
+
+/**
+ * amdgpu_ttm_training_reserve_vram_fini - free memory training reserved vram
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * free memory training reserved vram if it has been reserved.
+ */
+static int amdgpu_ttm_training_reserve_vram_fini(struct amdgpu_device *adev)
+{
+   struct psp_memory_training_context *ctx = >psp.mem_train_ctx;
+
+   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
+   if (ctx->c2p_bo) {
+   amdgpu_bo_free_kernel(>c2p_bo, NULL, NULL);
+   ctx->c2p_bo = NULL;
+   }
+   if (ctx->p2c_bo) {
+   amdgpu_bo_free_kernel(>p2c_bo, NULL, NULL);
+   ctx->p2c_bo = NULL;
+   }
+
+   return 0;
+}
+
+/**
+ * amdgpu_ttm_training_reserve_vram_init - create bo vram reservation from 
memory training
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * create bo vram reservation from memory training.
+ */
+static int amdgpu_ttm_training_reserve_vram_init(struct amdgpu_device *adev)
+{
+   int ret;
+   struct psp_memory_training_context *ctx = >psp.mem_train_ctx;
+
+   memset(ctx, 0, sizeof(*ctx));
+   if (!adev->fw_vram_usage.mem_train_support) {
+   DRM_DEBUG("memory training does not support!\n");
+   return 0;
+   }
+
+   ctx->c2p_train_data_offset = adev->fw_vram_usage.mem_train_fb_loc;
+   ctx->p2c_train_data_offset = (adev->gmc.mc_vram_size - 
GDDR6_MEM_TRAINING_OFFSET);
+   ctx->train_data_size = GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;
+
+   
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
+ ctx->train_data_size,
+ ctx->p2c_train_data_offset,
+ ctx->c2p_train_data_offset);
+
+   ret = amdgpu_bo_create_kernel_at(adev,
+ctx->p2c_train_data_offset,
+ctx->train_data_size,
+AMDGPU_GEM_DOMAIN_VRAM,
+>p2c_bo,
+NULL);
+   if (ret) {
+   DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);
+   ret = -ENOMEM;
+   goto err_out;
+   }
+
+   ret = amdgpu_bo_create_kernel_at(adev,
+ctx->c2p_train_data_offset,
+ctx->train_data_size,
+AMDGPU_GEM_DOMAIN_VRAM,
+>c2p_bo,
+NULL);
+   if (ret) {
+   DRM_ERROR("alloc c2p_bo failed(%d)!\n", ret);
+   ret = -ENOMEM;
+   goto err_out;
+   }
+
+   ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
+   return 0;
+
+err_out:
+   amdgpu_ttm_training_reserve_vram_fini(adev);
+   return ret;
+}
+
 /**
  * amdgpu_ttm_init - Init the memory management (ttm) as well as various
  * gtt/vram related fields.
@@ -1740,6 +1827,14 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
return r;
}
 
+   /*
+*The reserved vram for memory training must be pinned to the specified
+*place on the VRAM, so reserve it early.
+*/
+   r = amdgpu_ttm_training_reserve_vram_init(adev);
+   if (r)
+   return r;
+
/* allocate memory as required for VGA
 * This is used for VGA emulation and pre-OS scanout buffers to
 * avoid display artifacts while transitioning between pre-OS
@@ -1825,6 +1920,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
return;
 
amdgpu_ttm_debugfs_fini(adev);
+   amdgpu_ttm_training_reserve_vram_fini(adev);
amdgpu_ttm_fw_reserve_vram_fini(adev);
if (adev->mman.aper_base_kaddr)
iounmap(adev->mman.aper_base_kaddr);
-- 
2.17.1

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

[PATCH 4/8] drm/amdgpu: update atomfirmware header with memory training related members

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

add new vram_reserve_block structure and atomfirmware_internal_constants 
enumeration

Change-Id: I6ba642ecd7ad94250162ae5c322ed8d85de9c35a
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/include/atomfirmware.h | 28 +-
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h 
b/drivers/gpu/drm/amd/include/atomfirmware.h
index e88541d67aa0..463c18e99d78 100644
--- a/drivers/gpu/drm/amd/include/atomfirmware.h
+++ b/drivers/gpu/drm/amd/include/atomfirmware.h
@@ -492,12 +492,13 @@ struct atom_firmware_info_v3_1
 /* Total 32bit cap indication */
 enum atombios_firmware_capability
 {
-  ATOM_FIRMWARE_CAP_FIRMWARE_POSTED = 0x0001,
-  ATOM_FIRMWARE_CAP_GPU_VIRTUALIZATION  = 0x0002,
-  ATOM_FIRMWARE_CAP_WMI_SUPPORT  = 0x0040,
-  ATOM_FIRMWARE_CAP_HWEMU_ENABLE  = 0x0080,
-  ATOM_FIRMWARE_CAP_HWEMU_UMC_CFG = 0x0100,
-  ATOM_FIRMWARE_CAP_SRAM_ECC  = 0x0200,
+   ATOM_FIRMWARE_CAP_FIRMWARE_POSTED = 0x0001,
+   ATOM_FIRMWARE_CAP_GPU_VIRTUALIZATION  = 0x0002,
+   ATOM_FIRMWARE_CAP_WMI_SUPPORT  = 0x0040,
+   ATOM_FIRMWARE_CAP_HWEMU_ENABLE  = 0x0080,
+   ATOM_FIRMWARE_CAP_HWEMU_UMC_CFG = 0x0100,
+   ATOM_FIRMWARE_CAP_SRAM_ECC  = 0x0200,
+   ATOM_FIRMWARE_CAP_ENABLE_2STAGE_BIST_TRAINING  = 0x0400,
 };
 
 enum atom_cooling_solution_id{
@@ -671,6 +672,21 @@ struct vram_usagebyfirmware_v2_1
   uint16_t  used_by_driver_in_kb; 
 };
 
+/* This is part of vram_usagebyfirmware_v2_1 */
+struct vram_reserve_block
+{
+   uint32_t start_address_in_kb;
+   uint16_t used_by_firmware_in_kb;
+   uint16_t used_by_driver_in_kb;
+};
+
+/* Definitions for constance */
+enum atomfirmware_internal_constants
+{
+   ONE_K   = 0x400,
+   ONE_MEG = 0x10,
+   ONE_G   = 0x4000,
+};
 
 /* 
   ***
-- 
2.17.1

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

[PATCH 5/8] drm/amdgpu/atomfirmware: add memory training related helper functions

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

parse firmware to get memory training capability and fb location.

Change-Id: I147c1d48e255e0191be4beb1ad6b637da607bf75
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |   7 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c  |   5 +
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 133 ++
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h  |   1 +
 4 files changed, 146 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 1102e6bae5d5..e3d715c31ac9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -291,6 +291,9 @@ struct amdgpu_ip_block_version {
const struct amd_ip_funcs *funcs;
 };
 
+#define hw_revision(major, minor, revision) \
+   uint32_t) major) << 16) | ((uint32_t) minor << 8) | ((uint32_t) 
revision))
+
 struct amdgpu_ip_block {
struct amdgpu_ip_block_status status;
const struct amdgpu_ip_block_version *version;
@@ -633,6 +636,10 @@ struct amdgpu_fw_vram_usage {
u64 size;
struct amdgpu_bo *reserved_bo;
void *va;
+
+   /*offset on the top of vram, used as c2p write buffer*/
+   u64 mem_train_fb_loc;
+   bool mem_train_support;
 };
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 1c9d40f97a9b..72232fccf61a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -2038,6 +2038,11 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
if (adev->is_atom_fw) {
amdgpu_atomfirmware_scratch_regs_init(adev);
amdgpu_atomfirmware_allocate_fb_scratch(adev);
+   ret = amdgpu_atomfirmware_get_mem_train_fb_loc(adev);
+   if (ret) {
+   DRM_ERROR("Failed to get mem train fb location.\n");
+   return ret;
+   }
} else {
amdgpu_atombios_scratch_regs_init(adev);
amdgpu_atombios_allocate_fb_scratch(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index 39fd8ae5a822..1ebf5e9a9b7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -27,6 +27,7 @@
 #include "amdgpu_atomfirmware.h"
 #include "atom.h"
 #include "atombios.h"
+#include "soc15_hw_ip.h"
 
 bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device 
*adev)
 {
@@ -462,3 +463,135 @@ int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device 
*adev)
}
return -EINVAL;
 }
+
+/*
+ * Check if VBIOS supports GDDR6 training data save/restore
+ */
+static bool gddr6_mem_train_vbios_support(struct amdgpu_device *adev)
+{
+   uint16_t data_offset;
+   int index;
+
+   index = 
get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
+   firmwareinfo);
+   if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, 
NULL,
+ NULL, NULL, _offset)) {
+   struct atom_firmware_info_v3_1 *firmware_info =
+   (struct atom_firmware_info_v3_1 
*)(adev->mode_info.atom_context->bios +
+  data_offset);
+
+   DRM_DEBUG("atom firmware capability:0x%08x.\n",
+ le32_to_cpu(firmware_info->firmware_capability));
+
+   if (le32_to_cpu(firmware_info->firmware_capability) &
+   ATOM_FIRMWARE_CAP_ENABLE_2STAGE_BIST_TRAINING)
+   return true;
+   }
+
+   return false;
+}
+
+static int gddr6_mem_train_support(struct amdgpu_device *adev)
+{
+   int ret;
+   bool vbios_support;
+   uint32_t major, minor, revision, hw_v;
+
+   if (!amdgpu_sriov_vf(adev) &&
+   gddr6_mem_train_vbios_support(adev)) {
+   vbios_support = true;
+   } else {
+   vbios_support = false;
+   }
+   amdgpu_discovery_get_ip_version(adev, MP0_HWID, , , 
);
+   hw_v = hw_revision(major, minor, revision);
+   /*
+* treat 0 revision as a special case since register for MP0 and MMHUB 
is missing
+* for some Navi10 A0, preventing driver from discovering the hwip 
information since
+* none of the functions will be initialized, it should not cause any 
problems
+*/
+   switch (hw_v) {
+   case hw_revision(11, 0, 0):
+   case hw_revision(11, 0, 5):
+   ret = vbios_support;
+   break;
+   default:
+   if (vbios_support) {
+   DRM_ERROR("memory training vbios supports but psp 
hw(%08x)"
+ " doesn't support!\n", hw_v);
+   ret = -1;
+ 

[PATCH 2/8] drm/amdgpu: add a generic fb accessing helper function

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

add a generic helper function for accessing framebuffer via MMIO

Change-Id: I4baa0aa53c93a94c2eff98c6211a61f369239982
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 34 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 13 +--
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 51ccf175cda0..1102e6bae5d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -991,6 +991,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 void amdgpu_device_fini(struct amdgpu_device *adev);
 int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev);
 
+int amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
+ uint32_t *buf, size_t size, bool write);
 uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg,
uint32_t acc_flags);
 void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 598158e95ec1..fb21ec1f8a61 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -154,6 +154,40 @@ bool amdgpu_device_is_px(struct drm_device *dev)
return false;
 }
 
+/**
+ * VRAM access helper functions.
+ *
+ * amdgpu_device_vram_access - read/write a buffer in vram
+ *
+ * @adev: amdgpu_device pointer
+ * @pos: offset of the buffer in vram
+ * @buf: virtual address of the buffer in system memory
+ * @size: read/write size, sizeof(@buf) must > @size
+ * @write: true - write to vram, otherwise - read from vram
+ *
+ * Returns 0 on success or an -error on failure.
+ */
+int amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
+ uint32_t *buf, size_t size, bool write)
+{
+   uint64_t end = pos + size;
+   unsigned long flags;
+
+   while (pos < end) {
+   spin_lock_irqsave(>mmio_idx_lock, flags);
+   WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)pos) | 0x8000);
+   WREG32_NO_KIQ(mmMM_INDEX_HI, pos >> 31);
+   if (write)
+   WREG32_NO_KIQ(mmMM_DATA, *buf++);
+   else
+   *buf++ = RREG32_NO_KIQ(mmMM_DATA);
+   spin_unlock_irqrestore(>mmio_idx_lock, flags);
+   pos += 4;
+   }
+
+   return 0;
+}
+
 /*
  * MMIO register access helper functions.
  */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index db2dab3a6dff..324c2d605f54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -134,21 +134,10 @@ static int hw_id_map[MAX_HWIP] = {
 
 static int amdgpu_discovery_read_binary(struct amdgpu_device *adev, uint8_t 
*binary)
 {
-   uint32_t *p = (uint32_t *)binary;
uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
uint64_t pos = vram_size - BINARY_MAX_SIZE;
-   unsigned long flags;
-
-   while (pos < vram_size) {
-   spin_lock_irqsave(>mmio_idx_lock, flags);
-   WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)pos) | 0x8000);
-   WREG32_NO_KIQ(mmMM_INDEX_HI, pos >> 31);
-   *p++ = RREG32_NO_KIQ(mmMM_DATA);
-   spin_unlock_irqrestore(>mmio_idx_lock, flags);
-   pos += 4;
-   }
 
-   return 0;
+   return amdgpu_device_vram_access(adev, pos, (uint32_t *)binary, 
BINARY_MAX_SIZE, false);
 }
 
 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t 
size)
-- 
2.17.1

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

[PATCH 1/8] drm/amdgpu: update amdgpu_discovery to handle revision

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

update amdgpu_discovery to get IP revision.

Change-Id: If8152103d03b58e1dc0f32db63625e290f5f08a0
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 1481899f86c1..db2dab3a6dff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -333,7 +333,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device 
*adev)
 }
 
 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
-   int *major, int *minor)
+   int *major, int *minor, int *revision)
 {
struct binary_header *bhdr;
struct ip_discovery_header *ihdr;
@@ -369,6 +369,8 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device 
*adev, int hw_id,
*major = ip->major;
if (minor)
*minor = ip->minor;
+   if (revision)
+   *revision = ip->revision;
return 0;
}
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 
1);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
index 85b8c4d4d576..ada30cfd9d35 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
@@ -28,7 +28,7 @@ int amdgpu_discovery_init(struct amdgpu_device *adev);
 void amdgpu_discovery_fini(struct amdgpu_device *adev);
 int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev);
 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
-int *major, int *minor);
+int *major, int *minor, int *revision);
 int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev);
 
 #endif /* __AMDGPU_DISCOVERY__ */
-- 
2.17.1

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

[PATCH 3/8] drm/amdgpu: introduce psp_v11_0_is_sos_alive interface

2019-10-10 Thread Tianci Yin
From: "Tianci.Yin" 

introduce psp_v11_0_is_sos_alive func for common use.

Change-Id: Iee0a6dd924d6a4b164eb751c0bec49fcb7d79483
Reviewed-by: Alex Deucher 
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 04318cfd50a8..2ba0f68ced10 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -206,18 +206,26 @@ static int psp_v11_0_init_microcode(struct psp_context 
*psp)
return err;
 }
 
+static bool psp_v11_0_is_sos_alive(struct psp_context *psp)
+{
+   struct amdgpu_device *adev = psp->adev;
+   uint32_t sol_reg;
+
+   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
+
+   return sol_reg != 0x0;
+}
+
 static int psp_v11_0_bootloader_load_kdb(struct psp_context *psp)
 {
int ret;
uint32_t psp_gfxdrv_command_reg = 0;
struct amdgpu_device *adev = psp->adev;
-   uint32_t sol_reg;
 
/* Check tOS sign of life register to confirm sys driver and sOS
 * are already been loaded.
 */
-   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-   if (sol_reg) {
+   if (psp_v11_0_is_sos_alive(psp)) {
psp->sos_fw_version = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_58);
dev_info(adev->dev, "sos fw version = 0x%x.\n", 
psp->sos_fw_version);
return 0;
@@ -253,13 +261,11 @@ static int psp_v11_0_bootloader_load_sysdrv(struct 
psp_context *psp)
int ret;
uint32_t psp_gfxdrv_command_reg = 0;
struct amdgpu_device *adev = psp->adev;
-   uint32_t sol_reg;
 
/* Check sOS sign of life register to confirm sys driver and sOS
 * are already been loaded.
 */
-   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-   if (sol_reg) {
+   if (psp_v11_0_is_sos_alive(psp)) {
psp->sos_fw_version = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_58);
dev_info(adev->dev, "sos fw version = 0x%x.\n", 
psp->sos_fw_version);
return 0;
@@ -297,13 +303,11 @@ static int psp_v11_0_bootloader_load_sos(struct 
psp_context *psp)
int ret;
unsigned int psp_gfxdrv_command_reg = 0;
struct amdgpu_device *adev = psp->adev;
-   uint32_t sol_reg;
 
/* Check sOS sign of life register to confirm sys driver and sOS
 * are already been loaded.
 */
-   sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-   if (sol_reg)
+   if (psp_v11_0_is_sos_alive(psp))
return 0;
 
/* Wait for bootloader to signify that is ready having bit 31 of 
C2PMSG_35 set to 1 */
-- 
2.17.1

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

[PATCH] drm/amdgpu/gfx10: add support for wks firmware loading

2019-09-18 Thread Tianci Yin
From: "Tianci.Yin" 

load different cp firmware according to the DID and RID

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 082a0b3298a9..65caf404e7d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -66,6 +66,11 @@ MODULE_FIRMWARE("amdgpu/navi10_mec.bin");
 MODULE_FIRMWARE("amdgpu/navi10_mec2.bin");
 MODULE_FIRMWARE("amdgpu/navi10_rlc.bin");
 
+MODULE_FIRMWARE("amdgpu/navi14_ce_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_pfp_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_me_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_mec_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_mec2_wks.bin");
 MODULE_FIRMWARE("amdgpu/navi14_ce.bin");
 MODULE_FIRMWARE("amdgpu/navi14_pfp.bin");
 MODULE_FIRMWARE("amdgpu/navi14_me.bin");
@@ -591,7 +596,8 @@ static void gfx_v10_0_check_gfxoff_flag(struct 
amdgpu_device *adev)
 static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
 {
const char *chip_name;
-   char fw_name[30];
+   char fw_name[40];
+   char wks[10];
int err;
struct amdgpu_firmware_info *info = NULL;
const struct common_firmware_header *header = NULL;
@@ -604,12 +610,16 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
 
DRM_DEBUG("\n");
 
+   memset(wks, 0, sizeof(wks));
switch (adev->asic_type) {
case CHIP_NAVI10:
chip_name = "navi10";
break;
case CHIP_NAVI14:
chip_name = "navi14";
+   if (!(adev->pdev->device == 0x7340 &&
+ adev->pdev->revision != 0x00))
+   snprintf(wks, sizeof(wks), "_wks");
break;
case CHIP_NAVI12:
chip_name = "navi12";
@@ -618,7 +628,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
BUG();
}
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.pfp_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -629,7 +639,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
adev->gfx.pfp_feature_version = 
le32_to_cpu(cp_hdr->ucode_feature_version);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.me_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -640,7 +650,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
adev->gfx.me_feature_version = 
le32_to_cpu(cp_hdr->ucode_feature_version);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.ce_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -705,7 +715,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
if (adev->gfx.rlc.is_rlc_v2_1)
gfx_v10_0_init_rlc_ext_microcode(adev);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.mec_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -716,7 +726,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
adev->gfx.mec_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
adev->gfx.mec_feature_version = 
le32_to_cpu(cp_hdr->ucode_feature_version);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.mec2_fw, fw_name, adev->dev);
if (!err) {
err = amdgpu_ucode_validate(adev->gfx.mec2_fw);
-- 
2.17.1

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

[PATCH] drm/amdgpu/gfx10: add support for wks firmware loading

2019-09-18 Thread Tianci Yin
From: "Tianci.Yin" 

load different cp firmware according to the DID and RID

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 082a0b3298a9..b5d3e75e7e88 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -66,6 +66,11 @@ MODULE_FIRMWARE("amdgpu/navi10_mec.bin");
 MODULE_FIRMWARE("amdgpu/navi10_mec2.bin");
 MODULE_FIRMWARE("amdgpu/navi10_rlc.bin");
 
+MODULE_FIRMWARE("amdgpu/navi14_ce_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_pfp_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_me_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_mec_wks.bin");
+MODULE_FIRMWARE("amdgpu/navi14_mec2_wks.bin");
 MODULE_FIRMWARE("amdgpu/navi14_ce.bin");
 MODULE_FIRMWARE("amdgpu/navi14_pfp.bin");
 MODULE_FIRMWARE("amdgpu/navi14_me.bin");
@@ -591,7 +596,8 @@ static void gfx_v10_0_check_gfxoff_flag(struct 
amdgpu_device *adev)
 static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
 {
const char *chip_name;
-   char fw_name[30];
+   const char *wks;
+   char fw_name[40];
int err;
struct amdgpu_firmware_info *info = NULL;
const struct common_firmware_header *header = NULL;
@@ -618,7 +624,13 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
BUG();
}
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", chip_name);
+   if(adev->pdev->device == 0x7340 &&
+  adev->pdev->revision != 0x00)
+   wks = "";
+   else
+   wks = "_wks";
+
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.pfp_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -629,7 +641,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
adev->gfx.pfp_feature_version = 
le32_to_cpu(cp_hdr->ucode_feature_version);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.me_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -640,7 +652,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
adev->gfx.me_feature_version = 
le32_to_cpu(cp_hdr->ucode_feature_version);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.ce_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -705,7 +717,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
if (adev->gfx.rlc.is_rlc_v2_1)
gfx_v10_0_init_rlc_ext_microcode(adev);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.mec_fw, fw_name, adev->dev);
if (err)
goto out;
@@ -716,7 +728,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device 
*adev)
adev->gfx.mec_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
adev->gfx.mec_feature_version = 
le32_to_cpu(cp_hdr->ucode_feature_version);
 
-   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
+   snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2%s.bin", chip_name, 
wks);
err = request_firmware(>gfx.mec2_fw, fw_name, adev->dev);
if (!err) {
err = amdgpu_ucode_validate(adev->gfx.mec2_fw);
-- 
2.17.1

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

[PATCH 2/2] drm/amdgpu/gfx10: update gfx golden settings for navi14

2019-09-18 Thread Tianci Yin
From: "Tianci.Yin" 

update registers: mmUTCL1_CTRL

Change-Id: I6df12555b72ba6faa926af8155b3f079e422a500
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 7901530d07f0..121824b47d02 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -161,7 +161,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0x, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfff7, 0x0103),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CNTL, 0x6010, 0x479c0010),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0x0080, 0x0080),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0x00c0, 0x00c0),
 };
 
 static const struct soc15_reg_golden golden_settings_gc_10_1_nv14[] =
-- 
2.17.1

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

[PATCH 1/2] drm/amdgpu/gfx10: update gfx golden settings

2019-09-18 Thread Tianci Yin
From: "Tianci.Yin" 

update registers: mmUTCL1_CTRL

Change-Id: Icb50fb35a427a50a06138b8b3715651eebe92b95
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 4e6b48859aca..7901530d07f0 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -111,7 +111,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfff7, 0x0103),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CNTL, 0x6010, 0x479c0010),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CGTT_CLK_CTRL, 0xfeff0fff, 
0x4100),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0x0080, 0x0080)
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0x00c0, 0x00c0)
 };
 
 static const struct soc15_reg_golden golden_settings_gc_10_0_nv10[] =
-- 
2.17.1

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

[PATCH 2/2] drm/amdgpu: keep the stolen memory in visible vram region

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

stolen memory should be fixed in visible region.

Change-Id: Icbbbd39fd113e93423aad8d2555f4073c08020e5
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 --
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 801f912..dcd32d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1733,6 +1733,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
uint64_t gtt_size;
int r;
u64 vis_vram_limit;
+   void *stolen_vga_buf;
 
mutex_init(>mman.gtt_window_lock);
 
@@ -1787,7 +1788,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM,
>stolen_vga_memory,
-   NULL, NULL);
+   NULL, _vga_buf);
if (r)
return r;
DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
@@ -1851,8 +1852,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  */
 void amdgpu_ttm_late_init(struct amdgpu_device *adev)
 {
+   void *stolen_vga_buf;
/* return the VGA stolen memory (if any) back to VRAM */
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, NULL);
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index f77138b..ab43ae2 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1248,6 +1248,7 @@ static int gmc_v9_0_sw_init(void *handle)
 static int gmc_v9_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   void *stolen_vga_buf;
 
if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__UMC) &&
adev->gmc.umc_ras_if) {
@@ -1280,7 +1281,7 @@ static int gmc_v9_0_sw_fini(void *handle)
amdgpu_vm_manager_fini(adev);
 
if (gmc_v9_0_keep_stolen_memory(adev))
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, NULL);
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, 
_vga_buf);
 
amdgpu_gart_table_vram_free(adev);
amdgpu_bo_fini(adev);
-- 
2.7.4

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

[PATCH 1/2] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

Fix compute ring test failure in sriov scenario.

Change-Id: I141d3d094e2cba9bcf2f6c96f4d8c4ef43c421c3
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 9f7cc5b..d11ce86 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -239,6 +239,8 @@ static int psp_tmr_init(struct psp_context *psp)
 {
int ret;
int tmr_size;
+   void *tmr_buf;
+   void **pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
 
/*
 * According to HW engineer, they prefer the TMR address be "naturally
@@ -263,7 +265,7 @@ static int psp_tmr_init(struct psp_context *psp)
 
ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
  AMDGPU_GEM_DOMAIN_VRAM,
- >tmr_bo, >tmr_mc_addr, NULL);
+ >tmr_bo, >tmr_mc_addr, pptr);
 
return ret;
 }
@@ -1206,6 +1208,8 @@ static int psp_hw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct psp_context *psp = >psp;
+   void *tmr_buf;
+   void **pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
 
if (adev->gmc.xgmi.num_physical_nodes > 1 &&
psp->xgmi_context.initialized == 1)
@@ -1216,7 +1220,7 @@ static int psp_hw_fini(void *handle)
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, NULL);
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, pptr);
amdgpu_bo_free_kernel(>fw_pri_bo,
  >fw_pri_mc_addr, >fw_pri_buf);
amdgpu_bo_free_kernel(>fence_buf_bo,
-- 
2.7.4

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

[PATCH 2/2] drm/amdgpu: keep the stolen memory in visible vram region

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

stolen memory should be fixed in visible region.

Change-Id: Icbbbd39fd113e93423aad8d2555f4073c08020e5
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 --
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 801f912..dcd32d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1733,6 +1733,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
uint64_t gtt_size;
int r;
u64 vis_vram_limit;
+   void *stolen_vga_buf;
 
mutex_init(>mman.gtt_window_lock);
 
@@ -1787,7 +1788,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM,
>stolen_vga_memory,
-   NULL, NULL);
+   NULL, _vga_buf);
if (r)
return r;
DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
@@ -1851,8 +1852,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  */
 void amdgpu_ttm_late_init(struct amdgpu_device *adev)
 {
+   void *stolen_vga_buf;
/* return the VGA stolen memory (if any) back to VRAM */
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, NULL);
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index f77138b..ab43ae2 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1248,6 +1248,7 @@ static int gmc_v9_0_sw_init(void *handle)
 static int gmc_v9_0_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   void *stolen_vga_buf;
 
if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__UMC) &&
adev->gmc.umc_ras_if) {
@@ -1280,7 +1281,7 @@ static int gmc_v9_0_sw_fini(void *handle)
amdgpu_vm_manager_fini(adev);
 
if (gmc_v9_0_keep_stolen_memory(adev))
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, NULL);
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, 
_vga_buf);
 
amdgpu_gart_table_vram_free(adev);
amdgpu_bo_fini(adev);
-- 
2.7.4

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

[PATCH 1/2] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

Fix compute ring test failure in sriov scenario.

Change-Id: I141d3d094e2cba9bcf2f6c96f4d8c4ef43c421c3
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 9f7cc5b..43fa8b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -239,6 +239,7 @@ static int psp_tmr_init(struct psp_context *psp)
 {
int ret;
int tmr_size;
+   void *tmr_buf;
 
/*
 * According to HW engineer, they prefer the TMR address be "naturally
@@ -261,9 +262,14 @@ static int psp_tmr_init(struct psp_context *psp)
}
}
 
-   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
- AMDGPU_GEM_DOMAIN_VRAM,
- >tmr_bo, >tmr_mc_addr, NULL);
+   if (!amdgpu_sriov_vf(psp->adev))
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >tmr_bo, >tmr_mc_addr, 
NULL);
+   else
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >tmr_bo, >tmr_mc_addr, 
_buf);
 
return ret;
 }
@@ -1206,6 +1212,7 @@ static int psp_hw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct psp_context *psp = >psp;
+   void *tmr_buf;
 
if (adev->gmc.xgmi.num_physical_nodes > 1 &&
psp->xgmi_context.initialized == 1)
@@ -1216,7 +1223,7 @@ static int psp_hw_fini(void *handle)
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, NULL);
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, _buf);
amdgpu_bo_free_kernel(>fw_pri_bo,
  >fw_pri_mc_addr, >fw_pri_buf);
amdgpu_bo_free_kernel(>fence_buf_bo,
-- 
2.7.4

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

[PATCH 1/2] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

Fix compute ring test failure in sriov scenario.

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 9f7cc5b..92c68c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -261,9 +261,15 @@ static int psp_tmr_init(struct psp_context *psp)
}
}
 
-   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
- AMDGPU_GEM_DOMAIN_VRAM,
- >tmr_bo, >tmr_mc_addr, NULL);
+   psp->tmr_buf = NULL;
+   if (!amdgpu_sriov_vf(psp->adev))
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >tmr_bo, >tmr_mc_addr, 
NULL);
+   else
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >tmr_bo, >tmr_mc_addr, 
>tmr_buf);
 
return ret;
 }
@@ -1216,7 +1222,7 @@ static int psp_hw_fini(void *handle)
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, NULL);
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, >tmr_buf);
amdgpu_bo_free_kernel(>fw_pri_bo,
  >fw_pri_mc_addr, >fw_pri_buf);
amdgpu_bo_free_kernel(>fence_buf_bo,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index bc0947f..b73d4aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -171,6 +171,7 @@ struct psp_context
/* tmr buffer */
struct amdgpu_bo*tmr_bo;
uint64_ttmr_mc_addr;
+   void*tmr_buf;
 
/* asd firmware and buffer */
const struct firmware   *asd_fw;
-- 
2.7.4

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

[PATCH 2/2] drm/amdgpu: keep the stolen memory in visible vram region

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

stolen memory should be fixed in visible region.

Change-Id: Icbbbd39fd113e93423aad8d2555f4073c08020e5
Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 11e0fc0..d1a8f87 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -817,6 +817,7 @@ struct amdgpu_device {
uint8_t *bios;
uint32_tbios_size;
struct amdgpu_bo*stolen_vga_memory;
+   void*stolen_vga_buf;
uint32_tbios_scratch_reg_offset;
uint32_tbios_scratch[AMDGPU_BIOS_NUM_SCRATCH];
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 801f912..5ac9a66 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1787,7 +1787,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM,
>stolen_vga_memory,
-   NULL, NULL);
+   NULL, >stolen_vga_buf);
if (r)
return r;
DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
@@ -1852,7 +1852,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 void amdgpu_ttm_late_init(struct amdgpu_device *adev)
 {
/* return the VGA stolen memory (if any) back to VRAM */
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, NULL);
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, 
>stolen_vga_buf);
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index f77138b..602d7c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1280,7 +1280,7 @@ static int gmc_v9_0_sw_fini(void *handle)
amdgpu_vm_manager_fini(adev);
 
if (gmc_v9_0_keep_stolen_memory(adev))
-   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, NULL);
+   amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, 
>stolen_vga_buf);
 
amdgpu_gart_table_vram_free(adev);
amdgpu_bo_fini(adev);
-- 
2.7.4

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

[PATCH] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

2019-08-28 Thread Tianci Yin
From: "Tianci.Yin" 

Fix compute ring test failure in sriov scenario.

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 9f7cc5b..92c68c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -261,9 +261,15 @@ static int psp_tmr_init(struct psp_context *psp)
}
}
 
-   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
- AMDGPU_GEM_DOMAIN_VRAM,
- >tmr_bo, >tmr_mc_addr, NULL);
+   psp->tmr_buf = NULL;
+   if (!amdgpu_sriov_vf(psp->adev))
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >tmr_bo, >tmr_mc_addr, 
NULL);
+   else
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >tmr_bo, >tmr_mc_addr, 
>tmr_buf);
 
return ret;
 }
@@ -1216,7 +1222,7 @@ static int psp_hw_fini(void *handle)
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, NULL);
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, >tmr_buf);
amdgpu_bo_free_kernel(>fw_pri_bo,
  >fw_pri_mc_addr, >fw_pri_buf);
amdgpu_bo_free_kernel(>fence_buf_bo,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index bc0947f..b73d4aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -171,6 +171,7 @@ struct psp_context
/* tmr buffer */
struct amdgpu_bo*tmr_bo;
uint64_ttmr_mc_addr;
+   void*tmr_buf;
 
/* asd firmware and buffer */
const struct firmware   *asd_fw;
-- 
2.7.4

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

[PATCH] drm/amdgpu/psp: move TMR to cpu invisible vram region

2019-08-19 Thread Tianci Yin
From: "Tianci.Yin" 

so that more visible vram can be available for umd.

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c| 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h| 1 -
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 1059771..0476790 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -246,8 +246,9 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
bp.size = size;
bp.byte_align = align;
bp.domain = domain;
-   bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-   AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
+   bp.flags = cpu_addr ? AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
+   : AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
+   bp.flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
bp.type = ttm_bo_type_kernel;
bp.resv = NULL;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 7715c0d..5e7fbbe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -264,7 +264,7 @@ static int psp_tmr_init(struct psp_context *psp)
 
ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
  AMDGPU_GEM_DOMAIN_VRAM,
- >tmr_bo, >tmr_mc_addr, 
>tmr_buf);
+ >tmr_bo, >tmr_mc_addr, NULL);
 
return ret;
 }
@@ -1215,7 +1215,7 @@ static int psp_hw_fini(void *handle)
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, >tmr_buf);
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, NULL);
amdgpu_bo_free_kernel(>fw_pri_bo,
  >fw_pri_mc_addr, >fw_pri_buf);
amdgpu_bo_free_kernel(>fence_buf_bo,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 0029fa2..48b057d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -172,7 +172,6 @@ struct psp_context
/* tmr buffer */
struct amdgpu_bo*tmr_bo;
uint64_ttmr_mc_addr;
-   void*tmr_buf;
 
/* asd firmware and buffer */
const struct firmware   *asd_fw;
-- 
2.7.4

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

[PATCH] drm/amdgpu/psp: move TMR to cpu invisible vram region

2019-08-19 Thread Tianci Yin
From: "Tianci.Yin" 

so that more visible vram can be available for ocl applications.

Signed-off-by: Tianci.Yin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c| 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h| 1 -
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 1059771..ca35869 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -246,8 +246,9 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
bp.size = size;
bp.byte_align = align;
bp.domain = domain;
-   bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-   AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
+   bp.flags = (cpu_addr)?AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
+   :AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
+   bp.flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
bp.type = ttm_bo_type_kernel;
bp.resv = NULL;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 7715c0d..5e7fbbe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -264,7 +264,7 @@ static int psp_tmr_init(struct psp_context *psp)
 
ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
  AMDGPU_GEM_DOMAIN_VRAM,
- >tmr_bo, >tmr_mc_addr, 
>tmr_buf);
+ >tmr_bo, >tmr_mc_addr, NULL);
 
return ret;
 }
@@ -1215,7 +1215,7 @@ static int psp_hw_fini(void *handle)
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, >tmr_buf);
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, NULL);
amdgpu_bo_free_kernel(>fw_pri_bo,
  >fw_pri_mc_addr, >fw_pri_buf);
amdgpu_bo_free_kernel(>fence_buf_bo,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 0029fa2..48b057d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -172,7 +172,6 @@ struct psp_context
/* tmr buffer */
struct amdgpu_bo*tmr_bo;
uint64_ttmr_mc_addr;
-   void*tmr_buf;
 
/* asd firmware and buffer */
const struct firmware   *asd_fw;
-- 
2.7.4

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

[PATCH 1/2] drm/amd/powerplay: re-define smu interface version for smu v11

2019-08-07 Thread Tianci Yin
From: tiancyin 

[why]
navi14 share same defination of smu interface version with navi10,
anyone of them update the version may break the other one's
version checking.

[how]
create different version defination, so that they can
update their version separately.

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h  |  4 +++-
 .../gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h   |  4 +++-
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h|  5 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c   |  1 -
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c| 16 
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c   |  1 -
 6 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
index 755d51f..fdc6b7a 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
@@ -27,7 +27,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x13
+// Be aware of that the version should be updated in
+// smu_v11_0.h, rename is also needed.
+// #define SMU11_DRIVER_IF_VERSION 0x13
 
 #define PPTABLE_V20_SMU_VERSION 3
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
index adbbfeb..6d9e79e 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
@@ -26,7 +26,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x33
+// Be aware of that the version should be updated in
+// smu_v11_0.h, maybe rename is also needed.
+// #define SMU11_DRIVER_IF_VERSION 0x33
 
 #define PPTABLE_NV10_SMU_VERSION 8
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index fcb5801..97605e9 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -25,6 +25,11 @@
 
 #include "amdgpu_smu.h"
 
+#define SMU11_DRIVER_IF_VERSION_INV 0x
+#define SMU11_DRIVER_IF_VERSION_VG20 0x13
+#define SMU11_DRIVER_IF_VERSION_NV10 0x33
+#define SMU11_DRIVER_IF_VERSION_NV14 0x33
+
 /* MP Apertures */
 #define MP0_Public 0x0380
 #define MP0_SRAM   0x0390
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index be88c5d..fdc7db0 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -1630,6 +1630,5 @@ void navi10_set_ppt_funcs(struct smu_context *smu)
struct smu_table_context *smu_table = >smu_table;
 
smu->ppt_funcs = _ppt_funcs;
-   smu->smc_if_version = SMU11_DRIVER_IF_VERSION;
smu_table->table_count = TABLE_COUNT;
 }
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c 
b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index c078bf4..91dfae1 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -271,6 +271,22 @@ static int smu_v11_0_check_fw_version(struct smu_context 
*smu)
smu_minor = (smu_version >> 8) & 0xff;
smu_debug = (smu_version >> 0) & 0xff;
 
+   switch (smu->adev->asic_type) {
+   case CHIP_VEGA20:
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_VG20;
+   break;
+   case CHIP_NAVI10:
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_NV10;
+   break;
+   case CHIP_NAVI14:
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_NV14;
+   break;
+   default:
+   pr_err("smu unsuported asic type:%d.\n",smu->adev->asic_type);
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_INV;
+   break;
+   }
+
/*
 * 1. if_version mismatch is not critical as our fw is designed
 * to be backward compatible.
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 52c8fc9..e28c004 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -3173,6 +3173,5 @@ void vega20_set_ppt_funcs(struct smu_context *smu)
struct smu_table_context *smu_table = >smu_table;
 
smu->ppt_funcs = _ppt_funcs;
-   smu->smc_if_version = SMU11_DRIVER_IF_VERSION;
smu_table->table_count = TABLE_COUNT;
 }
-- 
2.7.4

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

[PATCH 2/2] drm/amd/powerplay: update smu11_driver_if_navi10.h

2019-08-07 Thread Tianci Yin
From: tiancyin 

update the smu11_driver_if_navi10.h since navi14 smu fw
update to 53.12

Change-Id: If0f729ec87c98f24e1794f0847eac5ba23671e34
Reviewed-by: Evan Quan 
Signed-off-by: tiancyin 
---
 .../drm/amd/powerplay/inc/smu11_driver_if_navi10.h | 25 +-
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h  |  2 +-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
index 6d9e79e..ac0120e 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
@@ -506,10 +506,11 @@ typedef struct {
   uint32_t Status;
 
   uint16_t DieTemperature;
-  uint16_t MemoryTemperature;
+  uint16_t CurrentMemoryTemperature;
 
-  uint16_t SelectedCardPower;
-  uint16_t Reserved4; 
+  uint16_t MemoryTemperature;
+  uint8_t MemoryHotspotPosition;
+  uint8_t Reserved4;
 
   uint32_t BoardLevelEnergyAccumulator;  
 } OutOfBandMonitor_t;
@@ -801,7 +802,12 @@ typedef struct {
   // Mvdd Svi2 Div Ratio Setting
   uint32_t MvddRatio; // This is used for MVDD Vid workaround. It has 16 
fractional bits (Q16.16)
 
-  uint32_t BoardReserved[9];
+  uint8_t  RenesesLoadLineEnabled;
+  uint8_t  GfxLoadlineResistance;
+  uint8_t  SocLoadlineResistance;
+  uint8_t  Padding8_Loadline;
+
+  uint32_t BoardReserved[8];
 
   // Padding for MMHUB - do not modify this
   uint32_t MmHubPadding[8]; // SMU internal use
@@ -905,13 +911,22 @@ typedef struct {
 } Watermarks_t;
 
 typedef struct {
+  uint16_t avgPsmCount[28];
+  uint16_t minPsmCount[28];
+  floatavgPsmVoltage[28];
+  floatminPsmVoltage[28];
+
+  uint32_t MmHubPadding[32]; // SMU internal use
+} AvfsDebugTable_t_NV14;
+
+typedef struct {
   uint16_t avgPsmCount[36];
   uint16_t minPsmCount[36];
   floatavgPsmVoltage[36]; 
   floatminPsmVoltage[36];
 
   uint32_t MmHubPadding[8]; // SMU internal use
-} AvfsDebugTable_t;
+} AvfsDebugTable_t_NV10;
 
 typedef struct {
   uint8_t  AvfsVersion;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index 97605e9..ee8542d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -28,7 +28,7 @@
 #define SMU11_DRIVER_IF_VERSION_INV 0x
 #define SMU11_DRIVER_IF_VERSION_VG20 0x13
 #define SMU11_DRIVER_IF_VERSION_NV10 0x33
-#define SMU11_DRIVER_IF_VERSION_NV14 0x33
+#define SMU11_DRIVER_IF_VERSION_NV14 0x34
 
 /* MP Apertures */
 #define MP0_Public 0x0380
-- 
2.7.4

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

[PATCH 1/2] md/powerplay: re-define smu interface version for smu v11

2019-08-07 Thread Tianci Yin
From: tiancyin 

[why]
navi14 share same defination of smu interface version with navi10,
anyone of them update the version may break the other one's
version checking.

[how]
create different version defination, so that they can
update their version separately.

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h  |  4 +++-
 .../gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h   |  4 +++-
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h|  5 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c   |  1 -
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c| 16 
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c   |  1 -
 6 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
index 755d51f..fdc6b7a 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
@@ -27,7 +27,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x13
+// Be aware of that the version should be updated in
+// smu_v11_0.h, rename is also needed.
+// #define SMU11_DRIVER_IF_VERSION 0x13
 
 #define PPTABLE_V20_SMU_VERSION 3
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
index adbbfeb..6d9e79e 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
@@ -26,7 +26,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x33
+// Be aware of that the version should be updated in
+// smu_v11_0.h, maybe rename is also needed.
+// #define SMU11_DRIVER_IF_VERSION 0x33
 
 #define PPTABLE_NV10_SMU_VERSION 8
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index fcb5801..97605e9 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -25,6 +25,11 @@
 
 #include "amdgpu_smu.h"
 
+#define SMU11_DRIVER_IF_VERSION_INV 0x
+#define SMU11_DRIVER_IF_VERSION_VG20 0x13
+#define SMU11_DRIVER_IF_VERSION_NV10 0x33
+#define SMU11_DRIVER_IF_VERSION_NV14 0x33
+
 /* MP Apertures */
 #define MP0_Public 0x0380
 #define MP0_SRAM   0x0390
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index be88c5d..fdc7db0 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -1630,6 +1630,5 @@ void navi10_set_ppt_funcs(struct smu_context *smu)
struct smu_table_context *smu_table = >smu_table;
 
smu->ppt_funcs = _ppt_funcs;
-   smu->smc_if_version = SMU11_DRIVER_IF_VERSION;
smu_table->table_count = TABLE_COUNT;
 }
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c 
b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index c078bf4..91dfae1 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -271,6 +271,22 @@ static int smu_v11_0_check_fw_version(struct smu_context 
*smu)
smu_minor = (smu_version >> 8) & 0xff;
smu_debug = (smu_version >> 0) & 0xff;
 
+   switch (smu->adev->asic_type) {
+   case CHIP_VEGA20:
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_VG20;
+   break;
+   case CHIP_NAVI10:
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_NV10;
+   break;
+   case CHIP_NAVI14:
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_NV14;
+   break;
+   default:
+   pr_err("smu unsuported asic type:%d.\n",smu->adev->asic_type);
+   smu->smc_if_version = SMU11_DRIVER_IF_VERSION_INV;
+   break;
+   }
+
/*
 * 1. if_version mismatch is not critical as our fw is designed
 * to be backward compatible.
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 52c8fc9..e28c004 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -3173,6 +3173,5 @@ void vega20_set_ppt_funcs(struct smu_context *smu)
struct smu_table_context *smu_table = >smu_table;
 
smu->ppt_funcs = _ppt_funcs;
-   smu->smc_if_version = SMU11_DRIVER_IF_VERSION;
smu_table->table_count = TABLE_COUNT;
 }
-- 
2.7.4

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

[PATCH 2/2] drm/amd/powerplay: update smu11_driver_if_navi10.h

2019-08-07 Thread Tianci Yin
From: tiancyin 

update the smu11_driver_if_navi10.h since navi14 smu fw
update to 53.12

Change-Id: If0f729ec87c98f24e1794f0847eac5ba23671e34
Reviewed-by: Evan Quan 
Signed-off-by: tiancyin 
---
 .../drm/amd/powerplay/inc/smu11_driver_if_navi10.h | 26 +-
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h  |  2 +-
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
index 6d9e79e..4b7c5c2 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
@@ -506,10 +506,11 @@ typedef struct {
   uint32_t Status;
 
   uint16_t DieTemperature;
-  uint16_t MemoryTemperature;
+  uint16_t CurrentMemoryTemperature;
 
-  uint16_t SelectedCardPower;
-  uint16_t Reserved4; 
+  uint16_t MemoryTemperature;
+  uint8_t MemoryHotspotPosition;
+  uint8_t Reserved4;
 
   uint32_t BoardLevelEnergyAccumulator;  
 } OutOfBandMonitor_t;
@@ -801,7 +802,13 @@ typedef struct {
   // Mvdd Svi2 Div Ratio Setting
   uint32_t MvddRatio; // This is used for MVDD Vid workaround. It has 16 
fractional bits (Q16.16)
 
-  uint32_t BoardReserved[9];
+  //FIXME: Reneses VR workaround
+  uint8_t  RenesesLoadLineEnabled;
+  uint8_t  GfxLoadlineResistance;
+  uint8_t  SocLoadlineResistance;
+  uint8_t  Padding8_Loadline;
+
+  uint32_t BoardReserved[8];
 
   // Padding for MMHUB - do not modify this
   uint32_t MmHubPadding[8]; // SMU internal use
@@ -905,13 +912,22 @@ typedef struct {
 } Watermarks_t;
 
 typedef struct {
+  uint16_t avgPsmCount[28];
+  uint16_t minPsmCount[28];
+  floatavgPsmVoltage[28];
+  floatminPsmVoltage[28];
+
+  uint32_t MmHubPadding[32]; // SMU internal use
+} AvfsDebugTable_t_NV14;
+
+typedef struct {
   uint16_t avgPsmCount[36];
   uint16_t minPsmCount[36];
   floatavgPsmVoltage[36]; 
   floatminPsmVoltage[36];
 
   uint32_t MmHubPadding[8]; // SMU internal use
-} AvfsDebugTable_t;
+} AvfsDebugTable_t_NV10;
 
 typedef struct {
   uint8_t  AvfsVersion;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index 97605e9..ee8542d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -28,7 +28,7 @@
 #define SMU11_DRIVER_IF_VERSION_INV 0x
 #define SMU11_DRIVER_IF_VERSION_VG20 0x13
 #define SMU11_DRIVER_IF_VERSION_NV10 0x33
-#define SMU11_DRIVER_IF_VERSION_NV14 0x33
+#define SMU11_DRIVER_IF_VERSION_NV14 0x34
 
 /* MP Apertures */
 #define MP0_Public 0x0380
-- 
2.7.4

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

[PATCH] drm/amdgpu/soc15: fix external_rev_id for navi14

2019-08-05 Thread Tianci Yin
From: tiancyin 

fix the hard code external_rev_id.

Change-Id: I7b46f7b49b6d0586d1fa282d4961815fb124379b
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 9bce6a1..2f45bf2 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -546,7 +546,7 @@ static int nv_common_early_init(void *handle)
AMD_CG_SUPPORT_BIF_LS;
adev->pg_flags = AMD_PG_SUPPORT_VCN |
AMD_PG_SUPPORT_VCN_DPG;
-   adev->external_rev_id = 20;
+   adev->external_rev_id = adev->rev_id + 20;
break;
default:
/* FIXME: not supported yet */
-- 
2.7.4

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

[PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map array

2019-07-11 Thread Tianci Yin
From: tiancyin 

ID of DCE_HWIP from vbios is DMU_HWID,
mismatch cause null pointer crash in navi10 modprobe.

Change-Id: I3be363cf5248de904b3bdae2f34d3bbe0bbbc07d
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index e049ae6..1481899 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -123,7 +123,7 @@ static int hw_id_map[MAX_HWIP] = {
[UVD_HWIP]  = UVD_HWID,
[VCE_HWIP]  = VCE_HWID,
[DF_HWIP]   = DF_HWID,
-   [DCE_HWIP]  = DCEAZ_HWID,
+   [DCE_HWIP]  = DMU_HWID,
[OSSSYS_HWIP]   = OSSSYS_HWID,
[SMUIO_HWIP]= SMUIO_HWID,
[PWR_HWIP]  = PWR_HWID,
-- 
2.7.4

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

[PATCH] drm/amd/powerplay: update smu11_driver_if_navi10.h

2019-06-27 Thread Tianci Yin
From: tiancyin 

update the smu11_driver_if_navi10.h since navi10 smu fw
update to 42.28

Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h | 6 +++---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
index a8b31bc..adbbfeb 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_navi10.h
@@ -26,7 +26,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x32
+#define SMU11_DRIVER_IF_VERSION 0x33
 
 #define PPTABLE_NV10_SMU_VERSION 8
 
@@ -813,8 +813,8 @@ typedef struct {
   uint16_t UclkAverageLpfTau;
   uint16_t GfxActivityLpfTau;
   uint16_t UclkActivityLpfTau;
+  uint16_t SocketPowerLpfTau;
 
-  uint16_t Padding;  
   // Padding - ignore
   uint32_t MmHubPadding[8]; // SMU internal use
 } DriverSmuConfig_t;
@@ -853,7 +853,7 @@ typedef struct {
   uint8_t  CurrGfxVoltageOffset  ;
   uint8_t  CurrMemVidOffset  ;
   uint8_t  Padding8  ;
-  uint16_t CurrSocketPower   ;
+  uint16_t AverageSocketPower;
   uint16_t TemperatureEdge   ;
   uint16_t TemperatureHotspot;
   uint16_t TemperatureMem;
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index 99566de..373aeba 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -863,7 +863,7 @@ static int navi10_get_gpu_power(struct smu_context *smu, 
uint32_t *value)
if (ret)
return ret;
 
-   *value = metrics.CurrSocketPower << 8;
+   *value = metrics.AverageSocketPower << 8;
 
return 0;
 }
-- 
2.7.4

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

[PATCH] drm/amdgpu: disable gfxoff on navi10

2019-06-24 Thread Tianci Yin
From: tiancyin 

The gfxoff brings unstability, disable it by default

Change-Id: I43bdab0f93d64f7e207f96157665a2bb232f6956
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 0090cba..16b2bcc 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -447,9 +447,7 @@ static void gfx_v10_0_check_gfxoff_flag(struct 
amdgpu_device *adev)
 {
switch (adev->asic_type) {
case CHIP_NAVI10:
-   if ((adev->gfx.rlc_fw_version < 85) ||
-   (adev->pm.fw_version < 0x002A0C00))
-   adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
+   adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
break;
default:
break;
-- 
2.7.4

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