From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACC25C52D7D for ; Sat, 17 Aug 2024 07:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Scgmx1Gy14t/+J79KcdymAvZdzIGaTJBly1hyr+iYTA=; b=2VZU7TmtY32Ok88oIYPhyq0N6d tKwopkc2QFPWTvl0NKwUIiIJpGwGy6r10+baf1P9OacgJN/eTMtQ+zM7HX6/whpOBz5WozXBV69XN VmkY2Jb9yN83I2bHwze0cWJwKzRB7Kwm/nDXmzG5Ggu2uiVJu11obDOVH6BlfMRzJJhvKipRL8mcd MdYc4A5pKmP66p865cQoDX8IPKTdMEWKJcClU6tb9jR4FxYLSAoOsUF9OUP4o0ZVcrfxUF+SNkToV r1+S9txwSXxkb4KW/+yMXpGqzdObYnNtDeCv9fr8WmQjHgC1ZJFC361ofPEIxRoGf0EX8KHlcZiSU IdX7s3+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfE5J-0000000ErmH-1Ajn; Sat, 17 Aug 2024 07:42:49 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfE4b-0000000ErYK-1Fwq for linux-arm-kernel@lists.infradead.org; Sat, 17 Aug 2024 07:42:07 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5bed72ff2f2so1308361a12.2 for ; Sat, 17 Aug 2024 00:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723880524; x=1724485324; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Scgmx1Gy14t/+J79KcdymAvZdzIGaTJBly1hyr+iYTA=; b=jlOwVyRzkDgjgOQtlgM6UiN3U06POPzdSXa+XcNJI+BYRwvo9jv2PsfyQklltjEih2 KinS/1+ww30m598J/pS3k3x0gEH8aDyBW7IErYC3if0XDllOGrhhh+3/KRKG0uzNEOa4 eXHLR3+0wRT9PN5jGuYZ2UcHWNMGqEjcWPt1ASx2aZFu4MOkZ9yGLRIgRfvCxWFMETE0 FQv/t7SWo+RNUrfKJkU9bSmfgjXs0D9lSQzoYoHO0D9qLisfpXyDBEkEbbTeGWPcj5zg CqW0TKxWWeF2PKK9ZnHLher4Hs2QHEQMEm3L/y1MFI0fSf+HkmK/igV0wWJ6A1QDUw0H xqhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723880524; x=1724485324; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Scgmx1Gy14t/+J79KcdymAvZdzIGaTJBly1hyr+iYTA=; b=RqB5aCzIXdV1LGPOC7evfkXQSm8pAnEY0spb3kX9nTjS7hy+whs7ildnZkmYTu7x// 4uAy6fW8eiXeuMnezfYnrC+HystxaCVmFOqjm7vMRnIdvVB6UmJ0xacTE3Hn+z57bI5d IIBXtY8jpWMmgRB4p0k4n6G2jdqwPr9rW9kFgp+eZ6SlwaVsLrySceo3k92w0IKioJr+ Q8osYqrb9LEaro/ejO4MdONDuKlkx/4AhBJwuhkGVZZXkpfx38YPTGmicrekKMSj65Vt L0wZ+qaOwgDGdlDCNlIEdPJJBcGiqP0pnmw3NuubofnKgskjxVhPO7eeZniVr2oDeUBQ Q4TA== X-Forwarded-Encrypted: i=1; AJvYcCWPcsaLDyDgQDadiadjKBgxhb5Xaus5rPhffwa829tVA2Cn0id5c1KhLAAycmGpDxzjRTStZofCW+/UP357LnIzP/L8EFgb7ZzGrsrvIUZFPX0/DQM= X-Gm-Message-State: AOJu0YwtnNOQa97gGIEXuH2Umh78XQysymXMxNjloq5RYgDvEWva2rYZ NxIMdpjNE5SZPhNhurDkpISmYW2muMRxRxzsY5rWZUPDcM/HgooxovM2g74WO0I= X-Google-Smtp-Source: AGHT+IEyEY1ACb4tUAripTPSCmB0FUFFTAKoRc5xxNQCmxLh1aHgyMRfh2Kx1r4BMktxuhjgrrRvVw== X-Received: by 2002:a05:6402:2710:b0:57c:c166:ba6 with SMTP id 4fb4d7f45d1cf-5beca5c5750mr2878547a12.19.1723880523014; Sat, 17 Aug 2024 00:42:03 -0700 (PDT) Received: from localhost (cst2-173-13.cust.vodafone.cz. [31.30.173.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bebbde5cbdsm3166518a12.37.2024.08.17.00.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 00:42:02 -0700 (PDT) Date: Sat, 17 Aug 2024 09:42:01 +0200 From: Andrew Jones To: Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, maz@kernel.org, mark.rutland@arm.com, saravanak@google.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, Anup Patel Subject: Re: [PATCH v2] of/irq: Support #msi-cells=<0> in of_msi_get_domain Message-ID: <20240817-c1d2345fcc50ade60ce09449@orel> References: <20240816124957.130017-2-ajones@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240817_004205_374768_12A50D40 X-CRM114-Status: GOOD ( 34.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 16, 2024 at 02:18:41PM GMT, Rob Herring wrote: > On Fri, Aug 16, 2024 at 6:50 AM Andrew Jones wrote: > > > > An 'msi-parent' property with a single entry and no accompanying > > '#msi-cells' property is considered the legacy definition as opposed > > to its definition after being expanded with commit 126b16e2ad98 > > ("Docs: dt: add generic MSI bindings"). However, the legacy > > definition is completely compatible with the current definition and, > > since of_phandle_iterator_next() tolerates missing and present-but- > > zero *cells properties since commit e42ee61017f5 ("of: Let > > of_for_each_phandle fallback to non-negative cell_count"), there's no > > need anymore to special case the legacy definition in > > of_msi_get_domain(). > > > > Indeed, special casing has turned out to be harmful, because, as of > > commit 7c025238b47a ("dt-bindings: irqchip: Describe the IMX MU block > > as a MSI controller"), MSI controller DT bindings have started > > specifying '#msi-cells' as a required property (even when the value > > must be zero) as an effort to make the bindings more explicit. But, > > since the special casing of 'msi-parent' only uses the existence of > > '#msi-cells' for its heuristic, and not whether or not it's also > > nonzero, the legacy path is not taken. Furthermore, the path to > > support the new, broader definition isn't taken either since that > > path has been restricted to the platform-msi bus. > > > > But, neither the definition of 'msi-parent' nor the definition of > > '#msi-cells' is platform-msi-specific (the platform-msi bus was just > > the first bus that needed '#msi-cells'), so remove both the special > > casing and the restriction. The code removal also requires changing > > to of_parse_phandle_with_optional_args() in order to ensure the > > legacy (but compatible) use of 'msi-parent' remains supported. This > > not only simplifies the code but also resolves an issue with PCI > > devices finding their MSI controllers on riscv, as the riscv,imsics > > binding requires '#msi-cells=<0>'. > > > > Signed-off-by: Andrew Jones > > --- > > v2: > > - switch to of_parse_phandle_with_optional_args() to ensure the > > absence of #msi-cells means count=0 > > > > drivers/of/irq.c | 37 +++++++++++-------------------------- > > 1 file changed, 11 insertions(+), 26 deletions(-) > > > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > > index c94203ce65bb..690df4b71ab9 100644 > > --- a/drivers/of/irq.c > > +++ b/drivers/of/irq.c > > @@ -709,8 +709,7 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 id, > > * @np: device node for @dev > > * @token: bus type for this domain > > * > > - * Parse the msi-parent property (both the simple and the complex > > - * versions), and returns the corresponding MSI domain. > > + * Parse the msi-parent property and returns the corresponding MSI domain. > > * > > * Returns: the MSI domain for this device (or NULL on failure). > > */ > > @@ -718,33 +717,19 @@ struct irq_domain *of_msi_get_domain(struct device *dev, > > struct device_node *np, > > enum irq_domain_bus_token token) > > { > > - struct device_node *msi_np; > > + struct of_phandle_args args; > > struct irq_domain *d; > > + int index = 0; > > > > - /* Check for a single msi-parent property */ > > - msi_np = of_parse_phandle(np, "msi-parent", 0); > > - if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) { > > - d = irq_find_matching_host(msi_np, token); > > - if (!d) > > - of_node_put(msi_np); > > - return d; > > - } > > - > > - if (token == DOMAIN_BUS_PLATFORM_MSI) { > > - /* Check for the complex msi-parent version */ > > - struct of_phandle_args args; > > - int index = 0; > > + while (!of_parse_phandle_with_optional_args(np, "msi-parent", > > + "#msi-cells", > > + index, &args)) { > > I guess you just maintained essentially what was here, but > of_for_each_phandle() should work here. It's a bit more efficient too > because of_parse_phandle_with_optional_args() is implemented using > of_for_each_phandle(). Thanks, Rob. I just sent v3. drew