From patchwork Thu Apr 22 11:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=QgxbT63K; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=G8oiVUgM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=dHkZhrE/; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=kqYJ3dd4; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw373VkDz9sTD for ; Thu, 22 Apr 2021 21:21:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=lrm1lltVKZDFRpaPUFLJqBHUcvVag+pLTb9qWuk+si0=; b=QgxbT63KxghgEo3tqyi1PGV4k Xrq5d7jae1wBY1I4KvynDR7FGiscsFzwkLm6ubGrGjoQcveI5ZMsDO8J3HCLDBf47MC0oxgSbCduT 8HZKzCsdo/a9KZITt2mFOVyUYlY8bkezRfH7wDvvU7SGun2WrlVRKwHCGtNgrVVH1eFAZgK1N9b4c 82vA3cg2Bf6juzxC83k/uQrpNdszFxxM7fEAm6g7ksWw1gfNJ8WR55dz5XE4sy8kebvEVuHbYlRz7 OOEUcS84mgZHhOGJ2RPTsT/85qxA56C36qvgh0FmhuCvCQTY70hZKtTeC1hYvvfY5K6nDqPD0jwwi fPu6R6WbQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOI-00GZmA-J5; Thu, 22 Apr 2021 11:21:02 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOF-00GZlh-WA for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=RN+PiFzLhMHEqKH1Hob6PRZseo4dd7f0oEVsX7mozd8=; b=G8oiVUgM/PLXq4wA+ddiOFhw3V BTZ1oijvgI/QCzfPJj4zsCa4IbRWRcGoAY4La2baYd4yiNpXPpYU0cKqRTJ1ZTA8Y5ov+/0dhu0ri 1iQ1T+28z39jAuw2wuqRyqWbR4ItF1n4Re8zn7IFi9dSHp983XmuV90s84GM1yp81uI3C5LeW2bOx YRCkIhnd8VN5H3dWDuYdvEsCDsVb3R5GxWpVMqBICtJcUzDUyuVuZllpGR3fnYIHH+IrIQLsUIERP zkKZ0qrgjvQM2/DTkNFCKM6Xq5hGvEhHPYtQ+YTYOjCuc1mPwfJOq9Pbe3K1r9cHmvGxes1YQj1uj JWn3tnMA==; Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOD-00DbxJ-Be for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:20:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090457; x=1650626457; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=8hptsBqCt/VkEso7DcKRp59kU9xGpTea+VcTGG5ni48=; b=dHkZhrE/txbnpuNcFjQkND1R+kEcOgx/bigWj4PfrPFmRZj3KC9hLiZM UO+iYq0diddl3DCWVG+RB+SX0ngipZTCdSAojgjGJkkDCuCeloYDd5gIw 48xHkzxqfEsdyAY1TucBOyVvllIxItoDIG9k7hbPlSLTT/IFPK0Knkhv2 aUyHCJ4ERsb4dTgbGk0jnf3f3kWcIx8mwLfkyK7x7BYsiuTyaX8IRGNZU p+Ft/YO+QCMEbJSrDIYSOMeaIn6SHSpMfOybrcbq4j7IqKXBJcoLUZgYn S4m0VA/frHUCTi2CGD3VtqNeNoQ9KPnOFY2Xfzr5byuQK3m5a08ZR7aWX Q==; IronPort-SDR: Pt2s+/NSZ8srzKLH4UUKQzuD7qY0LAhmuy+fdy227QNmam1uEYLw7We9Opeyg0xFy5WN4+1Rl4 A2r8qzwVjDdOA+cqJNeiOZ926GQxc52K57TXvBWBwp8o1bsXYETVH9rkD8Lr85v37INpvqtBKb m6XTKVt3s8kM84tOzoZY285iqaZzoRUfC7lBhkG/qqnXX4ifNw+TW2tiGXTtLQ+ccDQjWIsU1x Of22iac6O8/cE3gWYTophaRS/TfBPPZP9rV1C3i4XirscJ08ASuhuLBl8Vbs0z/7hnP8reABvT i38= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="165188456" Received: from mail-bn8nam12lp2173.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.173]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:20:56 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hKBVtjB+J2Hbng7DvdNo6g5t6ni8cDIejupBDx6HaFI3XsjVFl+CcJqlJY/xW4kB5T6Pti6OoY2+OeuqkKxXbW6tNerM1XWj6RYuCnZzdKOOC13vgafK2DE9E7d37VKJr1DSWxx32vGqJr7sZTcBvD0P0nCBqwUBzoA3XPs6E7vS1rt6V90xmh1r3bL5FtzNFAOIULwjbzHsQctgaZLlv3t8JVfkIkPJaaJDASrBhXba2Hl3r1Nk3sHy0OgYlSONr2H6lsrKxSCVSs9GlCj45gct4L9RS7LlhlQEOZJICChz1An64zKaot8M6U4wPn0uiK3Tab6Dc4U//0BrUAFQMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RN+PiFzLhMHEqKH1Hob6PRZseo4dd7f0oEVsX7mozd8=; b=FXrnwtm6oynGao9/POoMWHdQW5cbSOuTxDk7Vulz4zFIEdsH+CAa1xwxqpFRwK1venx/GnPV889qorGQTBI8Lypn6d+BTaVmRaA/CBYaEijTfxg3lbpS5qW+UxL9gns0O+ro8aBN3sOae9ZZ1doqLa8quIQk/j/iTAIJd9Cbhv7E/T3KWWle427Kasw/57mvKFYy4jmuPxYADUkJF/ca2f+UZdT5gsqsoSa9ldHE398jxm+ZuzckgtCXnX/AzIVDy6GbmBtSVTzQnyiEp60IV9LPJ4Eriupb34Q17HnXc7/6AoW0l8A0oUXScc48SNH7dNLoG8HknXpP6ALPeJ30yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RN+PiFzLhMHEqKH1Hob6PRZseo4dd7f0oEVsX7mozd8=; b=kqYJ3dd4+WEv1K2MO6fQuXN+xZG7si4grItQbeoXE6aqfAbq2T71QqzbDFOalckLdUJfIM67qUBAFyucEaAig7DdRI24JU1v0D3vfdzyVinE5iu+wAJ+gVcb572+jMTiWZLqdP5j1xHOrdjCPNBLduXmDngbi65whHYYgfgh2/o= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:20:55 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:20:55 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 1/7] lib: sbi: Remove domains_root_regions() platform callback Date: Thu, 22 Apr 2021 16:50:17 +0530 Message-Id: <20210422112023.670521-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:20:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8550a1b-f86b-4991-04ed-08d90580b231 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yuoufqHmV3jTFzW5R1mxAJn1BemC4ykqOGqWCFH6sfTYJG7ZSbq2BrcntiZWahvRAFDmm1ZoM936YL9PsdGGamNvcbcCySAuSMdBsYp9VDLnyxVnIB3bSRCrsQxkwYtjzttDvGLQfRCGjv5504QImRAZGoQAONW2cgYdfyV1IDXL06C8xtwgwDYPMmbIif0Ru3AYgTmw4BBl3NjIzaLxwDTm8hB9fahbRR7H7LPCrxEbqMKMEXW9d8OqUmY9NcLLEY0UUuMsI/+fh2VS1QzVAiEByy36wp33h8LVpApNFTm4uw3D+qSC7616TffW3V8XNVECNKG0UG53xZ1Zu3T0jN1qT6qCsyT/XXTSFybA/QR1BIbnCys0cTIqd0khORr+VhAXJyPuGQT5RmLnPuE9CuOREeK/Jk3qsv8MqZj4ek08jjCI1MkKKYwSqVEd3V0/JxtO04hL6otla1dvCecd7D68ZJ2XPgV191u9bhnoel4A35uuczMoD3fbeG9F90U3bdvcikYy+hSHR/dgPmsTW7G00APf0AiU/GkXxZD2+yt4Cd0gJ36/1H+JYh8hiaBuNRmo5p28m4bQ8K4GWX3+VMbv2WFbCWU9B6XBoI+BmbCNjmxQALLxCB7juQy6FlrLs2PDmKHqWNoV3uPyY2AbEP0FD2P6tU5i8UR1Ws+1emo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: K0hqbv4/CPjXeDX6lnxvtyWVPWpSbl8+XNSCqcDTCy8htIla2KCb7jdy2ZttBKoFfIfAR3G6qd7Fup48og7QTB5E1Cb4+Ijef8jgXBB2R95CqWgsGpgkioc/RjkVq4aR3H2mycj9Jz3yi2ISLrtkZcVS3YyEmx2ItoyFoVbqs+ejRTQEcasq9d8+TIEMpKmBOHQfQP38vkKXu3KH15XenXD2RPeQm6nWAvFC9Ou7GYh1ozjrlT8ddAT2rHIn17aomnENbeW2pnSPJAsJZONXBvjRNk+PRpIRT3g9+CyTGLnvrAx83eGS8aQSjhUR3d6EaAqq7OOrxwxkJ90+eXEW52r5sDbqd+LCRXr0EKY9ACMZYEU9d9JXP0IpEto5w7DBlxLWIEr4JbIz1pSKwECsS/PowKYXvqHL3I4eiYZEUTMYqEWBoas3D6cY+yC5vFXTVXKyo/JacGs0aFUg0xR+Q/mZWbsAE39lX5YSmUbIC3aoaTzZRuA7WKaznMAwlRN9IrtrXT35AIIzEBNBaCNFwSqhtW3asWhPhy2yDtmydC/3DqwpBW882KNXCOZCpxaF5zNPxkImxP541RwmgKqFI4fSXdRD6ybv2xASAPJAKB8hsncdC2iAkChrx/HDptjq8w3yLgwg/9NtnrK/8eumJ24YoyoN9i0OcB3JuZ4OeDEtbm60dsS0y0k+vCkoVKjMRHVQP694Txir18pu7ZdG2w3X5M/vMmx2agDV9CGYnDWoTblWv438pzEMxrnFYEN19Skldou8FrxBZoXUfI3+JFKWC7Uf3+C0giZIgezdpHFODlqv6iksBwfYLIO+8VzCtWR9QeNWl1p3XRi7PCysNa14kW+Cf7IyYKDClJasH0MHzKxZCPqUzbnv6rTE38bS+11spp4CoDJ3GFWVEMIeee0FwJ49BS7N8AI5bzfNan5GHiryV2f1igP0uNUbbtOClo9KMEigWc7Se7YYh5KrLC6+qvAGIh7uXnYbYDjkjv7k5xI3Ei2nYWx2AyDNcHQpmkCPso6cf6maxLlQlN4eTpGj49eEMi5PT7egvJQj7E0OZ1BCc914rDspYj3msuPRf1+AiPVpMatuWrVpS7BmBYRHfp04dLGXhG1fpVIzPP8vJOqooX81RgXNO1y8ehzazZ7b7k+4dFaci04H4IhbF//BLxIGJJwWSZIqUT58fsTufHwpPw+6SG92C5yFK6ARp1+KyBWzKDzNGWGSfGdmDr+SxcDsXQcD4qf2+hvfZZSExJWDs7vJ0P93M/+pTQ354n2mTAUij3fsknp6uv6JB6VTvfnNgW+9KTx6a1N9LYPn3L6QoBNjDS72vzyHDUCc X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8550a1b-f86b-4991-04ed-08d90580b231 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:20:55.4654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MjBwVdl012l4F8SAwGu4VVHs9nPMpPzqK+YN5Oq2EW0K7cb09tqkevhj9Kn/qBG4c2RRCbKYd7ZFW7jwxQoWUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042057_482113_4C76F7EF X-CRM114-Status: GOOD ( 13.07 ) X-Spam-Score: -2.5 (--) 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 now have sbi_domain_root_add_memregion() which allows platform support to add root domain regions at boot-time so let's remove the domains_root_regions() platform callback which was added for this [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.42 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 now have sbi_domain_root_add_memregion() which allows platform support to add root domain regions at boot-time so let's remove the domains_root_regions() platform callback which was added for this purpose. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Reviewed-by: Xiang W --- include/sbi/sbi_platform.h | 18 ------------------ lib/sbi/sbi_domain.c | 6 ------ 2 files changed, 24 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 837a75d..6736169 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -92,8 +92,6 @@ struct sbi_platform_operations { */ int (*misa_get_xlen)(void); - /** Get platform specific root domain memory regions */ - struct sbi_domain_memregion *(*domains_root_regions)(void); /** Initialize (or populate) domains for the platform */ int (*domains_init)(void); @@ -484,22 +482,6 @@ static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat) return -1; } -/** - * Get platform specific root domain memory regions - * - * @param plat pointer to struct sbi_platform - * - * @return an array of memory regions terminated by a region with order zero - * or NULL for no memory regions - */ -static inline struct sbi_domain_memregion * -sbi_platform_domains_root_regions(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->domains_root_regions) - return sbi_platform_ops(plat)->domains_root_regions(); - return NULL; -} - /** * Initialize (or populate) domains for the platform * diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 69a3795..9a53542 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -592,7 +592,6 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid) { u32 i; - struct sbi_domain_memregion *memregs; const struct sbi_platform *plat = sbi_platform_ptr(scratch); /* Root domain firmware memory region */ @@ -610,11 +609,6 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid) /* Root domain memory region end */ root_memregs[root_memregs_count].order = 0; - /* Use platform specific root memory regions when available */ - memregs = sbi_platform_domains_root_regions(plat); - if (memregs) - root.regions = memregs; - /* Root domain boot HART id is same as coldboot HART id */ root.boot_hartid = cold_hartid; From patchwork Thu Apr 22 11:20:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=GHDsk07u; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=J/D3AaS0; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=HkV2d+2F; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=SlIa6tjM; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw3c6tlSz9sTD for ; Thu, 22 Apr 2021 21:21:32 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=w3iTC5LVkEQi2BMBjmyu9TarKuYL88Bocc0Df6LR/Ws=; b=GHDsk07uUJBrmdEjiI9LsRbuP na3sozaGY8DZgxOfyzVBDPPKUFnxChTiUfuGiqvUUdelYeZMt8jrPh3yNq2RinBEl144dcevRxQ3K iYdiVAJvNIz9MM7GkNOwXuQcr3AyxEGGfZ6pf77/3FE9pFtAB/0H2s2TZdCAn20rQ5WJ529SpCwqn /4ODr1Gna8qwdQykmU8M3aqJYkmQolY70BVTvI+EHWpOFbjAwH77nOF6aOA6W/v1FAygAXXshtAhJ eXkLlwkHqmAF68qk5V9Knq4DYrcNv3JjFzoPtf6nXHeksAlP+aSC1zs/1Lgrd0XlQy3PBuSvX08Fe JWss0y+bQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOi-00GZv2-Ge; Thu, 22 Apr 2021 11:21:28 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOg-00GZtG-JJ for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=MqEKRSr5aOLFQv3k0TLRtn7rDYG1Jma32pqZzkZneSE=; b=J/D3AaS0HfF8TYhtdbwKuhf4JH 6fd0/hsP7dCFAGCFeRvJUcaYR84KWZdvVvqH+siZWAuO6c7eLu+ND2anzLWDCEkUCUZK6JI/88m7g AdkFdtd0+jv86mimVt02zVf3MuhQZIgsSaXVsrCvjokDazGcAoZ5V8P9ZA321uRRxctRbkNFMUe6S qAGHs56Sfa+iG78N314daN6dEyXMUp7rE/Pq2tWWVtFnUDhCq5E+3+c3gaoh+kliBYmJ8cRAP8lXj 6K+Bydzx75B/vWsdnaN+Xvq2+oEMd3KrqiFxrXKn1ZH0bjh0e95ndOHIbQnDX/d63jxdpXzf6usSx xTkO5bYA==; Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOc-00Dc1b-PW for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090481; x=1650626481; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=8WGOC/L25zKBUxRwjj5GVvGX1xarHUeNXw4XMIOYlUo=; b=HkV2d+2FDhAYYYzksPVZaBafw7L7JnWGQRn4bmRrOcw/Dw4mMN1RzT+v 9b+N8l851xtI561/CXSg8lgfmRf2QkVG6VPpONs0RaJL6Iq6Fsc8yjrgX +L94fBn5qApAL8diKjxutvlRm+2/p7XEnrW2M/pEy9PumWU6DgvlsBRA/ RjZTtxiKEQO0vmr3bm+MckXbSIEXAov89QOO4MFQvTvFIHssL3DojzjBK BGAvM6ZN01twkBhmzcbcoTlFlIo4qXZw0NVF99oYaTbLxf5/X+iURqPFX JowAt59ospr6F6N2y9oKEjLSFtYaN6P4NUBtCS6jgsovOHgrk/SrLbtx/ g==; IronPort-SDR: Zt0hnXEi9zVgpQvzUt3HuLIfy+9cQ9iVISyk0Cp4Jsau+tQXEgEEuPb5xJY+WCNqfQBFEZu/jn K7NgVdfu4kSC8GLsZ5uSM5PtCtS+8IpGEXrsasfZivOK86KTrwEqnJvHY2OKpZDg2KqPCin02h /cnNK5CNS5Rkpiv+fiI61KRMzhRIp1zFI8T/5sgT/4gd+Lxch+5UTi2Uu/Y+2YQeRirG80O5Zb 3AVxxNpygbA0Nxy+jKwmLmT3bE30wFUz2piQapUSGqVpM9s4B9JJuHevlZ2+lVyRjCYthbcJSX Vow= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="165856912" Received: from mail-bn8nam11lp2177.outbound.protection.outlook.com (HELO NAM11-BN8-obe.outbound.protection.outlook.com) ([104.47.58.177]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:20:59 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EuRexoVgZf/79TtwfTmFpihaEimQOagl8DkBlZUeZfuA1HiGAZv8eACNTxOSLFV4ExPXTfycJwyGkTjO1SBs3323vDT1yhfksdHb+G37qwF13Z9EFuC0YvwkwK0THjHgS0tmSuR+QGxJDyZTABN9hs7En0dKqRz6LoESIRRXHnxcKpbD4AruWzkZFce7QkIt1hr2Pow/bCfDjur4vVnRF/TSxTCel6fv5RMZdeXYMKpbo6odMXLmelkJ7JQJudCf6YhxL3baGMdq+cwfWA9KxpEDIToTBauagUbns53nt9PIXPozUxzBSvq2/ZqgEVqp5Xqj4UgkImY6KcOFFH6wpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MqEKRSr5aOLFQv3k0TLRtn7rDYG1Jma32pqZzkZneSE=; b=Ez3AlZs5VKiZACN/WRGBU8h1SzpuYty/EyKrYPDJU2Am2kCgrFj2cYcOSGZ06+m1yWBFEONB3MLK/eKqsMlzobABu3dVFgrk+8T6w/eiYwME5JVTEuQsThISGyutrKWlvrALeQGIc4CViTZ4+Qb092EgYP7D1JZEQJB5pRhH2iy+piKxhNy0BOe5zMPqL69tx1pg5JwpaHmwnYEgf6IwZoLXv/cVqwzi3EEgrtVVY/0QvbMCbo0KxX14IST5k/tERpBjYh6BXyc6QQxi2QFH69Fz4upMmNftCDQbkc78tbuHUOhpD1hWCzOhWjjssqJjWkxhGVP9OcM1S8lHcackQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MqEKRSr5aOLFQv3k0TLRtn7rDYG1Jma32pqZzkZneSE=; b=SlIa6tjMq0XC1feDOebThAkdhtFjj/IkqpmwIThMcVXSF8ovn+tlKPM+1IPaShvdAqnUFi3kmsNGSiBTVAl/I8CNmEl/S53LGwV/+x05DNnbkbkGMKGPFmxBZGtg7AmFuhqw6lw3AUjd16t0LZXnhdpLLIrtmszI+kZbedRNBM0= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:20:58 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:20:58 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 2/7] lib: sbi: Simplify console platform operations Date: Thu, 22 Apr 2021 16:50:18 +0530 Message-Id: <20210422112023.670521-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:20:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8297f309-2f54-468a-5b2a-08d90580b390 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OuS/fQmQC9iXEZ4g/XvTCbtogfLLEDXOvIxUcgUrz7y3npG204YT9WlXl4ZMz3TdZzCQ8L3n8S3Rw+OsmegZ9YdZk72pSF14tmbGP4aFzJEvp8cT3XLNi10W3TgcUBlUh2IXUHQ/KbhYHUV7XcwABfqjJlTgeiEQHvST/0JsQC0kCf8MsDHXoT0fPn3zpn3RW0WmxD9HvTfKOcR7dNi2j1YHew6MVtn88xOH1Wu9aWJ5HRK7RHSdpCqgnecUfyNeMRSkNP7fHq4x77Y+NSMT2Mf4wdcIfIXxYWwCuN66MNV0wS5XsZWOZrApIzeR0sJt4VEJ1ZJoDLCkNmtU9gK1MqlynGNFM8iwfkGK9TZlvhK8ZMj/P/+M+qAfpHJnca0/DnoyPB8WKmaFvXV4o7oVSsGf0p4ztH42OzqngJqlpjuGXdvmvaKDY+QBTTwiQqYMJXjAs2ErzfcMMdgN00bMkG7mRYFt2pQJZrs3qY/0HIiUAQXQQVyFt1wGEiFXCH6EiQsDtJBU5Vui+Yfc4JA0romuWSnzfCpE3mRUQGRD7lziY6F+CEyatTO5E/5Uw1VyxhLOY32EptDq7WU2njjliw/CrhQ9B0lvjiNaPu6UGzR3cMKGpIv4pWkur6qOeP8t3y7Nua0NfKkNuMqZezjSPzoxsKmmZFIsvyZQD658JnE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(30864003)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: aqO5wE7zmXZjWSeZcIThMo5VyYT9VELnAfDuycKVlxs54rz0n1PWbDpvea8x9UPZQbNc8doC0K4utzO/9I3BzbR+ohJj0t/WREC0k/X/yohp5vhQfOlC4wvT2LH/wk7QhVvZafJJN2KeobGhmTM+vbHV1fN/ZJaJaGnc1ssm3o3iap3dcAe77sxM8wF9dKQ5/arHsP2+LW877EM9bcOCs0zKNyDD4/zYNJx+4swYtXBKSIC5Ec+jM7FRWXiguIvhyh06T8cKm+4UIvcvRRDE58Az8z3f4WWQT6KTO666oz2mde1hzm1e4g55N1HTGw+vLONtEd3ZjGZLeAOw6LE23AgDRPLK5rCtjaNNMRvc3FDT/4e+rSTWy76OlxuDJanIUuDGUrXmbnlwn6oW5YjnGeap0isHZSng6vzPHfBCGY3M0il/Hj4QNJRVoTMGXskjMswZD7vm7XyMfx6pKzVUbcSGOv/LehBrleikEF69t9id3OfRjGRepSDv/jpW2BWwfWYyS1edNNWjb+TUgIucIAuGEDENmZykoRocMEYui5I3lSeV+8jpJfuDgkttrkRQ8vB/0E/tLuLJt8DEehleNyUxpkO71gJReDdkQUutjOipxoCs8o9oRC9kXmvSvT0Ihor1uHgRhG7or5wLKzDlqu8CvUghd5VYkl18IxyxEJItWSQbfTM1vpYG0bPsnYyG1hSPq5C2k+2hnTW57nyiEQ/xplm6gVhQ5JMNfipPxRNGx4hQskUTX44WV79NzxwoQ85uQT2zD97eBhYi1eiaDDLRVym4ddyHKe87JkOIqghTROKdOYPOz+R7X8z4i9nZ5+pGQ0QbvrB/CTuR3bxJ1EAb+C/TKQV8hUovrg0YpcRnX4hrhsp/+QAaKlWb0XyZq9hUYX2qfyOoJq1V30odDcczfoTWmQ0dTIVcy9ojSBefV9rStbxXq9Sc5g3KUIe6K1v8TEM+Y55sSd+rP7JvmHi64Xj/OJUhNAiB496e+k1CLSCeI44T3zSJiCi9S14XvVzcUv9QWcZl5Y22myCiZ+/cwr6arIO/XVYO/J3zVj3NwjmKavjfQWhrqiXkg8IS8+xzHB4ee/k88eu5IpaWlr1wvvdUxJKaGxyRZawh1CWaT0BI7zTX6Nk3HXNgnj65VGHy1WSrGaZZVO21DAK7ozEyGOuPXMFN1iifahRqOUdnZHzxZjgoLMj/eqyVoEVUjdHJwaJFDQBBRypTLTbsGoGY1RCx1OD7WUCvG5XfeCA3OOmBs3WbO5EE2zId1V1GZNGtFb/rnZMBouUeqlFBriWuUYCfjdbIYW485D/CLKoRESmNUaiTCcXerqC5ubtk X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8297f309-2f54-468a-5b2a-08d90580b390 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:20:58.2576 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cagZLGvY/gcYujWnvBdUiHXtKARarROankrjK8VhEHI9zVpWC5xjaWbE4jhbh0lguhLt4vOkgWz+/rsFzkSmug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042122_882758_2A3CB521 X-CRM114-Status: GOOD ( 19.69 ) X-Spam-Score: -0.9 (/) 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: Instead of having console_putc() and console_getc() callbacks in platform operations, it will be much simpler for console driver to directly register these operations as device to the sbi_console impl [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [216.71.153.144 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 Instead of having console_putc() and console_getc() callbacks in platform operations, it will be much simpler for console driver to directly register these operations as device to the sbi_console implementation. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Reviewed-by: Xiang W --- include/sbi/sbi_console.h | 15 +++++++++++++ include/sbi/sbi_platform.h | 31 -------------------------- include/sbi_utils/serial/fdt_serial.h | 6 ----- include/sbi_utils/serial/shakti-uart.h | 4 ---- include/sbi_utils/serial/sifive-uart.h | 4 ---- include/sbi_utils/serial/uart8250.h | 4 ---- include/sbi_utils/sys/htif.h | 4 +--- lib/sbi/sbi_console.c | 31 +++++++++++++++++++------- lib/utils/serial/fdt_serial.c | 21 ----------------- lib/utils/serial/fdt_serial_htif.c | 10 ++++++--- lib/utils/serial/fdt_serial_shakti.c | 4 +--- lib/utils/serial/fdt_serial_sifive.c | 4 +--- lib/utils/serial/fdt_serial_uart8250.c | 2 -- lib/utils/serial/shakti-uart.c | 12 ++++++++-- lib/utils/serial/sifive-uart.c | 12 ++++++++-- lib/utils/serial/uart8250.c | 13 +++++++++-- lib/utils/sys/htif.c | 20 ++++++++++++++--- platform/andes/ae350/platform.c | 2 -- platform/fpga/ariane/platform.c | 2 -- platform/fpga/openpiton/platform.c | 2 -- platform/generic/platform.c | 2 -- platform/kendryte/k210/platform.c | 2 -- platform/nuclei/ux600/platform.c | 2 -- platform/sifive/fu540/platform.c | 2 -- platform/template/platform.c | 19 ---------------- 25 files changed, 96 insertions(+), 134 deletions(-) diff --git a/include/sbi/sbi_console.h b/include/sbi/sbi_console.h index 7d648f0..e24ba5f 100644 --- a/include/sbi/sbi_console.h +++ b/include/sbi/sbi_console.h @@ -12,6 +12,17 @@ #include +struct sbi_console_device { + /** Name of the console device */ + char name[32]; + + /** Write a character to the console output */ + void (*console_putc)(char ch); + + /** Read a character from the console input */ + int (*console_getc)(void); +}; + #define __printf(a, b) __attribute__((format(printf, a, b))) bool sbi_isprintable(char ch); @@ -32,6 +43,10 @@ int __printf(1, 2) sbi_printf(const char *format, ...); int __printf(1, 2) sbi_dprintf(const char *format, ...); +const struct sbi_console_device *sbi_console_get_device(void); + +void sbi_console_set_device(const struct sbi_console_device *dev); + struct sbi_scratch; int sbi_console_init(struct sbi_scratch *scratch); diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 6736169..0d18ef2 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -95,10 +95,6 @@ struct sbi_platform_operations { /** Initialize (or populate) domains for the platform */ int (*domains_init)(void); - /** Write a character to the platform console output */ - void (*console_putc)(char ch); - /** Read a character from the platform console input */ - int (*console_getc)(void); /** Initialize the platform console */ int (*console_init)(void); @@ -496,33 +492,6 @@ static inline int sbi_platform_domains_init(const struct sbi_platform *plat) return 0; } -/** - * Write a character to the platform console output - * - * @param plat pointer to struct sbi_platform - * @param ch character to write - */ -static inline void sbi_platform_console_putc(const struct sbi_platform *plat, - char ch) -{ - if (plat && sbi_platform_ops(plat)->console_putc) - sbi_platform_ops(plat)->console_putc(ch); -} - -/** - * Read a character from the platform console input - * - * @param plat pointer to struct sbi_platform - * - * @return character read from console input - */ -static inline int sbi_platform_console_getc(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->console_getc) - return sbi_platform_ops(plat)->console_getc(); - return -1; -} - /** * Initialize the platform console * diff --git a/include/sbi_utils/serial/fdt_serial.h b/include/sbi_utils/serial/fdt_serial.h index 08f9799..6451c23 100644 --- a/include/sbi_utils/serial/fdt_serial.h +++ b/include/sbi_utils/serial/fdt_serial.h @@ -15,14 +15,8 @@ struct fdt_serial { const struct fdt_match *match_table; int (*init)(void *fdt, int nodeoff, const struct fdt_match *match); - void (*putc)(char ch); - int (*getc)(void); }; -void fdt_serial_putc(char ch); - -int fdt_serial_getc(void); - int fdt_serial_init(void); #endif diff --git a/include/sbi_utils/serial/shakti-uart.h b/include/sbi_utils/serial/shakti-uart.h index 08043be..bcb019e 100644 --- a/include/sbi_utils/serial/shakti-uart.h +++ b/include/sbi_utils/serial/shakti-uart.h @@ -9,10 +9,6 @@ #include -void shakti_uart_putc(char ch); - -int shakti_uart_getc(void); - int shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate); #endif diff --git a/include/sbi_utils/serial/sifive-uart.h b/include/sbi_utils/serial/sifive-uart.h index f323392..9c465ec 100644 --- a/include/sbi_utils/serial/sifive-uart.h +++ b/include/sbi_utils/serial/sifive-uart.h @@ -12,10 +12,6 @@ #include -void sifive_uart_putc(char ch); - -int sifive_uart_getc(void); - int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate); #endif diff --git a/include/sbi_utils/serial/uart8250.h b/include/sbi_utils/serial/uart8250.h index 0a1b5d3..6b9b48b 100644 --- a/include/sbi_utils/serial/uart8250.h +++ b/include/sbi_utils/serial/uart8250.h @@ -12,10 +12,6 @@ #include -void uart8250_putc(char ch); - -int uart8250_getc(void); - int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, u32 reg_width); diff --git a/include/sbi_utils/sys/htif.h b/include/sbi_utils/sys/htif.h index a431723..8073a44 100644 --- a/include/sbi_utils/sys/htif.h +++ b/include/sbi_utils/sys/htif.h @@ -10,9 +10,7 @@ #include -void htif_putc(char ch); - -int htif_getc(void); +int htif_serial_init(void); int htif_system_reset_check(u32 type, u32 reason); diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 7189b9b..b54f7a2 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -12,7 +12,7 @@ #include #include -static const struct sbi_platform *console_plat = NULL; +static const struct sbi_console_device *console_dev = NULL; static spinlock_t console_out_lock = SPIN_LOCK_INITIALIZER; bool sbi_isprintable(char c) @@ -26,14 +26,18 @@ bool sbi_isprintable(char c) int sbi_getc(void) { - return sbi_platform_console_getc(console_plat); + if (console_dev && console_dev->console_getc) + return console_dev->console_getc(); + return -1; } void sbi_putc(char ch) { - if (ch == '\n') - sbi_platform_console_putc(console_plat, '\r'); - sbi_platform_console_putc(console_plat, ch); + if (console_dev && console_dev->console_putc) { + if (ch == '\n') + console_dev->console_putc('\r'); + console_dev->console_putc(ch); + } } void sbi_puts(const char *str) @@ -390,9 +394,20 @@ int sbi_dprintf(const char *format, ...) return retval; } -int sbi_console_init(struct sbi_scratch *scratch) +const struct sbi_console_device *sbi_console_get_device(void) +{ + return console_dev; +} + +void sbi_console_set_device(const struct sbi_console_device *dev) { - console_plat = sbi_platform_ptr(scratch); + if (!dev || console_dev) + return; - return sbi_platform_console_init(console_plat); + console_dev = dev; +} + +int sbi_console_init(struct sbi_scratch *scratch) +{ + return sbi_platform_console_init(sbi_platform_ptr(scratch)); } diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c index b9ce67e..43c55e8 100644 --- a/lib/utils/serial/fdt_serial.c +++ b/lib/utils/serial/fdt_serial.c @@ -24,34 +24,13 @@ static struct fdt_serial *serial_drivers[] = { &fdt_serial_shakti, }; -static void dummy_putc(char ch) -{ -} - -static int dummy_getc(void) -{ - return -1; -} - static struct fdt_serial dummy = { .match_table = NULL, .init = NULL, - .putc = dummy_putc, - .getc = dummy_getc, }; static struct fdt_serial *current_driver = &dummy; -void fdt_serial_putc(char ch) -{ - current_driver->putc(ch); -} - -int fdt_serial_getc(void) -{ - return current_driver->getc(); -} - int fdt_serial_init(void) { const void *prop; diff --git a/lib/utils/serial/fdt_serial_htif.c b/lib/utils/serial/fdt_serial_htif.c index 32d6953..fae55b8 100644 --- a/lib/utils/serial/fdt_serial_htif.c +++ b/lib/utils/serial/fdt_serial_htif.c @@ -16,9 +16,13 @@ static const struct fdt_match serial_htif_match[] = { { }, }; +static int serial_htif_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + return htif_serial_init(); +} + struct fdt_serial fdt_serial_htif = { .match_table = serial_htif_match, - .init = NULL, - .getc = htif_getc, - .putc = htif_putc + .init = serial_htif_init }; diff --git a/lib/utils/serial/fdt_serial_shakti.c b/lib/utils/serial/fdt_serial_shakti.c index c6385a5..4f91419 100644 --- a/lib/utils/serial/fdt_serial_shakti.c +++ b/lib/utils/serial/fdt_serial_shakti.c @@ -29,7 +29,5 @@ static const struct fdt_match serial_shakti_match[] = { struct fdt_serial fdt_serial_shakti = { .match_table = serial_shakti_match, - .init = serial_shakti_init, - .getc = shakti_uart_getc, - .putc = shakti_uart_putc + .init = serial_shakti_init }; diff --git a/lib/utils/serial/fdt_serial_sifive.c b/lib/utils/serial/fdt_serial_sifive.c index 9e487a2..f4c833c 100644 --- a/lib/utils/serial/fdt_serial_sifive.c +++ b/lib/utils/serial/fdt_serial_sifive.c @@ -32,7 +32,5 @@ static const struct fdt_match serial_sifive_match[] = { struct fdt_serial fdt_serial_sifive = { .match_table = serial_sifive_match, - .init = serial_sifive_init, - .getc = sifive_uart_getc, - .putc = sifive_uart_putc + .init = serial_sifive_init }; diff --git a/lib/utils/serial/fdt_serial_uart8250.c b/lib/utils/serial/fdt_serial_uart8250.c index 5030b82..918193a 100644 --- a/lib/utils/serial/fdt_serial_uart8250.c +++ b/lib/utils/serial/fdt_serial_uart8250.c @@ -34,6 +34,4 @@ static const struct fdt_match serial_uart8250_match[] = { struct fdt_serial fdt_serial_uart8250 = { .match_table = serial_uart8250_match, .init = serial_uart8250_init, - .getc = uart8250_getc, - .putc = uart8250_putc }; diff --git a/lib/utils/serial/shakti-uart.c b/lib/utils/serial/shakti-uart.c index 7c1148e..e77a985 100644 --- a/lib/utils/serial/shakti-uart.c +++ b/lib/utils/serial/shakti-uart.c @@ -23,14 +23,14 @@ static volatile void *uart_base; -void shakti_uart_putc(char ch) +static void shakti_uart_putc(char ch) { while((readw(uart_base + REG_STATUS) & UART_TX_FULL)) ; writeb(ch, uart_base + REG_TX); } -int shakti_uart_getc(void) +static int shakti_uart_getc(void) { u16 status = readw(uart_base + REG_STATUS); if (status & UART_RX_FULL) @@ -38,11 +38,19 @@ int shakti_uart_getc(void) return -1; } +static struct sbi_console_device shakti_console = { + .name = "shakti_uart", + .console_putc = shakti_uart_putc, + .console_getc = shakti_uart_getc +}; + int shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate) { uart_base = (volatile void *)base; u16 baud = (u16)(in_freq/(16 * baudrate)); writew(baud, uart_base + REG_BAUD); + sbi_console_set_device(&shakti_console); + return 0; } diff --git a/lib/utils/serial/sifive-uart.c b/lib/utils/serial/sifive-uart.c index 72c8a62..57d80fa 100644 --- a/lib/utils/serial/sifive-uart.c +++ b/lib/utils/serial/sifive-uart.c @@ -66,7 +66,7 @@ static void set_reg(u32 num, u32 val) writel(val, uart_base + (num * 0x4)); } -void sifive_uart_putc(char ch) +static void sifive_uart_putc(char ch) { while (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL) ; @@ -74,7 +74,7 @@ void sifive_uart_putc(char ch) set_reg(UART_REG_TXFIFO, ch); } -int sifive_uart_getc(void) +static int sifive_uart_getc(void) { u32 ret = get_reg(UART_REG_RXFIFO); if (!(ret & UART_RXFIFO_EMPTY)) @@ -82,6 +82,12 @@ int sifive_uart_getc(void) return -1; } +static struct sbi_console_device sifive_console = { + .name = "sifive_uart", + .console_putc = sifive_uart_putc, + .console_getc = sifive_uart_getc +}; + int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate) { uart_base = (volatile void *)base; @@ -98,5 +104,7 @@ int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate) /* Enable Rx */ set_reg(UART_REG_RXCTRL, UART_RXCTRL_RXEN); + sbi_console_set_device(&sifive_console); + return 0; } diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c index 9635ba8..1cf6624 100644 --- a/lib/utils/serial/uart8250.c +++ b/lib/utils/serial/uart8250.c @@ -8,6 +8,7 @@ */ #include +#include #include /* clang-format off */ @@ -68,7 +69,7 @@ static void set_reg(u32 num, u32 val) writel(val, uart8250_base + offset); } -void uart8250_putc(char ch) +static void uart8250_putc(char ch) { while ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0) ; @@ -76,13 +77,19 @@ void uart8250_putc(char ch) set_reg(UART_THR_OFFSET, ch); } -int uart8250_getc(void) +static int uart8250_getc(void) { if (get_reg(UART_LSR_OFFSET) & UART_LSR_DR) return get_reg(UART_RBR_OFFSET); return -1; } +static struct sbi_console_device uart8250_console = { + .name = "uart8250", + .console_putc = uart8250_putc, + .console_getc = uart8250_getc +}; + int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, u32 reg_width) { @@ -121,5 +128,7 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, /* Set scratchpad */ set_reg(UART_SCR_OFFSET, 0x00); + sbi_console_set_device(&uart8250_console); + return 0; } diff --git a/lib/utils/sys/htif.c b/lib/utils/sys/htif.c index fd70fb9..2fd38a7 100644 --- a/lib/utils/sys/htif.c +++ b/lib/utils/sys/htif.c @@ -6,6 +6,7 @@ */ #include +#include #include #define HTIF_DATA_BITS 48 @@ -98,7 +99,7 @@ static void do_tohost_fromhost(uint64_t dev, uint64_t cmd, uint64_t data) spin_unlock(&htif_lock); } -void htif_putc(char ch) +static void htif_putc(char ch) { /* HTIF devices are not supported on RV32, so do a proxy write call */ volatile uint64_t magic_mem[8]; @@ -109,7 +110,7 @@ void htif_putc(char ch) do_tohost_fromhost(HTIF_DEV_SYSTEM, 0, (uint64_t)(uintptr_t)magic_mem); } #else -void htif_putc(char ch) +static void htif_putc(char ch) { spin_lock(&htif_lock); __set_tohost(HTIF_DEV_CONSOLE, HTIF_CONSOLE_CMD_PUTC, ch); @@ -117,7 +118,7 @@ void htif_putc(char ch) } #endif -int htif_getc(void) +static int htif_getc(void) { int ch; @@ -140,6 +141,19 @@ int htif_getc(void) return ch - 1; } +static struct sbi_console_device htif_console = { + .name = "htif", + .console_putc = htif_putc, + .console_getc = htif_getc +}; + +int htif_serial_init(void) +{ + sbi_console_set_device(&htif_console); + + return 0; +} + int htif_system_reset_check(u32 type, u32 reason) { return 1; diff --git a/platform/andes/ae350/platform.c b/platform/andes/ae350/platform.c index aec91cd..338159d 100644 --- a/platform/andes/ae350/platform.c +++ b/platform/andes/ae350/platform.c @@ -164,8 +164,6 @@ const struct sbi_platform_operations platform_ops = { .final_init = ae350_final_init, .console_init = ae350_console_init, - .console_putc = uart8250_putc, - .console_getc = uart8250_getc, .irqchip_init = ae350_irqchip_init, diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index ea179e5..4f32c42 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -154,8 +154,6 @@ const struct sbi_platform_operations platform_ops = { .early_init = ariane_early_init, .final_init = ariane_final_init, .console_init = ariane_console_init, - .console_putc = uart8250_putc, - .console_getc = uart8250_getc, .irqchip_init = ariane_irqchip_init, .ipi_init = ariane_ipi_init, .ipi_send = clint_ipi_send, diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 5eae477..77403c9 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -180,8 +180,6 @@ const struct sbi_platform_operations platform_ops = { .early_init = openpiton_early_init, .final_init = openpiton_final_init, .console_init = openpiton_console_init, - .console_putc = uart8250_putc, - .console_getc = uart8250_getc, .irqchip_init = openpiton_irqchip_init, .ipi_init = openpiton_ipi_init, .ipi_send = clint_ipi_send, diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 8c1e06f..445cbcf 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -210,8 +210,6 @@ const struct sbi_platform_operations platform_ops = { .early_exit = generic_early_exit, .final_exit = generic_final_exit, .domains_init = generic_domains_init, - .console_putc = fdt_serial_putc, - .console_getc = fdt_serial_getc, .console_init = fdt_serial_init, .irqchip_init = fdt_irqchip_init, .irqchip_exit = fdt_irqchip_exit, diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 0c50af5..495d214 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -149,8 +149,6 @@ const struct sbi_platform_operations platform_ops = { .final_init = k210_final_init, .console_init = k210_console_init, - .console_putc = sifive_uart_putc, - .console_getc = sifive_uart_getc, .irqchip_init = k210_irqchip_init, diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index d0a45a2..4f4f884 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -202,8 +202,6 @@ static void ux600_system_reset(u32 type, u32 reason) const struct sbi_platform_operations platform_ops = { .early_init = ux600_early_init, .final_init = ux600_final_init, - .console_putc = sifive_uart_putc, - .console_getc = sifive_uart_getc, .console_init = ux600_console_init, .irqchip_init = ux600_irqchip_init, .ipi_send = clint_ipi_send, diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c index cdd8293..82f6f75 100644 --- a/platform/sifive/fu540/platform.c +++ b/platform/sifive/fu540/platform.c @@ -156,8 +156,6 @@ static u32 fu540_hart_index2id[FU540_HART_COUNT - 1] = { const struct sbi_platform_operations platform_ops = { .final_init = fu540_final_init, - .console_putc = sifive_uart_putc, - .console_getc = sifive_uart_getc, .console_init = fu540_console_init, .irqchip_init = fu540_irqchip_init, .ipi_send = clint_ipi_send, diff --git a/platform/template/platform.c b/platform/template/platform.c index 5bdb186..fbbac30 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -63,23 +63,6 @@ static int platform_console_init(void) PLATFORM_UART_BAUDRATE, 0, 1); } -/* - * Write a character to the platform console output. - */ -static void platform_console_putc(char ch) -{ - /* Example if the generic UART8250 driver is used */ - uart8250_putc(ch); -} - -/* - * Read a character from the platform console input. - */ -static int platform_console_getc(void) -{ - return uart8250_getc(); -} - /* * Initialize the platform interrupt controller for current HART. */ @@ -198,8 +181,6 @@ static void platform_system_reset(u32 type, u32 reason) const struct sbi_platform_operations platform_ops = { .early_init = platform_early_init, .final_init = platform_final_init, - .console_putc = platform_console_putc, - .console_getc = platform_console_getc, .console_init = platform_console_init, .irqchip_init = platform_irqchip_init, .ipi_send = platform_ipi_send, From patchwork Thu Apr 22 11:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=luZldd/k; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=q0BcexB+; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=KYnd5DPy; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=R/PuN32D; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw3G5hdNz9sTD for ; Thu, 22 Apr 2021 21:21:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=r7tR6yV2cn3LR0X5XXYN7DcNifI9n8AHtzMiDDnIoIA=; b=luZldd/kj5PijetJ+ipbgv3s7 yvx6NmjBy2wqvBECB8LEri8uYJfMtbi+AmmZAisZNZ7diOeHnhhV8mPLQxEwWllGnZ5QS2HMYe/Xi /PyTI7LOOMFnrvzNOHL7rlycOq5vs9wyszY58orhgVPtyAhdtCsHBvqjaonvHWfsgkUPIRea8Qa0J ocFowa413Xx4AKuBGXptvsCLuVzN1ld8i+3NLAeMpr6oFNT7eISe6a3nob/VBrbvu/bybh5Hd3fEr KI+bI+RCGytSSAexC2rwgLvFD6N9BJ30q38vlO4PD06bANH8Pi+XtDLD6zWoFhRSHCQgDgZ2u3pvv kdTH3nOHw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOP-00GZna-8a; Thu, 22 Apr 2021 11:21:09 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXON-00GZn3-1h for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=TSGphSF0vpljoH8cKZ4Dyo5iS7rKLks5kbjQQ+MBBfs=; b=q0BcexB+VPxpXoBsB6CYKQhtP4 FQ2OiCDgdwryKxHYY7DJeX6qeumjhL3kdmW7u1Ln1E5fV82+GDDahlIvzOjcd+YYYE21SPIw9We61 mpkHhphvguFF7QlYpaTCB9XDwAtROcofb9rrDUkh/Y2ityVKPLDtzcnM+DqW7YLMwiS7BEj5JVcdQ SdwWSgtFlAtdgmDExpQyvIze43hh+tVq4niqSNbUerA1egAEGiFGAZKaXg4zSOlqSlO7FCRCyYPtu jW6kbrHrQZRV4fK/5ILWEA96xmN65WNfIxOAy6gHFvFJpeB3aDl3QNFNUBRBhHNtxrR0LAo/y5VUX a10rZRCg==; Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOJ-00Dbxc-4M for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090463; x=1650626463; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=zFZR//HUeyYQlIFXdEgPhoRnYLhzYor5rl2LO7Ac+6I=; b=KYnd5DPyB3/t0X4o/v1e8nZVtHBhRdFNjuOW8pylepOa9u8L9ZwAmHKI J28WTdvoh4WFrDoCXwhGtbj4p/Ov6T+rnBTTgVW/b7em+fHn+rb8Kfqnv p6/Ke61ypbce3UQ2dcCeq1sMGc8b3nDAYK5o5zfq4JI2xirA5G38Mf61Z f8U6ovdIvuiKljJ0GD4c7Fiq3DcGAmuOT3njBbgHTvlhl0AqkvZzYFkcO 1KrG7u9NeVQBhS+zRok/F7oUMsgyTKzCyg6T9PNKe0H6xmSX7GPds2cGL WUi1p52MkX3AaEbZf/h2rBeIwJcTWCiCFtyEonW75BBLTZwSmypIUfgXC w==; IronPort-SDR: 6dDg5Jx/tBdY54hQs7GXiJhBInPgsLU/gBFEp3eDUGxbS4EJPGjUSUgtmQvQZkDNw72ZcOi1/s m7YBIgVQ2lHQ5YvwPFSsSsrKfCoyPm7jM6eGgmIUHxC8XJ9odAiOByV6P6tkMm390sLRj7gLur UcV5bQsUMia05YPfemzwb5x/EEU7C6nHKAifioCF/zcLv9HGN+KFdniFChXA1m25v62G3RRKiB P7aTyARqWgS3E6wDtw5OmZ6ib+9RCWycu7CGiyyYX/wfLy9Mj0b7Ou+TaXH9M7MonMQnHSPVLc fkE= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="165188485" Received: from mail-bn8nam12lp2174.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.174]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:21:02 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jSwSSazM05CMMOyZo1L6SOgwy5fXTa2G3kAcWbBqdahl3fwdmADk2Ufb8uSSmBrq7GnAp5A5QdWO9RgjzN41RnavcwmcsOjKQhLb3z6l9Qd4Yb2tZ0/Ek9rCE9nCHsW9xBnwejTm1PtDdAH0DuFuoBTEeAeMzdTVPW7vbVhqPt2mgPnwSQw4IY3guvS8t2kHaIYxKh6onPoLWzCYk6Ovsi5Zg5+5Y2eQt3qXEXnH/tRmyFZv8jzYmEafDAqM+T+m/858rpDdwetgpGUSfNQcbFguKWWb0VP+tQPNwhQNu+XQGd3WrrYUE10j28qZ5arO9pRoIuxigb20kGuX6S4jrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TSGphSF0vpljoH8cKZ4Dyo5iS7rKLks5kbjQQ+MBBfs=; b=H4RqAhQjFvOPaFQNLqEY9UbHqd5MHat6J2Z9tD8q4ekzEzLhqMEQJaKrF5go/FZOtLVkumEJyANb13/kijkZ5/415l3y7Vl5X3S8BERKtf7Omj3GLmvmauYp3sszivJdbnCq3Dmr9j5iE5hZXcyLIlMdDzN1eIkujdDeAsEygoErnFZ3aEnXFEUKsXs9X/GZeIstn8WHMxSlBVDgQbEj+FgUHfvoqjlLzsskRQGfGWCdMfT2xKTY7RHmmH4xz0+aY1dFIx28LpnQTzDaGPMsLpGue2JifVWXZZSQdIYDEQBoTfaCz0pOia+GA+YibpnckdcnWrHu5u/dziB73mxmYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TSGphSF0vpljoH8cKZ4Dyo5iS7rKLks5kbjQQ+MBBfs=; b=R/PuN32DrD/L/DgQn1b/DTExpKoHCBkRnOmEZp1VI/seoi5RCLdwYtJfFmov4Zevo/3f8gE89xa6ajK0sYkbjOeegyMKX3rubhjHe3aLhkD9qDz5ksm0V3HQ2SE4UlQ7ilp3x9T5TxJMzYmXUR/B7Tj6IUTJIClR8JiNHyAPkFc= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:21:00 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:21:00 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 3/7] lib: sbi: Simplify timer platform operations Date: Thu, 22 Apr 2021 16:50:19 +0530 Message-Id: <20210422112023.670521-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:20:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0beae7f1-6aa6-4d01-4ea7-08d90580b546 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:296; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q4RT3Hes5CG1zRI5dSaoJuI4Lstc51JUhcjJe3p0NvZ7pQg4hc4OQ530IqgCy+vkZ8VSig2u4oXS2EHFbyJbFKn2klqSZgTPCn99E8r1RoYukNKdvj/trLzeu2L8rtQne+caYyEjxL2ZG5wbKYCc6h+Zh0Uqb1M0PIFFw4COzlzey9q4XEhjwpIOTTQ/Hm3GK5CKBuqpSFHCqMN5BbSMskaqnCQnx+0oL+m2NwKB8kifIVEFXDeoCsCAod52lQ7lS9fCT4kaBA9BMY7jEgwk6C7PPBrrqwKfC9tKDbSRJiDubKEIHQAkdpd1jCYk/bmldh+KmqFi8BVe1+OFDFsVkRns3rufW/+1qdUmjZPf7Lz297nNmWeuOyYQEfcAHTF0FvYhb1C2m+DW0HqlVGghaVAaLt+FUW+5GEjd8sZ9mj+Oz470ARDgF84fbjT5eGWMbCRAb/JMjnAWixyuS2sERYSGDjnXOeF/0NI/fae7r68B1YNKZEexV/JXshM3k2epF8HeXdF8eELROicL6oEvjEjLDarbWUX/lUmmnNFA9oIrFrMOocvdCCWLfcxPeJGtC1ZwggYHp3KPKAQT6BjZKauP5rWcfUqUtuHnxpB2CSkbIpD0Tq/OovcDHni3TpN1YJ/W8DXbVfJp3lTurfSXog== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(30864003)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pOVFsIHWyf8KQPSYDR6PyfKjiWE83KlKkwNSB/Di/I3cvJtsiDkG7PdqGonBhQ4mWvNa8pJwiwAVHZ0fL5ePlZ2bspngHI9z1GflbAjz0LWvoXWViUwtLx7y9piKcDg8EGrxwcnaDUrV68mGJ9tEotnNfzemGWwUnILBxTtqh6YCewA+07sJ1gJZ/WB3xS+j2JDe+3Rx2I0VTlFmVKRDFYNdheVOywkjdVpNSheThW0vvkpwyro88wBSv7zdDI0ZjNcxGnuuM4WAp0vIIXrxX9TREiytEhIxLJBU5Rr1wOYCAvDojd6+VHFOumMsatEaYq4aZWKBc1Ww5yBSijARfvRprVEb2uFCpzuTMBe5n7UgNujmJqT7Y9YE9fwgQkDa666X6F2nDXtbJsi9VoTPACY7sQVr3C6CDyX52lYVhagLBw6X4SDUL63HUhBACgUnU0DK1jPMzhZyBR5azg9KmE5zrkqMrP7vVDQpx3Ev0x/YwwVbd/RQJPePRqN+iNvV7VXxyAV223+5egYXdooI8AqZI0TLty/gIkznfdShpQTvhmRiJ3p3+PeG7VZ7kIKBjVutAZSufMUGp2mF/Q/8yHUWkqUGIj6y4elN/s4KuG6CaAhTDofoUKVz+TU5OJzNRGozRL6lEHeuk/4bRDhcwa585aCR0TH6A2Yfe5+vqv0umSRrFrY48SVMw88V/iWSR8l7bai6/3e9BBN8UYK+6lS6bmUx6uSaiIdyeenTju/PRQuid4TIPth1Knpoa+w5IdfrG7rzIO5mOCyWjHgAY5f2GFA83TfFly1zIZ78gBsctenYcKxWK+javqzOC6QeU2Q++b25ppwXgHak0uP3EN8Q5+UULNwsBPh4WYEEMLWSKDJQUmuPFGvxak97p/V3Ej9fkK9j5491Z8L7d/iWcfltKsYgOtnBszVmmwI6nEWHc46fZ1TbbWg/UpLHqW1SGL+q1iBUIg9zvmBXLqP+uSxAYAE7R5NYuaU3yduBbgS7sgr4Hfbo54pCkg45hh3K7jBWZceoCIMY1ym+Qa9p+kadqmGG+kY7KHexqsdL8Ok+QAIxnVC6NBAfzYP4F35L8D93KLzg9Hkz6QugVdFvxuHZbjKcf79qMKfoF3GNEgX10esAN4JK14sseKcUTGJ/GQDlsABsjUrvM3P5/cr0yrspvoSrQYw8Leeb3ZrIJF3iUbD2V21IT1vjGGIlz2QBFu7pOLvKkkiHRd8FdM3gBBRZ6GO/MzEOEWQeXm2wcIaDYsR1QBxPDHogxgxNF6x/cnnJfu7QlALdU8SXHZqq5K7UwA4EDXxt1mplozIw/oYPSMTxadjNLXgI0Y70f1OL X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0beae7f1-6aa6-4d01-4ea7-08d90580b546 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:21:00.7450 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uUILs0QEqXigSntLnD7j74KKOOKN1LYYGLBeiseZf5PNCUK7xkXo/tilN8dKzPQG8c8AhcErtfgEsgDljBE1ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042103_305478_44528016 X-CRM114-Status: GOOD ( 17.59 ) X-Spam-Score: -2.5 (--) 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: Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.42 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device to the sbi_timer implementation. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis --- include/sbi/sbi_platform.h | 58 ++--------------------------- include/sbi/sbi_timer.h | 21 +++++++++++ include/sbi_utils/sys/clint.h | 6 --- include/sbi_utils/timer/fdt_timer.h | 9 ----- lib/sbi/sbi_platform.c | 3 -- lib/sbi/sbi_timer.c | 55 +++++++++++++++++---------- lib/utils/sys/clint.c | 22 +++++++++-- lib/utils/timer/fdt_timer.c | 31 --------------- lib/utils/timer/fdt_timer_clint.c | 3 -- platform/andes/ae350/platform.c | 3 -- platform/andes/ae350/plmt.c | 16 ++++++-- platform/andes/ae350/plmt.h | 6 --- platform/fpga/ariane/platform.c | 3 -- platform/fpga/openpiton/platform.c | 3 -- platform/generic/platform.c | 3 -- platform/kendryte/k210/platform.c | 5 +-- platform/nuclei/ux600/platform.c | 3 -- platform/sifive/fu540/platform.c | 3 -- platform/template/platform.c | 30 --------------- platform/thead/c910/platform.c | 1 - 20 files changed, 92 insertions(+), 192 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 0d18ef2..a2084c1 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -51,14 +51,12 @@ struct sbi_trap_regs; /** Possible feature flags of a platform */ enum sbi_platform_features { - /** Platform has timer value */ - SBI_PLATFORM_HAS_TIMER_VALUE = (1 << 0), /** Platform has HART hotplug support */ - SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 1), + SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 0), /** Platform has fault delegation support */ - SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 2), + SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1), /** Platform has custom secondary hart booting support */ - SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 3), + SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 2), /** Last index of Platform features*/ SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_HART_SECONDARY_BOOT, @@ -66,7 +64,7 @@ enum sbi_platform_features { /** Default feature set for a platform */ #define SBI_PLATFORM_DEFAULT_FEATURES \ - (SBI_PLATFORM_HAS_TIMER_VALUE | SBI_PLATFORM_HAS_MFAULTS_DELEGATION) + (SBI_PLATFORM_HAS_MFAULTS_DELEGATION) /** Platform functions */ struct sbi_platform_operations { @@ -115,12 +113,6 @@ struct sbi_platform_operations { /** Get tlb flush limit value **/ u64 (*get_tlbr_flush_limit)(void); - /** Get platform timer value */ - u64 (*timer_value)(void); - /** Start platform timer event for current HART */ - void (*timer_event_start)(u64 next_event); - /** Stop platform timer event for current HART */ - void (*timer_event_stop)(void); /** Initialize platform timer for current HART */ int (*timer_init)(bool cold_boot); /** Exit platform timer for current HART */ @@ -210,9 +202,6 @@ struct sbi_platform { #define sbi_platform_ops(__p) \ ((const struct sbi_platform_operations *)(__p)->platform_ops_addr) -/** Check whether the platform supports timer value */ -#define sbi_platform_has_timer_value(__p) \ - ((__p)->features & SBI_PLATFORM_HAS_TIMER_VALUE) /** Check whether the platform supports HART hotplug */ #define sbi_platform_has_hart_hotplug(__p) \ ((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG) @@ -586,45 +575,6 @@ static inline void sbi_platform_ipi_exit(const struct sbi_platform *plat) sbi_platform_ops(plat)->ipi_exit(); } -/** - * Get platform timer value - * - * @param plat pointer to struct sbi_platform - * - * @return 64-bit timer value - */ -static inline u64 sbi_platform_timer_value(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->timer_value) - return sbi_platform_ops(plat)->timer_value(); - return 0; -} - -/** - * Start platform timer event for current HART - * - * @param plat pointer to struct struct sbi_platform - * @param next_event timer value when timer event will happen - */ -static inline void -sbi_platform_timer_event_start(const struct sbi_platform *plat, u64 next_event) -{ - if (plat && sbi_platform_ops(plat)->timer_event_start) - sbi_platform_ops(plat)->timer_event_start(next_event); -} - -/** - * Stop platform timer event for current HART - * - * @param plat pointer to struct sbi_platform - */ -static inline void -sbi_platform_timer_event_stop(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->timer_event_stop) - sbi_platform_ops(plat)->timer_event_stop(); -} - /** * Initialize the platform timer for current HART * diff --git a/include/sbi/sbi_timer.h b/include/sbi/sbi_timer.h index 87bbdbf..1ba6da0 100644 --- a/include/sbi/sbi_timer.h +++ b/include/sbi/sbi_timer.h @@ -12,6 +12,21 @@ #include +/** Timer hardware device */ +struct sbi_timer_device { + /** Name of the timer operations */ + char name[32]; + + /** Get free-running timer value */ + u64 (*timer_value)(void); + + /** Start timer event for current HART */ + void (*timer_event_start)(u64 next_event); + + /** Stop timer event for current HART */ + void (*timer_event_stop)(void); +}; + struct sbi_scratch; /** Get timer value for current HART */ @@ -35,6 +50,12 @@ void sbi_timer_event_start(u64 next_event); /** Process timer event for current HART */ void sbi_timer_process(void); +/** Get current timer device */ +const struct sbi_timer_device *sbi_timer_get_device(void); + +/** Register timer device */ +void sbi_timer_set_device(const struct sbi_timer_device *dev); + /* Initialize timer */ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot); diff --git a/include/sbi_utils/sys/clint.h b/include/sbi_utils/sys/clint.h index b07cf62..e102196 100644 --- a/include/sbi_utils/sys/clint.h +++ b/include/sbi_utils/sys/clint.h @@ -37,12 +37,6 @@ int clint_warm_ipi_init(void); int clint_cold_ipi_init(struct clint_data *clint); -u64 clint_timer_value(void); - -void clint_timer_event_stop(void); - -void clint_timer_event_start(u64 next_event); - int clint_warm_timer_init(void); int clint_cold_timer_init(struct clint_data *clint, diff --git a/include/sbi_utils/timer/fdt_timer.h b/include/sbi_utils/timer/fdt_timer.h index 770a0f3..36202a4 100644 --- a/include/sbi_utils/timer/fdt_timer.h +++ b/include/sbi_utils/timer/fdt_timer.h @@ -17,17 +17,8 @@ struct fdt_timer { int (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match); int (*warm_init)(void); void (*exit)(void); - u64 (*value)(void); - void (*event_stop)(void); - void (*event_start)(u64 next_event); }; -u64 fdt_timer_value(void); - -void fdt_timer_event_stop(void); - -void fdt_timer_event_start(u64 next_event); - void fdt_timer_exit(void); int fdt_timer_init(bool cold_boot); diff --git a/lib/sbi/sbi_platform.c b/lib/sbi/sbi_platform.c index 568d956..e78119a 100644 --- a/lib/sbi/sbi_platform.c +++ b/lib/sbi/sbi_platform.c @@ -19,9 +19,6 @@ static inline char *sbi_platform_feature_id2string(unsigned long feature) return NULL; switch (feature) { - case SBI_PLATFORM_HAS_TIMER_VALUE: - fstr = "timer"; - break; case SBI_PLATFORM_HAS_HART_HOTPLUG: fstr = "hotplug"; break; diff --git a/lib/sbi/sbi_timer.c b/lib/sbi/sbi_timer.c index b571b17..63e8ea9 100644 --- a/lib/sbi/sbi_timer.c +++ b/lib/sbi/sbi_timer.c @@ -16,10 +16,11 @@ #include static unsigned long time_delta_off; -static u64 (*get_time_val)(const struct sbi_platform *plat); +static u64 (*get_time_val)(void); +static const struct sbi_timer_device *timer_dev = NULL; #if __riscv_xlen == 32 -static u64 get_ticks(const struct sbi_platform *plat) +static u64 get_ticks(void) { u32 lo, hi, tmp; __asm__ __volatile__("1:\n" @@ -31,7 +32,7 @@ static u64 get_ticks(const struct sbi_platform *plat) return ((u64)hi << 32) | lo; } #else -static u64 get_ticks(const struct sbi_platform *plat) +static u64 get_ticks(void) { unsigned long n; @@ -40,9 +41,16 @@ static u64 get_ticks(const struct sbi_platform *plat) } #endif +static u64 get_platform_ticks(void) +{ + return timer_dev->timer_value(); +} + u64 sbi_timer_value(void) { - return get_time_val(sbi_platform_thishart_ptr()); + if (get_time_val) + return get_time_val(); + return 0; } u64 sbi_timer_virt_value(void) @@ -80,7 +88,8 @@ void sbi_timer_set_delta_upper(ulong delta_upper) void sbi_timer_event_start(u64 next_event) { - sbi_platform_timer_event_start(sbi_platform_thishart_ptr(), next_event); + if (timer_dev && timer_dev->timer_event_start) + timer_dev->timer_event_start(next_event); csr_clear(CSR_MIP, MIP_STIP); csr_set(CSR_MIE, MIP_MTIP); } @@ -91,17 +100,34 @@ void sbi_timer_process(void) csr_set(CSR_MIP, MIP_STIP); } +const struct sbi_timer_device *sbi_timer_get_device(void) +{ + return timer_dev; +} + +void sbi_timer_set_device(const struct sbi_timer_device *dev) +{ + if (!dev || timer_dev) + return; + + timer_dev = dev; + if (!get_time_val && timer_dev->timer_value) + get_time_val = get_platform_ticks; +} + int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) { u64 *time_delta; const struct sbi_platform *plat = sbi_platform_ptr(scratch); - int ret; if (cold_boot) { time_delta_off = sbi_scratch_alloc_offset(sizeof(*time_delta), "TIME_DELTA"); if (!time_delta_off) return SBI_ENOMEM; + + if (sbi_hart_has_feature(scratch, SBI_HART_HAS_TIME)) + get_time_val = get_ticks; } else { if (!time_delta_off) return SBI_ENOMEM; @@ -110,24 +136,13 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) time_delta = sbi_scratch_offset_ptr(scratch, time_delta_off); *time_delta = 0; - ret = sbi_platform_timer_init(plat, cold_boot); - if (ret) - return ret; - - if (sbi_hart_has_feature(scratch, SBI_HART_HAS_TIME)) - get_time_val = get_ticks; - else if (sbi_platform_has_timer_value(plat)) - get_time_val = sbi_platform_timer_value; - else - /* There is no method to provide timer value */ - return SBI_ENODEV; - - return 0; + return sbi_platform_timer_init(plat, cold_boot); } void sbi_timer_exit(struct sbi_scratch *scratch) { - sbi_platform_timer_event_stop(sbi_platform_ptr(scratch)); + if (timer_dev && timer_dev->timer_event_stop) + timer_dev->timer_event_stop(); csr_clear(CSR_MIP, MIP_STIP); csr_clear(CSR_MIE, MIP_MTIP); diff --git a/lib/utils/sys/clint.c b/lib/utils/sys/clint.c index 80e04fb..4b1963a 100644 --- a/lib/utils/sys/clint.c +++ b/lib/utils/sys/clint.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define CLINT_IPI_OFF 0 @@ -118,7 +119,7 @@ static void clint_time_wr32(u64 value, volatile u64 *addr) writel_relaxed(value >> 32, (void *)(addr) + 0x04); } -u64 clint_timer_value(void) +static u64 clint_timer_value(void) { struct clint_data *clint = clint_timer_hartid2data[current_hartid()]; @@ -126,7 +127,7 @@ u64 clint_timer_value(void) return clint->time_rd(clint->time_val) + clint->time_delta; } -void clint_timer_event_stop(void) +static void clint_timer_event_stop(void) { u32 target_hart = current_hartid(); struct clint_data *clint = clint_timer_hartid2data[target_hart]; @@ -136,7 +137,7 @@ void clint_timer_event_stop(void) &clint->time_cmp[target_hart - clint->first_hartid]); } -void clint_timer_event_start(u64 next_event) +static void clint_timer_event_start(u64 next_event) { u32 target_hart = current_hartid(); struct clint_data *clint = clint_timer_hartid2data[target_hart]; @@ -146,6 +147,13 @@ void clint_timer_event_start(u64 next_event) &clint->time_cmp[target_hart - clint->first_hartid]); } +static struct sbi_timer_device clint_timer = { + .name = "clint", + .timer_value = clint_timer_value, + .timer_event_start = clint_timer_event_start, + .timer_event_stop = clint_timer_event_stop +}; + int clint_warm_timer_init(void) { u64 v1, v2, mv; @@ -224,5 +232,11 @@ int clint_cold_timer_init(struct clint_data *clint, sbi_domain_memregion_init(clint->addr + CLINT_TIME_CMP_OFF, CLINT_TIME_CMP_SIZE, SBI_DOMAIN_MEMREGION_MMIO, ®); - return sbi_domain_root_add_memregion(®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + + sbi_timer_set_device(&clint_timer); + + return 0; } diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c index d1d0e0c..92198cd 100644 --- a/lib/utils/timer/fdt_timer.c +++ b/lib/utils/timer/fdt_timer.c @@ -17,46 +17,15 @@ static struct fdt_timer *timer_drivers[] = { &fdt_timer_clint }; -static u64 dummy_value(void) -{ - return 0; -} - -static void dummy_event_stop(void) -{ -} - -static void dummy_event_start(u64 next_event) -{ -} - static struct fdt_timer dummy = { .match_table = NULL, .cold_init = NULL, .warm_init = NULL, .exit = NULL, - .value = dummy_value, - .event_stop = dummy_event_stop, - .event_start = dummy_event_start }; static struct fdt_timer *current_driver = &dummy; -u64 fdt_timer_value(void) -{ - return current_driver->value(); -} - -void fdt_timer_event_stop(void) -{ - current_driver->event_stop(); -} - -void fdt_timer_event_start(u64 next_event) -{ - current_driver->event_start(next_event); -} - void fdt_timer_exit(void) { if (current_driver->exit) diff --git a/lib/utils/timer/fdt_timer_clint.c b/lib/utils/timer/fdt_timer_clint.c index 6ba6c7b..0352e53 100644 --- a/lib/utils/timer/fdt_timer_clint.c +++ b/lib/utils/timer/fdt_timer_clint.c @@ -47,7 +47,4 @@ struct fdt_timer fdt_timer_clint = { .cold_init = timer_clint_cold_init, .warm_init = clint_warm_timer_init, .exit = NULL, - .value = clint_timer_value, - .event_stop = clint_timer_event_stop, - .event_start = clint_timer_event_start, }; diff --git a/platform/andes/ae350/platform.c b/platform/andes/ae350/platform.c index 338159d..17a4e48 100644 --- a/platform/andes/ae350/platform.c +++ b/platform/andes/ae350/platform.c @@ -172,9 +172,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_clear = plicsw_ipi_clear, .timer_init = ae350_timer_init, - .timer_value = plmt_timer_value, - .timer_event_start = plmt_timer_event_start, - .timer_event_stop = plmt_timer_event_stop, .vendor_ext_provider = ae350_vendor_ext_provider }; diff --git a/platform/andes/ae350/plmt.c b/platform/andes/ae350/plmt.c index 3848e15..54dcb94 100644 --- a/platform/andes/ae350/plmt.c +++ b/platform/andes/ae350/plmt.c @@ -10,13 +10,14 @@ #include #include +#include static u32 plmt_time_hart_count; static volatile void *plmt_time_base; static volatile u64 *plmt_time_val; static volatile u64 *plmt_time_cmp; -u64 plmt_timer_value(void) +static u64 plmt_timer_value(void) { #if __riscv_xlen == 64 return readq_relaxed(plmt_time_val); @@ -32,7 +33,7 @@ u64 plmt_timer_value(void) #endif } -void plmt_timer_event_stop(void) +static void plmt_timer_event_stop(void) { u32 target_hart = current_hartid(); @@ -48,7 +49,7 @@ void plmt_timer_event_stop(void) #endif } -void plmt_timer_event_start(u64 next_event) +static void plmt_timer_event_start(u64 next_event) { u32 target_hart = current_hartid(); @@ -68,6 +69,13 @@ void plmt_timer_event_start(u64 next_event) } +static struct sbi_timer_device plmt_timer = { + .name = "ae350_plmt", + .timer_value = plmt_timer_value, + .timer_event_start = plmt_timer_event_start, + .timer_event_stop = plmt_timer_event_stop +}; + int plmt_warm_timer_init(void) { u32 target_hart = current_hartid(); @@ -93,5 +101,7 @@ int plmt_cold_timer_init(unsigned long base, u32 hart_count) plmt_time_val = (u64 *)(plmt_time_base); plmt_time_cmp = (u64 *)(plmt_time_base + 0x8); + sbi_timer_set_device(&plmt_timer); + return 0; } diff --git a/platform/andes/ae350/plmt.h b/platform/andes/ae350/plmt.h index 129fcf8..db093e0 100644 --- a/platform/andes/ae350/plmt.h +++ b/platform/andes/ae350/plmt.h @@ -10,12 +10,6 @@ #ifndef _AE350_PLMT_H_ #define _AE350_PLMT_H_ -u64 plmt_timer_value(void); - -void plmt_timer_event_stop(void); - -void plmt_timer_event_start(u64 next_event); - int plmt_warm_timer_init(void); int plmt_cold_timer_init(unsigned long base, u32 hart_count); diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 4f32c42..73c8b9c 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -159,9 +159,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, .timer_init = ariane_timer_init, - .timer_value = clint_timer_value, - .timer_event_start = clint_timer_event_start, - .timer_event_stop = clint_timer_event_stop, }; const struct sbi_platform platform = { diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 77403c9..4d876c9 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -185,9 +185,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, .timer_init = openpiton_timer_init, - .timer_value = clint_timer_value, - .timer_event_start = clint_timer_event_start, - .timer_event_stop = clint_timer_event_stop, }; const struct sbi_platform platform = { diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 445cbcf..cf18a1b 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -218,9 +218,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_init = fdt_ipi_init, .ipi_exit = fdt_ipi_exit, .get_tlbr_flush_limit = generic_tlbr_flush_limit, - .timer_value = fdt_timer_value, - .timer_event_stop = fdt_timer_event_stop, - .timer_event_start = fdt_timer_event_start, .timer_init = fdt_timer_init, .timer_exit = fdt_timer_exit, .system_reset_check = generic_system_reset_check, diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 495d214..c8fd45e 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -160,16 +160,13 @@ const struct sbi_platform_operations platform_ops = { .system_reset = k210_system_reset, .timer_init = k210_timer_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, }; const struct sbi_platform platform = { .opensbi_version = OPENSBI_VERSION, .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01), .name = "Kendryte K210", - .features = SBI_PLATFORM_HAS_TIMER_VALUE, + .features = 0, .hart_count = K210_HART_COUNT, .hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE, .platform_ops_addr = (unsigned long)&platform_ops diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 4f4f884..86130c8 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -207,9 +207,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, .ipi_init = ux600_ipi_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, .timer_init = ux600_timer_init, .system_reset_check = ux600_system_reset_check, .system_reset = ux600_system_reset diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c index 82f6f75..78de30d 100644 --- a/platform/sifive/fu540/platform.c +++ b/platform/sifive/fu540/platform.c @@ -162,9 +162,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_clear = clint_ipi_clear, .ipi_init = fu540_ipi_init, .get_tlbr_flush_limit = fu540_get_tlbr_flush_limit, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, .timer_init = fu540_timer_init, }; diff --git a/platform/template/platform.c b/platform/template/platform.c index fbbac30..1691652 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -133,33 +133,6 @@ static int platform_timer_init(bool cold_boot) return clint_warm_timer_init(); } -/* - * Get platform timer value. - */ -static u64 platform_timer_value(void) -{ - /* Example if the generic CLINT driver is used */ - return clint_timer_value(); -} - -/* - * Start platform timer event for current HART. - */ -static void platform_timer_event_start(u64 next_event) -{ - /* Example if the generic CLINT driver is used */ - clint_timer_event_start(next_event); -} - -/* - * Stop platform timer event for current HART. - */ -static void platform_timer_event_stop(void) -{ - /* Example if the generic CLINT driver is used */ - clint_timer_event_stop(); -} - /* * Check reset type and reason supported by the platform. */ @@ -186,9 +159,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = platform_ipi_send, .ipi_clear = platform_ipi_clear, .ipi_init = platform_ipi_init, - .timer_value = platform_timer_value, - .timer_event_stop = platform_timer_event_stop, - .timer_event_start = platform_timer_event_start, .timer_init = platform_timer_init, .system_reset_check = platform_system_reset_check, .system_reset = platform_system_reset diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c index dfa484a..989ef90 100644 --- a/platform/thead/c910/platform.c +++ b/platform/thead/c910/platform.c @@ -137,7 +137,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_clear = clint_ipi_clear, .timer_init = c910_timer_init, - .timer_event_start = clint_timer_event_start, .system_reset_check = c910_system_reset_check, .system_reset = c910_system_reset, From patchwork Thu Apr 22 11:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=NQ8uVBCX; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mh5GZcan; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Q9icUeZ7; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=Zx9+7Ddu; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw3K1NwJz9sTD for ; Thu, 22 Apr 2021 21:21:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=2+UFf5YwaEZu3JneSMhrPA3H42WQvuTyS7wZCMg6qvs=; b=NQ8uVBCXtl9ptOhQTD2FOXDwj 834U3rnOdVSpS5JYHjEJ/STAx760ErIA4O//ZFZ3MOE9tdhL8ktvIcDQ8Ws2Cda1OAJ8KmyhhwYhx 0/hLuTMskpyxqCWF0HjhSw84zsVMK2sBQ6yW8jFiyoPafyuBREpQmH+H49eCvGwE6EIYdSt8laQQu +EROXTuYZsHCd8jJZx/wXf/ZfRHuKOH5gTfQ8eEKVjGeOSiVvN9bJ5fFyoBx/FqLT0Yyy3XdHlQCy aDTJQaP0VSajW5p7lqsMY/sjb1DQg0xai55JSjbizYMDSgCU0QoFU2RvMkuoG1PILm9L2+lUF5aWe pS6fRoxAg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOS-00GZod-Nc; Thu, 22 Apr 2021 11:21:12 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOP-00GZnU-Hj for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=9Ug6YhgScnKIBE9xD/50iMkcqi+XqeVI3Fn+tf+EcGs=; b=mh5GZcanXiaEUi3K9Bb5JPQGxU Z2fOaGW1k5YMH9S12PxM6WYuh0gH6FQPuJdjnuweMpa0v8q9/mEZjG+7/IeMfoQpjLw95XArHuLZq sHerDrmKlyABBJIc6NUtwBDPRt1Pgr2rwrHCozMSvz853tMpSZicGLrDYOpeYmp7UZo0WS5+Ed23Y +XOYzuNwhxD16wRx3GPO9RYfVlrOSeD8GExQ+EPfVeb4X5YzNhyAP5jZLNl2yYq4QNs0DIJiQ1VG4 qpe4awEctmqfoSi4bTY1TMqjrzMjxrcaN3Pe8I3EP72OyQ0EUOXW9AqA1UVaFn1jVm253e+b+LV4E p5wUBuag==; Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOL-00Dby2-Ux for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090465; x=1650626465; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=GhJCLmMvKXvleu6eqG4oAdM5/IiY3rxkdLX43V8xDpI=; b=Q9icUeZ7IyYqsl2EDWfyQR6b2YMjr5KFscZQ4aESTRg8WhH2NAr3rIIy jMILgKohGEgl/donFJygDiB4NF8b33gWFUVDcOZ7ZX5DmbgVB2AGR1EDg hgKvEQ3nXqdcgqPBLRaz9pvYWfb8Yozr/B3eYRULrGjsrxvAMO9iZo6Fo IzpAKTvjhZ1Z9NjnIKP9Z2L8iLxGAaJz4A7JbMDrSO+pUHEnrz9oDZulY Wfc8supEIXFymIQLamPMqfirB37S6eCaY6cwie6RoKdgiPp7gPq6MQQVZ dfB6OLJf/+Y73Nlw9eZ24a3cypagozVK0jdOXUrc4Y3PfLWlocKbcrlRO g==; IronPort-SDR: GKKRT30qK194Jb16SCDBRDphJS0y0TqXVSnpvCcsd1rbJqwCjPcka6Vz5e5LySylwOin03R5yM 6fRTgYXo9khM9E/bo7iBlZ7+V7IY2aBaP0FwUerdnjOiiy80H5SF8+O2TtZj81vRopAbmEYk69 mVjj+WohxP6SIhQqnBNyDkER4KqFpT8EfJWQNH7Yu82NunpjDcrt4nCRZHvh0d2i1B7IV0RaJj vrKUp+kQHGvPJlqvuAu1TOjk0w1wEROJXIpGV5KzzpVe2xJLbFGmDLoU2STxEblPUKyg8Wz/d/ 028= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="165188492" Received: from mail-bn8nam12lp2175.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.175]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:21:05 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFtmav+ZbNyj7XMqkzdb+RVJ6hVPS1X/5m1qpYj97TYZy+WyQ+yAjP9i9GQOMWBj9Bk2i2MhMvhPqefUL+VW46WHMSuN4yce7GEsmL4HASs0I9NrtcTh6RndVAsKUseBM9hbu5q2g+szPDzbitOmOusrCE58avwvKYn+RwSrR/JvzlDHRXqOBR9S5QErgwk0zWnka4jZbMq6Eq9vPfKiKiWzHmolI3fxii/YcGP+GWZFtS6C3todaqI5ZP3TbIWphqzd9BkXUhSNx1sPeXHABw/1I4mXv9rYqc91J0XsmD5kkIyeoW4LHhR6sEJmUJmPv5KyPZG6WrZQeM7Nu9W73A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Ug6YhgScnKIBE9xD/50iMkcqi+XqeVI3Fn+tf+EcGs=; b=D3L9P6PRS1Q6g/3rcoxUPVBUCLy71zy2rnDvvUOD5DpaMFJ1n4wEqBnVjQJTOCUdn/45Vj31WKyxpm0bsz7NIb8siRed1avI3X2nVqb8aHRkrLkicdJxGHJKBoyeT4VCOIdV+6RU7pjfrxOrIu3zOqvnH8u19deyMdKzfnvvykQdtbaYSUPr35XBU7Z6Q0hJcVMHtqaSDiVzRcjTpsVKsTKpoestrpGMVi7tgaMvQE2UvzyouqP+f20Mms17pykwq3SPnPdeRSpYCZJzCZ3jp32rkGyC9Xc6Yr4sMTeZN0wND7RoGSFrGkvNOGfpiUDxbLffPDI0cFW1ornsLImowA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Ug6YhgScnKIBE9xD/50iMkcqi+XqeVI3Fn+tf+EcGs=; b=Zx9+7DduBU7tHj3UVL3NIoUSfzg6X7UY2VdoYCNvxdkooPRtzIrYwb9povVHwBp+TP+Y3YXsdKfFWa9F+Bnm+rJh8VpBMbnTd3Tqg664eSbtZxY1oozj/XQz5/kEFu7ULmm7AWM6DnPWUUQ2fUemWBpKNFx0pLbgKUwZr5jm1iI= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:21:03 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:21:03 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 4/7] lib: sbi: Simplify ipi platform operations Date: Thu, 22 Apr 2021 16:50:20 +0530 Message-Id: <20210422112023.670521-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:21:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 999e7025-043e-469b-8554-08d90580b6b3 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T9MFAuATtEPSU4tkaI94VstUmASmxRY6xt8W/jJUgu5Q1JzkfXR1T/jFJgG0bHJqGSwD2mjEoOAmGEcwhlVXt5t/KP4hbwhJQ7xOv8wNUQZBfTjVZ4eHFsotN6/LNwKMbyHOOCz7hPNoJ7UkZEZhfrILR7+T8TgT+XbuHB5+tPbdfUAs19FfniLSoIv1/pQG1DPhXpxyru0mc3WWBPiridMl/bsYOrrtnh24e9MFjIc6DJMOAs92HGM8d+9al2hGB73vu/no/mdtcSqjV9+TIyR+T1R1EyceWx2+vxnsYP/PYy0u+ar9r658jGsNAk7nwCUZJtntr8PPd4KYsc6iPvrZX7k1DjrNLVQORIwRWQmY5FfusSHw3hFI8Mctuf0GJNO1lVeksVTGonmaYt8k1J65CyTl+vOnJNZEYr/z04uZyFXHeHwMBsFMlIrhQFwW19lwlwHfIKhfPPZK8iKVDvugUMY5dq4RjMNvZak4pXY5mPOdSnd15JbdstsBm8RVCe99faDv75EtzSs+YMj1DOJL9HbAFUfIp8U4SFVRgDMk1KiDFgM+GV9zd2xnPfcIj6KHGgokx9I4UXtBLnY3Og+XKDgS74bdALGfSKQ75aOQ2H2ObXtbc6gjKScSUnpFd28vTpNV9qunk9w/2fWPVX/qHqyKXD0+tIbUepI322c= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(30864003)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 3zIzqUZl33WUgR5oXHxOXQ7l5mbCNxoG3knmsU25xLTROoh1LFJ79rdgscUR41o332zdY7Bw9pP957HkT7p+700wST9xAJX6z1SUGRdm3MepFz62unzzZDlhks8oxp8knrDqHCntThanb0ngmM0P/k0Dme6dErOkxyLaY9zp7D21WcNCsFDIcans50nfe3u/Pbkm8Kw88qXSeKkWfxwEiov2O/ZZEl4dgHeRAco/6PRlvBtrIw1aEbMcVXmi3VMA619Q9XjGf5dZwh+4bLhb1sC4y6wKHLDm9PPFbSE2zr6eAHZ8gI9GUh4LKpjnn9foLWo/1kWihZsXP0v5FA0hyg25QcmVEEJuif1jIw5DnZz233BZjIHM5CligOdZB6oMd9TXeMD6iKdgz1GoGjI3pWNDOr9JNUzIyy4+QLVBuMnga0bDdOeGA6J0SacBnk9dGWkmBWKdKV3U/jRhPUTk4XyPu8l6afjuFAAWrg6FQl2lCGCH1lcLyAhZu8YgBon1Y7JWz/MzDZHcV9g4SqCm+C5iobUih4cCN8fU40eWKhuYY5pB2sqIUWnN71CfVgiWe4B+XDUDvUfrQMQnv3HMsV1tUWWJ8sVxzbLYq9gw262otLLkaABEC0tIjaHymIT8C8r2HB+xThxwBNs1Z/BcweSTK3LoxE91fMBZK2H324u3fPLkiVSiQq0mXqMZlyINtEcGjELrCuKix94+iyaXh87Hpn3Q84X8bp1jxuROkFfrCaQa1YKG+j1ay4/CMtJMHTwqPWDquy5fNSykstgU+JwLBjgPJN5ecXN3/ZFZKCHSyQjrVIznphtvnPFOVsJXaowll4OikkqEcmek9EqNDCblt1DOnULKI8mg7CJhqIKLDi/NmHrHJ1cjPr+gbrKYGqzMZU+UtGdRviOdCySncrN/Hk2a+U9fpzzzjX0+Xg9JWFMyRnzAefRl0XDGmjQ8Wv/3aeekNx/JWORYRR+UCjzDVB7jWPgV9+2DRWItumXakN3z2DPb0KE1i4CfqxJB42hkxsk78x39JzRs5L890C78zEmbfWDDUGpVT24jfoYuoThyGiuUWlOKZtBy9RAfi09CYipJE3XGB2R9n7nL3Qi+n4S2W4eNSMxmd8Z2uEljiIcZcm9K2DUsx2yJ2LKvOit+AC7XBNf6U9ikjW0M77kgyTy00JkeTUePguDFoGJewi9RvmcA7I3TdEtbOx/WMCf1ps1vDrTVTi48PGsgn4Sdb3yROOPukbcuXXjKgB7dfqdFzRI6sbnmOpFKG5lMinWSg6j2WYvTfAEhDkUT63VXxQQA5P7gEYOUpvBNil5StIDtoGiST3ho0lwgm8R2 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 999e7025-043e-469b-8554-08d90580b6b3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:21:03.6002 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fUJgury3SHlEGJ5+fv4w5SLr8LYyERKPhqq/ALLWvJ9nFSnbaQTof9Qbl8Xm/njmERpzGrDMr2JjJrD1DpI+LA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042106_168345_1DEF9F7D X-CRM114-Status: GOOD ( 19.68 ) X-Spam-Score: -2.5 (--) 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: Instead of having ipi_send() and ipi_clear() callbacks in platform operations, it will be much simpler for ipi driver to directly register these operations as a device to sbi_ipi implementation. Signed-off-by: Anup Patel --- include/sbi/sbi_ipi.h | 18 +++++++++++++++++ include/sbi/sbi_platform.h | 30 include/sbi_utils/ipi/fdt_ipi.h | 6 ------ [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.42 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 Instead of having ipi_send() and ipi_clear() callbacks in platform operations, it will be much simpler for ipi driver to directly register these operations as a device to sbi_ipi implementation. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis --- include/sbi/sbi_ipi.h | 18 +++++++++++++++++ include/sbi/sbi_platform.h | 30 ---------------------------- include/sbi_utils/ipi/fdt_ipi.h | 6 ------ include/sbi_utils/sys/clint.h | 4 ---- lib/sbi/sbi_hsm.c | 2 +- lib/sbi/sbi_init.c | 4 +--- lib/sbi/sbi_ipi.c | 32 ++++++++++++++++++++++++------ lib/utils/ipi/fdt_ipi.c | 20 ------------------- lib/utils/ipi/fdt_ipi_clint.c | 2 -- lib/utils/sys/clint.c | 20 ++++++++++++++++--- platform/andes/ae350/platform.c | 11 ++++++++-- platform/fpga/ariane/platform.c | 2 -- platform/fpga/openpiton/platform.c | 2 -- platform/generic/platform.c | 2 -- platform/kendryte/k210/platform.c | 2 -- platform/nuclei/ux600/platform.c | 2 -- platform/sifive/fu540/platform.c | 2 -- platform/template/platform.c | 20 ------------------- platform/thead/c910/platform.c | 2 -- 19 files changed, 72 insertions(+), 111 deletions(-) diff --git a/include/sbi/sbi_ipi.h b/include/sbi/sbi_ipi.h index 617872c..fb7d658 100644 --- a/include/sbi/sbi_ipi.h +++ b/include/sbi/sbi_ipi.h @@ -18,6 +18,18 @@ /* clang-format on */ +/** IPI hardware device */ +struct sbi_ipi_device { + /** Name of the IPI device */ + char name[32]; + + /** Send IPI to a target HART */ + void (*ipi_send)(u32 target_hart); + + /** Clear IPI for a target HART */ + void (*ipi_clear)(u32 target_hart); +}; + struct sbi_scratch; /** IPI event operations or callbacks */ @@ -63,6 +75,12 @@ int sbi_ipi_send_halt(ulong hmask, ulong hbase); void sbi_ipi_process(void); +void sbi_ipi_raw_send(u32 target_hart); + +const struct sbi_ipi_device *sbi_ipi_get_device(void); + +void sbi_ipi_set_device(const struct sbi_ipi_device *dev); + int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot); void sbi_ipi_exit(struct sbi_scratch *scratch); diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index a2084c1..2756d73 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -101,10 +101,6 @@ struct sbi_platform_operations { /** Exit the platform interrupt controller for current HART */ void (*irqchip_exit)(void); - /** Send IPI to a target HART */ - void (*ipi_send)(u32 target_hart); - /** Clear IPI for a target HART */ - void (*ipi_clear)(u32 target_hart); /** Initialize IPI for current HART */ int (*ipi_init)(bool cold_boot); /** Exit IPI for current HART */ @@ -522,32 +518,6 @@ static inline void sbi_platform_irqchip_exit(const struct sbi_platform *plat) sbi_platform_ops(plat)->irqchip_exit(); } -/** - * Send IPI to a target HART - * - * @param plat pointer to struct sbi_platform - * @param target_hart HART ID of IPI target - */ -static inline void sbi_platform_ipi_send(const struct sbi_platform *plat, - u32 target_hart) -{ - if (plat && sbi_platform_ops(plat)->ipi_send) - sbi_platform_ops(plat)->ipi_send(target_hart); -} - -/** - * Clear IPI for a target HART - * - * @param plat pointer to struct sbi_platform - * @param target_hart HART ID of IPI target - */ -static inline void sbi_platform_ipi_clear(const struct sbi_platform *plat, - u32 target_hart) -{ - if (plat && sbi_platform_ops(plat)->ipi_clear) - sbi_platform_ops(plat)->ipi_clear(target_hart); -} - /** * Initialize the platform IPI support for current HART * diff --git a/include/sbi_utils/ipi/fdt_ipi.h b/include/sbi_utils/ipi/fdt_ipi.h index e817141..9337353 100644 --- a/include/sbi_utils/ipi/fdt_ipi.h +++ b/include/sbi_utils/ipi/fdt_ipi.h @@ -17,14 +17,8 @@ struct fdt_ipi { int (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match); int (*warm_init)(void); void (*exit)(void); - void (*send)(u32 target_hart); - void (*clear)(u32 target_hart); }; -void fdt_ipi_send(u32 target_hart); - -void fdt_ipi_clear(u32 target_hart); - void fdt_ipi_exit(void); int fdt_ipi_init(bool cold_boot); diff --git a/include/sbi_utils/sys/clint.h b/include/sbi_utils/sys/clint.h index e102196..1e2b40b 100644 --- a/include/sbi_utils/sys/clint.h +++ b/include/sbi_utils/sys/clint.h @@ -29,10 +29,6 @@ struct clint_data { void (*time_wr)(u64 value, volatile u64 *addr); }; -void clint_ipi_send(u32 target_hart); - -void clint_ipi_clear(u32 target_hart); - int clint_warm_ipi_init(void); int clint_cold_ipi_init(struct clint_data *clint); diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index bbc4ce9..64d299b 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -238,7 +238,7 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, return sbi_platform_hart_start(plat, hartid, scratch->warmboot_addr); } else { - sbi_platform_ipi_send(plat, hartid); + sbi_ipi_raw_send(hartid); } return 0; diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 4de2dfa..7380d01 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -178,8 +178,6 @@ static void wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid) static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid) { - const struct sbi_platform *plat = sbi_platform_ptr(scratch); - /* Mark coldboot done */ __smp_store_release(&coldboot_done, 1); @@ -190,7 +188,7 @@ static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid) for (int i = 0; i <= sbi_scratch_last_hartid(); i++) { if ((i != hartid) && sbi_hartmask_test_hart(i, &coldboot_wait_hmask)) - sbi_platform_ipi_send(plat, i); + sbi_ipi_raw_send(i); } /* Release coldboot lock */ diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index b50735e..bfaf4e9 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -25,7 +25,7 @@ struct sbi_ipi_data { }; static unsigned long ipi_data_off; - +static const struct sbi_ipi_device *ipi_dev = NULL; static const struct sbi_ipi_event_ops *ipi_ops_array[SBI_IPI_EVENT_MAX]; static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, @@ -33,7 +33,6 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, { int ret; struct sbi_scratch *remote_scratch = NULL; - const struct sbi_platform *plat = sbi_platform_ptr(scratch); struct sbi_ipi_data *ipi_data; const struct sbi_ipi_event_ops *ipi_ops; @@ -61,7 +60,9 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, */ atomic_raw_set_bit(event, &ipi_data->ipi_type); smp_wmb(); - sbi_platform_ipi_send(plat, remote_hartid); + + if (ipi_dev && ipi_dev->ipi_send) + ipi_dev->ipi_send(remote_hartid); if (ipi_ops->sync) ipi_ops->sync(scratch); @@ -178,12 +179,12 @@ void sbi_ipi_process(void) unsigned int ipi_event; const struct sbi_ipi_event_ops *ipi_ops; struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); - const struct sbi_platform *plat = sbi_platform_ptr(scratch); struct sbi_ipi_data *ipi_data = sbi_scratch_offset_ptr(scratch, ipi_data_off); - u32 hartid = current_hartid(); - sbi_platform_ipi_clear(plat, hartid); + + if (ipi_dev && ipi_dev->ipi_clear) + ipi_dev->ipi_clear(hartid); ipi_type = atomic_raw_xchg_ulong(&ipi_data->ipi_type, 0); ipi_event = 0; @@ -201,6 +202,25 @@ skip: }; } +void sbi_ipi_raw_send(u32 target_hart) +{ + if (ipi_dev && ipi_dev->ipi_send) + ipi_dev->ipi_send(target_hart); +} + +const struct sbi_ipi_device *sbi_ipi_get_device(void) +{ + return ipi_dev; +} + +void sbi_ipi_set_device(const struct sbi_ipi_device *dev) +{ + if (!dev || ipi_dev) + return; + + ipi_dev = dev; +} + int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot) { int ret; diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c index 6562469..efca37e 100644 --- a/lib/utils/ipi/fdt_ipi.c +++ b/lib/utils/ipi/fdt_ipi.c @@ -17,35 +17,15 @@ static struct fdt_ipi *ipi_drivers[] = { &fdt_ipi_clint }; -static void dummy_send(u32 target_hart) -{ -} - -static void dummy_clear(u32 target_hart) -{ -} - static struct fdt_ipi dummy = { .match_table = NULL, .cold_init = NULL, .warm_init = NULL, .exit = NULL, - .send = dummy_send, - .clear = dummy_clear }; static struct fdt_ipi *current_driver = &dummy; -void fdt_ipi_send(u32 target_hart) -{ - current_driver->send(target_hart); -} - -void fdt_ipi_clear(u32 target_hart) -{ - current_driver->clear(target_hart); -} - void fdt_ipi_exit(void) { if (current_driver->exit) diff --git a/lib/utils/ipi/fdt_ipi_clint.c b/lib/utils/ipi/fdt_ipi_clint.c index e799fd7..529f978 100644 --- a/lib/utils/ipi/fdt_ipi_clint.c +++ b/lib/utils/ipi/fdt_ipi_clint.c @@ -45,6 +45,4 @@ struct fdt_ipi fdt_ipi_clint = { .cold_init = ipi_clint_cold_init, .warm_init = clint_warm_ipi_init, .exit = NULL, - .send = clint_ipi_send, - .clear = clint_ipi_clear, }; diff --git a/lib/utils/sys/clint.c b/lib/utils/sys/clint.c index 4b1963a..e8c2bd9 100644 --- a/lib/utils/sys/clint.c +++ b/lib/utils/sys/clint.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,7 @@ static struct clint_data *clint_ipi_hartid2data[SBI_HARTMASK_MAX_BITS]; -void clint_ipi_send(u32 target_hart) +static void clint_ipi_send(u32 target_hart) { struct clint_data *clint; @@ -41,7 +42,7 @@ void clint_ipi_send(u32 target_hart) writel(1, &clint->ipi[target_hart - clint->first_hartid]); } -void clint_ipi_clear(u32 target_hart) +static void clint_ipi_clear(u32 target_hart) { struct clint_data *clint; @@ -55,6 +56,12 @@ void clint_ipi_clear(u32 target_hart) writel(0, &clint->ipi[target_hart - clint->first_hartid]); } +static struct sbi_ipi_device clint_ipi = { + .name = "clint", + .ipi_send = clint_ipi_send, + .ipi_clear = clint_ipi_clear +}; + int clint_warm_ipi_init(void) { /* Clear CLINT IPI for current HART */ @@ -66,6 +73,7 @@ int clint_warm_ipi_init(void) int clint_cold_ipi_init(struct clint_data *clint) { u32 i; + int rc; struct sbi_domain_memregion reg; if (!clint) @@ -82,7 +90,13 @@ int clint_cold_ipi_init(struct clint_data *clint) sbi_domain_memregion_init(clint->addr + CLINT_IPI_OFF, CLINT_IPI_SIZE, SBI_DOMAIN_MEMREGION_MMIO, ®); - return sbi_domain_root_add_memregion(®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + + sbi_ipi_set_device(&clint_ipi); + + return 0; } static struct clint_data *clint_timer_hartid2data[SBI_HARTMASK_MAX_BITS]; diff --git a/platform/andes/ae350/platform.c b/platform/andes/ae350/platform.c index 17a4e48..ae4ef71 100644 --- a/platform/andes/ae350/platform.c +++ b/platform/andes/ae350/platform.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -85,6 +86,12 @@ static int ae350_irqchip_init(bool cold_boot) return plic_warm_irqchip_init(&plic, 2 * hartid, 2 * hartid + 1); } +static struct sbi_ipi_device plicsw_ipi = { + .name = "ae350_plicsw", + .ipi_send = plicsw_ipi_send, + .ipi_clear = plicsw_ipi_clear +}; + /* Initialize IPI for current HART. */ static int ae350_ipi_init(bool cold_boot) { @@ -95,6 +102,8 @@ static int ae350_ipi_init(bool cold_boot) AE350_HART_COUNT); if (ret) return ret; + + sbi_ipi_set_device(&plicsw_ipi); } return plicsw_warm_ipi_init(); @@ -168,8 +177,6 @@ const struct sbi_platform_operations platform_ops = { .irqchip_init = ae350_irqchip_init, .ipi_init = ae350_ipi_init, - .ipi_send = plicsw_ipi_send, - .ipi_clear = plicsw_ipi_clear, .timer_init = ae350_timer_init, diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 73c8b9c..42e43fa 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -156,8 +156,6 @@ const struct sbi_platform_operations platform_ops = { .console_init = ariane_console_init, .irqchip_init = ariane_irqchip_init, .ipi_init = ariane_ipi_init, - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear, .timer_init = ariane_timer_init, }; diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 4d876c9..894bfdc 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -182,8 +182,6 @@ const struct sbi_platform_operations platform_ops = { .console_init = openpiton_console_init, .irqchip_init = openpiton_irqchip_init, .ipi_init = openpiton_ipi_init, - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear, .timer_init = openpiton_timer_init, }; diff --git a/platform/generic/platform.c b/platform/generic/platform.c index cf18a1b..4ae8b88 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -213,8 +213,6 @@ const struct sbi_platform_operations platform_ops = { .console_init = fdt_serial_init, .irqchip_init = fdt_irqchip_init, .irqchip_exit = fdt_irqchip_exit, - .ipi_send = fdt_ipi_send, - .ipi_clear = fdt_ipi_clear, .ipi_init = fdt_ipi_init, .ipi_exit = fdt_ipi_exit, .get_tlbr_flush_limit = generic_tlbr_flush_limit, diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index c8fd45e..4b89939 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -153,8 +153,6 @@ const struct sbi_platform_operations platform_ops = { .irqchip_init = k210_irqchip_init, .ipi_init = k210_ipi_init, - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear, .system_reset_check = k210_system_reset_check, .system_reset = k210_system_reset, diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 86130c8..ac81d03 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -204,8 +204,6 @@ const struct sbi_platform_operations platform_ops = { .final_init = ux600_final_init, .console_init = ux600_console_init, .irqchip_init = ux600_irqchip_init, - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear, .ipi_init = ux600_ipi_init, .timer_init = ux600_timer_init, .system_reset_check = ux600_system_reset_check, diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c index 78de30d..a17034d 100644 --- a/platform/sifive/fu540/platform.c +++ b/platform/sifive/fu540/platform.c @@ -158,8 +158,6 @@ const struct sbi_platform_operations platform_ops = { .final_init = fu540_final_init, .console_init = fu540_console_init, .irqchip_init = fu540_irqchip_init, - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear, .ipi_init = fu540_ipi_init, .get_tlbr_flush_limit = fu540_get_tlbr_flush_limit, .timer_init = fu540_timer_init, diff --git a/platform/template/platform.c b/platform/template/platform.c index 1691652..04334b2 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -98,24 +98,6 @@ static int platform_ipi_init(bool cold_boot) return clint_warm_ipi_init(); } -/* - * Send IPI to a target HART - */ -static void platform_ipi_send(u32 target_hart) -{ - /* Example if the generic CLINT driver is used */ - clint_ipi_send(target_hart); -} - -/* - * Clear IPI for a target HART. - */ -static void platform_ipi_clear(u32 target_hart) -{ - /* Example if the generic CLINT driver is used */ - clint_ipi_clear(target_hart); -} - /* * Initialize platform timer for current HART. */ @@ -156,8 +138,6 @@ const struct sbi_platform_operations platform_ops = { .final_init = platform_final_init, .console_init = platform_console_init, .irqchip_init = platform_irqchip_init, - .ipi_send = platform_ipi_send, - .ipi_clear = platform_ipi_clear, .ipi_init = platform_ipi_init, .timer_init = platform_timer_init, .system_reset_check = platform_system_reset_check, diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c index 989ef90..352edb6 100644 --- a/platform/thead/c910/platform.c +++ b/platform/thead/c910/platform.c @@ -133,8 +133,6 @@ const struct sbi_platform_operations platform_ops = { .irqchip_init = c910_irqchip_init, .ipi_init = c910_ipi_init, - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear, .timer_init = c910_timer_init, From patchwork Thu Apr 22 11:20:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=GXrQZNq6; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=eOKF3XV9; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=CrT3HsRg; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=bZ4SVxt7; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw3R6LFHz9sTD for ; Thu, 22 Apr 2021 21:21:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=9G0ETjjogl4yVDYgCy36GHmN2Cc1XeRNcOZMvOYUee0=; b=GXrQZNq6d5xhwvaHlVYSHzGf1 b1bOiFwYNQJhX+e+wdeyYNcCjJ50ejZp8xQ2tp1luQ5Iy3xe6dddVOH9YnqHkJzuHJGA+TeSKs7nU 8MqQLl4fs0L9FyWMkYR11l+noxVo38UNvWhHIO/4NjvJ0bDX1RRjyrfuf7EaT3ejBhf1RSHaSXboh wX/kf2bpZ4xEOEU02nDKji5Nm2C0GUOXrHyVaNlGBYj8d0utzCTP2FHQUYmcHcGS9vUguHKix1Rqy XU/HU6/yg2Fz41OXEGAO6mzKifRyy8tEA4hiXMkIC0XNoI2w5c1qI3IOwScjcADuB7jMh/lOFSIVQ 4DLjNldmg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOY-00GZqE-Sr; Thu, 22 Apr 2021 11:21:18 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOT-00GZow-TJ for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=k420yQDd2CWN4GP/q/HxqfTuRvX2wQm4rauvAk5p86g=; b=eOKF3XV9aXrIBADtsx1ezO92Ku TjXvdDTEy9LKsi62vE+hDAMQgzv389WjINlV4Oy60ECHaYHbQbk0VR897x2K9OEk3gLdeL6q2c2eL 3jcriWQhmQkPgPxGGNZFlpiLcGJ/zGgD6EQMosAhMHpU1dHXTIH+LmLYN0nUe1Q/Ic3PzkhHr6Uaf aSBbxMreGJqkWmqmOy7RIx7QlmuClphTfd0jclpuRcKIWlx0x4Vpi6mHKIxOL7TO5wsPwSHvukszq IICrX1+fmVWApUubEulDlHt/X4npCHOhw5kdDbV5MvtBebU6vMtIF2jwFg4OffhHA0F0avZj3I0DB DofkmuIw==; Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOP-00DbyM-SR for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090470; x=1650626470; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=SXaz/uraiJowwN+vjQ53CbN5eGuPVXxPXq30OyF+LTs=; b=CrT3HsRgZIDHKvgHxsC1II94CFn90Y4MnwpP9x1iVVK460vge18joAPw PN9opHyI62n1JBEVSr+KXpsklT75Cr7+5UsfrXHIpCg3+IuRPwV5oP5dr W9w7ytOlNheFvFQj9SnIISZuYdDAbylA6TGUTh35gDOro9h6OELKsgVl8 59T44Ad5+Qp4L9ztfZvHM/p22HXAm6Y68ftCcayMonRkOgnnPY0i1nz71 vWH1zx2t25IgxwJXrCmtQ5zUM5vCrH9oBa5pxXCtgXUpRjH/pS5AAaPZy m6Iw7/v2ANUwNVkgdyNb3t9zyHIyOSAYnBK745OlsKlUguvUmMReoYk95 w==; IronPort-SDR: y20XiPFbcfU/e/vB2wZn7TQfykNdNV2dZbGim45wkTBS5KIXJMKl4rRssXbTJZ/xG55eWxyBTr VtmFdbQNimZN8Ivlbzq6b3y7UnGCIqFWD5bGIiz5qRDMdrutoHW+vhSZbti9iT4qqa9/Qnobd5 FAZRpavgiB00D31lZpB3PfRZ/j5eigDnb9QNdGG+3LT4WJEx3b5v/TxU6FSuUAgUl/8XGsAJno Lnei7bT4JLxp/2CUTSHxAHgqjSsYbGlROLZ+X4JgC7D/Uem7frQTr9V1i9j1dNWH19ZLEKSH0b 1GU= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="166389008" Received: from mail-dm6nam11lp2171.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.171]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:21:08 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S4J0Yv2OIiZF1WCMD2rRmBWMRA+6DHMQvk4GGZIe3jS8RBXKyIZTOVE4eIOtgDqYv1yiLryvDEnh2dgLk2uG8EfFeAmgvQAJ9EnmcgvmMWKbzin9NZQf1LkI83iHnvfgZKLRPdeknOC3rBeNn+1Nm99t+JxvfJZ6rKK6SBI1kWl1IY2rK3t6AN0aAbmjwkgXOVz3tqjmlmWFJ2RC5aSJUXylUpoE/BrKoGM5v/Vy+uYrMGjY5wFCnr7VzTRzo5TFCeWQah0DrZmto+DMa98zFowF3y01FBJqgzGelquFwRP7g/csqX3/50EK84KnCUgKICd/tT7NTaOfCDs71q4eMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k420yQDd2CWN4GP/q/HxqfTuRvX2wQm4rauvAk5p86g=; b=Uou7WxkV8+r90+uOcicEsSotl1n/D/1vq5ASUX6k+tKtsxZhb0k/M8fQt3UcCtKzODl5auXzTm9sZJUfHhb+tFgpwbC8vl9rnsVOi1Xujzo8VJOBVPOGnFJrBFQJZzi2KLF1ARdCnulY4BPKzyE8V2CvKskdqop4FM1nV/qWQdt8rfsqdanfn7wcRmWKh0LOlLrNQH6tnl/7eX+6GFp/1dSNYej+dd96e+2Cko1y9nEPWGVl16xTfJL4Z6SwALYYHEVuxPqLtpHIN0El1SpLe9cjbgxDcEpdvEiMexCgJ1oQJEvczaE55jKmXvLB4ii0RYUgv0ALtgan97hQfWwJQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k420yQDd2CWN4GP/q/HxqfTuRvX2wQm4rauvAk5p86g=; b=bZ4SVxt7jI1x6EdOssZdQrIH4sXNIrkRKPBCEVLlwe84+r/qkyVoQiK3gDiLSq/79VFV0B/rryli/ONwFsoWyU4ADm56LzhaVCH5KCdTkfqTRHDemPHuxIDUwsjbWV/PhLd+SPp5D2BuQT/VOt62n2W2lZqr7IinrCFNrKhOkBQ= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:21:06 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:21:06 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 5/7] lib: sbi: Simplify system reset platform operations Date: Thu, 22 Apr 2021 16:50:21 +0530 Message-Id: <20210422112023.670521-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:21:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86bcccde-bcd2-4dc0-74de-08d90580b896 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PVnv6r6KTlFvrcOOkCWW10Zcu9UjArm47UnSPIMFiO0Kv7Yt1oNC8MhhoxR/miJD/ZU5yQurHm5PrA3LWexnziuqa3Z7PVCByK2o5Wn81+sgrZX1M+L4tJXYiDLMhDvg/CxqZgzUXn9xojayWj+Va2pzMuRVsfO16Louriiinf5OS+3g0sZZKOzZnYMcgDChruQfwC+od5babad8aZQH+zIjKqV0NzxPcVr3Ef1QVNdg1igwxG1l85gU8hSmCBS+TKhdF/EMIJeh5Q2R07xdfrs8CwQKKf25rvKeG/7abfZXYLsgMvIKAw3HCyo5H7p8nxeD6zdhTxu1RA4Z5w2yTWGPjWWJ2lrTbrTO8m++fwuRjgPMlfgMflHaxTkYsDbDo5FVNR3x+gBvsvX6ZIRdIFQ83oFdnqFElGKnH5PUvyU/midzhqpiuHQTOdqgnSS+wM7hLUY/9ahzHYuxPb4VVWwDs9c+KOsC3xL24e8TN+3lsK92qxgJh9m6V8YRlW5fTHtwRXiJ9KZ0QRqwHM/26YzvBRUznvVoNHEcXI/v9daOx8MPw+XD2N0ztCOwDUMTr8VNm7h/WdXkrBS4EeMel7QwU9xUYfCd3eNbWmZxKUeRZxb8ymcz6CH8TtWR62LXbqiOf4BpAas/AZULHIlEzA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(30864003)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: XfoMzRAW/5M0edMLwyiZJ82awiwBI+CM6ZDcZ+ci4s7otE89VzMqy4qqzpyC/eRgAy7BzBp7PNTMZ5PkldcLVzb3EeH5XN4MwzKm/1jaeRjGVmyTCmq26uMedoMOuPLK4DjMVJe9VZO7AR/vmpkNJJPhosx1s6QTIDLxS3w8RCdH09F3hfcN0r1qwba5AMDFM6LWw7drNIvLuu2hcPUWfF/TI4IkeG5MOSAz8+cdhRS/SST4MfsW84qV4K8w2uhJmaY7x0HJBr866P/tMDwdpIkJUrcXM4sWG+VNPMxNXDkoN0uej33Z8XE4tO71iEUMYrSsZEvYE3GEgdFVFFlUQh26UihjwCEEDPrMHkt05HKFdLwKeaV8/qaJ9JQxgw6DDX530/5auQocxvBzCHnhQN5fS1fzvI4irDj7cGlbR7Z0XakCevmtCkCJqsHlrl649TzobOkJBZgdau8IeGzO39uiyrr6cOWLu0C8NwHlpNhyvgwiync3e3/mIN9wcNVYk349ATXrkUulgo3DpEqgHvuMTfDsAdE354S8Lf+AzETllTUi5oRNXkPZYYVHX8vgIgWYQwRkXH291RFPB29G5dbCuYnHbcp91XTrhYVvHl1JmR3tWTzvt9lk57DzhV3gqEh9l2nRzlK5/yl206ZRWDouk0KJOpWWZBbS+EEkL0NzPrrIt0wOmeAS8Qea6JfxQrbm3U5GWWROCnDZtGCJbY25x+AzSBP7zSVBo7K+2POtx61NvrkU1m3x8TN+0sDBEXfJwfwrlI8kvr/FbsXDCdgORLuEYNlcAWMfJzxyTa8PsWxMnD7rZE3IjXo+gkKKKG80RYK2ktNycdvL51eWfsA2mS+1GivOqx3BrphGzD7BY21fCNGZ5PYSipryB/tk/TkrJYRgycx9zxXw1FV4kupRq8UM0Qu4fK+rpY6xlnCiUNwCFNbIQYXm+Lv0nn9yH5lzKKHbhQz7Vn6JfqUQIXBnZYSUsNsTWRAeN7ucP7X5ItmUAZvQLZJl7nYiCnY+YeFSxOhSfjy3pCaWaabX7R4a43U5CGItjskW8DdyoS+BococH4qDD38MMZRcfDbXIv039MuoSd9/OGJyhyDqZrDPfvOVkIvRDretAD7RLjRh7oPLUP3BPS73hgBWWiJPi1niSWkssNIH4uAFmnTsN9vgf6+E6qzzNAp2+F8TCzlC9HuP7Bm5M1pSFQRk4WiQ58OWWVybVLyHZ3zEfWprXnreD39aHQct+KF+IdBniYCNfQLIyOUI7jJZ/3OoTAMdfp82EcXhkf85JUbnx8GZYHOfvmuOxRpWneDN3Wu+u7HBrYXekRZWYUs2VKs8SBXi X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86bcccde-bcd2-4dc0-74de-08d90580b896 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:21:06.2205 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iMenGeyqsoJ6/8PBp79qGRuyPbGo/ZXNnA3ukh+JZyUH5BKmUQ3uEUYmxah1TmUROlxRCBF56BJiwd48MhGjmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042110_094821_C3BC62D7 X-CRM114-Status: GOOD ( 23.08 ) X-Spam-Score: -0.9 (/) 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: Instead of having system_reset_check() and system_reset() callbacks in platform operations, it will be much simpler for reset driver to directly register these operations as a device to the sbi_system [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [216.71.154.45 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 Instead of having system_reset_check() and system_reset() callbacks in platform operations, it will be much simpler for reset driver to directly register these operations as a device to the sbi_system implementation. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis --- include/sbi/sbi_platform.h | 40 --------------- include/sbi/sbi_system.h | 16 ++++++ include/sbi_utils/reset/fdt_reset.h | 6 --- include/sbi_utils/sys/htif.h | 4 +- include/sbi_utils/sys/sifive_test.h | 4 -- lib/sbi/sbi_system.c | 25 ++++++++-- lib/utils/reset/fdt_reset.c | 14 ------ lib/utils/reset/fdt_reset_htif.c | 9 +++- lib/utils/reset/fdt_reset_sifive.c | 2 - lib/utils/reset/fdt_reset_thead.c | 34 ++++++++----- lib/utils/sys/htif.c | 18 ++++++- lib/utils/sys/sifive_test.c | 12 ++++- platform/generic/include/platform_override.h | 4 -- platform/generic/platform.c | 22 --------- platform/kendryte/k210/platform.c | 52 +++++++++++++------- platform/nuclei/ux600/platform.c | 38 ++++++++------ platform/template/platform.c | 19 +------ platform/thead/c910/platform.c | 32 +++++++----- 18 files changed, 167 insertions(+), 184 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 2756d73..921d39c 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -127,11 +127,6 @@ struct sbi_platform_operations { */ int (*hart_suspend)(u32 suspend_type, ulong raddr); - /* Check whether reset type and reason supported by the platform */ - int (*system_reset_check)(u32 reset_type, u32 reset_reason); - /** Reset the platform */ - void (*system_reset)(u32 reset_type, u32 reset_reason); - /** platform specific SBI extension implementation probe function */ int (*vendor_ext_check)(long extid); /** platform specific SBI extension implementation provider */ @@ -572,41 +567,6 @@ static inline void sbi_platform_timer_exit(const struct sbi_platform *plat) sbi_platform_ops(plat)->timer_exit(); } -/** - * Check whether reset type and reason supported by the platform - * - * @param plat pointer to struct sbi_platform - * @param reset_type type of reset - * @param reset_reason reason for reset - * - * @return 0 if reset type and reason not supported and 1 if supported - */ -static inline int sbi_platform_system_reset_check( - const struct sbi_platform *plat, - u32 reset_type, u32 reset_reason) -{ - if (plat && sbi_platform_ops(plat)->system_reset_check) - return sbi_platform_ops(plat)->system_reset_check(reset_type, - reset_reason); - return 0; -} - -/** - * Reset the platform - * - * This function will not return for supported reset type and reset reason - * - * @param plat pointer to struct sbi_platform - * @param reset_type type of reset - * @param reset_reason reason for reset - */ -static inline void sbi_platform_system_reset(const struct sbi_platform *plat, - u32 reset_type, u32 reset_reason) -{ - if (plat && sbi_platform_ops(plat)->system_reset) - sbi_platform_ops(plat)->system_reset(reset_type, reset_reason); -} - /** * Check if a vendor extension is implemented or not. * diff --git a/include/sbi/sbi_system.h b/include/sbi/sbi_system.h index 34ba766..a9fa546 100644 --- a/include/sbi/sbi_system.h +++ b/include/sbi/sbi_system.h @@ -12,6 +12,22 @@ #include +/** System reset hardware device */ +struct sbi_system_reset_device { + /** Name of the system reset device */ + char name[32]; + + /* Check whether reset type and reason supported by the device */ + int (*system_reset_check)(u32 reset_type, u32 reset_reason); + + /** Reset the system */ + void (*system_reset)(u32 reset_type, u32 reset_reason); +}; + +const struct sbi_system_reset_device *sbi_system_reset_get_device(void); + +void sbi_system_reset_set_device(const struct sbi_system_reset_device *dev); + bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason); void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason); diff --git a/include/sbi_utils/reset/fdt_reset.h b/include/sbi_utils/reset/fdt_reset.h index cce441a..6d58697 100644 --- a/include/sbi_utils/reset/fdt_reset.h +++ b/include/sbi_utils/reset/fdt_reset.h @@ -15,14 +15,8 @@ struct fdt_reset { const struct fdt_match *match_table; int (*init)(void *fdt, int nodeoff, const struct fdt_match *match); - int (*system_reset_check)(u32 reset_type, u32 reset_reason); - void (*system_reset)(u32 reset_type, u32 reset_reason); }; -int fdt_system_reset_check(u32 reset_type, u32 reset_reason); - -void fdt_system_reset(u32 reset_type, u32 reset_reason); - int fdt_reset_init(void); #endif diff --git a/include/sbi_utils/sys/htif.h b/include/sbi_utils/sys/htif.h index 8073a44..9cc9634 100644 --- a/include/sbi_utils/sys/htif.h +++ b/include/sbi_utils/sys/htif.h @@ -12,8 +12,6 @@ int htif_serial_init(void); -int htif_system_reset_check(u32 type, u32 reason); - -void htif_system_reset(u32 type, u32 reason); +int htif_system_reset_init(void); #endif diff --git a/include/sbi_utils/sys/sifive_test.h b/include/sbi_utils/sys/sifive_test.h index 958622e..0a09499 100644 --- a/include/sbi_utils/sys/sifive_test.h +++ b/include/sbi_utils/sys/sifive_test.h @@ -12,10 +12,6 @@ #include -int sifive_test_system_reset_check(u32 type, u32 reason); - -void sifive_test_system_reset(u32 type, u32 reason); - int sifive_test_init(unsigned long base); #endif diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index 10915b4..479060b 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -18,10 +18,25 @@ #include #include +static const struct sbi_system_reset_device *reset_dev = NULL; + +const struct sbi_system_reset_device *sbi_system_reset_get_device(void) +{ + return reset_dev; +} + +void sbi_system_reset_set_device(const struct sbi_system_reset_device *dev) +{ + if (!dev || reset_dev) + return; + + reset_dev = dev; +} + bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason) { - if (sbi_platform_system_reset_check(sbi_platform_thishart_ptr(), - reset_type, reset_reason)) + if (reset_dev && reset_dev->system_reset_check && + reset_dev->system_reset_check(reset_type, reset_reason)) return TRUE; return FALSE; @@ -47,9 +62,9 @@ void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason) sbi_hsm_hart_stop(scratch, FALSE); /* Platform specific reset if domain allowed system reset */ - if (dom->system_reset_allowed) - sbi_platform_system_reset(sbi_platform_ptr(scratch), - reset_type, reset_reason); + if (dom->system_reset_allowed && + reset_dev && reset_dev->system_reset) + reset_dev->system_reset(reset_type, reset_reason); /* If platform specific reset did not work then do sbi_exit() */ sbi_exit(scratch); diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c index 82532c2..b01b0d1 100644 --- a/lib/utils/reset/fdt_reset.c +++ b/lib/utils/reset/fdt_reset.c @@ -23,20 +23,6 @@ static struct fdt_reset *reset_drivers[] = { static struct fdt_reset *current_driver = NULL; -int fdt_system_reset_check(u32 reset_type, u32 reset_reason) -{ - if (current_driver && current_driver->system_reset_check) - return current_driver->system_reset_check(reset_type, - reset_reason); - return 0; -} - -void fdt_system_reset(u32 reset_type, u32 reset_reason) -{ - if (current_driver && current_driver->system_reset) - current_driver->system_reset(reset_type, reset_reason); -} - int fdt_reset_init(void) { int pos, noff, rc; diff --git a/lib/utils/reset/fdt_reset_htif.c b/lib/utils/reset/fdt_reset_htif.c index 587e7d6..dd08660 100644 --- a/lib/utils/reset/fdt_reset_htif.c +++ b/lib/utils/reset/fdt_reset_htif.c @@ -11,6 +11,12 @@ #include #include +static int htif_reset_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + return htif_system_reset_init(); +} + static const struct fdt_match htif_reset_match[] = { { .compatible = "ucb,htif0" }, { }, @@ -18,6 +24,5 @@ static const struct fdt_match htif_reset_match[] = { struct fdt_reset fdt_reset_htif = { .match_table = htif_reset_match, - .system_reset_check = htif_system_reset_check, - .system_reset = htif_system_reset + .init = htif_reset_init }; diff --git a/lib/utils/reset/fdt_reset_sifive.c b/lib/utils/reset/fdt_reset_sifive.c index 38b520c..928dee9 100644 --- a/lib/utils/reset/fdt_reset_sifive.c +++ b/lib/utils/reset/fdt_reset_sifive.c @@ -33,6 +33,4 @@ static const struct fdt_match sifive_test_reset_match[] = { struct fdt_reset fdt_reset_sifive = { .match_table = sifive_test_reset_match, .init = sifive_test_reset_init, - .system_reset_check = sifive_test_system_reset_check, - .system_reset = sifive_test_system_reset }; diff --git a/lib/utils/reset/fdt_reset_thead.c b/lib/utils/reset/fdt_reset_thead.c index ea81fc9..95f8c36 100644 --- a/lib/utils/reset/fdt_reset_thead.c +++ b/lib/utils/reset/fdt_reset_thead.c @@ -7,8 +7,10 @@ #include #include #include +#include #include #include + #include "fdt_reset_thead.h" struct custom_csr custom_csr[MAX_CUSTOM_CSR]; @@ -37,6 +39,22 @@ static void clone_csrs(int cnt) } } +static int thead_system_reset_check(u32 type, u32 reason) +{ + return 1; +} + +static void thead_system_reset(u32 type, u32 reason) +{ + ebreak(); +} + +static struct sbi_system_reset_device thead_reset = { + .name = "thead_reset", + .system_reset_check = thead_system_reset_check, + .system_reset = thead_system_reset +}; + extern void __thead_pre_start_warm(void); static int thead_reset_init(void *fdt, int nodeoff, const struct fdt_match *match) @@ -106,17 +124,9 @@ static int thead_reset_init(void *fdt, int nodeoff, } } - return 0; -} - -int thead_system_reset_check(u32 type, u32 reason) -{ - return 1; -} + sbi_system_reset_set_device(&thead_reset); -void thead_system_reset(u32 type, u32 reason) -{ - ebreak(); + return 0; } static const struct fdt_match thead_reset_match[] = { @@ -126,7 +136,5 @@ static const struct fdt_match thead_reset_match[] = { struct fdt_reset fdt_reset_thead = { .match_table = thead_reset_match, - .init = thead_reset_init, - .system_reset_check = thead_system_reset_check, - .system_reset = thead_system_reset + .init = thead_reset_init }; diff --git a/lib/utils/sys/htif.c b/lib/utils/sys/htif.c index 2fd38a7..330a9a6 100644 --- a/lib/utils/sys/htif.c +++ b/lib/utils/sys/htif.c @@ -7,6 +7,7 @@ #include #include +#include #include #define HTIF_DATA_BITS 48 @@ -154,15 +155,28 @@ int htif_serial_init(void) return 0; } -int htif_system_reset_check(u32 type, u32 reason) +static int htif_system_reset_check(u32 type, u32 reason) { return 1; } -void htif_system_reset(u32 type, u32 reason) +static void htif_system_reset(u32 type, u32 reason) { while (1) { fromhost = 0; tohost = 1; } } + +static struct sbi_system_reset_device htif_reset = { + .name = "htif", + .system_reset_check = htif_system_reset_check, + .system_reset = htif_system_reset +}; + +int htif_system_reset_init(void) +{ + sbi_system_reset_set_device(&htif_reset); + + return 0; +} diff --git a/lib/utils/sys/sifive_test.c b/lib/utils/sys/sifive_test.c index fdf3169..4533954 100644 --- a/lib/utils/sys/sifive_test.c +++ b/lib/utils/sys/sifive_test.c @@ -9,6 +9,7 @@ #include #include +#include #include #define FINISHER_FAIL 0x3333 @@ -17,7 +18,7 @@ static void *sifive_test_base; -int sifive_test_system_reset_check(u32 type, u32 reason) +static int sifive_test_system_reset_check(u32 type, u32 reason) { switch (type) { case SBI_SRST_RESET_TYPE_SHUTDOWN: @@ -29,7 +30,7 @@ int sifive_test_system_reset_check(u32 type, u32 reason) return 0; } -void sifive_test_system_reset(u32 type, u32 reason) +static void sifive_test_system_reset(u32 type, u32 reason) { /* * Tell the "finisher" that the simulation @@ -49,9 +50,16 @@ void sifive_test_system_reset(u32 type, u32 reason) } } +static struct sbi_system_reset_device sifive_test_reset = { + .name = "sifive_test", + .system_reset_check = sifive_test_system_reset_check, + .system_reset = sifive_test_system_reset +}; + int sifive_test_init(unsigned long base) { sifive_test_base = (void *)base; + sbi_system_reset_set_device(&sifive_test_reset); return 0; } diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index 77a90d6..4af8754 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -20,10 +20,6 @@ struct platform_override { int (*final_init)(bool cold_boot, const struct fdt_match *match); void (*early_exit)(const struct fdt_match *match); void (*final_exit)(const struct fdt_match *match); - int (*system_reset_check)(u32 reset_type, u32 reset_reason, - const struct fdt_match *match); - void (*system_reset)(u32 reset_type, u32 reset_reason, - const struct fdt_match *match); int (*fdt_fixup)(void *fdt, const struct fdt_match *match); }; diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 4ae8b88..da0c1af 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -184,26 +184,6 @@ static u64 generic_tlbr_flush_limit(void) return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; } -static int generic_system_reset_check(u32 reset_type, u32 reset_reason) -{ - if (generic_plat && generic_plat->system_reset_check) - return generic_plat->system_reset_check(reset_type, - reset_reason, - generic_plat_match); - return fdt_system_reset_check(reset_type, reset_reason); -} - -static void generic_system_reset(u32 reset_type, u32 reset_reason) -{ - if (generic_plat && generic_plat->system_reset) { - generic_plat->system_reset(reset_type, reset_reason, - generic_plat_match); - return; - } - - fdt_system_reset(reset_type, reset_reason); -} - const struct sbi_platform_operations platform_ops = { .early_init = generic_early_init, .final_init = generic_final_init, @@ -218,8 +198,6 @@ const struct sbi_platform_operations platform_ops = { .get_tlbr_flush_limit = generic_tlbr_flush_limit, .timer_init = fdt_timer_init, .timer_exit = fdt_timer_exit, - .system_reset_check = generic_system_reset_check, - .system_reset = generic_system_reset, }; struct sbi_platform platform = { diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 4b89939..66a0392 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,36 @@ static u32 k210_get_clk_freq(void) return pll0_freq / div; } +static int k210_system_reset_check(u32 type, u32 reason) +{ + return 1; +} + +static void k210_system_reset(u32 type, u32 reason) +{ + u32 val; + + val = k210_read_sysreg(K210_RESET); + val |= K210_RESET_MASK; + k210_write_sysreg(val, K210_RESET); + + while (1); +} + +static struct sbi_system_reset_device k210_reset = { + .name = "kendryte_k210_reset", + .system_reset_check = k210_system_reset_check, + .system_reset = k210_system_reset +}; + +static int k210_early_init(bool cold_boot) +{ + if (cold_boot) + sbi_system_reset_set_device(&k210_reset); + + return 0; +} + static int k210_final_init(bool cold_boot) { void *fdt; @@ -129,23 +160,9 @@ static int k210_timer_init(bool cold_boot) return clint_warm_timer_init(); } -static int k210_system_reset_check(u32 type, u32 reason) -{ - return 1; -} - -static void k210_system_reset(u32 type, u32 reason) -{ - u32 val; - - val = k210_read_sysreg(K210_RESET); - val |= K210_RESET_MASK; - k210_write_sysreg(val, K210_RESET); - - while (1); -} - const struct sbi_platform_operations platform_ops = { + .early_init = k210_early_init, + .final_init = k210_final_init, .console_init = k210_console_init, @@ -154,9 +171,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_init = k210_ipi_init, - .system_reset_check = k210_system_reset_check, - .system_reset = k210_system_reset, - .timer_init = k210_timer_init, }; diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index ac81d03..5414316 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -104,10 +105,32 @@ static u32 ux600_get_clk_freq(void) return cpu_freq; } +static int ux600_system_reset_check(u32 type, u32 reason) +{ + return 1; +} + +static void ux600_system_reset(u32 type, u32 reason) +{ + /* Reset system using MSFTRST register in Nuclei Timer. */ + writel(UX600_NUCLEI_TIMER_MSFTRST_KEY, (void *)(UX600_NUCLEI_TIMER_ADDR + + UX600_NUCLEI_TIMER_MSFTRST_OFS)); + while(1); +} + +static struct sbi_system_reset_device ux600_reset = { + .name = "nuclei_ux600_reset", + .system_reset_check = ux600_system_reset_check, + .system_reset = ux600_system_reset +}; + static int ux600_early_init(bool cold_boot) { u32 regval; + if (cold_boot) + sbi_system_reset_set_device(&ux600_reset); + /* Measure CPU Frequency using Timer */ ux600_clk_freq = ux600_get_clk_freq(); @@ -186,19 +209,6 @@ static int ux600_timer_init(bool cold_boot) return clint_warm_timer_init(); } -static int ux600_system_reset_check(u32 type, u32 reason) -{ - return 1; -} - -static void ux600_system_reset(u32 type, u32 reason) -{ - /* Reset system using MSFTRST register in Nuclei Timer. */ - writel(UX600_NUCLEI_TIMER_MSFTRST_KEY, (void *)(UX600_NUCLEI_TIMER_ADDR - + UX600_NUCLEI_TIMER_MSFTRST_OFS)); - while(1); -} - const struct sbi_platform_operations platform_ops = { .early_init = ux600_early_init, .final_init = ux600_final_init, @@ -206,8 +216,6 @@ const struct sbi_platform_operations platform_ops = { .irqchip_init = ux600_irqchip_init, .ipi_init = ux600_ipi_init, .timer_init = ux600_timer_init, - .system_reset_check = ux600_system_reset_check, - .system_reset = ux600_system_reset }; const struct sbi_platform platform = { diff --git a/platform/template/platform.c b/platform/template/platform.c index 04334b2..d407fd5 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -115,21 +115,6 @@ static int platform_timer_init(bool cold_boot) return clint_warm_timer_init(); } -/* - * Check reset type and reason supported by the platform. - */ -static int platform_system_reset_check(u32 type, u32 reason) -{ - return 0; -} - -/* - * Reset the platform. - */ -static void platform_system_reset(u32 type, u32 reason) -{ -} - /* * Platform descriptor. */ @@ -139,9 +124,7 @@ const struct sbi_platform_operations platform_ops = { .console_init = platform_console_init, .irqchip_init = platform_irqchip_init, .ipi_init = platform_ipi_init, - .timer_init = platform_timer_init, - .system_reset_check = platform_system_reset_check, - .system_reset = platform_system_reset + .timer_init = platform_timer_init }; const struct sbi_platform platform = { .opensbi_version = OPENSBI_VERSION, diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c index 352edb6..8f8069c 100644 --- a/platform/thead/c910/platform.c +++ b/platform/thead/c910/platform.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,22 @@ static struct clint_data clint = { .has_64bit_mmio = FALSE, }; +static int c910_system_reset_check(u32 type, u32 reason) +{ + return 1; +} + +static void c910_system_reset(u32 type, u32 reason) +{ + asm volatile ("ebreak"); +} + +static struct sbi_system_reset_device c910_reset = { + .name = "thead_c910_reset", + .system_reset_check = c910_system_reset_check, + .system_reset = c910_system_reset +}; + static int c910_early_init(bool cold_boot) { if (cold_boot) { @@ -45,6 +62,8 @@ static int c910_early_init(bool cold_boot) c910_regs.plic_base_addr = csr_read(CSR_PLIC_BASE); c910_regs.clint_base_addr = c910_regs.plic_base_addr + C910_PLIC_CLINT_OFFSET; + + sbi_system_reset_set_device(&c910_reset); } else { /* Store to other core */ csr_write(CSR_PMPADDR0, c910_regs.pmpaddr0); @@ -108,16 +127,6 @@ static int c910_timer_init(bool cold_boot) return clint_warm_timer_init(); } -static int c910_system_reset_check(u32 type, u32 reason) -{ - return 1; -} - -static void c910_system_reset(u32 type, u32 reason) -{ - asm volatile ("ebreak"); -} - int c910_hart_start(u32 hartid, ulong saddr) { csr_write(CSR_MRVBR, saddr); @@ -136,9 +145,6 @@ const struct sbi_platform_operations platform_ops = { .timer_init = c910_timer_init, - .system_reset_check = c910_system_reset_check, - .system_reset = c910_system_reset, - .hart_start = c910_hart_start, }; From patchwork Thu Apr 22 11:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=mM6IKxr4; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=BG0JXN0j; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=mw4zwAXZ; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=xxIDWuhO; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw3S5dpHz9sWD for ; Thu, 22 Apr 2021 21:21:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=cOgBqTW63c4lAbc5c91J74KsppAXJK142DkT5FdCFkw=; b=mM6IKxr4JptC5nZV87CSne+Xp aHuwLJ+/oEmy4XuY6/l0CNpSeypmUalfHrLqL0FcEg0AOfo2GOXERvzKjNqqIySLNKjXgPZdaZ1LP YcJV2jTkFrT8IIPT3VSGrzHqvCMDNu9FbB67OSXYtb9Ala7OqbY6QFUjLtxgVWnKX1p3oILtwxlNk t0xEIKhDx3Y2oPKw1UJwaZs1+G3Ew+kgn6sjskpywq/yYUbaPXgkw5yI93E57VuwB3u6jB3E650pv GhK6BdLkqFhF9mB71zd9dllENtVe8eym2Kg2FtHdDU+fyvvwBg1KFxjY2aqaBeH5OtZX2SImMeN92 U2VQpZaPg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOa-00GZqh-5b; Thu, 22 Apr 2021 11:21:20 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOV-00GZpa-EZ for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=5GNRN69NdXf1/A2HhQF4tz4TV8wByJF5kZpk+/FugMg=; b=BG0JXN0jwjtGut+/hDwgGCCZ3s CxxRXkd4+m0s35H5guLBpV3LECOf7hMr6K8t6ETTP7F/UCH7RhCrvL/JQ4bWQTTtRBn0/JFcjFQwk f/xvwzqiX3nsCuJxcJeIWtVmMI8Dd+JRKQzJvfM907nn607iUon1YfHQ+OYxvSP1JMQupDLxRmsEW N3Vq6/dmrqzMmqISEfXppQS/V2KbLhu/x9+/OYIuxlvlMvH+7iN909jwHm8R0okSfLe5I0nFLGUqO Mpu8rdBxUg/PEppXzoS4tPgvDU2CiNUgi8mn5EspYb4IrH4BDqef/wjp6AkXuPbY+xGstyHMMzHOM PZxlxJ2w==; Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOQ-00Dbyb-GA for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090470; x=1650626470; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3R7gteFlKVaizOBPLhQmvKSOVTLoCFO6sHqAuIXxbSw=; b=mw4zwAXZWN7ejESU8900BA17S17eqIZx1SKZUgmtplcDiZvJ2YHNUBnD gVJGRz1D5FZeTz2Q6T51OzpWPWdrYd0hkLgLN/EmDRpYyzgGubd/PT3Jp CjMDXiZQ2YDSx4IXqR3vaT7qti7Ap8h0MrON8SBQKNFdOdgwKGy0qJ3kG vZDn0t45QX90GBVkBInn0mlMKTfVRMz77yWP5RGsU+Klo6yybEksvrk3s o63ip3DXQShaOHwETy5dsxLtDCGdZqna51sppGOAikUaYWvyqFTR6m8E1 OLbXP1d1z4qv6gGbLC9me+oLAdxkBwGttDycz2Sa27d3Y4qzmTyfz3ySz A==; IronPort-SDR: oIQRqhRNRF10qfS9urYXhf7jTlVopEBArrFNO/MC9TVZj5W2KUUIG3vuflHKz9XOJQdYAAuPac xffpOsDpqdtozyOoQ99HH4UCuyje48m+IZo9CoxNEllSNka3sasi2bB4x72mxYuMa+NO0IVvob ulhd64j3Acd2o+RSTmqgnnn8FVVX6vBZnRGuuTmil0gzMzsGoT4dogsz0Vj5oedBCdRNF7lYjw 6TzIl0g0J2vDSPu25/mzcD9VRpAH6T/L1p1yjAYK5bKGd9wp6TKT+uHJHI6/96xN7+S8AhvFDi ffY= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="166389012" Received: from mail-dm6nam11lp2177.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.177]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:21:10 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaZ2sIvI5biYesY8uNpXiXoZzYJCy+/f0HiZzQyiYrmsIOngXYDD6pOYlBHxDgE3AJVCyuVvWLt2LL7F/Sq3iMIJMIL+reo+/o7uk8L4CLDrFqv7DlvEpNrrPvcjz7M/l4xLvZP4T42lR3+C9SGrvExp0lnqN1MuUyWTZvNZTHT2+6JfIyTZ+r7P+eheaU92zt3gpD0QXsRtDwZ67sNppERpC7/IPvwEk6K8Hcfd61LbyxKlGh8TbghaeBJ/g9k/ldTtye7vxuE6T+Zn+vTjkm6Q+VZ/GbX/K4bhrlN2junNmdjRmot46PjGhtVyEsJK+5xQpnQLUiTdtPmkHD6EHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5GNRN69NdXf1/A2HhQF4tz4TV8wByJF5kZpk+/FugMg=; b=QwFdJhP0BguK+Y+04O333HXOjbIm+v8oZ2kEtDc6sj0PW2RwE9k4YahRlQx6OwZxyNE+XgCBuqsRF/IEdwwlVqwMCmiKyHTywpSHGaDRklKSxT4YFLpiMDuINmFT5u+rBpRKFqhy368AiFoNLUgOaqsfJSTkUT0f01uAiJHGWNpsMjmg41mdCX84QQsQNUXhjB3Skx1RJLKVe/lWsxMJuzLdbTIfcxlTbMh+cK6Y8OPwhIBTn6CyUKc05coAMjkQPSJlhKUCuf5GAxB9aWHKFdhhWpqIU4/11D2nglOedA7cM5VY2lZ+hbQl/H5Oc1YG/ZOLKly5CabsxMW/L35T3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5GNRN69NdXf1/A2HhQF4tz4TV8wByJF5kZpk+/FugMg=; b=xxIDWuhOzWR6vF5G1KM6RzF1kAQNhepLDCh9Yqgd9ZaRFgjkIt/a/W7Opr01VZyRqgemfs6Mu0CjBATms8PP0KckJzj0ueUsJPu/RjfBNyKV5VWOH1QZVrZ+lXHrZ3WBBUeXYpGrFB2+99/iG38tQ+m7d8Wn/f+H5f/pNyMJIO0= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:21:08 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:21:08 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 6/7] lib: sbi: Simplify HSM platform operations Date: Thu, 22 Apr 2021 16:50:22 +0530 Message-Id: <20210422112023.670521-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:21:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90c454f2-82c4-4a6e-968f-08d90580b9fb X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l0ldh20kJGeOVTXw6WMJOr9q4hXI3+xq+w5i595MVBBu5wPG7QvD3OFZVLesBU5v2+CIexk9EdXP6/7A1fZtsbO3NDYZqEIACfNKMN8jpZhK00zJigXwaC0/EhVpyFkMGqaj6Rq25S9MpeB39xW/ejJtVaJScPgEkFIx7L4GmChS2Ur7R0A19SLbo41WQPdYBwu2mYNmMgSh5jkP2WaqRrxlEE1owPs2sgnF7H2q8ZvomY+omPA5ft3XHTX6ebKyKfqM5VWUl6mvxO5Qypj6yrwM2kLzjoU7ZXQprP3SVhB3TJKnxkswnssJjgoo5HLvClEEvygqdo2yRBwocMYlLJffAdn4uYAOAnzOfUuwpVNLqRfxa1FukgZqw4Y9h0lDTOskNzLgdI9JKHkWMo9IVXKeNO03MzTMSyphmqz0dB1YhwzlSgSNIVLDCcnIyNneqKnb7klm8iwghJP9aHgWmQJDNaF8ZhiaLaBt+Fv76UOc7idziH6oJ+bpf6KSRyt7ro/u6GM9eMsUSVypXPWot+xlTu+XPOdzMKEgmQay6kbp1igt/zNc/m7j3LBWft2IPXqMWaOa5hnoZn9TID+6i8m+pd92jpL40sv07McLDDNm3y3jx6/WXzsxQmC9BnaN+jBRQhWKolrbBkrTRSNJFIyiLL4D8Zs1OZEZ1DfL7iU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(30864003)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: p7VXuDlqVNh8Sd/XU5d9wNMStrLyDMWAlm0P7IaT5bQz9NoLra/BVoESNd5qHbyKDpfxkJ1HD4VfRpHyg1MzBtsuB0AijR4R7X3SEGO/ABaoZqBuzzVAqAoczvmRqyeDXywYm0Al2fc5VvXGw2WbaOQVn9I0dNkDoFx5R1JeP+JrkqmRhw4Yg1jt1ntRX1VA416bM3J7yFgVu8pZJQt/sOTk0G6wn6z3JFjSG7AOoAQiwvakenrMEPvLSu/bO8Wqb23pqZvrUdF2lky3YBaWHQF+uRAhaDac4hZ4luHvGoZiGk4j/s0VMVkxIorMPto3IFNlzF2Rr+XLqKLssLCZjkl0hbOhSV0wzgFicwTTdDULqM7CbgZlLS4D0IDqoBBN0oC0TINXzexUfoA8+aHC8c3fH26ES4sdY9046VgPlesormQoY5Ae3XppVWhnu9z5A7SqTXHytJvhBiwGkTzCDmoJjrre9elkKPlZjnKJexWw9ZDeWt8xwiiudmncnLA32j83ZQAg1cg0LTCRMXRl7Ipwg4vwVWYa04t1o1yM3bQs8ZpdIOo2TksYUop7ALiRcnpIzCinnTAy4/e+BwyOUnfXND8X1JHJ7milxRPuLX+RpTU1ckMSATedYiVNkKpk9jRElTIJLROy1jEn4f/iZBp4K89dnacCYBOqHJww5Exdwk4ju4RbnHW02hRVEzvYU4IQJLiA4aYsAi/Pk2ReT3UhtrRtY642KCyg0FVR+GWHebGXaayYhffKCnEZU2galAKSSdCF1yCUgX5noCu4KvskJgHpq35RrXqGPiavaZUHBU5DAGdxifrFjDwaCS/z1HNTU+SkXLxFWwEN68DsSRASO+RheXMCqQaNCZjb9lL97zedo54zbHPYTYf7vnWyrMX5bJK97zhAqDW+78NnGADMU6xzOTj3VflPEHhzqKKlGLCC5UI2wfJIvcpF71sHCSsZsOMGRNjLlcSBgDglTkbUVQp/bOKVFeSuof0iV/MM8fvBmwSAKX4DE0S3u2Go/mTAJPKlw32Fbm+coTiYJ/njFmJ74/uI/Nzvy+k4EPHiApGwfbQbUd4Li4FBZcUc/b1Ep9WmH8GhUua4ZtAqF2yWpybtReYeScLddfMDsOZE7K5ZK492GJqL5usVGOyBEfgAst+4BR/nCDb28ZJjGNAWsv4r8BLfoZHHUzm0CIyx5JmKiWMfzN5CQK6AWu2A574xqfw1bKENMjTV7/Lcbyvp1xYElMSfxiVNmVoo8nx2kuRlJEM9KPq4GyZwn2Xaf+eIVh+iGmaPr2nANYlPCU2FHRyp7JkUoNKuLHJXibhku6Z6IZCroV5RHyPXz0BD X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90c454f2-82c4-4a6e-968f-08d90580b9fb X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:21:08.5970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1lusmkSBoBKzad5CMvwsWpmjoSRsJUC3/8vc7HgR/IbXbX0Ps1IP+gqYuY0uW370liZvxXW+P21y8gQYMvT0Aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042110_669927_34C9514C X-CRM114-Status: GOOD ( 24.03 ) X-Spam-Score: -0.9 (/) 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: Instead of having hsm_start(), hsm_stop() and hsm_suspend() callbacks in platform operations, it will be much simpler for HSM driver to directly register these operations as a device to the sbi_hsm im [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [216.71.154.45 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 Instead of having hsm_start(), hsm_stop() and hsm_suspend() callbacks in platform operations, it will be much simpler for HSM driver to directly register these operations as a device to the sbi_hsm implementation. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis --- include/sbi/sbi_hsm.h | 31 +++++++++++++ include/sbi/sbi_platform.h | 83 +--------------------------------- lib/sbi/sbi_hsm.c | 68 +++++++++++++++++++++++----- lib/sbi/sbi_platform.c | 6 --- platform/thead/c910/platform.c | 27 ++++++----- platform/thead/c910/platform.h | 3 +- 6 files changed, 105 insertions(+), 113 deletions(-) diff --git a/include/sbi/sbi_hsm.h b/include/sbi/sbi_hsm.h index bf0c1a5..c16e871 100644 --- a/include/sbi/sbi_hsm.h +++ b/include/sbi/sbi_hsm.h @@ -12,9 +12,40 @@ #include +/** Hart state managment device */ +struct sbi_hsm_device { + /** Name of the hart state managment device */ + char name[32]; + + /** Start (or power-up) the given hart */ + int (*hart_start)(u32 hartid, ulong saddr); + + /** + * Stop (or power-down) the current hart from running. This call + * doesn't expect to return if success. + */ + int (*hart_stop)(void); + + /** + * Put the current hart in platform specific suspend (or low-power) + * state. + * + * For successful retentive suspend, the call will return 0 when + * the hart resumes normal execution. + * + * For successful non-retentive suspend, the hart will resume from + * specified resume address + */ + int (*hart_suspend)(u32 suspend_type, ulong raddr); +}; + struct sbi_domain; struct sbi_scratch; +const struct sbi_hsm_device *sbi_hsm_get_device(void); + +void sbi_hsm_set_device(const struct sbi_hsm_device *dev); + int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot); void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch); diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 921d39c..f8074d2 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -51,15 +51,11 @@ struct sbi_trap_regs; /** Possible feature flags of a platform */ enum sbi_platform_features { - /** Platform has HART hotplug support */ - SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 0), /** Platform has fault delegation support */ SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1), - /** Platform has custom secondary hart booting support */ - SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 2), /** Last index of Platform features*/ - SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_HART_SECONDARY_BOOT, + SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_MFAULTS_DELEGATION, }; /** Default feature set for a platform */ @@ -114,19 +110,6 @@ struct sbi_platform_operations { /** Exit platform timer for current HART */ void (*timer_exit)(void); - /** Bringup the given hart */ - int (*hart_start)(u32 hartid, ulong saddr); - /** - * Stop the current hart from running. This call doesn't expect to - * return if success. - */ - int (*hart_stop)(void); - /** - * Put the current hart in platform specific suspend (or low-power) - * state. - */ - int (*hart_suspend)(u32 suspend_type, ulong raddr); - /** platform specific SBI extension implementation probe function */ int (*vendor_ext_check)(long extid); /** platform specific SBI extension implementation provider */ @@ -193,15 +176,9 @@ struct sbi_platform { #define sbi_platform_ops(__p) \ ((const struct sbi_platform_operations *)(__p)->platform_ops_addr) -/** Check whether the platform supports HART hotplug */ -#define sbi_platform_has_hart_hotplug(__p) \ - ((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG) /** Check whether the platform supports fault delegation */ #define sbi_platform_has_mfaults_delegation(__p) \ ((__p)->features & SBI_PLATFORM_HAS_MFAULTS_DELEGATION) -/** Check whether the platform supports custom secondary hart booting support */ -#define sbi_platform_has_hart_secondary_boot(__p) \ - ((__p)->features & SBI_PLATFORM_HAS_HART_SECONDARY_BOOT) /** * Get HART index for the given HART @@ -316,64 +293,6 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat, return FALSE; } -/** - * Bringup a given hart from previous stage. Platform should implement this - * operation if they support a custom mechanism to start a hart. Otherwise, - * a generic WFI based approach will be used to start/stop a hart in OpenSBI. - * - * @param plat pointer to struct sbi_platform - * @param hartid HART id - * @param saddr M-mode start physical address for the HART - * - * @return 0 if sucessful and negative error code on failure - */ -static inline int sbi_platform_hart_start(const struct sbi_platform *plat, - u32 hartid, ulong saddr) -{ - if (plat && sbi_platform_ops(plat)->hart_start) - return sbi_platform_ops(plat)->hart_start(hartid, saddr); - return SBI_ENOTSUPP; -} - -/** - * Stop the current hart in OpenSBI. - * - * @param plat pointer to struct sbi_platform - * - * @return Negative error code on failure. It doesn't return on success. - */ -static inline int sbi_platform_hart_stop(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->hart_stop) - return sbi_platform_ops(plat)->hart_stop(); - return SBI_ENOTSUPP; -} - -/** - * Put the current hart in platform specific suspend (or low-power) state. - * - * For successful retentive suspend, the call will return 0 when the hart - * resumes normal execution. - * - * For successful non-retentive suspend, the hart will resume from specified - * resume address - * - * @param plat pointer to struct sbi_platform - * @param suspend_type the type of suspend - * @param raddr physical address where the hart can resume in M-mode after - * non-retantive suspend - * - * @return 0 if successful and negative error code on failure - */ -static inline int sbi_platform_hart_suspend(const struct sbi_platform *plat, - u32 suspend_type, ulong raddr) -{ - if (plat && sbi_platform_ops(plat)->hart_suspend) - return sbi_platform_ops(plat)->hart_suspend(suspend_type, - raddr); - return SBI_ENOTSUPP; -} - /** * Early initialization for current HART * diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 64d299b..4662150 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -21,11 +21,12 @@ #include #include #include -#include +#include #include #include #include +static const struct sbi_hsm_device *hsm_dev = NULL; static unsigned long hart_data_offset; /** Per hart specific data to manage state transition **/ @@ -129,6 +130,54 @@ static void sbi_hsm_hart_wait(struct sbi_scratch *scratch, u32 hartid) */ } +const struct sbi_hsm_device *sbi_hsm_get_device(void) +{ + return hsm_dev; +} + +void sbi_hsm_set_device(const struct sbi_hsm_device *dev) +{ + if (!dev || hsm_dev) + return; + + hsm_dev = dev; +} + +static bool hsm_device_has_hart_hotplug(void) +{ + if (hsm_dev && hsm_dev->hart_start && hsm_dev->hart_stop) + return true; + return false; +} + +static bool hsm_device_has_hart_secondary_boot(void) +{ + if (hsm_dev && hsm_dev->hart_start && !hsm_dev->hart_stop) + return true; + return false; +} + +static int hsm_device_hart_start(u32 hartid, ulong saddr) +{ + if (hsm_dev && hsm_dev->hart_start) + return hsm_dev->hart_start(hartid, saddr); + return SBI_ENOTSUPP; +} + +static int hsm_device_hart_stop(void) +{ + if (hsm_dev && hsm_dev->hart_stop) + return hsm_dev->hart_stop(); + return SBI_ENOTSUPP; +} + +static int hsm_device_hart_suspend(u32 suspend_type, ulong raddr) +{ + if (hsm_dev && hsm_dev->hart_suspend) + return hsm_dev->hart_suspend(suspend_type, raddr); + return SBI_ENOTSUPP; +} + int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) { u32 i; @@ -164,7 +213,6 @@ int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch) { u32 hstate; - const struct sbi_platform *plat = sbi_platform_ptr(scratch); struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset); void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr; @@ -174,8 +222,8 @@ void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch) if (hstate != SBI_HSM_STATE_STOP_PENDING) goto fail_exit; - if (sbi_platform_has_hart_hotplug(plat)) { - sbi_platform_hart_stop(plat); + if (hsm_device_has_hart_hotplug()) { + hsm_device_hart_stop(); /* It should never reach here */ goto fail_exit; } @@ -201,7 +249,6 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, unsigned int hstate; struct sbi_scratch *rscratch; struct sbi_hsm_data *hdata; - const struct sbi_platform *plat = sbi_platform_ptr(scratch); /* For now, we only allow start mode to be S-mode or U-mode. */ if (smode != PRV_S && smode != PRV_U) @@ -233,10 +280,9 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, rscratch->next_addr = saddr; rscratch->next_mode = smode; - if (sbi_platform_has_hart_hotplug(plat) || - (sbi_platform_has_hart_secondary_boot(plat) && !init_count)) { - return sbi_platform_hart_start(plat, hartid, - scratch->warmboot_addr); + if (hsm_device_has_hart_hotplug() || + (hsm_device_has_hart_secondary_boot() && !init_count)) { + return hsm_device_hart_start(hartid, scratch->warmboot_addr); } else { sbi_ipi_raw_send(hartid); } @@ -374,7 +420,6 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, { int oldstate, ret; const struct sbi_domain *dom = sbi_domain_thishart_ptr(); - const struct sbi_platform *plat = sbi_platform_ptr(scratch); struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset); @@ -420,8 +465,7 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, hdata->suspend_type = suspend_type; /* Try platform specific suspend */ - ret = sbi_platform_hart_suspend(plat, suspend_type, - scratch->warmboot_addr); + ret = hsm_device_hart_suspend(suspend_type, scratch->warmboot_addr); if (ret == SBI_ENOTSUPP) { /* Try generic implementation of default suspend types */ if (suspend_type == SBI_HSM_SUSPEND_RET_DEFAULT) { diff --git a/lib/sbi/sbi_platform.c b/lib/sbi/sbi_platform.c index e78119a..e8b94a3 100644 --- a/lib/sbi/sbi_platform.c +++ b/lib/sbi/sbi_platform.c @@ -19,15 +19,9 @@ static inline char *sbi_platform_feature_id2string(unsigned long feature) return NULL; switch (feature) { - case SBI_PLATFORM_HAS_HART_HOTPLUG: - fstr = "hotplug"; - break; case SBI_PLATFORM_HAS_MFAULTS_DELEGATION: fstr = "mfdeleg"; break; - case SBI_PLATFORM_HAS_HART_SECONDARY_BOOT: - fstr = "sec_boot"; - break; default: break; } diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c index 8f8069c..8a9318c 100644 --- a/platform/thead/c910/platform.c +++ b/platform/thead/c910/platform.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,19 @@ static struct sbi_system_reset_device c910_reset = { .system_reset = c910_system_reset }; +static int c910_hart_start(u32 hartid, ulong saddr) +{ + csr_write(CSR_MRVBR, saddr); + csr_write(CSR_MRMR, csr_read(CSR_MRMR) | (1 << hartid)); + + return 0; +} + +static struct sbi_hsm_device c910_hsm = { + .name = "thead_c910_hsm", + .hart_start = c910_hart_start +}; + static int c910_early_init(bool cold_boot) { if (cold_boot) { @@ -63,6 +77,7 @@ static int c910_early_init(bool cold_boot) c910_regs.clint_base_addr = c910_regs.plic_base_addr + C910_PLIC_CLINT_OFFSET; + sbi_hsm_set_device(&c910_hsm); sbi_system_reset_set_device(&c910_reset); } else { /* Store to other core */ @@ -127,14 +142,6 @@ static int c910_timer_init(bool cold_boot) return clint_warm_timer_init(); } -int c910_hart_start(u32 hartid, ulong saddr) -{ - csr_write(CSR_MRVBR, saddr); - csr_write(CSR_MRMR, csr_read(CSR_MRMR) | (1 << hartid)); - - return 0; -} - const struct sbi_platform_operations platform_ops = { .early_init = c910_early_init, .final_init = c910_final_init, @@ -143,9 +150,7 @@ const struct sbi_platform_operations platform_ops = { .ipi_init = c910_ipi_init, - .timer_init = c910_timer_init, - - .hart_start = c910_hart_start, + .timer_init = c910_timer_init }; const struct sbi_platform platform = { diff --git a/platform/thead/c910/platform.h b/platform/thead/c910/platform.h index 354404e..880cb6b 100644 --- a/platform/thead/c910/platform.h +++ b/platform/thead/c910/platform.h @@ -8,8 +8,7 @@ #define C910_HART_COUNT 16 #define SBI_THEAD_FEATURES \ - (SBI_PLATFORM_HAS_MFAULTS_DELEGATION | \ - SBI_PLATFORM_HAS_HART_SECONDARY_BOOT) + (SBI_PLATFORM_HAS_MFAULTS_DELEGATION) #define CSR_MCOR 0x7c2 #define CSR_MHCR 0x7c1 From patchwork Thu Apr 22 11:20:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1469170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=MxbPOil1; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Nes5QVMt; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=rSV4h0qt; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=TGDoTah8; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQw3W2rZjz9sTD for ; Thu, 22 Apr 2021 21:21:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=sYNX3Da7qKTDxRcVzgsHDGU21KrjBvddgc9Omc86drs=; b=MxbPOil1vQmeYWOxc8Kym7rsN 0KhxdTYNh6NefFTAaNFdSoVXcpBQqFqBygPw8fakyMWr5LXjrcfZSPY6NhAwNpjqSLcXcHSpTkm34 NmxwJFwHpGURj5gz8+xRUXLyrj+Pd4ASaz+M6jWuh0wlDLvJwBrcF6RAhfiGmd+n6f00XG/3sHdDf 9KMI4ctbg2lwj7VuKgz9npOIAGnQLQ+EWAlyQ1mGiSs7qZUFgLUlmNP3yGI6Qrew450uhF09fHQN+ KqNQm6GJ9tbvGs//Us7YeIWg0Zt75tKtM42+P/iuJTLfJhkm0cReCJC433Un3ffVJNYhLwYWLXh62 1iL5Q7rCA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOc-00GZrV-78; Thu, 22 Apr 2021 11:21:22 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOV-00GZpU-53 for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=S0k8EamBEZLG7vkM6QFJuQrPPGDDCgrx4DMiXpFZ6HU=; b=Nes5QVMtNpBfZEj8ogQdE1KKam CFUjl5WpKo4QPF7yXukPN1rbYFoDl5gnkA3Syr5SJLaY4d7u3q+NEWb8GkLbf+xUeMgMnJnrySSha qf1qwGhs3qE4E/o+so7lbzd9GG3YeRAGajm5zE8ut3cYDmwMrrRpTc33SH1HD52izBlZnSU9UnBEl H1XeuXZHmnLsqSdHDF9cSBBZrlAQgZAQhUQVoqagrROhmkIpqHLKj//vZQniOeKywt0GnDUl0uWoC Kk9CujZfRIak11fTLejbJ0UGE/61+xnjXlER+MsXpcZElQ073PbGNX5RwaLb2h5RacqfANQm+Q1Nq k+CnUBCw==; Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOS-00Dbz5-Ee for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1619090472; x=1650626472; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jC382GsJIgk0nZ4A00OATGBpROYAP/RJT+MuKBqUsvU=; b=rSV4h0qtMsUFTQN5gDvAaugoML26bGLlRhSwm168C6JwWliW/0WaxGSx oZczZTeD6CCZYauDghaBix3uLy6+cAxjd7D0MU3BQnXr0X/avGFTh8vhS Cz+GSqu2uVICxJrnS2qAnHGFjX/UvkDs3TSIfG17WpNQx0jayUcmgP5XE 3h/R/lrdHlQEeZhaiXFYL5pVsBr/RTzDKVoMgegupLs4CeQY2HVEOZ+u8 DtdyrLYr6Wqn5YeefwB6JBGTVD81rUWvhbnCmQs5uIBv6TEV09k3y+ANn 29+W3oZ6sHWdHKmR3WMdTdqwFDh/7K7RfHQI52HwwitGLd3BdTAUXtQbG g==; IronPort-SDR: ulB2sBPY90M27wxKJIh1ngKIFNoUppcLFjHOjY1MkrkN0dbo6kxtfpGNwOMcqh4idBVgnePItl LkcZuV2yYktQDWZ3B9Qu0/SOzJkHHonyckUZ50taOvEwdSQs0aGxTq38Wrfy/R1ae5jiNPCZc4 Xc7zVVr5xf+xCbuWR4BnOoblsnd8Bu/Cy+gTiLC5M9FLYaDhy/MxRExU2FZOyV9tiaoTfIFYbV wrTmcNDANXF/zRBlTKJYoifOUajDwURzEwP/MGNjIm+mUWiNumquTQqQiWR6h/H6cEolfPlvwJ 1vI= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="166389019" Received: from mail-dm6nam11lp2169.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.169]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:21:12 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cTRbcA1fIGCmTwK0e3+lEzRs02tfJJuX+Ntrw7cEzj4fIETAiMM6dLZ83S0i0/+CGvsdjQ953dgiiiqy63qHMqp/jbPQKxjUOkAa4+X3fBMldJCNx9AQ0+K6NjL96PcGM9w6aGrvJSDj2thsPBrrbQyadsLUNRqErIQAQ1P0WALZgTxzudXijyyfZ1ZbLcsAxOUdU73fLwE5jaaq9v7VDtUQva1RqEXPjbQ2S6iNBS7CLq4T/Nui32e3OfXSnAYc8CAdO5zMfwW/UtYCSH7qEC/n9TxzhBgCL8nhV9P3TI3lmPhqZMUqpsGgeMTtWQORK3uBEOxroKlglTwpZhTvNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S0k8EamBEZLG7vkM6QFJuQrPPGDDCgrx4DMiXpFZ6HU=; b=OheuRCOLPMdwOwPzkt9rdKsaM6sI5IJuhspx3B4f8hFe44B5F028+Vi11j28e6eTvAbFiitnlCImPx0nZJ7kE/RTV8BaB4wN73BeMUGNK9T3cN6/u/GQ6GjfMHE/2HDRlY5EA09/XQOx6H98RF72Lci4D+Xc6ixoE61Pf47Np1v/BA08793G/dsqcqj9ic1RVpD6SdF6sFMlNgkAe11zdtzTxbsXyiqbgLmTrz8F6mNW1fBsFTHZhAvA4pGidH0HpY8knO18nlWzL1IvdSnH+jDrOGqsTsaSf+HbH8kEv7tGqyh+O81YBLOg8rLsl4Dk02n2yv2eq10fCUI7fnNz+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S0k8EamBEZLG7vkM6QFJuQrPPGDDCgrx4DMiXpFZ6HU=; b=TGDoTah8KWQa/c9AAIG/tDueR/pqbpKfYNckCxpFLBn2um3CIDD6NIGgW1pP4YyDwNWhceCkHqMNIhcm2ilE2P7H9zdhUGyV66jQbuVK8D4pGsvoh7qkWzjLpYRdh8QPqZuxEUTrcydRY7T2JSmBcHmoPr15AAQ6ho4oMh0eXpg= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:21:11 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:21:11 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 7/7] lib: sbi: Show devices provided by platform in boot prints Date: Thu, 22 Apr 2021 16:50:23 +0530 Message-Id: <20210422112023.670521-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:21:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee76beb7-7f48-4faa-725c-08d90580bb65 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:254; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rOBCASoCMLyV0xO/Pv4FRL6iYgfTi5q38SczxnH3y2Oxe/VHBdmztqMPyXjfxD+Do6p+HrmQg0/jM4TftskX4Shruj+oMBkQWGyvpJZ7kZNpQ7apcvqCzCo/Ioil1VC89I0xrdSov0vXD5FMueH5VVHuP0ZgomJfcAIWMPlxIi/ZgrzSlUgOq+XBENbfC1J3yHiBVd2YZEEdWkVcpKWVcJQWO4ioYlPhazy8UYAtyj9AjCj+/RSjahZWXhXbSP9WoWOjo0ZE+BhCLzqHTmWUoWpCFbyJXS/1VqPl3a7L9uVEcfYHoGQ9XKgGrdiPM9V5AQoPzNw9vuRK6FMMhrlo34+lohlAtmdasgbJ2S5jdJzZpvAANvlPxj6mFXEN/cZjnuQhnlTT6tSf1vW+W3k/GyW3mPks4eLHzSuucAM6VCoYJQYlkuI4k4nR7v4YCG0DDGjiYiFPN3gi5mw+4QPHj11G2NgJcpQAhkGnsaOoL3MivCqdO4841bteA2/EV8qSbzb5k2uPE7nUFqZhllBe8iJEzFTHyiDUcteVAA8TLfM0JqvDGUYlVdO7/2rv7vs5a0mWvpTgCtE1rA7Z8dsTmMMHJ8g7+60Q0qJOHYMkheq3URBW2anEO69D0xm+q7ymNccrANOVBroPoTOvaChWrfPNLeCKpU5vkUtaRW1bR7g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: suuLGFuDobO8DWmw1UQnbU5tCqCg+/8wbWwKVH/E7q6+t05nRq3KVQMasTyNLHbgf44HRNIQjFkm4E08UKN7ROdKb8mzC1RJJ6dDkDS29nIIU4+JR34oDGuiZ3W36fw5y+uSRqiMmjefinNujtU+QHMjfNVuzSUtwD8BNeI99UF1jawxRUenJfoCcipKcNsh8k5rnKj3jd+Re3vFpZj98/2fnIJ96RQrYRhel6yA5LDhsf8uQdFLeZn3aFitcu/rzMMXRHdDzKS2jLZi6e7DxCTddH0hEtjK894ctQGDrtpDMgM/1pROs79UoYUnluktjWMHazjgWYTlNFfm5443uHl9ugJwqSUhPWAISER0SHmvTBWjG5GEWszvhnFVWDXsCefmcBESrnGK7l6QmtVcqnmhIaExqXM5YBIXZlTogIigdOfdQbgXkW2mp5dmGtLkhqmO9GRuyNVwVPqYDG6LWi3LzGZFbIEyaN8fd9n9A3YlprVarcXVL7TqaNasBPc19OCoTBQbCnNclyaPb3xqJ2LOK/SA+NkyEWkB7TAcsSMmAd28mfZTrrZyU3Ln8QZ59CNWYYDXJ4kWt2czQAxqsH3NiAyiRB9SCz5sYz9OYCs43CEpItjwuW/NtV3hOh8OXijIJdJKjBvhaURVAZ4dlidRMaSiW4c5HOT1JG8angzuFtdgBeaq6v9K5FLU7Z3O8oZvYLHnF7EfPx4jI+DFpkxkm9HeWop/BocJxVrvutzL9u6A4r48fP1MKE7ADJnGLumyAHJ36mLp9E0r4R73785g+AY4+53EB+uCelwgP5QNqqoqFig2gdXOVfFlLTORLnVPQtvpnFDaRtoV6rX4CzWAPWROzFyy1oaBxBOkqkTb3Ip6xB0GBcSdULzY99lKSZhN0IVpaXIUJbOWT+2PwJB3aZ1QnRYpW5zuhNpbkVTRC1qC1psFJ6tMuWkywQTUTEvWCgPd+K9LUVcf8QsQEoqhjgOVahNqDELP1Z1EBHCuBBlaPqnRnpk76IZgLDt3KCku9AqO/TabOrB0wt8Ma3oeKO8C5qdj43VOGePt3HDAUont2ITxnoxYISfYM1XIOEW0v3ohLC8A+6breHIeJs3X3LQYquCqwEktP1yV3ZKPuAHc93lK6k8uSQspg/ZmM7TYgo68Ng+d4GdQee/Q0+tVz5/JvpfHhI3ZlnhfoHJLeQrKMUe+osb3MXAYrBFPGZhhv3wQesmDFbu1auI111nc8+WAyxMsMu2midu6OXVcf9AcHWH+4V5snt5yfEvJ7SaI+ER47R1+dELlUY4SoBH83XK/xwpYOA64w4SFuxvnY/7PQQ8gOCbh40l9BmmL X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee76beb7-7f48-4faa-725c-08d90580bb65 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:21:10.9125 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rUesXMiYZkanPEcs87KbSaOx69zel+3H/alrYa5XaLDl6CYiee0dUgpNbHiDzDxaqj18WpngHFPog3ah937uFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042112_576545_AED11FC9 X-CRM114-Status: GOOD ( 11.92 ) X-Spam-Score: -0.9 (/) 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 extend the boot-time prints to show various devices provided (or registered) by the platform support. This will help users verify hardware devices available for OpenSBI firmwares. Signed-off-by: Anup Patel --- lib/sbi/sbi_init.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [216.71.154.45 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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 extend the boot-time prints to show various devices provided (or registered) by the platform support. This will help users verify hardware devices available for OpenSBI firmwares. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis --- lib/sbi/sbi_init.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 7380d01..3f44a2b 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -53,6 +53,11 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) static void sbi_boot_print_general(struct sbi_scratch *scratch) { char str[128]; + const struct sbi_hsm_device *hdev; + const struct sbi_ipi_device *idev; + const struct sbi_timer_device *tdev; + const struct sbi_console_device *cdev; + const struct sbi_system_reset_device *srdev; const struct sbi_platform *plat = sbi_platform_ptr(scratch); if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS) @@ -65,6 +70,21 @@ static void sbi_boot_print_general(struct sbi_scratch *scratch) sbi_printf("Platform Features : %s\n", str); sbi_printf("Platform HART Count : %u\n", sbi_platform_hart_count(plat)); + idev = sbi_ipi_get_device(); + sbi_printf("Platform IPI Device : %s\n", + (idev) ? idev->name : "---"); + tdev = sbi_timer_get_device(); + sbi_printf("Platform Timer Device : %s\n", + (tdev) ? tdev->name : "---"); + cdev = sbi_console_get_device(); + sbi_printf("Platform Console Device : %s\n", + (cdev) ? cdev->name : "---"); + hdev = sbi_hsm_get_device(); + sbi_printf("Platform HSM Device : %s\n", + (hdev) ? hdev->name : "---"); + srdev = sbi_system_reset_get_device(); + sbi_printf("Platform SysReset Device : %s\n", + (srdev) ? srdev->name : "---"); /* Firmware details */ sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start);