Skip to content

Commit

Permalink
drm/amdgpu: Add gmc interface to request NPS mode
Browse files Browse the repository at this point in the history
Add a common interface in GMC to request NPS mode through PSP. Also add
a variable in hive and gmc control to track the last requested mode.

Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Lijo Lazar authored and Alex Deucher committed Oct 7, 2024
1 parent b1cf3dd commit bbc1600
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,3 +1235,19 @@ int amdgpu_gmc_get_nps_memranges(struct amdgpu_device *adev,

return ret;
}

int amdgpu_gmc_request_memory_partition(struct amdgpu_device *adev,
int nps_mode)
{
/* Not supported on VF devices and APUs */
if (amdgpu_sriov_vf(adev) || (adev->flags & AMD_IS_APU))
return -EOPNOTSUPP;

if (!adev->psp.funcs) {
dev_err(adev->dev,
"PSP interface not available for nps mode change request");
return -EINVAL;
}

return psp_memory_partition(&adev->psp, nps_mode);
}
6 changes: 6 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ struct amdgpu_gmc_funcs {

enum amdgpu_memory_partition (*query_mem_partition_mode)(
struct amdgpu_device *adev);
/* Request NPS mode */
int (*request_mem_partition_mode)(struct amdgpu_device *adev,
int nps_mode);
};

struct amdgpu_xgmi_ras {
Expand Down Expand Up @@ -304,6 +307,7 @@ struct amdgpu_gmc {
struct amdgpu_mem_partition_info *mem_partitions;
uint8_t num_mem_partitions;
const struct amdgpu_gmc_funcs *gmc_funcs;
enum amdgpu_memory_partition requested_nps_mode;

struct amdgpu_xgmi xgmi;
struct amdgpu_irq_src ecc_irq;
Expand Down Expand Up @@ -454,4 +458,6 @@ int amdgpu_gmc_get_nps_memranges(struct amdgpu_device *adev,
struct amdgpu_mem_partition_info *mem_ranges,
int exp_ranges);

int amdgpu_gmc_request_memory_partition(struct amdgpu_device *adev,
int nps_mode);
#endif
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)
task_barrier_init(&hive->tb);
hive->pstate = AMDGPU_XGMI_PSTATE_UNKNOWN;
hive->hi_req_gpu = NULL;
atomic_set(&hive->requested_nps_mode, UNKNOWN_MEMORY_PARTITION_MODE);

/*
* hive pstate on boot is high in vega20 so we have to go to low
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct amdgpu_hive_info {
atomic_t ras_recovery;
struct ras_event_manager event_mgr;
struct work_struct reset_on_init_work;
atomic_t requested_nps_mode;
};

struct amdgpu_pcs_ras_field {
Expand Down

0 comments on commit bbc1600

Please sign in to comment.