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=-16.0 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_SANE_2 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 C8C54C432BE for ; Fri, 30 Jul 2021 17:41:42 +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 938C06054F for ; Fri, 30 Jul 2021 17:41:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 938C06054F 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S66t2WjMWbmQuzckcqKJTfuU5AcTx50IhVfREKgiHIA=; b=XvZDLWTvMsHcJB Zb5GGN5Nwqa4osujkrXoCZTI5jG31d9yt1xWLZu4VvP0trFaCdH2i74Offxw+N5GTTG5fh4x1oG7A FATa2CsdhCleE8yY8pRzkRi1//W31tMi2szFFIvcVrIqHd4Gs2DUkixc+s7eVv14xBZEDbTa0fNw1 jYYJRSdoDi/ADAIky+hTq64CgcIpHZ5JCkF085Sc7zDnffhi2QMNCy+YDbp3C1eQ3CpRoRJhVI2d3 7nduTiwmf5n7yklORZhMootkcQ/Kfy1d0jjMmTHXM+u/uCds52boQm6NYw2bArpSMp7MBOTs+M8e5 bHbJ5CVGRZR/Qad8w4wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9WTy-009igE-Dg; Fri, 30 Jul 2021 17:39:39 +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 1m9WTi-009idM-VU for linux-arm-kernel@lists.infradead.org; Fri, 30 Jul 2021 17:39:24 +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 B63C311B3; Fri, 30 Jul 2021 10:39:21 -0700 (PDT) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E3A7A3F66F; Fri, 30 Jul 2021 10:39:20 -0700 (PDT) Date: Fri, 30 Jul 2021 18:38:30 +0100 From: Andre Przywara To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, Jaxson.Han@arm.com, Wei.Chen@arm.com Subject: Re: [boot-wrapper PATCH 08/12] Consistently use logical CPU IDs Message-ID: <20210730183830.3fcf59e8@slackpad.fritz.box> In-Reply-To: <20210729152050.23635-9-mark.rutland@arm.com> References: <20210729152050.23635-1-mark.rutland@arm.com> <20210729152050.23635-9-mark.rutland@arm.com> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210730_103923_180224_7B2E9199 X-CRM114-Status: GOOD ( 22.12 ) 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: , 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 On Thu, 29 Jul 2021 16:20:46 +0100 Mark Rutland wrote: > 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. logical Indeed, and I think can we can configure the model to have the primary CPU with an MPIDR != 0. > > 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 Reviewed-by: Andre Przywara Cheers, Andre > --- > 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; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel