@@ -400,6 +400,8 @@ struct arm_smmu_device {
400400
401401 u32 cavium_id_base ; /* Specific to Cavium */
402402
403+ spinlock_t global_sync_lock ;
404+
403405 /* IOMMU core code handle */
404406 struct iommu_device iommu ;
405407};
@@ -436,7 +438,7 @@ struct arm_smmu_domain {
436438 struct arm_smmu_cfg cfg ;
437439 enum arm_smmu_domain_stage stage ;
438440 struct mutex init_mutex ; /* Protects smmu pointer */
439- spinlock_t cb_lock ; /* Serialises ATS1* ops */
441+ spinlock_t cb_lock ; /* Serialises ATS1* ops and TLB syncs */
440442 struct iommu_domain domain ;
441443};
442444
@@ -602,19 +604,25 @@ static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu,
602604static void arm_smmu_tlb_sync_global (struct arm_smmu_device * smmu )
603605{
604606 void __iomem * base = ARM_SMMU_GR0 (smmu );
607+ unsigned long flags ;
605608
609+ spin_lock_irqsave (& smmu -> global_sync_lock , flags );
606610 __arm_smmu_tlb_sync (smmu , base + ARM_SMMU_GR0_sTLBGSYNC ,
607611 base + ARM_SMMU_GR0_sTLBGSTATUS );
612+ spin_unlock_irqrestore (& smmu -> global_sync_lock , flags );
608613}
609614
610615static void arm_smmu_tlb_sync_context (void * cookie )
611616{
612617 struct arm_smmu_domain * smmu_domain = cookie ;
613618 struct arm_smmu_device * smmu = smmu_domain -> smmu ;
614619 void __iomem * base = ARM_SMMU_CB (smmu , smmu_domain -> cfg .cbndx );
620+ unsigned long flags ;
615621
622+ spin_lock_irqsave (& smmu_domain -> cb_lock , flags );
616623 __arm_smmu_tlb_sync (smmu , base + ARM_SMMU_CB_TLBSYNC ,
617624 base + ARM_SMMU_CB_TLBSTATUS );
625+ spin_unlock_irqrestore (& smmu_domain -> cb_lock , flags );
618626}
619627
620628static void arm_smmu_tlb_sync_vmid (void * cookie )
@@ -1511,7 +1519,6 @@ static int arm_smmu_add_device(struct device *dev)
15111519
15121520 if (using_legacy_binding ) {
15131521 ret = arm_smmu_register_legacy_master (dev , & smmu );
1514- fwspec = dev -> iommu_fwspec ;
15151522 if (ret )
15161523 goto out_free ;
15171524 } else if (fwspec && fwspec -> ops == & arm_smmu_ops ) {
@@ -1550,15 +1557,15 @@ static int arm_smmu_add_device(struct device *dev)
15501557
15511558 ret = arm_smmu_master_alloc_smes (dev );
15521559 if (ret )
1553- goto out_free ;
1560+ goto out_cfg_free ;
15541561
15551562 iommu_device_link (& smmu -> iommu , dev );
15561563
15571564 return 0 ;
15581565
1566+ out_cfg_free :
1567+ kfree (cfg );
15591568out_free :
1560- if (fwspec )
1561- kfree (fwspec -> iommu_priv );
15621569 iommu_fwspec_free (dev );
15631570 return ret ;
15641571}
@@ -1925,6 +1932,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
19251932
19261933 smmu -> num_mapping_groups = size ;
19271934 mutex_init (& smmu -> stream_map_mutex );
1935+ spin_lock_init (& smmu -> global_sync_lock );
19281936
19291937 if (smmu -> version < ARM_SMMU_V2 || !(id & ID0_PTFS_NO_AARCH32 )) {
19301938 smmu -> features |= ARM_SMMU_FEAT_FMT_AARCH32_L ;
0 commit comments