From patchwork Fri May 1 17:36:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 6312071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 91D159F1C2 for ; Fri, 1 May 2015 17:40:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61A5F2045A for ; Fri, 1 May 2015 17:40:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86D542012E for ; Fri, 1 May 2015 17:40:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YoEsv-0006uP-2S; Fri, 01 May 2015 17:37:57 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YoErz-0006WF-3d for linux-arm-kernel@lists.infradead.org; Fri, 01 May 2015 17:37:01 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3B97A662; Fri, 1 May 2015 10:36:13 -0700 (PDT) Received: from collaborate-mta1.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTP id 7BFDD3F21B; Fri, 1 May 2015 10:36:40 -0700 (PDT) Received: from hornet.cambridge.arm.com (hornet.cambridge.arm.com [10.2.206.52]) by collaborate-mta1.arm.com (Postfix) with ESMTP id B376C13F884; Fri, 1 May 2015 12:36:39 -0500 (CDT) From: Pawel Moll To: arm@kernel.org Subject: [PATCH 4/5] bus: arm-ccn: Do not group CCN events with other PMUs Date: Fri, 1 May 2015 18:36:29 +0100 Message-Id: <1430501790-26918-5-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430501790-26918-1-git-send-email-pawel.moll@arm.com> References: <1430501790-26918-1-git-send-email-pawel.moll@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150501_103659_295404_B8CC12E1 X-CRM114-Status: GOOD ( 10.81 ) X-Spam-Score: -5.0 (-----) Cc: Drew Richardson , Pawel Moll , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Groups must not mix events from different PMUs (software events are allowed). Unfortunately the core does not ensures that, so it is necessary to validate the group at the PMU driver level. Signed-off-by: Pawel Moll --- drivers/bus/arm-ccn.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c index 572360f..fb589d4 100644 --- a/drivers/bus/arm-ccn.c +++ b/drivers/bus/arm-ccn.c @@ -660,6 +660,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) int valid, bit; struct arm_ccn_component *source; int i; + struct perf_event *sibling; if (event->attr.type != event->pmu->type) return -ENOENT; @@ -762,6 +763,21 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) node_xp, type, port); } + /* + * We must NOT create groups containing mixed PMUs, although software + * events are acceptable (for example to create a CCN group + * periodically read when a hrtimer aka cpu-clock leader triggers). + */ + if (event->group_leader->pmu != event->pmu && + !is_software_event(event->group_leader)) + return -EINVAL; + + list_for_each_entry(sibling, &event->group_leader->sibling_list, + group_entry) + if (sibling->pmu != event->pmu && + !is_software_event(sibling)) + return -EINVAL; + /* Allocate the cycle counter */ if (type == CCN_TYPE_CYCLES) { if (test_and_set_bit(CCN_IDX_PMU_CYCLE_COUNTER,