On Wed, Dec 3, 2025 at 8:44 AM Lijo Lazar <[email protected]> wrote:
>
> Add a helper function to get the number of XCCs given a parition id. If
> there is no partition manager, return 1 as default.
>
> Signed-off-by: Lijo Lazar <[email protected]>

Reviewed-by: Alex Deucher <[email protected]>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h
> index 8058e8f35d41..b780c12b07e0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h
> @@ -217,4 +217,26 @@ amdgpu_get_next_xcp(struct amdgpu_xcp_mgr *xcp_mgr, int 
> *from)
>         for (i = 0, xcp = amdgpu_get_next_xcp(xcp_mgr, &i); xcp; \
>              ++i, xcp = amdgpu_get_next_xcp(xcp_mgr, &i))
>
> +static inline int amdgpu_xcp_get_num_xcc(struct amdgpu_xcp_mgr *xcp_mgr,
> +                                        int xcp_id)
> +{
> +       struct amdgpu_xcp *xcp;
> +       uint32_t xcc_mask;
> +       int i, r;
> +
> +       if (!xcp_mgr || xcp_id == AMDGPU_XCP_NO_PARTITION)
> +               return 1;
> +       for_each_xcp(xcp_mgr, xcp, i) {
> +               if (xcp->id == xcp_id) {
> +                       r = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_GFX,
> +                                                       &xcc_mask);
> +                       if (unlikely(r))
> +                               return 1;
> +                       else
> +                               return hweight32(xcc_mask);
> +               }
> +       }
> +
> +       return 1;
> +}
>  #endif
> --
> 2.49.0
>

Reply via email to