public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Qinxin Xia <xiaqinxin@huawei.com>
Cc: <will@kernel.org>, <robin.murphy@arm.com>, <jpb@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux.dev>,
	<wangzhou1@hisilicon.com>, <prime.zeng@hisilicon.com>,
	<fanghao11@huawei.com>, <jonathan.cameron@huawei.com>,
	<linuxarm@huawei.com>
Subject: Re: [RFC PATCH 4/5] iommu/arm-smmu-v3: Add stream table directory structure to debugfs
Date: Fri, 13 Mar 2026 13:44:49 -0700	[thread overview]
Message-ID: <abR3QXHGAWz9E6qV@Asurada-Nvidia> (raw)
In-Reply-To: <20260313104351.3502293-5-xiaqinxin@huawei.com>

On Fri, Mar 13, 2026 at 06:43:50PM +0800, Qinxin Xia wrote:
>   * The capabilities file provides detailed information about:
>   * - Architecture version and translation stage support (Stage1/Stage2)
> @@ -324,5 +327,78 @@ static int smmu_debugfs_ste_show(struct seq_file *seq, void *v)
>  	smmu_debug_dump_ste(seq, dev);
>  	return 0;
>  }
> -
>  DEFINE_SHOW_ATTRIBUTE(smmu_debugfs_ste);

nit: let's not add that line in the first place

> +
> +/**
> + * smmu_debugfs_create_stream_table() - Create debugfs entries for stream table
> + * @dev: device to create entries for
> + * @smmu: SMMU device
> + *
> + * Return: 0 on success, negative error code on failure
> + */
> +int smmu_debugfs_create_stream_table(struct device *dev,
> +				     struct arm_smmu_device *smmu)
> +{
> +	struct dentry *stream_dir, *cd_dir, *dev_dir;
> +	struct dentry *ste_file, *all_cds_file;
> +	struct iommu_fwspec *fwspec;
> +	char name[64];
> +	int i, ret = 0;
> +
> +	if (!smmu->debugfs->stream_dir) {
> +		stream_dir = debugfs_create_dir("stream_table",
> +						smmu->debugfs->smmu_dir);
> +		if (!stream_dir)
> +			return -ENOMEM;
> +		smmu->debugfs->stream_dir = stream_dir;
> +	} else {
> +		stream_dir = smmu->debugfs->stream_dir;
> +	}
> +
> +	fwspec = dev_iommu_fwspec_get(dev);
> +	if (!fwspec)
> +		return -ENODEV;
> +
> +	for (i = 0; i < fwspec->num_ids; i++) {
> +		u32 sid = fwspec->ids[i];
> +
> +		if (dev_is_pci(dev)) {
> +			struct pci_dev *pdev = to_pci_dev(dev);
> +
> +			snprintf(name, sizeof(name), "%04x:%02x:%02x.%d:%u",
> +				 pci_domain_nr(pdev->bus), pdev->bus->number,
> +				 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
> +				 sid);

Doesn't dev_name(dev) print the BDF numbers as well?

> +		} else {
> +			snprintf(name, sizeof(name), "%s:%u", dev_name(dev),
> +				 sid);
> +		}
> +
> +		dev_dir = debugfs_create_dir(name, stream_dir);
> +		if (!dev_dir) {
> +			ret = -ENOMEM;
> +			goto cleanup;
> +		}

A device can have multiple streams. So, dev_dir should be the
parent directory?

> +
> +		/* Success for this stream ID, continue to next */
> +		continue;
> +
> +cleanup_dev:
> +		debugfs_remove_recursive(dev_dir);
> +cleanup:
> +		if (ret) {
> +			debugfs_remove_recursive(stream_dir);

One is the other's parent directory. So it should be good enough
with a single debugfs_remove_recursive()?

> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 211a0c87507a..c57897e5f644 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -3133,6 +3133,9 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev,
>  
>  	arm_smmu_attach_commit(&state);
>  	mutex_unlock(&arm_smmu_asid_lock);
> +#ifdef CONFIG_ARM_SMMU_V3_DEBUGFS
> +	smmu_debugfs_create_stream_table(dev, smmu);
> +#endif

Calling in attach_dev doesn't seem correct to me. And device/master
can be unplugged. So, we would need to unwind those dev/stream_dir.

Maybe probe_device/release_device are the places to go?

Nicolin


  reply	other threads:[~2026-03-13 20:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 10:43 [RFC PATCH 0/5] Add debugfs support for ARM SMMUv3 Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 1/5] iommu/arm-smmu-v3: Add basic debugfs framework Qinxin Xia
2026-03-13 19:58   ` Nicolin Chen
2026-03-16 15:14     ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 2/5] iommu/arm-smmu-v3: Add register display to debugfs Qinxin Xia
2026-03-13 20:20   ` Nicolin Chen
2026-03-16 15:22     ` Qinxin Xia
2026-03-16 15:19   ` Robin Murphy
2026-03-16 15:35     ` Qinxin Xia
2026-03-16 16:26       ` Robin Murphy
2026-03-17  1:44         ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 3/5] iommu/arm-smmu-v3: Add Stream Table Entry " Qinxin Xia
2026-03-13 20:19   ` Nicolin Chen
2026-03-16 15:43     ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 4/5] iommu/arm-smmu-v3: Add stream table directory structure " Qinxin Xia
2026-03-13 20:44   ` Nicolin Chen [this message]
2026-03-16 14:57     ` Qinxin Xia
2026-03-16 16:01   ` Robin Murphy
2026-03-17  2:04     ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 5/5] iommu/arm-smmu-v3: Add Context Descriptor display " Qinxin Xia
2026-03-13 21:04   ` Nicolin Chen
2026-03-16 15:12     ` Qinxin Xia
2026-03-16 15:42   ` Robin Murphy
2026-03-17  2:14     ` Qinxin Xia

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=abR3QXHGAWz9E6qV@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=fanghao11@huawei.com \
    --cc=iommu@lists.linux.dev \
    --cc=jonathan.cameron@huawei.com \
    --cc=jpb@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxarm@huawei.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=robin.murphy@arm.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=will@kernel.org \
    --cc=xiaqinxin@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox