lkml.org 
[lkml]   [2017]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v8 7/9] perf/amd/iommu: Check return value when set and get counter value
On Mon, Jan 16, 2017 at 01:23:34AM -0600, Suravee Suthikulpanit wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>
> In, perf_iommu_start(), we need to check the return value from
> amd_iommu_set_reg(). In case of failure, we should not enable the PMU.
>
> Also, in perf_iommu_read(), we need to check the return value from
> amd_iommu_get_reg() before using the value.

So basically you wanna say:

"Add amd_iommu_{g,s}et_reg() error handling."

>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Joerg Roedel <joro@8bytes.org>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
> arch/x86/events/amd/iommu.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
> index 200d2e8..cc7bea4 100644
> --- a/arch/x86/events/amd/iommu.c
> +++ b/arch/x86/events/amd/iommu.c
> @@ -284,6 +284,7 @@ static void perf_iommu_disable_event(struct perf_event *event)
>
> static void perf_iommu_start(struct perf_event *event, int flags)
> {
> + u64 val;
> struct hw_perf_event *hwc = &event->hw;
>
> if (WARN_ON_ONCE(!(hwc->state & PERF_HES_STOPPED)))
> @@ -292,15 +293,16 @@ static void perf_iommu_start(struct perf_event *event, int flags)
> WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
> hwc->state = 0;
>
> - if (flags & PERF_EF_RELOAD) {
> - u64 prev_raw_count = local64_read(&hwc->prev_count);
> - amd_iommu_pc_set_reg(0, _GET_BANK(event), _GET_CNTR(event),
> - IOMMU_PC_COUNTER_REG, &prev_raw_count);
> - }
> + if (!(flags & PERF_EF_RELOAD))
> + return;

This looks wrong - you still need to do

perf_iommu_enable_event(event);
perf_event_update_userpage(event);

even if !PERF_EF_RELOAD.

> + val = local64_read(&hwc->prev_count) & GENMASK_ULL(48, 0);
> + if (amd_iommu_pc_set_reg(0, _GET_BANK(event), _GET_CNTR(event),
> + IOMMU_PC_COUNTER_REG, &val))
> + return;
>
> perf_iommu_enable_event(event);
> perf_event_update_userpage(event);
> -
> }

--
Regards/Gruss,
Boris.

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

\
 
 \ /
  Last update: 2017-01-22 20:54    [W:0.231 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site