Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751610AbdIOR7t (ORCPT ); Fri, 15 Sep 2017 13:59:49 -0400 Received: from sender-pp-091.zoho.com ([135.84.80.236]:25068 "EHLO sender-pp-091.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbdIOR7s (ORCPT ); Fri, 15 Sep 2017 13:59:48 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=to:cc:from:subject:message-id:date:user-agent:mime-version:content-type; b=hKq5mZ0QqY87Ziil1fZVrlC7WOl1Abyb6BgYHTcW4yWz+X7gU54VDCSjgOOzK99N1uNoYn9/cKKT ohig7m2rftV6d/mhFPBy1QpVxHWerD7O20Lf3Ku9VBG99M+v7q48 To: marc.zyngier@arm.com Cc: tglx@linutronix.de, jason@lakedaemon.net, james.morse@arm.com, sudeep.holla@arm.com, linux-kernel@vger.kernel.org, zijun_hu@htc.com From: zijun_hu Subject: [PATCH v2 1/1] irqchip/gicv3: iterate over possible CPUs by for_each_possible_cpu() Message-ID: Date: Sat, 16 Sep 2017 01:59:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-ZohoMailClient: External Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1268 Lines: 45 From: zijun_hu get_cpu_number() doesn't use existing helper to iterate over possible CPUs, it will cause error in case of discontinuous @cpu_possible_mask such as 0b11110001, such discontinuous @cpu_possible_mask is resulted in likely because one core have failed to come up on a SMP machine fixed by using existing helper for_each_possible_cpu(). Signed-off-by: zijun_hu --- Changes in v2: - more detailed commit messages are offered drivers/irqchip/irq-gic-v3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 519149ec9053..b5df99c6f680 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1042,7 +1042,7 @@ static int get_cpu_number(struct device_node *dn) { const __be32 *cell; u64 hwid; - int i; + int cpu; cell = of_get_property(dn, "reg", NULL); if (!cell) @@ -1056,9 +1056,9 @@ static int get_cpu_number(struct device_node *dn) if (hwid & ~MPIDR_HWID_BITMASK) return -1; - for (i = 0; i < num_possible_cpus(); i++) - if (cpu_logical_map(i) == hwid) - return i; + for_each_possible_cpu(cpu) + if (cpu_logical_map(cpu) == hwid) + return cpu; return -1; } -- 1.9.1