From patchwork Wed Nov 22 07:36:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-Chien Peter Lin X-Patchwork-Id: 1867195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=YAuP0kOo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SZtTs6Wx6z1ySN for ; Wed, 22 Nov 2023 18:41:21 +1100 (AEDT) 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: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=HshQQq2C4GGSgBbZZXFxnEHW8Ha90RSNTF61IppILPU=; b=YAuP0kOoSkYIAR X1f0Lle86oIkfW4HZgWOTCy2C2jxZwE5jfZRB2yLF7H4rfEB0wVehIVn3mPm2nshbrEi6fnWZMU/t hlpO4pun6Wyqa4U6lRdTyei93UZDa/UEUaD3SwkNkfxiqo1NLpzkuFZTkkODvBqGmnyJmDMJrWckF Wf19wAV8vLV8JuCJ+/F/41G2t9iThuthHSR4Tfhg2adMbGaOfhiTrxJmikCCIV4FGUJOyMHaeeO7t NCcrZVS3FenBxNBkzHYALlORuNHGVuxTPyat+l9fcffSh1Qv/Lrk6JmhYIuz1iwcjaMPfcaP+Ky81 2KY+huAVWFk99hU8rZHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5hrC-000w9F-1R; Wed, 22 Nov 2023 07:41:10 +0000 Received: from 60-248-80-70.hinet-ip.hinet.net ([60.248.80.70] helo=Atcsqr.andestech.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5hr8-000w6I-02 for opensbi@lists.infradead.org; Wed, 22 Nov 2023 07:41:09 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 3AM7eZ12090984; Wed, 22 Nov 2023 15:40:35 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from swlinux02.andestech.com (10.0.15.183) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Wed, 22 Nov 2023 15:40:31 +0800 From: Yu Chien Peter Lin To: CC: , , , , , , , , Yu Chien Peter Lin Subject: [PATCH v3 11/15] platform: andes: Factor out is_andes() helper Date: Wed, 22 Nov 2023 15:36:13 +0800 Message-ID: <20231122073617.379441-12-peterlin@andestech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122073617.379441-1-peterlin@andestech.com> References: <20231122073617.379441-1-peterlin@andestech.com> MIME-Version: 1.0 X-Originating-IP: [10.0.15.183] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 3AM7eZ12090984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_234106_500921_CA90D267 X-CRM114-Status: GOOD ( 11.11 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: We will need is_andes(45) in the following patch, so factor out the code that parses marchid to make it reusable for checking any Andes CPU variants. Also improves the comment in ae350_hart_start(). Signed-off-by: Yu Chien Peter Lin Reviewed-by: Anup Patel --- Changes v1 -> v2: - New patch Changes v2 -> v3: - Include Anup's RB tag --- platform/generi [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 TVD_RCVD_IP Message was received from an IP address -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We will need is_andes(45) in the following patch, so factor out the code that parses marchid to make it reusable for checking any Andes CPU variants. Also improves the comment in ae350_hart_start(). Signed-off-by: Yu Chien Peter Lin Reviewed-by: Anup Patel --- Changes v1 -> v2: - New patch Changes v2 -> v3: - Include Anup's RB tag --- platform/generic/andes/ae350.c | 16 +++++++--------- platform/generic/include/andes/andes45.h | 6 ++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/platform/generic/andes/ae350.c b/platform/generic/andes/ae350.c index dc769b7..088ec07 100644 --- a/platform/generic/andes/ae350.c +++ b/platform/generic/andes/ae350.c @@ -24,16 +24,14 @@ static struct smu_data smu = { 0 }; extern void __ae350_enable_coherency_warmboot(void); extern void __ae350_disable_coherency(void); -static __always_inline bool is_andes25(void) -{ - ulong marchid = csr_read(CSR_MARCHID); - return !!(EXTRACT_FIELD(marchid, CSR_MARCHID_MICROID) == 0xa25); -} - static int ae350_hart_start(u32 hartid, ulong saddr) { - /* Don't send wakeup command at boot-time */ - if (!sbi_init_count(hartid) || (is_andes25() && hartid == 0)) + /* + * Don't send wakeup command when: + * 1) boot-time + * 2) the target hart is non-sleepable 25-series hart0 + */ + if (!sbi_init_count(hartid) || (is_andes(25) && hartid == 0)) return sbi_ipi_raw_send(sbi_hartid_to_hartindex(hartid)); /* Write wakeup command to the sleep hart */ @@ -52,7 +50,7 @@ static int ae350_hart_stop(void) * L2-cache, instead of turning it off, it should fall * through and jump to warmboot_addr. */ - if (is_andes25() && hartid == 0) + if (is_andes(25) && hartid == 0) return SBI_ENOTSUPP; if (!smu_support_sleep_mode(&smu, DEEPSLEEP_MODE, hartid)) diff --git a/platform/generic/include/andes/andes45.h b/platform/generic/include/andes/andes45.h index ce31617..01f63d4 100644 --- a/platform/generic/include/andes/andes45.h +++ b/platform/generic/include/andes/andes45.h @@ -43,6 +43,12 @@ #ifndef __ASSEMBLER__ +#define is_andes(series) \ +({ \ + char value = csr_read(CSR_MARCHID) & 0xff; \ + (series) == (value >> 4) * 10 + (value & 0x0f); \ +}) + #define has_andes_pmu() \ ({ \ (((csr_read(CSR_MMSC_CFG) & \