From patchwork Thu Mar 23 12:43:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 9640973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E038601E9 for ; Thu, 23 Mar 2017 12:44:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51C04279E0 for ; Thu, 23 Mar 2017 12:44:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 462BA28304; Thu, 23 Mar 2017 12:44:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1EF9279E0 for ; Thu, 23 Mar 2017 12:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbdCWMoS (ORCPT ); Thu, 23 Mar 2017 08:44:18 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:38208 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbdCWMoR (ORCPT ); Thu, 23 Mar 2017 08:44:17 -0400 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990845AbdCWMoOpqD9Y (ORCPT ); Thu, 23 Mar 2017 13:44:14 +0100 Date: Thu, 23 Mar 2017 13:43:55 +0100 From: Ladislav Michl To: Tony Lindgren Cc: Grygorii Strashko , linux-omap@vger.kernel.org Subject: Re: gpio-omap: Edge interrupts stall Message-ID: <20170323124355.npcptv255roleku3@lenoch> References: <20170310230430.6pfljo5rr7esn5qb@lenoch> <20170311201105.GV20572@atomide.com> <20170314182125.GG20572@atomide.com> <20170315061832.yswodnpe3btfttfi@lenoch> <20170315163108.GL20572@atomide.com> <20170316191745.GP20572@atomide.com> <20170320112154.aip27xoacb7pcqut@lenoch> <15d7bf1f-a3b0-f0b7-aa89-46962e4742bc@ti.com> <20170321001732.gs525wb5klq7fuq7@lenoch> <20170322171713.GD10760@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170322171713.GD10760@atomide.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Tony & Grygorii, On Wed, Mar 22, 2017 at 10:17:14AM -0700, Tony Lindgren wrote: > * Ladislav Michl [170320 17:19]: > > On Mon, Mar 20, 2017 at 04:16:33PM -0500, Grygorii Strashko wrote: > > > > > > > > > On 03/20/2017 06:21 AM, Ladislav Michl wrote: > > > > On Thu, Mar 16, 2017 at 12:17:45PM -0700, Tony Lindgren wrote: > > > >> Hmm maybe we need to flush posted writes when re-enabling the GPIO interrupts? > > > >> > > > >> Below is an untested patch that might help if that's the case. > > > > > > > > Unfortunately that's not the case. Even writing set&clear version of > > > > interrupt demux handler did not make it any better. And idea from > > > > ancient patch I initially sent is not easily extensible when we > > > > need to trigger interrupt on both edges. So far I'm clueless... > > > > > > So, just to be sure - can you reproduce it with LKML? > > > > Do you mean mainline kernel? I'm on 4.11-rc3 now... > > > > > As per code, the possible problem could be with double acking of edge irqs > > > (theoretically): > > > - omap_gpio_irq_handler > > > - "isr" = read irq status > > > - omap_clear_gpio_irqbank(bank, isr_saved & ~level_mask); --- clear edge status, so new irq can be accepted > > > - loop while "isr" > > > generic_handle_irq() > > > - handle_edge_irq() > > > - desc->irq_data.chip->irq_ack(&desc->irq_data); > > > - omap_gpio_ack_irq() > > > it might be that at this moment edge IRQ was triggered again and it will be cleared. > > > > > > just as an experiment, could you try to update omap_gpio_ack_irq() > > > as below: > > > > > > if (irq type is not edge) > > > omap_clear_gpio_irqstatus(bank, offset); > > > > Rewritten as: > > > > diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c > > index efc85a279d54..9381763e1fec 100644 > > --- a/drivers/gpio/gpio-omap.c > > +++ b/drivers/gpio/gpio-omap.c > > @@ -806,7 +806,8 @@ static void omap_gpio_ack_irq(struct irq_data *d) > > struct gpio_bank *bank = omap_irq_data_get_bank(d); > > unsigned offset = d->hwirq; > > > > - omap_clear_gpio_irqstatus(bank, offset); > > + if (bank->level_mask & BIT(offset)) > > + omap_clear_gpio_irqstatus(bank, offset); > > } > > > > static void omap_gpio_mask_irq(struct irq_data *d) > > > > And that did the trick. So far I tried IR decoder and decoding sometimes > > fails, but I cannot say anything certain until I check with scope (which > > I do tomorrow) > > Another good code review catch by Grygorii! :) So, to add more info to my previous emails... For testing above patch I setup tftp server and nfs root and that did the trick. As both (tested) edge triggered GPIO and ethernet interrupt line are connected to the same GPIO bank it seemed as an improvement. So I changed to initramfs for tests. See bellow... > Can you guys please add a comment there to the code when posting the > proper patch? Something like: > > /* > * Edge GPIOs are already cleared during handling, clearing > * them here again will cause lost interrupts. > */ > > And also add a proper Fixes tag so this gets propagated to the > stable kernels. It really seems we've had this for a long time. Above probably still applies, but it is a bit hard to trigger. I'll setup a test for that and provide reports. Edge triggered interrupts are lost no matter how fast is its source. It happens even at 10Hz and patch bellow fixes issue. Of course, it is just a hack showing where problem is and it will need a bit more debugging. Thank you, ladis --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index efc85a279d54..f6398ab7b75a 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1273,6 +1273,7 @@ static int omap_gpio_runtime_suspend(struct device *dev) unsigned long flags; u32 wake_low, wake_hi; + return -EINVAL; raw_spin_lock_irqsave(&bank->lock, flags); /* @@ -1341,6 +1342,7 @@ static int omap_gpio_runtime_resume(struct device *dev) unsigned long flags; int c; + return -EINVAL; raw_spin_lock_irqsave(&bank->lock, flags); /*