Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965871AbcKXO2i (ORCPT ); Thu, 24 Nov 2016 09:28:38 -0500 Received: from muru.com ([72.249.23.125]:51852 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965562AbcKXO2T (ORCPT ); Thu, 24 Nov 2016 09:28:19 -0500 Date: Thu, 24 Nov 2016 06:27:47 -0800 From: Tony Lindgren To: "Rafael J. Wysocki" Cc: Brian Norris , Dmitry Torokhov , "Rafael J . Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , lkml , Brian Norris , "linux-pm@vger.kernel.org" Subject: Re: [PATCH] PM / wakeirq: report wakeup events in dedicated wake-IRQs Message-ID: <20161124142747.GL4082@atomide.com> References: <20161111163147.GC7138@atomide.com> <20161111222911.GL7138@atomide.com> <20161111223234.GM7138@atomide.com> <20161112001917.GN7138@atomide.com> <20161118201823.GX4082@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1967 Lines: 57 * Rafael J. Wysocki [161123 14:37]: > On Fri, Nov 18, 2016 at 9:18 PM, Tony Lindgren wrote: > > Hi, > > > > * Rafael J. Wysocki [161111 16:35]: > >> However, my understanding is that the current code actually works for > >> runtime PM just fine. > > > > Hmm well I just noticed that for drivers not using autosuspend it can be > > flakey, see the patch below. That probably explains some mysteries people > > are seeing with wakeirqs. > > > > Do you have any better ideas for setting wirq->active on the first > > rpm_suspend()? > > You could change dedicated_irq into status and have three values for > it: INVALID, ALLOCATED and IN_USE. > > dev_pm_set_dedicated_wake_irq() would make it ALLOCATED and > dev_pm_check_wake_irq() would change it into IN_USE. In turn, > dev_pm_enable/disable_wake_irq() would only touch it if it is IN_USE > and dev_pm_clear_wake_irq() would free it if it is not INVALID. OK sounds good to me. > > +static inline void dev_pm_check_wake_irq(struct device *dev) > > +{ > > + struct wake_irq *wirq = dev->power.wakeirq; > > + > > + if (!wirq) > > + return; > > + > > + if (unlikely(!wirq->active)) { > > + wirq->active = true; > > + wmb(); /* ensure dev_pm_enable_wake_irq() sees active */ > > smp_wmb()? > > Also, do we have a corresponding barrier on the reader side? Will check thanks. > I wonder if it would make sense to fold dev_pm_check_wake_irq() into > dev_pm_enable_wake_irq()? I was thinking that too but then bus or device itself won't be able to manage the wakeirq if needed. Let me check if we could easily add something to initialize things like dev_pm_manage_wake_irq() and dev_pm_dont_manage_wake_irq(). That means we need to update the drivers using it, but then we don't need to add extra checks to the idle path and can let bus or drivers mange the wakeirq if necessary. Regards, Tony