* [PATCH v2] arm/smmuv3: clean stream tables for non-coherent hardware
@ 2026-11-16 11:47 Mykola Kvach
2026-11-18 21:03 ` Oleksandr Tyshchenko
0 siblings, 1 reply; 3+ messages in thread
From: Mykola Kvach @ 2026-11-16 11:47 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Bertrand Marquis, Rahul Singh, Stefano Stabellini, Julien Grall,
Michal Orzel, Volodymyr Babchuk
Xen's dmam_alloc_coherent() returns cacheable memory. A non-coherent
SMMU cannot see writes that remain in the CPU cache.
On Orange Pi 5 (RK3588S), NVMe initialization failed with C_BAD_STREAMID
for SID 0x4100 while the CPU saw a populated L1 descriptor.
Clean new stream tables before use. Clean updated STE data in
arm_smmu_sync_ste_for_sid() before issuing CFGI_STE and CMD_SYNC.
Keep both sync points around the dst[0] update.
Clean the L2 table before writing its L1 pointer, then clean the pointer.
Skip these cache operations on coherent SMMUs.
See Arm IHI 0070G.b, sections 3.15 and 3.21.3.1.
Fixes: 452ddbe3592b ("xen/arm: smmuv3: Add support for SMMUv3 driver")
Assisted-by: Codex:GPT-6.1
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
---
Changes in v2:
- Rename arm_smmu_clean_strtab() to arm_smmu_clean_dcache().
- Pass the STE pointer and clean size to arm_smmu_sync_ste_for_sid().
Clean the given range there before CFGI_STE and CMD_SYNC. Keep the
original clean ranges, both sync points around dst[0], and the
explicit cleaning during table initialisation.
---
xen/drivers/passthrough/arm/smmu-v3.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c
index 232df2421c..945a18a7a1 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -637,6 +637,14 @@ static int arm_smmu_cmdq_issue_sync(struct arm_smmu_device *smmu)
}
/* Stream table manipulation functions */
+static void arm_smmu_clean_dcache(struct arm_smmu_device *smmu,
+ const void *ptr, size_t size)
+{
+ /* Xen's dmam_alloc_coherent() returns cacheable memory. */
+ if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY))
+ (void)clean_dcache_va_range(ptr, size);
+}
+
static void
arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc)
{
@@ -649,7 +657,8 @@ arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc)
write_atomic(dst, cpu_to_le64(val));
}
-static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid)
+static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid,
+ const __le64 *dst, size_t size)
{
struct arm_smmu_cmdq_ent cmd = {
.opcode = CMDQ_OP_CFGI_STE,
@@ -659,6 +668,7 @@ static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid)
},
};
+ arm_smmu_clean_dcache(smmu, dst, size);
arm_smmu_cmdq_issue_cmd(smmu, &cmd);
arm_smmu_cmdq_issue_sync(smmu);
}
@@ -736,7 +746,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid,
* the STE regardless of whether the old value was live.
*/
if (smmu)
- arm_smmu_sync_ste_for_sid(smmu, sid);
+ arm_smmu_sync_ste_for_sid(smmu, sid, dst,
+ STRTAB_STE_DWORDS << 3);
return;
}
@@ -762,9 +773,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid,
dst[1] |= cpu_to_le64(FIELD_PREP(STRTAB_STE_1_EATS,
STRTAB_STE_1_EATS_TRANS));
- arm_smmu_sync_ste_for_sid(smmu, sid);
+ arm_smmu_sync_ste_for_sid(smmu, sid, dst, STRTAB_STE_DWORDS << 3);
write_atomic(&dst[0], cpu_to_le64(val));
- arm_smmu_sync_ste_for_sid(smmu, sid);
+ arm_smmu_sync_ste_for_sid(smmu, sid, dst, sizeof(*dst));
/* It's likely that we'll want to use the new STE soon */
if (!(smmu->options & ARM_SMMU_OPT_SKIP_PREFETCH))
@@ -805,7 +816,10 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid)
}
arm_smmu_init_bypass_stes(desc->l2ptr, 1 << STRTAB_SPLIT);
+ /* Clean the L2 table before writing the L1 pointer. */
+ arm_smmu_clean_dcache(smmu, desc->l2ptr, size);
arm_smmu_write_strtab_l1_desc(strtab, desc);
+ arm_smmu_clean_dcache(smmu, strtab, STRTAB_L1_DESC_DWORDS << 3);
return 0;
}
@@ -1744,6 +1758,7 @@ static int __init arm_smmu_init_queues(struct arm_smmu_device *smmu)
static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
{
unsigned int i;
+ size_t size;
struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
void *strtab = smmu->strtab_cfg.strtab;
@@ -1757,6 +1772,9 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
strtab += STRTAB_L1_DESC_DWORDS << 3;
}
+ size = cfg->num_l1_ents * (STRTAB_L1_DESC_DWORDS << 3);
+ arm_smmu_clean_dcache(smmu, cfg->strtab, size);
+
return 0;
}
@@ -1823,6 +1841,7 @@ static int arm_smmu_init_strtab_linear(struct arm_smmu_device *smmu)
cfg->strtab_base_cfg = reg;
arm_smmu_init_bypass_stes(strtab, cfg->num_l1_ents);
+ arm_smmu_clean_dcache(smmu, strtab, size);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] arm/smmuv3: clean stream tables for non-coherent hardware 2026-11-16 11:47 [PATCH v2] arm/smmuv3: clean stream tables for non-coherent hardware Mykola Kvach @ 2026-11-18 21:03 ` Oleksandr Tyshchenko 2026-11-18 23:58 ` Mykola Kvach 0 siblings, 1 reply; 3+ messages in thread From: Oleksandr Tyshchenko @ 2026-11-18 21:03 UTC (permalink / raw) To: Mykola Kvach, xen-devel@lists.xenproject.org Cc: Bertrand Marquis, Rahul Singh, Stefano Stabellini, Julien Grall, Michal Orzel, Volodymyr Babchuk 16.11.2026 13:47, Mykola Kvach пишет: Hello Mykola > Xen's dmam_alloc_coherent() returns cacheable memory. A non-coherent > SMMU cannot see writes that remain in the CPU cache. > > On Orange Pi 5 (RK3588S), NVMe initialization failed with C_BAD_STREAMID > for SID 0x4100 while the CPU saw a populated L1 descriptor. > > Clean new stream tables before use. Clean updated STE data in > arm_smmu_sync_ste_for_sid() before issuing CFGI_STE and CMD_SYNC. > Keep both sync points around the dst[0] update. > > Clean the L2 table before writing its L1 pointer, then clean the pointer. > Skip these cache operations on coherent SMMUs. > > See Arm IHI 0070G.b, sections 3.15 and 3.21.3.1. > > Fixes: 452ddbe3592b ("xen/arm: smmuv3: Add support for SMMUv3 driver") > Assisted-by: Codex:GPT-6.1 > Signed-off-by: Mykola Kvach <mykola_kvach@epam.com> So, If I understand the patch/problem correctly, this looks like a follow-up to "xen/arm: smmuv3: Add cache maintenance for non-coherent SMMU queues". The underlying issue seems the same, cache maintenance for in-memory data structures, except that previous patch addressed the command queue, while this one targets the stream table. I did not find any serious issues with the current patch, just a couple of NITs below for you to consider. Preferably with the NITs addressed: Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> > --- > Changes in v2: > - Rename arm_smmu_clean_strtab() to arm_smmu_clean_dcache(). > - Pass the STE pointer and clean size to arm_smmu_sync_ste_for_sid(). > Clean the given range there before CFGI_STE and CMD_SYNC. Keep the > original clean ranges, both sync points around dst[0], and the > explicit cleaning during table initialisation. > --- > xen/drivers/passthrough/arm/smmu-v3.c | 27 +++++++++++++++++++++++---- > 1 file changed, 23 insertions(+), 4 deletions(-) > > diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c > index 232df2421c..945a18a7a1 100644 > --- a/xen/drivers/passthrough/arm/smmu-v3.c > +++ b/xen/drivers/passthrough/arm/smmu-v3.c > @@ -637,6 +637,14 @@ static int arm_smmu_cmdq_issue_sync(struct arm_smmu_device *smmu) > } > > /* Stream table manipulation functions */ > +static void arm_smmu_clean_dcache(struct arm_smmu_device *smmu, > + const void *ptr, size_t size) > +{ > + /* Xen's dmam_alloc_coherent() returns cacheable memory. */ > + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) > + (void)clean_dcache_va_range(ptr, size); So, two ways of testing coherency in one file. The queues use q->non_coherent in several places. The new helper reads smmu->features & ARM_SMMU_FEAT_COHERENCY. Both derive from the same bit, so behaviour is correct. NIT 1: Cast is inconsistent. The helper casts the int return of clean_dcache_va_range() to (void). The queue code in the same file ignores the same return without a cast. NIT 2: I wonder if the queue code's open-coded "if (q->non_coherent) clean/invalidate..." calls could share the helper? That would eliminate the duplicate coherency checks, avoid spreading CMO logic across the driver, and also resolve NIT 1 since the cast (or lack thereof) would live in one place. *** Somthing like this: +static void arm_smmu_clean_dcache(struct arm_smmu_device *smmu, + const void *ptr, size_t size) +{ + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) + (void)clean_dcache_va_range(ptr, size); +} + +static void arm_smmu_invalidate_dcache(struct arm_smmu_device *smmu, + const void *ptr, size_t size) +{ + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) + (void)invalidate_dcache_va_range(ptr, size); +} The queue callers would then look like this: - if (q->non_coherent) - clean_dcache_va_range(q_addr, q->ent_dwords * sizeof(*q_addr)); + arm_smmu_clean_dcache(q->smmu, q_addr, + q->ent_dwords * sizeof(*q_addr)); ... - if (q->non_coherent) - invalidate_dcache_va_range(q_addr, q->ent_dwords * sizeof(*q_addr)); + arm_smmu_invalidate_dcache(q->smmu, q_addr, + q->ent_dwords * sizeof(*q_addr)); For this to work, the queue needs a back pointer to the SMMU (replacing the non_coherent flag), set in arm_smmu_init_one_queue(): - q->non_coherent = !(smmu->features & ARM_SMMU_FEAT_COHERENCY); + q->smmu = smmu; struct arm_smmu_queue { ... - /* Is the memory access coherent? */ - bool non_coherent; + struct arm_smmu_device *smmu; }; This is optional, so feel free to keep the code as it is if you prefer. > +} > + > static void > arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc) > { > @@ -649,7 +657,8 @@ arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc) > write_atomic(dst, cpu_to_le64(val)); > } > > -static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid) > +static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid, > + const __le64 *dst, size_t size) > { > struct arm_smmu_cmdq_ent cmd = { > .opcode = CMDQ_OP_CFGI_STE, > @@ -659,6 +668,7 @@ static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid) > }, > }; > > + arm_smmu_clean_dcache(smmu, dst, size); > arm_smmu_cmdq_issue_cmd(smmu, &cmd); > arm_smmu_cmdq_issue_sync(smmu); > } > @@ -736,7 +746,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, > * the STE regardless of whether the old value was live. > */ > if (smmu) > - arm_smmu_sync_ste_for_sid(smmu, sid); > + arm_smmu_sync_ste_for_sid(smmu, sid, dst, > + STRTAB_STE_DWORDS << 3); > return; > } > > @@ -762,9 +773,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, > dst[1] |= cpu_to_le64(FIELD_PREP(STRTAB_STE_1_EATS, > STRTAB_STE_1_EATS_TRANS)); > > - arm_smmu_sync_ste_for_sid(smmu, sid); > + arm_smmu_sync_ste_for_sid(smmu, sid, dst, STRTAB_STE_DWORDS << 3); > write_atomic(&dst[0], cpu_to_le64(val)); > - arm_smmu_sync_ste_for_sid(smmu, sid); > + arm_smmu_sync_ste_for_sid(smmu, sid, dst, sizeof(*dst)); > > /* It's likely that we'll want to use the new STE soon */ > if (!(smmu->options & ARM_SMMU_OPT_SKIP_PREFETCH)) > @@ -805,7 +816,10 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid) > } > > arm_smmu_init_bypass_stes(desc->l2ptr, 1 << STRTAB_SPLIT); > + /* Clean the L2 table before writing the L1 pointer. */ > + arm_smmu_clean_dcache(smmu, desc->l2ptr, size); > arm_smmu_write_strtab_l1_desc(strtab, desc); > + arm_smmu_clean_dcache(smmu, strtab, STRTAB_L1_DESC_DWORDS << 3); > return 0; > } > > @@ -1744,6 +1758,7 @@ static int __init arm_smmu_init_queues(struct arm_smmu_device *smmu) > static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu) > { > unsigned int i; > + size_t size; > struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg; > void *strtab = smmu->strtab_cfg.strtab; > > @@ -1757,6 +1772,9 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu) > strtab += STRTAB_L1_DESC_DWORDS << 3; > } > > + size = cfg->num_l1_ents * (STRTAB_L1_DESC_DWORDS << 3); > + arm_smmu_clean_dcache(smmu, cfg->strtab, size); NIT 3: arm_smmu_init_l1_strtab() recomputes the L1 size that its caller already has as l1size. I would move arm_smmu_clean_dcache() to arm_smmu_init_strtab_2lvl() to avoid recalculating it and reduce the diff. > + > return 0; > } > > @@ -1823,6 +1841,7 @@ static int arm_smmu_init_strtab_linear(struct arm_smmu_device *smmu) > cfg->strtab_base_cfg = reg; > > arm_smmu_init_bypass_stes(strtab, cfg->num_l1_ents); > + arm_smmu_clean_dcache(smmu, strtab, size); > return 0; > } > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] arm/smmuv3: clean stream tables for non-coherent hardware 2026-11-18 21:03 ` Oleksandr Tyshchenko @ 2026-11-18 23:58 ` Mykola Kvach 0 siblings, 0 replies; 3+ messages in thread From: Mykola Kvach @ 2026-11-18 23:58 UTC (permalink / raw) To: Oleksandr Tyshchenko Cc: Mykola Kvach, xen-devel@lists.xenproject.org, Bertrand Marquis, Rahul Singh, Stefano Stabellini, Julien Grall, Michal Orzel, Volodymyr Babchuk Hi Oleksandr, On Wed, Nov 18, 2026 at 11:04 PM Oleksandr Tyshchenko <olekstysh@gmail.com> wrote: > > > > 16.11.2026 13:47, Mykola Kvach пишет: > > Hello Mykola > > > > Xen's dmam_alloc_coherent() returns cacheable memory. A non-coherent > > SMMU cannot see writes that remain in the CPU cache. > > > > On Orange Pi 5 (RK3588S), NVMe initialization failed with C_BAD_STREAMID > > for SID 0x4100 while the CPU saw a populated L1 descriptor. > > > > Clean new stream tables before use. Clean updated STE data in > > arm_smmu_sync_ste_for_sid() before issuing CFGI_STE and CMD_SYNC. > > Keep both sync points around the dst[0] update. > > > > Clean the L2 table before writing its L1 pointer, then clean the pointer. > > Skip these cache operations on coherent SMMUs. > > > > See Arm IHI 0070G.b, sections 3.15 and 3.21.3.1. > > > > Fixes: 452ddbe3592b ("xen/arm: smmuv3: Add support for SMMUv3 driver") > > Assisted-by: Codex:GPT-6.1 > > Signed-off-by: Mykola Kvach <mykola_kvach@epam.com> > > > So, If I understand the patch/problem correctly, this looks like a > follow-up to "xen/arm: smmuv3: Add cache maintenance for non-coherent > SMMU queues". The underlying issue seems the same, cache maintenance for > in-memory data structures, except that previous patch addressed the > command queue, while this one targets the stream table. Thanks for the review. Yes, the earlier patch fixed the same cache visibility issue for the queues. This patch covers the stream tables. > > I did not find any serious issues with the current patch, just a couple > of NITs below for you to consider. > > Preferably with the NITs addressed: > Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> > > > --- > > Changes in v2: > > - Rename arm_smmu_clean_strtab() to arm_smmu_clean_dcache(). > > - Pass the STE pointer and clean size to arm_smmu_sync_ste_for_sid(). > > Clean the given range there before CFGI_STE and CMD_SYNC. Keep the > > original clean ranges, both sync points around dst[0], and the > > explicit cleaning during table initialisation. > > --- > > xen/drivers/passthrough/arm/smmu-v3.c | 27 +++++++++++++++++++++++---- > > 1 file changed, 23 insertions(+), 4 deletions(-) > > > > diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c > > index 232df2421c..945a18a7a1 100644 > > --- a/xen/drivers/passthrough/arm/smmu-v3.c > > +++ b/xen/drivers/passthrough/arm/smmu-v3.c > > @@ -637,6 +637,14 @@ static int arm_smmu_cmdq_issue_sync(struct arm_smmu_device *smmu) > > } > > > > /* Stream table manipulation functions */ > > +static void arm_smmu_clean_dcache(struct arm_smmu_device *smmu, > > + const void *ptr, size_t size) > > +{ > > + /* Xen's dmam_alloc_coherent() returns cacheable memory. */ > > + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) > > + (void)clean_dcache_va_range(ptr, size); > > So, two ways of testing coherency in one file. The queues use > q->non_coherent in several places. The new helper reads smmu->features & > ARM_SMMU_FEAT_COHERENCY. Both derive from the same bit, so behaviour is > correct. > > NIT 1: Cast is inconsistent. The helper casts the int return of > clean_dcache_va_range() to (void). The queue code in the same file > ignores the same return without a cast. On Arm, clean_dcache_va_range() always returns 0. I used (void) in the new helper to discard the result explicitly and avoid a new MISRA C Rule 17.7 violation. I kept the patch focused on the stream-table code. > > NIT 2: I wonder if the queue code's open-coded "if (q->non_coherent) > clean/invalidate..." calls could share the helper? That would eliminate > the duplicate coherency checks, avoid spreading CMO logic across the > driver, and also resolve NIT 1 since the cast (or lack thereof) would > live in one place. I see the benefit of sharing the cache helpers. I'd prefer to keep this patch focused on the stream-table fix. The queue functions already get the same coherency information from q->non_coherent, so sharing the helpers there could be a separate refactoring. I'd also welcome the maintainers' thoughts on whether it makes sense to include that change in this patch. > > *** > > Somthing like this: > +static void arm_smmu_clean_dcache(struct arm_smmu_device *smmu, > + const void *ptr, size_t size) > +{ > + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) > + (void)clean_dcache_va_range(ptr, size); > +} > + > +static void arm_smmu_invalidate_dcache(struct arm_smmu_device *smmu, > + const void *ptr, size_t size) > +{ > + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) > + (void)invalidate_dcache_va_range(ptr, size); > +} > > > The queue callers would then look like this: > > - if (q->non_coherent) > - clean_dcache_va_range(q_addr, q->ent_dwords * sizeof(*q_addr)); > + arm_smmu_clean_dcache(q->smmu, q_addr, > + q->ent_dwords * sizeof(*q_addr)); > > ... > > - if (q->non_coherent) > - invalidate_dcache_va_range(q_addr, q->ent_dwords * sizeof(*q_addr)); > + arm_smmu_invalidate_dcache(q->smmu, q_addr, > + q->ent_dwords * sizeof(*q_addr)); > > For this to work, the queue needs a back pointer to the SMMU > (replacing the non_coherent flag), set in arm_smmu_init_one_queue(): > > - q->non_coherent = !(smmu->features & ARM_SMMU_FEAT_COHERENCY); > + q->smmu = smmu; > > > struct arm_smmu_queue { > ... > > - /* Is the memory access coherent? */ > - bool non_coherent; > + struct arm_smmu_device *smmu; > }; > > This is optional, so feel free to keep the code as it is if you prefer. > > > > +} > > + > > static void > > arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc) > > { > > @@ -649,7 +657,8 @@ arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc) > > write_atomic(dst, cpu_to_le64(val)); > > } > > > > -static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid) > > +static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid, > > + const __le64 *dst, size_t size) > > { > > struct arm_smmu_cmdq_ent cmd = { > > .opcode = CMDQ_OP_CFGI_STE, > > @@ -659,6 +668,7 @@ static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid) > > }, > > }; > > > > + arm_smmu_clean_dcache(smmu, dst, size); > > arm_smmu_cmdq_issue_cmd(smmu, &cmd); > > arm_smmu_cmdq_issue_sync(smmu); > > } > > @@ -736,7 +746,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, > > * the STE regardless of whether the old value was live. > > */ > > if (smmu) > > - arm_smmu_sync_ste_for_sid(smmu, sid); > > + arm_smmu_sync_ste_for_sid(smmu, sid, dst, > > + STRTAB_STE_DWORDS << 3); > > return; > > } > > > > @@ -762,9 +773,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, > > dst[1] |= cpu_to_le64(FIELD_PREP(STRTAB_STE_1_EATS, > > STRTAB_STE_1_EATS_TRANS)); > > > > - arm_smmu_sync_ste_for_sid(smmu, sid); > > + arm_smmu_sync_ste_for_sid(smmu, sid, dst, STRTAB_STE_DWORDS << 3); > > write_atomic(&dst[0], cpu_to_le64(val)); > > - arm_smmu_sync_ste_for_sid(smmu, sid); > > + arm_smmu_sync_ste_for_sid(smmu, sid, dst, sizeof(*dst)); > > > > /* It's likely that we'll want to use the new STE soon */ > > if (!(smmu->options & ARM_SMMU_OPT_SKIP_PREFETCH)) > > @@ -805,7 +816,10 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid) > > } > > > > arm_smmu_init_bypass_stes(desc->l2ptr, 1 << STRTAB_SPLIT); > > + /* Clean the L2 table before writing the L1 pointer. */ > > + arm_smmu_clean_dcache(smmu, desc->l2ptr, size); > > arm_smmu_write_strtab_l1_desc(strtab, desc); > > + arm_smmu_clean_dcache(smmu, strtab, STRTAB_L1_DESC_DWORDS << 3); > > return 0; > > } > > > > @@ -1744,6 +1758,7 @@ static int __init arm_smmu_init_queues(struct arm_smmu_device *smmu) > > static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu) > > { > > unsigned int i; > > + size_t size; > > struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg; > > void *strtab = smmu->strtab_cfg.strtab; > > > > @@ -1757,6 +1772,9 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu) > > strtab += STRTAB_L1_DESC_DWORDS << 3; > > } > > > > + size = cfg->num_l1_ents * (STRTAB_L1_DESC_DWORDS << 3); > > + arm_smmu_clean_dcache(smmu, cfg->strtab, size); > > NIT 3: arm_smmu_init_l1_strtab() recomputes the L1 size that its caller > already has as l1size. I would move arm_smmu_clean_dcache() to > arm_smmu_init_strtab_2lvl() to avoid recalculating it and reduce the diff. Agreed. I'll move the L1 table clean to arm_smmu_init_strtab_2lvl() and use the existing l1size once arm_smmu_init_l1_strtab() succeeds. Best regards, Mykola ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-18 23:58 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-16 11:47 [PATCH v2] arm/smmuv3: clean stream tables for non-coherent hardware Mykola Kvach 2026-11-18 21:03 ` Oleksandr Tyshchenko 2026-11-18 23:58 ` Mykola Kvach
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.