[PATCH v3 1/2] drm/amd/pm: Add interface to get FW private buffer
Lazar, Lijo
Lijo.Lazar at amd.com
Fri Apr 16 04:20:36 UTC 2021
[AMD Public Use]
v1: Add new interface to get FW private buffer details
v2: Drop domain check
v3: Use amdgpu_bo_kmap to get cpu address
Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
Suggested-by: Alex Deucher <alexander.deucher at amd.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
Reviewed-by: Kevin Wang <kevin1.wang at amd.com>
---
.../gpu/drm/amd/include/kgd_pp_interface.h | 1 +
.../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 21 +++++++++++++++++++
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 21 +++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 353468667036..abd5a9d41d4c 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -350,6 +350,7 @@ struct amd_pm_funcs {
unsigned int *num_states);
int (*get_dpm_clock_table)(void *handle,
struct dpm_clocks *clock_table);
+ int (*get_smu_prv_buf_details)(void *handle, void **addr, size_t *size);
};
struct metrics_table_header {
diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index ee6340c6f921..c73504e998e5 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -1651,6 +1651,26 @@ static int pp_gfx_state_change_set(void *handle, uint32_t state)
return 0;
}
+static int pp_get_prv_buffer_details(void *handle, void **addr, size_t *size)
+{
+ struct pp_hwmgr *hwmgr = handle;
+ struct amdgpu_device *adev = hwmgr->adev;
+
+ if (!addr || !size)
+ return -EINVAL;
+
+ *addr = NULL;
+ *size = 0;
+ mutex_lock(&hwmgr->smu_lock);
+ if (adev->pm.smu_prv_buffer) {
+ amdgpu_bo_kmap(adev->pm.smu_prv_buffer, addr);
+ *size = adev->pm.smu_prv_buffer_size;
+ }
+ mutex_unlock(&hwmgr->smu_lock);
+
+ return 0;
+}
+
static const struct amd_pm_funcs pp_dpm_funcs = {
.load_firmware = pp_dpm_load_fw,
.wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
@@ -1714,4 +1734,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.set_xgmi_pstate = pp_set_xgmi_pstate,
.get_gpu_metrics = pp_get_gpu_metrics,
.gfx_state_change_set = pp_gfx_state_change_set,
+ .get_smu_prv_buf_details = pp_get_prv_buffer_details,
};
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index e0eb7ca112e2..849a85ea84b9 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -2932,6 +2932,26 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable)
return ret;
}
+static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)
+{
+ struct smu_context *smu = handle;
+ struct smu_table_context *smu_table = &smu->smu_table;
+ struct smu_table *memory_pool = &smu_table->memory_pool;
+
+ if (!addr || !size)
+ return -EINVAL;
+
+ *addr = NULL;
+ *size = 0;
+ mutex_lock(&smu->mutex);
+ if (memory_pool->bo) {
+ *addr = memory_pool->cpu_addr;
+ *size = memory_pool->size;
+ }
+ mutex_unlock(&smu->mutex);
+
+ return 0;
+}
static const struct amd_pm_funcs swsmu_pm_funcs = {
/* export for sysfs */
@@ -2983,6 +3003,7 @@ static const struct amd_pm_funcs swsmu_pm_funcs = {
.get_max_sustainable_clocks_by_dc = smu_get_max_sustainable_clocks_by_dc,
.load_firmware = smu_load_microcode,
.gfx_state_change_set = smu_gfx_state_change_set,
+ .get_smu_prv_buf_details = smu_get_prv_buffer_details,
};
int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
--
2.17.1
More information about the amd-gfx
mailing list