From patchwork Wed Jun 15 14:40:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 882292 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5FEfMAc027797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 15 Jun 2011 14:41:44 GMT Received: from canuck.infradead.org ([134.117.69.58]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QWrHF-0006lB-G9; Wed, 15 Jun 2011 14:41:06 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QWrHC-0001xW-Ny; Wed, 15 Jun 2011 14:41:02 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QWrGa-0001qO-IC for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2011 14:40:25 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 15 Jun 2011 15:40:21 +0100 Received: from localhost.localdomain ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 15 Jun 2011 15:40:55 +0100 From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 2/4] ARM: pmu: reject duplicate PMU registrations Date: Wed, 15 Jun 2011 15:40:02 +0100 Message-Id: <1308148804-5518-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1308148804-5518-1-git-send-email-mark.rutland@arm.com> References: <1308148804-5518-1-git-send-email-mark.rutland@arm.com> X-OriginalArrivalTime: 15 Jun 2011 14:40:55.0900 (UTC) FILETIME=[3BEFC9C0:01CC2B6A] X-MC-Unique: 111061515402102201 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110615_104024_904792_DA29FB50 X-CRM114-Status: UNSURE ( 9.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] Cc: Mark Rutland X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 15 Jun 2011 14:41:58 +0000 (UTC) Currently, the PMU reservation framework allows for multiple PMUs of the same type to register themselves. This can lead to a bug with the sequence: register_pmu(pmu1); reserve_pmu(pmu_type); register_pmu(pmu2); release_pmu(pmu1); Here, pmu1 cannot be released, and pmu2 cannot be reserved. This patch modifies register_pmu to reject registrations where a PMU is already present, preventing this problem. PMUs which can have multiple instances should not use the PMU reservation framework. Signed-off-by: Mark Rutland Acked-By: Jamie Iles Acked-By: Will Deacon --- arch/arm/kernel/pmu.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c index 87942b9..de6b1b0 100644 --- a/arch/arm/kernel/pmu.c +++ b/arch/arm/kernel/pmu.c @@ -34,13 +34,13 @@ static int __devinit pmu_register(struct platform_device *pdev, return -EINVAL; } - if (pmu_devices[type]) - pr_warning("registering new PMU device type %d overwrites " - "previous registration!\n", type); - else - pr_info("registered new PMU device of type %d\n", - type); + if (pmu_devices[type]) { + pr_warning("rejecting duplicate registration of PMU device " + "type %d.", type); + return -ENOSPC; + } + pr_info("registered new PMU device of type %d\n", type); pmu_devices[type] = pdev; return 0; }