Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5319972rwp; Mon, 17 Jul 2023 01:46:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvaVZWBJ7JpqjVMB4Ls9Gx5OS80p42JwIex7KGcrlqWdCoFLbRsqq9Cy5O29rUufeVU0Lo X-Received: by 2002:a05:6a20:1441:b0:123:828f:68c with SMTP id a1-20020a056a20144100b00123828f068cmr13307379pzi.50.1689583580923; Mon, 17 Jul 2023 01:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689583580; cv=none; d=google.com; s=arc-20160816; b=jJq9bHKF01l13BqYV8xwAQRjFX9No3n1izzH7yOL32Ld1lw+yjWPgl6QWbOPvfoVXR 6jT5bfXN7rjqTv5MqbfI8mvv510MFAnr3RaSvDpSq+Ivhq/8diPLGp4A1GniekgwJwtz Tx/JMgAEaVFxv7I7h4SwJ/lHNDQYBSImw0tPwQwfcm9S5Od2z6uAQyPf03BGScClw127 jMns/E51TmelUBY04REKXCMoZU3jjxMhuZ1QG9Q/Pyb3kmM5PWNue1KkeVyGVdjDk/Rp mVDo/l+bZc0IQelESUbrLy/KE0F5AjL/smjW0qLwumq7SMyDLwfN2MGutMTfcqmE9CV/ yBIg== 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=0pNKwHQV4T9MzZEJJq8jYbGybU/B65jOoO3ccR/Z2h8=; fh=L0XOJg025aaag+RCG4aCpKIm3V/qTfEBidUY6gTDAeE=; b=F+WXMlduhHE/fJuVqLAxMZU0i9G8GFOsmzzGwmvDhSfc3FBXtmsmUDuaI8Kevx8Ptp MWPChfyqD+JkQulK1HJC+fCoRwBx7tkicLKPVSuTZBk89IIh3ocvgiLmuV5wzZjvR/fE Pqu3PzD/RLpS8DQnx2Nj2WU6WgIcwsHsr6OExibzxlRNSKnzxx4XTQltwfkNbq4AWyV+ srT4jRCPIKHOXiO4Zwr0Gfe0Udfrs93b2LCIIPuOX/B6AjgExjkQAcmuIstg71+tHG7r 60/jaII31Mu3eDuYH4gxx4rE+Zkk1JG7Ir+laY9f38soKLiaWOUBqX3q71+JZ7nLo8R0 yjVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YJ9ZPNl6; 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 w67-20020a636246000000b0055c79555b97si8010806pgb.876.2023.07.17.01.46.07; Mon, 17 Jul 2023 01:46:20 -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=YJ9ZPNl6; 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 S231232AbjGQIGX (ORCPT + 99 others); Mon, 17 Jul 2023 04:06:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbjGQIGV (ORCPT ); Mon, 17 Jul 2023 04:06:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 128301B6; Mon, 17 Jul 2023 01:05:43 -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 A528C60FC3; Mon, 17 Jul 2023 08:05:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7566C433C7; Mon, 17 Jul 2023 08:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689581142; bh=46YRuhlRY7c+LYecTNMxpUt1Pqhr6LxrNXXMX9FblS8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YJ9ZPNl69moiTL72CtguPknDitu9OYCgTsJ1oohTyF1xD9D7scok/HBn6g558ydmr w4J9kIB46QEYnPH7PTmfVhWc8q1e9RJEM0Np66ZpYP2TDUP31ncREtXa1DjX4N26q0 YNN48134XAQBpEo2sP2oJ/JF8P7Ng8qH8/NfV46yHBna/6mt0UTf7Lo9EpzK/7M71f 8lw1cZ+h/x1jPmSy9kaPPSw2CUwHDsCggyT/MavGe1bpqhyJQwmV8Iic3ZBvwqctyX rRLK0naXMu4oKGp5TwUws64y3gKY+xyaxZstv5By2W2eXn4geCQd9R/JmE/OytHXz5 akddHBScOHDWA== 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 1qLJEf-00Df2M-Oo; Mon, 17 Jul 2023 09:05:39 +0100 Date: Mon, 17 Jul 2023 09:05:37 +0100 Message-ID: <868rbfufn2.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> 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: anup@brainfault.org, apatel@ventanamicro.com, 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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Fri, 14 Jul 2023 15:05:07 +0100, Anup Patel wrote: >=20 > On Fri, Jul 14, 2023 at 7:05=E2=80=AFPM Marc Zyngier wro= te: > > > > 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) specification = defines > > > > > > a new interrupt controller for managing wired interrupts on a R= ISC-V > > > > > > platform. This new interrupt controller is referred to as advan= ced > > > > > > platform-level interrupt controller (APLIC) which can forward w= ired > > > > > > interrupts to CPUs (or HARTs) as local interrupts OR as message > > > > > > signaled interrupts. > > > > > > (For more details refer https://github.com/riscv/riscv-aia) > > > > > > > > > > > > This patch adds an irqchip driver for RISC-V APLIC found on RIS= C-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 early > > > > > > + * so for device tree: > > > > > > + * > > > > > > + * 1) Set the FWNODE_FLAG_BEST_EFFORT flag in fwnode wh= ich > > > > > > + * provides a hint to the device driver core to prob= e the > > > > > > + * platform driver early. > > > > > > + * 2) Clear the OF_POPULATED flag in device_node because > > > > > > + * 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 thi= s 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 "discussio= n" > > > > 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 poi= nt > > > > it cannot be a platform device, and the story is pretty simple. > > > > > > > > - or it isn't that fundamental, and it can be probed as a platform > > > > device using the dependency infrastructure that is already used 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 difficult > > 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 this > > for even a second. >=20 > 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 > > > > 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 purpose > > being early drivers. They must be platform drivers, and only that. >=20 > We can have IMSIC and APLIC-Direct-Mode as non-platform driver > whereas APLIC-as-MSI-bridge will be a platform driver. >=20 > Both APLIC-Direct-Mode and APLIC-as-MSI-bridge can share a large > part of the current driver. >=20 > > > > > > If these rules don't apply to your stuff, please explain what is so > > > > different. And I mean actually explain the issue. Which isn't telli= ng > > > > 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 methods. > > > > > > 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*. >=20 > Both APLIC and IMSIC are separate devices as defined by the AIA spec. >=20 > 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? > 3) Systems with both APLIC and IMSIC (i.e. both wired interrupts and MSIs) >=20 > To address the above, APLIC and IMSIC are separate drivers. I am okay > with splitting the APLIC driver into two separate drivers . Again, we don't have to follow the split established by the architecture. Instead, we should follow what is *functionally correct* for the kernel. If we were to write Risc-V-OS, that'd be an acceptable solution. But this is Linux, and the constraints are different. My take on this discussion is that we should have: - Direct-mode APLIC + IPI support as a an early irqchip driver - MSI-bridge APLIC + MSI support as platform driver Yes, these will likely share most of their code. But at least the split will be manageable, and will avoid ugly hacks. M. --=20 Without deviation from the norm, progress is not possible.