From: "Christian König" <christian.koenig@amd.com>
To: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>,
amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, shashank.sharma@amd.com
Subject: Re: [PATCH v12 1/2] drm/amdgpu: add debugfs for reset registers list
Date: Tue, 22 Feb 2022 16:38:26 +0100 [thread overview]
Message-ID: <4fbd2956-c3f1-182d-fa4d-84206771bb30@amd.com> (raw)
In-Reply-To: <20220222153433.11464-1-Amaranath.Somalapuram@amd.com>
Am 22.02.22 um 16:34 schrieb Somalapuram Amaranath:
> List of register populated for dump collection during the GPU reset.
>
> Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 83 +++++++++++++++++++++
> 2 files changed, 87 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index b85b67a88a3d..6e35f2c4c869 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1097,6 +1097,10 @@ struct amdgpu_device {
>
> struct amdgpu_reset_control *reset_cntl;
> uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE];
> +
> + /* reset dump register */
> + uint32_t *reset_dump_reg_list;
> + int num_regs;
> };
>
> static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 164d6a9e9fbb..0cc80aa1b5ec 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -1609,6 +1609,87 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,
> DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL,
> amdgpu_debugfs_sclk_set, "%llu\n");
>
> +static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,
> + char __user *buf, size_t size, loff_t *pos)
> +{
> + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
> + char reg_offset[11];
> + int i, ret, len = 0;
> +
> + if (*pos)
> + return 0;
> +
> + ret = down_read_killable(&adev->reset_sem);
> + if (ret)
> + return ret;
> +
> + for (i = 0; i < adev->num_regs; i++) {
> + sprintf(reg_offset, "0x%x\n", adev->reset_dump_reg_list[i]);
> + up_read(&adev->reset_sem);
> + ret = copy_to_user(buf + len, reg_offset, strlen(reg_offset));
> + if (ret)
> + return -EFAULT;
> +
> + len += strlen(reg_offset);
> + ret = down_read_killable(&adev->reset_sem);
> + if (ret)
> + return ret;
> + }
> +
> + up_read(&adev->reset_sem);
> + if (ret)
> + return ret;
That if and return now looks superfluous.
> +
> + *pos += len;
> +
> + return len;
> +}
> +
> +static ssize_t amdgpu_reset_dump_register_list_write(struct file *f,
> + const char __user *buf, size_t size, loff_t *pos)
> +{
> + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
> + char reg_offset[12];
> + uint32_t *tmp;
> + int ret, i = 0, len = 0;
> +
> + do {
> + memset(reg_offset, 0, 12);
> + if (copy_from_user(reg_offset, buf + len,
> + min(11, ((int)size-len)))) {
> + ret = -EFAULT;
> + goto error_free;
> + }
> +
> + tmp = krealloc_array(tmp, i + 1, sizeof(uint32_t), GFP_KERNEL);
> + if (sscanf(reg_offset, "%X %n", &tmp[i], &ret) != 1)
Does this also work when we write the registers separated with newlines
into the debugfs file?
Regards,
Christian.
> + goto error_free;
> +
> + len += ret;
> + i++;
> + } while (len < size);
> +
> + ret = down_write_killable(&adev->reset_sem);
> + if (ret)
> + goto error_free;
> +
> + swap(adev->reset_dump_reg_list, tmp);
> + adev->num_regs = i;
> + up_write(&adev->reset_sem);
> + ret = size;
> +
> +error_free:
> + kfree(tmp);
> + return ret;
> +}
> +
> +static const struct file_operations amdgpu_reset_dump_register_list = {
> + .owner = THIS_MODULE,
> + .read = amdgpu_reset_dump_register_list_read,
> + .write = amdgpu_reset_dump_register_list_write,
> + .llseek = default_llseek
> +};
> +
> int amdgpu_debugfs_init(struct amdgpu_device *adev)
> {
> struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;
> @@ -1672,6 +1753,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
> &amdgpu_debugfs_test_ib_fops);
> debugfs_create_file("amdgpu_vm_info", 0444, root, adev,
> &amdgpu_debugfs_vm_info_fops);
> + debugfs_create_file("amdgpu_reset_dump_register_list", 0644, root, adev,
> + &amdgpu_reset_dump_register_list);
>
> adev->debugfs_vbios_blob.data = adev->bios;
> adev->debugfs_vbios_blob.size = adev->bios_size;
next prev parent reply other threads:[~2022-02-22 15:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 15:34 [PATCH v12 1/2] drm/amdgpu: add debugfs for reset registers list Somalapuram Amaranath
2022-02-22 15:34 ` [PATCH v12 2/2] drm/amdgpu: add reset register dump trace on GPU Somalapuram Amaranath
2022-02-22 15:38 ` Christian König [this message]
2022-02-22 15:44 ` [PATCH v12 1/2] drm/amdgpu: add debugfs for reset registers list Somalapuram, Amaranath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4fbd2956-c3f1-182d-fa4d-84206771bb30@amd.com \
--to=christian.koenig@amd.com \
--cc=Amaranath.Somalapuram@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=shashank.sharma@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.