From patchwork Tue Sep 12 17:49:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp700987vqx; Tue, 12 Sep 2023 14:55:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZVDyaKzeJs2jNpYLrbMLgyJGk/tZ/RGezxNBZGl61+tjoQx7dUUIkop8CmmPKi6YvHE+W X-Received: by 2002:a05:6a20:7fa8:b0:13d:7f7b:1926 with SMTP id d40-20020a056a207fa800b0013d7f7b1926mr4377986pzj.11.1694555749681; Tue, 12 Sep 2023 14:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694555749; cv=none; d=google.com; s=arc-20160816; b=SyrvWicv1Y5oevoxbstGZjEUPRQ09k1fSOzinOXT+HY6tsm8j0jIktP6Kcklb+lIrZ VAcpR4UYQvYvo75X5XSWoF3fgAykj9nfJJ9bH+PfXEj4ZFGdlexWjlKYcIj4u1Ls2jl0 Pao55HdaZlYWiNdv9tGk81JRquUPBeoUppgw12aYbaNo3kiMhQePXEuIoHE1QWxEUyrS 4x4BnisCNHRwH5NMn+Kh6urqp4j5esPgKmyFpN2gVkvOJC4FV95ixEzVfiozDqgpO1Ah JnyhyxZ9exSkPxL0M12MDCa8/gV1X3pFlyJ2wbayHi79f+tzJWZorgf0YHjIR5UgRHlo npXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eNKC5KP8qQDW8slouBLKMG229/gzuMYaPiRbkfNYlhQ=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=rDJfZ7lGDej6L7b8oZW8/gDwb4Nf3A9mMjYMGjTaeTvbvF9vtVleLe4T6nBD7odq75 j+2tXUBqRfDsVKG6mO7nomYZCdvhU4Wp/MZJrve1Bx3UYs9qFMDjfofCZXepjbfklNco kL2M1ODB4ckfeUZQUtbIxT5UCD5Q7KDYHVaLkjBJ7w1y5nUqrYIEap0Mi4FF74e0QQ90 5XQAGuL0pspyZMPyDA0kLofpxkzKl0A5+tNXXRvQOyp9WDLn5YJv87+3RHfKsqiYJY/7 dgVDm9pT3ntiM5sMdes8m6rr2bxNVKIq4tHw/r0WD9zTjZXFerMdjVK6UubD4fLMAO4I otqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GkTQE+t8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id fb36-20020a056a002da400b0068e3950c705si9036708pfb.24.2023.09.12.14.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 14:55:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GkTQE+t8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8A01B8063BC4; Tue, 12 Sep 2023 10:50:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236851AbjILRu3 (ORCPT + 36 others); Tue, 12 Sep 2023 13:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236841AbjILRu2 (ORCPT ); Tue, 12 Sep 2023 13:50:28 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C4610E6 for ; Tue, 12 Sep 2023 10:50:24 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf57366ccdso575295ad.1 for ; Tue, 12 Sep 2023 10:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541024; x=1695145824; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eNKC5KP8qQDW8slouBLKMG229/gzuMYaPiRbkfNYlhQ=; b=GkTQE+t8ytpx1H0aeGvQa6IeSiGqjTv27CVdXnV8MoS/M9X+w3mmBbNjFahgBsyBEt AnRUpQHAxJKu6cxarnCI70iidCMv6mWo5Qtf/eVWSOjCM6Ld9Nnl52m1KT5rW4rq61d3 PZLOM0/MhqZ7fGLOnCqOzYHcx5wPY5xOO/6bYGOl4g0LEQfK9oU3AeyjcyOfvWPwrVwC k6NmddaJHftmxVaP2Kw2/LGhxM1r4kB+3N1istVaS5TpJeVipgvfLfN8EhYBZeI3KoTO xXiaaZXbmzVRtutzgj1vb+9rEzH/ilfxdcW7QGSp12u8F+jdz6AFNMvi3L+md0TajtUL +fjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541024; x=1695145824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eNKC5KP8qQDW8slouBLKMG229/gzuMYaPiRbkfNYlhQ=; b=u0BAl+7+es7vW1UaJ/bWNFccv28tAS2DG0O7z0K0VujCPdM7VhuaRPR6on4HWOGzBH i7HpUf3UoibAuFzI2wjHgN1wvyndP/GGbUDcwlpk1RidDzMlLF94wewqveMzsT9IJfd+ Z6BETZbAQkXkMtiwTSmzUbImeJgAozQrOnaNzGQsh8DJ0oJuRE2lthbVQEv68ub1rxxU kFxaitu2fKvBCRFD6YMRfHzDTuPbBg55zkI21YWLtTV5yidYod6UrzwxrqMWjQhWE+R/ DgNKY0Fh2dEwNrY6a3r5H+mozX5oo0ImCbNy0gnhkjA0AVnKYgUHggGGTpR5DXgXFfQY ORiw== X-Gm-Message-State: AOJu0YwztXvQmaR2bZ8oBqo8EMzd5Ry/NKtx8/XXHC1HT9dSljj+uNAT eYg2FHXl5+8QgXZ7UTEZ21paXQ== X-Received: by 2002:a17:902:dac2:b0:1c1:f0b4:f68f with SMTP id q2-20020a170902dac200b001c1f0b4f68fmr490270plx.10.1694541024051; Tue, 12 Sep 2023 10:50:24 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:50:23 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 01/16] RISC-V: Don't fail in riscv_of_parent_hartid() for disabled HARTs Date: Tue, 12 Sep 2023 23:19:13 +0530 Message-Id: <20230912174928.528414-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:50:47 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776870489580629983 X-GMAIL-MSGID: 1776870489580629983 The riscv_of_processor_hartid() used by riscv_of_parent_hartid() fails for HARTs disabled in the DT. This results in the following warning thrown by the RISC-V INTC driver for the E-core on SiFive boards: [ 0.000000] riscv-intc: unable to find hart id for /cpus/cpu@0/interrupt-controller The riscv_of_parent_hartid() is only expected to read the hartid from the DT so we should directly call of_get_cpu_hwid() instead of calling riscv_of_processor_hartid(). Fixes: ad635e723e17 ("riscv: cpu: Add 64bit hartid support on RV64") Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- arch/riscv/kernel/cpu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index c17dacb1141c..157ace8b262c 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -125,13 +125,14 @@ int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned lo */ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid) { - int rc; - for (; node; node = node->parent) { if (of_device_is_compatible(node, "riscv")) { - rc = riscv_of_processor_hartid(node, hartid); - if (!rc) - return 0; + *hartid = (unsigned long)of_get_cpu_hwid(node, 0); + if (*hartid == ~0UL) { + pr_warn("Found CPU without hart ID\n"); + return -ENODEV; + } + return 0; } } From patchwork Tue Sep 12 17:49:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138638 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp849146vqx; Tue, 12 Sep 2023 21:36:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZ65wiz6u5/AMunPPL5KJCnopWvbYr5gzwkWhEFn/5LCtYyPDC/LahcaXMDSsE7DOjl/hr X-Received: by 2002:a05:620a:f02:b0:76c:ba10:4973 with SMTP id v2-20020a05620a0f0200b0076cba104973mr1845626qkl.37.1694579804133; Tue, 12 Sep 2023 21:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694579804; cv=none; d=google.com; s=arc-20160816; b=RQpTxkLW60Tpo6WDmzcgx79DXEO2nqjsZa0i/LmZD3AhXGMcF+EevHMPUkFDTNLImG 1aV8WF1JlkRUOyGCo5FrxM4+HnBTTujs47Ce5m0vjlFSbV7ndC92euP3Y9+2tqT0IPSt KHH5RBe4kGYm/gSosPbEVCyaGZWgwbGj3/ALoObxKi34SwsUYAOW34IPWQoW/fm+35Lg aChpSVHlJLtfAqskBRTYBjOoHSvawAhyWuJPJDpTuvsyH9IqcxA93dpIyRt55USk2Xc4 YFQwA4LRSbqH2IHuBpFW83hJYJRmBobrhzXL+j/L+Wie+A/di6cy6jzFtkpb2ymuTWdu TwIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9IKD5S2fbnJino2jsSEu0lyxkI20ofFJrbuG4PPQ6fw=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=T/xlfgCTC0sKT99rhPNQNo3D9+jf1qGIMLWV0qt7xZ53iGf5w1G6sEPmpyOSYbC+vC N/lAlWvTy4IRH4hwVSdMl64ouD4Vv0dv8mPLMHPywxBpUCVUy3zHSBXamcm2sQx2nA83 Y7YpMdGRW0Q72e5jiAlto9doZNbRTsl/SpsMYoXpX16bMuOb4HiS6m8c5chcU9I5fxIB rvIeekYS4Af8jKH8j+ThCTsabQwyiokQhsROc4TXZjN/uyj+ze295mb6FzaS7iB4pdor VBjyV2SVUP9put9/su8aFVsmA3T9qZZ+BdvAuP8JbTEWUNRnrAPYV2FVZF8a1qA4zAU5 7LAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=o3x55fPZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b0055bd8c2b3bdsi9055527pgb.153.2023.09.12.21.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 21:36:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=o3x55fPZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 537E98036EA8; Tue, 12 Sep 2023 10:50:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236885AbjILRug (ORCPT + 36 others); Tue, 12 Sep 2023 13:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236865AbjILRue (ORCPT ); Tue, 12 Sep 2023 13:50:34 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 066DE10E9 for ; Tue, 12 Sep 2023 10:50:31 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c1e780aa95so40602305ad.3 for ; Tue, 12 Sep 2023 10:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541030; x=1695145830; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9IKD5S2fbnJino2jsSEu0lyxkI20ofFJrbuG4PPQ6fw=; b=o3x55fPZ6iwO23F8UrGX29emOODOiVCte7aeVIcROae4NVD4l/pIgJBOUrhCkfNF2B lqu3gHnUpwssK6y1FdOPdnQ8F4NwPbRotWYK9vmJcJtvf0FXQquUaIAEgiVokn8ET5gx XR+pVZSfEetcXdyIv5nTjjP2ZsTCHA5Vm94B+YONExOz/SdwRvJ3f0l8/LU5O4VcVxKG s4xlhqS8S1Ld0pOj+6PvYNYGpWDLAhz2q4MRR4Hf/mX00ZhH9VhMEe3hyZvjzTIyiF4T zuj43pIJe0G1mzpdP0ub+Ln4QuX/B9jyhEk0o7ctmhMY4A5fEfZ7qvPbI6MzPqaSmb8r HGLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541030; x=1695145830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9IKD5S2fbnJino2jsSEu0lyxkI20ofFJrbuG4PPQ6fw=; b=dQjsDGTg44sKFTp6JWvMhTA47Y9n7xQbHk7wl/5eaUS9DRrbxgrcsfD5GEh/NtnFtJ vEaEELzctfgP/hSxU/TpSCguAgeWLeWzLpapycYqY+dzTJBjkpTZ9w1/YvYlqcRNL+OV BMwLns9AluYV+70vNtnNyUxvIUXY/QIWGkWlq4w3bTF9ldeWtKuP3GwJTN4Wk49KP9nK 7y4tBbUjQjSBQlIwenuI+Ai/hzcqAHq186zi6lDG0pAba2mZAFEKF/QU75KetesuQBxZ SDYDtVCJkcm+R4VL4dSK4F/oDzGzrbnSUXSob11544ohiVOCuNPvJCeGQdl1XpX0/b2J Rx3g== X-Gm-Message-State: AOJu0YzjP0IIeJU5sZ6NG1GPCwwZPV8jmH/4OcJhwWhfPzSQ+lKqS95g c977hx3WTvGAivNbCL597Bbuwg== X-Received: by 2002:a17:902:e546:b0:1c3:bc7c:e14c with SMTP id n6-20020a170902e54600b001c3bc7ce14cmr578213plf.32.1694541030378; Tue, 12 Sep 2023 10:50:30 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:50:29 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 02/16] RISC-V: Add riscv_get_intc_hartid() function Date: Tue, 12 Sep 2023 23:19:14 +0530 Message-Id: <20230912174928.528414-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:50:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776895712530564953 X-GMAIL-MSGID: 1776895712530564953 We add a common riscv_get_intc_hartid() which help device drivers to get hartid of the HART associated with a INTC (i.e. local interrupt controller) fwnode. This new function is more generic compared to the existing riscv_of_parent_hartid() function hence we also replace use of riscv_of_parent_hartid() with riscv_get_intc_hartid(). Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- arch/riscv/include/asm/processor.h | 4 +++- arch/riscv/kernel/cpu.c | 13 ++++++++++++- drivers/irqchip/irq-riscv-intc.c | 2 +- drivers/irqchip/irq-sifive-plic.c | 3 ++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 3e23e1786d05..3ce64b3bea4e 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -119,7 +119,9 @@ static inline void wait_for_interrupt(void) struct device_node; int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid); int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hartid); -int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid); + +struct fwnode_handle; +int riscv_get_intc_hartid(struct fwnode_handle *node, unsigned long *hartid); extern void riscv_fill_hwcap(void); extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 157ace8b262c..ee583eac3c5b 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -123,7 +123,8 @@ int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned lo * To achieve this, we walk up the DT tree until we find an active * RISC-V core (HART) node and extract the cpuid from it. */ -int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid) +static int riscv_of_parent_hartid(struct device_node *node, + unsigned long *hartid) { for (; node; node = node->parent) { if (of_device_is_compatible(node, "riscv")) { @@ -139,6 +140,16 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid) return -1; } +/* Find hart ID of the INTC fwnode. */ +int riscv_get_intc_hartid(struct fwnode_handle *node, unsigned long *hartid) +{ + /* Extend this function ACPI in the future. */ + if (!is_of_node(node)) + return -ENODEV; + + return riscv_of_parent_hartid(to_of_node(node), hartid); +} + DEFINE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo); unsigned long riscv_cached_mvendorid(unsigned int cpu_id) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 4adeee1bc391..65f4a2afb381 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -143,7 +143,7 @@ static int __init riscv_intc_init(struct device_node *node, int rc; unsigned long hartid; - rc = riscv_of_parent_hartid(node, &hartid); + rc = riscv_get_intc_hartid(of_fwnode_handle(node), &hartid); if (rc < 0) { pr_warn("unable to find hart id for %pOF\n", node); return 0; diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index e1484905b7bd..56b0544b1f27 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -477,7 +477,8 @@ static int __init __plic_init(struct device_node *node, continue; } - error = riscv_of_parent_hartid(parent.np, &hartid); + error = riscv_get_intc_hartid(of_fwnode_handle(parent.np), + &hartid); if (error < 0) { pr_warn("failed to parse hart ID for context %d.\n", i); continue; From patchwork Tue Sep 12 17:49:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp836566vqx; Tue, 12 Sep 2023 20:56:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYNaTrpUYgtYWdZIeWfMUT37qZaX8eeBEeqmJIZSst6CWJdt0gP8pMshtpoU6P7ZohN+Jn X-Received: by 2002:a05:6a00:4791:b0:68e:2c2a:aa1d with SMTP id dh17-20020a056a00479100b0068e2c2aaa1dmr5215227pfb.11.1694577386257; Tue, 12 Sep 2023 20:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694577386; cv=none; d=google.com; s=arc-20160816; b=rRcGC7QU5ozYvYWhYlIzBB/Ycq+5LM2NXK8wcQ/ZsYyfqAaCStpWPc6BpkTXX5z0Nz YLQ19g+kSjEwxzD30cSk++qNJbIkg2tKZHsJtxFwWvEiJ0xRGTSLazLV4BNf6vDR7IXV d8DLBc8uvvcPuRJS5pYjTZTTY4opar7a/Ou1nRaioCOikufHxMeKsqck0bzeFcggYcmP rE3kvQqYjSq/5zdD01ai/IFrRo7GiT7dNydS9D69A7ZeRfs70+Wl4kxTtf0LClXAurz6 WwHzGufmqEuvg7nolbYiec6CMfO9hVB4PnvkZA4gcRJyK2ou0T6rLnDYxNjLi/raudd7 NgeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3yJEEb56ymg39YALnwyrySa9js/OLlIbNxAluFRWmmE=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=gtIDqzf602Fbnwk6s5xVKuPK24L5HZ0svEiMAyvusOf4ANP1PZLV3RA1PYUPvMhORD Oxgy2pk7pLPZeXEusdfKCN8Q8VcMhiuZXqHQCK2oEXqx3HjgQCkH5QN0H3c4sqm8tXbP UxxdG1vEOpHGjXPJfY3ZP/LY+C3wGUAYJe64TqQvVSOZc8tGhn9rflp8Jg3/OIG8Df10 zyoX1hxzSfApCx5iq4dOMVxh/ctxHSQYoMZFXBy6x3jzi9jTy8ao+hv8pWrZ7oSuQFwl 6XY0PUztSABcWIMqKU+HmH5Qye/QzzzVNVkqUS6ggbYR0HMrlNsST4zXV5z0vldbJhye u9wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dMxc9F4p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j21-20020a056a00235500b0068fcf194dacsi3952394pfj.92.2023.09.12.20.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 20:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dMxc9F4p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C69AE802139C; Tue, 12 Sep 2023 10:50:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236903AbjILRun (ORCPT + 36 others); Tue, 12 Sep 2023 13:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236886AbjILRul (ORCPT ); Tue, 12 Sep 2023 13:50:41 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A33710C9 for ; Tue, 12 Sep 2023 10:50:37 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c39bc0439bso739355ad.0 for ; Tue, 12 Sep 2023 10:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541037; x=1695145837; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3yJEEb56ymg39YALnwyrySa9js/OLlIbNxAluFRWmmE=; b=dMxc9F4pitexwe3ahC6PFnOzexdamCvBXYNk+ppx7sYcke5Bt6keJv4UTam+QjCwnP ltnM1XWjDX/YEoI+VVoXFnyQI1WLBvUuklFDxGlXDJtndShy09jKuL7ZxD8V7J2qsjp+ Twyjt9bYTbHLYGLMxIa23oItPYbAzyyJ3SyLWEJyQxWkFdOzD672o/EGG4Hy3jXA98pm B+ni5KmPmUzM0LYiwDvZ3wGuvBdkpm0evN5TI2wrJ7Uh3dxqXgVvd6VOKNqkceIrhn2L BhvEmmOunQ8HqU204KOJ7/Nw0w6pkFEi9id1kIL/ZRqiAPnd7Iei7oELcM0Fvw2v5tCG XDOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541037; x=1695145837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3yJEEb56ymg39YALnwyrySa9js/OLlIbNxAluFRWmmE=; b=TG30BcDid0fT3J6uoKByY/jdnlQQ/wFvFDAr+03R1Yt1G+nDf533a/v1HhFQRW/Md8 DIQMxoHfA0M1xOUVhcoDNvkalohvZfodAkxyOoZwU/YdX3sis6E0DmqTbU7ild/PgIL6 yL8YrzQo406PtfU9+gn691kS6RijdOFJ41NAHPZxGY/MoEL1hWOQqm4dY4dYI1Pe1Lds BDxROHYT+zsVAz/ihkasuJmuUA98FjoFlVV5HfeRZ74hh9lv9ZF/dX8Qte4U48Si3lPl /EgtgHCju4hZ0LK6U64N6mzioRPx+ZaqqYA88VF1x5fdwAFZPchHaGid2hped/Bro85m ra0Q== X-Gm-Message-State: AOJu0YzD6wvH5gLG4x7jw7BsswvIIjszEW4h/ghrGEU2vr++a+vNqexs ooreAgmmT0zPwal+T1tlY9LVzA== X-Received: by 2002:a17:902:ce90:b0:1bf:7aeb:c488 with SMTP id f16-20020a170902ce9000b001bf7aebc488mr386820plg.29.1694541036636; Tue, 12 Sep 2023 10:50:36 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:50:36 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 03/16] of: property: Add fw_devlink support for msi-parent Date: Tue, 12 Sep 2023 23:19:15 +0530 Message-Id: <20230912174928.528414-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:50:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776893177565657865 X-GMAIL-MSGID: 1776893177565657865 This allows fw_devlink to create device links between consumers of a MSI and the supplier of the MSI. Signed-off-by: Anup Patel --- drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index cf8dacf3e3b8..758ea822e46d 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1267,6 +1267,7 @@ DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells") DEFINE_SIMPLE_PROP(leds, "leds", NULL) DEFINE_SIMPLE_PROP(backlight, "backlight", NULL) DEFINE_SIMPLE_PROP(panel, "panel", NULL) +DEFINE_SIMPLE_PROP(msi_parent, "msi-parent", "#msi-cells") DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") @@ -1361,6 +1362,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_regulators, }, { .parse_prop = parse_gpio, }, { .parse_prop = parse_gpios, }, + { .parse_prop = parse_msi_parent, }, {} }; From patchwork Tue Sep 12 17:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp761267vqx; Tue, 12 Sep 2023 17:17:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGT81OMxK3UzWvJOPoxH/MvBbwxFk7ZQF3TxCtpZQ3V7nauvPJzFsnW8nhoPP+28a5/2bXM X-Received: by 2002:a05:6870:1697:b0:1d5:bda7:130e with SMTP id j23-20020a056870169700b001d5bda7130emr1150714oae.18.1694564272739; Tue, 12 Sep 2023 17:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694564272; cv=none; d=google.com; s=arc-20160816; b=O70s1fzOrhN54/E38vaKZxesZ1wVOYQwMsxKLmzG3l2mlekrASPK38kaM/AV4dyZbh l6iMDlCbe19DubTSj2OLF2SRtZz6kHdVDquHKCultsFmUhHSBS/d4Q0fS4cxnWB7ysMM kU2kCyJBksJGcjad8wUXJzOqCseC/wBYR5ZyMHayc3GmqvRYkZL+KN3NPhKb/obVH03X 4lpot/e2pQ8egG5+hYxTR/ddvQ7IDfUh35B0VuXR4nYgdwqYAg3NtSNvd55ti84r8ADO RcTUkXh0gJpMynvJeKgUzHAsCSH8aZZ58Q0jXtfsH9OzBnM89QgBqM7YhCbSxGXd3P/B JGrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oQiwHLQTp/8j8gItu3f4LCSePQxOFgN8ncFMh196Onk=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=J+079Ls0qnYXdGTL5g9riVLODLbAyvOBmkVizXUzpzY6MJ1VNltjvjXpKOeWjA33d8 6Z/I78MkMRJc5vPSbevmG/3KlzUG87lXYNPAed/uQCI+0UO7QeYctLwN05U5qRyA3qrx AILBFhoRjtgNbXXPT/MqAmD7aSQrXcdckWT/5lp/Wj4qN90hKZh+XEnY2G5a01ei7ooq mm+74vG8IjTO9ukCxPKaTijX53aq6PztBQn0/e5BOusaKnDlqyZF7ljIWgFD9qEociiM 0sEggXgcDNKGUkgkYvuJoP85LHUmnYbdxmO3k0DadErChBM6C0ZWDKag4vcO89W3l35v XbZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=o8oicXFZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id c7-20020a633507000000b005653378ef3fsi8854812pga.849.2023.09.12.17.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 17:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=o8oicXFZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A963181BFCD2; Tue, 12 Sep 2023 10:51:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237050AbjILRuv (ORCPT + 36 others); Tue, 12 Sep 2023 13:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236837AbjILRur (ORCPT ); Tue, 12 Sep 2023 13:50:47 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 550D81706 for ; Tue, 12 Sep 2023 10:50:43 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bf7423ef3eso44418365ad.3 for ; Tue, 12 Sep 2023 10:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541043; x=1695145843; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oQiwHLQTp/8j8gItu3f4LCSePQxOFgN8ncFMh196Onk=; b=o8oicXFZRIf/pt60zd/YZysbGGj4Xr3aPhFkPQGUR/qXmkUayQMcXt5H+KJbGCNxQG TMjL01ISotYVOZsstGcnqIOM8KDdVqtYJ1Gm/e01OVTCoVIq/nLh0SZ0R39CD7QSbfIt 1FLEkNQ8lfjRShLAD8NTHWbJX1/OPCgFZVWUs9Z6uaTtHE9l5ewN54cdRjMQGubq0Csj iPB9Yet+wIlXUg8E4whTYFpkuC+Xh0ohtrUz/dHIj2BuJDLCp3BwPVqYP0XLDfZBgTQi 2x6miusK5lQew3ViMrVq14/Whvhxoeoi/Ue4Eugj/pWk+jaIU0gYJ9ltzJKdxB8eeCid 4DrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541043; x=1695145843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oQiwHLQTp/8j8gItu3f4LCSePQxOFgN8ncFMh196Onk=; b=hZzV14Sj5ETK7MHuxJDQXyJSh9AC4U4/zNr3mi3k417iuFuEvSan0o96o7aL9/Fz1R kKpPQ+JNA2R9bd9Xl03oYknZS7PuW3p2DjBSJgjLsKeAB1lELS6zqFAr40r6usDDBLZe vSIY1bNMT5rQhH9ggJS4VgTVVpSff+mJAPw1fYPsW4j79rMfiwUx7Us0NJdT2e24+vhX Z940nm9hJEOnU7cj3frLsV/VntHcnmCHHG2RpQKHAWQd5xtr8pHyKHYEmB4PlFEYmhWM Kt+8O0jJIzpne+wmYHrgUq2KTXBWiUgBu0UkdQq9+J/aWglOkRZWzPpGqB+OV5HdEUV+ pRxg== X-Gm-Message-State: AOJu0Ywj5e9kx8ESb1zbsmk19JIY4jVVMZWa3ItEny4EV5DvglULoxra tWsanUo9CNt5lDyHhv/Cr3/o9A== X-Received: by 2002:a17:902:e812:b0:1c3:39f8:3e71 with SMTP id u18-20020a170902e81200b001c339f83e71mr544767plg.18.1694541042718; Tue, 12 Sep 2023 10:50:42 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:50:42 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 04/16] drivers: irqchip/riscv-intc: Mark all INTC nodes as initialized Date: Tue, 12 Sep 2023 23:19:16 +0530 Message-Id: <20230912174928.528414-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:35 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776879426846893500 X-GMAIL-MSGID: 1776879426846893500 The RISC-V INTC local interrupts are per-HART (or per-CPU) so we create INTC IRQ domain only for the INTC node belonging to the boot HART. This means only the boot HART INTC node will be marked as initialized and other INTC nodes won't be marked which results downstream interrupt controllers (such as IMSIC and APLIC direct-mode) not being probed due to missing device suppliers. To address this issue, we mark all INTC node for which we don't create IRQ domain as initialized. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-intc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 65f4a2afb381..4e2704bc25fb 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -155,8 +155,16 @@ static int __init riscv_intc_init(struct device_node *node, * for each INTC DT node. We only need to do INTC initialization * for the INTC DT node belonging to boot CPU (or boot HART). */ - if (riscv_hartid_to_cpuid(hartid) != smp_processor_id()) + if (riscv_hartid_to_cpuid(hartid) != smp_processor_id()) { + /* + * The INTC nodes of each CPU are suppliers for downstream + * interrupt controllers (such as IMSIC and APLIC direct-mode) + * so we should mark an INTC node as initialized if we are + * not creating IRQ domain for it. + */ + fwnode_dev_initialized(of_fwnode_handle(node), true); return 0; + } return riscv_intc_init_common(of_node_to_fwnode(node)); } From patchwork Tue Sep 12 17:49:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp585959vqx; Tue, 12 Sep 2023 11:03:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAbWnxZ7Z2YsVpoIIFPJHs/4sNe64IRJn0bZtLxujcQ78CIiTanda5SqWxZUyvUpCl4Na/ X-Received: by 2002:a05:6a21:3388:b0:14c:4deb:3de2 with SMTP id yy8-20020a056a21338800b0014c4deb3de2mr151162pzb.46.1694541809290; Tue, 12 Sep 2023 11:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694541809; cv=none; d=google.com; s=arc-20160816; b=sy2LU850LVEKuYCqMs2J75TC7DPBk6D8O5xWMfAnTm5kE93TdeOhP4PK6GnY1BbDeD qqEin1SKvxAE1yMUXTyDf92vP2UcSRdSHsHEobbmKaw/FNQmncWRmTdcFrDCLUS6ARCh q0NqjNLh1Fqlr0qUKFOt2L0zWoigATT3kiRTL2BVxprc4Foc0+coBLAa2je8bSeVC/xq CXb+j90hgaRpyqpLKI/MD9mCCYiwxvJbdD1bsPiAzzbTv16bpbMkbbxCOtJrZKvF64zU ut4TIJpfEZmejvgNG8+zYBopwrGax8lrf58pK/DdIozU1BpCiZc4Y+KuTV8CelhKIIcD K5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KCVa9hJzP2APKbmQpyeCR0W7lcMtt7PzRbdh31HXulM=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=sarwSGxwuIfmUSBYbU2YA8+TNfFqPaaQoFrPQ+rcIHTEZH1XkU1bFgm63j5e2M8B92 2H5y/X7qpN1K/UXufBYIA7cbOfAINbtlZPFBtJxaNtJINQb0ahxhckwFV3W9jdAfXZ65 QiOHW4RXy+uY62SWNr5YF5rPGH20a2z8I+nFcqGJK5wjyRzvYxu5FCflWZMuhfu+olFJ 1m+LoHDusPy2dCJ8MPnBE6OqicnCgp8N0kp59+8FJXnuvfISv5W12uxAW4d4Dc8wphIg 3bic+ZLsuhQyOvKyp3kCSo1HPiU3K+8aPjm9FN+6HYjAE+O8kOfccnCiLYHRDGSXQzyC degA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="J/HhH35/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id me17-20020a17090b17d100b00267f99d5b8csi8735843pjb.20.2023.09.12.11.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:03:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="J/HhH35/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3C7B0830D36A; Tue, 12 Sep 2023 10:51:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236891AbjILRvA (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236934AbjILRux (ORCPT ); Tue, 12 Sep 2023 13:50:53 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7318710F6 for ; Tue, 12 Sep 2023 10:50:49 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c1e780aa95so40604855ad.3 for ; Tue, 12 Sep 2023 10:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541049; x=1695145849; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KCVa9hJzP2APKbmQpyeCR0W7lcMtt7PzRbdh31HXulM=; b=J/HhH35/a0s/pYGuGN46/ZdMOfdSLAEHJcR2bFhimQDzbQUvGBOrwnHWnBODOVzQuA kU9qdnajPm28W9yJXa/02zm0UJqh6bSNi+jhVoW/5tvAIM0QGZ3D32d3nsIPVBGer5vI JCx0XsKO8xElDpqiqB7BYfVzt9mn2MxicA0gmkcAoD3pfB29bBjrgxQSEcW7gnmXhH5B JitwDEvCyy02rWu/fzQR2smgwl+kG61WY3/5szSmdTQLNk69nnedMLvsFohtw1WenPEs ADfoRD9RX4Hwti5o61hGjgDZ2LCGMH55QWKKPmKRjWAFF9dN+lyp4xk8TxHEm1RQemxn 5KAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541049; x=1695145849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KCVa9hJzP2APKbmQpyeCR0W7lcMtt7PzRbdh31HXulM=; b=P/xnvh0uecqp6T/s/pTmJy3NdVEhid/o9GFrLzE4bdixUhRVJF7kfRA+5cwe13CtZC WB/QEgxXZ4qZrBuu/iH2764/KDMdklBtdJvp2dAFxSZCmU0qCPA7uG3DhgknDhWYlZNw 3nLnW8Z0gw8vpA72XlbbXD/fGsRo7KCHiqAiTO/cXLgySwlu2mCRpWblDOt/7kawOY/W B/pwrm+2fp523ti3ctJRaP3riDHd+Ay+QDaSuPdt9nCqaJv61m033dnIgtlMTaeSXnaK Go0ERseCO4OmPWIpwY5Zb4coSt8j5D3EFkCpT2t2n6RkPhyMx1wApmFgglrAo8yXY4fG GIDQ== X-Gm-Message-State: AOJu0Yx1W23Ylhal6njScAH4anoDWxdPTLFtscqICVa9Zh2KcBn8kUo0 hyDlWspcMZYDSbdYA6Ca8U2AGA== X-Received: by 2002:a17:902:ec89:b0:1c3:9632:f144 with SMTP id x9-20020a170902ec8900b001c39632f144mr578158plg.31.1694541048828; Tue, 12 Sep 2023 10:50:48 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:50:48 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 05/16] irqchip/sifive-plic: Fix syscore registration for multi-socket systems Date: Tue, 12 Sep 2023 23:19:17 +0530 Message-Id: <20230912174928.528414-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776855872293274446 X-GMAIL-MSGID: 1776855872293274446 On multi-socket systems, we will have a separate PLIC in each socket so we should register syscore operation only once for multi-socket systems. Fixes: e80f0b6a2cf3 ("irqchip/irq-sifive-plic: Add syscore callbacks for hibernation") Signed-off-by: Anup Patel --- drivers/irqchip/irq-sifive-plic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 56b0544b1f27..62ba27553cc3 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -533,17 +533,18 @@ static int __init __plic_init(struct device_node *node, } /* - * We can have multiple PLIC instances so setup cpuhp state only - * when context handler for current/boot CPU is present. + * We can have multiple PLIC instances so setup cpuhp state + * and register syscore operations only when context handler + * for current/boot CPU is present. */ handler = this_cpu_ptr(&plic_handlers); if (handler->present && !plic_cpuhp_setup_done) { cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, "irqchip/sifive/plic:starting", plic_starting_cpu, plic_dying_cpu); + register_syscore_ops(&plic_irq_syscore_ops); plic_cpuhp_setup_done = true; } - register_syscore_ops(&plic_irq_syscore_ops); pr_info("%pOFP: mapped %d interrupts with %d handlers for" " %d contexts.\n", node, nr_irqs, nr_handlers, nr_contexts); From patchwork Tue Sep 12 17:49:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp807938vqx; Tue, 12 Sep 2023 19:23:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSK2Z5Ne+ijxCX+uiqEesOunjTedv3z5lk2lJA0fQq1cOPpoIBj9OrsItbZm3/jF3dJTs8 X-Received: by 2002:a17:90b:4f87:b0:271:80f2:52bd with SMTP id qe7-20020a17090b4f8700b0027180f252bdmr838748pjb.35.1694571820690; Tue, 12 Sep 2023 19:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694571820; cv=none; d=google.com; s=arc-20160816; b=PQNh3qGLMqPViVH9q3juR/CBlCVyOCQbIK4UaQBi3Vn8wfdUyUUqb+lcuywpafztF4 ORFBh1/EVkz2APThLlvAoX/LUV075XwsrITFvxBL+G4NvnQxRPsrSBVjL3B4/8d/Z+N4 5d1G1lVoPVrH20shG3WRc7baiENNvcfGAO5mkn/J4CvivNr1ainOIlyr1RhpOz2ILNrH AN0SbLjMkwViXjIp3Vexq3+SBJZKVdHZ8zFkXyDPrbnlG8btv5quOl7KzjWBxHj6QtKl g9m/bKbBv1y/r6bZh9CdQwcSdnOgM/Jir5xh2CbJm+/pkbcPEEEcLs1AM2/xiTRzY7Zt GB3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zqvOnLhOJ7ioO5JJTC1Cfy8iveYDzUsMPwOovPSix+c=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=xA85ECokhKEBjJGS/ZyiyaQlaAUZ3wH+1skRZZvwJPYtAAhPOXbpbufnjx+IVMHTpi dDK4a9efgb5Zd2nW39XpQcHLV2r8164JzdB0CI730l+EC0eeqAlVG2RU4dYwaKv63VhG Z5QiFtWckhl51VkMNbT/uOFEdwJGQ0wCJ8cLEWXuwi1WYuCGKLLl569rd/CkdGibfaci xytDuCZ8vbNSuw8whNRh9nz0eD98Ogcu+aeD5OFKH2YKsxiYbOmw3YOUc6qauPPI6oUN lWwqLZiqCGHNOm5c9tEOHh54+VjS2qaTSdt6YalpN5z3ajfeBV6CZcZrjliZASz0yJdt roig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="R/OPu7sP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id oj10-20020a17090b4d8a00b0026b49dac834si640492pjb.34.2023.09.12.19.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 19:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="R/OPu7sP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 818CB871829F; Tue, 12 Sep 2023 10:51:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237010AbjILRvE (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236863AbjILRu7 (ORCPT ); Tue, 12 Sep 2023 13:50:59 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C9CF10FD for ; Tue, 12 Sep 2023 10:50:55 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c3bd829b86so19005125ad.0 for ; Tue, 12 Sep 2023 10:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541055; x=1695145855; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zqvOnLhOJ7ioO5JJTC1Cfy8iveYDzUsMPwOovPSix+c=; b=R/OPu7sPkJMOtLuKB1+uF0O6VOP/6E+uA24RgK0YThml/IU17RbWODTyO51aCTWoHq 2NqCaifap18cnSBqv1OMDop9gfAv8lkTX6DDGZD/XH56r/A0WV+VA41IHlxMnfSfBpNl jBArEi0Lu+Mr4YwAVt/T7oLRl5ifNKXh48W96cu22e3AmwX8FEA6xBXgsFm7yghKdFZ0 zR4H27JEIdxCsPZ+aWiLhm9DHMMdlPlln9dmfkH2NgzCsbeHJQrdd/iyGj+E2CVlchVk J9/ff7nJclqk6zDZdRcUa3HpRXKiraC68/49Oeb05qsBJQG2/1x5eAFlLYGzBUhFV8l+ XYYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541055; x=1695145855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zqvOnLhOJ7ioO5JJTC1Cfy8iveYDzUsMPwOovPSix+c=; b=u1PqAH911HBhf/L/fqpx0hCh9bpolwCT2l6JLAeHjDm8mw6ZYaFpF+RcxFeyLwVHlh qDRudamKahnyY3IH/20T9azzv46X/wOUqXvFTnVGWRwNY2bLRLFECvxGF3r6THkt/3z3 RSTLv+fB2P/KlnYd1BFHeCvMypmIiZsyWQSsRSb6bOBm4ENJuWV3Zy5LaqTrRaF9JRYf eWID54GZLL0U2BjdgVJO0gm+Xwf/htD6ORs5RBKugMnAdpbMh8SviPIJdQU7hbNtm/sJ ZHuoqI1GwUiFjlFoMqLC23fvusBJWCcCCFBIE78BcEL9VFLgtIfYW0jvYD2RKIomvkmU n6Lg== X-Gm-Message-State: AOJu0YzJD1qgFIhMDTUTTQluCeg5bOxUH/QQ8l+q412G4cbolV3kKmZI Yq7hXW8s1Db/5LUf52BkaL6t8A== X-Received: by 2002:a17:902:f687:b0:1c3:ae56:4594 with SMTP id l7-20020a170902f68700b001c3ae564594mr575848plg.49.1694541054694; Tue, 12 Sep 2023 10:50:54 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:50:54 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 06/16] irqchip/sifive-plic: Convert PLIC driver into a platform driver Date: Tue, 12 Sep 2023 23:19:18 +0530 Message-Id: <20230912174928.528414-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776887341461184101 X-GMAIL-MSGID: 1776887341461184101 The PLIC driver does not require very early initialization so let us convert it into a platform driver. As part of the conversion, the PLIC probing undergoes the following changes: 1. Use dev_info(), dev_err() and dev_warn() instead of pr_info(), pr_err() and pr_warn() 2. Use devm_xyz() APIs wherever applicable 3. Use fwnode APIs to read PLIC properties so that PLIC driver is suitable for ACPI as well. 4. PLIC is now probed after CPUs are brought-up so we have to setup cpuhp state after context handler of all online CPUs are initialized otherwise we see crash on multi-socket systems Signed-off-by: Anup Patel --- drivers/irqchip/irq-sifive-plic.c | 198 +++++++++++++++++------------- 1 file changed, 112 insertions(+), 86 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 62ba27553cc3..72d6e06ef52b 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -3,7 +3,6 @@ * Copyright (C) 2017 SiFive * Copyright (C) 2018 Christoph Hellwig */ -#define pr_fmt(fmt) "plic: " fmt #include #include #include @@ -13,8 +12,6 @@ #include #include #include -#include -#include #include #include #include @@ -64,6 +61,7 @@ #define PLIC_QUIRK_EDGE_INTERRUPT 0 struct plic_priv { + struct device *dev; struct cpumask lmask; struct irq_domain *irqdomain; void __iomem *regs; @@ -85,7 +83,6 @@ struct plic_handler { struct plic_priv *priv; }; static int plic_parent_irq __ro_after_init; -static bool plic_cpuhp_setup_done __ro_after_init; static DEFINE_PER_CPU(struct plic_handler, plic_handlers); static int plic_irq_set_type(struct irq_data *d, unsigned int type); @@ -371,7 +368,8 @@ static void plic_handle_irq(struct irq_desc *desc) int err = generic_handle_domain_irq(handler->priv->irqdomain, hwirq); if (unlikely(err)) - pr_warn_ratelimited("can't find mapping for hwirq %lu\n", + dev_warn_ratelimited(handler->priv->dev, + "can't find mapping for hwirq %lu\n", hwirq); } @@ -406,57 +404,83 @@ static int plic_starting_cpu(unsigned int cpu) return 0; } -static int __init __plic_init(struct device_node *node, - struct device_node *parent, - unsigned long plic_quirks) +static const struct of_device_id plic_match[] = { + { .compatible = "sifive,plic-1.0.0" }, + { .compatible = "riscv,plic0" }, + { .compatible = "andestech,nceplic100", + .data = (const void *)BIT(PLIC_QUIRK_EDGE_INTERRUPT) }, + { .compatible = "thead,c900-plic", + .data = (const void *)BIT(PLIC_QUIRK_EDGE_INTERRUPT) }, + {} +}; + +static int plic_probe(struct platform_device *pdev) { - int error = 0, nr_contexts, nr_handlers = 0, i; - u32 nr_irqs; - struct plic_priv *priv; + int rc, nr_contexts, nr_handlers = 0, i, cpu; + unsigned long plic_quirks = 0, hartid; + struct fwnode_reference_args parent; + struct device *dev = &pdev->dev; struct plic_handler *handler; - unsigned int cpu; + struct irq_domain *domain; + struct plic_priv *priv; + irq_hw_number_t hwirq; + struct resource *res; + bool cpuhp_setup; + u32 nr_irqs; + + if (is_of_node(dev->fwnode)) { + const struct of_device_id *id; + + id = of_match_node(plic_match, to_of_node(dev->fwnode)); + if (id) + plic_quirks = (unsigned long)id->data; + } - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - + priv->dev = dev; priv->plic_quirks = plic_quirks; - priv->regs = of_iomap(node, 0); - if (WARN_ON(!priv->regs)) { - error = -EIO; - goto out_free_priv; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "failed to get MMIO resource\n"); + return -EINVAL; + } + priv->regs = devm_ioremap(dev, res->start, resource_size(res)); + if (!priv->regs) { + dev_err(dev, "failed map MMIO registers\n"); + return -EIO; } - error = -EINVAL; - of_property_read_u32(node, "riscv,ndev", &nr_irqs); - if (WARN_ON(!nr_irqs)) - goto out_iounmap; - + rc = fwnode_property_read_u32_array(dev->fwnode, "riscv,ndev", + &nr_irqs, 1); + if (rc) { + dev_err(dev, "riscv,ndev property not available\n"); + return rc; + } priv->nr_irqs = nr_irqs; - priv->prio_save = bitmap_alloc(nr_irqs, GFP_KERNEL); + priv->prio_save = devm_bitmap_zalloc(dev, nr_irqs, GFP_KERNEL); if (!priv->prio_save) - goto out_free_priority_reg; - - nr_contexts = of_irq_count(node); - if (WARN_ON(!nr_contexts)) - goto out_free_priority_reg; + return -ENOMEM; - error = -ENOMEM; - priv->irqdomain = irq_domain_add_linear(node, nr_irqs + 1, - &plic_irqdomain_ops, priv); - if (WARN_ON(!priv->irqdomain)) - goto out_free_priority_reg; + nr_contexts = 0; + while (!fwnode_property_get_reference_args(dev->fwnode, + "interrupts-extended", "#interrupt-cells", + 0, nr_contexts, &parent)) + nr_contexts++; + if (WARN_ON(!nr_contexts)) { + dev_err(dev, "no PLIC context available\n"); + return -EINVAL; + } for (i = 0; i < nr_contexts; i++) { - struct of_phandle_args parent; - irq_hw_number_t hwirq; - int cpu; - unsigned long hartid; - - if (of_irq_parse_one(node, i, &parent)) { - pr_err("failed to parse parent for context %d.\n", i); + rc = fwnode_property_get_reference_args(dev->fwnode, + "interrupts-extended", "#interrupt-cells", + 0, i, &parent); + if (rc) { + dev_warn(dev, "parent irq for context%d not found\n", i); continue; } @@ -477,22 +501,23 @@ static int __init __plic_init(struct device_node *node, continue; } - error = riscv_get_intc_hartid(of_fwnode_handle(parent.np), - &hartid); - if (error < 0) { - pr_warn("failed to parse hart ID for context %d.\n", i); + rc = riscv_get_intc_hartid(parent.fwnode, &hartid); + if (rc < 0) { + dev_warn(dev, "failed to get hart ID for context%d.\n", i); continue; } cpu = riscv_hartid_to_cpuid(hartid); if (cpu < 0) { - pr_warn("Invalid cpuid for context %d\n", i); + dev_warn(dev, "Invalid cpuid for context %d\n", i); continue; } /* Find parent domain and register chained handler */ - if (!plic_parent_irq && irq_find_host(parent.np)) { - plic_parent_irq = irq_of_parse_and_map(node, i); + domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), + DOMAIN_BUS_ANY); + if (!plic_parent_irq && domain) { + plic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT); if (plic_parent_irq) irq_set_chained_handler(plic_parent_irq, plic_handle_irq); @@ -505,7 +530,7 @@ static int __init __plic_init(struct device_node *node, */ handler = per_cpu_ptr(&plic_handlers, cpu); if (handler->present) { - pr_warn("handler already present for context %d.\n", i); + dev_warn(dev, "handler already present for context%d.\n", i); plic_set_threshold(handler, PLIC_DISABLE_THRESHOLD); goto done; } @@ -519,10 +544,13 @@ static int __init __plic_init(struct device_node *node, i * CONTEXT_ENABLE_SIZE; handler->priv = priv; - handler->enable_save = kcalloc(DIV_ROUND_UP(nr_irqs, 32), - sizeof(*handler->enable_save), GFP_KERNEL); + handler->enable_save = devm_kcalloc(dev, + DIV_ROUND_UP(nr_irqs, 32), + sizeof(*handler->enable_save), + GFP_KERNEL); if (!handler->enable_save) - goto out_free_enable_reg; + return -ENOMEM; + done: for (hwirq = 1; hwirq <= nr_irqs; hwirq++) { plic_toggle(handler, hwirq, 0); @@ -532,52 +560,50 @@ static int __init __plic_init(struct device_node *node, nr_handlers++; } + priv->irqdomain = irq_domain_create_linear(dev->fwnode, nr_irqs + 1, + &plic_irqdomain_ops, priv); + if (WARN_ON(!priv->irqdomain)) + return -ENOMEM; + /* * We can have multiple PLIC instances so setup cpuhp state - * and register syscore operations only when context handler - * for current/boot CPU is present. + * and register syscore operations only after context handlers + * of all online CPUs are initialized. */ - handler = this_cpu_ptr(&plic_handlers); - if (handler->present && !plic_cpuhp_setup_done) { + cpuhp_setup = true; + for_each_online_cpu(cpu) { + handler = per_cpu_ptr(&plic_handlers, cpu); + if (!handler->present) { + cpuhp_setup = false; + break; + } + } + if (cpuhp_setup) { cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, "irqchip/sifive/plic:starting", plic_starting_cpu, plic_dying_cpu); register_syscore_ops(&plic_irq_syscore_ops); - plic_cpuhp_setup_done = true; } - pr_info("%pOFP: mapped %d interrupts with %d handlers for" - " %d contexts.\n", node, nr_irqs, nr_handlers, nr_contexts); + dev_info(dev, "mapped %d interrupts with %d handlers for" + " %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); return 0; - -out_free_enable_reg: - for_each_cpu(cpu, cpu_present_mask) { - handler = per_cpu_ptr(&plic_handlers, cpu); - kfree(handler->enable_save); - } -out_free_priority_reg: - kfree(priv->prio_save); -out_iounmap: - iounmap(priv->regs); -out_free_priv: - kfree(priv); - return error; -} - -static int __init plic_init(struct device_node *node, - struct device_node *parent) -{ - return __plic_init(node, parent, 0); } -IRQCHIP_DECLARE(sifive_plic, "sifive,plic-1.0.0", plic_init); -IRQCHIP_DECLARE(riscv_plic0, "riscv,plic0", plic_init); /* for legacy systems */ +static struct platform_driver plic_driver = { + .driver = { + .name = "riscv-plic", + .of_match_table = plic_match, + }, + .probe = plic_probe, +}; -static int __init plic_edge_init(struct device_node *node, - struct device_node *parent) +static int __init plic_init(void) { - return __plic_init(node, parent, BIT(PLIC_QUIRK_EDGE_INTERRUPT)); + /* + * Register PLIC driver as early as possible so that PLIC + * platform device is probed as soon as it is created. + */ + return platform_driver_register(&plic_driver); } - -IRQCHIP_DECLARE(andestech_nceplic100, "andestech,nceplic100", plic_edge_init); -IRQCHIP_DECLARE(thead_c900_plic, "thead,c900-plic", plic_edge_init); +core_initcall(plic_init); From patchwork Tue Sep 12 17:49:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138400 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp632922vqx; Tue, 12 Sep 2023 12:27:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE27asyIfYmmtgRCf6xHJcUaPod7ypp26Xdx+xwg+DTQwmfIlHOk8ftYQaZbW8OH4p8/BkM X-Received: by 2002:a17:902:da92:b0:1c0:cbaf:6954 with SMTP id j18-20020a170902da9200b001c0cbaf6954mr735944plx.25.1694546867361; Tue, 12 Sep 2023 12:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694546867; cv=none; d=google.com; s=arc-20160816; b=ArJkESijfaoWNi2rIMHIppnqFvmhtwG29+QatMzTFHv+Fa8r+Ld78geDLG9lI8X082 BTKSQ9ZJDCmaUZqSaT453YX8kQ7jBSbKjjob1UIQhnYqYxJsYrRnwbE/sNgWnoCRGdna 9CwD9XrJYVXO9pFZ2Aben7sFlBAj2QAkrHphFIZoOVXEz0xFhmTCMTCbE+PUJ8nCEHHv ZJiSngMW3HjPSYDHWZYYtkLsmXsCyBBzF9rEnc82fXAiO4pnvZpEet+EqpaL0aXoeTN8 WAKhhcja2zsi+8wNCisXfoEkUm06uHfFm9VXfi+24mhLCL6dr+woatgtC4Ja1g2y5OWs wDXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VKnkNq9mHXbpDqEgJF2mGpUUpQc6aLvqIlFOdqDcBBw=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=JtEEt48fskLHN0GKGvvznHwtoeRb+WSkMm2Re8J6rvSp6uxj2Wl+5vgXWKf5wPZf3l yzQkg72HQudpGQ+M8VL8vIWmKERVxk+utI4vQkzZDNMjHi+zNLkVna0bTb3dckZDrXhU vDEy9VihE3U0ZmP0Lv4c6anT73wenqvtcGqEItcEK/pp5Ctrq5cz424SFau0DHVKYE25 rwwnGEr2t7wgnBKJ8Y72X3Y22HC14JJvDHMXdU+GCfo8QDdQTZu0aNOJQzxU9o2JE8GS 7EXbn5vDV5d3GIAGrqGxeiU6mwYePUjR+SwqJ62WwB7eesdESczpeLYCit2+VIbJc+2D BjKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="S4E/jZuX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u13-20020a170903124d00b001bb8c4279f5si8742131plh.148.2023.09.12.12.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 12:27:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="S4E/jZuX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id ACBA280CD70B; Tue, 12 Sep 2023 10:51:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237239AbjILRvN (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237054AbjILRvF (ORCPT ); Tue, 12 Sep 2023 13:51:05 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AED81704 for ; Tue, 12 Sep 2023 10:51:01 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1bf1935f6c2so645275ad.1 for ; Tue, 12 Sep 2023 10:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541061; x=1695145861; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VKnkNq9mHXbpDqEgJF2mGpUUpQc6aLvqIlFOdqDcBBw=; b=S4E/jZuXTiWMIg/NaauFCatHPXcoIAmMsfBaYhPHgTs/TUjUSQpJBOnfuyqdnThfnM +oim4iR+aa1mZXZ7+QqMhtH7FpolcmRybPicqskLj5WBQk6BZ5kh6XpESKCJR9WTmLtf memS/0bhuWIRZNyO+n7OREH8Ml/aEoJGyr32F1NIkS3JixNonyotcOjjJYCiSP6hQP+4 FAH0f1AlJwMtmOZKblBMZQQioCgiSfN/IoxaUESmLylkZvnF2aipwFex3SwdgvT9/YIQ kshb7O1hwdgYKaSiX68Rw8PMduyvWNa3TDUfVAOCGQe9gwRRjY4ftOMLgrOg0iyAUmiv Pb/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541061; x=1695145861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VKnkNq9mHXbpDqEgJF2mGpUUpQc6aLvqIlFOdqDcBBw=; b=CnVFOE72zzH24eSpxSrkwg6y/KuKnCMQYNI0FFWgD+2WvS9LExBVnMtVWJvUxy07Kg WZgUrGm+JGjZ2+uRj8OTDHaRsnSM2fnqFbN6rr2YN7/ufYNT9srVvaUHV5lKI/OtN3Lz Dbsqfzsouu7Gb3Qf4uJupykQvcq50fkRQO7HKiHNZ8ykH0Pz+OpASuAZEXfISA9RJf+N LPXvOBQlkJNqZEJ57AOutN32t4NHctHYKGvDdmaYtm31mSlpBRGC5XGWK34v2UkZszGY +5oRDyxN9G/8brt4iw35WiJCuMUEluR1tGokA5pyL0NrYApMXUqeyXKauTuhYhkB7LMU c8Fg== X-Gm-Message-State: AOJu0Yz8E7iwiFkXP5b/FgAHvTKj668JtHaM7Nd6RQ/rfbn85NPI3Ipq pZJ3klIQoPwpMp4komtrnOfNhw== X-Received: by 2002:a17:903:22c7:b0:1bc:4415:3c1 with SMTP id y7-20020a17090322c700b001bc441503c1mr4832136plg.7.1694541061020; Tue, 12 Sep 2023 10:51:01 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:00 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 07/16] irqchip/riscv-intc: Add support for RISC-V AIA Date: Tue, 12 Sep 2023 23:19:19 +0530 Message-Id: <20230912174928.528414-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:30 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776861175873893990 X-GMAIL-MSGID: 1776861175873893990 The RISC-V advanced interrupt architecture (AIA) extends the per-HART local interrupts in following ways: 1. Minimum 64 local interrupts for both RV32 and RV64 2. Ability to process multiple pending local interrupts in same interrupt handler 3. Priority configuration for each local interrupts 4. Special CSRs to configure/access the per-HART MSI controller We add support for #1 and #2 described above in the RISC-V intc driver. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-intc.c | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 4e2704bc25fb..1a0fc87152c5 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -17,6 +17,7 @@ #include #include #include +#include static struct irq_domain *intc_domain; @@ -30,6 +31,15 @@ static asmlinkage void riscv_intc_irq(struct pt_regs *regs) generic_handle_domain_irq(intc_domain, cause); } +static asmlinkage void riscv_intc_aia_irq(struct pt_regs *regs) +{ + unsigned long topi; + + while ((topi = csr_read(CSR_TOPI))) + generic_handle_domain_irq(intc_domain, + topi >> TOPI_IID_SHIFT); +} + /* * On RISC-V systems local interrupts are masked or unmasked by writing * the SIE (Supervisor Interrupt Enable) CSR. As CSRs can only be written @@ -39,12 +49,18 @@ static asmlinkage void riscv_intc_irq(struct pt_regs *regs) static void riscv_intc_irq_mask(struct irq_data *d) { - csr_clear(CSR_IE, BIT(d->hwirq)); + if (IS_ENABLED(CONFIG_32BIT) && d->hwirq >= BITS_PER_LONG) + csr_clear(CSR_IEH, BIT(d->hwirq - BITS_PER_LONG)); + else + csr_clear(CSR_IE, BIT(d->hwirq)); } static void riscv_intc_irq_unmask(struct irq_data *d) { - csr_set(CSR_IE, BIT(d->hwirq)); + if (IS_ENABLED(CONFIG_32BIT) && d->hwirq >= BITS_PER_LONG) + csr_set(CSR_IEH, BIT(d->hwirq - BITS_PER_LONG)); + else + csr_set(CSR_IE, BIT(d->hwirq)); } static void riscv_intc_irq_eoi(struct irq_data *d) @@ -115,16 +131,20 @@ static struct fwnode_handle *riscv_intc_hwnode(void) static int __init riscv_intc_init_common(struct fwnode_handle *fn) { - int rc; + int rc, nr_irqs = riscv_isa_extension_available(NULL, SxAIA) ? + 64 : BITS_PER_LONG; - intc_domain = irq_domain_create_linear(fn, BITS_PER_LONG, + intc_domain = irq_domain_create_linear(fn, nr_irqs, &riscv_intc_domain_ops, NULL); if (!intc_domain) { pr_err("unable to add IRQ domain\n"); return -ENXIO; } - rc = set_handle_irq(&riscv_intc_irq); + if (riscv_isa_extension_available(NULL, SxAIA)) + rc = set_handle_irq(&riscv_intc_aia_irq); + else + rc = set_handle_irq(&riscv_intc_irq); if (rc) { pr_err("failed to set irq handler\n"); return rc; @@ -132,7 +152,9 @@ static int __init riscv_intc_init_common(struct fwnode_handle *fn) riscv_set_intc_hwnode_fn(riscv_intc_hwnode); - pr_info("%d local interrupts mapped\n", BITS_PER_LONG); + pr_info("%d local interrupts mapped%s\n", + nr_irqs, riscv_isa_extension_available(NULL, SxAIA) ? + " using AIA" : ""); return 0; } From patchwork Tue Sep 12 17:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp832041vqx; Tue, 12 Sep 2023 20:40:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFO6sUk/FCocAQPidkUpZGizuO3kWas10obi4OPEiD4mFBp6np4I7Nc5TRyoyICpbdwSfR+ X-Received: by 2002:a05:622a:548:b0:40f:e176:ddb7 with SMTP id m8-20020a05622a054800b0040fe176ddb7mr1355614qtx.37.1694576420484; Tue, 12 Sep 2023 20:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694576420; cv=none; d=google.com; s=arc-20160816; b=V8cthBLoyb6pu80xQJ/Wqdwy9vHB+tuAXIjYz01TVUT+AXrDGAlTC+KcHvHZAMDKJ0 rQbcKNiyHwgWitHxuPAowhFreimx1szkGjJI/zIIBbP11PJhhchtZnvXBf6QobQBQA93 b8kRfdkJQ2j2YW4ZEnfYpxqo6369m2Lzh4qwb1dXPwhgeVRomqnqmLFG5cnA4my/tAeH TPBHe04Pt4waRx9ZGD1epKtlvIW/XUgCEG+jBAsYIGXLx0bQBMDw7aHxaysKAOigwNg+ NppYmMjpBeRkzxqHJXPlvwnZ+LyFJnxr7yNZneDcDsdW1YRsqxAaNVi/xExMtFUGT+n5 KNjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZOjDepVi55uZJQ1rIBBnqb1diEnF/zfemFV4q9wl2F4=; fh=cnGyrU6KU0VQNJMKB03edoR8OrOtwtd0XanYVBu+B1Y=; b=hZBIECi69xjEdvO79dyJjGR5zem/c/gl9irV8RNnUj5vSUSt1AVKBFBF6YlzoS/ENG JPl0WH/KZCyuT6wtDjemfuJtTfLMOGRfb05s3fHwMGiemujX61H6EMTosSHmmEIIGFkM 9jjXC9ezgOlsswyEYmBzLcBRaq6jNDtLEAj/exAPJcotYSIlX7WVl1Na0H6eaY7QlWCJ Oe+66YqdbBAg5fRstFvwbJs2mOhU6/UKSSG9XyWjgMpqEmoEuyfuQ8Jtl//C0FRCJxEN h1Y2wzqEN6SVBiPEAp7+yDPYWINJUoaRHuT26JOhckAnjmwhHwaMaxp1SXA1OnI3Z2DS eSUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=iLTlvW8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s9-20020a637709000000b005778dc6a841si3465283pgc.178.2023.09.12.20.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 20:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=iLTlvW8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 38808875EA03; Tue, 12 Sep 2023 10:51:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236907AbjILRvY (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237262AbjILRvO (ORCPT ); Tue, 12 Sep 2023 13:51:14 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 693C21711 for ; Tue, 12 Sep 2023 10:51:08 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bf6ea270b2so40831685ad.0 for ; Tue, 12 Sep 2023 10:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541068; x=1695145868; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZOjDepVi55uZJQ1rIBBnqb1diEnF/zfemFV4q9wl2F4=; b=iLTlvW8m2poUuDTLDw6BWFYVMWFYVcJo21WLpGX/KMXHMVXzrlr2w0+mGjQuwLuhok QQ6a4Xx/0B12HRT2t7OBzRaTJgmDVkmy2NwHPq0y1wmPcswTDb7tpiygaJXlBBWy+35e M4Eomoh2BuEHYtcKIiWf+TqTMNjqpEjt7bAS8k7SR79ltoDw6hndg7t/gLBZEYJ4paRG T+hxMKDH4lNsrhAlrHgFSiZqNSMrAF2S2rq8Wnn+2lPYg99DL/3XkTzMv2aKZymnqIWE YZvGQN+4B8rVaHCjcYFfgbsEjpoau9mAgHnjXnijCVjhzuuBHN+vWT1T5Wwr+c+k3eWf IwTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541068; x=1695145868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZOjDepVi55uZJQ1rIBBnqb1diEnF/zfemFV4q9wl2F4=; b=e14bNXMmattXo6o5JYeEhGhX6QeCCDnEmDlpdcbHIyI4tpSzwwohIuxzq+jZ0hjh7L xITQXaXE7ZR7T8N/wMWmmkrYIhx5PKOgG2TQ7S6pylnq1d7HO43aQwHEYPWTaJ2/Qcst 8+VJCRxEHySmbdNL6jhMTysRWw5gjiCjaTMFTR0WH2KODh58JkeoG+Fo24gRzOVZ5ZwP vkrYDeq5oXkcw40zTCAGzNDcYZ1dvhlNDp9mj1Wv3bPAVhrFzacsXujec7OtkBmrBa6K 4rdN7o9H08vwL+u/VYRTQYj0dgfp5nIlEyXPFfkHnlMsC1S0fRb2aTLgYERAHpJQ1Rf7 rZuA== X-Gm-Message-State: AOJu0YxipSqHPljQM0sGesuUQYYPSs8lmNAFyH9zmtUrg7KvWPBTHUoK B6WyNKfX3nZbALzCpDE8J6yuMA== X-Received: by 2002:a17:902:ec89:b0:1c3:9632:f144 with SMTP id x9-20020a170902ec8900b001c39632f144mr579021plg.31.1694541067692; Tue, 12 Sep 2023 10:51:07 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:07 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel , Conor Dooley , Krzysztof Kozlowski Subject: [PATCH v8 08/16] dt-bindings: interrupt-controller: Add RISC-V incoming MSI controller Date: Tue, 12 Sep 2023 23:19:20 +0530 Message-Id: <20230912174928.528414-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776892164744754868 X-GMAIL-MSGID: 1776892164744754868 We add DT bindings document for the RISC-V incoming MSI controller (IMSIC) defined by the RISC-V advanced interrupt architecture (AIA) specification. Signed-off-by: Anup Patel Reviewed-by: Conor Dooley Acked-by: Krzysztof Kozlowski --- .../interrupt-controller/riscv,imsics.yaml | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml b/Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml new file mode 100644 index 000000000000..84976f17a4a1 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml @@ -0,0 +1,172 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/riscv,imsics.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V Incoming MSI Controller (IMSIC) + +maintainers: + - Anup Patel + +description: | + The RISC-V advanced interrupt architecture (AIA) defines a per-CPU incoming + MSI controller (IMSIC) for handling MSIs in a RISC-V platform. The RISC-V + AIA specification can be found at https://github.com/riscv/riscv-aia. + + The IMSIC is a per-CPU (or per-HART) device with separate interrupt file + for each privilege level (machine or supervisor). The configuration of + a IMSIC interrupt file is done using AIA CSRs and it also has a 4KB MMIO + space to receive MSIs from devices. Each IMSIC interrupt file supports a + fixed number of interrupt identities (to distinguish MSIs from devices) + which is same for given privilege level across CPUs (or HARTs). + + The device tree of a RISC-V platform will have one IMSIC device tree node + for each privilege level (machine or supervisor) which collectively describe + IMSIC interrupt files at that privilege level across CPUs (or HARTs). + + The arrangement of IMSIC interrupt files in MMIO space of a RISC-V platform + follows a particular scheme defined by the RISC-V AIA specification. A IMSIC + group is a set of IMSIC interrupt files co-located in MMIO space and we can + have multiple IMSIC groups (i.e. clusters, sockets, chiplets, etc) in a + RISC-V platform. The MSI target address of a IMSIC interrupt file at given + privilege level (machine or supervisor) encodes group index, HART index, + and guest index (shown below). + + XLEN-1 > (HART Index MSB) 12 0 + | | | | + ------------------------------------------------------------- + |xxxxxx|Group Index|xxxxxxxxxxx|HART Index|Guest Index| 0 | + ------------------------------------------------------------- + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + items: + - enum: + - qemu,imsics + - const: riscv,imsics + + reg: + minItems: 1 + maxItems: 16384 + description: + Base address of each IMSIC group. + + interrupt-controller: true + + "#interrupt-cells": + const: 0 + + msi-controller: true + + "#msi-cells": + const: 0 + + interrupts-extended: + minItems: 1 + maxItems: 16384 + description: + This property represents the set of CPUs (or HARTs) for which given + device tree node describes the IMSIC interrupt files. Each node pointed + to should be a riscv,cpu-intc node, which has a CPU node (i.e. RISC-V + HART) as parent. + + riscv,num-ids: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 63 + maximum: 2047 + description: + Number of interrupt identities supported by IMSIC interrupt file. + + riscv,num-guest-ids: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 63 + maximum: 2047 + description: + Number of interrupt identities are supported by IMSIC guest interrupt + file. When not specified it is assumed to be same as specified by the + riscv,num-ids property. + + riscv,guest-index-bits: + minimum: 0 + maximum: 7 + default: 0 + description: + Number of guest index bits in the MSI target address. + + riscv,hart-index-bits: + minimum: 0 + maximum: 15 + description: + Number of HART index bits in the MSI target address. When not + specified it is calculated based on the interrupts-extended property. + + riscv,group-index-bits: + minimum: 0 + maximum: 7 + default: 0 + description: + Number of group index bits in the MSI target address. + + riscv,group-index-shift: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 55 + default: 24 + description: + The least significant bit position of the group index bits in the + MSI target address. + +required: + - compatible + - reg + - interrupt-controller + - msi-controller + - "#msi-cells" + - interrupts-extended + - riscv,num-ids + +unevaluatedProperties: false + +examples: + - | + // Example 1 (Machine-level IMSIC files with just one group): + + interrupt-controller@24000000 { + compatible = "qemu,imsics", "riscv,imsics"; + interrupts-extended = <&cpu1_intc 11>, + <&cpu2_intc 11>, + <&cpu3_intc 11>, + <&cpu4_intc 11>; + reg = <0x28000000 0x4000>; + interrupt-controller; + #interrupt-cells = <0>; + msi-controller; + #msi-cells = <0>; + riscv,num-ids = <127>; + }; + + - | + // Example 2 (Supervisor-level IMSIC files with two groups): + + interrupt-controller@28000000 { + compatible = "qemu,imsics", "riscv,imsics"; + interrupts-extended = <&cpu1_intc 9>, + <&cpu2_intc 9>, + <&cpu3_intc 9>, + <&cpu4_intc 9>; + reg = <0x28000000 0x2000>, /* Group0 IMSICs */ + <0x29000000 0x2000>; /* Group1 IMSICs */ + interrupt-controller; + #interrupt-cells = <0>; + msi-controller; + #msi-cells = <0>; + riscv,num-ids = <127>; + riscv,group-index-bits = <1>; + riscv,group-index-shift = <24>; + }; +... From patchwork Tue Sep 12 17:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp586793vqx; Tue, 12 Sep 2023 11:04:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF22hE/2abdPYa2mq8iarvlKuFpWTSkX5ybTjBk1cX3eMJ6y1n4LV5wBKNJIKgmQNVUPqWV X-Received: by 2002:a17:902:7590:b0:1b8:66f6:87a3 with SMTP id j16-20020a170902759000b001b866f687a3mr519319pll.52.1694541872588; Tue, 12 Sep 2023 11:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694541872; cv=none; d=google.com; s=arc-20160816; b=W4qTBgwx4thNnDVSLr1ufW2bEmZ5X/+fNjMn9NTJZEV1cyqwdJdOXnjUgGnUsVkRFW 0JgSsbG8NPYU3rgYO6QZuC3Zlu4lddqdXqs85VCigPnK4SsoH011a8Mu3phFZrpimwIi da81QMgC9KaJwGj8Fl/+yDJpR5I9VsCc8QvXfO1QOrEzxd2PHab6/Ymiy1IQkqJ5n4SS zUoXzIc7QUZqP+YXtBX2NrZuWxgmQffmQCBjobKobDCZidM31rEikAV0HurjslN8Sssf 2ifk18bMzCNBxGPsQHKPh8FWdG737wDBXRJgZl6S0wBlobL6WlIpxZF6K2/10gXQ0grd kN/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XkMQ2jtVMuo5w8c8ED0B+Z1BKJsVHgji+qsaF/DBbWo=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=eMw+/ntbAifc6Txz4rlvB0aalXGv/BIsKDAnEIXDPdLNnQNxu3mnNQ/sV/r0HQ88rU a6w1qgXresCV0IIXHNQnSrOfoc6Utzd/NPbGvqKo0yWe7uhLDsTmXzijfn0brzT8pQDq tpgwqa08Y1E4S2CdK9PJyzXTTaEpZVZ5K3POfdKmsDBF/hgOLA2YCcjlfDHUo/s0Oqv0 KkUephovhZ1Dk+qx/oTGC3p0JFTFX8X85fCXtsFkp/K4IqlBfpe4s+YmQz+i8GepWuck ft69FSNEseSh62adnIW6/Rx1hye2Ku1oJj5tO4cRerZvMjsfJRmksLIFxmd71BIKu7sB d/iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=KF90t0WK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c13-20020a170902d48d00b001c38abae9b6si1465348plg.258.2023.09.12.11.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=KF90t0WK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 08BDB809D3D1; Tue, 12 Sep 2023 10:51:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237245AbjILRvb (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237366AbjILRvS (ORCPT ); Tue, 12 Sep 2023 13:51:18 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F8931737 for ; Tue, 12 Sep 2023 10:51:14 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c336f3f449so51723105ad.3 for ; Tue, 12 Sep 2023 10:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541074; x=1695145874; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XkMQ2jtVMuo5w8c8ED0B+Z1BKJsVHgji+qsaF/DBbWo=; b=KF90t0WK56UH+WUb7oAJT/ShUWH4eGA0OddXwrNSdZQC7tKPuMISJ66CasIk5C6e3s 9XtSfEAAWOkdYdmR2sea8zFgGjM64bDJKjVqsDJcCBBFL+w1gYmaSjYGDSKFy16ig0Zu ZMdnBbdGQsHJiaFXHR2q1lA89WoXHDIsFyI058gXsOhz8zJ/o/PCeINJZdOTs2+WKmCc P5/ZKitQJCmAoF69lA3n3gHJzkbPsHlVNLJnKV/rKF+IlnR4ToAXbuIZ4hgxnUiciloV CYXj7iJDnuxypP4IrDBDdpnJMDDMhHj7edS4jCdPWXZrTf9Gi08dRYktpOXk1kY59hkz CYig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541074; x=1695145874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XkMQ2jtVMuo5w8c8ED0B+Z1BKJsVHgji+qsaF/DBbWo=; b=YLndmMFy2NUMTyf+fTmxLY0i1B1XvjHyzN8zt7lwrSIaj5BcGtOXYaysDjSXmgpfEN /gheXlJMJNMh7w+7S3M7JjxUVucItt4qpZgKloXn9uF+Ca7laDxXWxM5ft0lhSYLyllT 1RkeYTLRSQrg/S2L4+T7XXZ7b6sy3lgTqzf+8X/GV41skkO9UbbQJWXIxz48Sp7XMw0b C9IoWiAoYRB2OIhqdKXUlkOh80+UeAEcNEIWEFfxJPy2tlzDnq42O/2+I0RecXH4TUY0 MarLIxxVB2Umaqz1RiRuR1ExkwBdWIX2YpaKBSs+dEPqijKCr+cAq4JaDf9xxP07TxHh NvmQ== X-Gm-Message-State: AOJu0Yy9r6hF6Ag4D31UPwy3I10myJZxN38lWWfEgm2q4PlrsnP/r99A ++WtmzXixu9mIS4U3PyUGVYghA== X-Received: by 2002:a17:902:7590:b0:1b8:66f6:87a3 with SMTP id j16-20020a170902759000b001b866f687a3mr478755pll.52.1694541073864; Tue, 12 Sep 2023 10:51:13 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:13 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 09/16] irqchip: Add RISC-V incoming MSI controller early driver Date: Tue, 12 Sep 2023 23:19:21 +0530 Message-Id: <20230912174928.528414-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776855938257034645 X-GMAIL-MSGID: 1776855938257034645 The RISC-V advanced interrupt architecture (AIA) specification defines a new MSI controller called incoming message signalled interrupt controller (IMSIC) which manages MSI on per-HART (or per-CPU) basis. It also supports IPIs as software injected MSIs. (For more details refer https://github.com/riscv/riscv-aia) Let us add an early irqchip driver for RISC-V IMSIC which sets up the IMSIC state and provide IPIs. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 7 +- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-riscv-imsic-early.c | 258 ++++++++++++ drivers/irqchip/irq-riscv-imsic-state.c | 523 ++++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.h | 66 +++ include/linux/irqchip/riscv-imsic.h | 86 ++++ 6 files changed, 940 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-riscv-imsic-early.c create mode 100644 drivers/irqchip/irq-riscv-imsic-state.c create mode 100644 drivers/irqchip/irq-riscv-imsic-state.h create mode 100644 include/linux/irqchip/riscv-imsic.h diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index f7149d0f3d45..ee99aacbefcc 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -30,7 +30,6 @@ config ARM_GIC_V2M config GIC_NON_BANKED bool - config ARM_GIC_V3 bool select IRQ_DOMAIN_HIERARCHY @@ -546,6 +545,12 @@ config SIFIVE_PLIC select IRQ_DOMAIN_HIERARCHY select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP +config RISCV_IMSIC + bool + depends on RISCV + select IRQ_DOMAIN_HIERARCHY + select GENERIC_MSI_IRQ + config EXYNOS_IRQ_COMBINER bool "Samsung Exynos IRQ combiner support" if COMPILE_TEST depends on (ARCH_EXYNOS && ARM) || COMPILE_TEST diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index ffd945fe71aa..d714724387ce 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -95,6 +95,7 @@ obj-$(CONFIG_QCOM_MPM) += irq-qcom-mpm.o obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o +obj-$(CONFIG_RISCV_IMSIC) += irq-riscv-imsic-state.o irq-riscv-imsic-early.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o obj-$(CONFIG_IMX_INTMUX) += irq-imx-intmux.o diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c new file mode 100644 index 000000000000..1de89ce1ec2f --- /dev/null +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#define pr_fmt(fmt) "riscv-imsic: " fmt +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "irq-riscv-imsic-state.h" + +/* + * The IMSIC driver uses 1 IPI for ID synchronization and + * arch/riscv/kernel/smp.c require 6 IPIs so we fix the + * total number of IPIs to 8. + */ +#define IMSIC_NR_IPI 8 + +static int imsic_parent_irq; + +#ifdef CONFIG_SMP +static irqreturn_t imsic_ids_sync_handler(int irq, void *data) +{ + imsic_ids_local_sync(); + return IRQ_HANDLED; +} + +void imsic_ids_remote_sync(void) +{ + struct cpumask amask; + + /* + * We simply inject ID synchronization IPI to all target CPUs + * except current CPU. The ipi_send_mask() implementation of + * IPI mux will inject ID synchronization IPI only for CPUs + * that have enabled it so offline CPUs won't receive IPI. + * An offline CPU will unconditionally synchronize IDs through + * imsic_starting_cpu() when the CPU is brought up. + */ + cpumask_andnot(&amask, cpu_online_mask, cpumask_of(smp_processor_id())); + __ipi_send_mask(imsic->ipi_lsync_desc, &amask); +} + +static void imsic_ipi_send(unsigned int cpu) +{ + struct imsic_local_config *local = + per_cpu_ptr(imsic->global.local, cpu); + + writel(imsic->ipi_id, local->msi_va); +} + +static void imsic_ipi_starting_cpu(void) +{ + /* Enable IPIs for current CPU. */ + __imsic_id_enable(imsic->ipi_id); + + /* Enable virtual IPI used for IMSIC ID synchronization */ + enable_percpu_irq(imsic->ipi_virq, 0); +} + +static void imsic_ipi_dying_cpu(void) +{ + /* + * Disable virtual IPI used for IMSIC ID synchronization so + * that we don't receive ID synchronization requests. + */ + disable_percpu_irq(imsic->ipi_virq); +} + +static int __init imsic_ipi_domain_init(void) +{ + int virq; + + /* Allocate interrupt identity for IPIs */ + virq = imsic_ids_alloc(get_count_order(1)); + if (virq < 0) + return virq; + imsic->ipi_id = virq; + + /* Create IMSIC IPI multiplexing */ + virq = ipi_mux_create(IMSIC_NR_IPI, imsic_ipi_send); + if (virq <= 0) { + imsic_ids_free(imsic->ipi_id, get_count_order(1)); + return (virq < 0) ? virq : -ENOMEM; + } + imsic->ipi_virq = virq; + + /* First vIRQ is used for IMSIC ID synchronization */ + virq = request_percpu_irq(imsic->ipi_virq, imsic_ids_sync_handler, + "riscv-imsic-lsync", imsic->global.local); + if (virq) { + imsic_ids_free(imsic->ipi_id, get_count_order(1)); + return virq; + } + irq_set_status_flags(imsic->ipi_virq, IRQ_HIDDEN); + imsic->ipi_lsync_desc = irq_to_desc(imsic->ipi_virq); + + /* Set vIRQ range */ + riscv_ipi_set_virq_range(imsic->ipi_virq + 1, IMSIC_NR_IPI - 1, true); + + /* Announce that IMSIC is providing IPIs */ + pr_info("%pfwP: providing IPIs using interrupt %d\n", + imsic->fwnode, imsic->ipi_id); + + return 0; +} +#else +static void imsic_ipi_starting_cpu(void) +{ +} + +static void imsic_ipi_dying_cpu(void) +{ +} + +static int __init imsic_ipi_domain_init(void) +{ + /* Clear the IPI id because we are not using IPIs */ + imsic->ipi_id = 0; + return 0; +} +#endif + +/* + * To handle an interrupt, we read the TOPEI CSR and write zero in one + * instruction. If TOPEI CSR is non-zero then we translate TOPEI.ID to + * Linux interrupt number and let Linux IRQ subsystem handle it. + */ +static void imsic_handle_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = irq_desc_get_chip(desc); + irq_hw_number_t hwirq; + int err; + + chained_irq_enter(chip, desc); + + while ((hwirq = csr_swap(CSR_TOPEI, 0))) { + hwirq = hwirq >> TOPEI_ID_SHIFT; + + if (hwirq == imsic->ipi_id) { +#ifdef CONFIG_SMP + ipi_mux_process(); +#endif + continue; + } + + if (unlikely(!imsic->base_domain)) + continue; + + err = generic_handle_domain_irq(imsic->base_domain, hwirq); + if (unlikely(err)) + pr_warn_ratelimited( + "hwirq %lu mapping not found\n", hwirq); + } + + chained_irq_exit(chip, desc); +} + +static int imsic_starting_cpu(unsigned int cpu) +{ + /* Enable per-CPU parent interrupt */ + enable_percpu_irq(imsic_parent_irq, + irq_get_trigger_type(imsic_parent_irq)); + + /* Setup IPIs */ + imsic_ipi_starting_cpu(); + + /* + * Interrupts identities might have been enabled/disabled while + * this CPU was not running so sync-up local enable/disable state. + */ + imsic_ids_local_sync(); + + /* Enable local interrupt delivery */ + imsic_ids_local_delivery(true); + + return 0; +} + +static int imsic_dying_cpu(unsigned int cpu) +{ + /* Cleanup IPIs */ + imsic_ipi_dying_cpu(); + + return 0; +} + +static int __init imsic_early_probe(struct fwnode_handle *fwnode) +{ + int rc; + struct irq_domain *domain; + + /* Setup IMSIC state */ + rc = imsic_setup_state(fwnode); + if (rc) { + pr_err("%pfwP: failed to setup state (error %d)\n", + fwnode, rc); + return rc; + } + + /* Find parent domain and register chained handler */ + domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), + DOMAIN_BUS_ANY); + if (!domain) { + pr_err("%pfwP: Failed to find INTC domain\n", fwnode); + return -ENOENT; + } + imsic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT); + if (!imsic_parent_irq) { + pr_err("%pfwP: Failed to create INTC mapping\n", fwnode); + return -ENOENT; + } + irq_set_chained_handler(imsic_parent_irq, imsic_handle_irq); + + /* Initialize IPI domain */ + rc = imsic_ipi_domain_init(); + if (rc) { + pr_err("%pfwP: Failed to initialize IPI domain\n", fwnode); + return rc; + } + + /* + * Setup cpuhp state (must be done after setting imsic_parent_irq) + * + * Don't disable per-CPU IMSIC file when CPU goes offline + * because this affects IPI and the masking/unmasking of + * virtual IPIs is done via generic IPI-Mux + */ + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, + "irqchip/riscv/imsic:starting", + imsic_starting_cpu, imsic_dying_cpu); + + return 0; +} + +static int __init imsic_early_dt_init(struct device_node *node, + struct device_node *parent) +{ + int rc; + + /* Do early setup of IMSIC state and IPIs */ + rc = imsic_early_probe(&node->fwnode); + if (rc) + return rc; + + /* Ensure that OF platform device gets probed */ + of_node_clear_flag(node, OF_POPULATED); + return 0; +} +IRQCHIP_DECLARE(riscv_imsic, "riscv,imsics", imsic_early_dt_init); diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c new file mode 100644 index 000000000000..412b5b919dcc --- /dev/null +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -0,0 +1,523 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#define pr_fmt(fmt) "riscv-imsic: " fmt +#include +#include +#include +#include +#include +#include + +#include "irq-riscv-imsic-state.h" + +#define IMSIC_DISABLE_EIDELIVERY 0 +#define IMSIC_ENABLE_EIDELIVERY 1 +#define IMSIC_DISABLE_EITHRESHOLD 1 +#define IMSIC_ENABLE_EITHRESHOLD 0 + +#define imsic_csr_write(__c, __v) \ +do { \ + csr_write(CSR_ISELECT, __c); \ + csr_write(CSR_IREG, __v); \ +} while (0) + +#define imsic_csr_read(__c) \ +({ \ + unsigned long __v; \ + csr_write(CSR_ISELECT, __c); \ + __v = csr_read(CSR_IREG); \ + __v; \ +}) + +#define imsic_csr_set(__c, __v) \ +do { \ + csr_write(CSR_ISELECT, __c); \ + csr_set(CSR_IREG, __v); \ +} while (0) + +#define imsic_csr_clear(__c, __v) \ +do { \ + csr_write(CSR_ISELECT, __c); \ + csr_clear(CSR_IREG, __v); \ +} while (0) + +struct imsic_priv *imsic; + +const struct imsic_global_config *imsic_get_global_config(void) +{ + return (imsic) ? &imsic->global : NULL; +} +EXPORT_SYMBOL_GPL(imsic_get_global_config); + +void __imsic_eix_update(unsigned long base_id, + unsigned long num_id, bool pend, bool val) +{ + unsigned long i, isel, ireg; + unsigned long id = base_id, last_id = base_id + num_id; + + while (id < last_id) { + isel = id / BITS_PER_LONG; + isel *= BITS_PER_LONG / IMSIC_EIPx_BITS; + isel += (pend) ? IMSIC_EIP0 : IMSIC_EIE0; + + ireg = 0; + for (i = id & (__riscv_xlen - 1); + (id < last_id) && (i < __riscv_xlen); i++) { + ireg |= BIT(i); + id++; + } + + /* + * The IMSIC EIEx and EIPx registers are indirectly + * accessed via using ISELECT and IREG CSRs so we + * need to access these CSRs without getting preempted. + * + * All existing users of this function call this + * function with local IRQs disabled so we don't + * need to do anything special here. + */ + if (val) + imsic_csr_set(isel, ireg); + else + imsic_csr_clear(isel, ireg); + } +} + +void imsic_id_set_target(unsigned int id, unsigned int target_cpu) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + imsic->ids_target_cpu[id] = target_cpu; + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); +} + +unsigned int imsic_id_get_target(unsigned int id) +{ + unsigned int ret; + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + ret = imsic->ids_target_cpu[id]; + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); + + return ret; +} + +void imsic_ids_local_sync(void) +{ + int i; + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + for (i = 1; i <= imsic->global.nr_ids; i++) { + if (imsic->ipi_id == i) + continue; + + if (test_bit(i, imsic->ids_enabled_bimap)) + __imsic_id_enable(i); + else + __imsic_id_disable(i); + } + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); +} + +void imsic_ids_local_delivery(bool enable) +{ + if (enable) { + imsic_csr_write(IMSIC_EITHRESHOLD, IMSIC_ENABLE_EITHRESHOLD); + imsic_csr_write(IMSIC_EIDELIVERY, IMSIC_ENABLE_EIDELIVERY); + } else { + imsic_csr_write(IMSIC_EIDELIVERY, IMSIC_DISABLE_EIDELIVERY); + imsic_csr_write(IMSIC_EITHRESHOLD, IMSIC_DISABLE_EITHRESHOLD); + } +} + +int imsic_ids_alloc(unsigned int order) +{ + int ret; + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + ret = bitmap_find_free_region(imsic->ids_used_bimap, + imsic->global.nr_ids + 1, order); + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); + + return ret; +} + +void imsic_ids_free(unsigned int base_id, unsigned int order) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + bitmap_release_region(imsic->ids_used_bimap, base_id, order); + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); +} + +static int __init imsic_ids_init(void) +{ + int i; + struct imsic_global_config *global = &imsic->global; + + raw_spin_lock_init(&imsic->ids_lock); + + /* Allocate used bitmap */ + imsic->ids_used_bimap = bitmap_zalloc(global->nr_ids + 1, GFP_KERNEL); + if (!imsic->ids_used_bimap) + return -ENOMEM; + + /* Allocate enabled bitmap */ + imsic->ids_enabled_bimap = bitmap_zalloc(global->nr_ids + 1, + GFP_KERNEL); + if (!imsic->ids_enabled_bimap) { + kfree(imsic->ids_used_bimap); + return -ENOMEM; + } + + /* Allocate target CPU array */ + imsic->ids_target_cpu = kcalloc(global->nr_ids + 1, + sizeof(unsigned int), GFP_KERNEL); + if (!imsic->ids_target_cpu) { + bitmap_free(imsic->ids_enabled_bimap); + bitmap_free(imsic->ids_used_bimap); + return -ENOMEM; + } + for (i = 0; i <= global->nr_ids; i++) + imsic->ids_target_cpu[i] = UINT_MAX; + + /* Reserve ID#0 because it is special and never implemented */ + bitmap_set(imsic->ids_used_bimap, 0, 1); + + return 0; +} + +static void __init imsic_ids_cleanup(void) +{ + kfree(imsic->ids_target_cpu); + bitmap_free(imsic->ids_enabled_bimap); + bitmap_free(imsic->ids_used_bimap); +} + +static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, + u32 index, unsigned long *hartid) +{ + int rc; + struct fwnode_reference_args parent; + + rc = fwnode_property_get_reference_args(fwnode, + "interrupts-extended", "#interrupt-cells", + 0, index, &parent); + if (rc) + return rc; + + /* + * Skip interrupts other than external interrupts for + * current privilege level. + */ + if (parent.args[0] != RV_IRQ_EXT) + return -EINVAL; + + return riscv_get_intc_hartid(parent.fwnode, hartid); +} + +static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode, + u32 index, struct resource *res) +{ + /* + * Currently, only OF fwnode is support so extend this function + * for other types of fwnode for ACPI support. + */ + if (!is_of_node(fwnode)) + return -EINVAL; + return of_address_to_resource(to_of_node(fwnode), index, res); +} + +int __init imsic_setup_state(struct fwnode_handle *fwnode) +{ + int rc, cpu; + phys_addr_t base_addr; + void __iomem **mmios_va = NULL; + struct resource res, *mmios = NULL; + struct imsic_local_config *local; + struct imsic_global_config *global; + unsigned long reloff, hartid; + u32 i, j, index, nr_parent_irqs, nr_handlers = 0, num_mmios = 0; + + /* + * Only one IMSIC instance allowed in a platform for clean + * implementation of SMP IRQ affinity and per-CPU IPIs. + * + * This means on a multi-socket (or multi-die) platform we + * will have multiple MMIO regions for one IMSIC instance. + */ + if (imsic) { + pr_err("%pfwP: already initialized hence ignoring\n", + fwnode); + return -EALREADY; + } + + if (!riscv_isa_extension_available(NULL, SxAIA)) { + pr_err("%pfwP: AIA support not available\n", fwnode); + return -ENODEV; + } + + imsic = kzalloc(sizeof(*imsic), GFP_KERNEL); + if (!imsic) + return -ENOMEM; + imsic->fwnode = fwnode; + global = &imsic->global; + + global->local = alloc_percpu(typeof(*(global->local))); + if (!global->local) { + rc = -ENOMEM; + goto out_free_priv; + } + + /* Find number of parent interrupts */ + nr_parent_irqs = 0; + while (!imsic_get_parent_hartid(fwnode, nr_parent_irqs, &hartid)) + nr_parent_irqs++; + if (!nr_parent_irqs) { + pr_err("%pfwP: no parent irqs available\n", fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* Find number of guest index bits in MSI address */ + rc = fwnode_property_read_u32_array(fwnode, "riscv,guest-index-bits", + &global->guest_index_bits, 1); + if (rc) + global->guest_index_bits = 0; + i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT; + if (i < global->guest_index_bits) { + pr_err("%pfwP: guest index bits too big\n", fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* Find number of HART index bits */ + rc = fwnode_property_read_u32_array(fwnode, "riscv,hart-index-bits", + &global->hart_index_bits, 1); + if (rc) { + /* Assume default value */ + global->hart_index_bits = __fls(nr_parent_irqs); + if (BIT(global->hart_index_bits) < nr_parent_irqs) + global->hart_index_bits++; + } + i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT - global->guest_index_bits; + if (i < global->hart_index_bits) { + pr_err("%pfwP: HART index bits too big\n", fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* Find number of group index bits */ + rc = fwnode_property_read_u32_array(fwnode, "riscv,group-index-bits", + &global->group_index_bits, 1); + if (rc) + global->group_index_bits = 0; + i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT - + global->guest_index_bits - global->hart_index_bits; + if (i < global->group_index_bits) { + pr_err("%pfwP: group index bits too big\n", fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* + * Find first bit position of group index. + * If not specified assumed the default APLIC-IMSIC configuration. + */ + rc = fwnode_property_read_u32_array(fwnode, "riscv,group-index-shift", + &global->group_index_shift, 1); + if (rc) + global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + i = global->group_index_bits + global->group_index_shift - 1; + if (i >= BITS_PER_LONG) { + pr_err("%pfwP: group index shift too big\n", fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* Find number of interrupt identities */ + rc = fwnode_property_read_u32_array(fwnode, "riscv,num-ids", + &global->nr_ids, 1); + if (rc) { + pr_err("%pfwP: number of interrupt identities not found\n", + fwnode); + goto out_free_local; + } + if ((global->nr_ids < IMSIC_MIN_ID) || + (global->nr_ids >= IMSIC_MAX_ID) || + ((global->nr_ids & IMSIC_MIN_ID) != IMSIC_MIN_ID)) { + pr_err("%pfwP: invalid number of interrupt identities\n", + fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* Find number of guest interrupt identities */ + if (fwnode_property_read_u32_array(fwnode, "riscv,num-guest-ids", + &global->nr_guest_ids, 1)) + global->nr_guest_ids = global->nr_ids; + if ((global->nr_guest_ids < IMSIC_MIN_ID) || + (global->nr_guest_ids >= IMSIC_MAX_ID) || + ((global->nr_guest_ids & IMSIC_MIN_ID) != IMSIC_MIN_ID)) { + pr_err("%pfwP: invalid number of guest interrupt identities\n", + fwnode); + rc = -EINVAL; + goto out_free_local; + } + + /* Compute base address */ + rc = imsic_get_mmio_resource(fwnode, 0, &res); + if (rc) { + pr_err("%pfwP: first MMIO resource not found\n", fwnode); + rc = -EINVAL; + goto out_free_local; + } + global->base_addr = res.start; + global->base_addr &= ~(BIT(global->guest_index_bits + + global->hart_index_bits + + IMSIC_MMIO_PAGE_SHIFT) - 1); + global->base_addr &= ~((BIT(global->group_index_bits) - 1) << + global->group_index_shift); + + /* Find number of MMIO register sets */ + while (!imsic_get_mmio_resource(fwnode, num_mmios, &res)) + num_mmios++; + + /* Allocate MMIO resource array */ + mmios = kcalloc(num_mmios, sizeof(*mmios), GFP_KERNEL); + if (!mmios) { + rc = -ENOMEM; + goto out_free_local; + } + + /* Allocate MMIO virtual address array */ + mmios_va = kcalloc(num_mmios, sizeof(*mmios_va), GFP_KERNEL); + if (!mmios_va) { + rc = -ENOMEM; + goto out_iounmap; + } + + /* Parse and map MMIO register sets */ + for (i = 0; i < num_mmios; i++) { + rc = imsic_get_mmio_resource(fwnode, i, &mmios[i]); + if (rc) { + pr_err("%pfwP: unable to parse MMIO regset %d\n", + fwnode, i); + goto out_iounmap; + } + + base_addr = mmios[i].start; + base_addr &= ~(BIT(global->guest_index_bits + + global->hart_index_bits + + IMSIC_MMIO_PAGE_SHIFT) - 1); + base_addr &= ~((BIT(global->group_index_bits) - 1) << + global->group_index_shift); + if (base_addr != global->base_addr) { + rc = -EINVAL; + pr_err("%pfwP: address mismatch for regset %d\n", + fwnode, i); + goto out_iounmap; + } + + mmios_va[i] = ioremap(mmios[i].start, resource_size(&mmios[i])); + if (!mmios_va[i]) { + rc = -EIO; + pr_err("%pfwP: unable to map MMIO regset %d\n", + fwnode, i); + goto out_iounmap; + } + } + + /* Initialize interrupt identity management */ + rc = imsic_ids_init(); + if (rc) { + pr_err("%pfwP: failed to initialize interrupt management\n", + fwnode); + goto out_iounmap; + } + + /* Configure handlers for target CPUs */ + for (i = 0; i < nr_parent_irqs; i++) { + rc = imsic_get_parent_hartid(fwnode, i, &hartid); + if (rc) { + pr_warn("%pfwP: hart ID for parent irq%d not found\n", + fwnode, i); + continue; + } + + cpu = riscv_hartid_to_cpuid(hartid); + if (cpu < 0) { + pr_warn("%pfwP: invalid cpuid for parent irq%d\n", + fwnode, i); + continue; + } + + /* Find MMIO location of MSI page */ + index = num_mmios; + reloff = i * BIT(global->guest_index_bits) * + IMSIC_MMIO_PAGE_SZ; + for (j = 0; num_mmios; j++) { + if (reloff < resource_size(&mmios[j])) { + index = j; + break; + } + + /* + * MMIO region size may not be aligned to + * BIT(global->guest_index_bits) * IMSIC_MMIO_PAGE_SZ + * if holes are present. + */ + reloff -= ALIGN(resource_size(&mmios[j]), + BIT(global->guest_index_bits) * IMSIC_MMIO_PAGE_SZ); + } + if (index >= num_mmios) { + pr_warn("%pfwP: MMIO not found for parent irq%d\n", + fwnode, i); + continue; + } + + local = per_cpu_ptr(global->local, cpu); + local->msi_pa = mmios[index].start + reloff; + local->msi_va = mmios_va[index] + reloff; + + nr_handlers++; + } + + /* If no CPU handlers found then can't take interrupts */ + if (!nr_handlers) { + pr_err("%pfwP: No CPU handlers found\n", fwnode); + rc = -ENODEV; + goto out_ids_cleanup; + } + + /* We don't need MMIO arrays anymore so let's free-up */ + kfree(mmios_va); + kfree(mmios); + + return 0; + +out_ids_cleanup: + imsic_ids_cleanup(); +out_iounmap: + for (i = 0; i < num_mmios; i++) { + if (mmios_va[i]) + iounmap(mmios_va[i]); + } + kfree(mmios_va); + kfree(mmios); +out_free_local: + free_percpu(imsic->global.local); +out_free_priv: + kfree(imsic); + imsic = NULL; + return rc; +} diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h new file mode 100644 index 000000000000..3170018949a8 --- /dev/null +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#ifndef _IRQ_RISCV_IMSIC_STATE_H +#define _IRQ_RISCV_IMSIC_STATE_H + +#include +#include +#include + +struct imsic_priv { + /* Device details */ + struct fwnode_handle *fwnode; + + /* Global configuration common for all HARTs */ + struct imsic_global_config global; + + /* Global state of interrupt identities */ + raw_spinlock_t ids_lock; + unsigned long *ids_used_bimap; + unsigned long *ids_enabled_bimap; + unsigned int *ids_target_cpu; + + /* IPI interrupt identity and synchronization */ + u32 ipi_id; + int ipi_virq; + struct irq_desc *ipi_lsync_desc; + + /* IRQ domains (created by platform driver) */ + struct irq_domain *base_domain; + struct irq_domain *plat_domain; +}; + +extern struct imsic_priv *imsic; + +void __imsic_eix_update(unsigned long base_id, + unsigned long num_id, bool pend, bool val); + +#define __imsic_id_enable(__id) \ + __imsic_eix_update((__id), 1, false, true) +#define __imsic_id_disable(__id) \ + __imsic_eix_update((__id), 1, false, false) + +void imsic_id_set_target(unsigned int id, unsigned int target_cpu); +unsigned int imsic_id_get_target(unsigned int id); + +void imsic_ids_local_sync(void); +void imsic_ids_local_delivery(bool enable); + +#ifdef CONFIG_SMP +void imsic_ids_remote_sync(void); +#else +static inline void imsic_ids_remote_sync(void) +{ +} +#endif + +int imsic_ids_alloc(unsigned int order); +void imsic_ids_free(unsigned int base_id, unsigned int order); + +int imsic_setup_state(struct fwnode_handle *fwnode); + +#endif diff --git a/include/linux/irqchip/riscv-imsic.h b/include/linux/irqchip/riscv-imsic.h new file mode 100644 index 000000000000..1f6fc9a57218 --- /dev/null +++ b/include/linux/irqchip/riscv-imsic.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ +#ifndef __LINUX_IRQCHIP_RISCV_IMSIC_H +#define __LINUX_IRQCHIP_RISCV_IMSIC_H + +#include +#include + +#define IMSIC_MMIO_PAGE_SHIFT 12 +#define IMSIC_MMIO_PAGE_SZ (1UL << IMSIC_MMIO_PAGE_SHIFT) +#define IMSIC_MMIO_PAGE_LE 0x00 +#define IMSIC_MMIO_PAGE_BE 0x04 + +#define IMSIC_MIN_ID 63 +#define IMSIC_MAX_ID 2048 + +#define IMSIC_EIDELIVERY 0x70 + +#define IMSIC_EITHRESHOLD 0x72 + +#define IMSIC_EIP0 0x80 +#define IMSIC_EIP63 0xbf +#define IMSIC_EIPx_BITS 32 + +#define IMSIC_EIE0 0xc0 +#define IMSIC_EIE63 0xff +#define IMSIC_EIEx_BITS 32 + +#define IMSIC_FIRST IMSIC_EIDELIVERY +#define IMSIC_LAST IMSIC_EIE63 + +#define IMSIC_MMIO_SETIPNUM_LE 0x00 +#define IMSIC_MMIO_SETIPNUM_BE 0x04 + +struct imsic_local_config { + phys_addr_t msi_pa; + void __iomem *msi_va; +}; + +struct imsic_global_config { + /* + * MSI Target Address Scheme + * + * XLEN-1 12 0 + * | | | + * ------------------------------------------------------------- + * |xxxxxx|Group Index|xxxxxxxxxxx|HART Index|Guest Index| 0 | + * ------------------------------------------------------------- + */ + + /* Bits representing Guest index, HART index, and Group index */ + u32 guest_index_bits; + u32 hart_index_bits; + u32 group_index_bits; + u32 group_index_shift; + + /* Global base address matching all target MSI addresses */ + phys_addr_t base_addr; + + /* Number of interrupt identities */ + u32 nr_ids; + + /* Number of guest interrupt identities */ + u32 nr_guest_ids; + + /* Per-CPU IMSIC addresses */ + struct imsic_local_config __percpu *local; +}; + +#ifdef CONFIG_RISCV_IMSIC + +extern const struct imsic_global_config *imsic_get_global_config(void); + +#else + +static inline const struct imsic_global_config *imsic_get_global_config(void) +{ + return NULL; +} + +#endif + +#endif From patchwork Tue Sep 12 17:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp631190vqx; Tue, 12 Sep 2023 12:24:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHG/BXSpKOkU4z19ZpZ7LpcCmYUdi7/ZXKzm4DAjME55JtZTYFMbAxt9HY6LZEH67vzsJ5k X-Received: by 2002:a17:902:db03:b0:1bd:f314:7896 with SMTP id m3-20020a170902db0300b001bdf3147896mr638083plx.25.1694546679415; Tue, 12 Sep 2023 12:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694546679; cv=none; d=google.com; s=arc-20160816; b=bPpphawyaAgumiZuYxLEXE17NmDVestRRJVynI6F/CZy0q6I5uZl6I+RjeBNhX0LGa fDYfuLmdo3noGWBK/6vEUBJC5qfO4CZCIy6CcncE3n2qy4Bbs4MmRngM/HGJ8r+L61HS XyFiY01HnuKV0X3TveAJVqwwq6skA1XQ4ETlcJTw3an67pvITvkkflzXuSUTS9u3H/xv DzImyqjn5bXzLbea2MEiftvr0lmie4us0nVrSXRrKSQdrRIqovBc3Lm4fypYGAjOByHs p59wNT4U283RKpeR2wLXNUj6IgieRMkHNu88jWFwtcc8+tt/LYzGWfROhr6LuVxRJ3n1 w2dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EqLslZ2IpeL26Xg5SufuITXQb4lOmt+bkcLgkdLrkFY=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=AWdus6prBuTqIqQync5q4GQkURYg2oUhWmxO/tUY/DK0OVESn4q+YqXz/M2lU/tmQ3 mlDC2Ir130SbSjbQ2QI14wyyg+sT+NL+yUtRslx4qnFheg/oVy20MGzvTaqXE2GeigQh wMT5vD14RRIXa5hC97HtebuuzyGgiJ0wy+/IkpT5Zcd82s8zWZJqP5KZyPReF0iVonmS eIOOSYzPk4zIVJOwmM7ZpinMqTrCiNeMRiBTFIxPMf0MWSFhrkH2XCuKMYC2A+e6ILy3 rOMCsdwxCVSoebh52SltOs/pOfahNY81gNkcPrDaABQCPEkd9k+D9pUoI1CDrnv1sJXS dhTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PIfFuFBe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id kq4-20020a170903284400b001bb324569efsi8194198plb.364.2023.09.12.12.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 12:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PIfFuFBe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 755C5875F49C; Tue, 12 Sep 2023 10:51:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237361AbjILRvk (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236914AbjILRvY (ORCPT ); Tue, 12 Sep 2023 13:51:24 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F5F10D3 for ; Tue, 12 Sep 2023 10:51:20 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68fb5bd8f02so2459367b3a.0 for ; Tue, 12 Sep 2023 10:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541080; x=1695145880; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EqLslZ2IpeL26Xg5SufuITXQb4lOmt+bkcLgkdLrkFY=; b=PIfFuFBeOWLV0PQJyHX8taiBXc+t9aXmA4HBP2SR8pm+63C+XxQRrz47fLAOOoAkyu fiSAogVX0SSK+dTgGKeNfTUMrcHocnusVr02hhOJb6vgexVlQRXUuIKiqIFVTKeqc1Vq W0kc8dStJG4PCfUPT3xeQSiEifuxmU3205/AVJgByjsutManuvJ1QKhchOxbevSdTcSP eI2vrH1OnAWnxngyMYFBP+ZNujxQg6RYXEhZPFUo71j0STiRXmGk5r6Lq/M7HEPN94jk Q7gLF7gPOqGHSR5PQkbOCkgtIpvsB9exI6nhQ3u3RX7sH9tj/DDJmpAplxXtuTinHfGc rYhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541080; x=1695145880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EqLslZ2IpeL26Xg5SufuITXQb4lOmt+bkcLgkdLrkFY=; b=aDlGy/MBDKYLYDhg9oR6SY/MMMdlBMRuXQuaJJmGS+DnUjuoQqe1+8NjCRnn1JnYpX xEZ3MUmzFcE6F8ZkYcMRSAaw0sm99H8HVTOjnxkwYvhlQvT5POoJoqP6FSgQt5bLR1WX bMbAStZEkqVdsyytadDey9ZrapF0U/zc0R30orcudhKuLTbWDIinp010mdx3my+3XQKB XAKb49wzO5uVpnhqkcalG52G/TRH+l1JAIHBnwvJuSE/muNv8fIla2JnAUZwi6OfKevx hoAJzNXNBmCZ0mLc9n26b5io8fDyw6ZjRicphHU99JqZZ+eH7z0SMKzlR5z4Z+QROxkz de7g== X-Gm-Message-State: AOJu0Yzp6nx+/y5icVkTosIaJGBJ7mjGZ/ecKoiDBYkVrefhntxNVrU+ V77fZ44s2HXoHUWSEa40Y467Yw== X-Received: by 2002:a05:6a20:ce91:b0:14b:f9b2:eb7 with SMTP id if17-20020a056a20ce9100b0014bf9b20eb7mr103534pzb.59.1694541079814; Tue, 12 Sep 2023 10:51:19 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:19 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 10/16] irqchip/riscv-imsic: Add support for platform MSI irqdomain Date: Tue, 12 Sep 2023 23:19:22 +0530 Message-Id: <20230912174928.528414-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776860978816207480 X-GMAIL-MSGID: 1776860978816207480 The Linux platform MSI support requires a platform MSI irqdomain so let us add a platform irqchip driver for RISC-V IMSIC which provides a base IRQ domain and platform MSI domain. This driver assumes that the IMSIC state is already initialized by the IMSIC early driver. Signed-off-by: Anup Patel --- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-riscv-imsic-platform.c | 280 +++++++++++++++++++++ 2 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-riscv-imsic-platform.c diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index d714724387ce..abca445a3229 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -95,7 +95,7 @@ obj-$(CONFIG_QCOM_MPM) += irq-qcom-mpm.o obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o -obj-$(CONFIG_RISCV_IMSIC) += irq-riscv-imsic-state.o irq-riscv-imsic-early.o +obj-$(CONFIG_RISCV_IMSIC) += irq-riscv-imsic-state.o irq-riscv-imsic-early.o irq-riscv-imsic-platform.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o obj-$(CONFIG_IMX_INTMUX) += irq-imx-intmux.o diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c new file mode 100644 index 000000000000..b78f1b2ee3dc --- /dev/null +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -0,0 +1,280 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "irq-riscv-imsic-state.h" + +static int imsic_cpu_page_phys(unsigned int cpu, + unsigned int guest_index, + phys_addr_t *out_msi_pa) +{ + struct imsic_global_config *global; + struct imsic_local_config *local; + + global = &imsic->global; + local = per_cpu_ptr(global->local, cpu); + + if (BIT(global->guest_index_bits) <= guest_index) + return -EINVAL; + + if (out_msi_pa) + *out_msi_pa = local->msi_pa + + (guest_index * IMSIC_MMIO_PAGE_SZ); + + return 0; +} + +static int imsic_get_cpu(const struct cpumask *mask_val, bool force, + unsigned int *out_target_cpu) +{ + unsigned int cpu; + + if (force) + cpu = cpumask_first(mask_val); + else + cpu = cpumask_any_and(mask_val, cpu_online_mask); + + if (cpu >= nr_cpu_ids) + return -EINVAL; + + if (out_target_cpu) + *out_target_cpu = cpu; + + return 0; +} + +static void imsic_irq_mask(struct irq_data *d) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + bitmap_clear(imsic->ids_enabled_bimap, d->hwirq, 1); + __imsic_id_disable(d->hwirq); + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); + + imsic_ids_remote_sync(); +} + +static void imsic_irq_unmask(struct irq_data *d) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&imsic->ids_lock, flags); + bitmap_set(imsic->ids_enabled_bimap, d->hwirq, 1); + __imsic_id_enable(d->hwirq); + raw_spin_unlock_irqrestore(&imsic->ids_lock, flags); + + imsic_ids_remote_sync(); +} + +static void imsic_irq_compose_msi_msg(struct irq_data *d, + struct msi_msg *msg) +{ + phys_addr_t msi_addr; + unsigned int cpu; + int err; + + cpu = imsic_id_get_target(d->hwirq); + if (WARN_ON(cpu == UINT_MAX)) + return; + + err = imsic_cpu_page_phys(cpu, 0, &msi_addr); + if (WARN_ON(err)) + return; + + msg->address_hi = upper_32_bits(msi_addr); + msg->address_lo = lower_32_bits(msi_addr); + msg->data = d->hwirq; +} + +#ifdef CONFIG_SMP +static int imsic_irq_set_affinity(struct irq_data *d, + const struct cpumask *mask_val, + bool force) +{ + unsigned int target_cpu; + int rc; + + rc = imsic_get_cpu(mask_val, force, &target_cpu); + if (rc) + return rc; + + imsic_id_set_target(d->hwirq, target_cpu); + irq_data_update_effective_affinity(d, cpumask_of(target_cpu)); + + return IRQ_SET_MASK_OK; +} +#endif + +static struct irq_chip imsic_irq_base_chip = { + .name = "IMSIC-BASE", + .irq_mask = imsic_irq_mask, + .irq_unmask = imsic_irq_unmask, +#ifdef CONFIG_SMP + .irq_set_affinity = imsic_irq_set_affinity, +#endif + .irq_compose_msi_msg = imsic_irq_compose_msi_msg, + .flags = IRQCHIP_SKIP_SET_WAKE | + IRQCHIP_MASK_ON_SUSPEND, +}; + +static int imsic_irq_domain_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + int i, hwirq, err = 0; + unsigned int cpu; + + err = imsic_get_cpu(cpu_online_mask, false, &cpu); + if (err) + return err; + + hwirq = imsic_ids_alloc(get_count_order(nr_irqs)); + if (hwirq < 0) + return hwirq; + + for (i = 0; i < nr_irqs; i++) { + imsic_id_set_target(hwirq + i, cpu); + irq_domain_set_info(domain, virq + i, hwirq + i, + &imsic_irq_base_chip, imsic, + handle_simple_irq, NULL, NULL); + irq_set_noprobe(virq + i); + irq_set_affinity(virq + i, cpu_online_mask); + /* + * IMSIC does not implement irq_disable() so Linux interrupt + * subsystem will take a lazy approach for disabling an IMSIC + * interrupt. This means IMSIC interrupts are left unmasked + * upon system suspend and interrupts are not processed + * immediately upon system wake up. To tackle this, we disable + * the lazy approach for all IMSIC interrupts. + */ + irq_set_status_flags(virq + i, IRQ_DISABLE_UNLAZY); + } + + return 0; +} + +static void imsic_irq_domain_free(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + + imsic_ids_free(d->hwirq, get_count_order(nr_irqs)); + irq_domain_free_irqs_parent(domain, virq, nr_irqs); +} + +static const struct irq_domain_ops imsic_base_domain_ops = { + .alloc = imsic_irq_domain_alloc, + .free = imsic_irq_domain_free, +}; + +static struct irq_chip imsic_plat_irq_chip = { + .name = "IMSIC-PLAT", +}; + +static struct msi_domain_ops imsic_plat_domain_ops = { +}; + +static struct msi_domain_info imsic_plat_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS), + .ops = &imsic_plat_domain_ops, + .chip = &imsic_plat_irq_chip, +}; + +static int imsic_irq_domains_init(struct device *dev) +{ + /* Create Base IRQ domain */ + imsic->base_domain = irq_domain_create_tree(dev->fwnode, + &imsic_base_domain_ops, imsic); + if (!imsic->base_domain) { + dev_err(dev, "failed to create IMSIC base domain\n"); + return -ENOMEM; + } + irq_domain_update_bus_token(imsic->base_domain, DOMAIN_BUS_NEXUS); + + /* Create Platform MSI domain */ + imsic->plat_domain = platform_msi_create_irq_domain(dev->fwnode, + &imsic_plat_domain_info, + imsic->base_domain); + if (!imsic->plat_domain) { + dev_err(dev, "failed to create IMSIC platform domain\n"); + irq_domain_remove(imsic->base_domain); + return -ENOMEM; + } + + return 0; +} + +static int imsic_platform_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct imsic_global_config *global; + int rc; + + if (!imsic) { + dev_err(dev, "early driver not probed\n"); + return -ENODEV; + } + + if (imsic->base_domain) { + dev_err(dev, "irq domain already created\n"); + return -ENODEV; + } + + global = &imsic->global; + + /* Initialize IRQ and MSI domains */ + rc = imsic_irq_domains_init(dev); + if (rc) { + dev_err(dev, "failed to initialize IRQ and MSI domains\n"); + return rc; + } + + dev_info(dev, " hart-index-bits: %d, guest-index-bits: %d\n", + global->hart_index_bits, global->guest_index_bits); + dev_info(dev, " group-index-bits: %d, group-index-shift: %d\n", + global->group_index_bits, global->group_index_shift); + dev_info(dev, " mapped %d interrupts at base PPN %pa\n", + global->nr_ids, &global->base_addr); + + return 0; +} + +static const struct of_device_id imsic_platform_match[] = { + { .compatible = "riscv,imsics" }, + {} +}; + +static struct platform_driver imsic_platform_driver = { + .driver = { + .name = "riscv-imsic", + .of_match_table = imsic_platform_match, + }, + .probe = imsic_platform_probe, +}; + +static int __init imsic_platform_init(void) +{ + /* + * Register IMSIC driver as early as possible so that IMSIC + * platform device is probed as soon as it is created. + */ + return platform_driver_register(&imsic_platform_driver); +} +core_initcall(imsic_platform_init); From patchwork Tue Sep 12 17:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp893937vqx; Tue, 12 Sep 2023 23:48:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBwzIhvz84F/+uryBnSqHM/U2h5EWUErXFj4n3UVLOv+xXAiolFrKum7SD0KNWJiubrwfj X-Received: by 2002:a05:620a:214a:b0:76f:19fd:5064 with SMTP id m10-20020a05620a214a00b0076f19fd5064mr1620909qkm.33.1694587691388; Tue, 12 Sep 2023 23:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694587691; cv=none; d=google.com; s=arc-20160816; b=ckl4w18dmtBdJkhY6lFEAGjpKmUcJ4RduvCwVsmX2U3XigaJGa0fc3Qb+dz6TU4y0z wuHsz8mU4+ZQeFIvmaOPMRb9M/rCs5fYp3Y5bHFx31LkFKBENTe4QUKGCDFENxKEqp14 GuKCsMFfw2sB5nfxsiI36N8obgj7SbR0KXHxo3dA5k+R4jsKPiOe3T4p3HS86PlXJOKd IHZcTiOeKEbNec59t5S0CFB8n7glxu/Inv63mAPNI5+aRZhiGu99ed1eFNTdhR5Fsggp ZQqKD2Iz3ZW4/uLd0qjGWZmkq03RNaX6dgv5UWmY3uCtqL+megBuXNrj5YlLzU2YKGa/ xVSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ULAM2cjqGNSNlXEqRgMaXwaIHenoZQcGTorSa/ElLrs=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=v+U62TVem9aobbPZGG1Ej7q/mkdf6I6lMvlbmQQN1IoAEBtQTNobMJHAX7BgiHCI0u RJvvZZVrnavQURq0crsGAVBH4LW7NVu3/+nEvjipx8Z4HuCU+EHxIspddCzWDzMTTw7S TkuEwfCHj1SZgZKIAA4c44/Zh9Ay73TiuKkh2HDOMwSPfrifN5unFes2nriXRv/OqxFu dzBVe8Tf+dkAgUb2D63dFXgO3GVzz+cpA9JLH4Qmi6J2MZT1q/wSaBuG758r5QioZW8c HcoEKUOq4k8hyvR2LYhdLjiZAClZFx97d8j20J/0M8FixiJV1LiEyg5TrGl11MdhOB/V rJ2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=h+5i2yKb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u12-20020a65670c000000b0056963f23048si9229586pgf.84.2023.09.12.23.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 23:48:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=h+5i2yKb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B020880CD702; Tue, 12 Sep 2023 10:51:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237233AbjILRvz (ORCPT + 36 others); Tue, 12 Sep 2023 13:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237209AbjILRva (ORCPT ); Tue, 12 Sep 2023 13:51:30 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 752A5172C for ; Tue, 12 Sep 2023 10:51:26 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c06f6f98c0so50041425ad.3 for ; Tue, 12 Sep 2023 10:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541086; x=1695145886; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ULAM2cjqGNSNlXEqRgMaXwaIHenoZQcGTorSa/ElLrs=; b=h+5i2yKbgAk0GYhbNKmFzThzcxUXB48Qb2fo3LabLppdwJDQG/d+CB4TJHi+WGMLAp hVIlxYzVRtBsnZ6OFdNMh3ZxrEz3xRChy8OF55RGA/rCQhT+F3L3qymAQr/6BegXFJvq XEzoXM4c0MSDeiwHQkvrr2vPxJO4w6HaFWxJJuH7E098jHj74KxgqGS9xuPyNrghiLZH y5kqPL/HBraA3Y/G8XISxiFELRD/rHpnBLXScNsZ3eRUOByfR60lfpZy3IgwHkDjuyrj f/JqUko9g6qc0/jDBmo/bNhBRAFHOCEFgp6pWhXYGvX7JXmU5TP+dkKWseiUTSlVL9Ig 4APA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541086; x=1695145886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ULAM2cjqGNSNlXEqRgMaXwaIHenoZQcGTorSa/ElLrs=; b=KOS9RNpZKwxAqQ7c7KPrwaaVUQtdwVSjUUcWP1XBUtU6CnM1HSyo3kKN3gmDJfiK9E zoWtcL7ulHoAr8emhUxUqlYAXOGCH1UU2SI1JTFIHY3knd8uk6zRqninXoUHLbUd9aF1 6ih6X1bt4yf338fkb1d+ypctjPp/YqZYOKBJibWdn/wFedYnaNVYZ2e0WS+YrtM8CFlc XpGIvFl69a5FMV4ZQuzbgq1bAyXh8XzCM0FdXo/FZOz9Q3s+ZDrekz9MDDX+vb77bMfo hBXyDQC0RnJ4JEV9O+3WYCx0Kd7RDbNp+IM21FSoc5TblTE6IHDyy3iVmaX9t599wwSq w3mQ== X-Gm-Message-State: AOJu0YzJCkNYZIZCNAoU90ulLyLY3Xv7zuGK2rX8wdB27UW2NoR1mLc4 gBMTlGbbfVt2W068ZlnDfQvbBQ== X-Received: by 2002:a17:902:b697:b0:1c3:d864:d6a8 with SMTP id c23-20020a170902b69700b001c3d864d6a8mr489453pls.23.1694541085840; Tue, 12 Sep 2023 10:51:25 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:25 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 11/16] irqchip/riscv-imsic: Add support for PCI MSI irqdomain Date: Tue, 12 Sep 2023 23:19:23 +0530 Message-Id: <20230912174928.528414-12-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:51:58 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776903982795622502 X-GMAIL-MSGID: 1776903982795622502 The Linux PCI framework requires it's own dedicated MSI irqdomain so let us create PCI MSI irqdomain as child of the IMSIC base irqdomain. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 7 ++++ drivers/irqchip/irq-riscv-imsic-platform.c | 48 ++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.h | 1 + 3 files changed, 56 insertions(+) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index ee99aacbefcc..a6aad78076a0 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -551,6 +551,13 @@ config RISCV_IMSIC select IRQ_DOMAIN_HIERARCHY select GENERIC_MSI_IRQ +config RISCV_IMSIC_PCI + bool + depends on RISCV_IMSIC + depends on PCI + depends on PCI_MSI + default RISCV_IMSIC + config EXYNOS_IRQ_COMBINER bool "Samsung Exynos IRQ combiner support" if COMPILE_TEST depends on (ARCH_EXYNOS && ARM) || COMPILE_TEST diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index b78f1b2ee3dc..ff737b4e195f 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -184,6 +185,39 @@ static const struct irq_domain_ops imsic_base_domain_ops = { .free = imsic_irq_domain_free, }; +#ifdef CONFIG_RISCV_IMSIC_PCI + +static void imsic_pci_mask_irq(struct irq_data *d) +{ + pci_msi_mask_irq(d); + irq_chip_mask_parent(d); +} + +static void imsic_pci_unmask_irq(struct irq_data *d) +{ + pci_msi_unmask_irq(d); + irq_chip_unmask_parent(d); +} + +static struct irq_chip imsic_pci_irq_chip = { + .name = "IMSIC-PCI", + .irq_mask = imsic_pci_mask_irq, + .irq_unmask = imsic_pci_unmask_irq, + .irq_eoi = irq_chip_eoi_parent, +}; + +static struct msi_domain_ops imsic_pci_domain_ops = { +}; + +static struct msi_domain_info imsic_pci_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX | MSI_FLAG_MULTI_PCI_MSI), + .ops = &imsic_pci_domain_ops, + .chip = &imsic_pci_irq_chip, +}; + +#endif + static struct irq_chip imsic_plat_irq_chip = { .name = "IMSIC-PLAT", }; @@ -208,12 +242,26 @@ static int imsic_irq_domains_init(struct device *dev) } irq_domain_update_bus_token(imsic->base_domain, DOMAIN_BUS_NEXUS); +#ifdef CONFIG_RISCV_IMSIC_PCI + /* Create PCI MSI domain */ + imsic->pci_domain = pci_msi_create_irq_domain(dev->fwnode, + &imsic_pci_domain_info, + imsic->base_domain); + if (!imsic->pci_domain) { + dev_err(dev, "failed to create IMSIC PCI domain\n"); + irq_domain_remove(imsic->base_domain); + return -ENOMEM; + } +#endif + /* Create Platform MSI domain */ imsic->plat_domain = platform_msi_create_irq_domain(dev->fwnode, &imsic_plat_domain_info, imsic->base_domain); if (!imsic->plat_domain) { dev_err(dev, "failed to create IMSIC platform domain\n"); + if (imsic->pci_domain) + irq_domain_remove(imsic->pci_domain); irq_domain_remove(imsic->base_domain); return -ENOMEM; } diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 3170018949a8..ff3c377b9b33 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -31,6 +31,7 @@ struct imsic_priv { /* IRQ domains (created by platform driver) */ struct irq_domain *base_domain; + struct irq_domain *pci_domain; struct irq_domain *plat_domain; }; From patchwork Tue Sep 12 17:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138382 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp615969vqx; Tue, 12 Sep 2023 11:58:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgwUjbMQC+f9UyRp5dmpGDvlrfxXl5SfWvxUgTBGWfbMvlATj6IoBKYl1BNARV1Hq9MKSe X-Received: by 2002:a17:90a:6c63:b0:268:dd0:3497 with SMTP id x90-20020a17090a6c6300b002680dd03497mr179568pjj.7.1694545088721; Tue, 12 Sep 2023 11:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694545088; cv=none; d=google.com; s=arc-20160816; b=BsZcMMGeRFrgOZbzD+BVjfNnjf879hKuqpKNPMuJ2CW3Yhyq5D4djknRrMVEEzd7xH lddqF2oXsPVKtFf9/9p0dEa58QQkwPYHR83DKOPEmUlzo9wP3nikVvx4iPviBbAHz92c RJPz5wA1SjY+KaWRpPewraShy1wIaD/8G0fk+5Mz9ROhBsXO5pb6whOx+r/cA6MnkBY9 AcDjebEA5w0AJFmo1CdpXzOpM5NgeWO/QvSrT5JPlJbfztsINXcYk/CGFfe3OOTqJhn5 oNTNhu1xnF/TZA7eBFuzWQjtleEY+gkzMqrpATkf/y2ElA/Df3BZZ7HwjskLmxQ7VrtO D1Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TYQsgV6mmNiNxm7fkk00HaM0IkP9BeYIjrigTOut9Eg=; fh=bYfFSU2XTEItRctk+6nchXKOSKHpgc6pltayodDbw3U=; b=BocNDtN4SubSsBnemIc5hMJMyweRLTsVI4y+WsBPtSidDfKb0ROKxqnEKHJKtWkEle YvVv9E/xfYgpygTqF5vaoyz4/p6MXSJo0ERJPYNjMZBDhXh6VRCenE9W3Nso0kELUub+ 0hpAKotmpiYJI4xBX3Qdc07WDpnRpILTNPFq2m9IA2/7ZdLLyj45SgLPoPx4P2/IgjsR 4MveHCrAZKujeJp36mSNzmUrhUuH0Y8yNZ2u7xDiT6E4hrKWlsRtEmf/6jE5nTxIODr9 5yKbFfckh8YveMc6iSwWiUXoCi1cOEnpPpPDldhhks+tz7MU5utDYqky7DPK1vPk6Vwh 2Zww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="gazS/kcV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id l4-20020a17090a660400b0026d41496190si10320374pjj.85.2023.09.12.11.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="gazS/kcV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A99028292A6C; Tue, 12 Sep 2023 10:53:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237352AbjILRwF (ORCPT + 36 others); Tue, 12 Sep 2023 13:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237334AbjILRvg (ORCPT ); Tue, 12 Sep 2023 13:51:36 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB17719B2 for ; Tue, 12 Sep 2023 10:51:32 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c09673b006so40873325ad.1 for ; Tue, 12 Sep 2023 10:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541092; x=1695145892; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TYQsgV6mmNiNxm7fkk00HaM0IkP9BeYIjrigTOut9Eg=; b=gazS/kcVcpT83/pir3gVYGfdwUEyLAVd6E+K4MLbU+lqdtTd0fTdV8OuEwqxdONNg5 UZQdtwR+h9BCtet4burnj91W/cYk03xn23mvnsg4ZvKolxyoD2dzsUMDtXLkPqefw2IK YyjKMpUlQ/Oi2VYJpYv2jIa3wooBnMu4RjF983ZGHWsx3fthREHT8MQAlE0+4ZJtx0/2 8cEARuv3pB3OQsM95ODxCFcFpGwxT6zVK/gI2O6YDX9VUsDk6XhM6syp+CgkXCZ7kMXS g500CAzA7rVBeTySN1QgI0hshrtyYMFJO1mZG2EyKlmI26/76hU6MSXbDibMJhL2wv71 c+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541092; x=1695145892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TYQsgV6mmNiNxm7fkk00HaM0IkP9BeYIjrigTOut9Eg=; b=CuqUN45TS2uOuoBWk3zYR7npRsznWbRUy6dYD8cfjCYGScH2TIyVlwaN7VCUHgyLZX mQtoPipodJTNzo0LWY4ECDRRKdmodVwaRtAPVx5+gC+6CFzbGQARThXRI0KmpMJiXCnd CJyD8Q5asslsTE2i02L8DgxyIcvW+mRd2WKN9JWYm9TFhOay7q8zD5lBY2Nu4uXBOqaS sZA2th2mqFw6IIiqmH91QZ54zDZky332ExfpkhsjxIzEZYFfI6OHrqlBcS35vY0n8rBb dQeDvIgiuBv1XqZbZA0pCpKgbCoTWYpqXAyuME4zYzo1R2a+fo/g8OHywOKMDJn7J63h N4cw== X-Gm-Message-State: AOJu0Yx3jDMnYHX9bAiTRZ9yaMGfYG3PEphMKOYWoTJkPemLZJrTUDeZ HMNFOHBUmYdEHPs8wOw43L6C2Q== X-Received: by 2002:a17:903:22c9:b0:1c0:9d6f:9d28 with SMTP id y9-20020a17090322c900b001c09d6f9d28mr598157plg.11.1694541092104; Tue, 12 Sep 2023 10:51:32 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:31 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel , Conor Dooley Subject: [PATCH v8 12/16] dt-bindings: interrupt-controller: Add RISC-V advanced PLIC Date: Tue, 12 Sep 2023 23:19:24 +0530 Message-Id: <20230912174928.528414-13-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:53:47 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776859311234979874 X-GMAIL-MSGID: 1776859311234979874 We add DT bindings document for RISC-V advanced platform level interrupt controller (APLIC) defined by the RISC-V advanced interrupt architecture (AIA) specification. Signed-off-by: Anup Patel Reviewed-by: Conor Dooley --- .../interrupt-controller/riscv,aplic.yaml | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml b/Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml new file mode 100644 index 000000000000..190a6499c932 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml @@ -0,0 +1,172 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/riscv,aplic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V Advanced Platform Level Interrupt Controller (APLIC) + +maintainers: + - Anup Patel + +description: + The RISC-V advanced interrupt architecture (AIA) defines an advanced + platform level interrupt controller (APLIC) for handling wired interrupts + in a RISC-V platform. The RISC-V AIA specification can be found at + https://github.com/riscv/riscv-aia. + + The RISC-V APLIC is implemented as hierarchical APLIC domains where all + interrupt sources connect to the root APLIC domain and a parent APLIC + domain can delegate interrupt sources to it's child APLIC domains. There + is one device tree node for each APLIC domain. + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + items: + - enum: + - qemu,aplic + - const: riscv,aplic + + reg: + maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + + interrupts-extended: + minItems: 1 + maxItems: 16384 + description: + Given APLIC domain directly injects external interrupts to a set of + RISC-V HARTS (or CPUs). Each node pointed to should be a riscv,cpu-intc + node, which has a CPU node (i.e. RISC-V HART) as parent. + + msi-parent: + description: + Given APLIC domain forwards wired interrupts as MSIs to a AIA incoming + message signaled interrupt controller (IMSIC). If both "msi-parent" and + "interrupts-extended" properties are present then it means the APLIC + domain supports both MSI mode and Direct mode in HW. In this case, the + APLIC driver has to choose between MSI mode or Direct mode. + + riscv,num-sources: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 1 + maximum: 1023 + description: + Specifies the number of wired interrupt sources supported by this + APLIC domain. + + riscv,children: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + maxItems: 1024 + items: + maxItems: 1 + description: + A list of child APLIC domains for the given APLIC domain. Each child + APLIC domain is assigned a child index in increasing order, with the + first child APLIC domain assigned child index 0. The APLIC domain child + index is used by firmware to delegate interrupts from the given APLIC + domain to a particular child APLIC domain. + + riscv,delegation: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + maxItems: 1024 + items: + items: + - description: child APLIC domain phandle + - description: first interrupt number of the parent APLIC domain (inclusive) + - description: last interrupt number of the parent APLIC domain (inclusive) + description: + A interrupt delegation list where each entry is a triple consisting + of child APLIC domain phandle, first interrupt number of the parent + APLIC domain, and last interrupt number of the parent APLIC domain. + Firmware must configure interrupt delegation registers based on + interrupt delegation list. + +dependencies: + riscv,delegation: [ "riscv,children" ] + +required: + - compatible + - reg + - interrupt-controller + - "#interrupt-cells" + - riscv,num-sources + +anyOf: + - required: + - interrupts-extended + - required: + - msi-parent + +unevaluatedProperties: false + +examples: + - | + // Example 1 (APLIC domains directly injecting interrupt to HARTs): + + interrupt-controller@c000000 { + compatible = "qemu,aplic", "riscv,aplic"; + interrupts-extended = <&cpu1_intc 11>, + <&cpu2_intc 11>, + <&cpu3_intc 11>, + <&cpu4_intc 11>; + reg = <0xc000000 0x4080>; + interrupt-controller; + #interrupt-cells = <2>; + riscv,num-sources = <63>; + riscv,children = <&aplic1>, <&aplic2>; + riscv,delegation = <&aplic1 1 63>; + }; + + aplic1: interrupt-controller@d000000 { + compatible = "qemu,aplic", "riscv,aplic"; + interrupts-extended = <&cpu1_intc 9>, + <&cpu2_intc 9>; + reg = <0xd000000 0x4080>; + interrupt-controller; + #interrupt-cells = <2>; + riscv,num-sources = <63>; + }; + + aplic2: interrupt-controller@e000000 { + compatible = "qemu,aplic", "riscv,aplic"; + interrupts-extended = <&cpu3_intc 9>, + <&cpu4_intc 9>; + reg = <0xe000000 0x4080>; + interrupt-controller; + #interrupt-cells = <2>; + riscv,num-sources = <63>; + }; + + - | + // Example 2 (APLIC domains forwarding interrupts as MSIs): + + interrupt-controller@c000000 { + compatible = "qemu,aplic", "riscv,aplic"; + msi-parent = <&imsic_mlevel>; + reg = <0xc000000 0x4000>; + interrupt-controller; + #interrupt-cells = <2>; + riscv,num-sources = <63>; + riscv,children = <&aplic3>; + riscv,delegation = <&aplic3 1 63>; + }; + + aplic3: interrupt-controller@d000000 { + compatible = "qemu,aplic", "riscv,aplic"; + msi-parent = <&imsic_slevel>; + reg = <0xd000000 0x4000>; + interrupt-controller; + #interrupt-cells = <2>; + riscv,num-sources = <63>; + }; +... From patchwork Tue Sep 12 17:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp816175vqx; Tue, 12 Sep 2023 19:50:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL17gv1UzI/mkxgErFyxuJLNVrF7aU7bHykQQ78REiaOEVWAwaIP33D3igk8bmt3mCVCAV X-Received: by 2002:a05:6871:150:b0:1b7:8836:95c9 with SMTP id z16-20020a056871015000b001b7883695c9mr1438305oab.42.1694573410031; Tue, 12 Sep 2023 19:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694573409; cv=none; d=google.com; s=arc-20160816; b=uOdFs7REujOIcnl40e9cKWBjjmq6xEpquLHEVlgVoCIOBrWn8Ym3OJbCx878R47Ful MVRRCLia0MQZEK1zuW5rTeQRVJiY0JuvZeDrqdElvA1LHHl6AZ3gaKXH1nK1uDRoMSl5 iF0hqL03z8HRt+b4xMaMKXgcCeChIqRuwsy3gEehWUE+l4gFtQZj+wSb9+yfkkJCVoz3 MyifnlKNrvhYtAo0zfFuerBOqxwUP+MCZ21ljnlX41X2+jwgu4VZzK2wQjb4DB4/+g7M FMnYKaiTUSVVoChDG4bwhWC3GhKzjOVBHuMSiUSnu9RlnNIBRW3zpTArYTPO4sM4+27P TiWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7fI6y7KNasG96FyDZj1Te7Lxf3AIUVL5IbYABbFYeqY=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=RE1XPEaoNuEIvSF17RSfuiipHfqm235GlPDuSNgHPGUDDBDt/3yZUz2oAqlFqpLU3d SHY94KhO0z1FgpPCHWEAbc6dxeY+Nu/Axe3YD4m2ytEUGAeexe4+re5lJczfoc2rJOrT fpPEFXJPRQWc9/WsUMT7sT7yFPqk/DaLcdhu+hFeUtv/MwoJN3ITt3WR0ha2ikCR3XJ+ IP0jV6cqsCSbforZKhB98Ue+8rZnBFP2zuJi1KUrWOhCPBP0EfeRo8B6uNbN+lqoTeqZ Ri4PrZknndXzz68z2Noc3cvVn1x3kOqjvPwRoEWKR7RR9dAh3ZhRuWS1466FnaeZFmsw M/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=QNmkpDMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id az1-20020a056a02004100b00565eee2d0fesi6594728pgb.324.2023.09.12.19.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 19:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=QNmkpDMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 654588031C5B; Tue, 12 Sep 2023 10:52:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237216AbjILRwN (ORCPT + 36 others); Tue, 12 Sep 2023 13:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237189AbjILRvx (ORCPT ); Tue, 12 Sep 2023 13:51:53 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1381719 for ; Tue, 12 Sep 2023 10:51:38 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c3d8fb23d9so6784905ad.0 for ; Tue, 12 Sep 2023 10:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541098; x=1695145898; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7fI6y7KNasG96FyDZj1Te7Lxf3AIUVL5IbYABbFYeqY=; b=QNmkpDMgZHF3uqsOB95/SVbJsMQkWQ8889vIw8uyT76852EP9xaBkX7QwyQ+iOeaFz PxpRgJB0G21HN99DKMNu6cQDnuXPzofticz8Ft/xEFWtXyElH6w+35AJYS5pniDj3S7x lG5UEaNh2HhJwpXUxO6OugAR79EMRfQvDcSiPXRVflUxF9X31bW2ZXiE1UFod4+rbic0 QgXbf9c5xsF/tSi8rSZFnfE1lKGd8VqE7LdnomR+UEBgb/UzeUNehlDl6gCPro1B70s2 rF3PJKAKKSImZ8nG+RXu+ACinAkRBAud/OF7vzSp7DQf9d67EfBX5qL9Gt1K6lWstfXX 8eoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541098; x=1695145898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7fI6y7KNasG96FyDZj1Te7Lxf3AIUVL5IbYABbFYeqY=; b=DJ7WMEEpqNUJYod0tf78P9tKDmEKoHHXgXzu8XtmogQDum1R9E1jHSQX4AIOod/OjL yRt1kr4xWVxO0q5QVE4qX/5gVdtPH/2F/W7u3ijtnLn5LJsH0IPAAtO+MIkIgk2yKTuy FsS+9mp0qcfv1JHFez0WDWwurlbKinQ/jy7iM34duiNZRTuHXKCpk8LKPDrgXazWuJbn Z65DbVC56e0qJ27tG9uFN2n2pMZlXURmYma04vnJByjzsOvTtvmExsKe420z9NIRWD2f LyMS93xYC6OyW/rdAM2t9FzrAd+dqZa4H9EfyjBjy8oHRz2KwnfqMiuhC2wcLteNf61C JDtg== X-Gm-Message-State: AOJu0YyDYVU59qQQPKFfMaowHKPtn2Dutt+ioF0hqjBtgjnMbGYz33hX EJqc7kuistp8gW90mWeYHA3YWg== X-Received: by 2002:a17:903:1105:b0:1c3:8679:6ed4 with SMTP id n5-20020a170903110500b001c386796ed4mr620764plh.8.1694541098124; Tue, 12 Sep 2023 10:51:38 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:37 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 13/16] irqchip: Add RISC-V advanced PLIC driver for direct-mode Date: Tue, 12 Sep 2023 23:19:25 +0530 Message-Id: <20230912174928.528414-14-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:52:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776889008170285807 X-GMAIL-MSGID: 1776889008170285807 The RISC-V advanced interrupt architecture (AIA) specification defines advanced platform-level interrupt controller (APLIC) which has two modes of operation: 1) Direct mode and 2) MSI mode. (For more details, refer https://github.com/riscv/riscv-aia) In APLIC direct-mode, wired interrupts are forwared to CPUs (or HARTs) as a local external interrupt. We add a platform irqchip driver for the RISC-V APLIC direct-mode to support RISC-V platforms having only wired interrupts. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-riscv-aplic-direct.c | 326 +++++++++++++++++++++++ drivers/irqchip/irq-riscv-aplic-main.c | 240 +++++++++++++++++ drivers/irqchip/irq-riscv-aplic-main.h | 45 ++++ include/linux/irqchip/riscv-aplic.h | 119 +++++++++ 6 files changed, 736 insertions(+) create mode 100644 drivers/irqchip/irq-riscv-aplic-direct.c create mode 100644 drivers/irqchip/irq-riscv-aplic-main.c create mode 100644 drivers/irqchip/irq-riscv-aplic-main.h create mode 100644 include/linux/irqchip/riscv-aplic.h diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index a6aad78076a0..44c455084d09 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -545,6 +545,11 @@ config SIFIVE_PLIC select IRQ_DOMAIN_HIERARCHY select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP +config RISCV_APLIC + bool + depends on RISCV + select IRQ_DOMAIN_HIERARCHY + config RISCV_IMSIC bool depends on RISCV diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index abca445a3229..7f8289790ed8 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -95,6 +95,7 @@ obj-$(CONFIG_QCOM_MPM) += irq-qcom-mpm.o obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o +obj-$(CONFIG_RISCV_APLIC) += irq-riscv-aplic-main.o irq-riscv-aplic-direct.o obj-$(CONFIG_RISCV_IMSIC) += irq-riscv-imsic-state.o irq-riscv-imsic-early.o irq-riscv-imsic-platform.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq-riscv-aplic-direct.c new file mode 100644 index 000000000000..e36d655a1490 --- /dev/null +++ b/drivers/irqchip/irq-riscv-aplic-direct.c @@ -0,0 +1,326 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "irq-riscv-aplic-main.h" + +#define APLIC_DISABLE_IDELIVERY 0 +#define APLIC_ENABLE_IDELIVERY 1 +#define APLIC_DISABLE_ITHRESHOLD 1 +#define APLIC_ENABLE_ITHRESHOLD 0 + +struct aplic_direct { + struct aplic_priv priv; + struct irq_domain *irqdomain; + struct cpumask lmask; +}; + +struct aplic_idc { + unsigned int hart_index; + void __iomem *regs; + struct aplic_direct *direct; +}; + +static unsigned int aplic_direct_parent_irq; +static DEFINE_PER_CPU(struct aplic_idc, aplic_idcs); + +static void aplic_direct_irq_eoi(struct irq_data *d) +{ + /* + * The fasteoi_handler requires irq_eoi() callback hence + * provide a dummy handler. + */ +} + +#ifdef CONFIG_SMP +static int aplic_direct_set_affinity(struct irq_data *d, + const struct cpumask *mask_val, bool force) +{ + struct aplic_priv *priv = irq_data_get_irq_chip_data(d); + struct aplic_direct *direct = + container_of(priv, struct aplic_direct, priv); + struct aplic_idc *idc; + unsigned int cpu, val; + struct cpumask amask; + void __iomem *target; + + cpumask_and(&amask, &direct->lmask, mask_val); + + if (force) + cpu = cpumask_first(&amask); + else + cpu = cpumask_any_and(&amask, cpu_online_mask); + + if (cpu >= nr_cpu_ids) + return -EINVAL; + + idc = per_cpu_ptr(&aplic_idcs, cpu); + target = priv->regs + APLIC_TARGET_BASE; + target += (d->hwirq - 1) * sizeof(u32); + val = idc->hart_index & APLIC_TARGET_HART_IDX_MASK; + val <<= APLIC_TARGET_HART_IDX_SHIFT; + val |= APLIC_DEFAULT_PRIORITY; + writel(val, target); + + irq_data_update_effective_affinity(d, cpumask_of(cpu)); + + return IRQ_SET_MASK_OK_DONE; +} +#endif + +static struct irq_chip aplic_direct_chip = { + .name = "APLIC-DIRECT", + .irq_mask = aplic_irq_mask, + .irq_unmask = aplic_irq_unmask, + .irq_set_type = aplic_irq_set_type, + .irq_eoi = aplic_direct_irq_eoi, +#ifdef CONFIG_SMP + .irq_set_affinity = aplic_direct_set_affinity, +#endif + .flags = IRQCHIP_SET_TYPE_MASKED | + IRQCHIP_SKIP_SET_WAKE | + IRQCHIP_MASK_ON_SUSPEND, +}; + +static int aplic_direct_irqdomain_translate(struct irq_domain *d, + struct irq_fwspec *fwspec, + unsigned long *hwirq, + unsigned int *type) +{ + struct aplic_priv *priv = d->host_data; + + return aplic_irqdomain_translate(fwspec, priv->gsi_base, + hwirq, type); +} + +static int aplic_direct_irqdomain_alloc(struct irq_domain *domain, + unsigned int virq, unsigned int nr_irqs, + void *arg) +{ + int i, ret; + unsigned int type; + irq_hw_number_t hwirq; + struct irq_fwspec *fwspec = arg; + struct aplic_priv *priv = domain->host_data; + struct aplic_direct *direct = + container_of(priv, struct aplic_direct, priv); + + ret = aplic_irqdomain_translate(fwspec, priv->gsi_base, + &hwirq, &type); + if (ret) + return ret; + + for (i = 0; i < nr_irqs; i++) { + irq_domain_set_info(domain, virq + i, hwirq + i, + &aplic_direct_chip, priv, + handle_fasteoi_irq, NULL, NULL); + irq_set_affinity(virq + i, &direct->lmask); + /* See the reason described in aplic_msi_irqdomain_alloc() */ + irq_set_status_flags(virq + i, IRQ_DISABLE_UNLAZY); + } + + return 0; +} + +static const struct irq_domain_ops aplic_direct_irqdomain_ops = { + .translate = aplic_direct_irqdomain_translate, + .alloc = aplic_direct_irqdomain_alloc, + .free = irq_domain_free_irqs_top, +}; + +/* + * To handle an APLIC direct interrupts, we just read the CLAIMI register + * which will return highest priority pending interrupt and clear the + * pending bit of the interrupt. This process is repeated until CLAIMI + * register return zero value. + */ +static void aplic_direct_handle_irq(struct irq_desc *desc) +{ + struct aplic_idc *idc = this_cpu_ptr(&aplic_idcs); + struct irq_chip *chip = irq_desc_get_chip(desc); + struct irq_domain *irqdomain = idc->direct->irqdomain; + irq_hw_number_t hw_irq; + int irq; + + chained_irq_enter(chip, desc); + + while ((hw_irq = readl(idc->regs + APLIC_IDC_CLAIMI))) { + hw_irq = hw_irq >> APLIC_IDC_TOPI_ID_SHIFT; + irq = irq_find_mapping(irqdomain, hw_irq); + + if (unlikely(irq <= 0)) + dev_warn_ratelimited(idc->direct->priv.dev, + "hw_irq %lu mapping not found\n", + hw_irq); + else + generic_handle_irq(irq); + } + + chained_irq_exit(chip, desc); +} + +static void aplic_idc_set_delivery(struct aplic_idc *idc, bool en) +{ + u32 de = (en) ? APLIC_ENABLE_IDELIVERY : APLIC_DISABLE_IDELIVERY; + u32 th = (en) ? APLIC_ENABLE_ITHRESHOLD : APLIC_DISABLE_ITHRESHOLD; + + /* Priority must be less than threshold for interrupt triggering */ + writel(th, idc->regs + APLIC_IDC_ITHRESHOLD); + + /* Delivery must be set to 1 for interrupt triggering */ + writel(de, idc->regs + APLIC_IDC_IDELIVERY); +} + +static int aplic_direct_dying_cpu(unsigned int cpu) +{ + if (aplic_direct_parent_irq) + disable_percpu_irq(aplic_direct_parent_irq); + + return 0; +} + +static int aplic_direct_starting_cpu(unsigned int cpu) +{ + if (aplic_direct_parent_irq) + enable_percpu_irq(aplic_direct_parent_irq, + irq_get_trigger_type(aplic_direct_parent_irq)); + + return 0; +} + +int aplic_direct_setup(struct device *dev, void __iomem *regs) +{ + int i, j, rc, cpu, setup_count = 0; + struct fwnode_reference_args parent; + struct aplic_direct *direct; + struct aplic_priv *priv; + struct irq_domain *domain; + unsigned long hartid; + struct aplic_idc *idc; + u32 val; + + direct = kzalloc(sizeof(*direct), GFP_KERNEL); + if (!direct) + return -ENOMEM; + priv = &direct->priv; + + rc = aplic_setup_priv(priv, dev, regs); + if (rc) { + dev_err(dev, "failed to create APLIC context\n"); + kfree(direct); + return rc; + } + + /* Setup per-CPU IDC and target CPU mask */ + for (i = 0; i < priv->nr_idcs; i++) { + rc = fwnode_property_get_reference_args(dev->fwnode, + "interrupts-extended", "#interrupt-cells", + 0, i, &parent); + if (rc) { + dev_warn(dev, "parent irq for IDC%d not found\n", i); + continue; + } + + /* + * Skip interrupts other than external interrupts for + * current privilege level. + */ + if (parent.args[0] != RV_IRQ_EXT) + continue; + + rc = riscv_get_intc_hartid(parent.fwnode, &hartid); + if (rc) { + dev_warn(dev, "invalid hartid for IDC%d\n", i); + continue; + } + + cpu = riscv_hartid_to_cpuid(hartid); + if (cpu < 0) { + dev_warn(dev, "invalid cpuid for IDC%d\n", i); + continue; + } + + cpumask_set_cpu(cpu, &direct->lmask); + + idc = per_cpu_ptr(&aplic_idcs, cpu); + idc->hart_index = i; + idc->regs = priv->regs + APLIC_IDC_BASE + i * APLIC_IDC_SIZE; + idc->direct = direct; + + aplic_idc_set_delivery(idc, true); + + /* + * Boot cpu might not have APLIC hart_index = 0 so check + * and update target registers of all interrupts. + */ + if (cpu == smp_processor_id() && idc->hart_index) { + val = idc->hart_index & APLIC_TARGET_HART_IDX_MASK; + val <<= APLIC_TARGET_HART_IDX_SHIFT; + val |= APLIC_DEFAULT_PRIORITY; + for (j = 1; j <= priv->nr_irqs; j++) + writel(val, priv->regs + APLIC_TARGET_BASE + + (j - 1) * sizeof(u32)); + } + + setup_count++; + } + + /* Find parent domain and register chained handler */ + domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), + DOMAIN_BUS_ANY); + if (!aplic_direct_parent_irq && domain) { + aplic_direct_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT); + if (aplic_direct_parent_irq) { + irq_set_chained_handler(aplic_direct_parent_irq, + aplic_direct_handle_irq); + + /* + * Setup CPUHP notifier to enable parent + * interrupt on all CPUs + */ + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, + "irqchip/riscv/aplic:starting", + aplic_direct_starting_cpu, + aplic_direct_dying_cpu); + } + } + + /* Fail if we were not able to setup IDC for any CPU */ + if (!setup_count) { + kfree(direct); + return -ENODEV; + } + + /* Setup global config and interrupt delivery */ + aplic_init_hw_global(priv, false); + + /* Create irq domain instance for the APLIC */ + direct->irqdomain = irq_domain_create_linear(dev->fwnode, + priv->nr_irqs + 1, + &aplic_direct_irqdomain_ops, + priv); + if (!direct->irqdomain) { + dev_err(dev, "failed to create direct irq domain\n"); + kfree(direct); + return -ENOMEM; + } + + /* Advertise the interrupt controller */ + dev_info(dev, "%d interrupts directly connected to %d CPUs\n", + priv->nr_irqs, priv->nr_idcs); + + return 0; +} diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c new file mode 100644 index 000000000000..d62a096774c4 --- /dev/null +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#include +#include +#include +#include + +#include "irq-riscv-aplic-main.h" + +void aplic_irq_unmask(struct irq_data *d) +{ + struct aplic_priv *priv = irq_data_get_irq_chip_data(d); + + writel(d->hwirq, priv->regs + APLIC_SETIENUM); +} + +void aplic_irq_mask(struct irq_data *d) +{ + struct aplic_priv *priv = irq_data_get_irq_chip_data(d); + + writel(d->hwirq, priv->regs + APLIC_CLRIENUM); +} + +int aplic_irq_set_type(struct irq_data *d, unsigned int type) +{ + u32 val = 0; + void __iomem *sourcecfg; + struct aplic_priv *priv = irq_data_get_irq_chip_data(d); + + switch (type) { + case IRQ_TYPE_NONE: + val = APLIC_SOURCECFG_SM_INACTIVE; + break; + case IRQ_TYPE_LEVEL_LOW: + val = APLIC_SOURCECFG_SM_LEVEL_LOW; + break; + case IRQ_TYPE_LEVEL_HIGH: + val = APLIC_SOURCECFG_SM_LEVEL_HIGH; + break; + case IRQ_TYPE_EDGE_FALLING: + val = APLIC_SOURCECFG_SM_EDGE_FALL; + break; + case IRQ_TYPE_EDGE_RISING: + val = APLIC_SOURCECFG_SM_EDGE_RISE; + break; + default: + return -EINVAL; + } + + sourcecfg = priv->regs + APLIC_SOURCECFG_BASE; + sourcecfg += (d->hwirq - 1) * sizeof(u32); + writel(val, sourcecfg); + + return 0; +} + +int aplic_irqdomain_translate(struct irq_fwspec *fwspec, u32 gsi_base, + unsigned long *hwirq, unsigned int *type) +{ + if (WARN_ON(fwspec->param_count < 2)) + return -EINVAL; + if (WARN_ON(!fwspec->param[0])) + return -EINVAL; + + /* For DT, gsi_base is always zero. */ + *hwirq = fwspec->param[0] - gsi_base; + *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK; + + WARN_ON(*type == IRQ_TYPE_NONE); + + return 0; +} + +void aplic_init_hw_global(struct aplic_priv *priv, bool msi_mode) +{ + u32 val; +#ifdef CONFIG_RISCV_M_MODE + u32 valH; + + if (msi_mode) { + val = priv->msicfg.base_ppn; + valH = ((u64)priv->msicfg.base_ppn >> 32) & + APLIC_xMSICFGADDRH_BAPPN_MASK; + valH |= (priv->msicfg.lhxw & APLIC_xMSICFGADDRH_LHXW_MASK) + << APLIC_xMSICFGADDRH_LHXW_SHIFT; + valH |= (priv->msicfg.hhxw & APLIC_xMSICFGADDRH_HHXW_MASK) + << APLIC_xMSICFGADDRH_HHXW_SHIFT; + valH |= (priv->msicfg.lhxs & APLIC_xMSICFGADDRH_LHXS_MASK) + << APLIC_xMSICFGADDRH_LHXS_SHIFT; + valH |= (priv->msicfg.hhxs & APLIC_xMSICFGADDRH_HHXS_MASK) + << APLIC_xMSICFGADDRH_HHXS_SHIFT; + writel(val, priv->regs + APLIC_xMSICFGADDR); + writel(valH, priv->regs + APLIC_xMSICFGADDRH); + } +#endif + + /* Setup APLIC domaincfg register */ + val = readl(priv->regs + APLIC_DOMAINCFG); + val |= APLIC_DOMAINCFG_IE; + if (msi_mode) + val |= APLIC_DOMAINCFG_DM; + writel(val, priv->regs + APLIC_DOMAINCFG); + if (readl(priv->regs + APLIC_DOMAINCFG) != val) + dev_warn(priv->dev, "unable to write 0x%x in domaincfg\n", + val); +} + +static void aplic_init_hw_irqs(struct aplic_priv *priv) +{ + int i; + + /* Disable all interrupts */ + for (i = 0; i <= priv->nr_irqs; i += 32) + writel(-1U, priv->regs + APLIC_CLRIE_BASE + + (i / 32) * sizeof(u32)); + + /* Set interrupt type and default priority for all interrupts */ + for (i = 1; i <= priv->nr_irqs; i++) { + writel(0, priv->regs + APLIC_SOURCECFG_BASE + + (i - 1) * sizeof(u32)); + writel(APLIC_DEFAULT_PRIORITY, + priv->regs + APLIC_TARGET_BASE + + (i - 1) * sizeof(u32)); + } + + /* Clear APLIC domaincfg */ + writel(0, priv->regs + APLIC_DOMAINCFG); +} + +int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, + void __iomem *regs) +{ + struct fwnode_reference_args parent; + int rc; + + /* Save device pointer and register base */ + priv->dev = dev; + priv->regs = regs; + + /* + * Find out GSI base number + * + * Note: DT does not define "riscv,gsi-base" property so GSI + * base is always zero for DT. + */ + rc = fwnode_property_read_u32_array(dev->fwnode, "riscv,gsi-base", + &priv->gsi_base, 1); + if (rc) + priv->gsi_base = 0; + + /* Find out number of interrupt sources */ + rc = fwnode_property_read_u32_array(dev->fwnode, "riscv,num-sources", + &priv->nr_irqs, 1); + if (rc) { + dev_err(dev, "failed to get number of interrupt sources\n"); + return rc; + } + + /* Setup initial state APLIC interrupts */ + aplic_init_hw_irqs(priv); + + /* + * Find out number of IDCs based on parent interrupts + * + * If "msi-parent" property is present then we ignore the + * APLIC IDCs which forces the APLIC driver to use MSI mode. + */ + if (!fwnode_property_present(dev->fwnode, "msi-parent")) { + while (!fwnode_property_get_reference_args(dev->fwnode, + "interrupts-extended", "#interrupt-cells", + 0, priv->nr_idcs, &parent)) + priv->nr_idcs++; + } + + return 0; +} + +static int aplic_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + void __iomem *regs; + int rc; + + /* Map the MMIO registers */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "failed to get MMIO resource\n"); + return -EINVAL; + } + regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!regs) { + dev_err(dev, "failed map MMIO registers\n"); + return -ENOMEM; + } + + /* + * If msi-parent property is present then setup APLIC MSI mode + * otherwise setup APLIC direct mode. + */ + if (fwnode_property_present(dev->fwnode, "msi-parent")) + rc = -ENODEV; + else + rc = aplic_direct_setup(dev, regs); + if (rc) { + dev_err(dev, "failed setup APLIC in %s mode\n", + fwnode_property_present(dev->fwnode, "msi-parent") ? + "MSI" : "direct"); + return rc; + } + + return 0; +} + +static const struct of_device_id aplic_match[] = { + { .compatible = "riscv,aplic" }, + {} +}; + +static struct platform_driver aplic_driver = { + .driver = { + .name = "riscv-aplic", + .of_match_table = aplic_match, + }, + .probe = aplic_probe, +}; + +static int __init aplic_init(void) +{ + /* + * Register APLIC driver as early as possible so that APLIC + * platform device is probed as soon as it is created. + */ + return platform_driver_register(&aplic_driver); +} +core_initcall(aplic_init); diff --git a/drivers/irqchip/irq-riscv-aplic-main.h b/drivers/irqchip/irq-riscv-aplic-main.h new file mode 100644 index 000000000000..474a04229334 --- /dev/null +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#ifndef _IRQ_RISCV_APLIC_MAIN_H +#define _IRQ_RISCV_APLIC_MAIN_H + +#include +#include +#include +#include +#include + +#define APLIC_DEFAULT_PRIORITY 1 + +struct aplic_msicfg { + phys_addr_t base_ppn; + u32 hhxs; + u32 hhxw; + u32 lhxs; + u32 lhxw; +}; + +struct aplic_priv { + struct device *dev; + u32 gsi_base; + u32 nr_irqs; + u32 nr_idcs; + void __iomem *regs; + struct aplic_msicfg msicfg; +}; + +void aplic_irq_unmask(struct irq_data *d); +void aplic_irq_mask(struct irq_data *d); +int aplic_irq_set_type(struct irq_data *d, unsigned int type); +int aplic_irqdomain_translate(struct irq_fwspec *fwspec, u32 gsi_base, + unsigned long *hwirq, unsigned int *type); +void aplic_init_hw_global(struct aplic_priv *priv, bool msi_mode); +int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, + void __iomem *regs); +int aplic_direct_setup(struct device *dev, void __iomem *regs); + +#endif diff --git a/include/linux/irqchip/riscv-aplic.h b/include/linux/irqchip/riscv-aplic.h new file mode 100644 index 000000000000..97e198ea0109 --- /dev/null +++ b/include/linux/irqchip/riscv-aplic.h @@ -0,0 +1,119 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ +#ifndef __LINUX_IRQCHIP_RISCV_APLIC_H +#define __LINUX_IRQCHIP_RISCV_APLIC_H + +#include + +#define APLIC_MAX_IDC BIT(14) +#define APLIC_MAX_SOURCE 1024 + +#define APLIC_DOMAINCFG 0x0000 +#define APLIC_DOMAINCFG_RDONLY 0x80000000 +#define APLIC_DOMAINCFG_IE BIT(8) +#define APLIC_DOMAINCFG_DM BIT(2) +#define APLIC_DOMAINCFG_BE BIT(0) + +#define APLIC_SOURCECFG_BASE 0x0004 +#define APLIC_SOURCECFG_D BIT(10) +#define APLIC_SOURCECFG_CHILDIDX_MASK 0x000003ff +#define APLIC_SOURCECFG_SM_MASK 0x00000007 +#define APLIC_SOURCECFG_SM_INACTIVE 0x0 +#define APLIC_SOURCECFG_SM_DETACH 0x1 +#define APLIC_SOURCECFG_SM_EDGE_RISE 0x4 +#define APLIC_SOURCECFG_SM_EDGE_FALL 0x5 +#define APLIC_SOURCECFG_SM_LEVEL_HIGH 0x6 +#define APLIC_SOURCECFG_SM_LEVEL_LOW 0x7 + +#define APLIC_MMSICFGADDR 0x1bc0 +#define APLIC_MMSICFGADDRH 0x1bc4 +#define APLIC_SMSICFGADDR 0x1bc8 +#define APLIC_SMSICFGADDRH 0x1bcc + +#ifdef CONFIG_RISCV_M_MODE +#define APLIC_xMSICFGADDR APLIC_MMSICFGADDR +#define APLIC_xMSICFGADDRH APLIC_MMSICFGADDRH +#else +#define APLIC_xMSICFGADDR APLIC_SMSICFGADDR +#define APLIC_xMSICFGADDRH APLIC_SMSICFGADDRH +#endif + +#define APLIC_xMSICFGADDRH_L BIT(31) +#define APLIC_xMSICFGADDRH_HHXS_MASK 0x1f +#define APLIC_xMSICFGADDRH_HHXS_SHIFT 24 +#define APLIC_xMSICFGADDRH_LHXS_MASK 0x7 +#define APLIC_xMSICFGADDRH_LHXS_SHIFT 20 +#define APLIC_xMSICFGADDRH_HHXW_MASK 0x7 +#define APLIC_xMSICFGADDRH_HHXW_SHIFT 16 +#define APLIC_xMSICFGADDRH_LHXW_MASK 0xf +#define APLIC_xMSICFGADDRH_LHXW_SHIFT 12 +#define APLIC_xMSICFGADDRH_BAPPN_MASK 0xfff + +#define APLIC_xMSICFGADDR_PPN_SHIFT 12 + +#define APLIC_xMSICFGADDR_PPN_HART(__lhxs) \ + (BIT(__lhxs) - 1) + +#define APLIC_xMSICFGADDR_PPN_LHX_MASK(__lhxw) \ + (BIT(__lhxw) - 1) +#define APLIC_xMSICFGADDR_PPN_LHX_SHIFT(__lhxs) \ + ((__lhxs)) +#define APLIC_xMSICFGADDR_PPN_LHX(__lhxw, __lhxs) \ + (APLIC_xMSICFGADDR_PPN_LHX_MASK(__lhxw) << \ + APLIC_xMSICFGADDR_PPN_LHX_SHIFT(__lhxs)) + +#define APLIC_xMSICFGADDR_PPN_HHX_MASK(__hhxw) \ + (BIT(__hhxw) - 1) +#define APLIC_xMSICFGADDR_PPN_HHX_SHIFT(__hhxs) \ + ((__hhxs) + APLIC_xMSICFGADDR_PPN_SHIFT) +#define APLIC_xMSICFGADDR_PPN_HHX(__hhxw, __hhxs) \ + (APLIC_xMSICFGADDR_PPN_HHX_MASK(__hhxw) << \ + APLIC_xMSICFGADDR_PPN_HHX_SHIFT(__hhxs)) + +#define APLIC_IRQBITS_PER_REG 32 + +#define APLIC_SETIP_BASE 0x1c00 +#define APLIC_SETIPNUM 0x1cdc + +#define APLIC_CLRIP_BASE 0x1d00 +#define APLIC_CLRIPNUM 0x1ddc + +#define APLIC_SETIE_BASE 0x1e00 +#define APLIC_SETIENUM 0x1edc + +#define APLIC_CLRIE_BASE 0x1f00 +#define APLIC_CLRIENUM 0x1fdc + +#define APLIC_SETIPNUM_LE 0x2000 +#define APLIC_SETIPNUM_BE 0x2004 + +#define APLIC_GENMSI 0x3000 + +#define APLIC_TARGET_BASE 0x3004 +#define APLIC_TARGET_HART_IDX_SHIFT 18 +#define APLIC_TARGET_HART_IDX_MASK 0x3fff +#define APLIC_TARGET_GUEST_IDX_SHIFT 12 +#define APLIC_TARGET_GUEST_IDX_MASK 0x3f +#define APLIC_TARGET_IPRIO_MASK 0xff +#define APLIC_TARGET_EIID_MASK 0x7ff + +#define APLIC_IDC_BASE 0x4000 +#define APLIC_IDC_SIZE 32 + +#define APLIC_IDC_IDELIVERY 0x00 + +#define APLIC_IDC_IFORCE 0x04 + +#define APLIC_IDC_ITHRESHOLD 0x08 + +#define APLIC_IDC_TOPI 0x18 +#define APLIC_IDC_TOPI_ID_SHIFT 16 +#define APLIC_IDC_TOPI_ID_MASK 0x3ff +#define APLIC_IDC_TOPI_PRIO_MASK 0xff + +#define APLIC_IDC_CLAIMI 0x1c + +#endif From patchwork Tue Sep 12 17:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp764854vqx; Tue, 12 Sep 2023 17:27:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETqdf9CPSP81y5+CoB2kHc4f4fegxSk/42UI8CMKdt0S0Lo2E+NCVUFoP0p25bXm2fFWxV X-Received: by 2002:a17:90b:1194:b0:273:e42b:34c9 with SMTP id gk20-20020a17090b119400b00273e42b34c9mr842236pjb.38.1694564833481; Tue, 12 Sep 2023 17:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694564833; cv=none; d=google.com; s=arc-20160816; b=MrEbX/AiaCtdtlxtGOf6cogemt/26Tcx3eANDsZQMwlPnNn3zrHlYRg01BUjoyPHzd worb4ym0AoQxhFwWDl6xnMV/CInnKvwRUuU8qOIb3iYuGFWLcFBEMuzg7cJQ83hruCCi 3k60F4oyNXA90w4X95A/q2+zgqlbE/DOICdrC5MrH0/05XPtEN5AJiL9hV3yhTzRbhBI mV70iqwxyhPemBVmZDAimNyFbHcX9xEUFzq1MF4cmQvH/7RTUkz+YPpA3Z8blQSA+SHf nGadugZQZrZIJY1RTBzVU82t5HBxDVHY/ytyoi/MOIeSpCA8TWFDTjoRiimLtQFnKD2J D+ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lN4uZIebc5z1KPZeHWrBtdkLg5fdhXgpNNIgeKERLHc=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=RgGGzs4KkIymppi04SWX8nyxP/vcLQXEOn368PPZmqPIEt90rCqrQOIIT2eKupCf34 IXd1rv1MwlF6YhrmfE5sPq+u4QFxsPiiOoBCAS+iAA64ExeQ3Waa3BEvuuhZwplbbfYH mHWIdOPtUK+cumqOdK0Vk34ornH+KmIEKXNhVCDF8AnY+VrPhaydN2EEE3stMJC9JH/u 4RUeetK/KpAf7x6hYrjsKrYnGA1LfIEgZ6Kn0LazaEoZssZW+t6LyRxLwGB9ND77ILpD 38RJae76rtkKWwnpGYKUtGBiZUWEJ2CJFEdGO/2/aNUrP4alioYEu3WBuyaN38oM1bxl d2Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=K9w50IEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id h19-20020a17090acf1300b0026390b4a4e0si378727pju.124.2023.09.12.17.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 17:27:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=K9w50IEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1E36580CD73D; Tue, 12 Sep 2023 10:53:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237364AbjILRwW (ORCPT + 36 others); Tue, 12 Sep 2023 13:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237381AbjILRv5 (ORCPT ); Tue, 12 Sep 2023 13:51:57 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70CE2109 for ; Tue, 12 Sep 2023 10:51:44 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fac346f6aso2796296b3a.3 for ; Tue, 12 Sep 2023 10:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541104; x=1695145904; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lN4uZIebc5z1KPZeHWrBtdkLg5fdhXgpNNIgeKERLHc=; b=K9w50IEZU7kQWTgl+9Wi3VX7plAbmp9J+LRE7Ioo20xns5wS/2u7RlCX6GeK7hkHq9 3/twVcbfBAgwopYfphyjjbgn13XxVF/WgwOwMOHliANJB0+zZ1ByM4C82CtRrC/Sv0X5 ZNT068D0ZZHL3Bq20ZhmUzjJZazAsHyXqMtcBF2WaW0mz176GT21oy67Ej9+BsJfkKiv IUUCgTOEIgmbd2j5W0mJJ3yzDaGfZZxhJkVpVnOg0NHk0qyaSE2gZicCj2yJAE/xCOUM 8DExEhe5iEiQG3Y4e97UQY8dCMKkdBrT7yRNRETqUwayArWqNnWvBPgJmVOoCsXsWV4z nrpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541104; x=1695145904; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lN4uZIebc5z1KPZeHWrBtdkLg5fdhXgpNNIgeKERLHc=; b=Ow3JkWycMzylZUpyFDvf6tSLqs3jQmCsDmHjcqnjDMFNS2Xjs4NOYwlFeBWTolHX9s TGRRsxmReEgNoljL5kJXZJG0TYP5lPjFdmQs42NH1TDrTkZVZfLa0dkwggIzXRINVtpq Aye8MgPRRc1uq7xTvEiakqJNFjU2PRpykIg/vNm7HgeOUJ48K4KbBZ1nnichp171Z5gp E8hUBz/FGAtapAxL2E8ss0OgHu13SfOGWZPEk+TZ/TMiPQoUprc0+m3jG3RMy4x1nsY8 960raanjkvDxV/lruE26P6cuiEvRHG/VyDC+NILTJM8oVajYB99M+OS0oqHQmMldFhWb XJnA== X-Gm-Message-State: AOJu0YzSKEZyxTshHmTyooJnfHTRINAQMAV8ru+3zxo2K8c2tuNk6mJU tyfSs5Bl9KNhvFO2oaULq21XpA== X-Received: by 2002:a05:6a21:819c:b0:157:dffb:fdfe with SMTP id pd28-20020a056a21819c00b00157dffbfdfemr96436pzb.32.1694541104281; Tue, 12 Sep 2023 10:51:44 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:43 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 14/16] irqchip/riscv-aplic: Add support for MSI-mode Date: Tue, 12 Sep 2023 23:19:26 +0530 Message-Id: <20230912174928.528414-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:53:00 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776880014888693965 X-GMAIL-MSGID: 1776880014888693965 The RISC-V advanced platform-level interrupt controller (APLIC) has two modes of operation: 1) Direct mode and 2) MSI mode. (For more details, refer https://github.com/riscv/riscv-aia) In APLIC MSI-mode, wired interrupts are forwared as message signaled interrupts (MSIs) to CPUs via IMSIC. We extend the existing APLIC irqchip driver to support MSI-mode for RISC-V platforms having both wired interrupts and MSIs. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 6 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-riscv-aplic-main.c | 2 +- drivers/irqchip/irq-riscv-aplic-main.h | 8 + drivers/irqchip/irq-riscv-aplic-msi.c | 285 +++++++++++++++++++++++++ 5 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-riscv-aplic-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 44c455084d09..31c069bf7343 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -550,6 +550,12 @@ config RISCV_APLIC depends on RISCV select IRQ_DOMAIN_HIERARCHY +config RISCV_APLIC_MSI + bool + depends on RISCV_APLIC + select GENERIC_MSI_IRQ + default RISCV_APLIC + config RISCV_IMSIC bool depends on RISCV diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 7f8289790ed8..47995fdb2c60 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -96,6 +96,7 @@ obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o obj-$(CONFIG_RISCV_APLIC) += irq-riscv-aplic-main.o irq-riscv-aplic-direct.o +obj-$(CONFIG_RISCV_APLIC_MSI) += irq-riscv-aplic-msi.o obj-$(CONFIG_RISCV_IMSIC) += irq-riscv-imsic-state.o irq-riscv-imsic-early.o irq-riscv-imsic-platform.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c index d62a096774c4..f225ac77ea3c 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.c +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -203,7 +203,7 @@ static int aplic_probe(struct platform_device *pdev) * otherwise setup APLIC direct mode. */ if (fwnode_property_present(dev->fwnode, "msi-parent")) - rc = -ENODEV; + rc = aplic_msi_setup(dev, regs); else rc = aplic_direct_setup(dev, regs); if (rc) { diff --git a/drivers/irqchip/irq-riscv-aplic-main.h b/drivers/irqchip/irq-riscv-aplic-main.h index 474a04229334..78267ec58098 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.h +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -41,5 +41,13 @@ void aplic_init_hw_global(struct aplic_priv *priv, bool msi_mode); int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs); int aplic_direct_setup(struct device *dev, void __iomem *regs); +#ifdef CONFIG_RISCV_APLIC_MSI +int aplic_msi_setup(struct device *dev, void __iomem *regs); +#else +static inline int aplic_msi_setup(struct device *dev, void __iomem *regs) +{ + return -ENODEV; +} +#endif #endif diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-riscv-aplic-msi.c new file mode 100644 index 000000000000..086d00e0429e --- /dev/null +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -0,0 +1,285 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "irq-riscv-aplic-main.h" + +static void aplic_msi_irq_unmask(struct irq_data *d) +{ + aplic_irq_unmask(d); + irq_chip_unmask_parent(d); +} + +static void aplic_msi_irq_mask(struct irq_data *d) +{ + aplic_irq_mask(d); + irq_chip_mask_parent(d); +} + +static void aplic_msi_irq_eoi(struct irq_data *d) +{ + struct aplic_priv *priv = irq_data_get_irq_chip_data(d); + u32 reg_off, reg_mask; + + /* + * EOI handling only required only for level-triggered + * interrupts in APLIC MSI mode. + */ + + reg_off = APLIC_CLRIP_BASE + ((d->hwirq / APLIC_IRQBITS_PER_REG) * 4); + reg_mask = BIT(d->hwirq % APLIC_IRQBITS_PER_REG); + switch (irqd_get_trigger_type(d)) { + case IRQ_TYPE_LEVEL_LOW: + if (!(readl(priv->regs + reg_off) & reg_mask)) + writel(d->hwirq, priv->regs + APLIC_SETIPNUM_LE); + break; + case IRQ_TYPE_LEVEL_HIGH: + if (readl(priv->regs + reg_off) & reg_mask) + writel(d->hwirq, priv->regs + APLIC_SETIPNUM_LE); + break; + } +} + +static struct irq_chip aplic_msi_chip = { + .name = "APLIC-MSI", + .irq_mask = aplic_msi_irq_mask, + .irq_unmask = aplic_msi_irq_unmask, + .irq_set_type = aplic_irq_set_type, + .irq_eoi = aplic_msi_irq_eoi, +#ifdef CONFIG_SMP + .irq_set_affinity = irq_chip_set_affinity_parent, +#endif + .flags = IRQCHIP_SET_TYPE_MASKED | + IRQCHIP_SKIP_SET_WAKE | + IRQCHIP_MASK_ON_SUSPEND, +}; + +static int aplic_msi_irqdomain_translate(struct irq_domain *d, + struct irq_fwspec *fwspec, + unsigned long *hwirq, + unsigned int *type) +{ + struct aplic_priv *priv = platform_msi_get_host_data(d); + + return aplic_irqdomain_translate(fwspec, priv->gsi_base, hwirq, type); +} + +static int aplic_msi_irqdomain_alloc(struct irq_domain *domain, + unsigned int virq, unsigned int nr_irqs, + void *arg) +{ + int i, ret; + unsigned int type; + irq_hw_number_t hwirq; + struct irq_fwspec *fwspec = arg; + struct aplic_priv *priv = platform_msi_get_host_data(domain); + + ret = aplic_irqdomain_translate(fwspec, priv->gsi_base, &hwirq, &type); + if (ret) + return ret; + + ret = platform_msi_device_domain_alloc(domain, virq, nr_irqs); + if (ret) + return ret; + + for (i = 0; i < nr_irqs; i++) { + irq_domain_set_info(domain, virq + i, hwirq + i, + &aplic_msi_chip, priv, handle_fasteoi_irq, + NULL, NULL); + /* + * APLIC does not implement irq_disable() so Linux interrupt + * subsystem will take a lazy approach for disabling an APLIC + * interrupt. This means APLIC interrupts are left unmasked + * upon system suspend and interrupts are not processed + * immediately upon system wake up. To tackle this, we disable + * the lazy approach for all APLIC interrupts. + */ + irq_set_status_flags(virq + i, IRQ_DISABLE_UNLAZY); + } + + return 0; +} + +static const struct irq_domain_ops aplic_msi_irqdomain_ops = { + .translate = aplic_msi_irqdomain_translate, + .alloc = aplic_msi_irqdomain_alloc, + .free = platform_msi_device_domain_free, +}; + +static void aplic_msi_write_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + unsigned int group_index, hart_index, guest_index, val; + struct irq_data *d = irq_get_irq_data(desc->irq); + struct aplic_priv *priv = irq_data_get_irq_chip_data(d); + struct aplic_msicfg *mc = &priv->msicfg; + phys_addr_t tppn, tbppn, msg_addr; + void __iomem *target; + + /* For zeroed MSI, simply write zero into the target register */ + if (!msg->address_hi && !msg->address_lo && !msg->data) { + target = priv->regs + APLIC_TARGET_BASE; + target += (d->hwirq - 1) * sizeof(u32); + writel(0, target); + return; + } + + /* Sanity check on message data */ + WARN_ON(msg->data > APLIC_TARGET_EIID_MASK); + + /* Compute target MSI address */ + msg_addr = (((u64)msg->address_hi) << 32) | msg->address_lo; + tppn = msg_addr >> APLIC_xMSICFGADDR_PPN_SHIFT; + + /* Compute target HART Base PPN */ + tbppn = tppn; + tbppn &= ~APLIC_xMSICFGADDR_PPN_HART(mc->lhxs); + tbppn &= ~APLIC_xMSICFGADDR_PPN_LHX(mc->lhxw, mc->lhxs); + tbppn &= ~APLIC_xMSICFGADDR_PPN_HHX(mc->hhxw, mc->hhxs); + WARN_ON(tbppn != mc->base_ppn); + + /* Compute target group and hart indexes */ + group_index = (tppn >> APLIC_xMSICFGADDR_PPN_HHX_SHIFT(mc->hhxs)) & + APLIC_xMSICFGADDR_PPN_HHX_MASK(mc->hhxw); + hart_index = (tppn >> APLIC_xMSICFGADDR_PPN_LHX_SHIFT(mc->lhxs)) & + APLIC_xMSICFGADDR_PPN_LHX_MASK(mc->lhxw); + hart_index |= (group_index << mc->lhxw); + WARN_ON(hart_index > APLIC_TARGET_HART_IDX_MASK); + + /* Compute target guest index */ + guest_index = tppn & APLIC_xMSICFGADDR_PPN_HART(mc->lhxs); + WARN_ON(guest_index > APLIC_TARGET_GUEST_IDX_MASK); + + /* Update IRQ TARGET register */ + target = priv->regs + APLIC_TARGET_BASE; + target += (d->hwirq - 1) * sizeof(u32); + val = (hart_index & APLIC_TARGET_HART_IDX_MASK) + << APLIC_TARGET_HART_IDX_SHIFT; + val |= (guest_index & APLIC_TARGET_GUEST_IDX_MASK) + << APLIC_TARGET_GUEST_IDX_SHIFT; + val |= (msg->data & APLIC_TARGET_EIID_MASK); + writel(val, target); +} + +int aplic_msi_setup(struct device *dev, void __iomem *regs) +{ + const struct imsic_global_config *imsic_global; + struct irq_domain *irqdomain; + struct aplic_priv *priv; + struct aplic_msicfg *mc; + phys_addr_t pa; + int rc; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + rc = aplic_setup_priv(priv, dev, regs); + if (!priv) { + dev_err(dev, "failed to create APLIC context\n"); + return rc; + } + mc = &priv->msicfg; + + /* + * The APLIC outgoing MSI config registers assume target MSI + * controller to be RISC-V AIA IMSIC controller. + */ + imsic_global = imsic_get_global_config(); + if (!imsic_global) { + dev_err(dev, "IMSIC global config not found\n"); + return -ENODEV; + } + + /* Find number of guest index bits (LHXS) */ + mc->lhxs = imsic_global->guest_index_bits; + if (APLIC_xMSICFGADDRH_LHXS_MASK < mc->lhxs) { + dev_err(dev, "IMSIC guest index bits big for APLIC LHXS\n"); + return -EINVAL; + } + + /* Find number of HART index bits (LHXW) */ + mc->lhxw = imsic_global->hart_index_bits; + if (APLIC_xMSICFGADDRH_LHXW_MASK < mc->lhxw) { + dev_err(dev, "IMSIC hart index bits big for APLIC LHXW\n"); + return -EINVAL; + } + + /* Find number of group index bits (HHXW) */ + mc->hhxw = imsic_global->group_index_bits; + if (APLIC_xMSICFGADDRH_HHXW_MASK < mc->hhxw) { + dev_err(dev, "IMSIC group index bits big for APLIC HHXW\n"); + return -EINVAL; + } + + /* Find first bit position of group index (HHXS) */ + mc->hhxs = imsic_global->group_index_shift; + if (mc->hhxs < (2 * APLIC_xMSICFGADDR_PPN_SHIFT)) { + dev_err(dev, "IMSIC group index shift should be >= %d\n", + (2 * APLIC_xMSICFGADDR_PPN_SHIFT)); + return -EINVAL; + } + mc->hhxs -= (2 * APLIC_xMSICFGADDR_PPN_SHIFT); + if (APLIC_xMSICFGADDRH_HHXS_MASK < mc->hhxs) { + dev_err(dev, "IMSIC group index shift big for APLIC HHXS\n"); + return -EINVAL; + } + + /* Compute PPN base */ + mc->base_ppn = imsic_global->base_addr >> APLIC_xMSICFGADDR_PPN_SHIFT; + mc->base_ppn &= ~APLIC_xMSICFGADDR_PPN_HART(mc->lhxs); + mc->base_ppn &= ~APLIC_xMSICFGADDR_PPN_LHX(mc->lhxw, mc->lhxs); + mc->base_ppn &= ~APLIC_xMSICFGADDR_PPN_HHX(mc->hhxw, mc->hhxs); + + /* Setup global config and interrupt delivery */ + aplic_init_hw_global(priv, true); + + /* Set the APLIC device MSI domain if not available */ + if (!dev_get_msi_domain(dev)) { + /* + * The device MSI domain for OF devices is only set at the + * time of populating/creating OF device. If the device MSI + * domain is discovered later after the OF device is created + * then we need to set it explicitly before using any platform + * MSI functions. + * + * In case of APLIC device, the parent MSI domain is always + * IMSIC and the IMSIC MSI domains are created later through + * the platform driver probing so we set it explicitly here. + */ + if (is_of_node(dev->fwnode)) + of_msi_configure(dev, to_of_node(dev->fwnode)); + } + + /* Create irq domain instance for the APLIC MSI-mode */ + irqdomain = platform_msi_create_device_domain( + dev, priv->nr_irqs + 1, + aplic_msi_write_msg, + &aplic_msi_irqdomain_ops, + priv); + if (!irqdomain) { + dev_err(dev, "failed to create MSI irq domain\n"); + return -ENOMEM; + } + + /* Advertise the interrupt controller */ + pa = priv->msicfg.base_ppn << APLIC_xMSICFGADDR_PPN_SHIFT; + dev_info(dev, "%d interrupts forwared to MSI base %pa\n", + priv->nr_irqs, &pa); + + return 0; +} From patchwork Tue Sep 12 17:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp625619vqx; Tue, 12 Sep 2023 12:13:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGat47xTccq4sNlEa+DVvlaW6e8vv73X8vu2Qn9uChbNtjcegC2AK0m5cTT+oXyNtABX1MI X-Received: by 2002:a05:6a00:1787:b0:68f:edfd:2ac6 with SMTP id s7-20020a056a00178700b0068fedfd2ac6mr876116pfg.0.1694546021679; Tue, 12 Sep 2023 12:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694546021; cv=none; d=google.com; s=arc-20160816; b=CHZ7CDxKOao5N0EBmI9BLJu7HWBi6XnV0BnJ1kj5Ku1rcjgwbXjsFByoLVj4MDwp/S +ZkzNzHthwL6bw0cSWbU+HEoOJqVWJGZUMtP1aA3taWYFXG8wPSixjd94tLGokOMivzS p8/2TNNgAKSZodcHqY4PJsmFb9gNgKV208vBw2fBsH1nMxKZsUdtcWqXGt6DRPcJrQws 6GPYCVJY8NcQSZs138glrNoN/AtsW4A68xIibPAhVRZ9YRTKxjRgup/e5pKNsjKMnzM5 0p8AinJTcSHj+T0+BMirCci8jWZSJME5CtoMku+2QpE4oIFz1YW2Sv6JNyNujDVQHa42 rmBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=36mJhajWQppw1r4vewDK4hFKpILxPms9Bh84cWTmNnE=; fh=bYfFSU2XTEItRctk+6nchXKOSKHpgc6pltayodDbw3U=; b=mW9jPwsqaJ89pZgs8GnErCwBfNAv0OHBMM5BoVXhtHgNeL7eAT7e3dJ4/V7vw6yDaK iN1pG6p9coXFCjA9My+qtdZHbjBuyowZaJkMl4RO4wZ41IvA2eEPKkpA2R+7K0lBZxgA 1yMJQw2q5ZCjIy5w0lMeqfS+6C6QCFO3nrjWiuOSEH+wvqw3JoDmWpU00Wo3gP3TbCMG f6iNNTb2AbsFZUL2WhR4Fo+LmjAn5+QbgbPLMdC8OrIejwZgKQH9BB0F0Vrcmxufdozf zCUvHN4eQZXOsrzhRLA3yt8hkIs+g2B8kLevlMp4dYUI/QyRwCRkt9NU/sdGqYq2fX31 UN+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dLyJ0In8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t22-20020a639556000000b00573f9a427d2si8494259pgn.53.2023.09.12.12.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 12:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dLyJ0In8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E9DB9820BFD5; Tue, 12 Sep 2023 10:52:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237384AbjILRwf (ORCPT + 36 others); Tue, 12 Sep 2023 13:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237034AbjILRwG (ORCPT ); Tue, 12 Sep 2023 13:52:06 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 483841722 for ; Tue, 12 Sep 2023 10:51:51 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c1ff5b741cso53884215ad.2 for ; Tue, 12 Sep 2023 10:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541111; x=1695145911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=36mJhajWQppw1r4vewDK4hFKpILxPms9Bh84cWTmNnE=; b=dLyJ0In8g2tzAQ5nH8ZwWqnx4HAZl3wma3kUpU3lHqzcep8L+N6dc21fRLjJVqJEGn 9tCHwM7fwl7KMPTLAQQzdPCsrVdxWYGS0cL1SA192Vso9ZxgBk7VD06dENJ5n4tAHo91 os/i8RYTEdHw9KJkOizZy0lk9miiljlEyzB9yaWfMsKiv3zxPtbUDqU4MD8kiMvFndQS DsXWvVYbapg08aXZE3lggob+SE+t+6paCLPTbvtAncVsPX9RDtyKGdZuZKNo1wJSsGF4 OQvghNCYoc9+DG9rc9rFh28zRJ/ONzR9XB2/B1KF71Ze+KMueknpoTnm6pkBFb0FKtV2 tjSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541111; x=1695145911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=36mJhajWQppw1r4vewDK4hFKpILxPms9Bh84cWTmNnE=; b=R8BuogUGPUcyGGOZ5vsAWys+Qeob8tStOVoyuVx2nuGB/kozx6DUwh5fyQiSEjk4q1 ft7x2WUCxOT2absQnJw/anECxQc6aB5lnPo4+EvLOvK4xjfSs1aSteNnqrYasbSz4LVM MJXIS778KqMDQpHp9UDZTRez5hE6IJBmYfVtnTRdPhGTubcEFqehQEyx8o1VXeIv45P+ DmlEDpDersHLqGi/SuIZwGl5WsvvtkesjLlWOlej/Db6qhTujzISF8bdbWCkHTKWBd7K 2wFSkihoWxZDx3TOxnu3tUaipEDTgWglZMs5/5xCghL/hPgj5boaGEhQJhwatauMckvB ul1Q== X-Gm-Message-State: AOJu0Yxf+hnXRwP3ZCZTqQioCtwKZwIVXhNrs0zTyNJhvXxZXOALRauR LdMs5lMNMs9RAtqxsCrDmO5Prw== X-Received: by 2002:a17:902:be08:b0:1b0:f8:9b2d with SMTP id r8-20020a170902be0800b001b000f89b2dmr447310pls.29.1694541110710; Tue, 12 Sep 2023 10:51:50 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:50 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel , Conor Dooley Subject: [PATCH v8 15/16] RISC-V: Select APLIC and IMSIC drivers Date: Tue, 12 Sep 2023 23:19:27 +0530 Message-Id: <20230912174928.528414-16-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:52:59 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776860289110757698 X-GMAIL-MSGID: 1776860289110757698 The QEMU virt machine supports AIA emulation and we also have quite a few RISC-V platforms with AIA support under development so let us select APLIC and IMSIC drivers for all RISC-V platforms. Signed-off-by: Anup Patel Reviewed-by: Conor Dooley --- arch/riscv/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d607ab0f7c6d..45c660f1219d 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -153,6 +153,8 @@ config RISCV select PCI_DOMAINS_GENERIC if PCI select PCI_MSI if PCI select RISCV_ALTERNATIVE if !XIP_KERNEL + select RISCV_APLIC + select RISCV_IMSIC select RISCV_INTC select RISCV_TIMER if RISCV_SBI select SIFIVE_PLIC From patchwork Tue Sep 12 17:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 138550 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp804264vqx; Tue, 12 Sep 2023 19:12:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIUKQn2PyG56LL2yTmI1yVIU5N12a1HoDLiwUm2EsN0JczmUzH5Hif1jH2QCLXiAKT1sjy X-Received: by 2002:a17:90a:c90e:b0:263:f630:228f with SMTP id v14-20020a17090ac90e00b00263f630228fmr1048903pjt.23.1694571153313; Tue, 12 Sep 2023 19:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694571153; cv=none; d=google.com; s=arc-20160816; b=emawi0WR6udQWcIxvagsN7CrbXUQx+9c+sTRx28DFgT8ZoTUHT5qtS2VHi0p77BfXU Asfiz+YpAZuMibslKbHHCvpTGZ7/zzhRdlzwb3ou9+Cx4iBiyIRXTlPOiy4+C+nQ+VGu 5wfZ2yquOzDtg9dFHjjcHznojkYiTa80of78yj3r+iQ8XyCb8S7FCMjZCtKRNlPyPnNi p6Vo+kSPk/VZQH/b5rSiBaxgRNra6FlWIUHUCCbmWKOi2Rf2ojRs6nxQytCFGls9PTQA V+VWT8nWbJPcw6KkOE1iDinMVFbpmjAR4ZsL+RfUj6H74X1ny0axVS1xgV9Qk/nGBLyz 7cyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lqTrA/em/7YP7OpnvHuiTizJO+kQoS+OxvFJurohpH4=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=J5ogHhRfofQ6WK3h09+btYqZW102MqW08HkJeRs0J4wQiPWw9NldTGeYgsR4ITJbRT xVSZ9uUC1756rnFh1A1u6c0UizaT5ilmhSu7WO6STe6AQfg/x9U4t6VA2qPwD4WFHQsV q3xkPPV/45PkBAauQZzCResIRbj/SpWT+aTZKujWmNwplXQu/x8PZe4A8sANwO1aBHwe J1fltPpdCKKR/FIY/cXwVdt9WCIUrH+OcctI0lluC1mQgwqIoqTCdOJeMdcJJsS4wf2y wv2bhe2qiK5dXoIPXCNdiodfS+KQk38mcubsTccEUCDzS5d8cSlQRolEkHelK3JBPT6L j65A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=hm6BVyYZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j2-20020a17090a588200b00263d0beafafsi523649pji.181.2023.09.12.19.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 19:12:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=hm6BVyYZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3C3448266317; Tue, 12 Sep 2023 10:53:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237267AbjILRwo (ORCPT + 36 others); Tue, 12 Sep 2023 13:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237403AbjILRwQ (ORCPT ); Tue, 12 Sep 2023 13:52:16 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2CA6213B for ; Tue, 12 Sep 2023 10:51:57 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c336f3f449so51730825ad.3 for ; Tue, 12 Sep 2023 10:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694541117; x=1695145917; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lqTrA/em/7YP7OpnvHuiTizJO+kQoS+OxvFJurohpH4=; b=hm6BVyYZwYf2nDuxAk7P0BzSqkG/XfT4F7k2Qb4OEA2WTvQBHvwWa140YoVrWHC2SF uYvNFmovO3JqyARCcau1w8oCBdB8NMVQaeqgAjnGNuf2NmOJ3jAcSaRNDEql6WGwV2fr 4f+udYXwPGJe2UltmpzJa7z8cfKisVLdC2Y9WcfS27fg/KpuqtLCpDKOwSVQG/LeIom+ zZKisk5bzWTDnHp6y6L8OfYeFJdHk4e/6V+E6iB8+VuXIDQIRfmzIeeNVCuBVq0yXipG hitO37fz8yOMdTh6J/lorsSSrbOb/Vxe+T9wQ86Nk9RZozUD4SL5yHJcp5tfH7Mm2hBO iYcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541117; x=1695145917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lqTrA/em/7YP7OpnvHuiTizJO+kQoS+OxvFJurohpH4=; b=q61e3bgcQ0fMzgb3OAZgp7p6BugVPrujaqzfV8UMOZcH1UxKQqrI98JLWssDOrUiZb Lt8BXogeNfbky4FOWivJKWdyjvMa/CjuDsmdUDWk8n7bvnNZ7wod48CMLBtegxuEE7FW 3+FBkskuJJ99Ylwrlw9DQMQe/M6k+Isc6c0vIZ/2BEE9ZL2o4MxaIzSXrta/LiBNYCZi 7+Sb8UXyvC/LkG90xiBjMjuPxvC2Xx45bjQXhD9CiFRKtHdHbR4RZun9JgMZKwB8x52L v8FMjSwiJpUlwW4t8HDe1r/xafI8y64dZYy4NQH3jTBVjaxYu4KNF17h+AvJSfwZ8ybn G7pg== X-Gm-Message-State: AOJu0Yw0WdqZOmE5DBHpjrlrvTZn30Zyp/MBZXxdmmUge4gFFlS7I5Zf j8MEtsYkLyVcskpd6zQbnctDmg== X-Received: by 2002:a17:902:d2c5:b0:1c3:5d5c:cc99 with SMTP id n5-20020a170902d2c500b001c35d5ccc99mr369320plc.36.1694541117116; Tue, 12 Sep 2023 10:51:57 -0700 (PDT) Received: from localhost.localdomain ([171.76.81.83]) by smtp.gmail.com with ESMTPSA id p12-20020a170902a40c00b001b891259eddsm8691440plq.197.2023.09.12.10.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:51:56 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v8 16/16] MAINTAINERS: Add entry for RISC-V AIA drivers Date: Tue, 12 Sep 2023 23:19:28 +0530 Message-Id: <20230912174928.528414-17-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912174928.528414-1-apatel@ventanamicro.com> References: <20230912174928.528414-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:53:40 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776886641279177866 X-GMAIL-MSGID: 1776886641279177866 Add myself as maintainer for RISC-V AIA drivers including the RISC-V INTC driver which supports both AIA and non-AIA platforms. Signed-off-by: Anup Patel --- MAINTAINERS | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 90f13281d297..6f331ac31d27 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18410,6 +18410,20 @@ S: Maintained F: drivers/mtd/nand/raw/r852.c F: drivers/mtd/nand/raw/r852.h +RISC-V AIA DRIVERS +M: Anup Patel +L: linux-riscv@lists.infradead.org +S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml +F: Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml +F: drivers/irqchip/irq-riscv-aplic-*.c +F: drivers/irqchip/irq-riscv-aplic-*.h +F: drivers/irqchip/irq-riscv-imsic-*.c +F: drivers/irqchip/irq-riscv-imsic-*.h +F: drivers/irqchip/irq-riscv-intc.c +F: include/linux/irqchip/riscv-aplic.h +F: include/linux/irqchip/riscv-imsic.h + RISC-V ARCHITECTURE M: Paul Walmsley M: Palmer Dabbelt