Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5482009pxb; Wed, 26 Jan 2022 13:05:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4hT7k8qaRaEGJOX4tZKEeBfDIU1bUfwM2yq6BFZwNGKrl1eqmdzTIisZrM7BS7do3gUbm X-Received: by 2002:a17:902:c7cb:: with SMTP id r11mr391880pla.135.1643231114256; Wed, 26 Jan 2022 13:05:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643231114; cv=none; d=google.com; s=arc-20160816; b=s5O3VlNWg+vDG+hh74EdNO9Rkn+laDzIy4VU4CkZ5bjsgGUlZjBr3Dus6ku6FooNCO cwxpsTSr0YB5Uyq6Hk+D7KbfRn0QevO4N6oMvs7pDSZ41L3k/uvxff8A5e03He6K+fqU zDqbU1G2g8LhdJgwOSWA6KFfepEOPg1dYEnfGG9R6qXTAp5j6rAyNNzDriJYVbUvsGL2 cj5Z+c8suYSGP+6MbJv43f2oM4o4rsf4mfdPgU8fEP6LgEYSBMF5f9NWC/dJlUD7yyQ8 5FNvRFbHwYp/97e+wXd/lqeq8Z2v3L5VRjXJFwh9dVP/AfnVgBW53KDjxCOSjRPhLkC9 LuJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=xXfKV6oFG9X8dVfSz5rVHifhtq818BcMomeua8N05fc=; b=Ibq6Cy0nOgmHaifxCw1ffdt/i8FJYsBQ1sMpccyifu2hXyimB5KejY5ajht3GII6sU 8IBkPvBSaggu3MGRg8GyC4/arT9vwIPGhr04Z85szxYbwrESYUm4/YFZ5oZbUaOeQTGI G8QW++lV0k45Peh47irpOq7DNC+eOu8TBmXLelP51Je4x0SZrUruUzA5c9DcJc7D7msJ D1AKclaskPLw/Wk/Gy3l8OyGcFawqrK/qmPV1F16qHwCccOGLKcwsrErHPGzBYYmT9Z5 mEWVc99wvMnhZJtMDFoMeVES5d5BTu7Cod6AaLl56K0KPj/nsOXHfbNnTBp7BD/4qyQr etMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VOQk1TeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si271056pfd.342.2022.01.26.13.05.01; Wed, 26 Jan 2022 13:05:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VOQk1TeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240182AbiAZKrE (ORCPT + 99 others); Wed, 26 Jan 2022 05:47:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240177AbiAZKrC (ORCPT ); Wed, 26 Jan 2022 05:47:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98DF5C06161C for ; Wed, 26 Jan 2022 02:47:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C1C7B81C10 for ; Wed, 26 Jan 2022 10:47:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B641C340E3; Wed, 26 Jan 2022 10:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643194020; bh=J5SBi4isD3eLyC9DrQ37B+AuK48/7awuYs3XRR1bZVg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VOQk1TeYp4o7RV06yBaNACg/ZLyYk5NBp2jUD993soo4AbAjtpkAO4sPgVBOEIE6d YX1m9kokA7DFCJdBPCYNY0G3jMoflGjinASnp2nHZRqKSiWdGgQHQBN3wYBrsF2MyP mURIJboc5HiSc3EgoIPEcf02Fr95E4hP7G6bOO3ZmjESu6iMsZ8mjZzyflBPz5V7bu FOW8onN8HT2mSyTsklno/XRc+FHjHQG9Vm42+eUdR0iHiglfXJfZ/26mEmIKC+Cb60 MXm3pU0Bg/cGFlq1WTXrOTdTSgNNY0ug86AT6LgKjGP41tOY+KIU5TmEFWByNB+kpx JUw4ZK61zvZXQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nCfpK-003BPe-2w; Wed, 26 Jan 2022 10:46:58 +0000 Date: Wed, 26 Jan 2022 10:46:57 +0000 Message-ID: <87fspa7p0e.wl-maz@kernel.org> From: Marc Zyngier To: Anup Patel Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Daniel Lezcano , Rob Herring , Atish Patra , Alistair Francis , linux-riscv , "linux-kernel@vger.kernel.org List" Subject: Re: [PATCH 2/6] irqchip/riscv-intc: Set intc domain as the default host In-Reply-To: References: <20220125054217.383482-1-apatel@ventanamicro.com> <20220125054217.383482-3-apatel@ventanamicro.com> <87lez37k8h.wl-maz@kernel.org> <87ilu67tvw.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: apatel@ventanamicro.com, anup@brainfault.org, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, daniel.lezcano@linaro.org, robh+dt@kernel.org, atishp@atishpatra.org, Alistair.Francis@wdc.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 26 Jan 2022 10:12:25 +0000, Anup Patel wrote: > > On Wed, Jan 26, 2022 at 2:31 PM Marc Zyngier wrote: > > > > On Wed, 26 Jan 2022 03:16:55 +0000, > > Anup Patel wrote: > > > > > > On Tue, Jan 25, 2022 at 11:47 PM Marc Zyngier wrote: > > > > > > > > On Tue, 25 Jan 2022 05:42:13 +0000, > > > > Anup Patel wrote: > > > > > > > > > > We have quite a few RISC-V drivers (such as RISC-V SBI IPI driver, > > > > > RISC-V timer driver, RISC-V PMU driver, etc) which do not have a > > > > > dedicated DT/ACPI fwnode. This patch makes intc domain as the default > > > > > host so that these drivers can directly create local interrupt mapping > > > > > using standardized local interrupt numbers > > > > > > > > > > Signed-off-by: Anup Patel > > > > > --- > > > > > drivers/clocksource/timer-riscv.c | 17 +---------------- > > > > > drivers/irqchip/irq-riscv-intc.c | 9 +++++++++ > > > > > 2 files changed, 10 insertions(+), 16 deletions(-) > > > > > > > > > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > > > > > index 1767f8bf2013..dd6916ae6365 100644 > > > > > --- a/drivers/clocksource/timer-riscv.c > > > > > +++ b/drivers/clocksource/timer-riscv.c > > > > > @@ -102,8 +102,6 @@ static irqreturn_t riscv_timer_interrupt(int irq, void *dev_id) > > > > > static int __init riscv_timer_init_dt(struct device_node *n) > > > > > { > > > > > int cpuid, hartid, error; > > > > > - struct device_node *child; > > > > > - struct irq_domain *domain; > > > > > > > > > > hartid = riscv_of_processor_hartid(n); > > > > > if (hartid < 0) { > > > > > @@ -121,20 +119,7 @@ static int __init riscv_timer_init_dt(struct device_node *n) > > > > > if (cpuid != smp_processor_id()) > > > > > return 0; > > > > > > > > > > - domain = NULL; > > > > > - child = of_get_compatible_child(n, "riscv,cpu-intc"); > > > > > - if (!child) { > > > > > - pr_err("Failed to find INTC node [%pOF]\n", n); > > > > > - return -ENODEV; > > > > > - } > > > > > - domain = irq_find_host(child); > > > > > - of_node_put(child); > > > > > - if (!domain) { > > > > > - pr_err("Failed to find IRQ domain for node [%pOF]\n", n); > > > > > - return -ENODEV; > > > > > - } > > > > > - > > > > > - riscv_clock_event_irq = irq_create_mapping(domain, RV_IRQ_TIMER); > > > > > + riscv_clock_event_irq = irq_create_mapping(NULL, RV_IRQ_TIMER); > > > > > if (!riscv_clock_event_irq) { > > > > > pr_err("Failed to map timer interrupt for node [%pOF]\n", n); > > > > > return -ENODEV; > > > > > diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c > > > > > index b65bd8878d4f..9f0a7a8a5c4d 100644 > > > > > --- a/drivers/irqchip/irq-riscv-intc.c > > > > > +++ b/drivers/irqchip/irq-riscv-intc.c > > > > > @@ -125,6 +125,15 @@ static int __init riscv_intc_init(struct device_node *node, > > > > > return rc; > > > > > } > > > > > > > > > > + /* > > > > > + * Make INTC as the default domain which will allow drivers > > > > > + * not having dedicated DT/ACPI fwnode (such as RISC-V SBI IPI > > > > > + * driver, RISC-V timer driver, RISC-V PMU driver, etc) can > > > > > + * directly create local interrupt mapping using standardized > > > > > + * local interrupt numbers. > > > > > + */ > > > > > + irq_set_default_host(intc_domain); > > > > > > > > No, please. This really is a bad idea. This sort of catch-all have > > > > constantly proven to be a nuisance, because they discard all the > > > > topology information. Eventually, you realise that you need to know > > > > where this is coming from, but it really is too late. > > > > > > > > I'd rather you *synthesise* a fwnode (like ACPI does) rather then do > > > > this. > > > > > > In absence of INTC as the default domain, currently we have various > > > drivers looking up INTC irq_domain from DT (or ACPI). This is quite a > > > bit of duplicate code across various drivers. > > > > > > How about having a irq_domain lookup routine (riscv_intc_find_irq_domain()) > > > exported by the RISC-V INTC driver or arch/riscv ? > > > OR > > > Do you have an alternative suggestion ? > > > > But *why* don't you provide an interrupt controller node for DT? I > > really don't think that's outlandish to require. > > Historically, all RISC-V SBI related drivers never had any DT/ACPI > node because we can always query/discover the SBI functionality > at runtime. > > The mechanism to query/discover SBI IPI, Timer and PMU is > through SBI base functions. Also, local interrupts used by these > drivers are specified by the RISC-V specification. This means having > a DT/ACPI node for these drivers doesn't provide any info. > > We will be having KVM RISC-V AIA support in future which will not > have a DT/ACPI node as well because this can be discovered as a > CPU capability and the local interrupt to be used is specified by the > RISC-V hypervisor specification. > > > > > For ACPI, we already have an interface that allows a fwnode to be > > registered (acpi_set_irq_model) and interrupts mapped > > (acpi_register_gsi). > > The ACPI specification being proposed for RISC-V does not have > any details for SBI IPI, Timer, and PMU for the same reasons > mentioned above. Neither does it on the other architectures. And yet we are able to synthesise fwnodes and use the whole of the infrastructure as intended without having to resort to this crap that was only introduced to cope with 20 year old PPC board files. Only dead architectures are using irq_set_default_host(). > > > > > You should already have all the required tools you need. > > Are you okay if arch/riscv exports riscv_intc_find_irq_domain() ? > OR > Maybe export riscv_intc_find_irq_domain() from INTC driver ? Neither. That's just papering over the core problem. Either you start creating fwnodes out of thin air, which is what we do for both x86 and arm64 when using ACPI, or you add support for SBI (or whatever new spec the RISC-V people come up with) as a provider of fwnodes. Anything else looks like a pretty bad regression. Thanks, M. -- Without deviation from the norm, progress is not possible.