On 04.10.20 20:59, Jan Kiszka wrote:
> From: Jan Kiszka <[email protected]>
> 
> Properly disable the SMMU on shutdown as well as on errors during setup.
> 
> Signed-off-by: Jan Kiszka <[email protected]>
> ---
>  hypervisor/arch/arm64/smmu.c | 30 ++++++++++++++++++++++++------
>  1 file changed, 24 insertions(+), 6 deletions(-)
> 
> diff --git a/hypervisor/arch/arm64/smmu.c b/hypervisor/arch/arm64/smmu.c
> index 34c99a6a..f20a44f6 100644
> --- a/hypervisor/arch/arm64/smmu.c
> +++ b/hypervisor/arch/arm64/smmu.c
> @@ -890,6 +890,17 @@ static void arm_smmu_cell_exit(struct cell *cell)
>       }
>  }
>  
> +static void arm_smmu_shutdown(void)
> +{
> +     struct arm_smmu_device *smmu;
> +     unsigned int dev;
> +
> +     for_each_smmu(smmu, dev) {
> +             mmio_write32(ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0,
> +                          sCR0_CLIENTPD);

BTW, does someone know if we need a TLB flush after this as well? My
expectation and understanding of the spec is that this bit makes the
transactions bypass early, but maybe I'm missing something.

Jan

> +     }
> +}
> +
>  static int arm_smmu_init(void)
>  {
>       struct jailhouse_iommu *iommu;
> @@ -906,8 +917,10 @@ static int arm_smmu_init(void)
>               smmu->arm_sid_mask = iommu->arm_mmu500.sid_mask;
>  
>               smmu->base = paging_map_device(iommu->base, iommu->size);
> -             if (!smmu->base)
> -                     return -ENOMEM;
> +             if (!smmu->base) {
> +                     err = -ENOMEM;
> +                     goto error;
> +             }
>  
>               printk("ARM MMU500 at 0x%llx with:\n", iommu->base);
>  
> @@ -915,11 +928,11 @@ static int arm_smmu_init(void)
>  
>               err = arm_smmu_device_cfg_probe(smmu);
>               if (err)
> -                     return err;
> +                     goto error;
>  
>               err = arm_smmu_device_reset(smmu);
>               if (err)
> -                     return err;
> +                     goto error;
>  
>               arm_smmu_test_smr_masks(smmu);
>  
> @@ -929,9 +942,14 @@ static int arm_smmu_init(void)
>       if (num_smmu_devices == 0)
>               return 0;
>  
> -     return arm_smmu_cell_init(&root_cell);
> +     err = arm_smmu_cell_init(&root_cell);
> +     if (!err)
> +             return 0;
> +
> +error:
> +     arm_smmu_shutdown();
> +     return err;
>  }
>  
>  DEFINE_UNIT_MMIO_COUNT_REGIONS_STUB(arm_smmu);
> -DEFINE_UNIT_SHUTDOWN_STUB(arm_smmu);
>  DEFINE_UNIT(arm_smmu, "ARM 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/aca61191-4d49-044f-cb61-c532492a26df%40siemens.com.

Reply via email to