lkml.org 
[lkml]   [2021]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH v7 6/6] iommu/tegra-smmu: Add pagetable mappings to debugfs
From
Date
Hi,

08.12.2021 11:47, Nicolin Chen пишет:
> This patch dumps all active mapping entries from pagetable to a
> debugfs directory named "mappings".
>
> Attaching an example:
>
> [SWGROUP: xusb_host] [as: (id: 5), (attr: R|W|-), (pd_dma: 0x0000000080005000)]
> {
> [index: 1023] 0xf0080040 (count: 52)
> {
> PTE RANGE | ATTR | PHYS | IOVA | SIZE
> [#913 , #913 ] | 0x7 | 0x0000000102674000 | 0x00000000fff91000 | 0x1000
> [#914 , #914 ] | 0x7 | 0x0000000102672000 | 0x00000000fff92000 | 0x1000
> [#915 , #915 ] | 0x7 | 0x0000000102671000 | 0x00000000fff93000 | 0x1000
> [#916 , #916 ] | 0x7 | 0x0000000102670000 | 0x00000000fff94000 | 0x1000
> [#921 , #921 ] | 0x7 | 0x00000000fcc00000 | 0x00000000fff99000 | 0x1000
> [#922 , #922 ] | 0x7 | 0x000000010266d000 | 0x00000000fff9a000 | 0x1000
> [#923 , #923 ] | 0x7 | 0x000000010266c000 | 0x00000000fff9b000 | 0x1000
> [#948 , #948 ] | 0x7 | 0x0000000102668000 | 0x00000000fffb4000 | 0x1000
> [#949 , #949 ] | 0x7 | 0x0000000102667000 | 0x00000000fffb5000 | 0x1000
> [#950 , #950 ] | 0x7 | 0x0000000102666000 | 0x00000000fffb6000 | 0x1000
> [#951 , #951 ] | 0x7 | 0x0000000102665000 | 0x00000000fffb7000 | 0x1000
> [#952 , #952 ] | 0x7 | 0x000000010264b000 | 0x00000000fffb8000 | 0x1000
> [#953 , #953 ] | 0x7 | 0x000000010264a000 | 0x00000000fffb9000 | 0x1000
> [#954 , #954 ] | 0x7 | 0x0000000102649000 | 0x00000000fffba000 | 0x1000
> [#955 , #955 ] | 0x7 | 0x0000000102648000 | 0x00000000fffbb000 | 0x1000
> [#956 , #956 ] | 0x7 | 0x000000010260f000 | 0x00000000fffbc000 | 0x1000
> [#957 , #957 ] | 0x7 | 0x000000010260e000 | 0x00000000fffbd000 | 0x1000
> [#958 , #958 ] | 0x7 | 0x000000010260d000 | 0x00000000fffbe000 | 0x1000
> [#959 , #959 ] | 0x7 | 0x000000010260b000 | 0x00000000fffbf000 | 0x1000
> [#960 , #992 ] | 0x7 | 0x00000001025ea000 | 0x00000000fffc0000 | 0x21000
> }
> }
> Total PDEs: 1, total PTEs: 52

The patch is almost good to me, there is one nit.

On older SoCs we put multiple devices into the same shared group and the debugfs shows it as the first member of the group.

This is what we get on T30 using this v7:

# ls/sys/kernel/debug/smmu/mappings
g2 hc vde

# cat /sys/kernel/debug/smmu/mappings/g2
[SWGROUP: g2] [as: (id: 2), (attr: R|W|-), (pd_dma: 0x834a6000)]
{
[index: 0] 0xf0083494 (count: 1000)
{
PTE RANGE | ATTR | PHYS | IOVA | SIZE
[#0 , #15 ] | 0x7 | 0xbfde0000 | 0x00000000 | 0x10000
[#16 , #47 ] | 0x7 | 0xbfdc0000 | 0x00010000 | 0x20000
[#48 , #111 ] | 0x7 | 0xbfd80000 | 0x00030000 | 0x40000
[#112 , #239 ] | 0x7 | 0xbfd00000 | 0x00070000 | 0x80000
[#240 , #495 ] | 0x7 | 0xbfc00000 | 0x000f0000 | 0x100000
[#496 , #999 ] | 0x7 | 0xbf400000 | 0x001f0000 | 0x1f8000
}
}
Total PDEs: 1, total PTEs: 1000

See that name is "g2", meanwhile these mappings are made by display client driver.

I changed your patch to use the proper group name and to show all members of the group, see that change in the end of this email.

With my change applied, we get:

# ls/sys/kernel/debug/smmu/mappings
drm hc vde

# cat /sys/kernel/debug/smmu/mappings/drm
[SWGROUP: dc, dcb, g2, nv, nv2] [as: (id: 2), (attr: R|W|-), (pd_dma: 0x82480000)]
{
[index: 0] 0xf0083583 (count: 1000)
{
PTE RANGE | ATTR | PHYS | IOVA | SIZE
[#0 , #15 ] | 0x7 | 0xbfde0000 | 0x00000000 | 0x10000
[#16 , #47 ] | 0x7 | 0xbfdc0000 | 0x00010000 | 0x20000
[#48 , #111 ] | 0x7 | 0xbfd80000 | 0x00030000 | 0x40000
[#112 , #239 ] | 0x7 | 0xbfd00000 | 0x00070000 | 0x80000
[#240 , #495 ] | 0x7 | 0xbfc00000 | 0x000f0000 | 0x100000
[#496 , #999 ] | 0x7 | 0xbf400000 | 0x001f0000 | 0x1f8000
}
}
Total PDEs: 1, total PTEs: 1000

--- >8 ---

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 575e82076270..fb1326a72038 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -509,6 +509,7 @@ static void tegra_smmu_as_unprepare(struct tegra_smmu *smmu,
static int tegra_smmu_debugfs_mappings_show(struct seq_file *s, void *data)
{
struct tegra_smmu_group *group = s->private;
+ const struct tegra_smmu_group_soc *soc;
const struct tegra_smmu_swgroup *swgrp;
struct tegra_smmu_as *as;
struct tegra_smmu *smmu;
@@ -524,6 +525,7 @@ static int tegra_smmu_debugfs_mappings_show(struct seq_file *s, void *data)

swgrp = group->swgrp;
smmu = group->smmu;
+ soc = group->soc;
as = group->as;

mutex_lock(&smmu->lock);
@@ -536,7 +538,38 @@ static int tegra_smmu_debugfs_mappings_show(struct seq_file *s, void *data)
if (!pd)
goto unlock;

- seq_printf(s, "[SWGROUP: %s] ", swgrp->name);
+ seq_puts(s, "[SWGROUP: ");
+ if (soc) {
+ bool first_swgroup = true;
+ unsigned int i;
+
+ for (i = 0; i < soc->num_swgroups; i++) {
+ swgrp = tegra_smmu_find_swgrp(smmu, soc->swgroups[i]);
+
+ if (WARN_ON(!swgrp))
+ goto unlock;
+
+ val = smmu_readl(smmu, swgrp->reg);
+
+ if (!(val & SMMU_ASID_ENABLE))
+ continue;
+
+ if (WARN_ON((val & SMMU_ASID_MASK) != as->id))
+ continue;
+
+ if (first_swgroup)
+ first_swgroup = false;
+ else
+ seq_puts(s, ", ");
+
+ seq_printf(s, "%s", swgrp->name);
+ }
+ } else {
+ WARN_ON((val & SMMU_ASID_MASK) != as->id);
+ seq_printf(s, "%s", swgrp->name);
+ }
+ seq_puts(s, "] ");
+
seq_printf(s, "[as: (id: %d), ", as->id);
seq_printf(s, "(attr: %c|%c|%c), ",
as->attr & SMMU_PD_READABLE ? 'R' : '-',
@@ -631,6 +664,7 @@ static void tegra_smmu_attach_as(struct tegra_smmu *smmu,
{
const struct tegra_smmu_swgroup *swgrp;
struct tegra_smmu_group *group;
+ const char *name;

/* Find swgrp according to the swgroup id */
swgrp = tegra_smmu_find_swgrp(smmu, swgroup);
@@ -647,10 +681,16 @@ static void tegra_smmu_attach_as(struct tegra_smmu *smmu,
"overwriting group->as for swgroup: %s\n", swgrp->name);
group->as = as;

- if (smmu->debugfs_mappings)
- debugfs_create_file(group->swgrp->name, 0444,
+ if (smmu->debugfs_mappings) {
+ if (group->soc)
+ name = group->soc->name;
+ else
+ name = group->swgrp->name;
+
+ debugfs_create_file(name, 0444,
smmu->debugfs_mappings, group,
&tegra_smmu_debugfs_mappings_fops);
+ }

break;
}
\
 
 \ /
  Last update: 2021-12-08 15:37    [W:0.111 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site