On Wed, Mar 22, 2017 at 02:02:41AM -0500, Suravee Suthikulpanit wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpa...@amd.com>
> 
> Current AMD IOMMU Perf PMU inappropriately uses hardware struct
> inside the union inside the struct hw_perf_event, mainly the use of
> extra_reg.
> 
> Instead, introduce amd_iommu-specific struct with required
> parameters to be programmed onto the IOMMU performance counter
> control register.
> 
> Also update the pasid field from 16 to 20 bits.
> 
> Cc: Peter Zijlstra <pet...@infradead.org>
> Cc: Borislav Petkov <b...@alien8.de>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpa...@amd.com>
> ---
>  arch/x86/events/amd/iommu.c | 102 
> +++++++++++++++++++-------------------------
>  include/linux/perf_event.h  |   7 +++
>  2 files changed, 52 insertions(+), 57 deletions(-)
> 
> diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
> index 7ac8138..915a20c 100644
> --- a/arch/x86/events/amd/iommu.c
> +++ b/arch/x86/events/amd/iommu.c
> @@ -23,17 +23,16 @@
>  
>  #define COUNTER_SHIFT                16
>  
> -#define _GET_BANK(ev)       ((u8)(ev->hw.extra_reg.reg >> 8))
> -#define _GET_CNTR(ev)       ((u8)(ev->hw.extra_reg.reg))
> -
> -/* iommu pmu config masks */
> -#define _GET_CSOURCE(ev)    ((ev->hw.config & 0xFFULL))
> -#define _GET_DEVID(ev)      ((ev->hw.config >> 8)  & 0xFFFFULL)
> -#define _GET_PASID(ev)      ((ev->hw.config >> 24) & 0xFFFFULL)
> -#define _GET_DOMID(ev)      ((ev->hw.config >> 40) & 0xFFFFULL)
> -#define _GET_DEVID_MASK(ev) ((ev->hw.extra_reg.config)  & 0xFFFFULL)
> -#define _GET_PASID_MASK(ev) ((ev->hw.extra_reg.config >> 16) & 0xFFFFULL)
> -#define _GET_DOMID_MASK(ev) ((ev->hw.extra_reg.config >> 32) & 0xFFFFULL)
> +/* iommu pmu conf masks */
> +#define GET_CSOURCE(x)     (x->conf & 0xFFULL)

You need to prevent the macro arg from potentially wrong precedence
rules/multiple eval:

#define GET_CSOURCE(x)     ((x)->conf & 0xFFULL)
                            ^^^

I fixed them up when applying.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

Reply via email to