Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5378116rwp; Mon, 17 Jul 2023 03:07:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXToFrhzMZCE9vh+g51zN0azyckqEBQuA4N9I+eiHn9YEpJb5h9LywtRIAzMDioKf4MUwf X-Received: by 2002:a17:902:e851:b0:1b8:987f:39c0 with SMTP id t17-20020a170902e85100b001b8987f39c0mr12758167plg.28.1689588426668; Mon, 17 Jul 2023 03:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689588426; cv=none; d=google.com; s=arc-20160816; b=V3df1OK5QKKWVmDa729o8qAAVpIUoy1R/fHwXN41bmPIIoF5p3HkVa/1UFoPyOAgV6 Ulpabi0QFIEduIG4RNUcaE9zpwcvUDWLZV4JELZQtyHxu23C3VbDOvgoa/xeLQXWbTTO DrmYAbsIAuaAVWzUp7A+eLzmfqHC8HImXUZD5kMGgUPaUT9y6sCAEC8p2athees6tNsc 3gp9CjqRnp1DMITCo5UvBMLMywr3/JTIrnfWYn2De/WONKY3oI5a5tbohOuqamj3NnHS R8bQFbcJu39aj89WXyXShaIXY4iHkxUgtc5vrI0x9OIdbfElDgKbHLZ34mNyu30Rjlcy Cs4g== 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 :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=Xzhddp+QMyLNHX1H8RgAM5L7NGp7+pVm0xtioj9tndY=; fh=K4zJjfbpuiP8O1eM1PeJfYIZ4nEq0zBCh9PsXKXHyMU=; b=KXweaX+MxJ8Z4KTYqODVH3t9W7c1OrnnJvZdkf1TrCrJxSrVLF1gXxUNe3aLo71prr 9FBiFXN7jEM0X0GjBg7DiXEqf8gclaEhDiBZQfYHKj5AQM+gC7CuLqfMlE+IO9lHwcwU pULXtwtt+pLHu0KkRmu7aPg8UokmUgQnhRw0OTU1y2tk44gMHfuNSTnWWu2SRTaN2r2J hY/nhCbxNkkeSXCKzuhXW5PalW6fQXeLjTGp6wvtTsyMjN/z7ugSp41xIiXA0swEM7U+ FbYmFlJ8C4FXIrza2fNNBYNUoNcEEcehFaNuFzGDztiDDakAFoQWXV5yEPBBw4F/lQbW Eg5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oxoQSO72; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a170903124f00b001b9d180fd9asi11780102plh.121.2023.07.17.03.06.54; Mon, 17 Jul 2023 03:07:06 -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=@kernel.org header.s=k20201202 header.b=oxoQSO72; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbjGQJs5 (ORCPT + 99 others); Mon, 17 Jul 2023 05:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbjGQJsd (ORCPT ); Mon, 17 Jul 2023 05:48:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28DE813D; Mon, 17 Jul 2023 02:48:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 938D761000; Mon, 17 Jul 2023 09:48:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7658C433C8; Mon, 17 Jul 2023 09:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689587311; bh=JdKVUUp6m0Uye11so85pYdbz5La3leOelaYQhIMR/ow=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oxoQSO72xKHk5tAprUaf/IoUnkyd4nPgQOmA4cNPs0Pwqvf7arZNFCaNDtXqnKyDm LwriU5lzm7OQtL2/QtWxb4lJPBaQcP6es/8cDYuI5/LTfHYQeR51ECAQHTKLas0eXb 5Ti50RDLr5eHNO8fv53d0BeMuugKkPukujsw/g6d+EXMBUE/jG/HVz8UHvb6pT9yN0 BELBKLd229ZPw6fnG3ElF2ltYVVFi/ceD5Jb0HVbSlLd9gfNqMDw0e+gsGSiMVVE0n rLX77uGJtjxGAHl/r4PGOFZRfE0GDkyCsAPg058zTd3X4UhPlfVPmlsuEwNKWE1VRw 6xSJNGo55N1gA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qLKqC-00DgoU-Ej; Mon, 17 Jul 2023 10:48:28 +0100 Date: Mon, 17 Jul 2023 10:48:28 +0100 Message-ID: <865y6ivpg3.wl-maz@kernel.org> From: Marc Zyngier To: Anup Patel Cc: Anup Patel , Saravana Kannan , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Atish Patra , Andrew Jones , Sunil V L , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v5 7/9] irqchip: Add RISC-V advanced PLIC driver In-Reply-To: References: <20230710094321.1378351-1-apatel@ventanamicro.com> <20230710094321.1378351-8-apatel@ventanamicro.com> <86jzv2vpdb.wl-maz@kernel.org> <86cz0uvcof.wl-maz@kernel.org> <868rbfufn2.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/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: apatel@ventanamicro.com, anup@brainfault.org, saravanak@google.com, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, atishp@atishpatra.org, ajones@ventanamicro.com, sunilvl@ventanamicro.com, conor@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Mon, 17 Jul 2023 10:05:01 +0100, Anup Patel wrote: >=20 > On Mon, Jul 17, 2023 at 1:35=E2=80=AFPM Marc Zyngier wro= te: > > > > On Fri, 14 Jul 2023 15:05:07 +0100, > > Anup Patel wrote: > > > > > > On Fri, Jul 14, 2023 at 7:05=E2=80=AFPM Marc Zyngier = wrote: > > > > > > > > On Fri, 14 Jul 2023 10:35:34 +0100, > > > > Anup Patel wrote: > > > > > > > > > > On Fri, Jul 14, 2023 at 2:31=E2=80=AFPM Marc Zyngier wrote: > > > > > > > > > > > > Anup, > > > > > > > > > > > > On Fri, 14 Jul 2023 00:56:22 +0100, > > > > > > Saravana Kannan wrote: > > > > > > > > > > > > > > On Mon, Jul 10, 2023 at 2:44=E2=80=AFAM Anup Patel wrote: > > > > > > > > > > > > > > > > The RISC-V advanced interrupt architecture (AIA) specificat= ion defines > > > > > > > > a new interrupt controller for managing wired interrupts on= a RISC-V > > > > > > > > platform. This new interrupt controller is referred to as a= dvanced > > > > > > > > platform-level interrupt controller (APLIC) which can forwa= rd wired > > > > > > > > interrupts to CPUs (or HARTs) as local interrupts OR as mes= sage > > > > > > > > signaled interrupts. > > > > > > > > (For more details refer https://github.com/riscv/riscv-aia) > > > > > > > > > > > > > > > > This patch adds an irqchip driver for RISC-V APLIC found on= RISC-V > > > > > > > > platforms. > > > > > > > > > > > > > > > > Signed-off-by: Anup Patel > > > > > > > > > > > > [...] > > > > > > > > > > > > > > +static int __init aplic_dt_init(struct device_node *node, > > > > > > > > + struct device_node *parent) > > > > > > > > +{ > > > > > > > > + /* > > > > > > > > + * The APLIC platform driver needs to be probed ear= ly > > > > > > > > + * so for device tree: > > > > > > > > + * > > > > > > > > + * 1) Set the FWNODE_FLAG_BEST_EFFORT flag in fwnod= e which > > > > > > > > + * provides a hint to the device driver core to = probe the > > > > > > > > + * platform driver early. > > > > > > > > + * 2) Clear the OF_POPULATED flag in device_node be= cause > > > > > > > > + * of_irq_init() sets it which prevents creation= of > > > > > > > > + * platform device. > > > > > > > > + */ > > > > > > > > + node->fwnode.flags |=3D FWNODE_FLAG_BEST_EFFORT; > > > > > > > > > > > > > > Please stop spamming us with broken patches. Already told you= this is > > > > > > > not an option. > > > > > > > > > > > > > > Nack. > > > > > > > > > > > > What puzzles me here is that *no other arch* requires this sort= of > > > > > > hack. What is so special about the APLIC that it requires it? I= see > > > > > > nothing in this patch that even hints at it, despite the "discu= ssion" > > > > > > in the last round. > > > > > > > > > > > > The rules are simple: > > > > > > > > > > > > - either the APLIC is so fundamental to the system that it has = to be > > > > > > initialised super early, much like the GIC on arm64, at which= point > > > > > > it cannot be a platform device, and the story is pretty simpl= e. > > > > > > > > > > > > - or it isn't that fundamental, and it can be probed as a platf= orm > > > > > > device using the dependency infrastructure that is already us= ed by > > > > > > multiple other interrupt controller drivers, without any need= to > > > > > > mess with internal flags. Again, this should be simple enough. > > > > > > > > > > APLIC manages all wired interrupts whereas IMSIC manages all > > > > > MSIs. Both APLIC and IMSIC are fundamental devices which need > > > > > to be probed super early. > > > > > > > > > > Now APLIC has two modes of operations: > > > > > 1) Direct mode where there is no IMSIC in the system and APLIC > > > > > directly injects interrupt to CPUs > > > > > 2) MSI mode where IMSIC is present in the system and APLIC > > > > > converts wired interrupts into MSIs > > > > > > > > > > The APLIC driver added by this patch is a common driver for > > > > > both above modes. > > > > > > > > Which it doesn't need to be. You are pointlessly making life diffic= ult > > > > for yourself, and everyone else. The MSI bridge behaviour has *zero* > > > > reason to be the same driver as the main "I need it super early" > > > > driver. They may be called the same, but they *are* different things > > > > in the system. > > > > > > > > They can share code, but they are fundamentally a different thing in > > > > the system. And I guess this silly approach has other ramifications: > > > > the IMSIC is also some early driver when it really doesn't need to = be. > > > > Who needs MSIs that early in the life of the system? I don't buy th= is > > > > for even a second. > > > > > > IMSIC also provides IPIs which are required super early so I think > > > we can't make IMSIC as a platform driver. > > > > Then split this part further. Just because the architecture lumps two > > completely unrelated concepts together doesn't mean we need to follow > > the same organisation. >=20 > IPIs are supported as software injected MSIs. Basically, each HART > has its own MSI controller and one HART can inject IPI to other HART > by writing its MSI MMIO register. >=20 > > > > > > > > > > > > > Frankly, this whole thing needs to be taken apart and rebuilt from = the > > > > ground up. > > > > > > > > > For #2, APLIC needs to be a platform device to create a device > > > > > MSI domain using platform_msi_create_device_domain() which > > > > > is why the APLIC driver is a platform driver. > > > > > > > > You can't have your cake and eat it. If needed super early, and it > > > > cannot be a platform driver. End of the story. > > > > > > > > And to my earlier point: IMSIC and APLIC-as-MSI-bridge have no purp= ose > > > > being early drivers. They must be platform drivers, and only that. > > > > > > We can have IMSIC and APLIC-Direct-Mode as non-platform driver > > > whereas APLIC-as-MSI-bridge will be a platform driver. > > > > > > Both APLIC-Direct-Mode and APLIC-as-MSI-bridge can share a large > > > part of the current driver. > > > > > > > > > > > > > If these rules don't apply to your stuff, please explain what i= s so > > > > > > different. And I mean actually explain the issue. Which isn't t= elling > > > > > > us "it doesn't work without it". Because as things stand, there= is no > > > > > > way I will even consider taking this ugly mix of probing method= s. > > > > > > > > > > Yes, I don't want this ugly FWNODE_FLAG_BEST_EFFORT hack > > > > > in this driver. > > > > > > > > And yet you are hammering it even when told this is wrong. > > > > > > > > > I tried several things but setting the FWNODE_FLAG_BEST_EFFORT > > > > > flag is the only thing which works right now. > > > > > > > > How about you take a step back and realise that the way you've > > > > architected your drivers makes little sense? I don't think you have > > > > tried *that*. > > > > > > Both APLIC and IMSIC are separate devices as defined by the AIA spec. > > > > > > There are three possible systems: > > > 1) Systems with only APLIC (i.e. only wired interrupts) > > > 2) Systems with only IMSIC (i.e. only MSIs) > > > > How is that possible? Are you saying that even things like timers are > > firing as MSIs? >=20 > No, timer interrupts are triggered through INTC. So all the above is BS. All you need is timers and IPIs to be supported early. Everything else can be postponed until you probe the rest of the interrupt hierarchy. M. --=20 Without deviation from the norm, progress is not possible.