[PATCH] drm/amdgpu: Expose an IP function to get register offset

Deucher, Alexander Alexander.Deucher at amd.com
Tue Oct 30 21:07:14 UTC 2018


> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Oak
> Zeng
> Sent: Tuesday, October 30, 2018 4:41 PM
> To: amd-gfx at lists.freedesktop.org
> Cc: Zeng, Oak <Oak.Zeng at amd.com>
> Subject: [PATCH] drm/amdgpu: Expose an IP function to get register offset
> 
> Expose get_reg_offset function of sdma_v4_0 for kfd to use
> 
> Change-Id: Ib687b390d6d3f8c8a35651e064e35aacf6722f98
> Signed-off-by: Oak Zeng <Oak.Zeng at amd.com>

First, split something like this into two patches, one to add the new API, one to add the implementations.
Next how are you planning to use this?  Do you have plans to add this for other IPs as well, or is it just a one off for
sdma?  I'd rather not a new functionality at the IP level as a one-off for one IP.  The implementation is trivial; it's just a wrapper around an array lookup.
It's probably easier to just implement the same thing in kfd rather than adding a new callback.  Or even make a generic wrapper  e.g.,

amdgpu_device_ip_get_reg_offset(hwip, instance, seg, offset)
{
    return adev->reg_offset[hwip][instance][seg] + offset;
}

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 7 +++++++
>  drivers/gpu/drm/amd/include/amd_shared.h | 3 +++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> index f35f578..1b6c591 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> @@ -206,6 +206,12 @@ static u32 sdma_v4_0_get_reg_offset(struct
> amdgpu_device *adev,
>  	return 0;
>  }
> 
> +static u32 sdma_v4_0_get_reg_offset_external(void *handle, u32
> +instance, u32 offset) {
> +	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> +	return sdma_v4_0_get_reg_offset(adev, instance, offset); }
> +
>  static unsigned sdma_v4_0_seq_to_irq_id(int seq_num)  {
>  	switch (seq_num) {
> @@ -1746,6 +1752,7 @@ const struct amd_ip_funcs sdma_v4_0_ip_funcs = {
>  	.set_clockgating_state = sdma_v4_0_set_clockgating_state,
>  	.set_powergating_state = sdma_v4_0_set_powergating_state,
>  	.get_clockgating_state = sdma_v4_0_get_clockgating_state,
> +	.get_reg_offset = sdma_v4_0_get_reg_offset_external,
>  };
> 
>  static const struct amdgpu_ring_funcs sdma_v4_0_ring_funcs = { diff --git
> a/drivers/gpu/drm/amd/include/amd_shared.h
> b/drivers/gpu/drm/amd/include/amd_shared.h
> index fc7fcb1..ab44fa8 100644
> --- a/drivers/gpu/drm/amd/include/amd_shared.h
> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> @@ -173,6 +173,9 @@ struct amd_ip_funcs {
>  				     enum amd_powergating_state state);
>  	/* get current clockgating status */
>  	void (*get_clockgating_state)(void *handle, u32 *flags);
> +
> +	/* get instance's register offset */
> +	u32 (*get_reg_offset)(void *handle, u32 instance, u32 offset);
>  };
> 
> 
> --
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list