From: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
To: Vasant Hegde <vasant.hegde@amd.com>,
joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org,
robin.murphy@arm.com, linux-kernel@vger.kernel.org,
iommu@lists.linux.dev
Subject: Re: [PATCH v3 4/8] iommu/amd: Add debugfs support to dump IOMMU command buffer
Date: Mon, 17 Mar 2025 16:54:20 +0530 [thread overview]
Message-ID: <4ebbf7c1-c3ee-4375-b65a-a242f1c5e75c@amd.com> (raw)
In-Reply-To: <014da701-dc74-4082-98b0-378da8ebbfd0@amd.com>
Hi Vasant,
On 3/13/2025 4:08 PM, Vasant Hegde wrote:
> Dheeraj,
>
>
> On 2/6/2025 11:29 AM, Dheeraj Kumar Srivastava wrote:
>> IOMMU driver sends command to IOMMU hardware via command buffer. In cases
>> where IOMMU hardware fails to process commands in command buffer, dumping
>> it is a valuable input to debug the issue.
>>
>> IOMMU hardware processes command buffer entry at offset equals to the head
>> pointer. Dumping just the entry at the head pointer may not always be
>> useful. The current head may not be pointing to the entry of the command
>> buffer which is causing the issue. IOMMU Hardware may have processed the
>> entry and updated the head pointer. So dumping the entire command buffer
>> gives a broad understanding of what hardware was/is doing. The command
>> buffer dump will have all entries from start to end of the command buffer.
>> Along with that, it will have a head and tail command buffer pointer
>> register dump to facilitate where the IOMMU driver and hardware are in
>> the command buffer for injecting and processing the entries respectively.
>>
>> Command buffer is a per IOMMU data structure. So dumping on per IOMMU
>> basis.
>> eg. To get command buffer dump for iommu<x>
>> #cat /sys/kernel/debug/iommu/amd/iommu<x>/cmdbuf
>>
>> Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
>> ---
>> drivers/iommu/amd/amd_iommu_types.h | 7 +++++++
>> drivers/iommu/amd/debugfs.c | 26 ++++++++++++++++++++++++++
>> drivers/iommu/amd/iommu.c | 7 -------
>> 3 files changed, 33 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
>> index 0bbda60d3cdc..c4ca6d9c6b51 100644
>> --- a/drivers/iommu/amd/amd_iommu_types.h
>> +++ b/drivers/iommu/amd/amd_iommu_types.h
>> @@ -892,6 +892,13 @@ struct dev_table_entry {
>> };
>> };
>>
>> +/*
>> + * Structure defining one entry in the command buffer
>> + */
>> +struct iommu_cmd {
>> + u32 data[4];
>> +};
>> +
>> /*
>> * Structure to sture persistent DTE flags from IVHD
>> */
>> diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c
>> index dc5fdc905754..bf718e7258c5 100644
>> --- a/drivers/iommu/amd/debugfs.c
>> +++ b/drivers/iommu/amd/debugfs.c
>> @@ -103,6 +103,30 @@ static int iommu_capability_show(struct seq_file *m, void *unused)
>> }
>> DEFINE_SHOW_STORE_ATTRIBUTE(iommu_capability);
>>
>> +static int iommu_cmdbuf_show(struct seq_file *m, void *unused)
>> +{
>> + struct amd_iommu *iommu = m->private;
>> + struct iommu_cmd *cmd;
>> + unsigned long flag;
>> + u32 head, tail;
>> + int i;
>> +
>> + raw_spin_lock_irqsave(&iommu->lock, flag);
>> + head = readl(iommu->mmio_base + MMIO_CMD_HEAD_OFFSET);
>> + tail = readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
>> + seq_printf(m, "CMD Buffer Head Offset:%d Tail Offset:%d\n",
>> + (head >> 4) & 0x7fff, (tail >> 4) & 0x7fff);
>> + for (i = 0; i < CMD_BUFFER_ENTRIES; i++) {
>> + cmd = (struct iommu_cmd *)(iommu->cmd_buf + i * sizeof(*cmd));
>> + seq_printf(m, "%3d: %08x%08x%08x%08x\n", i, cmd->data[0],
>
> Can you give space between words so that its easy to read?
>
Sure. Will update in v4.
Thanks
Dheeraj
> -Vasant
>
>
next prev parent reply other threads:[~2025-03-17 11:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 5:59 [PATCH v3 0/8] Introduce debugfs support in IOMMU Dheeraj Kumar Srivastava
2025-02-06 5:59 ` [PATCH v3 1/8] iommu/amd: Refactor AMD IOMMU debugfs initial setup Dheeraj Kumar Srivastava
2025-03-13 10:27 ` Vasant Hegde
2025-02-06 5:59 ` [PATCH v3 2/8] iommu/amd: Add debugfs support to dump IOMMU MMIO registers Dheeraj Kumar Srivastava
2025-03-13 10:28 ` Vasant Hegde
2025-03-17 11:22 ` Dheeraj Kumar Srivastava
2025-02-06 5:59 ` [PATCH v3 3/8] iommu/amd: Add debugfs support to dump IOMMU Capability registers Dheeraj Kumar Srivastava
2025-03-13 10:32 ` Vasant Hegde
2025-03-17 11:23 ` Dheeraj Kumar Srivastava
2025-02-06 5:59 ` [PATCH v3 4/8] iommu/amd: Add debugfs support to dump IOMMU command buffer Dheeraj Kumar Srivastava
2025-03-13 10:38 ` Vasant Hegde
2025-03-17 11:24 ` Dheeraj Kumar Srivastava [this message]
2025-02-06 6:00 ` [PATCH v3 5/8] iommu/amd: Add support for device id user input Dheeraj Kumar Srivastava
2025-03-13 10:52 ` Vasant Hegde
2025-03-17 11:25 ` Dheeraj Kumar Srivastava
2025-02-06 6:00 ` [PATCH v3 6/8] iommu/amd: Add debugfs support to dump device table Dheeraj Kumar Srivastava
2025-02-06 6:00 ` [PATCH v3 7/8] iommu/amd: Add debugfs support to dump IRT Table Dheeraj Kumar Srivastava
2025-03-13 11:03 ` Vasant Hegde
2025-03-17 11:26 ` Dheeraj Kumar Srivastava
2025-02-06 6:00 ` [PATCH v3 8/8] iommu/amd: Add documentation for AMD IOMMU debugfs support Dheeraj Kumar Srivastava
2025-02-06 8:56 ` [PATCH v3 0/8] Introduce debugfs support in IOMMU Suthikulpanit, Suravee
2025-03-07 8:17 ` Dheeraj Kumar Srivastava
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=4ebbf7c1-c3ee-4375-b65a-a242f1c5e75c@amd.com \
--to=dheerajkumar.srivastava@amd.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=will@kernel.org \
/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.