On 30.10.20 11:07, Andrea Bastoni wrote: > On 30/10/2020 10:25, Jan Kiszka wrote: >> From: Jan Kiszka <[email protected]> >> >> There are no tables ready during arm_smmu_init(). Therefore, we need to >> hold back writing sCR0 until config commit. >> >> This fixes DMA errors during startup. > > Thanks! Tested on the ZCU 102, the DMA errors I had are gone. >
Great, thanks for testing quickly! Nikhil, Lokesh... bad news: The fact that there is no arm_smmuv3_config_commit strongly suggests that you are sharing another deficit/bug with the v3 implementation. And the PVU does have pvu_iommu_config_commit, but it also flips PVU_ENABLE_EN already during init. Jan >> >> Signed-off-by: Jan Kiszka <[email protected]> >> --- >> >> Replaces "arm64: smmu: Do not enable SMMU if TLB flush fails". >> >> hypervisor/arch/arm64/include/asm/smmu.h | 12 ++++++++ >> hypervisor/arch/arm64/iommu.c | 2 ++ >> hypervisor/arch/arm64/smmu.c | 35 +++++++++++++++--------- >> 3 files changed, 36 insertions(+), 13 deletions(-) >> create mode 100644 hypervisor/arch/arm64/include/asm/smmu.h >> >> diff --git a/hypervisor/arch/arm64/include/asm/smmu.h >> b/hypervisor/arch/arm64/include/asm/smmu.h >> new file mode 100644 >> index 00000000..def7cbde >> --- /dev/null >> +++ b/hypervisor/arch/arm64/include/asm/smmu.h >> @@ -0,0 +1,12 @@ >> +/* >> + * Jailhouse, a Linux-based partitioning hypervisor >> + * >> + * Copyright Siemens AG, 2020 >> + * >> + * This work is licensed under the terms of the GNU GPL, version 2. See >> + * the COPYING file in the top-level directory. >> + */ >> + >> +#include <jailhouse/cell.h> >> + >> +void arm_smmu_config_commit(struct cell *cell); >> diff --git a/hypervisor/arch/arm64/iommu.c b/hypervisor/arch/arm64/iommu.c >> index 805589b3..ca998789 100644 >> --- a/hypervisor/arch/arm64/iommu.c >> +++ b/hypervisor/arch/arm64/iommu.c >> @@ -12,6 +12,7 @@ >> >> #include <jailhouse/control.h> >> #include <asm/iommu.h> >> +#include <asm/smmu.h> >> #include <asm/ti-pvu.h> >> >> unsigned int iommu_count_units(void) >> @@ -38,5 +39,6 @@ int iommu_unmap_memory_region(struct cell *cell, >> >> void iommu_config_commit(struct cell *cell) >> { >> + arm_smmu_config_commit(cell); >> pvu_iommu_config_commit(cell); >> } >> diff --git a/hypervisor/arch/arm64/smmu.c b/hypervisor/arch/arm64/smmu.c >> index 89631d16..911f50d1 100644 >> --- a/hypervisor/arch/arm64/smmu.c >> +++ b/hypervisor/arch/arm64/smmu.c >> @@ -14,6 +14,7 @@ >> #include <jailhouse/printk.h> >> #include <jailhouse/unit.h> >> #include <asm/iommu.h> >> +#include <asm/smmu.h> >> >> #include <jailhouse/cell-config.h> >> >> @@ -238,7 +239,6 @@ static int arm_smmu_device_reset(struct arm_smmu_device >> *smmu) >> void *gr0_base = ARM_SMMU_GR0(smmu); >> unsigned int idx; >> u32 reg; >> - int ret; >> >> /* Clear global FSR */ >> reg = mmio_read32(ARM_SMMU_GR0(smmu) + ARM_SMMU_GR0_sGFSR); >> @@ -287,18 +287,7 @@ static int arm_smmu_device_reset(struct arm_smmu_device >> *smmu) >> /* Invalidate the TLB, just in case */ >> mmio_write32(gr0_base + ARM_SMMU_GR0_TLBIALLH, 0); >> mmio_write32(gr0_base + ARM_SMMU_GR0_TLBIALLNSNH, 0); >> - >> - /* Enable fault reporting */ >> - reg = sCR0_GFRE | sCR0_GFIE | sCR0_GCFGFRE | sCR0_GCFGFIE; >> - >> - /* Private VMIDS, disable TLB broadcasting, fault unmatched streams */ >> - reg |= sCR0_VMIDPNE | sCR0_PTM | sCR0_USFCFG; >> - >> - /* Push the button */ >> - ret = arm_smmu_tlb_sync_global(smmu); >> - mmio_write32(ARM_SMMU_GR0(smmu) + ARM_SMMU_GR0_sCR0, reg); >> - >> - return ret; >> + return arm_smmu_tlb_sync_global(smmu); >> } >> >> static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) >> @@ -512,6 +501,26 @@ static void arm_smmu_cell_exit(struct cell *cell) >> } >> } >> >> +void arm_smmu_config_commit(struct cell *cell) >> +{ >> + struct arm_smmu_device *smmu; >> + unsigned int dev; >> + >> + if (cell != &root_cell) >> + return; >> + >> + for_each_smmu(smmu, dev) { >> + /* >> + * Enable fault reporting, >> + * private VMIDS, disable TLB broadcasting, >> + * fault unmatched streams >> + */ >> + mmio_write32(ARM_SMMU_GR0(smmu) + ARM_SMMU_GR0_sCR0, >> + sCR0_GFRE | sCR0_GFIE | sCR0_GCFGFRE | sCR0_GCFGFIE | >> + sCR0_VMIDPNE | sCR0_PTM | sCR0_USFCFG); >> + } >> +} >> + >> static void arm_smmu_shutdown(void) >> { >> struct arm_smmu_device *smmu; >> > -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/870e41d6-8f76-1498-67f3-20062d1b28a7%40siemens.com.
