From patchwork Mon Aug 30 04:17:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12464519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AB39C4320E for ; Mon, 30 Aug 2021 04:18:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8CCD60F5C for ; Mon, 30 Aug 2021 04:18:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B8CCD60F5C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=zvCPbX9d1s/XosSp46+zbQxOdVgSIsrtzCX3Pz7YWiA=; b=OgCLpClKplCUBY qFoD0IDJzR9993QkDqLxV6Jev7h4LklbBOS9jtXoJG9Lfyrt0ks0s1MHWajJGg2qgUl6SEsKLMypf Rw+DWIO0/wsysex250rJBBLTnEAdUPp4ivxItJWmm/fTuZZAKNSKzPhaHhh8hT3lO3240uNhF3CrK eDRt1QJHWGvVJgnQmalhiFjzOYMuygrt2MDmAC8dIDj85mSiP/nFw7J8sRwy0IrE7A2tenb0KGA6r YAeR20M0sZNs/ptYdSSpJzseYmTCxFULgJWfyQS5kLG20iC50U/KJ5v0JkbqdUDFgokfglB1pH322 GKeU6YkbAA1n3D6XbIgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKYkP-00GOO5-5I; Mon, 30 Aug 2021 04:18:13 +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 1mKYk9-00GOMp-Rl for linux-riscv@lists.infradead.org; Mon, 30 Aug 2021 04:18:01 +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=1630297077; x=1661833077; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=rnbMD9CLPfahBUqf7I1nJpQUplEY6+bh467medZmRJA=; b=le+qK75oQD7YMUGw8yaFnCZruOPPbwJyyoCwKId+C5tAlL8ip7yBJdtX gyp4H2fZ/XdM61rWaPmOd3CLlfzMVSDgtbDmiySSzzVlnqT1+oyR7d6Ip hLijiYX0LqKaSd+zg4C2FIBqFhlnXNp3lyvZRE4nb3RDKLpPzSW+WL+b1 2ur1ejaimv7dfvVvCl4mctofmvbSI1NcHMZGi1NvrtENXhYPXL5TxiXoo 2xMWtx9higb8qwRA8XosGI7Qs2J7NzT0OV5afbasm4ABHXQa39VR5KLuY on65MZVT66H7G9SLN2LNI8hn5cZ1uol3X1SMLHLV0nFMrteE+8xIxtyED Q==; X-IronPort-AV: E=Sophos;i="5.84,362,1620662400"; d="scan'208";a="290332129" Received: from mail-mw2nam08lp2168.outbound.protection.outlook.com (HELO NAM04-MW2-obe.outbound.protection.outlook.com) ([104.47.73.168]) by ob1.hgst.iphmx.com with ESMTP; 30 Aug 2021 12:17:54 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cusflI3oxiklEHaDKzDMpehOPzr6yY24Lvg3IgVFentobD9ZxUuBnTNW5DxersbmV65xsCt5pvPeSXbqaZk+r8U/MoII+1lZ1FvTA7uqix3SVbZHp0qUwD9ItkG7W/D82G6K1Y6mR5C31vUMSg4eW9KqlcKyJ3In7E+KhJGW8hSHW0HdKrYdu0seRkdNR/kPIZD/ikIc9DazcPLiMppMv0ZLc7Dx0ddFYZsJ2UCqBJH+naMXtx8OaFBNRqaDFCMd2PahAEZXQw+52ew8jrZamM+9Y8EzQ9VX5se0kCGyL9ItB2DIKCY690aZN0IL7jQVyvIb+sYhjAM5izxM363ySw== 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=M0Mu6IBC7/mpjfLqlPuysyhHKQvovegDoci+AKpF8h4=; b=gfwJsJ/5wr6dQxkM49TWWwkcRaNLmTZzi5zxr6nuNo/oFxqZsHDDih6ix5N8Z+FbdgTxxKpskDQ3Peaab9UHen7R7fHTUuR5nZm9toSGl92ScRTFZo1/l0HEDiO1QfQyuMALZ/REyRSwUnQtKXVPY61XDLCjR88AlmXb6C4t69VpW06CDi9wmp2FSjptNIEuujVtvcbP9VW7m+Qo5RpRpeNhXgQYKJtLFxPqw2+TcYlEydiE2fLFtY+WwH9G4u+DOXcB1W7vP8fm+n9Hn9UwOMhfQ9DMeWM4ylaWyQgeGbC0r3Frxa0SPMiu1uO+fVAk0trwLPZPGfCEdHNlseBcMw== 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=M0Mu6IBC7/mpjfLqlPuysyhHKQvovegDoci+AKpF8h4=; b=bJS+NHIaCUIajHspb9nZalW8PoMSuHAsI5zjnqPCTCBcowJ3Bk6wrdC+ioRveK/nioGIO/3tCxNkoiM0gizgCYTeBNmxel8HYR2IKBJ1IO8gaQxoZFeySZigWbl6VVjvqY7Rt5VqIUC/nKEURdAuIaJEJz/fRxBqTAdIJYA/nWI= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none;dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from SJ0PR04MB7821.namprd04.prod.outlook.com (2603:10b6:a03:3ac::8) by SJ0PR04MB7838.namprd04.prod.outlook.com (2603:10b6:a03:3ac::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.20; Mon, 30 Aug 2021 04:17:53 +0000 Received: from SJ0PR04MB7821.namprd04.prod.outlook.com ([fe80::545a:34f7:53c5:6514]) by SJ0PR04MB7821.namprd04.prod.outlook.com ([fe80::545a:34f7:53c5:6514%8]) with mapi id 15.20.4457.024; Mon, 30 Aug 2021 04:17:53 +0000 From: Anup Patel To: Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Daniel Lezcano , Rob Herring Cc: Atish Patra , Alistair Francis , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [RFC PATCH v3 00/11] Linux RISC-V ACLINT Support Date: Mon, 30 Aug 2021 09:47:18 +0530 Message-Id: <20210830041729.237252-1-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: MA1PR0101CA0002.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::12) To SJ0PR04MB7821.namprd04.prod.outlook.com (2603:10b6:a03:3ac::8) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.179.63.14) by MA1PR0101CA0002.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Mon, 30 Aug 2021 04:17:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4dcf21b-58cd-4131-5a89-08d96b6d22e4 X-MS-TrafficTypeDiagnostic: SJ0PR04MB7838: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZOaY74iX185WvLSPPYdiam9heANUL23augE1aDiG8K19Rbfuciv4hKqAfqiBnVZY3LZkZLMZ6Ym64uqFA1n6ZBaLEefYbDUMp+9ZpZCmVLbqBFDARjYiMPMSHCEHN/UXDSoGRnERyMfn03ZxqYVank/e1cVswGtCis+hY7/FziDV+JTYG2cYN++xBuxOqWLijvtg4M0e4A5zzTyy0InScxbr7rmUW22kOtqCH00CSbOzrMXL6jGpaC8J+aHtwPxpYcs5dPK/waF7rp0gqSaQDiZ5O8wZT6WpB5mxpFRjnoRr/b86LK6XbIDLXZK93UIhZepI/Mcxk05NWblpsjie+D3W7kh6M3eEiFBio+Js4MHZguZ9567rWH1fRSqh1zAqUJvgJUA6GHVXYM90XQd+4CnNGwoCevpS6vJ/QbBo2MTzHnFB3UDKOrr3hrOLTrrV4p/RBaeCsPxoCh0bIxw4DbZSzikJTJlLHsVGWddPfCBNrPkca8fX7OQnhNq+fxhij/7h3gGJlm34md6dWhYYw0RslHrSecF/DK/+dwnN/3laOYeHCIA7DHjamiN9Jjna6avnWHbpsM2ajs+D4fSgxBGtuVQgWrx6TA1W1fMAziK8+w72VjXWNr0UtdIiodYWYevJ5Wr0RR59Wf83ZpZHfYJvN4e/iLaRdi61JcV7tmTE14IWvOWIZMpD4z6MkVa8Q2tCmyr4MRvJEKpH+TYwJsswIbtqs8eMLl9dg0aaCPdoLhGMTohTHPtI61twms4M/77mjls2nlysEy164fd+q/dzGFCzQ7Zqf/rdFgdBxHk6aVthOqeQk5GMgItrSGfs X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR04MB7821.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(376002)(396003)(366004)(66946007)(8936002)(83380400001)(2906002)(966005)(86362001)(110136005)(4326008)(54906003)(186003)(36756003)(66476007)(8886007)(8676002)(7696005)(52116002)(66556008)(316002)(38350700002)(38100700002)(2616005)(55016002)(44832011)(956004)(1076003)(5660300002)(7416002)(478600001)(6666004)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qP8e3anrOf7Fshwo33R4UoP1XGNEoJ1eNMdRhqad5ngJpMi46sFODulNo/tPbcnYARGTUEVoot2gHC3HWHhdCIm3K4vRR3SfNEFup8cI41GDEGxtflKvVEqq7Ko6MsjpIOeVX6qyxLIVKgCXQg74XeaQTPxWo7BkJC8rB7ETX8WNJKZCJyVOID/m/XETbLK5/G9Wgc4Rf8PO6ibPIg9WhkaLuiNkPillsFMBibKC83xiOnDvaA98Bc59IO03P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rb3D4b42tA X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4dcf21b-58cd-4131-5a89-08d96b6d22e4 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR04MB7821.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2021 04:17:53.4815 (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: whMNTYkb517F/0/xxNCeFRD2bB+1tg6MNGj2Brp6bsabc2kxZPRpAR3BSxKLFY5IFlIN3dWElAJlX7gWaYD9Mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR04MB7838 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210829_211757_959346_0DAD19F3 X-CRM114-Status: GOOD ( 17.51 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Most of the existing RISC-V platforms use SiFive CLINT to provide M-level timer and IPI support whereas S-level uses SBI calls for timer and IPI support. Also, the SiFive CLINT device is a single device providing both timer and IPI functionality so RISC-V platforms can't partially implement SiFive CLINT device and provide alternate mechanism for timer and IPI. The RISC-V Advacned Core Local Interruptor (ACLINT) tries to address the limitations of SiFive CLINT by: 1) Taking modular approach and defining timer and IPI functionality as separate devices so that RISC-V platforms can include only required devices 2) Providing dedicated MMIO device for S-level IPIs so that SBI calls can be avoided for IPIs in Linux RISC-V 3) Allowing multiple instances of timer and IPI devices for a multi-socket (or multi-die) NUMA systems 4) Being backward compatible to SiFive CLINT so that existing RISC-V platforms stay compliant with RISC-V ACLINT specification Latest RISC-V ACLINT specification (to be frozen soon) can be found at: https://github.com/riscv/riscv-aclint/blob/main/riscv-aclint.adoc This series adds RISC-V ACLINT support and can be found in the riscv_aclint_v3 branch at: https://github.com/avpatel/linux To test this series, the RISC-V ACLINT support for QEMU can be found in the riscv_aclint_v3 branch at: https://github.com/avpatel/qemu Changes since v2: - Addresed Rob's comments on [M|S]SWI DT bindings - Dropped PATCH2 because it was not a required change - Addressed Marc's comments on ACLINT SWI driver added by PATCH7 - Added a separate PATCH6 to update SiFive CLINT DT bindings Changes since v1: - Added a new PATCH3 to treat IPIs as normal Linux IRQs for RISC-V kernel - New SBI IPI call based irqchip driver in PATCH3 which is only initialized by riscv_ipi_setup() when no Linux IRQ numbers are available for IPIs - Moved DT bindings patches before corresponding driver patches - Implemented ACLINT SWI driver as a irqchip driver in PATCH7 - Minor nit fixes pointed by Bin Meng Anup Patel (11): RISC-V: Clear SIP bit only when using SBI IPI operations RISC-V: Treat IPIs as normal Linux IRQs RISC-V: Allow marking IPIs as suitable for remote FENCEs RISC-V: Use IPIs for remote TLB flush when possible dt-bindings: interrupt-controller: Add ACLINT MSWI and SSWI bindings dt-bindings: timer: Update SiFive CLINT bindings for IPI support irqchip: Add ACLINT software interrupt driver RISC-V: Select ACLINT SWI driver for virt machine dt-bindings: timer: Add ACLINT MTIMER bindings clocksource: clint: Add support for ACLINT MTIMER device MAINTAINERS: Add entry for RISC-V ACLINT drivers .../riscv,aclint-swi.yaml | 95 +++++++ .../bindings/timer/riscv,aclint-mtimer.yaml | 70 +++++ .../bindings/timer/sifive,clint.yaml | 20 +- MAINTAINERS | 9 + arch/riscv/Kconfig | 1 + arch/riscv/Kconfig.socs | 1 + arch/riscv/boot/dts/canaan/k210.dtsi | 2 + .../boot/dts/microchip/microchip-mpfs.dtsi | 2 + arch/riscv/include/asm/sbi.h | 2 + arch/riscv/include/asm/smp.h | 48 +++- arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/cpu-hotplug.c | 2 + arch/riscv/kernel/irq.c | 1 + arch/riscv/kernel/sbi-ipi.c | 215 ++++++++++++++ arch/riscv/kernel/sbi.c | 15 - arch/riscv/kernel/smp.c | 172 ++++++------ arch/riscv/kernel/smpboot.c | 4 +- arch/riscv/mm/tlbflush.c | 91 ++++-- drivers/clocksource/timer-clint.c | 69 +++-- drivers/irqchip/Kconfig | 9 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-riscv-aclint-swi.c | 265 ++++++++++++++++++ drivers/irqchip/irq-riscv-intc.c | 55 ++-- 23 files changed, 946 insertions(+), 204 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/riscv,aclint-swi.yaml create mode 100644 Documentation/devicetree/bindings/timer/riscv,aclint-mtimer.yaml create mode 100644 arch/riscv/kernel/sbi-ipi.c create mode 100644 drivers/irqchip/irq-riscv-aclint-swi.c