From patchwork Sat Jul 24 12:24:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1509484 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=2607:7c80:54:e::133; helo=bombadil.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=bombadil.20210309 header.b=iBJyK6QH; 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=KEah9MJ+; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=uo7CopYO; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4GX54h4tg0z9sXJ for ; Sat, 24 Jul 2021 22:25:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=25vq9H64TJ6/NLd9+OPi4iXJV89CA4p52lXqri4SJVA=; b=iBJyK6QHDtvIxL kIN3m5R7p/HNIyq0i4w2Cfp9XqPX2Oxer/4uPn4XgxQx/MM2IkUcUqx1m8jZ7322cGs5wUlRLpx4T MhBi/KstKIDq6eAB8hnBaKttNPovMmm/u19K67nkmmTHbAQRcfKvHRCTet+wH/fPwvSJgCPVmfO0/ WnDS9K+Vr7ye85BsetcJGWfTcHvV1vlGHlRsg80utpS0laXlC9CnWY8lC8agtE/K/JVT+PI5GAGNU mKkCq0Mwr5lOTWEuMuuRrYKL9vgqpCBxzY1fIsUA9S+ZjX41GIlGdsdy4IMvndK17QwT/nJAYd9DR O8hp9rObliSZwMSTfv6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gii-007AXS-Fu; Sat, 24 Jul 2021 12:25:32 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gie-007AW7-Vu for opensbi@lists.infradead.org; Sat, 24 Jul 2021 12:25:31 +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=1627129528; x=1658665528; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=8ssYtHmDzb7oW076g9AnVBUm7r/li70clzZ72GlSm/M=; b=KEah9MJ+wrIuzlh//6bZfkwS04dZVz1c2B/6E2DtBBhkXtCheFSIIcqm eM3Y6Dp6K44xWZOZ8w96R+mrMJ7cKVPp77kNnDq0Hg8l/5HwM/2iBEyjp lFkxWXh6ZFSxSPOR50TlbfzIrphojsjq5fj/8qj1GhC8aw2n3+0b6NGgc a+fVyUjG8cBRc5QJGTIdffx3tzzadkm2+5u/5FdegqPJqCmBgwz+vClNo hxjxu3FuPZJCmmX7Eqh7IIR7LibcQxdyEjEsq1/yavMlC9HAycedhNn0u YjON4y/ME7S5mlZl5r01qTRla06zhNTKfAKs+4hibaA5ocqw9m8jAosNt Q==; X-IronPort-AV: E=Sophos;i="5.84,266,1620662400"; d="scan'208";a="286959715" Received: from mail-dm6nam08lp2040.outbound.protection.outlook.com (HELO NAM04-DM6-obe.outbound.protection.outlook.com) ([104.47.73.40]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2021 20:25:26 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkQtpbh6LMDEMCsIZYMCgc6o1qkSNpTh2ZFLtxo1ewLE9Apfn1NgcrcLTDQSBVO1d6yzpCJ77gUmKmpI4mROQkhD8KaCkcsoMGf0xu4iagwXMzG6BFGDWB2/PIb0LdOQN1FwvFy2EMiyGRaeoVIcMpgtOVXOPNXRnDftfVerEJ/XNl7XkSPler8BaU0EEtN86i4NXI0eCJCps0+qgb3bKfMojPBLObSphhXXNVckoVnCVL5ktAnSPbPvlnSHqGPBQrFSHbghQgz2CxP5/wxJXzcf5ZeABaBhfYyf2xB0Dt+u9CuSVKpFHuqg7hMxeWFbn0NmV7JJWzv1e0Fl86vsww== 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=3K2OE3at4tWkG5x5HvoUC/D8ddQyJVGP24v2GMh+YXM=; b=Okyeih+2iNr0g1fQjTuA5nmEaD+cqDXEIA4V+uULKBDOOradeWO0YMAtToHsvitDPYwEUPTlPEKd7z21XEI2gSEmdHLbw0dkB+zA6EmN8UqasZg+l5SDaOUb4JQD4WulkRT6WLhEI4usGfJ3l2B81zNQaNW/bpB+jjz5bOCVSt/YWzbXJZezQqeA6t8qStXui9G9BZWsl2rmIhjr605pPqRqQ3HYSF7ncGOuGcDaeE4Cnmmo5dmT16uAclNgFWUb/+ENkGwY6NnXSH21LW2xQTB4Yi1WIVZLxVXGPBq/McPwBI4FLMi7YgeILzsFgto4MXKLSBXde+JTrGxZaroZWw== 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=3K2OE3at4tWkG5x5HvoUC/D8ddQyJVGP24v2GMh+YXM=; b=uo7CopYO9dHADQ4FwdSxkqfjrS6TuHopHylHkS/6BTTs4fZSzi+JGgz2gpO9bupBW/p76sMI4LxxqWNGJJIYQMlluSJhYG3ooqsoNv3lW4sKyWG1wlcGJtD23C1DW5xqfALarJLQydcrOCVIFhuSwVNm7pnJ7xb4T/YC5ckKJFM= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7764.namprd04.prod.outlook.com (2603:10b6:303:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Sat, 24 Jul 2021 12:25:26 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%8]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 12:25:26 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 1/5] lib: utils/timer: Allow separate base addresses for MTIME and MTIMECMP Date: Sat, 24 Jul 2021 17:54:59 +0530 Message-Id: <20210724122503.2486624-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724122503.2486624-1-anup.patel@wdc.com> References: <20210724122503.2486624-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.179.61.225) by MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Sat, 24 Jul 2021 12:25:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1911f3e0-9c4b-4acd-694c-08d94e9e1d9a X-MS-TrafficTypeDiagnostic: CO6PR04MB7764: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:663; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6oqce2zwVTwDi8e1OQWlWiKYUS4iLqL/h8D6zhOXXonN7hJwd4j84TlcOkhxZB3vZ1thCEFH1x+uKs9ZE9mhitqaZMxhE5X6AHsMe3dPzYfFUWPNAoKZ9XXQ/A+970VrabEBsAwlQltXGc06cZ2NEFOQ0OESNUZS1HvUvR1otWkb/Lg2dlMV3C6EezWuTbSNbAZA9yeOx4RrlvaPeMvi2BUURRpSRmxhLA1PCheSGySigoYNgce2b1dssOkUs/hzMFUfS3Bx9WGjOuIfZ0y+8e/Fho0Szd4ly4FtHAh2rXhjDXq/sIM3o8xbNg1d2PDd6mEDcOkHbTjlVEysSrG3EmRQ89ZGk+3q7vLycWS2xhwGZFa3SAdHXcabceWvWjK5MOC+ZbE6o9JzTW068cS0j1IUdC4/+IGmrW9XyHSAa3k2jCbct0ffQXHYsUZGTGhYzrdwF5f5vA7aNCDYD1IzuWCH5mMqttljIDpFW5IBrj3oOV40k/5ICxfz/waOprCzAHqY67SlBOU5Uv5agohEFdEevrWjaucbGid+ZPoMT65rYZ5yZxLwpRb6exQrwztyKKJou25ahz9aMOtFmzjadYWs7GNhW6TC5GQb43JlNei/9hh16ZTX1uz/8eksujMuY27gyCalg2E2z6A5wDN4qf8bRqiOplqgB8WLmApyfIdlcKf+pxiPmCg+cPUnpXizIXBb9mCB84/i/ahHVjoH+Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(956004)(44832011)(2616005)(38350700002)(36756003)(1076003)(8676002)(38100700002)(4326008)(508600001)(5660300002)(55016002)(110136005)(8936002)(66476007)(66556008)(66946007)(316002)(6636002)(8886007)(6666004)(54906003)(52116002)(7696005)(83380400001)(86362001)(2906002)(26005)(186003)(30864003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IyjYkXDQqvu79+jab0LQt2Ft2kIssgNL/46uOnwHUxNqdiLGC19lKTkO2ms+J55oW5zn0Ts17OQn0jMhtXBsEkxxkMy2SdoDgpsafuCZmr8Xzi7NZQVx6qnQ+bjInZhsSVjrCBS3pfcvDA2x2bnEo5MSRLuPcXrAft4WKJ4xnBsRFuxzyMr11/TnERassDKs+sbPDCjp6eK2lDtkLskkDUBeASwRwOCPHtGuHujnNCINg0bfimR8+tJQ4mv36C6BQegYp7ejE0nLHQLo2qKWcsL55wvdt53ameJtTUesnrZCFG2PRuePA16fm85HrJZ7GffIxW0OFMoSgn+FPfSaXkpzEBIo+O2eoRP/obgIqr8W4Dc3TnxR3D34309z6mGSyq8Bu0/y1iWiT4EB+UPe8yzrASYa8hwl+MzrdczThjUtvi5iLeerXHwmtW1kuYL/i6IFwFOwd8DWGl9T/7lxL8zKr1e/siEYY4QtsswLnjjWIr1Uy8/wrALgh+sZpaZm96gQyrV0W0l0tFwc/jsUQWj0wY+egU4aIVwgrQ0T5Pq5fFklUDNhXUQK3PTE+IVxebfc+Qi1HoRuuYDY8fv/2pOJl+Uvk25ICtX4+x/xlNYS3gQbY2TEKuMEtICqQ3HdZ/d/owNXgo/JVWteXxjgHYBDQjyKkFQdHq9rmZwypXm+NVNiAkdhnqyzANhRMXYHkGNspfPHCQupSAUKmJ5dhzyWG+yZbgTep66GRVIg2HoKTlFXuAQPbf/kwlOMWbR5hN4iTJ8BLcZGdPBbOu9FqHB4tMJMmvd4QbYPGigpPiCo4iGh9XoCPivy5Ppe6a18r+qLxVsdcf84ri2jmVzP1pQMfijGQcDNsCTVQGEp38HmdemhkrJLZAfnNYxcZkCtsTFtf1x4Q9dECcrOrozFNsdyVqABfvWAx1ZcPFujqSNa4m1gxrnN3JL/O2yz3xkr1f2A/Ax7xXYvAm8WT6n7V+ixCurZ+2KkIJPpmItXHDJ/ujyB2lvLGhjEJ9xzGJ40JFtzYNWiYtGd+daFHphE3LpO4o83BRylmpgp1PmLMm39aHcB9WBqW0ARbEI/1jUgbpZj9wly+WCxvCW49ALiOFo67FgJOWCyXBg5+8AAHMENrXVcELBYudZvjRPCpeSjJgtc63YlrwiDE3LH/l3Vi3cSaSJMGcbaqmILJiCyk1U9BQOrt6hWpHNlKfnsqXPmS3hc7BJv5R59MxCjT1HKPATlxXf30sbAOlaEUrDpCs/muLl7HTzORFZmS1nI63eyJMPgS6AHYa3yAB7sEmfEfTjdSmr8E655oH8Bi3O4wjz2Wl8yKV0EIusqkNHPmpsK X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1911f3e0-9c4b-4acd-694c-08d94e9e1d9a X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 12:25:25.9507 (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: KW7Pl2phSfKBAZGblTEvWw4PBwjTWfnJv3AZeYdCU+i253aaInvGL2ORI24mWiNCW3EMP74Guoo4i9cl8nQsQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7764 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210724_052529_090680_5D9AA80B X-CRM114-Status: GOOD ( 19.11 ) 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 extend the ACLINT library to support separate base addresses for MTIME and MTIMECMP registers. Signed-off-by: Anup Patel --- include/sbi_utils/timer/aclint_mtimer.h | 19 ++++-- lib/utils/timer/aclint_mtimer.c | 77 +++++++++++++++++++------ lib/utils/timer/fdt_timer_mtimer.c [...] 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 [68.232.141.245 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 ACLINT library to support separate base addresses for MTIME and MTIMECMP registers. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi_utils/timer/aclint_mtimer.h | 19 ++++-- lib/utils/timer/aclint_mtimer.c | 77 +++++++++++++++++++------ lib/utils/timer/fdt_timer_mtimer.c | 16 +++-- platform/fpga/ariane/platform.c | 8 ++- platform/fpga/openpiton/platform.c | 13 ++++- platform/kendryte/k210/platform.c | 8 ++- platform/nuclei/ux600/platform.c | 8 ++- platform/template/platform.c | 8 ++- 8 files changed, 116 insertions(+), 41 deletions(-) diff --git a/include/sbi_utils/timer/aclint_mtimer.h b/include/sbi_utils/timer/aclint_mtimer.h index 62aa086..54eb238 100644 --- a/include/sbi_utils/timer/aclint_mtimer.h +++ b/include/sbi_utils/timer/aclint_mtimer.h @@ -12,16 +12,25 @@ #include -#define ACLINT_MTIMER_ALIGN 0x1000 -#define ACLINT_MTIMER_SIZE 0x8000 -#define ACLINT_MTIMER_MAX_HARTS 4095 +#define ACLINT_MTIME_ALIGN 0x8 +#define ACLINT_MTIMECMP_ALIGN 0x8 +#define ACLINT_MTIMER_MAX_HARTS 4095 + +#define ACLINT_DEFAULT_MTIME_OFFSET 0x7ff8 +#define ACLINT_DEFAULT_MTIME_SIZE 0x8 +#define ACLINT_DEFAULT_MTIMECMP_OFFSET 0x0000 +#define ACLINT_DEFAULT_MTIMECMP_SIZE 0x7ff8 +#define ACLINT_DEFAULT_MTIMER_SIZE 0x8000 +#define ACLINT_DEFAULT_MTIMER_ALIGN 0x1000 #define CLINT_MTIMER_OFFSET 0x4000 struct aclint_mtimer_data { /* Public details */ - unsigned long addr; - unsigned long size; + unsigned long mtime_addr; + unsigned long mtime_size; + unsigned long mtimecmp_addr; + unsigned long mtimecmp_size; u32 first_hartid; u32 hart_count; bool has_64bit_mmio; diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c index 41b0290..ebc9300 100644 --- a/lib/utils/timer/aclint_mtimer.c +++ b/lib/utils/timer/aclint_mtimer.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -17,9 +18,6 @@ #include #include -#define MTIMER_CMP_OFF 0x0000 -#define MTIMER_VAL_OFF 0x7ff8 - static struct aclint_mtimer_data *mtimer_hartid2data[SBI_HARTMASK_MAX_BITS]; #if __riscv_xlen != 32 @@ -56,7 +54,7 @@ static void mtimer_time_wr32(bool timecmp, u64 value, volatile u64 *addr) static u64 mtimer_value(void) { struct aclint_mtimer_data *mt = mtimer_hartid2data[current_hartid()]; - u64 *time_val = ((void *)mt->addr) + MTIMER_VAL_OFF; + u64 *time_val = (void *)mt->mtime_addr; /* Read MTIMER Time Value */ return mt->time_rd(time_val) + mt->time_delta; @@ -66,7 +64,7 @@ static void mtimer_event_stop(void) { u32 target_hart = current_hartid(); struct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart]; - u64 *time_cmp = (void *)mt->addr + MTIMER_CMP_OFF; + u64 *time_cmp = (void *)mt->mtimecmp_addr; /* Clear MTIMER Time Compare */ mt->time_wr(true, -1ULL, &time_cmp[target_hart - mt->first_hartid]); @@ -76,7 +74,7 @@ static void mtimer_event_start(u64 next_event) { u32 target_hart = current_hartid(); struct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart]; - u64 *time_cmp = (void *)mt->addr + MTIMER_CMP_OFF; + u64 *time_cmp = (void *)mt->mtimecmp_addr; /* Program MTIMER Time Compare */ mt->time_wr(true, next_event - mt->time_delta, @@ -111,8 +109,8 @@ int aclint_mtimer_warm_init(void) */ if (mt->time_delta_reference) { reference = mt->time_delta_reference; - mt_time_val = (void *)mt->addr + MTIMER_VAL_OFF; - ref_time_val = (void *)reference->addr + MTIMER_VAL_OFF; + mt_time_val = (void *)mt->mtime_addr; + ref_time_val = (void *)reference->mtime_addr; if (!atomic_raw_xchg_ulong(&mt->time_delta_computed, 1)) { v1 = mt->time_rd(mt_time_val); mv = reference->time_rd(ref_time_val); @@ -122,24 +120,53 @@ int aclint_mtimer_warm_init(void) } /* Clear Time Compare */ - mt_time_cmp = (void *)mt->addr + MTIMER_CMP_OFF; + mt_time_cmp = (void *)mt->mtimecmp_addr; mt->time_wr(true, -1ULL, &mt_time_cmp[target_hart - mt->first_hartid]); return 0; } +static int aclint_mtimer_add_regions(unsigned long addr, unsigned long size) +{ + int rc; + unsigned long pos, end, rsize; + struct sbi_domain_memregion reg; + + pos = addr; + end = addr + size; + while (pos < end) { + rsize = pos & (ACLINT_DEFAULT_MTIMER_ALIGN - 1); + if (rsize) + rsize = 1UL << __ffs(pos); + else + rsize = ((end - pos) < ACLINT_DEFAULT_MTIMER_ALIGN) ? + (end - pos) : ACLINT_DEFAULT_MTIMER_ALIGN; + + sbi_domain_memregion_init(pos, rsize, + SBI_DOMAIN_MEMREGION_MMIO, ®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + pos += rsize; + } + + return 0; +} + int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, struct aclint_mtimer_data *reference) { u32 i; int rc; - unsigned long pos, region_size; - struct sbi_domain_memregion reg; /* Sanity checks */ - if (!mt || (mt->addr & (ACLINT_MTIMER_ALIGN - 1)) || - (mt->size < ACLINT_MTIMER_SIZE) || + if (!mt || !mt->mtime_size || + (mt->hart_count && !mt->mtimecmp_size) || + (mt->mtime_addr & (ACLINT_MTIME_ALIGN - 1)) || + (mt->mtime_size & (ACLINT_MTIME_ALIGN - 1)) || + (mt->mtimecmp_addr & (ACLINT_MTIMECMP_ALIGN - 1)) || + (mt->mtimecmp_size & (ACLINT_MTIMECMP_ALIGN - 1)) || (mt->first_hartid >= SBI_HARTMASK_MAX_BITS) || (mt->hart_count > ACLINT_MTIMER_MAX_HARTS)) return SBI_EINVAL; @@ -164,12 +191,24 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, mtimer_hartid2data[mt->first_hartid + i] = mt; /* Add MTIMER regions to the root domain */ - for (pos = 0; pos < mt->size; pos += ACLINT_MTIMER_ALIGN) { - region_size = ((mt->size - pos) < ACLINT_MTIMER_ALIGN) ? - (mt->size - pos) : ACLINT_MTIMER_ALIGN; - sbi_domain_memregion_init(mt->addr + pos, region_size, - SBI_DOMAIN_MEMREGION_MMIO, ®); - rc = sbi_domain_root_add_memregion(®); + if (mt->mtime_addr == (mt->mtimecmp_addr + mt->mtimecmp_size)) { + rc = aclint_mtimer_add_regions(mt->mtimecmp_addr, + mt->mtime_size + mt->mtimecmp_size); + if (rc) + return rc; + } else if (mt->mtimecmp_addr == (mt->mtime_addr + mt->mtime_size)) { + rc = aclint_mtimer_add_regions(mt->mtime_addr, + mt->mtime_size + mt->mtimecmp_size); + if (rc) + return rc; + } else { + rc = aclint_mtimer_add_regions(mt->mtime_addr, + mt->mtime_size); + if (rc) + return rc; + + rc = aclint_mtimer_add_regions(mt->mtimecmp_addr, + mt->mtimecmp_size); if (rc) return rc; } diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index 4907428..3f830ad 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -22,7 +22,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - unsigned long offset; + unsigned long offset, addr, size; struct aclint_mtimer_data *mt, *mtmaster = NULL; if (MTIMER_MAX_NR <= mtimer_count) @@ -31,19 +31,23 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, if (0 < mtimer_count) mtmaster = &mtimer[0]; - rc = fdt_parse_aclint_node(fdt, nodeoff, true, &mt->addr, &mt->size, + rc = fdt_parse_aclint_node(fdt, nodeoff, true, &addr, &size, &mt->first_hartid, &mt->hart_count); if (rc) return rc; mt->has_64bit_mmio = true; + mt->mtimecmp_addr = addr + ACLINT_DEFAULT_MTIMECMP_OFFSET; + mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE; + mt->mtime_addr = addr + ACLINT_DEFAULT_MTIME_OFFSET; + mt->mtime_size = size - mt->mtimecmp_size; + if (match->data) { /* Adjust MTIMER address and size for CLINT device */ offset = *((unsigned long *)match->data); - mt->addr += offset; - if ((mt->size - offset) < ACLINT_MTIMER_SIZE) - return SBI_EINVAL; - mt->size -= offset; + mt->mtime_addr += offset; + mt->mtimecmp_addr += offset; + mt->mtime_size -= offset; /* Parse additional CLINT properties */ if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) mt->has_64bit_mmio = false; diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 0b47aa0..58a46c0 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -44,8 +44,12 @@ static struct aclint_mswi_data mswi = { }; static struct aclint_mtimer_data mtimer = { - .addr = ARIANE_ACLINT_MTIMER_ADDR, - .size = ACLINT_MTIMER_SIZE, + .mtime_addr = ARIANE_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIME_OFFSET, + .mtime_size = ACLINT_DEFAULT_MTIME_SIZE, + .mtimecmp_addr = ARIANE_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIMECMP_OFFSET, + .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE, .first_hartid = 0, .hart_count = ARIANE_HART_COUNT, .has_64bit_mmio = TRUE, diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 57ec21b..bcfe7eb 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -49,8 +49,12 @@ static struct aclint_mswi_data mswi = { }; static struct aclint_mtimer_data mtimer = { - .addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR, - .size = ACLINT_MTIMER_SIZE, + .mtime_addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIME_OFFSET, + .mtime_size = ACLINT_DEFAULT_MTIME_SIZE, + .mtimecmp_addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIMECMP_OFFSET, + .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE, .first_hartid = 0, .hart_count = OPENPITON_DEFAULT_HART_COUNT, .has_64bit_mmio = TRUE, @@ -82,7 +86,10 @@ static int openpiton_early_init(bool cold_boot) rc = fdt_parse_compat_addr(fdt, &clint_addr, "riscv,clint0"); if (!rc) { mswi.addr = clint_addr; - mtimer.addr = clint_addr + CLINT_MTIMER_OFFSET; + mtimer.mtime_addr = clint_addr + CLINT_MTIMER_OFFSET + + ACLINT_DEFAULT_MTIME_OFFSET; + mtimer.mtimecmp_addr = clint_addr + CLINT_MTIMER_OFFSET + + ACLINT_DEFAULT_MTIMECMP_OFFSET; } return 0; diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 55c4b1e..ee4c223 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -42,8 +42,12 @@ static struct aclint_mswi_data mswi = { }; static struct aclint_mtimer_data mtimer = { - .addr = K210_ACLINT_MTIMER_ADDR, - .size = ACLINT_MTIMER_SIZE, + .mtime_addr = K210_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIME_OFFSET, + .mtime_size = ACLINT_DEFAULT_MTIME_SIZE, + .mtimecmp_addr = K210_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIMECMP_OFFSET, + .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE, .first_hartid = 0, .hart_count = K210_HART_COUNT, .has_64bit_mmio = TRUE, diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 22ca4c9..ab0becc 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -74,8 +74,12 @@ static struct aclint_mswi_data mswi = { }; static struct aclint_mtimer_data mtimer = { - .addr = UX600_ACLINT_MTIMER_ADDR, - .size = ACLINT_MTIMER_SIZE, + .mtime_addr = UX600_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIME_OFFSET, + .mtime_size = ACLINT_DEFAULT_MTIME_SIZE, + .mtimecmp_addr = UX600_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIMECMP_OFFSET, + .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE, .first_hartid = 0, .hart_count = UX600_HART_COUNT, .has_64bit_mmio = TRUE, diff --git a/platform/template/platform.c b/platform/template/platform.c index 3f09d98..4528822 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -43,8 +43,12 @@ static struct aclint_mswi_data mswi = { }; static struct aclint_mtimer_data mtimer = { - .addr = PLATFORM_ACLINT_MTIMER_ADDR, - .size = ACLINT_MTIMER_SIZE, + .mtime_addr = PLATFORM_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIME_OFFSET, + .mtime_size = ACLINT_DEFAULT_MTIME_SIZE, + .mtimecmp_addr = PLATFORM_ACLINT_MTIMER_ADDR + + ACLINT_DEFAULT_MTIMECMP_OFFSET, + .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE, .first_hartid = 0, .hart_count = PLATFORM_HART_COUNT, .has_64bit_mmio = TRUE, From patchwork Sat Jul 24 12:25:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1509485 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=2607:7c80:54:e::133; helo=bombadil.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=bombadil.20210309 header.b=U0YvEJtZ; 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=ds7CnbkS; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=SIeJL4XI; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4GX54j04CLz9sXS for ; Sat, 24 Jul 2021 22:25:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w8Tq+0XBVLHUPnKSdq1JHSXJ6vdyTPksgyirtxDXEpw=; b=U0YvEJtZGDwZMV a21fb40N5Xlmvn9p5heiK0Knf9gbiw4xGlrSSNO/iP7m60N89MjuGAAAs8rr4Pi56KXkAqmEECvVD 5evZZyqtpeNY0mI5p48KUjinBipqywZmihfLdizG7Vn/LyNIoh7tomqgYXF0YP0oE20WRJfPoXbOP vHBwKjWAZiAkH39aTTxIKLe4ujYwIvuZVP53t94F8Vl6uC0IZSuh6StlW57KsVn5H4q7sxYm2G5Ks dmstrhf7YLMUbo/Vln2SCY+zWhMBv0KddeVZSADiirVcfGzLBqs+oQxrYsEXyn7lWHXPldLdpusqi 483yMPh2wGRWDNzVmiiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gii-007AXZ-Vy; Sat, 24 Jul 2021 12:25:33 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gif-007AWa-HI for opensbi@lists.infradead.org; Sat, 24 Jul 2021 12:25:31 +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=1627129529; x=1658665529; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=DAsbE46XGXML751BBumzRRGwKx3xZ+sdwpvqznSj0iI=; b=ds7CnbkS34zbxIgwuHb6jEJXJW9Hq3h0qAlM/u7e0WFS9zkA5dYcAQhp 2lcfJHQGp+XuOzceEIoHWDY7bIYeMO4mdGJ72YG5UnnTUscVz7HtMNp9I Hfuy9qR/VNFjL6tsL35u4lkA8QqO8CiJGkt661qp+cWCq+XgjPEUADPha GdG1lhFiDqITOVA0MRBR6QsXnFadKfIjwyz2tzof5vk4qHyO8rBZR52po atRvIDi4PlIGd5JpPsGAiobyDZurYhANB5qPzEuX0BxZ+kNF/oONVrD/l /hu/TPNppwiyko84h7CqF9hocCSP/g2K1e+8eTOJbLRvchBdNORT1cRhh w==; X-IronPort-AV: E=Sophos;i="5.84,266,1620662400"; d="scan'208";a="286959719" Received: from mail-dm6nam08lp2046.outbound.protection.outlook.com (HELO NAM04-DM6-obe.outbound.protection.outlook.com) ([104.47.73.46]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2021 20:25:28 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fjZpC82gtrARmw4YimGfrTsNw3gWliIa1R6elOD05w6m+F9J590if7lkZuxsY/hOH3Kus2bSqD33kaJx02ZcUoXvvjtvO+mxhOHQVb0AddJpLOYrKCcJMPV4hORPidzaS8kWtK0dQfPd9va3C3YudwC93rOQaqXOgnDPVyVKyi3fvjW+qQI7BwXYXPPolJQ/9cn4TTfrzRDEjhDheLjaepXC8a2o6KaEvS/xw4BTFO0Yp1svELu8RSKEWZcqFhZ7qj/T68aIsvzrRMzrNAlWX89mC/Lw+ppSVnClfNE6RU7WzgQjxT0u4cz1pZav4ctKY8L+HbaHCn9KLoZXWPWLOw== 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=IbgiUlhVHNiqkbtjSOzZAoxP76I3f4SjXFni0a63DIE=; b=gPZ6iKKIRM5tfFth5cquL9W88u2rBvnV+RfnyR/GixDcHsQu/UlKyoLylYf1J7l+sncZ1vSb+4CI3T9kZ75ODKsqsUH5oSiZIQlk0kKEoFSjrod3A0TU2SlGKlpgKXy5WdJQfhTsOWA0WnVBE/gJ35I2Al6r+w2Gwm+Yy7nbNYpeH2BZo3iEzZCxKHUpM5HZEWw2Gbcbp+aeb2jfsL3+zYcpehHKv+riZGZbQGR16R7/5VMcOoECfhjmkrOYzwTZOcj6TZeiPuHFso6kLywm61Q2TxDWnOPgyun1SwmcW5lFgLYHfRTqL5nARE9T9sBYGtVOMMdcLfDcU3adZaAY/Q== 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=IbgiUlhVHNiqkbtjSOzZAoxP76I3f4SjXFni0a63DIE=; b=SIeJL4XIUOFOxusU8M64frndN9aIoJaFow8WemBnzQz3R16Yddg2rstx4OtxZcubAr51Xi7GJvET7JLC1OLfO4NW5ifWPLptbdcPgcxFVXSh+rBgajgDd5KweZBA6FCHl21NHe4g8cxcD79XiHc7nn495Pf5MYVqQYTPrPR9tGs= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7764.namprd04.prod.outlook.com (2603:10b6:303:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Sat, 24 Jul 2021 12:25:28 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%8]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 12:25:28 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 2/5] lib: utils: Extend fdt_get_node_addr_size() for multiple register sets Date: Sat, 24 Jul 2021 17:55:00 +0530 Message-Id: <20210724122503.2486624-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724122503.2486624-1-anup.patel@wdc.com> References: <20210724122503.2486624-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.179.61.225) by MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Sat, 24 Jul 2021 12:25:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e33fb5b-072d-47d6-27b5-08d94e9e1ed2 X-MS-TrafficTypeDiagnostic: CO6PR04MB7764: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XAru1RlZNigXey7R5GFhxb+0CppHsS7Q1w+dXDJZdpw08zh2pN3Eh+V8SotWNChQOv6xE69Xfet8qvDt8UEoAzDsJgk6jQhQojoPdXoTactaia4vV2YhhIZe5KR0PE5Ylfh8ZAI9in+ZeJUtW6Kl/egI6xsXlixXXnlkNeUWMnUav4r3dTGdIHL24aSNEhu9hICX283u5RRI9D/GjN6Gi9wGqgG9QU1n3QmpTSDVniHZ30/To2HXV0xy0TT5JVZKT5KLrttJTnPq9mkfRh/jdxfd7U4KqhDJk7J5MndeQh3bGqOQ0H1gSboSkSnY5AYt3ybcrWa6k2dWELWg/J10dkC3yq4Loxs0cwSBP6M2IUQLvhV/ZsdBhTs7oC3OrIS1HraJMZcS9ciRJAicOfxWiWBdbLtnFNYNlST2j6CLoUFOs8FTYAro9X5xqNzZSacenC3MYxHcjnquUGiBiE/W6aPELAPkv5j9yawcdyUi5W2+INWPdX9utHMuxOXF2oe44g8f0GhgkjUoo2Ul9rVt0TVsV9h84qdF7cgBAQPbhjBtui5XvvNMYlen2tSO2mYiAUY8jIv1O7cfpTFFlA2xYsJnqTT28NPYYRhuQcrAWzL7FgZGdJJ318/OqXfPqw1PDRwpk1P06DTSfRQG9iPe40TbZU+roCogM++WojML/pqqq4xskL5I0gi9PALFfIhsv7Mg9CkQbovJlZQfENt7Rg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(956004)(44832011)(2616005)(38350700002)(36756003)(1076003)(8676002)(38100700002)(4326008)(508600001)(5660300002)(55016002)(110136005)(8936002)(66476007)(66556008)(66946007)(316002)(6636002)(8886007)(6666004)(54906003)(52116002)(7696005)(83380400001)(86362001)(2906002)(26005)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2cMhgE68KqF7z9YVL8yyN+0rSw72xEnmGuxH3VWWg/Bj6HAhMRs3/WurV0VkBHbHaQrDMuGtdvdqiCdUUPOtK55dF/OKMKxf1uiGpN3iC3loNSA6Odoa9S74NWCpzlyy9p8ofhJFtw3BLUdM98orHo1S2JEdE/gFempf29i27hwXd1ntlwZsvB9N6WcNM3HXpWQlJkDBS1GK13BKzQhFcwm6FPHKHkB5jRIs8GxBO3UiXuSvyyqdPrv483pWOIONFmDIEmXGYdQEL+16ceFg1wNa+iyCNgDTfgaubl9IHptsW02CjS2QSSKJz+baxkhRjAAzP5RAMrcobZUR/oXNXo8LkjZDFtgYfrS7fIELYU8rSYVRlfusiJEx6YZkkwAMOFO70njjv81OtqKQ+2HilgqggscsO2BOqLpxJ1AFd1cTtz2gWMhjvTeqCZObIesNT60YgxKDsveup6kNPzz6cNvCLzz4Nbo3RtF644oKgNMFLGg/gPA80yCx4wB7DpD7GJOWtyIa/0TuWJXM/tjoEK5YyoTk/+63g/dIgFM0NhBcwqQXrEr4b6EIaNsDj1aV+lHTkKtOFj8+Bf0jTy6fhY7uODoNDUzyzhvKQvYNSm/dz7nr75RhI7z/BE0ow2k0J7VPlMPfspYJ6s1Sqzu4CgNdjSDh9enNRT7BTt66sjnsgMSm500+T7u1lg2BH5X9pI+2ZmlJSp77eTgRL19mUDfhUr3ehY+uU+9WfVwUSFCs770LLv19M+QK4fm/whxDXILuX5W/x8qyxyRpCECQRipfleYEsK/gtTHdVyvGTGFclHRYCPb/Uy3cnb0ghmj77vCxcc0SEJPybqQqFf52K5FTYKigBt54ykuFPtxnLgyWsZFy5H2kbjyglU5ua7td4sHb5/pxYRPNYRzhkWLt5HaV4kLHDLhQioI4FZ8brMTn7WI4Bqb8hOWNPHCqTRpfBa7iTe8FtIYxBsTcApMWlnx5DDV38MLci8I/a0o3sjfkTi9VzKju/5aM0QTztbiaBLNzvspQG8yucDZ1fefX76YZGizyrdREWTfYhuJGu7X2HjOimy7D7LywhqEyucFy8a0sJ0hIEZuRHKqldNNsTetve0ISRcUGML3ng++AlMTY0SBYr/tT0b7jlak7HPDaLyO/3MTMdXhEU9Tz+ab5IoBC70DYZFETLXvnKWeyieoqjJAalSy4t7YNDdLvw580GuyMWuS0cwJphyWtoFbDygDMws6oXVdwS8VzgalqZSYtzu07cEirdhDUfNp5K6B8w/23mMziH1oyIyAAIirP8I2zfIyyrQA58O5hnq8P6iZUaCqHxSYF30Vnslmysauf X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e33fb5b-072d-47d6-27b5-08d94e9e1ed2 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 12:25:27.9838 (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: ZyM63VxIHrVTfCv9o2tGIFBIGrDEnF0Ja0vFGpskNTjn10alnWnD2qC6rIjM62Sv6xvafjq8GAKKdy4zI7+Y9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7764 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210724_052529_627236_A52100A1 X-CRM114-Status: GOOD ( 14.49 ) 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 add "set" parameter to fdt_get_node_addr_size() API so that calling function can specify index of desired register set. This will allow fdt_get_node_addr_size() to handle DT nodes with multiple reg [...] 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 [68.232.141.245 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 add "set" parameter to fdt_get_node_addr_size() API so that calling function can specify index of desired register set. This will allow fdt_get_node_addr_size() to handle DT nodes with multiple register sets. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi_utils/fdt/fdt_helper.h | 3 ++- lib/utils/fdt/fdt_helper.c | 31 ++++++++++++++++++------- lib/utils/gpio/fdt_gpio_sifive.c | 2 +- lib/utils/reset/fdt_reset_sifive_test.c | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index 55b9382..0445e36 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -43,7 +43,8 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff, const char *prop, const char *cells_prop, int index, struct fdt_phandle_args *out_args); -int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, +int fdt_get_node_addr_size(void *fdt, int node, int set, + unsigned long *addr, unsigned long *size); int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid); diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index a970c0f..a992911 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -157,7 +157,8 @@ static int fdt_translate_address(void *fdt, uint64_t reg, int parent, return 0; } -int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, +int fdt_get_node_addr_size(void *fdt, int node, int set, + unsigned long *addr, unsigned long *size) { int parent, len, i, rc; @@ -165,6 +166,9 @@ int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, const fdt32_t *prop_addr, *prop_size; uint64_t temp = 0; + if (!fdt || node < 0 || set < 0) + return SBI_EINVAL; + parent = fdt_parent_offset(fdt, node); if (parent < 0) return parent; @@ -179,6 +183,11 @@ int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, prop_addr = fdt_getprop(fdt, node, "reg", &len); if (!prop_addr) return SBI_ENODEV; + + if ((len / sizeof(u32)) <= (set * (cell_addr + cell_size))) + return SBI_EINVAL; + + prop_addr = prop_addr + (set * (cell_addr + cell_size)); prop_size = prop_addr + cell_addr; if (addr) { @@ -271,7 +280,8 @@ int fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset, if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; - rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, + ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; uart->addr = reg_addr; @@ -309,7 +319,8 @@ int fdt_parse_shakti_uart_node(void *fdt, int nodeoffset, if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; - rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, + ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; uart->addr = reg_addr; @@ -343,7 +354,8 @@ int fdt_parse_sifive_uart_node(void *fdt, int nodeoffset, if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; - rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, + ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; uart->addr = reg_addr; @@ -381,7 +393,8 @@ int fdt_parse_uart8250_node(void *fdt, int nodeoffset, if (nodeoffset < 0 || !uart || !fdt) return SBI_ENODEV; - rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, + ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; uart->addr = reg_addr; @@ -441,7 +454,8 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic) if (nodeoffset < 0 || !plic || !fdt) return SBI_ENODEV; - rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, + ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; plic->addr = reg_addr; @@ -482,7 +496,8 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, !out_first_hartid || !out_hart_count) return SBI_EINVAL; - rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, + ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; *out_addr = reg_addr; @@ -544,7 +559,7 @@ int fdt_parse_compat_addr(void *fdt, unsigned long *addr, if (nodeoffset < 0) return nodeoffset; - rc = fdt_get_node_addr_size(fdt, nodeoffset, addr, NULL); + rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, addr, NULL); if (rc < 0 || !addr) return SBI_ENODEV; diff --git a/lib/utils/gpio/fdt_gpio_sifive.c b/lib/utils/gpio/fdt_gpio_sifive.c index abc9d72..bbddd58 100644 --- a/lib/utils/gpio/fdt_gpio_sifive.c +++ b/lib/utils/gpio/fdt_gpio_sifive.c @@ -76,7 +76,7 @@ static int sifive_gpio_init(void *fdt, int nodeoff, u32 phandle, return SBI_ENOSPC; chip = &sifive_gpio_chip_array[sifive_gpio_chip_count]; - rc = fdt_get_node_addr_size(fdt, nodeoff, &chip->addr, NULL); + rc = fdt_get_node_addr_size(fdt, nodeoff, 0, &chip->addr, NULL); if (rc) return rc; diff --git a/lib/utils/reset/fdt_reset_sifive_test.c b/lib/utils/reset/fdt_reset_sifive_test.c index f98f03d..b0b7dbb 100644 --- a/lib/utils/reset/fdt_reset_sifive_test.c +++ b/lib/utils/reset/fdt_reset_sifive_test.c @@ -18,7 +18,7 @@ static int sifive_test_reset_init(void *fdt, int nodeoff, int rc; unsigned long addr; - rc = fdt_get_node_addr_size(fdt, nodeoff, &addr, NULL); + rc = fdt_get_node_addr_size(fdt, nodeoff, 0, &addr, NULL); if (rc) return rc; From patchwork Sat Jul 24 12:25:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1509482 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=2607:7c80:54:e::133; helo=bombadil.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=bombadil.20210309 header.b=t6CXSFVu; 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=rynTRLzA; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=y7ZLHQwj; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4GX54h5Zwbz9sXN for ; Sat, 24 Jul 2021 22:25:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SFmyy5FxA9FizJl8UnVwc152tZeb6oUbAbjeifPKVtw=; b=t6CXSFVuVCKz1/ mjKhF1fXnZtznrpHjhZzlUbBb2GfJgQ8euQMJVDTb7gUZo3q6UAEfvkIGN9XB8DbRMH/cEx3i0F0j uAdEtXbWMybeT1lN1tBTQKHYuENwbAs/h/5DZIZkZfp9ZRpx7c6x7QdUWtOwPSLsSGeoLLRY0fcIT t/0p6H+yue69gIzQf4d0KOth1AwrKG4Eo+2A3PMvm/jqPduSE7pxaMQqPZWc3bmAiIElQHsl8qwW+ FY09Jnzbr8DyM/wiheJMEPoFnFMuZuhcaMjmpsPtit0P54NMQ4JhNuXj1Vey9PbXyicpd1++Vqliq StD8ThqfiWVt7PG9pbvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gik-007AY2-L4; Sat, 24 Jul 2021 12:25:34 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gih-007AX0-GQ for opensbi@lists.infradead.org; Sat, 24 Jul 2021 12:25:33 +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=1627129531; x=1658665531; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=wXtS0IdWF7clYhxty4cAwGSVHbu2AyEYsH7yke+M2a8=; b=rynTRLzAedyAGLzovTwtkpU2uzz4t25mkEbFAKz9IXYh2HVYJ0RfVRXx FGIqs255Ht90JfvOyH6rCBn/JTMD1sj87feBAlQ5B/BsFqRbg1Lq/cI5B v64QC9Ga3AqyQxEs2WwlLOrnOiH/uulk4YpkncmBGVeFO2MrycGbJagO4 NkReqf+PXAO2uNF2cxVntoCpl7f1TsFFZMFR8P1cLpaJcbgB4YTNaSxRk Bjq9PwmwYsJzH1PTcWVZk8LtWQJLFwzqmdDq2t8TWmZYqmdovjo6u15NR UcO10esqsht7X66JB9kUow9R7NrYWgkNjyAoMf9ZG6DQSTBC45HK/g4Jm w==; X-IronPort-AV: E=Sophos;i="5.84,266,1620662400"; d="scan'208";a="286959723" Received: from mail-dm6nam08lp2045.outbound.protection.outlook.com (HELO NAM04-DM6-obe.outbound.protection.outlook.com) ([104.47.73.45]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2021 20:25:30 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OAVTmVzGKvQGuPOhBpl03xyyFzC/pLXhpsepGdKJ4e94Yt17bEang3NOeLREEZ560oMf624d/Dx/VEZdgp3rYL6NdvUd5vHKi0GnCxqTE5HGGa5LbyqEdS7VXZY/gq3lJaJsIF4mEYwifwmTwlU8QKe3gZhxD1Hii/xhaTb/cdoORwXi+BYae9S3HsJkvdv6LyQO2ctBfUTRjyZV90kin/YAOXkYg6KASnDb5YCzuE4GQ6+A6E8hW9SKQO37Pb9AybCbVsOMPePInEG3ljFYxLV23Ez3Z5M8vuplAIKuakLslK1TMKS37DD/QHeXVPhZcmE6wLl+z6oA6f1lTi8Ftw== 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=DnfRCb2t4pfoLwSbRK42iUFnpdh2zwldQXqqiRYGAq0=; b=jkdzPPnlHabmMXSIOmSY307ziBGD5YuToXYFtxsrZZzl/gWxguAUtnTEyd4hxMTNofurAe2yTNx+To2zUOX/Zx14+rNnDAJs6sL0JoRztBCOdv2LjabuFcmbA8xZSlFwX1Jatie7c8C1QWLBv4SQYxPUb0gBzlJbih5le+lBhgg/exlsiTmGrZBVtSj54zcj+G53gOxQSLGFs3H4Q5pC5HTtlYB9IjZpH3VHAb3Wse5RGABqprcwTMmrZm4tNGNjsog2wSMC14K7mRVCnu1lCxhZiUsRJwgLem7v8HGcwmjnDwzMml045e5HV2oD9jQO7Y0YqU/E0mseqjYwY2c21w== 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=DnfRCb2t4pfoLwSbRK42iUFnpdh2zwldQXqqiRYGAq0=; b=y7ZLHQwjcjIZg7bPt2E7/z58HLPNvJsvhl9aMCov29dlo1vc2wX1S4ODxBcepFxIAJH85Dz0iIixA4ho8NzLU+sDFdExmBbBRIlJfISCuxz8tgTO7VrQtKfM+waU9T9IlXaspyxps9RtkMKctrzOBlfwUE5IoEAk9YwyB9BVUOg= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7764.namprd04.prod.outlook.com (2603:10b6:303:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Sat, 24 Jul 2021 12:25:30 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%8]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 12:25:30 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 3/5] lib: utils/fdt: Extend fdt_parse_aclint_node() function Date: Sat, 24 Jul 2021 17:55:01 +0530 Message-Id: <20210724122503.2486624-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724122503.2486624-1-anup.patel@wdc.com> References: <20210724122503.2486624-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.179.61.225) by MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Sat, 24 Jul 2021 12:25:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba816545-8777-41cf-bec5-08d94e9e1ffd X-MS-TrafficTypeDiagnostic: CO6PR04MB7764: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D7KGf5HkHFjtr9P3rCkH5sCKldjrCd273PIrs+V9t/KScdcWbmKScVOp9WuOrzwg1SwkO01RZJRG0bX4xEektLyBPmX9ngoKxdZfGYaxM1tgsA7+bY5yNJapmI+Zc8zNs5pfAHqiQGg9JxT//tMqUHCQhwuTNoZWgYJBA3KgNF8ouGG1pAmlByEd+Nsdr0YpMYNxQ4o1PKwKvXBWSyoK0dHRcRdIrasbJ5ZLQ8lkJMtKplUcR0S6BP8D6gN/qlxGoXpsV4LiOD9WsUXkT+YJzmo7rKmM4MCwtEccQVNq++77kQk17MVCEC4njALmPIKc7Z1+TXxcm01ivikkBOxSaXG1rvCSKb0eniS3M/28ytFeLq7zy82JbujSMJg3i9aZqwnXBcF5o2B2U9FAFvE8uneQl80Uy36TPbeE4IiAVGGaHqtlLXDYjSDISog8IIryCF5WfIzSUWrNl5oUWbx1CRt8AzeSlBPYw8jLW1gdAlI+TSVbSksed/AhkAtn0/tT4rrIrRhMNwlSH6gAaFRpaDvet27y8nDEkf87ofDGDZEzkF2TT7RSWEtFtj+LC4ffPhLFSxwQ0WxOVFG60/SCoKgWtYr+DaQU5JlG8toVJNspngC8HAYcqXfgrvC1cz0T/GJyZaQaMtJy89OOKtN1zyjkkObNrPiEsUSJRD0K8F841p5HxhiKiyJEE3l0/TPdcmayu7dI9KZnbHqVuOLcsA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(956004)(44832011)(2616005)(38350700002)(36756003)(1076003)(8676002)(38100700002)(4326008)(508600001)(5660300002)(55016002)(110136005)(8936002)(66476007)(66556008)(66946007)(316002)(6636002)(8886007)(6666004)(54906003)(52116002)(7696005)(83380400001)(86362001)(2906002)(26005)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8FewZRzY1BFMerbLHYWBtK+uxbJoAlDPJyKPFnTPUnOmo2wqSA+G7EJsxrCHEHyMFikZe/jT3NQnLRt2bnvSjWFwlq5rGuCAm9zmPMCCQXeKDm8rPDcUePN1siJaRZNMz7Kdf8TAM8roMJC7bO82EnEWlAkiJZP9RiQm4jB6i1XJDu0zW8Ai3Io5F8zUhVcXJ3yiRbZHdD31ZiRIoOcsL2RxILU/lZ2Xf0hBUXmBn/EI6XDlFE/AufX5UOdV1raeBsYBUpiu+m2vnEf1/MLTD29BNmzYWn+cXdn2sT8na5ZULKFHoaa0EPP8gybybduJilggdNGXEcfgR2mvL1LmyXTDdCq9dhzd0WIbZqPqGt1u4MsvR6MMm500J+bgE+Lbwe48yZgbk6ExN9Hmfpr41fOKdM7BM7qu2VzsHmPICl7JTnIy2rWqSmAJU6VygR8dxNytKD2WxN0a/X7Qc7TzG4eqyfuIGbttUTAdel4YEBxDDzUHnzy+586BkwZZOmGwVb+dN8j8yK/Ws8WAJL0JmS2OzxelLFUs+VqyMJ/yYGQUhayhu4NZmv94P015Osei199LR0BlNdLujH3aS3iXFk0dARYDV27fPsd/K2TsKmmuZ4ARvt8vHuPAoA0Hdj7b5FcDr28Ua+TYQBzsIQkUocWzJVC5b3E73JYZ2mbnpyHbC4WozvuXjkPJeaaR71xguEyqbo5wXEYegpqMudsAYD6AvQepUl5b0YLIDml4AExQwVltPDZcmzCL6ojqlWT2qDH00S2hYwnSAZ5nwAv3xs4bie1DCuRG7ZOPLpQhZI7LFuez1BGy0XcQFY3AKpFrkOWdeQTdsyNvRLOpSKuNeUkrnmfR6TZuz811dYX4rDu93WGhkl0tHks3D0kzMUR5XU6WkSoGPajvK7ezC1DeaE/x3CDIZzpRikD9TTIUI9QzbX51aFqsUY1wGRYvn31EW0Ecf1SgL90LmUEr5fyeqVyFwBrDYVdOlg2t5600P/JRwR8lFhcXXVh1OP8ZQ/esDoi7HWRhXeweILzf0OY8jQwgCmPCUSJOpMsGHZ6UyKuJwc0rBvL51rvdvl6RNQWoWnzIsd+sLESoqvTHQoDQKGGL/4kNqMrPQwO0H7UpOcohaEpdSIFjarqUnI+7UtIZ31RZznoHD4Z+QP1iKOWjZVbTaJJlekGYsVu5pIha3ZIUV64H7Yj6f/YCBvSc7VfSiZXJKr9h7Eho3r9IKwO4HDNOIV3JrXfm32TueFL416ZYh3IvrEHeJwk3hLPo0GX3z3CV5MoVcW+KzYrAEAj5nepdJnKRi8vv7Hv+S6ba1yu4hVfdCk1bUXDvd6wDVqA7 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba816545-8777-41cf-bec5-08d94e9e1ffd X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 12:25:29.9372 (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: ajKYi2jvlXM7gdMmC+h/FPLK5TXTSTJ7gHfguWhVeMsEsJeJOhhYFUhoPkwFoMv3MTvsYcoEAZ2wJCE1rSg02w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7764 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210724_052531_647912_A5B53262 X-CRM114-Status: GOOD ( 18.99 ) 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: The fdt_parse_aclint_node() is used to parse DT node for SiFive CLINT, ACLINT MTIMER, and ACLINT MSWI devices. The ACLINT MTIMER has undergone following changes: 1) MTIMER DT node now requires separate addresses in for MTIME register and MTIMECMPx registers in the reg DT property. 2) MTIMER DT node might have [...] 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 [68.232.141.245 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 The fdt_parse_aclint_node() is used to parse DT node for SiFive CLINT, ACLINT MTIMER, and ACLINT MSWI devices. The ACLINT MTIMER has undergone following changes: 1) MTIMER DT node now requires separate addresses in for MTIME register and MTIMECMPx registers in the reg DT property. 2) MTIMER DT node might have no interrupts-extended DT property when the MTIMER device has no associated HARTs (i.e. the MTIMER device has no MTIMECMPx registers) This patch extends fdt_parse_aclint_node() to handle above mentioned changes in ACLINT MTIMER DT bindings. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi_utils/fdt/fdt_helper.h | 3 +- lib/utils/fdt/fdt_helper.c | 50 ++++++++++++++++++------------ lib/utils/ipi/fdt_ipi_mswi.c | 3 +- lib/utils/timer/fdt_timer_mtimer.c | 23 +++++++++----- 4 files changed, 49 insertions(+), 30 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index 0445e36..d49b123 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -73,7 +73,8 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic); int fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat); int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, - unsigned long *out_addr, unsigned long *out_size, + unsigned long *out_addr1, unsigned long *out_size1, + unsigned long *out_addr2, unsigned long *out_size2, u32 *out_first_hartid, u32 *out_hart_count); int fdt_parse_compat_addr(void *fdt, unsigned long *addr, diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index a992911..12e694c 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -482,38 +482,50 @@ int fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat) } int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, - unsigned long *out_addr, unsigned long *out_size, + unsigned long *out_addr1, unsigned long *out_size1, + unsigned long *out_addr2, unsigned long *out_size2, u32 *out_first_hartid, u32 *out_hart_count) { const fdt32_t *val; unsigned long reg_addr, reg_size; int i, rc, count, cpu_offset, cpu_intc_offset; - u32 phandle, hwirq, hartid, first_hartid, last_hartid; + u32 phandle, hwirq, hartid, first_hartid, last_hartid, hart_count; u32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT; if (nodeoffset < 0 || !fdt || - !out_addr || !out_size || + !out_addr1 || !out_size1 || !out_first_hartid || !out_hart_count) return SBI_EINVAL; rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, ®_addr, ®_size); - if (rc < 0 || !reg_addr || !reg_size) + if (rc < 0 || !reg_size) return SBI_ENODEV; - *out_addr = reg_addr; - *out_size = reg_size; + *out_addr1 = reg_addr; + *out_size1 = reg_size; + + rc = fdt_get_node_addr_size(fdt, nodeoffset, 1, + ®_addr, ®_size); + if (rc < 0 || !reg_size) + reg_addr = reg_size = 0; + if (out_addr2) + *out_addr2 = reg_addr; + if (out_size2) + *out_size2 = reg_size; + + *out_first_hartid = 0; + *out_hart_count = 0; val = fdt_getprop(fdt, nodeoffset, "interrupts-extended", &count); if (!val || count < sizeof(fdt32_t)) - return SBI_ENODEV; + return 0; count = count / sizeof(fdt32_t); first_hartid = -1U; - last_hartid = 0; - *out_hart_count = 0; - for (i = 0; i < count; i += 2) { - phandle = fdt32_to_cpu(val[i]); - hwirq = fdt32_to_cpu(val[i + 1]); + hart_count = last_hartid = 0; + for (i = 0; i < (count / 2); i++) { + phandle = fdt32_to_cpu(val[2 * i]); + hwirq = fdt32_to_cpu(val[(2 * i) + 1]); cpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle); if (cpu_intc_offset < 0) @@ -535,17 +547,15 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, first_hartid = hartid; if (hartid > last_hartid) last_hartid = hartid; - (*out_hart_count)++; + hart_count++; } } - if ((last_hartid < first_hartid) || first_hartid == -1U) - return SBI_ENODEV; - - *out_first_hartid = first_hartid; - count = last_hartid - first_hartid + 1; - if (*out_hart_count < count) - *out_hart_count = count; + if ((last_hartid >= first_hartid) && first_hartid != -1U) { + *out_first_hartid = first_hartid; + count = last_hartid - first_hartid + 1; + *out_hart_count = (hart_count < count) ? hart_count : count; + } return 0; } diff --git a/lib/utils/ipi/fdt_ipi_mswi.c b/lib/utils/ipi/fdt_ipi_mswi.c index f119f9c..1f0fda7 100644 --- a/lib/utils/ipi/fdt_ipi_mswi.c +++ b/lib/utils/ipi/fdt_ipi_mswi.c @@ -28,7 +28,8 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff, return SBI_ENOSPC; ms = &mswi[mswi_count]; - rc = fdt_parse_aclint_node(fdt, nodeoff, false, &ms->addr, &ms->size, + rc = fdt_parse_aclint_node(fdt, nodeoff, false, + &ms->addr, &ms->size, NULL, NULL, &ms->first_hartid, &ms->hart_count); if (rc) return rc; diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index 3f830ad..b08ed38 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -22,7 +22,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - unsigned long offset, addr, size; + unsigned long offset, addr[2], size[2]; struct aclint_mtimer_data *mt, *mtmaster = NULL; if (MTIMER_MAX_NR <= mtimer_count) @@ -31,18 +31,19 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, if (0 < mtimer_count) mtmaster = &mtimer[0]; - rc = fdt_parse_aclint_node(fdt, nodeoff, true, &addr, &size, + rc = fdt_parse_aclint_node(fdt, nodeoff, true, + &addr[0], &size[0], &addr[1], &size[1], &mt->first_hartid, &mt->hart_count); if (rc) return rc; mt->has_64bit_mmio = true; - mt->mtimecmp_addr = addr + ACLINT_DEFAULT_MTIMECMP_OFFSET; - mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE; - mt->mtime_addr = addr + ACLINT_DEFAULT_MTIME_OFFSET; - mt->mtime_size = size - mt->mtimecmp_size; - - if (match->data) { + if (match->data) { /* SiFive CLINT */ + /* Set CLINT addresses */ + mt->mtimecmp_addr = addr[0] + ACLINT_DEFAULT_MTIMECMP_OFFSET; + mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE; + mt->mtime_addr = addr[0] + ACLINT_DEFAULT_MTIME_OFFSET; + mt->mtime_size = size[0] - mt->mtimecmp_size; /* Adjust MTIMER address and size for CLINT device */ offset = *((unsigned long *)match->data); mt->mtime_addr += offset; @@ -51,6 +52,12 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, /* Parse additional CLINT properties */ if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) mt->has_64bit_mmio = false; + } else { /* RISC-V ACLINT MTIMER */ + /* Set ACLINT MTIMER addresses */ + mt->mtime_addr = addr[0]; + mt->mtime_size = size[0]; + mt->mtimecmp_addr = addr[1]; + mt->mtimecmp_size = size[1]; } rc = aclint_mtimer_cold_init(mt, mtmaster); From patchwork Sat Jul 24 12:25:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1509486 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=2607:7c80:54:e::133; helo=bombadil.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=bombadil.20210309 header.b=YHU+Vik8; 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=Z1cngFl8; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=RuaPXtoW; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4GX54j5Kthz9t0G for ; Sat, 24 Jul 2021 22:25:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Uq+6+72W6jB9o5tG8Ts78H88R/rz3lGMZ53K4j8iyUU=; b=YHU+Vik89vs1Em XgxcGiG3MW27Yu+wnUM0cRp5InsTZqtIEgkTtchfGUzzHnWtPygXLlQ8g2pxRv7g6vj1dx/GLsOqS n0boAiA1FeyI5hWMK1FRwML0bgPLy6z6XqjNAq/woMs+lMmvekbQAygePc79vFqu1a+x/XlDc3kVt GTH2sutd6HV8OOgljnnVkhbwfzqHw5e7/+Ms8h8TVMlLfyTviTRIBbfarWe4/Nyvu3BWC9EUG2vix vY4zjPZu8gvQaOh2HvzVSt+Ca+msApfcaZSGK6SeDVObVF25+cMsgN5XcQW95xo5Ff02YOduEz67t Dt5dNFIcpAqSY0F2Kq8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gin-007AZK-Bq; Sat, 24 Jul 2021 12:25:37 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gik-007AY3-U7 for opensbi@lists.infradead.org; Sat, 24 Jul 2021 12:25:36 +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=1627129533; x=1658665533; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=SJlnXD2Zbw6c88kse0xgCtGlkRZWxXHZWRCQLh9TvOE=; b=Z1cngFl8RO4kvMN7AGZwQEE5m75/2Daw5qUbu+zM8/Pq+R5S7vGbzF1P QRR4xkM+Dy2zB8RmyNMrLV9fL910ChkE9uKxz2QSVc3HkoUZsRKC8VMYj J8j5NnBMiMp6qle8VSZbQuVTqQxUGqUrjMxd5lMQJZSiOwWA6xHnGvyV1 S5hNXhPKxvzFOfPLkrc6hcRrpPrOr6xzHidGqX2eGPfq4RWMpcY+vYoD6 mdvjCsoR+Zdh6wI3sSwIWRS+4W9OCFyShN0BZX1L7r7QxJTZh/n7mCdOk p713hfkP2vpVuMxBnL5x8PPcEo/arE5Ab5B/aZZdSOB8atFdQ8RndHcCQ Q==; X-IronPort-AV: E=Sophos;i="5.84,266,1620662400"; d="scan'208";a="175402048" Received: from mail-dm6nam08lp2042.outbound.protection.outlook.com (HELO NAM04-DM6-obe.outbound.protection.outlook.com) ([104.47.73.42]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2021 20:25:31 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=llHqUl0I7exVzyqcvC/Eo7KwS0dWgWcMWko1OtG9dObh2af5iEZv9CshF+Lg+aaEvnqkPivavc4rsuMAgChY9i6liDyXSaL3dBfztJhSOKpmeeRECNLqJW67u45RlwPOtfNC2E+MW6Ug0CF1KykJfKVHOqw2cLBNR9/H1UmHTsl4elqeV5DA0IIUeIlVF+o38b6NsqcgmsPQUmct1PFVg9s1W6iq6EVVrKHGmq+SbPj7GQ1cPwrTMDVQgOWiMVoLbnAd1OYdj4+bmSwk8JN3frGiLs94jPvtfuF3L/3zPrsrKadazo7ghSPMysgoYyb7UrddQmMYYmzkETaJAXM7Lg== 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=bDzPVfv6jltn1Joa6v7RxmBBHFUaohVvq0ifx82T4Xc=; b=EwZK+Q0LLe9oPhQDemAOgfXZlggoEn8I66VIf+pMn1qC1tjUjsJo+yeR8v0/hCgcc5dx+oUraojuwGMDq76BufdxE09GstfGEBJ6CPCIMYvGY0AuF4ob3jUjZW1Q0zYyE1nC41w18rrbZ1oliJbEdugjOi7jDVgaltwdz+WVEvTHbXggdAs2PBIT+ERSnp8BtG7Z4PZGa/KIgaIj0Gcu4weI+LhRyJM8vHJ0nPMSorxAzuPJSWW2pSjsGvlPCvLVpwlem4sg92ZmS3dEWsVp8CYiE0BgUYdiDhJ3bJysbQPE7xDzrKaruhl0p2nui1MoLZwvSwuhh+REbMUTyqpCdw== 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=bDzPVfv6jltn1Joa6v7RxmBBHFUaohVvq0ifx82T4Xc=; b=RuaPXtoWY2rNPmc8qIRS1+TbiuB3JFy7NhFdMWX0fkO6yOBvAVQcxaqkT2maRlY7mlrYlVHJ4Q/R9BlU73dU7lIxv1jS1VnrOdt36n9o35wZmoc9qGQyTBcqCZqzlrFDOJpESY9RpogDeqZgicHnn9kzKtUsCsOohOtzVfsW8vo= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7764.namprd04.prod.outlook.com (2603:10b6:303:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Sat, 24 Jul 2021 12:25:32 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%8]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 12:25:32 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 4/5] lib: utils/timer: Allow ACLINT MTIMER supporting only 32-bit MMIO Date: Sat, 24 Jul 2021 17:55:02 +0530 Message-Id: <20210724122503.2486624-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724122503.2486624-1-anup.patel@wdc.com> References: <20210724122503.2486624-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.179.61.225) by MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Sat, 24 Jul 2021 12:25:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c737fa4-aff7-48fb-2ee0-08d94e9e2129 X-MS-TrafficTypeDiagnostic: CO6PR04MB7764: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:765; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LUjTW+m/4K+IxkvIBmDuCK8x2/NdQf9ZpRNXRa9trH4ogE3luQO6tjDHcygXdz8YobRUVs7pQ9HX0PdWZsHOrNCbB2kuheL/7m/rxZLD0JIkKAnMygwSyIMHzflp8Z8g9H68YxM7wER4DCYYDQxBZ/yP5DbRkGmUO7F0qtLN5Q73SfMRcWGhUILRmD0ZosvBsaeJh2g8qZkiPe5iZm8GXet7wZ6/+fOhmqRzlk06RThiMpF4WYilERAm2ZSJz7eX7Se9+gNpLKEn9wUDSP7RvtULqX68cBjpn/zGmiyVV5YmBnRmX9k86uNdzfjGDQJIwrY4STlyU3wFGfO4c8qWgpfWA9y5jjaoCrrwq4XJs3jKsVzPqPejkcHeaASaDQx8o83WvK6gJaG12JVCHfzePgb1SN7K1hYnbAeakV/WLH/DL0aIF1HhNZl+2tgs8V7tOcbLbU72p/AQir8ZgM24bGp4QdqEUx+Sx3NFkPrSMWjvRvV2Kax0JCBMuOaOLHlxrvc21BhoM8H+V01iz7pyuY/CR0FvytP5hyM0KP8J9T9i3tjD7lJ4x1u4bCM/I5wLSwX7eWE7554i8kAnttKS32z/omihzrU2slSIJaRKACpHkpJh9HOdbClpXcwHyYPiIWw0RrYgFPm8FPmzGSehewqctLGtzCE6bz1RWVySanc8MvrDGSndaUoXgBvJIp40k1CQgfLnwaCnCSM+chOaOw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(956004)(44832011)(2616005)(38350700002)(36756003)(1076003)(8676002)(38100700002)(4326008)(508600001)(5660300002)(55016002)(110136005)(8936002)(66476007)(66556008)(66946007)(316002)(6636002)(8886007)(6666004)(54906003)(52116002)(7696005)(83380400001)(86362001)(2906002)(26005)(186003)(4744005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dlG296oHtDzSuIKbYoMVpJFj+YLfuk1+M/mAL3+8G4a6ZWGhbfBS/OmC0ThM75OIJTZCkpESzQ7CdVhbmlMRG6LTM2XIO2UFlzO/ReFomQCDHehMmHNMnGOAOijXIMZgvwyTgiVAqmCj4wLApK0EHCCY5QNxpqtMAfr2VVnH6vRU4iTkBBcvfqufFK8LTDB4lV5ARQI9CTZeENcs0ShLPqlwX94zGLHViKcPytXs8fh57hcsveMWh6qNvDBF3QZSDO1Y2+S4xn82+nkL3FSsW8DoxejixTuWbeYmEo7qDARWV6+hkNE311lrb7Gt9CqC8i5yDipScscyFnI6KvPx559mukDf+q25+7c9+8FFGdtqquRBdfCZ/L34WMMTXc18uquc+cgcOH+salALXsKBBTHvFQtyiBjTMr5XUL1WijQZE5plbW2u6vMD6o/TGdBng7d8Of0ZfpMvF0agl/DSo/p3UESpWSHNMJZCKtHYbfpHPs4kDI5vHxaiQ2m8Gj1uuqe8AiJSd4L1ssITD4+74iJfDo8VMNGTE8deRdZ9ca9nlMG0075R3M58y9xqJC8Ng5QOLthOG+4NUYAROarGWLFznnzOJlJlavDuzo2WkxJtyT4dvsYDlxus8YuLxf2Wx7LwM8PNldDboBmnkPgVasxQM0j9zqKnukLrwpEWHwhj+OWf44ENuwHw1/bLmvODwEiM6z1mjbiTzYFiALQM2HXkVG9tlXstHFOVCScJpTpOV1fcwy0Pla9WCuZ+5Zf6s3CbdpyYZoKhJ+Z7+b53rDgWxWZwtfd/ZzzoO0+y3Kpb3x/t75wfLH1UKVdaG70APzJJFXhHYyDUACuUDQALXuRTO4EN74ZhITQFtp3vW43CQDBxdKQRIQXi8Qmske044WkvQ8EtQqhT/LwQpHTzycAu+dgibJMukzx3itjbPyrSqlyY7V11lxWQZgbF/lgcHHRPzmUla5qZemY77PTzWNy0AW+KWpt/RtSQyWcRVeO2PJch0omlAr4fY36N9YpJnMTxJVbOP1f5y+rZPbnXXFn0GQDiuwoa3JwBaGhzLSk/0C37PgexZm0xCoKucl0deA7NfGHGtFX+upgxR2fIb5RR31UOPFZOt3/MDRmSg2JcW773sfZuZeruIfBEWC4QIvfh5/pOqTe3a3GvsMONIZ8/N9L9TYsKr6CMw18sYoylg/oUgns9MN2WlYA/I1ZiP/CzPrRMMxm/RrDFCKdf1ZDXd4tev/O14QIORAOVNaqo97v4Y8Fpr3Zf57OPOLyWzDaolbxNZU7O/iwYrVBe5AWxqVXR+BK/s/VXaf3+tEEqhSczootRRhFok5dwK1Af X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c737fa4-aff7-48fb-2ee0-08d94e9e2129 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 12:25:32.1237 (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: bPPPsXQATVKsB+6pbH2AnCZ6qMQ4YX7x6KWRxP+k80k1w3zNWgTtB82Kxggrpq4HdZ7wyMO6Vsdok2y2CvTFWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7764 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210724_052535_061303_8DD96BD2 X-CRM114-Status: GOOD ( 10.71 ) 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 can have ACLINT MTIMER devices which only support 32-bit MMIO accesses on RV64 system so this patch adds a boolean DT property "mtimer, no-64bit-mmio" to detect this from MTIMER DT node. Signed-off-by: Anup Patel --- lib/utils/timer/fdt_timer_mtimer.c | 3 +++ 1 file changed, 3 insertions(+) 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.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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 can have ACLINT MTIMER devices which only support 32-bit MMIO accesses on RV64 system so this patch adds a boolean DT property "mtimer,no-64bit-mmio" to detect this from MTIMER DT node. Signed-off-by: Anup Patel --- lib/utils/timer/fdt_timer_mtimer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index b08ed38..15a36ed 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -58,6 +58,9 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, mt->mtime_size = size[0]; mt->mtimecmp_addr = addr[1]; mt->mtimecmp_size = size[1]; + /* Parse additional ACLINT MTIMER properties */ + if (fdt_getprop(fdt, nodeoff, "mtimer,no-64bit-mmio", &rc)) + mt->has_64bit_mmio = false; } rc = aclint_mtimer_cold_init(mt, mtmaster); From patchwork Sat Jul 24 12:25:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1509487 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=2607:7c80:54:e::133; helo=bombadil.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=bombadil.20210309 header.b=jYx3yyD0; 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=VmJ9L/SZ; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=kvhx2WUL; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4GX54l1jfsz9t0p for ; Sat, 24 Jul 2021 22:25:43 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lYUtKx2pWjHicJFIfQ5UO5q6ZIRyMVVioCm7gpTdH4I=; b=jYx3yyD0UfEDsR KpkitoZSGyc44O6s8T/9aKSYMlodmVtIA+1Odoul/TNNOzWQdc+V14kn9FEejy3C4u/TW3Gl+wOfh Ghinz+czSIvORD4gVyV5ISJ2Emv8+rq+GU/K4RmWXbAZ3Xmq4alH8QFiRcWp6IhIDx15s8ApnIFtl Tqmg3c9nBEWtrBd54bZBwgTrwTlZ4Q1H/PAyCcAkDoc4kPp9aKqC9Wh1p+nAZ4oxD7VaioaMute/I 4U5GcGgTe1WpCeOqM+hH9DC1xZ8ENmRU437AUr7eJxVCHA0LC+/p/a/4lMTQkyBL/pKxzDnubzhny A76vdyYgiP/KOTIY3kDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gio-007Aa3-Tm; Sat, 24 Jul 2021 12:25:38 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7Gil-007AYe-Nx for opensbi@lists.infradead.org; Sat, 24 Jul 2021 12:25:37 +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=1627129534; x=1658665534; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/C9ASrzHzJzj89ka2SC0AMltHEF1XKybmKLkJWe7aSE=; b=VmJ9L/SZPmGJaFlxejOKTmLBsXlevMAfxp6WOXUQAN6gUfpjJkz+ri+e n4o4VxlaS46D112iKZXLuAs8ee5rgQsf+jzjh2h6FitxrQIfa99b1cCED WVFVmx5qn4zaN30IvSlZ5ZpH8qLUcarUy9XkYrGNtWYIvE/ma54IDFdCS GFkIk7gIHNicf3ZZH8LqJItdfFxA0zvKcZl9dk47SfqZF7lRnAPeXQAg3 bd7AiY4hrviekzYd/+JfWcjwIzJbYBOczHGTuR1aL8lZW+GpoDIHc6z90 rzb3feXfvxakBJjbxBD6SpZJpCw2b4x47xhzQgw5BxY0fok3nkNBD5huz Q==; X-IronPort-AV: E=Sophos;i="5.84,266,1620662400"; d="scan'208";a="175402052" Received: from mail-dm6nam08lp2040.outbound.protection.outlook.com (HELO NAM04-DM6-obe.outbound.protection.outlook.com) ([104.47.73.40]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2021 20:25:33 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gt1ZzvuQ4I1IV9TRLG3Snksy1GLvC0QbnlNbTq0qaoRIO8RfdPvQSEV5BrVqwzvIgKVWIM2Oysw+LX8fjqFlkEvTvegfOPmtpVgIQi61y3tMGZ0QfEi/1RctKOimXVMOoxgTuwg23mmmp9rcNByxNrJj27KNdNIDXsqZdG+evjii0MhRVceTVgCdahFP23HvQltNcjpnVC1ZrfgRjTd7VZs9N4jhdY5PJQy//r/VHlNIXk0/CzlTZM99bvo/1X9VE1aWJSJVxZ+hXtCVXuZHSkswzQsn3qNGWZvwz1PnQVF4PjO7hlQUI33gS+3kbLgfYXp7jda0YB4kiud/MyWjgg== 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=9ufXmMWwQLky0/BD+WgH/0EdOU0ouj/q6iQoXNScXVg=; b=DIOWLmQc/7vaM1V7GWYIk6r7Hb3HgMezSnwBdpJSoMze7k5I82xlXg3S/Mw381nWLCxuVHR1ORytfa+Ilp5cJsIQEDbAJErmQdgrvTc2goegL26GDZ9ciXgpEMkjuhhZO+IcNthB0Tb207gnS8z2tRAj9MZkGDrNKhKu3YsnQ9YIrHZ16fjwD1PxL1wtq8x+2NBgTLm8JEIkiuPB+qkUtwyGAr78DKOrQJD947FMejUI5kxvcHxZQSFlA0jPQouLwO+/eRVY2ieBkPPIoEA8Fz6mUsy4l7/eOyW2jmLl8TBEKdr4jvRNxoEBFJ5hYBeXXUz0P1dzpyyJ7W0lh3SUaQ== 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=9ufXmMWwQLky0/BD+WgH/0EdOU0ouj/q6iQoXNScXVg=; b=kvhx2WULt1iG04OY1OWy+D9rpZvtjf0FLYwtFs+jWfdGpZJxJlnMXUM4aSDLTmpjMCFkAMi2NPJceFBNbVHQSquRXnOABVfDggpe9YeQEkrLbC0Ps3bSNtkz1aiS35kH2+Fn4PxHhpoQtif3Yw2+ioxTwZyauoMzqFZJA8rp2C0= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7764.namprd04.prod.outlook.com (2603:10b6:303:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Sat, 24 Jul 2021 12:25:34 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%8]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 12:25:34 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 5/5] lib: utils/timer: Simplify MTIMER synchronization Date: Sat, 24 Jul 2021 17:55:03 +0530 Message-Id: <20210724122503.2486624-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724122503.2486624-1-anup.patel@wdc.com> References: <20210724122503.2486624-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.179.61.225) by MAXPR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Sat, 24 Jul 2021 12:25:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e6dde49-99b6-4a82-529c-08d94e9e2278 X-MS-TrafficTypeDiagnostic: CO6PR04MB7764: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wikYVufN+dE9p36jR9MEYpSI8U3aIVVHO2D+a/KkSfIfubUmgIbliKUz6A2g87OMgAbtcn1Y8sgvA/wW/iuLP0xV7MI6Qi5qGUDR1YpjN4iMzChv0gnuCaKRDLoXRB94Tl73WzD0oEC8cUaN7GS8IhHgtVpRy1zRXpMvYIch6kgWLt5SdXVyRU+rzJ61Y1xE5CC2AXqHgiMp6MC6EFOLb+qBh4h6UnlHo32rLv8CI6P++pUz7sdaV1amVpXW8ChLx1AbRdhZNNc3aiEI2qoNyKH9kMonHZ2uCYxHGSQWPXE/5/2HgaSoysvULywNn6k3/JLmBaT9WHgUfEoClhPlNkbEm0Iwy0/opo+Xm4QPqSW6aL1M6BT5dkRH/nXtejrLxmMIc7avdY3BAS30VIqz09iZUnbZV0ODuUT1uZ8aAUbmLazHZ8IaHsYby16ZZ88HyOIupgXvHfjBva/H2RJQRHGG1/5LMOkcWet10lY0NT5Ce2ZTk6/E/1QmfwLUrRMIeVkr3XB9hDoauWcyFslaPshlKuNtdOdKnRjrk6FHmI+3+5zbnOs7sQQaWx+av78gnsVGqz40hQOF8aV2kTYezSewFpk+zbMXHiaOCRtVz8nmePRiWe5QDo+B4HkY5XedaKpSFsFV6URKeUuu3tP0u6oMvHq5G5z95PP2fD1Ts0MiRBXK4JosS6wDUfx1UyP0+gPOvpQkAsBUFyfWW0M0UA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(956004)(44832011)(2616005)(38350700002)(36756003)(1076003)(8676002)(38100700002)(4326008)(508600001)(5660300002)(55016002)(110136005)(8936002)(66476007)(66556008)(66946007)(316002)(6636002)(8886007)(6666004)(54906003)(52116002)(7696005)(83380400001)(86362001)(2906002)(26005)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lKTycBAicYjA0fwKD98WwEAGVdrA2IgVnHZDmF4SKd4Zmmnja+buHBf11YlaehCqSUSqCYvtCmJi6/tFYdzPuaIk3qyfVpA39/jvcxJlyuyUdGS5tID02yELuPt4sZW3BEUqHGVfjuv9V0R93GgjkQRn6pHDikQfJAUYrEjXjzwSdRIKZSolTIFTzinLpQR799OYd+6afWtOO7NojGiUFTK6bp+JMdYIU3aIXoEqUqM1DBtjrOXPotfgpDiSdztqEMLeOrzrE0189iD80VItAH+Tvua55G+nrAbuvwJtSzJsEwalj0j21Rg4JYBruUP6Ni9S5qe2B3pd6N6lgoPFhxaYg216Eq1h+uZjoNC07L1pJ/OmXftlTP7F0ZtjQZmr09dW+9MWV2zT38URqWGGzr0oWi1ydjgSS9t4VxUfvTAfuJIOJ3bFEdh6BBCadbxqlv9MXf4nTS74y1U8N6uib6c4gpcwYAWQyHlkq53W2I5nCFvSC0OSJgmXDF7JyqafcvddW4zEOWF0Whu9jJX0w1RaI8qyBOSDMr3fIQZQVDum1UNaEV3AcdXkoKxvOpVYz2LwFyN8bPlMaS7YEzcuJwZU/4Pw1ot4GZnydvXtjHdKvPcC27rz6Qa580+LvRhh3e8mp5EUlMtu3sIZF4FZpQSR4xtAZ0CpJc7aIat834cv8Wa1neOS9OFCyK3XAAq9YFMQUulzvod5ldC2TBFvzYow8w4vRKyjAfM9E9KygeQ9wXYDNq2W7xEsxinvQJWg/Mkifbedu/DXHXmqJiRec58HR3glvitOFUevpLcsNQMyyAlXX0PqomkhF9Pu8qfbkavUQbs42g1/8iUC54S3iPTNr8gyr1ArDtI/I14IQpKUKlt2Jg3dQp4SrOcq/s7gms4ZUGSe5IbZCymup5RjMZcu96qoP2PNtOfycQN0GQTDcKH5/J1/fafVx32yVlob2MDr/9+z3K2Nyt0SxY0sWngDEAKUO6g34dGKXwSG118GkM9Ayz8naw9dkEQyJ3jIWjPm7/MzcweBSQL8bsnD9IJrvLGhJptk88ZSsWV2h+HnBE/kV672gVAQHtX/5WsBgao31wyRtcX7oX2Tz5JhTZy6YEEaRKdt66nA91VoaqkUXlaSfEmNwUsQ5SDVX7ATqP00yWu6qCnN3KlHkjmEPZeKik2lbjHGEFBRwJm1wCaxPEILW9YlE7e1drw+G0kav2lX+wpAZXxH5sThfEQmN0EGT7BrYMHdr9BGaNRAXGgSB7o6YLg+63z6waEOgPApHkdBH0L8j5R9xpME3MznYH1KDstBpv3/jHu5aaaMegZ/YwLPuy+6Cs9JXdUpCorT X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e6dde49-99b6-4a82-529c-08d94e9e2278 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 12:25:34.1348 (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: gUsF8d6bwrp28dxgnNgzZ2qMjVzOp1vAwHDos8ijIjOwoeJcGQNeIJo+QVjGt+OPjt1JrAxHMoHYVQQM2ZE+5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7764 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210724_052535_835055_BC22C8A1 X-CRM114-Status: GOOD ( 22.03 ) 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 simplify MTIMER synchronization as follows: 1) Detect MTIMER devices with unique (or non-shared) MTIME register at boot-time 2) Select first MTIMER device with no associated HART as our reference MTIMER device 3) Only synchronize MTIMER devices [...] 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.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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 simplify MTIMER synchronization as follows: 1) Detect MTIMER devices with unique (or non-shared) MTIME register at boot-time 2) Select first MTIMER device with no associated HART as our reference MTIMER device 3) Only synchronize MTIMER devices with unique (or non-shared) MTIME register using reference MTIMER device 4) Directly update the MTIME register at time of synchronization because MTIME is a read/write register. Signed-off-by: Anup Patel --- include/sbi_utils/timer/aclint_mtimer.h | 7 ++- lib/utils/timer/aclint_mtimer.c | 67 +++++++++++++++---------- lib/utils/timer/fdt_timer_mtimer.c | 39 ++++++++++++-- 3 files changed, 80 insertions(+), 33 deletions(-) diff --git a/include/sbi_utils/timer/aclint_mtimer.h b/include/sbi_utils/timer/aclint_mtimer.h index 54eb238..5416ecc 100644 --- a/include/sbi_utils/timer/aclint_mtimer.h +++ b/include/sbi_utils/timer/aclint_mtimer.h @@ -34,14 +34,19 @@ struct aclint_mtimer_data { u32 first_hartid; u32 hart_count; bool has_64bit_mmio; + bool has_shared_mtime; /* Private details (initialized and used by ACLINT MTIMER library) */ struct aclint_mtimer_data *time_delta_reference; unsigned long time_delta_computed; - u64 time_delta; u64 (*time_rd)(volatile u64 *addr); void (*time_wr)(bool timecmp, u64 value, volatile u64 *addr); }; +void aclint_mtimer_sync(struct aclint_mtimer_data *mt); + +void aclint_mtimer_set_reference(struct aclint_mtimer_data *mt, + struct aclint_mtimer_data *ref); + int aclint_mtimer_warm_init(void); int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c index ebc9300..a6a8df0 100644 --- a/lib/utils/timer/aclint_mtimer.c +++ b/lib/utils/timer/aclint_mtimer.c @@ -57,7 +57,7 @@ static u64 mtimer_value(void) u64 *time_val = (void *)mt->mtime_addr; /* Read MTIMER Time Value */ - return mt->time_rd(time_val) + mt->time_delta; + return mt->time_rd(time_val); } static void mtimer_event_stop(void) @@ -77,7 +77,7 @@ static void mtimer_event_start(u64 next_event) u64 *time_cmp = (void *)mt->mtimecmp_addr; /* Program MTIMER Time Compare */ - mt->time_wr(true, next_event - mt->time_delta, + mt->time_wr(true, next_event, &time_cmp[target_hart - mt->first_hartid]); } @@ -88,36 +88,51 @@ static struct sbi_timer_device mtimer = { .timer_event_stop = mtimer_event_stop }; +void aclint_mtimer_sync(struct aclint_mtimer_data *mt) +{ + u64 v1, v2, mv, delta; + u64 *mt_time_val, *ref_time_val; + struct aclint_mtimer_data *reference; + + /* Sync-up non-shared MTIME if reference is available */ + if (mt->has_shared_mtime || !mt->time_delta_reference) + return; + + reference = mt->time_delta_reference; + mt_time_val = (void *)mt->mtime_addr; + ref_time_val = (void *)reference->mtime_addr; + if (!atomic_raw_xchg_ulong(&mt->time_delta_computed, 1)) { + v1 = mt->time_rd(mt_time_val); + mv = reference->time_rd(ref_time_val); + v2 = mt->time_rd(mt_time_val); + delta = mv - ((v1 / 2) + (v2 / 2)); + mt->time_wr(false, mt->time_rd(mt_time_val) + delta, + mt_time_val); + } + +} + +void aclint_mtimer_set_reference(struct aclint_mtimer_data *mt, + struct aclint_mtimer_data *ref) +{ + if (!mt || !ref || mt == ref) + return; + + mt->time_delta_reference = ref; + mt->time_delta_computed = 0; +} + int aclint_mtimer_warm_init(void) { - u64 v1, v2, mv; + u64 *mt_time_cmp; u32 target_hart = current_hartid(); - struct aclint_mtimer_data *reference; - u64 *mt_time_val, *mt_time_cmp, *ref_time_val; struct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart]; if (!mt) return SBI_ENODEV; - /* - * Compute delta if reference available - * - * We deliberately compute time_delta in warm init so that time_delta - * is computed on a HART which is going to use given MTIMER. We use - * atomic flag timer_delta_computed to ensure that only one HART does - * time_delta computation. - */ - if (mt->time_delta_reference) { - reference = mt->time_delta_reference; - mt_time_val = (void *)mt->mtime_addr; - ref_time_val = (void *)reference->mtime_addr; - if (!atomic_raw_xchg_ulong(&mt->time_delta_computed, 1)) { - v1 = mt->time_rd(mt_time_val); - mv = reference->time_rd(ref_time_val); - v2 = mt->time_rd(mt_time_val); - mt->time_delta = mv - ((v1 / 2) + (v2 / 2)); - } - } + /* Sync-up MTIME register */ + aclint_mtimer_sync(mt); /* Clear Time Compare */ mt_time_cmp = (void *)mt->mtimecmp_addr; @@ -172,9 +187,7 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, return SBI_EINVAL; /* Initialize private data */ - mt->time_delta_reference = reference; - mt->time_delta_computed = 0; - mt->time_delta = 0; + aclint_mtimer_set_reference(mt, reference); mt->time_rd = mtimer_time_rd32; mt->time_wr = mtimer_time_wr32; diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index 15a36ed..26b5a2a 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -17,19 +17,18 @@ static unsigned long mtimer_count = 0; static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR]; +static struct aclint_mtimer_data *mt_reference = NULL; static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) { - int rc; + int i, rc; unsigned long offset, addr[2], size[2]; - struct aclint_mtimer_data *mt, *mtmaster = NULL; + struct aclint_mtimer_data *mt; if (MTIMER_MAX_NR <= mtimer_count) return SBI_ENOSPC; mt = &mtimer[mtimer_count]; - if (0 < mtimer_count) - mtmaster = &mtimer[0]; rc = fdt_parse_aclint_node(fdt, nodeoff, true, &addr[0], &size[0], &addr[1], &size[1], @@ -37,6 +36,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, if (rc) return rc; mt->has_64bit_mmio = true; + mt->has_shared_mtime = false; if (match->data) { /* SiFive CLINT */ /* Set CLINT addresses */ @@ -63,10 +63,39 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, mt->has_64bit_mmio = false; } - rc = aclint_mtimer_cold_init(mt, mtmaster); + /* Check if MTIMER device has shared MTIME address */ + mt->has_shared_mtime = false; + for (i = 0; i < mtimer_count; i++) { + if (mtimer[i].mtime_addr == mt->mtime_addr) { + mt->has_shared_mtime = true; + break; + } + } + + /* Initialize the MTIMER device */ + rc = aclint_mtimer_cold_init(mt, mt_reference); if (rc) return rc; + /* + * Select first MTIMER device with no associated HARTs as + * our reference MTIMER device + */ + if (!mt->hart_count && !mt_reference) { + mt_reference = mt; + /* + * Set reference for already propbed MTIMER devices + * with non-shared MTIME + */ + for (i = 0; i < mtimer_count; i++) + if (!mtimer[i].has_shared_mtime) + aclint_mtimer_set_reference(&mtimer[i], mt); + } + + /* Explicitly sync-up MTIMER devices not associated with any HARTs */ + if (!mt->hart_count) + aclint_mtimer_sync(mt); + mtimer_count++; return 0; }