Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2406893ybl; Mon, 19 Aug 2019 01:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdbZ8TS7THSsDvHWemSm20mt+wDgZYLTRE010ERhL0ohMX4u9rBwMR7hemSVxIrWV9JCDC X-Received: by 2002:a63:181:: with SMTP id 123mr19267378pgb.63.1566202906880; Mon, 19 Aug 2019 01:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566202906; cv=none; d=google.com; s=arc-20160816; b=iCq3uOgmbFvvXeLuiL2/ov5g5BoH98ApSFvW0ZzYT8UtOQwiRq0rlQppxfxwjsMyRP d5iEijF0xbV6DASrUtxVmM3YYGeWlXL58N1i0KOdG2jFrtWXVOhVyBHSWPE98Elhapwf v4fpB1BeS5tt/FG94RhcdxEeyuuaP0LOD5lyRJDPyyRYGB91EOuz/urDex1UFS+p0T9y JYEqFZNxRr8O0NxEY4HvccsP9Fljsibth0DHrza5dRzVK0qyl7DghMTDpp9zAS2Uyoct snYrKsqFLvRNCOqNgwhWGyIwaYLJIjRGl28f39xIbWdFN6pNssttkEMI3TcnHpcAmGS2 8VgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=xS8pnTXr+3PwEje+y6dB7oMHpWB4o5rNXOdh/Rkk++Q=; b=UbO+iv27rQ9oJwlqiUb4S2rs1SyjfPTsN6Z84xiyd3Rp1mRyBEvt8bRcldYpagIITo eVPjQEJSZUdEjx9LXnGjvo5P2QjM6vL/y9r+1X+P1HB6eh2iyH+QLzXCsg+Xe5JUq6BO 70gYAbbYwU0wc+01d2MtofhZsyU91vjMCbbmgOHv1a5OHztY2UbgVAwMC3OWTPtP0Fo1 wot3UKp8pfGa7VNB7gFIu5OHaSHzmYU+pUN/cZOjPbtaOKWsdxAmshxXpGP7nQt6mjUb /lz/kx7JYhP3fIIqCQeRnbaf1Q3lqD9tQi9ouDjdRprh+/r9d5aPidMdlsaqwJAlv1WJ 6F5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si9275598pll.439.2019.08.19.01.21.31; Mon, 19 Aug 2019 01:21:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbfHSIUY (ORCPT + 99 others); Mon, 19 Aug 2019 04:20:24 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:35517 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbfHSIUX (ORCPT ); Mon, 19 Aug 2019 04:20:23 -0400 Received: by mail-ot1-f66.google.com with SMTP id g17so908983otl.2; Mon, 19 Aug 2019 01:20:23 -0700 (PDT) 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=xS8pnTXr+3PwEje+y6dB7oMHpWB4o5rNXOdh/Rkk++Q=; b=Bh00pV3P2Tc1HHvbUwcmcyHK7qdEFnNeS6c007CgKYO/XFQ/4AgjFEZpYLqGcszjlQ 7mTj+4p9AtuKr2cxXYxoEwn4W+wRVb6Kgf11wr//5Exm7ERuD7x+cWqN738/ZR/2X+1/ fKMB6imCQxkbSfAhCTumTC65XYuUMJS+xQ2ZTtHGwAUNNB/9qr5+tb6evgUFg/5nIG09 qmOrrSGHvA4tfJJB51iPvF5KXQZF/XmeluahA5Wa1plGRDSnzkvJikFJ0EaZmyWI9ism YgEI+lo23U0QkR32t9r4ZGPEK8PSb0q48jmZT8aWltS/shmZF44vQBEp5nXJqQ2eK1dy OBZQ== X-Gm-Message-State: APjAAAWeKojBLxvADFXLcJQRGquIS687sM0XvJSj4kHA5QUnfjd3seQ5 /YoNzvaNQsz5yCLc6X6hjOVef7vrAXClwZ0JEYY= X-Received: by 2002:a9d:674c:: with SMTP id w12mr13640118otm.118.1566202822686; Mon, 19 Aug 2019 01:20:22 -0700 (PDT) MIME-Version: 1.0 References: <20190724074722.12270-1-ran.wang_1@nxp.com> <4158639.B12JYek7R7@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 19 Aug 2019 10:20:11 +0200 Message-ID: Subject: Re: [PATCH v5 1/3] PM: wakeup: Add routine to help fetch wakeup source object. To: Ran Wang Cc: "Rafael J. Wysocki" , Leo Li , Rob Herring , Mark Rutland , Pavel Machek , Biwen Li , Len Brown , Greg Kroah-Hartman , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 10:15 AM Ran Wang wrote: > > Hi Rafael, > > On Monday, August 05, 2019 17:59, Rafael J. Wysocki wrote: > > > > On Wednesday, July 24, 2019 9:47:20 AM CEST Ran Wang wrote: > > > Some user might want to go through all registered wakeup sources and > > > doing things accordingly. For example, SoC PM driver might need to do > > > HW programming to prevent powering down specific IP which wakeup > > > source depending on. So add this API to help walk through all > > > registered wakeup source objects on that list and return them one by one. > > > > > > Signed-off-by: Ran Wang > > > --- > > > Change in v5: > > > - Update commit message, add decription of walk through all wakeup > > > source objects. > > > - Add SCU protection in function wakeup_source_get_next(). > > > - Rename wakeup_source member 'attached_dev' to 'dev' and move it > > up > > > (before wakeirq). > > > > > > Change in v4: > > > - None. > > > > > > Change in v3: > > > - Adjust indentation of *attached_dev;. > > > > > > Change in v2: > > > - None. > > > > > > drivers/base/power/wakeup.c | 24 ++++++++++++++++++++++++ > > > include/linux/pm_wakeup.h | 3 +++ > > > 2 files changed, 27 insertions(+) > > > > > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > > > index ee31d4f..2fba891 100644 > > > --- a/drivers/base/power/wakeup.c > > > +++ b/drivers/base/power/wakeup.c > > > @@ -14,6 +14,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -226,6 +227,28 @@ void wakeup_source_unregister(struct > > wakeup_source *ws) > > > } > > > } > > > EXPORT_SYMBOL_GPL(wakeup_source_unregister); > > > +/** > > > + * wakeup_source_get_next - Get next wakeup source from the list > > > + * @ws: Previous wakeup source object, null means caller want first one. > > > + */ > > > +struct wakeup_source *wakeup_source_get_next(struct wakeup_source > > > +*ws) { > > > + struct list_head *ws_head = &wakeup_sources; > > > + struct wakeup_source *next_ws = NULL; > > > + int idx; > > > + > > > + idx = srcu_read_lock(&wakeup_srcu); > > > + if (ws) > > > + next_ws = list_next_or_null_rcu(ws_head, &ws->entry, > > > + struct wakeup_source, entry); > > > + else > > > + next_ws = list_entry_rcu(ws_head->next, > > > + struct wakeup_source, entry); > > > + srcu_read_unlock(&wakeup_srcu, idx); > > > + > > > > This is incorrect. > > > > The SRCU cannot be unlocked until the caller of this is done with the object > > returned by it, or that object can be freed while it is still being accessed. > > Thanks for the comment. Looks like I was not fully understanding your point on > v4 discussion. So I will implement 3 APIs by referring wakeup_sources_stats_seq_start/next/stop() > > > Besides, this patch conflicts with some general wakeup sources changes in the > > works, so it needs to be deferred and rebased on top of those changes. > > Could you please tell me which is the right code base I should developing on? > I just tried applying v5 patch on latest git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git branch master (d1abaeb Linux 5.3-rc5) > and no conflict encountered. It is better to use the most recent -rc from Linus (5.3-rc5 as of today) as the base unless your patches depend on some changes that are not in there.