|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] arm/smmuv3: clean stream tables for non-coherent hardware
16.11.2026 13:47, Mykola Kvach пишет: Hello Mykola 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@xxxxxxxx> --- 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 */ 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.
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.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |