<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 10/17/2024 5:50 PM, Christian König
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:1f534179-6ffe-446c-ba20-6b5ab4da8db3@gmail.com">Am
      17.10.24 um 12:06 schrieb Sunil Khatri:
      <br>
      <blockquote type="cite">Validate the function pointer for
        get_clockgating_state
        <br>
        before making a function call.
        <br>
      </blockquote>
      <br>
      Oh, I'm not sure if that is necessary or not. The NBIO, HDP and
      SMUIO functions are not IP specific.
      <br>
      <br>
    </blockquote>
    For many socs this check is added and only missing in the
    files/functions mentioned below. SOC where these functions are
    called are nv_common, soc15_common, soc21_common, soc24_common<br>
    eg: SOC15 already have these changes and its safe to add for other
    socs that i mentioned above.<br>
    <div style="color: #cccccc;background-color: #1f1f1f;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #dcdcaa;">soc15_common_get_clockgating_state

Regards
Sunil 
</span></div></div>
    <blockquote type="cite" cite="mid:1f534179-6ffe-446c-ba20-6b5ab4da8db3@gmail.com">Christian.
      <br>
      <br>
      <blockquote type="cite">
        <br>
        Signed-off-by: Sunil Khatri <a class="moz-txt-link-rfc2396E" href="mailto:sunil.khatri@amd.com"><sunil.khatri@amd.com></a>
        <br>
        ---
        <br>
          drivers/gpu/drm/amd/amdgpu/nv.c    | 9 ++++++---
        <br>
          drivers/gpu/drm/amd/amdgpu/soc21.c | 6 ++++--
        <br>
          drivers/gpu/drm/amd/amdgpu/soc24.c | 6 ++++--
        <br>
          3 files changed, 14 insertions(+), 7 deletions(-)
        <br>
        <br>
        diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c
        b/drivers/gpu/drm/amd/amdgpu/nv.c
        <br>
        index 6b72169be8f8..40c720b32c59 100644
        <br>
        --- a/drivers/gpu/drm/amd/amdgpu/nv.c
        <br>
        +++ b/drivers/gpu/drm/amd/amdgpu/nv.c
        <br>
        @@ -1084,11 +1084,14 @@ static void
        nv_common_get_clockgating_state(void *handle, u64 *flags)
        <br>
              if (amdgpu_sriov_vf(adev))
        <br>
                  *flags = 0;
        <br>
          -    adev->nbio.funcs->get_clockgating_state(adev,
        flags);
        <br>
        +    if (adev->nbio.funcs &&
        adev->nbio.funcs->get_clockgating_state)
        <br>
        +        adev->nbio.funcs->get_clockgating_state(adev,
        flags);
        <br>
          -    adev->hdp.funcs->get_clock_gating_state(adev,
        flags);
        <br>
        +    if (adev->hdp.funcs &&
        adev->hdp.funcs->get_clock_gating_state)
        <br>
        +        adev->hdp.funcs->get_clock_gating_state(adev,
        flags);
        <br>
          -    adev->smuio.funcs->get_clock_gating_state(adev,
        flags);
        <br>
        +    if (adev->smuio.funcs &&
        adev->smuio.funcs->get_clock_gating_state)
        <br>
        +        adev->smuio.funcs->get_clock_gating_state(adev,
        flags);
        <br>
          }
        <br>
            static const struct amd_ip_funcs nv_common_ip_funcs = {
        <br>
        diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c
        b/drivers/gpu/drm/amd/amdgpu/soc21.c
        <br>
        index 1c07ebdc0d1f..196286be35b4 100644
        <br>
        --- a/drivers/gpu/drm/amd/amdgpu/soc21.c
        <br>
        +++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
        <br>
        @@ -975,9 +975,11 @@ static void
        soc21_common_get_clockgating_state(void *handle, u64 *flags)
        <br>
          {
        <br>
              struct amdgpu_device *adev = (struct amdgpu_device
        *)handle;
        <br>
          -    adev->nbio.funcs->get_clockgating_state(adev,
        flags);
        <br>
        +    if (adev->nbio.funcs &&
        adev->nbio.funcs->get_clockgating_state)
        <br>
        +        adev->nbio.funcs->get_clockgating_state(adev,
        flags);
        <br>
          -    adev->hdp.funcs->get_clock_gating_state(adev,
        flags);
        <br>
        +    if (adev->hdp.funcs &&
        adev->hdp.funcs->get_clock_gating_state)
        <br>
        +        adev->hdp.funcs->get_clock_gating_state(adev,
        flags);
        <br>
          }
        <br>
            static const struct amd_ip_funcs soc21_common_ip_funcs = {
        <br>
        diff --git a/drivers/gpu/drm/amd/amdgpu/soc24.c
        b/drivers/gpu/drm/amd/amdgpu/soc24.c
        <br>
        index 3af10ef4b793..f4278a0fa8f7 100644
        <br>
        --- a/drivers/gpu/drm/amd/amdgpu/soc24.c
        <br>
        +++ b/drivers/gpu/drm/amd/amdgpu/soc24.c
        <br>
        @@ -564,9 +564,11 @@ static void
        soc24_common_get_clockgating_state(void *handle, u64 *flags)
        <br>
          {
        <br>
              struct amdgpu_device *adev = (struct amdgpu_device
        *)handle;
        <br>
          -    adev->nbio.funcs->get_clockgating_state(adev,
        flags);
        <br>
        +    if (adev->nbio.funcs &&
        adev->nbio.funcs->get_clockgating_state)
        <br>
        +        adev->nbio.funcs->get_clockgating_state(adev,
        flags);
        <br>
          -    adev->hdp.funcs->get_clock_gating_state(adev,
        flags);
        <br>
        +    if (adev->hdp.funcs &&
        adev->hdp.funcs->get_clock_gating_state)
        <br>
        +        adev->hdp.funcs->get_clock_gating_state(adev,
        flags);
        <br>
                return;
        <br>
          }
        <br>
      </blockquote>
      <br>
    </blockquote>
  </body>
</html>