From patchwork Thu May 14 10:50:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 6404461 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 844CD9F374 for ; Thu, 14 May 2015 10:53:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F053E20452 for ; Thu, 14 May 2015 10:53:06 +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 2B0BE20451 for ; Thu, 14 May 2015 10:53:06 +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 1YsqjH-00027t-DL; Thu, 14 May 2015 10:51:03 +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 1YsqjB-0001zp-Gr for linux-arm-kernel@lists.infradead.org; Thu, 14 May 2015 10:50:58 +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 0C52F29; Thu, 14 May 2015 03:49:56 -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 478573F21B; Thu, 14 May 2015 03:50:34 -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 2D02B13F806; Thu, 14 May 2015 05:50:33 -0500 (CDT) From: Pawel Moll To: arm@kernel.org Subject: [PATCH] bus: arm-ccn: Handle correctly no-more-cpus case Date: Thu, 14 May 2015 11:50:24 +0100 Message-Id: <1431600624-10965-1-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <20150514101344.GA20531@mwanda> References: <20150514101344.GA20531@mwanda> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150514_035057_670069_B7922483 X-CRM114-Status: UNSURE ( 7.55 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) Cc: Mark Rutland , kernel-janitors@vger.kernel.org, Pawel Moll , linux-arm-kernel@lists.infradead.org, "Suzuki K. Poulose" 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 When migrating events the driver picks another cpu using cpumask_any_but() function, which returns value >= nr_cpu_ids when there is none available, not a negative value as the code assumed. Fixed now. Reported-by: Dan Carpenter Signed-off-by: Pawel Moll Acked-by: Mark Rutland --- Another day, another arm-ccn.c update... This time Dan's static checker spotted unsigned int target being expected to carry negative values. Fixed now. Interestingly enough, cpumask_any_but() implementation (and its normal prototype) returns int, but version for NR_CPUS == 1 case, inlined in linux/cpumask.h returns unsigned int... drivers/bus/arm-ccn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c index 7d9879e..cc322fb 100644 --- a/drivers/bus/arm-ccn.c +++ b/drivers/bus/arm-ccn.c @@ -1184,7 +1184,7 @@ static int arm_ccn_pmu_cpu_notifier(struct notifier_block *nb, if (!cpumask_test_and_clear_cpu(cpu, &dt->cpu)) break; target = cpumask_any_but(cpu_online_mask, cpu); - if (target < 0) + if (target >= nr_cpu_ids) break; perf_pmu_migrate_context(&dt->pmu, cpu, target); cpumask_set_cpu(target, &dt->cpu);