Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp167118pxb; Thu, 21 Jan 2021 04:17:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhypy3GpInJo2Uys7pjXyBPzkY8xn4MqC8b/gLwDHEtgSmwgtcLDaT4SztshvGgVDstWB0 X-Received: by 2002:a17:906:eb46:: with SMTP id mc6mr9125762ejb.184.1611231444618; Thu, 21 Jan 2021 04:17:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611231444; cv=none; d=google.com; s=arc-20160816; b=OYTqkBksm1cu6mz5JPn3Svl5llqWBo3tjvgf1sw1Wk9JJJoghHlCKVQbPYmniR3xcD B+FU1v0sKq1aQQ9Ei+TSJkZnomceujvWpqPiCDH+/G476THs4Mk3V9ySTw2EbgsnprAc gCADfFAAVXg4+xhhx5hnhTO5DjJQUG5rx1AERuAsxwL8Ztod7xZX6Co8ZqxrGGaAdLU7 2aFMI5gykgXViRBpnkIOrCzDvPzHrM1rrzBNlIXl2iQ4MNsUNGAcMCFhxAKQKA/QBMpg gSmt775SlIRpkIaHBT0eZMzLPHXBwV0LjrPqRC0Yz3/XFekPDkrWQeuk/V4Yhk71TKfm 8oGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=74gw7o+OO7Q7aDvPtMEjR/zc2dSGvqCTFDo3Lw0ey7o=; b=d/mDraGcwc5n7Lse0/B0Qo8DZFv/NeOVY/mjtjVTmZGDaOm8PwAQjsINQsZDR6HZ9m 7l+cJU5weQTt0q/itsfC3cUi28UvMYbV3CM4zolokMzcn+RliSkPMhtM4Zn2a/6qfoC4 zd/R90XLKtHp8FYQr78jrqbRO52NTI1+FofJYDhiJ+jX+eOrxIlXJ1AgRUWew5O201HO gZQpzk/xoZ1uYfcSvoBADi8ci/LlinbQKWXBWv+VhB5PjOpP+U7udpXwwrItVrlXtNae 1or/M30Md8q7jWXVY1cZ0yIYQpEeGh9NM0XQ+kgjSF/rWlahBeUQ4jdp/+ODPB4+yOph getg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZxaoFgCO; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si2207371edl.551.2021.01.21.04.17.00; Thu, 21 Jan 2021 04:17:24 -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=@chromium.org header.s=google header.b=ZxaoFgCO; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730551AbhAUMPK (ORCPT + 99 others); Thu, 21 Jan 2021 07:15:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730494AbhAUMOI (ORCPT ); Thu, 21 Jan 2021 07:14:08 -0500 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2361C061575 for ; Thu, 21 Jan 2021 04:13:27 -0800 (PST) Received: by mail-vs1-xe2a.google.com with SMTP id j138so560708vsd.8 for ; Thu, 21 Jan 2021 04:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=74gw7o+OO7Q7aDvPtMEjR/zc2dSGvqCTFDo3Lw0ey7o=; b=ZxaoFgCOKpzQNF9P9CAbJRTQX52OYbGya3+y8gRNe7u3+DF/A+gPmS64giuGrYBJCL REfPrGABoR1BJKnj2FvpuiJLsahf5ZRb1X5tJe55Ohi+ZQQ34uLvkTI9m2Ro3YEubJPj 7QKAP1ZQR/5oFIqTwHAvfGJlKfm5dBCwcLe9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=74gw7o+OO7Q7aDvPtMEjR/zc2dSGvqCTFDo3Lw0ey7o=; b=OkDvrQRmjb7w7pV3cgr6el+kargRBDSpAepx5GIA20j9DKXSQdQf0pmcer/mgngc6G I3fVZXMY5Vg/0Uje7jwE/+i3HxtpIs6D+7xA0QYg/0beP3kXhooUHNhPiFBO6hrMmcZU BONODevpwZQGd3r2V/qPpmrf80eQjS22X0QXKfKONyrI5eqZHFNBfirGREKLMokjX7YU P+lMyMUa9/ywdO/W7ridC3KSIabekc2nekaJPVnDgMq1DkpZxYvDvgJmJSlH1d8mgEYj CMmW8a1hX7jGcg8Y5OC2wxHN7/6T2BHwCg6L165MTz2rW4LVnNL725ritJ+jOY0/k3t3 Yhfg== X-Gm-Message-State: AOAM532hmUIDH9WTOt+3frCYyCXnl9GTnIhR7vkC/JsfLJJiNt/ArVwr FqH4xHwTj2583qYm8dqy9kB/AdoWAr89bScvh500qw== X-Received: by 2002:a05:6102:34f:: with SMTP id e15mr10011997vsa.21.1611231207046; Thu, 21 Jan 2021 04:13:27 -0800 (PST) MIME-Version: 1.0 References: <20210121075149.1310-1-hailong.fan@mediatek.com> <1611230975.2493.17.camel@mhfsdcap03> In-Reply-To: <1611230975.2493.17.camel@mhfsdcap03> From: Nicolas Boichat Date: Thu, 21 Jan 2021 20:13:16 +0800 Message-ID: Subject: Re: [PATCH RESEND] pinctrl: mediatek: Fix trigger type setting follow for unexpected interrupt To: mtk15103 Cc: Sean Wang , Linus Walleij , Matthias Brugger , "moderated list:ARM/Mediatek SoC support" , "open list:GPIO SUBSYSTEM" , linux-arm Mailing List , lkml , youlin.pei@mediatek.com, srv_heupstream , Chen-Tsung Hsieh , gtk_pangao@mediatek.com, Hanks Chen , Yong Wu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 8:09 PM mtk15103 wrote: > > On Thu, 2021-01-21 at 16:55 +0800, Nicolas Boichat wrote: > > On Thu, Jan 21, 2021 at 3:52 PM Hailong Fan wrote: > > > > > > When flipping the polarity will be generated interrupt under certain > > > circumstances, but GPIO external signal has not changed. > > > Then, mask the interrupt before polarity setting, and clear the > > > unexpected interrupt after trigger type setting completed. > > > > > > Signed-off-by: Hailong Fan > > > --- > > > Resend since some server reject. > > > --- > > > drivers/pinctrl/mediatek/mtk-eint.c | 13 +++++++++++-- > > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c > > > index 22736f60c16c..3acda6bb401e 100644 > > > --- a/drivers/pinctrl/mediatek/mtk-eint.c > > > +++ b/drivers/pinctrl/mediatek/mtk-eint.c > > > @@ -157,6 +157,7 @@ static void mtk_eint_ack(struct irq_data *d) > > > static int mtk_eint_set_type(struct irq_data *d, unsigned int type) > > > { > > > struct mtk_eint *eint = irq_data_get_irq_chip_data(d); > > > + unsigned int unmask; > > > > bool? > Yes,thanks. > > > > > u32 mask = BIT(d->hwirq & 0x1f); > > > void __iomem *reg; > > > > > > @@ -173,6 +174,13 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type) > > > else > > > eint->dual_edge[d->hwirq] = 0; > > > > > > + if (!mtk_eint_get_mask(eint, d->hwirq)) { > > > + mtk_eint_mask(d); > > > + unmask = 1; > > > + } else { > > > + unmask = 0; > > > + } > > > + > > > if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) { > > > reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->pol_clr); > > > writel(mask, reg); > > > @@ -189,8 +197,9 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type) > > > writel(mask, reg); > > > } > > > > > > - if (eint->dual_edge[d->hwirq]) > > > - mtk_eint_flip_edge(eint, d->hwirq); > > > > Why are you dropping this? Aren't we at risk to miss the first edge > > after mtk_eint_set_type is called? > mtk_eint_unmask() will do it. > If unmask != 1, user need to call mtk_eint_unmask() to enable the > interrupt before use it, thanks. Makes sense, I just have one more worry: https://elixir.bootlin.com/linux/latest/source/drivers/pinctrl/mediatek/mtk-eint.c#L122 mtk_eint_unmask unmasks the interrupt _before_ the edge is flipped, could this cause a spurious interrupt? On any unmask operation -- not just on mtk_eint_set_type (so this is technically another problem, that should be fixed as a separate patch) > > > + mtk_eint_ack(d); > > > + if (unmask == 1) > > > > Just `if (unmask)` > Yes,thanks. > > > + mtk_eint_unmask(d); > > > > > > return 0; > > > } > > > -- > > > 2.18.0 >