Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754217AbbHQJLw (ORCPT ); Mon, 17 Aug 2015 05:11:52 -0400 Received: from mail-yk0-f173.google.com ([209.85.160.173]:34368 "EHLO mail-yk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754857AbbHQJJx (ORCPT ); Mon, 17 Aug 2015 05:09:53 -0400 MIME-Version: 1.0 In-Reply-To: <1439797974.22004.2.camel@mtksdaap41> References: <1439541486-22203-1-git-send-email-maoguang.meng@mediatek.com> <1439797974.22004.2.camel@mtksdaap41> From: Daniel Kurtz Date: Mon, 17 Aug 2015 17:09:32 +0800 X-Google-Sender-Auth: 2RqKRE3kTdFrbfLbrjfAQFkgErM Message-ID: Subject: Re: [PATCH v4] pinctrl: mediatek: Implement wake handler and suspend resume To: Yingjoe Chen Cc: maoguang meng , Linus Walleij , Matthias Brugger , Hongzhou Yang , linux-gpio@vger.kernel.org, "linux-arm-kernel@lists.infradead.org" , linux-mediatek@lists.infradead.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3765 Lines: 115 On Mon, Aug 17, 2015 at 3:52 PM, Yingjoe Chen wrote: > On Fri, 2015-08-14 at 16:38 +0800, maoguang.meng@mediatek.com wrote: >> From: Maoguang Meng >> >> This patch implement irq_set_wake to get who is wakeup source and >> setup on suspend resume. >> >> Signed-off-by: Maoguang Meng >> >> --- >> changes since v3: >> -add a comment in mtk_eint_chip_read_mask. >> -delete ALIGN when allocate eint_offsets.ports. >> -fix unrelated change. >> >> changes since v2: >> -modify irq_wake to handle irq wakeup source. >> -allocate two buffers separately. >> -fix some codestyle. >> >> Changes since v1: >> -implement irq_wake handler. >> --- >> >> drivers/pinctrl/mediatek/pinctrl-mt8173.c | 1 + >> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 91 ++++++++++++++++++++++++++- >> drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 4 ++ >> 3 files changed, 95 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8173.c b/drivers/pinctrl/mediatek/pinctrl-mt8173.c >> index d0c811d..ad27184 100644 >> --- a/drivers/pinctrl/mediatek/pinctrl-mt8173.c >> +++ b/drivers/pinctrl/mediatek/pinctrl-mt8173.c >> @@ -385,6 +385,7 @@ static struct platform_driver mtk_pinctrl_driver = { >> .driver = { >> .name = "mediatek-mt8173-pinctrl", >> .of_match_table = mt8173_pctrl_match, >> + .pm = &mtk_eint_pm_ops, >> }, >> }; >> >> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c >> index ad1ea16..fe34ce9 100644 >> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c >> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c >> @@ -33,6 +33,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include "../core.h" >> @@ -1062,6 +1063,77 @@ static int mtk_eint_set_type(struct irq_data *d, >> return 0; >> } >> >> +static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on) >> +{ >> + struct mtk_pinctrl *pctl = irq_data_get_irq_chip_data(d); >> + int shift = d->hwirq & 0x1f; >> + int reg = d->hwirq >> 5; >> + >> + if (on) >> + pctl->wake_mask[reg] |= BIT(shift); >> + else >> + pctl->wake_mask[reg] &= ~BIT(shift); >> + >> + return 0; >> +} > > Hi Maoguang, > > You changed from set_bit/clear_bit to this, but didn't add any locking. > Since this is basic read/modify/write, is it OK to do it without > locking? I believe calling .irq_set_wake() concurrently with itself is protected by irq_get_desc_buslock(): int irq_set_irq_wake(unsigned int irq, unsigned int on) { unsigned long flags; struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); int ret = 0; ... ret = set_irq_wake_real(irq, on); ... irq_put_desc_busunlock(desc, flags); return ret; } I'm not 100% sure about the .suspend/.resume paths, but I don't think they can occur during .irq_set_wake(), either. Nor were they protected by the set_bit/clear_bit implementation. -Dan > > Joe.C > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/