<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 5/26/2022 3:24 PM, Sharma, Shashank
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:483cf4d0-ef9d-ea0c-e0ea-8c006051ba55@amd.com">Hey Amar,
      <br>
      <br>
      On 5/26/2022 11:48 AM, Somalapuram Amaranath wrote:
      <br>
      <blockquote type="cite">Allocate memory for register value and use
        the same values for devcoredump.
        <br>
        v1 -> V2: Change krealloc_array() to kmalloc_array()
        <br>
        <br>
        Signed-off-by: Somalapuram Amaranath
        <a class="moz-txt-link-rfc2396E" href="mailto:Amaranath.Somalapuram@amd.com"><Amaranath.Somalapuram@amd.com></a>
        <br>
        ---
        <br>
          drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 1 +
        <br>
          drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
        <br>
          drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 6 +++---
        <br>
          3 files changed, 11 insertions(+), 3 deletions(-)
        <br>
        <br>
        diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
        b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
        <br>
        index 76df583663c7..c79d9992b113 100644
        <br>
        --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
        <br>
        +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
        <br>
        @@ -1042,6 +1042,7 @@ struct amdgpu_device {
        <br>
                /* reset dump register */
        <br>
              uint32_t                        *reset_dump_reg_list;
        <br>
        +    uint32_t            *reset_dump_reg_value;
        <br>
              int                             num_regs;
        <br>
                struct amdgpu_reset_domain    *reset_domain;
        <br>
        diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
        b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
        <br>
        index eedb12f6b8a3..f3ac7912c29c 100644
        <br>
        --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
        <br>
        +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
        <br>
        @@ -1709,17 +1709,24 @@ static ssize_t
        amdgpu_reset_dump_register_list_write(struct file *f,
        <br>
                  i++;
        <br>
              } while (len < size);
        <br>
          +    new = kmalloc_array(i, sizeof(uint32_t), GFP_KERNEL);
        <br>
        +    if (!new) {
        <br>
        +        ret = -ENOMEM;
        <br>
        +        goto error_free;
        <br>
        +    }
        <br>
              ret =
        down_write_killable(&adev->reset_domain->sem);
        <br>
              if (ret)
        <br>
                  goto error_free;
        <br>
                swap(adev->reset_dump_reg_list, tmp);
        <br>
        +    swap(adev->reset_dump_reg_value, new);
        <br>
              adev->num_regs = i;
        <br>
              up_write(&adev->reset_domain->sem);
        <br>
              ret = size;
        <br>
            error_free:
        <br>
              kfree(tmp);
        <br>
        +    kfree(new);
        <br>
              return ret;
        <br>
          }
        <br>
          diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
        b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
        <br>
        index 4daa0e893965..866b4980a6fa 100644
        <br>
        --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
        <br>
        +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
        <br>
        @@ -4720,15 +4720,15 @@ int amdgpu_device_pre_asic_reset(struct
        amdgpu_device *adev,
        <br>
            static int amdgpu_reset_reg_dumps(struct amdgpu_device
        *adev)
        <br>
          {
        <br>
        -    uint32_t reg_value;
        <br>
              int i;
        <br>
                lockdep_assert_held(&adev->reset_domain->sem);
        <br>
              dump_stack();
        <br>
                for (i = 0; i < adev->num_regs; i++) {
        <br>
        -        reg_value = RREG32(adev->reset_dump_reg_list[i]);
        <br>
        -       
        trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list[i],
        reg_value);
        <br>
        +        adev->reset_dump_reg_value[i] =
        RREG32(adev->reset_dump_reg_list[i]);
        <br>
        +       
        trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list[i],
        <br>
        +                adev->reset_dump_reg_value[i]);
        <br>
      </blockquote>
    </blockquote>
    <p>Alignment is showing spaces in email. But its 2 tabs in code.</p>
    <img src="cid:part1.Xziuqf4a.c74LRdxP@amd.com" alt=""><br>
    Regards,<br>
    S.Amarnath
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:483cf4d0-ef9d-ea0c-e0ea-8c006051ba55@amd.com">Please fix
      the alignment with the line above, after that, please feel free to
      use:
      <br>
      Reviewed-by: Shashank Sharma <a class="moz-txt-link-rfc2396E" href="mailto:shashank.sharma@amd.com"><shashank.sharma@amd.com></a>
      <br>
      <br>
      - Shashank
      <br>
      <blockquote type="cite">      }
        <br>
                return 0;
        <br>
      </blockquote>
    </blockquote>
  </body>
</html>