Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp425859pxb; Thu, 14 Jan 2021 09:09:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKgDr3U/pEItuJpaRMeGjD7N7L5j7TiW6olJgTcJ183QEJOzmT8w2bgQbs+M4s6YIrke6e X-Received: by 2002:a17:906:3283:: with SMTP id 3mr998191ejw.243.1610644176341; Thu, 14 Jan 2021 09:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610644176; cv=none; d=google.com; s=arc-20160816; b=aDL+QdrbwFAoU/RGiFh0QSFjwIDmcIfTi4j6M5QsPa+bLReICWa7PzxklXJJsfZ6Ig gpz2VwWLUgLczp30zQIfecSMgslBvjyEp8RR3yVy3PaU1LHNXCsPZaqyfL3J+ay14Ffy SwLsD/FpQMEZ1tnYG/q4HDOoaFUoI96eIhEmiSuRBetIoUJ+l/blFRUncYZ6cC2JLWel HHcYH6gIf35khaQTlVk/aLuEV3HaYAtbL4ZpCp3nANgv48Vwq/6gHTpD9K2x7xRlwenB ipmGtk5YCDgD6tt4GX8t3mK6mVr06ZDMROnHCJ7hxRdaP0gIFTJwctfuahKyFedGLGO7 NBaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SwBoPxM4e+KPD8l3ra5+IOX8Gq6+3SFn8A7GKWD3FX8=; b=z7YPZ3HE7o774TRqdudRgNAZaWBce9rP7c6rgiLHFpnpZx6KYQ8v4j+sFuFTcCB1B+ 9FhjcKAB8TFMwRg+XbUAJzdRgmTcIJRd/RWP/URAj90o3w0JQGrv5dI0bwdxLGYOGXsk cY72z8Sp1J/wdusGXDwlg7lJhg1ooGdPUPnNQyC7gTomRzInUGzx6a4RtE56MPUyn36+ gshR/FNnR1F+Ct3gUtLlhmvXg5txI8WkBEAJzE36Mw3dLj+GXFgYAOOSnbWcS0RZ6/P3 qiYBs5Aden/E55KYjFjq38+pguQ7kk99HCDNmHhgL2eySj6g9sRFit6wqKNDcL9NpFDX xXwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UkMSbIXm; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si918661eds.336.2021.01.14.09.09.10; Thu, 14 Jan 2021 09:09:36 -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=@linaro.org header.s=google header.b=UkMSbIXm; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727438AbhANRH6 (ORCPT + 99 others); Thu, 14 Jan 2021 12:07:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbhANRH5 (ORCPT ); Thu, 14 Jan 2021 12:07:57 -0500 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95ADBC0613C1 for ; Thu, 14 Jan 2021 09:07:17 -0800 (PST) Received: by mail-oi1-x230.google.com with SMTP id d203so6642177oia.0 for ; Thu, 14 Jan 2021 09:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SwBoPxM4e+KPD8l3ra5+IOX8Gq6+3SFn8A7GKWD3FX8=; b=UkMSbIXmINhwwlXIKiQREIz9EE6dc734maENiqSjMl23e7Bl2Hp8HGV5AKJn+EF+q0 dZ6qP66LdOaplurMTV6uy2Y/iER2gnlK6SeN//w+CwECRVXTU2PBtQTYF2ciGQsGA6v7 Gh023QIBNMD5JgEBjcdCh0Ei676E7dtyx+E9QPDDtZEfKsI6ziuOq0bm6gp8wMYd4TSL iUn1T17m8zSs6W2Y9hqjZNHzpKjBh5AMZ39byUvcRwl9D+SQ3QePrbeBvLAfCoXatdal JndcIkjepGFnFNqMU5IdO9ytDA2Fhfr8XUWtbDsG+SPa3Df6yRzLxDQtv7+Tj3S3l1DI Fj6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SwBoPxM4e+KPD8l3ra5+IOX8Gq6+3SFn8A7GKWD3FX8=; b=Tp3HLfyRRJdSXdJnRpFAHivfVEoGrZ0KhYJj5kB05WxRNdVcPSvieaEQ6lmqfvsumF 9o/1aP4FXtY2BGPC+DZw6UsjgvDushh6JNpuY6kLxfGngK8m9E+GFipKGm8VnJ3H3c23 JorTkTc9o9Ksh8WnWdsHXnIu3dm9Q3CUguLGJg+2ImDnTvvzqhMObysOW3Y2P+P0s0SJ OqiOQ3kd+cM7MFTGgu2biKhgbtv7ybFgGV6FTWnapewYsPBOBvwB7tEffnOhGibTgeI7 EWXhho182X7NgPavHInO3IAjNIkS55poHzT0RrBwr7nBehEhOJAyKFUQIb/Vf2ZKQbOY oU2g== X-Gm-Message-State: AOAM533vFxCWVY7vU+j9298vNZhpe3dmk1yeDI2+clNVSpPQuCv3rNKA LfByjTT11SnVx5K9149P3wn8ug== X-Received: by 2002:aca:efc6:: with SMTP id n189mr3140106oih.161.1610644036934; Thu, 14 Jan 2021 09:07:16 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id g200sm1141338oib.19.2021.01.14.09.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 09:07:16 -0800 (PST) Date: Thu, 14 Jan 2021 11:07:14 -0600 From: Bjorn Andersson To: Stephen Boyd Cc: Douglas Anderson , Jason Cooper , Linus Walleij , Marc Zyngier , Thomas Gleixner , Neeraj Upadhyay , Rajendra Nayak , Maulik Shah , linux-gpio@vger.kernel.org, Srinivas Ramana , linux-arm-msm@vger.kernel.org, Andy Gross , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 4/4] pinctrl: qcom: Don't clear pending interrupts when enabling Message-ID: References: <20210108093339.v5.1.I3ad184e3423d8e479bc3e86f5b393abb1704a1d1@changeid> <20210108093339.v5.4.I7cf3019783720feb57b958c95c2b684940264cd1@changeid> <161060848425.3661239.17417977666663714149@swboyd.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161060848425.3661239.17417977666663714149@swboyd.mtv.corp.google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 14 Jan 01:14 CST 2021, Stephen Boyd wrote: > Quoting Douglas Anderson (2021-01-08 09:35:16) > > Let's deal with the problem like this: > > * When we mux away, we'll mask our interrupt. This isn't necessary in > > the above case since the client already masked us, but it's a good > > idea in general. > > * When we mux back will clear any interrupts and unmask. > > I'm on board! > > > > > Fixes: 4b7618fdc7e6 ("pinctrl: qcom: Add irq_enable callback for msm gpio") > > Fixes: 71266d9d3936 ("pinctrl: qcom: Move clearing pending IRQ to .irq_request_resources callback") > > Signed-off-by: Douglas Anderson > > --- > > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c > > index a6b0c17e2f78..d5d1f3430c6c 100644 > > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > > @@ -51,6 +51,7 @@ > > * @dual_edge_irqs: Bitmap of irqs that need sw emulated dual edge > > * detection. > > * @skip_wake_irqs: Skip IRQs that are handled by wakeup interrupt controller > > + * @disabled_for_mux: These IRQs were disabled because we muxed away. > > * @soc: Reference to soc_data of platform specific data. > > * @regs: Base addresses for the TLMM tiles. > > * @phys_base: Physical base address > > @@ -72,6 +73,7 @@ struct msm_pinctrl { > > DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO); > > DECLARE_BITMAP(enabled_irqs, MAX_NR_GPIO); > > DECLARE_BITMAP(skip_wake_irqs, MAX_NR_GPIO); > > + DECLARE_BITMAP(disabled_for_mux, MAX_NR_GPIO); > > > > const struct msm_pinctrl_soc_data *soc; > > void __iomem *regs[MAX_NR_TILES]; > > @@ -179,6 +181,10 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, > > unsigned group) > > { > > struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); > > + struct gpio_chip *gc = &pctrl->chip; > > + unsigned int irq = irq_find_mapping(gc->irq.domain, group); > > + struct irq_data *d = irq_get_irq_data(irq); > > + unsigned int gpio_func = pctrl->soc->gpio_func; > > const struct msm_pingroup *g; > > unsigned long flags; > > u32 val, mask; > > @@ -195,6 +201,20 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, > > if (WARN_ON(i == g->nfuncs)) > > return -EINVAL; > > > > + /* > > + * If an GPIO interrupt is setup on this pin then we need special > > + * handling. Specifically interrupt detection logic will still see > > + * the pin twiddle even when we're muxed away. > > + * > > + * When we see a pin with an interrupt setup on it then we'll disable > > + * (mask) interrupts on it when we mux away until we mux back. Note > > + * that disable_irq() refcounts and interrupts are disabled as long as > > + * at least one disable_irq() has been called. > > + */ > > + if (d && i != gpio_func && > > + !test_and_set_bit(d->hwirq, pctrl->disabled_for_mux)) > > + disable_irq(irq); > > Does it need to be forced non-lazy so that it is actually disabled at > the GIC? I'm trying to understand how the lazy irq disabling plays into > this. I think it's a don't care situation because if the line twiddles > and triggers an irq then we'll actually disable it at the GIC in the > genirq core and mark it pending for resend. I wonder if we wouldn't have > to undo the pending state if we actually ignored it at the GIC > forcefully. And I also worry that it may cause a random wakeup if the > line twiddles, becomes pending at GIC and thus blocks the CPU from > running a WFI but it isn't an irq that Linux cares about because it's > muxed to UART, and then lazy handling runs and shuts it down. Is that > possible? > > > + > > raw_spin_lock_irqsave(&pctrl->lock, flags); > > > > val = msm_readl_ctl(pctrl, g); > > @@ -204,6 +224,20 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, > > > > raw_spin_unlock_irqrestore(&pctrl->lock, flags); > > > > + if (d && i == gpio_func && > > + test_and_clear_bit(d->hwirq, pctrl->disabled_for_mux)) { > > + /* > > + * Clear interrupts detected while not GPIO since we only > > + * masked things. > > + */ > > + if (d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs)) > > + irq_chip_set_parent_state(d, IRQCHIP_STATE_PENDING, false); > > So if not lazy this could go away? Although I think this is to clear out > the pending state in the GIC and not the PDC which is the parent. > Isn't this the PDC line after all, because the GIC only has the summary line while the PDC (if we have d->parent_data) has a dedicated line for this irq? Regards, Bjorn > > + else > > + msm_ack_intr_status(pctrl, g); > > + > > + enable_irq(irq); > > + } > > +