[RFC PATCH 3/5] iommu/arm-smmu-v3: Add Stream Table Entry display to debugfs
Qinxin Xia
xiaqinxin at huawei.com
Mon Mar 16 08:43:03 PDT 2026
On 2026/3/14 04:19:14, Nicolin Chen <nicolinc at nvidia.com> wrote:
> On Fri, Mar 13, 2026 at 06:43:49PM +0800, Qinxin Xia wrote:
>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c
>> @@ -43,6 +49,8 @@
>> */
>>
>> #include <linux/debugfs.h>
>> +#include <linux/pci.h>
>
> It doesn't seem being used (yet).
>
>> +static struct arm_smmu_ste *smmu_get_ste(struct arm_smmu_device *smmu, u32 sid)
>> +{
>> + struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
>> +
>> + if (sid >= (1 << smmu->sid_bits))
>> + return NULL;
>> +
>> + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) {
>> + u32 l1_idx = arm_smmu_strtab_l1_idx(sid);
>> + u32 l2_idx = arm_smmu_strtab_l2_idx(sid);
>> +
>> + if (l1_idx >= cfg->l2.num_l1_ents || !cfg->l2.l2ptrs[l1_idx])
>> + return NULL;
>> +
>> + return &cfg->l2.l2ptrs[l1_idx]->stes[l2_idx];
>> + }
>> +
>> + return &cfg->linear.table[sid];
>> +}
>
> arm_smmu_get_step_for_sid() instead?
>
>> +/**
>> + * smmu_debug_dump_ste() - Dump STE details to seq_file
>> + * @seq: seq_file to write to
>> + * @dev: device associated with the STE
>> + */
>> +static void smmu_debug_dump_ste(struct seq_file *seq, struct device *dev)
>> +{
>> + struct arm_smmu_master *master = dev_iommu_priv_get(dev);
>> + struct arm_smmu_device *smmu;
>> + struct arm_smmu_ste *ste;
>> + u32 sid, cfg;
>> + int i;
>> +
>> + if (!master || !master->smmu) {
>> + seq_puts(seq, "No SMMU master data\n");
>> + return;
>> + }
>> +
>> + smmu = master->smmu;
>> +
>> + /* Use first stream ID for debug */
>> + if (master->num_streams == 0) {
>> + seq_puts(seq, "No streams configured for device\n");
>> + return;
>> + }
>> + sid = master->streams[0].id;
>
> These might race with release_device that would destroy master?
>
Can we lock streams_mutex here?
>> +
>> + if (sid >= (1 << smmu->sid_bits)) {
>> + seq_printf(seq, "Invalid Stream ID: %u (max %u)\n",
>> + sid, (1 << smmu->sid_bits) - 1);
>> + return;
>> + }
>
> arm_smmu_sid_in_range() instead?
>
>> +/* STE debugfs file operations */
>> +static int smmu_debugfs_ste_show(struct seq_file *seq, void *v)
>> +{
>> + struct device *dev = seq->private;
>> +
>> + smmu_debug_dump_ste(seq, dev);
>> + return 0;
>
> Could unwrap smmu_debug_dump_ste().
>
> Nicolin
>
As above, I will do clean code in the next version.
--
Thanks,
Qinxin
More information about the linux-arm-kernel
mailing list