Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp937984ima; Wed, 6 Feb 2019 10:48:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IYat9CmDi5jdn3TQwZNJgleifg9uiP6H37bWBxDJJbubHEiF+DHD+7zUNlTBVnA9oDgqfIm X-Received: by 2002:a63:3c58:: with SMTP id i24mr11111401pgn.284.1549478913760; Wed, 06 Feb 2019 10:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549478913; cv=none; d=google.com; s=arc-20160816; b=y0yhEdp8m0R6yuGWwKn4YCKPqWdcV6wyIVHoaNDr6Nu7x/OOTd1EN2dpimUIHcBXTy aub4C2Wu0gXzhJ/1yAqFGmU53aodwpSj0PPohpPQ7kYzKM5erJ6KOVL3DVHmOBg4C+Gg /Q2TMdWltjkoSGUrxS/24YnMlM3yRIwqjhF047CQTUh7tRgLwvkbVTFOMC3fN2j221El A4mlgl7jkdxI/DRfpMTK1l504xUjzB+zUx1idgv8N5OI8ndhWPR3MLk7gpSYIOogQEah gBEM0cMLimxEjDFUSCO60mbYu+ktU4KM9XSjVqaR4B7tkbHN+yctzn2DZislo026CtTv cEqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:from:cc:references:message-id :subject:user-agent:in-reply-to:to:content-transfer-encoding :mime-version:dkim-signature; bh=KvKr862sWMd/Gvg3+sFqt/IYClo/w4CyIdlzhe0fDFw=; b=mtGv46nV+H5zcByj3dE3J1nJ0ww8FodHs6n1ld67uL6euuNReMtEwDDQ6XIOPc3D5m eVCiGhFlHE5b6xpoSkSkBhHxw0XMv8SVtFYfOgcbdKIMwn1Rt5VVRmiGL2whtEij/UNR TrCyxWPz/aLZ+VNt/p5lJsW3MbSk5iTUk8H3pLnOIOnFImHUEh1YPkFVEn8Fm+i8ul+q d5svkaLnKqDAndo3A+4bgibTQz2u/+qlp8VVGj+SNPIk2rOWv82z8RHCA+2WeCFwd7eu 4M+tbUJz+1RDE4hFsPgTqsswA/tzo0WrcvC85Ufk3yLm/zIj5XuxIB0VtQoEgw6RWhZf YSDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bE4q1vPh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si6669292pfb.191.2019.02.06.10.48.17; Wed, 06 Feb 2019 10:48:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bE4q1vPh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726764AbfBFSrv (ORCPT + 99 others); Wed, 6 Feb 2019 13:47:51 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41729 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfBFSru (ORCPT ); Wed, 6 Feb 2019 13:47:50 -0500 Received: by mail-pf1-f195.google.com with SMTP id b7so3479904pfi.8 for ; Wed, 06 Feb 2019 10:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:to:in-reply-to:user-agent :subject:message-id:references:cc:from:date; bh=KvKr862sWMd/Gvg3+sFqt/IYClo/w4CyIdlzhe0fDFw=; b=bE4q1vPhK1ux1FN0ErvuDbpbeshiR5NMqE2tQhqEA8mPOQTJ9yjacwgcbuqO9OcFvh BZI9/1qYdH6mVMICBdsTZx7+YVBS6iAwHxWeW/N7vYSrM4oMmE3kFQnwAU2Y5CAaRoKK fFapdNUuSzXP2YQOdmM7C+Cwfp3EJ0671TOvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:to :in-reply-to:user-agent:subject:message-id:references:cc:from:date; bh=KvKr862sWMd/Gvg3+sFqt/IYClo/w4CyIdlzhe0fDFw=; b=fBtf9t/XF1diPpG6I6nkbOOCGkqeWjIW6D8RpYsmGgibyASxKBVJBEq/0WuNfs+Suo 8aeSRt3a5YVfu7GECuDVcJ1YzOnkY8tKJhkw7vSkafBlnQR1q2NfUhkTjk8S1FguLFjE s+v7TT2eOslnujzbyizf4KXe8qFL6ZXuMTJOuHp0+EVFsYwzIr6QW/2743BPnNW3HLZX w890crtSRg5kqnzbiWCMxjJdT8ePDayzHwtwQmRg6t5cJGjsncCmc3Q1QdALPSYg45Ps eNhbijNqelzTcClIe+rXrMxCFkRKaOVU6LOpWEE3QpfO/+orTjKyoLjr38pd5Jcd6HWj Aang== X-Gm-Message-State: AHQUAuaSWViSqPVZx3lp/+ENdCzWoWyKkW4pxN7OFWKBW++IdtVSOS/I nQSkFBKUmzO+49TD4gyE4c84eg== X-Received: by 2002:a62:3c1:: with SMTP id 184mr12039936pfd.56.1549478869504; Wed, 06 Feb 2019 10:47:49 -0800 (PST) Received: from localhost ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id c9sm16572917pfc.92.2019.02.06.10.47.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 10:47:48 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Lina Iyer In-Reply-To: <20190206170730.GA16254@codeaurora.org> User-Agent: alot/0.8 Subject: Re: [PATCH 4/7] dt-bindings: sdm845-pinctrl: add wakeup interrupt parent for GPIO Message-ID: <154947886779.115909.17337770809316468217@swboyd.mtv.corp.google.com> References: <20181219221105.3004-5-ilina@codeaurora.org> <20190107185113.GH14960@codeaurora.org> <20190109173111.GB22547@codeaurora.org> <154724884881.169631.9705938789464714812@swboyd.mtv.corp.google.com> <154827672955.136743.8509585166504871320@swboyd.mtv.corp.google.com> <154897162267.169292.1911486544543857784@swboyd.mtv.corp.google.com> <154900498906.169292.1193422735086292701@swboyd.mtv.corp.google.com> <20190206170730.GA16254@codeaurora.org> Cc: Rob Herring , Evan Green , Marc Zyngier , "linux-kernel@vger.kernel.org" , "Raju P.L.S.S.S.N" , linux-arm-msm , Thierry Reding , Bjorn Andersson , devicetree@vger.kernel.org, Linus Walleij From: Stephen Boyd Date: Wed, 06 Feb 2019 10:47:47 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lina Iyer (2019-02-06 09:07:30) > Thanks for the patch Stephen. Sorry, it took a while to get to this and > understand how this works. >=20 > On Thu, Jan 31 2019 at 00:10 -0700, Stephen Boyd wrote: > >Quoting Stephen Boyd (2019-01-31 13:53:42) > >> > >> I'm prototyping out some code to do the remapping based on this type of > >> DT property, because it will make the irqdomain::alloc function a litt= le > >> simpler to implement by passing in a struct irq_fwspec and getting out= a > >> parent irq_fwspec and it will make the patches to add these mapping > >> tables in C irrelevant. Plus, I think Lina will be happy that the > >> pinctrl driver will know if some pin maps to the PDC or not without > >> having to see if it fails to allocate in the parent irqdomain. But the= re > >> will still need to be a property for 'wakeup-parent' unless we do > >> something to expose irqdomain tokens into DT. > >> > > > >And here's the code to do this remapping idea, heavily based on the > >phandle remapping code. I didn't properly fix up the irq alloc function > >for the pinctrl driver here, but it should work out properly without > >much more diff. I realize now that the pass-thru mechanism will fail > >horribly when a specifier changes size types. > Could you explain? The pass-thru code maps an incoming specifier directly to an outgoing specifier, so it won't work well if the incoming specifier size is different than the outgoing specifier. For example, converting a GPIO two cell to a GIC 3 cell specifier doesn't work well. incoming: outgoing: And the pass-thru and mask properties can't "shift" or swap a u32 element of the specifier. All they can do is copy from the incoming to the outgoing specifier. Furthermore, we only copy over how ever many cells there are in the incoming specifier so we don't do anything with the last cell. So if GPIO32 corresponds to GIC SPI 14 we can't copy over the flags. <32 IRQ_TYPE_LEVEL_HIGH> becomes but the code only sees <32 4> and needs to copy each element over one by one to <0 14 4>. One solution is to match on the incoming flags and then remap them to the outgoing flags, but then pass-thru property is unusable and we have to list all possible flag combinations on the incoming specifier side of the mapping. > >I guess we'll need to keep > >that in mind if we convert the PDC driver to this too. Or we can leave > >the PDC driver as is and not worry about listing out the individual > >pins. > The PDC pins are more sequential and it looks clean as it. I would > prefer that it be left as is. Sure. I don't see any problems keeping the status quo in the PDC driver. > > > >-----8<----- > >diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/= qcom/sdm845.dtsi > >index a2241dd9c185..6b3a4227f433 100644 > >--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi > >+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi [...] > >+ <122 0 &pdc_intc 97 0>, > >+ <123 0 &pdc_intc 98 0>, > >+ <124 0 &pdc_intc 99 0>, > >+ <125 0 &pdc_intc 100 0>, > >+ <127 0 &pdc_intc 102 0>, > >+ <128 0 &pdc_intc 103 0>, > >+ <129 0 &pdc_intc 104 0>, > >+ <130 0 &pdc_intc 105 0>, > >+ <132 0 &pdc_intc 106 0>, > >+ <133 0 &pdc_intc 107 0>, > >+ <145 0 &pdc_intc 108 0>; > >+ irqdomain-map-mask =3D <0xff 0>; > >+ irqdomain-map-pass-thru =3D <0 0xff>; > Where do we document these bindings? In the DT spec itself or at Documentation/devicetree/booting-without-of.txt I guess. > > > > qspi_clk: qspi-clk { > > pinmux { > >diff --git a/drivers/of/irq.c b/drivers/of/irq.c > >index 02ad93a304a4..b37f4cdfda53 100644 > >--- a/drivers/of/irq.c > >+++ b/drivers/of/irq.c > >@@ -274,6 +274,130 @@ int of_irq_parse_raw(const __be32 *addr, struct of= _phandle_args *out_irq) > > } > > EXPORT_SYMBOL_GPL(of_irq_parse_raw); > > > I would think this would be a separate patch and I presume, I can add > you as the author with your signed-off-by? Sure, but I'd rather see if Rob has any views or opinions here. >=20 > >+int of_irq_domain_map(const struct irq_fwspec *in, struct irq_fwspec *o= ut) > >+{ [...] > >+ while (map_len > (in_size + 1) && !match) { > >+ /* Compare specifiers */ > >+ match =3D 1; > >+ for (i =3D 0; i < in_size; i++, map_len--) > >+ match &=3D !((match_array[i] ^ *map++) & mask[i]); > >+ > >+ of_node_put(new); > >+ new =3D of_find_node_by_phandle(be32_to_cpup(map)); > >+ map++; > >+ map_len--; > >+ > >+ /* Check if not found */ > >+ if (!new) > >+ goto put; > >+ > >+ if (!of_device_is_available(new)) > >+ match =3D 0; > >+ > >+ ret =3D of_property_read_u32(new, cells_name, &out_size); > >+ if (ret) > >+ goto put; > >+ > >+ /* Check for malformed properties */ > >+ if (WARN_ON(out_size > MAX_PHANDLE_ARGS)) > >+ goto put; > >+ if (map_len < out_size) > >+ goto put; > >+ > >+ /* Move forward by new node's #interrupt-cells amount */ > >+ map +=3D out_size; > >+ map_len -=3D out_size; > Nit: Could make this a bit simpler to understand if you broke out the > loop on match instead of continuing the loop. Instead of just doing that in the loop condition? > >+ } > >+ if (match) { > >+ /* Get the irqdomain-map-pass-thru property (optional) */ > >+ pass =3D of_get_property(cur, pass_name, NULL); > >+ if (!pass) > >+ pass =3D dummy_pass; > >+ > >+ /* > >+ * Successfully parsed a irqdomain-map translation; copy = new > >+ * specifier into the out structure, keeping the > >+ * bits specified in irqdomain-map-pass-thru. > >+ */ > >+ match_array =3D map - out_size; > >+ for (i =3D 0; i < out_size; i++) { > >+ __be32 val =3D *(map - out_size + i); > >+ > >+ out->param[i] =3D in->param[i]; > >+ if (i < in_size) { > >+ val &=3D ~pass[i]; > I don't get why the mask is inverted and reversed here again? The mask is inverted to clear out the bits in the outgoing specifier for whatever is there on the incoming side, per what the pass-thru mask indicates should be copied over from incoming to outgoing. > >+ val |=3D cpu_to_be32(out->param[i]) & pas= s[i]; > >+ } > >+