From patchwork Mon May 8 11:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 91101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2115526vqo; Mon, 8 May 2023 05:27:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LWFO8e3l0HUNZ9TnE8iPPAO36p+d32SzQvq7eAZ5YntpovLSlCs2tsdHDTqO5xul5aBkJ X-Received: by 2002:a17:902:f7d6:b0:1a9:f425:5409 with SMTP id h22-20020a170902f7d600b001a9f4255409mr10523044plw.49.1683548868340; Mon, 08 May 2023 05:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683548868; cv=none; d=google.com; s=arc-20160816; b=H0zNFEjDYULRXEt53qZYKsNc5Wd+1P+9TbEW7fnAd9+IlUQ9pR4AX3WQ8e1cwiw+Bl yKY4osFs/o/+DrfvtBeTsEhP/ZBKmy2k3vyPkfdjM/apMAcg03XNzjrnJJ57tAfws41f 6JV3r801lYnwdCrfIHeJzKKlU9pZIt/oamys9hi0+h2Eq8tBBtwC7I+y1VhpjUjTnxAk ngpMuMuuSUDFqYYtTVEOSvWB0GAzIUeX67fioEl331sKfKnXAfvG0fU8/nTy6/vsWxej ma3qgvzahZNRHKpkCV3NJqFqU2lARy3rUFx+4niE8BihSuqGm7mkb3Jjlz3QKrYRp+wf qdUg== 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=GSuTggFYj3JSbFizfFEsySbatkGCHwC0oNgPzvEucIg=; b=PF9nmy3dt+cZWfPj/OQTsYn9ZlTEukt/DDgHJZ6n4Lh36MZj3EYWXUILmVKMJXm9p6 RJMywrJTetRC5qfj5oMvsDdJWSOHATtpn0O+lPrR2/o41SbBDvCyzKnPtt+oFJ7tMZ0n a92TunPl3ee8bHenv8auZMDF4qsAUfVMQSMkq2O/hq+Ex5TYnJ0fYxWgPGtfVCkc5den S4QVaRXX+GzVkTmG4BgnUQ3EPC2JPnq2JdW7HGsekDCbmlcXBY/Tnb8LiMbMjN7QW4ND 9D8s320Gl4mOMj7D4Q+IkUQ7hizxD3Dk83LoNVCjES9Ob6aT2sNDB2l8ULLZtPp9FUYj uLug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OwnBVNyw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170902ed1100b001a27afc07d9si5512780pld.146.2023.05.08.05.27.33; Mon, 08 May 2023 05:27:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OwnBVNyw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236404AbjEHL50 (ORCPT + 99 others); Mon, 8 May 2023 07:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233475AbjEHL4r (ORCPT ); Mon, 8 May 2023 07:56:47 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7A3E43BA6 for ; Mon, 8 May 2023 04:55:07 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1aaebed5bd6so30378655ad.1 for ; Mon, 08 May 2023 04:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1683546900; x=1686138900; 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=GSuTggFYj3JSbFizfFEsySbatkGCHwC0oNgPzvEucIg=; b=OwnBVNyw27EdkLus1jTOuwbndB2EL2oVzQ7k7WqNfE23/8qlo+tk8UFosj4+DGtIEM we9+O1U8hj7m0aWDcbRQxN5ACgyeeG2VJSTA+BGXf0Lc91Yu3v8w6YkG0P9tVDrl1Pjb M/Jj9HtGkwPWIa+gtgQXauU7tRECTZ4MSLSX7eV6SQDAJy5Q22e88y0ohlQ2w+9nI9vm 4cLX6IAHT9CSG0m6PilY/qusyz8K+wT4LRCKXTzhosGOyZItkPHdE81/RAXq3F3cHu9l MrD0rX8pil+aPxPPGWzdKtYQEVz9zLmR7W/XzVVJNkvN4gGzVcNn/RllSUoQVTVxW2HZ pP5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683546900; x=1686138900; 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=GSuTggFYj3JSbFizfFEsySbatkGCHwC0oNgPzvEucIg=; b=EIP/WPVQRd2wxaK2Lc0JIzUXm5bXJsL3NQ4taL3N535Z1Dt2NNNGDr50UHDTrDSyD1 /QMMVAT9pYXnjAwNO2n9tccJAglPLeqRL2f11cW7U+6mjkDgShcRi+OlNo5j6b42F15b 1mz3hQwGLnDb3ADjAh96BxGlzegYBREnJOTNt+ZSOeUeNIJtSPjVBAxUJoRZwP9LUqf+ 4kOdvZG7xeokVPnIk6BXW45lg0FUG+qdG5P5WJtHg8o9rx7sk0GsGemGHsL8Zobh1KeI tazVHmro1E2iBFspYdXqHAccFmiijCmYvF3NQEK7hjqM5NGkUuKenZ4VVOEKRiTer6BX w6Aw== X-Gm-Message-State: AC+VfDylIZVVn9PuVcbeUQhj9HSvJR2Y0OQqMe0LCogGnM6P/fV6jtxT VFZgUNmzY/08fe0+y55LfJZZhg== X-Received: by 2002:a17:902:eccc:b0:1a6:6b85:7b4a with SMTP id a12-20020a170902eccc00b001a66b857b4amr12146859plh.18.1683546899877; Mon, 08 May 2023 04:54:59 -0700 (PDT) Received: from sunil-laptop.. ([106.51.189.144]) by smtp.gmail.com with ESMTPSA id w9-20020a170902904900b001aaed524541sm7015149plz.227.2023.05.08.04.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 04:54:59 -0700 (PDT) From: Sunil V L To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-crypto@vger.kernel.org, platform-driver-x86@vger.kernel.org, llvm@lists.linux.dev Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Daniel Lezcano , Thomas Gleixner , Weili Qian , Zhou Wang , Herbert Xu , "David S . Miller" , Marc Zyngier , Maximilian Luz , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , Sunil V L , "Rafael J . Wysocki" , Andrew Jones , Conor Dooley Subject: [PATCH V5 15/21] irqchip/riscv-intc: Add ACPI support Date: Mon, 8 May 2023 17:22:31 +0530 Message-Id: <20230508115237.216337-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230508115237.216337-1-sunilvl@ventanamicro.com> References: <20230508115237.216337-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765328938142442043?= X-GMAIL-MSGID: =?utf-8?q?1765328938142442043?= Add support for initializing the RISC-V INTC driver on ACPI platforms. Signed-off-by: Sunil V L Acked-by: Rafael J. Wysocki Reviewed-by: Andrew Jones Reviewed-by: Conor Dooley --- drivers/irqchip/irq-riscv-intc.c | 70 +++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index f229e3e66387..4adeee1bc391 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -6,6 +6,7 @@ */ #define pr_fmt(fmt) "riscv-intc: " fmt +#include #include #include #include @@ -112,6 +113,30 @@ static struct fwnode_handle *riscv_intc_hwnode(void) return intc_domain->fwnode; } +static int __init riscv_intc_init_common(struct fwnode_handle *fn) +{ + int rc; + + intc_domain = irq_domain_create_linear(fn, BITS_PER_LONG, + &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 (rc) { + pr_err("failed to set irq handler\n"); + return rc; + } + + riscv_set_intc_hwnode_fn(riscv_intc_hwnode); + + pr_info("%d local interrupts mapped\n", BITS_PER_LONG); + + return 0; +} + static int __init riscv_intc_init(struct device_node *node, struct device_node *parent) { @@ -133,24 +158,39 @@ static int __init riscv_intc_init(struct device_node *node, if (riscv_hartid_to_cpuid(hartid) != smp_processor_id()) return 0; - intc_domain = irq_domain_add_linear(node, BITS_PER_LONG, - &riscv_intc_domain_ops, NULL); - if (!intc_domain) { - pr_err("unable to add IRQ domain\n"); - return -ENXIO; - } + return riscv_intc_init_common(of_node_to_fwnode(node)); +} - rc = set_handle_irq(&riscv_intc_irq); - if (rc) { - pr_err("failed to set irq handler\n"); - return rc; - } +IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); - riscv_set_intc_hwnode_fn(riscv_intc_hwnode); +#ifdef CONFIG_ACPI - pr_info("%d local interrupts mapped\n", BITS_PER_LONG); +static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct fwnode_handle *fn; + struct acpi_madt_rintc *rintc; - return 0; + rintc = (struct acpi_madt_rintc *)header; + + /* + * The ACPI MADT will have one INTC for each CPU (or HART) + * so riscv_intc_acpi_init() function will be called once + * for each INTC. We only do INTC initialization + * for the INTC belonging to the boot CPU (or boot HART). + */ + if (riscv_hartid_to_cpuid(rintc->hart_id) != smp_processor_id()) + return 0; + + fn = irq_domain_alloc_named_fwnode("RISCV-INTC"); + if (!fn) { + pr_err("unable to allocate INTC FW node\n"); + return -ENOMEM; + } + + return riscv_intc_init_common(fn); } -IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); +IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, + ACPI_MADT_RINTC_VERSION_V1, riscv_intc_acpi_init); +#endif