@@ -806,16 +806,27 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
806
806
{
807
807
#ifdef CONFIG_IRQ_REMAP
808
808
u32 status , i ;
809
+ u64 entry ;
809
810
810
811
if (!iommu -> ga_log )
811
812
return - EINVAL ;
812
813
813
- status = readl (iommu -> mmio_base + MMIO_STATUS_OFFSET );
814
-
815
814
/* Check if already running */
816
- if (status & (MMIO_STATUS_GALOG_RUN_MASK ))
815
+ status = readl (iommu -> mmio_base + MMIO_STATUS_OFFSET );
816
+ if (WARN_ON (status & (MMIO_STATUS_GALOG_RUN_MASK )))
817
817
return 0 ;
818
818
819
+ entry = iommu_virt_to_phys (iommu -> ga_log ) | GA_LOG_SIZE_512 ;
820
+ memcpy_toio (iommu -> mmio_base + MMIO_GA_LOG_BASE_OFFSET ,
821
+ & entry , sizeof (entry ));
822
+ entry = (iommu_virt_to_phys (iommu -> ga_log_tail ) &
823
+ (BIT_ULL (52 )- 1 )) & ~7ULL ;
824
+ memcpy_toio (iommu -> mmio_base + MMIO_GA_LOG_TAIL_OFFSET ,
825
+ & entry , sizeof (entry ));
826
+ writel (0x00 , iommu -> mmio_base + MMIO_GA_HEAD_OFFSET );
827
+ writel (0x00 , iommu -> mmio_base + MMIO_GA_TAIL_OFFSET );
828
+
829
+
819
830
iommu_feature_enable (iommu , CONTROL_GAINT_EN );
820
831
iommu_feature_enable (iommu , CONTROL_GALOG_EN );
821
832
@@ -825,7 +836,7 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
825
836
break ;
826
837
}
827
838
828
- if (i >= LOOP_TIMEOUT )
839
+ if (WARN_ON ( i >= LOOP_TIMEOUT ) )
829
840
return - EINVAL ;
830
841
#endif /* CONFIG_IRQ_REMAP */
831
842
return 0 ;
@@ -834,8 +845,6 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
834
845
static int iommu_init_ga_log (struct amd_iommu * iommu )
835
846
{
836
847
#ifdef CONFIG_IRQ_REMAP
837
- u64 entry ;
838
-
839
848
if (!AMD_IOMMU_GUEST_IR_VAPIC (amd_iommu_guest_ir ))
840
849
return 0 ;
841
850
@@ -849,16 +858,6 @@ static int iommu_init_ga_log(struct amd_iommu *iommu)
849
858
if (!iommu -> ga_log_tail )
850
859
goto err_out ;
851
860
852
- entry = iommu_virt_to_phys (iommu -> ga_log ) | GA_LOG_SIZE_512 ;
853
- memcpy_toio (iommu -> mmio_base + MMIO_GA_LOG_BASE_OFFSET ,
854
- & entry , sizeof (entry ));
855
- entry = (iommu_virt_to_phys (iommu -> ga_log_tail ) &
856
- (BIT_ULL (52 )- 1 )) & ~7ULL ;
857
- memcpy_toio (iommu -> mmio_base + MMIO_GA_LOG_TAIL_OFFSET ,
858
- & entry , sizeof (entry ));
859
- writel (0x00 , iommu -> mmio_base + MMIO_GA_HEAD_OFFSET );
860
- writel (0x00 , iommu -> mmio_base + MMIO_GA_TAIL_OFFSET );
861
-
862
861
return 0 ;
863
862
err_out :
864
863
free_ga_log (iommu );
0 commit comments