Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756633AbbGFNmN (ORCPT ); Mon, 6 Jul 2015 09:42:13 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:36411 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755328AbbGFNmK (ORCPT ); Mon, 6 Jul 2015 09:42:10 -0400 Date: Mon, 6 Jul 2015 15:41:59 +0200 From: Peter Zijlstra To: Max Filippov Cc: linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org, Chris Zankel , Marc Gauthier , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo Subject: Re: [PATCH 7/8] xtensa: implement counting and sampling perf events Message-ID: <20150706134159.GH3644@twins.programming.kicks-ass.net> References: <1436189569-28802-1-git-send-email-jcmvbkbc@gmail.com> <1436189569-28802-8-git-send-email-jcmvbkbc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1436189569-28802-8-git-send-email-jcmvbkbc@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1480 Lines: 48 On Mon, Jul 06, 2015 at 04:32:48PM +0300, Max Filippov wrote: > +static int xtensa_pmu_event_init(struct perf_event *event) > +{ > + int ret; > + > + switch (event->attr.type) { > + case PERF_TYPE_HARDWARE: > + if (event->attr.config >= ARRAY_SIZE(xtensa_hw_ctl) || > + xtensa_hw_ctl[event->attr.config] == 0) > + return -ENOENT; > + event->hw.config = xtensa_hw_ctl[event->attr.config]; > + return 0; > + > + case PERF_TYPE_HW_CACHE: > + ret = xtensa_pmu_cache_event(event->attr.config); > + if (ret < 0) > + return ret; > + event->hw.config = ret; > + return 0; > + > + case PERF_TYPE_RAW: > + /* Not 'previous counter' select */ > + if ((event->attr.config & XTENSA_PMU_PMCTRL_SELECT) == > + (1 << XTENSA_PMU_PMCTRL_SELECT_SHIFT)) > + return -ENOENT; > + event->hw.config = (event->attr.config & > + (XTENSA_PMU_PMCTRL_KRNLCNT | > + XTENSA_PMU_PMCTRL_TRACELEVEL | > + XTENSA_PMU_PMCTRL_SELECT | > + XTENSA_PMU_PMCTRL_MASK)) | > + XTENSA_PMU_PMCTRL_INTEN; > + return 0; Since this PMU implements TYPE_HARDWARE/TYPE_HW_CACHE/TYPE_RAW, returning -ENOENT for those is wrong. If the configuration is invalid, return -EINVAL. > + > + default: > + return -ENOENT; > + } > +} -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/