Messages in this thread | | | Date | Mon, 21 Aug 2023 15:06:07 +0200 | Subject | Re: [PATCH v2 1/7] drm/amdgpu: Added init/fini functions for workload | From | Shashank Sharma <> |
| |
Hey Arvind,
On 21/08/2023 08:47, Arvind Yadav wrote: > The'struct amdgpu_smu_workload' initialization/cleanup > functions is added by this patch. > > v2: > - Splitting big patch into separate patches. > - Added new fini function. > > Cc: Shashank Sharma <shashank.sharma@amd.com> > Cc: Christian Koenig <christian.koenig@amd.com> > Cc: Alex Deucher <alexander.deucher@amd.com> > Signed-off-by: Arvind Yadav <Arvind.Yadav@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c | 44 +++++++++++++++ > drivers/gpu/drm/amd/include/amdgpu_workload.h | 53 +++++++++++++++++++ > 5 files changed, 105 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c > create mode 100644 drivers/gpu/drm/amd/include/amdgpu_workload.h > > diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile > index 415a7fa395c4..6a9e187d61e1 100644 > --- a/drivers/gpu/drm/amd/amdgpu/Makefile > +++ b/drivers/gpu/drm/amd/amdgpu/Makefile > @@ -60,7 +60,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ > amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \ > amdgpu_fw_attestation.o amdgpu_securedisplay.o \ > amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \ > - amdgpu_ring_mux.o > + amdgpu_ring_mux.o amdgpu_workload.o > > amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 02b827785e39..1939fa1af8a6 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -107,6 +107,7 @@ > #include "amdgpu_fdinfo.h" > #include "amdgpu_mca.h" > #include "amdgpu_ras.h" > +#include "amdgpu_workload.h" > > #define MAX_GPU_INSTANCE 16 > > @@ -1050,6 +1051,8 @@ struct amdgpu_device { > > bool job_hang; > bool dc_enabled; > + > + struct amdgpu_smu_workload smu_workload; > }; > > static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 5c7d40873ee2..cd3bf641b630 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -2243,6 +2243,8 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) > adev->cg_flags &= amdgpu_cg_mask; > adev->pg_flags &= amdgpu_pg_mask; > > + amdgpu_workload_profile_init(adev); > + > return 0; > } > > @@ -2890,6 +2892,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) > { > int i, r; > > + amdgpu_workload_profile_fini(adev); > + > if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done) > amdgpu_virt_release_ras_err_handler_data(adev); > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c > new file mode 100644 > index 000000000000..32166f482f77 > --- /dev/null > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_workload.c > @@ -0,0 +1,44 @@ > +// SPDX-License-Identifier: MIT > +/* > + * Copyright 2023 Advanced Micro Devices, Inc. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + */ > + > +#include "amdgpu.h" > + > +void amdgpu_workload_profile_init(struct amdgpu_device *adev) > +{ > + adev->smu_workload.adev = adev; > + adev->smu_workload.submit_workload_status = 0; > + adev->smu_workload.initialized = true; why do we need this variable ? > + > + mutex_init(&adev->smu_workload.workload_lock); > +} > + > +void amdgpu_workload_profile_fini(struct amdgpu_device *adev) > +{ > + if (!adev->smu_workload.initialized) > + return; > + > + adev->smu_workload.submit_workload_status = 0; > + adev->smu_workload.initialized = false; > + mutex_destroy(&adev->smu_workload.workload_lock); > +} > diff --git a/drivers/gpu/drm/amd/include/amdgpu_workload.h b/drivers/gpu/drm/amd/include/amdgpu_workload.h > new file mode 100644 > index 000000000000..5d0f068422d4 > --- /dev/null > +++ b/drivers/gpu/drm/amd/include/amdgpu_workload.h > @@ -0,0 +1,53 @@ > +/* SPDX-License-Identifier: MIT */ > +/* > + * Copyright 2023 Advanced Micro Devices, Inc. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + */ > + > +#ifndef _AMDGPU_WORKLOAD_H_ > +#define _AMDGPU_WORKLOAD_H_ > + > +struct amdgpu_smu_workload { > + struct amdgpu_device *adev; > + struct mutex workload_lock; > + struct delayed_work smu_delayed_work;
call it power_profile_work instead ? Looks good otherwise.
- Shashank
> + uint32_t submit_workload_status; > + bool initialized; > + atomic_t power_profile_ref[PP_SMC_POWER_PROFILE_COUNT]; > +}; > + > +/* Workload mode names */ > +static const char * const amdgpu_workload_mode_name[] = { > + "Default", > + "3D", > + "Powersaving", > + "Video", > + "VR", > + "Compute", > + "Custom", > + "Window3D" > +}; > + > +void amdgpu_workload_profile_init(struct amdgpu_device *adev); > + > +void amdgpu_workload_profile_fini(struct amdgpu_device *adev); > + > +#endif
| |