From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51AB3C4338F for ; Thu, 29 Jul 2021 15:30:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E10960F22 for ; Thu, 29 Jul 2021 15:30:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E10960F22 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i3BnTi5M1wVpllVzsdwTNVXLt6VLGkFwlXMgF0ROTw8=; b=bWl1l50nPw+7bq UuX/c+ZRfATFoQoWVgVA6QNcPGXkLWn9C/taEWyLDbqeE6yRIYPl/sUz5k8fSXGOSE0YKAlHPoH/w 87Ys0o5kBkxfbdPUpqKYFp6GA9mgmsxWAGne6ahiUZpdGzfglvQK1Bbhf0OaJm/5+8/5CFObNrkfH hMX62LQFINobtzLFNMduCMPkELWNIGOhTFQVsTADq6rLzxHjVkIYweWlw2SOLGTJ77EPssY5OWzNj zQxwjEU2PpLb0TpbVQDeh1+g0L6apmNXtArPRTaBfR+uPEqHTfjNJFhHQ9i8x2DI6vj4TNiT5olAO CI5llMGzXhmHzi4iTZZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m97xH-004iQK-7i; Thu, 29 Jul 2021 15:28:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m97qO-004gcs-Vi for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 15:21:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3ABB6D; Thu, 29 Jul 2021 08:21:07 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 22EB13F73D; Thu, 29 Jul 2021 08:21:07 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: Andre.Przywara@arm.com, Jaxson.Han@arm.com, mark.rutland@arm.com, Wei.Chen@arm.com Subject: [boot-wrapper PATCH 08/12] Consistently use logical CPU IDs Date: Thu, 29 Jul 2021 16:20:46 +0100 Message-Id: <20210729152050.23635-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210729152050.23635-1-mark.rutland@arm.com> References: <20210729152050.23635-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_082109_134855_51E589D5 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In some places we assume that the cpu with MPIDR_EL1.Aff* == 0 is the same as logical CPU 0. While this is almost certainly true, it would be best to consistently use the ligical ID. Add a new `this_cpu_logical_id()` helper, and use this in preference to checking the MPIDR_EL1.Aff* bits directly. Signed-off-by: Mark Rutland --- gic-v3.c | 4 +--- gic.c | 3 +-- include/cpu.h | 2 ++ psci.c | 5 ++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gic-v3.c b/gic-v3.c index ae2d2bc..62f9676 100644 --- a/gic-v3.c +++ b/gic-v3.c @@ -101,8 +101,6 @@ void gic_secure_init_primary(void) void gic_secure_init(void) { - uint32_t cpu = read_mpidr(); - uint32_t sre; /* @@ -113,7 +111,7 @@ void gic_secure_init(void) if (!has_gicv3_sysreg()) return; - if (cpu == 0) + if (this_cpu_logical_id() == 0) gic_secure_init_primary(); sre = gic_read_icc_sre(); diff --git a/gic.c b/gic.c index a84779e..04d4289 100644 --- a/gic.c +++ b/gic.c @@ -31,14 +31,13 @@ void gic_secure_init(void) { unsigned int i; - uint32_t cpu = read_mpidr(); void *gicd_base = (void *)GIC_DIST_BASE; void *gicc_base = (void *)GIC_CPU_BASE; /* Set local interrupts to Group 1 (those fields are banked) */ raw_writel(~0, gicd_base + GICD_IGROUPRn); - if (cpu == 0) { + if (this_cpu_logical_id() == 0) { uint32_t typer = raw_readl(gicd_base + GICD_TYPER); /* Set SPIs to Group 1 */ diff --git a/include/cpu.h b/include/cpu.h index 704d6d8..4bfb172 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -25,5 +25,7 @@ unsigned int find_logical_id(unsigned long mpidr); +#define this_cpu_logical_id() find_logical_id(read_mpidr()) + #endif /* !__ASSEMBLY__ */ #endif diff --git a/psci.c b/psci.c index e5d54b7..df5b0f2 100644 --- a/psci.c +++ b/psci.c @@ -35,7 +35,7 @@ static int psci_cpu_on(unsigned long target_mpidr, unsigned long address) { int ret; unsigned int cpu = find_logical_id(target_mpidr); - unsigned int this_cpu = find_logical_id(read_mpidr()); + unsigned int this_cpu = this_cpu_logical_id(); if (cpu == MPIDR_INVALID) return PSCI_RET_INVALID_PARAMETERS; @@ -49,8 +49,7 @@ static int psci_cpu_on(unsigned long target_mpidr, unsigned long address) static int psci_cpu_off(void) { - unsigned long mpidr = read_mpidr(); - unsigned int cpu = find_logical_id(mpidr); + unsigned int cpu = this_cpu_logical_id(); if (cpu == MPIDR_INVALID) return PSCI_RET_DENIED; -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel