From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCA24C31E49 for ; Wed, 19 Jun 2019 09:36:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0AE4206E0 for ; Wed, 19 Jun 2019 09:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="lmOjRpt3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727144AbfFSJgf (ORCPT ); Wed, 19 Jun 2019 05:36:35 -0400 Received: from mail-eopbgr20083.outbound.protection.outlook.com ([40.107.2.83]:50054 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726826AbfFSJgf (ORCPT ); Wed, 19 Jun 2019 05:36:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yNBuzmlPjAt3HItsdXiyAdHm2GJkn6nVc80tD9V0/2k=; b=lmOjRpt3USmutmzpKo8euFc1pFK9psF04rMm9EB1W3vjDdCvOgkAviqf6sdkwj8So4tvnigByiMCU7rezu5YDQLoytFYHiEdZCf00TC1HF8z4Wom4P+lJ5Qt5oxiksa5qCNj8+RL/PB16RiG9m8rkQEqCl5oe0XzC0YNYsq6uLY= Received: from VE1PR04MB6655.eurprd04.prod.outlook.com (20.179.235.94) by VE1PR04MB6672.eurprd04.prod.outlook.com (20.179.235.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Wed, 19 Jun 2019 09:36:27 +0000 Received: from VE1PR04MB6655.eurprd04.prod.outlook.com ([fe80::e127:7fe9:ab91:c552]) by VE1PR04MB6655.eurprd04.prod.outlook.com ([fe80::e127:7fe9:ab91:c552%7]) with mapi id 15.20.1987.014; Wed, 19 Jun 2019 09:36:28 +0000 From: Ran Wang To: "Rafael J. Wysocki" CC: Leo Li , Rob Herring , Mark Rutland , Pavel Machek , 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" Subject: RE: [PATCH v4 1/3] PM: wakeup: Add routine to help fetch wakeup source object. Thread-Topic: [PATCH v4 1/3] PM: wakeup: Add routine to help fetch wakeup source object. Thread-Index: AQHVDvGJHigpnFjbr0+iCnHCepvpt6aiMPUAgACuisA= Date: Wed, 19 Jun 2019 09:36:27 +0000 Message-ID: References: <20190520095238.29210-1-ran.wang_1@nxp.com> <3448272.3g8bHhgBA9@kreacher> In-Reply-To: <3448272.3g8bHhgBA9@kreacher> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ran.wang_1@nxp.com; x-originating-ip: [92.121.36.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0030911f-d6cc-45df-6f5e-08d6f4999a96 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:VE1PR04MB6672; x-ms-traffictypediagnostic: VE1PR04MB6672: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39860400002)(366004)(136003)(396003)(376002)(189003)(199004)(54534003)(66446008)(8936002)(81166006)(25786009)(66066001)(186003)(66946007)(76116006)(73956011)(7696005)(64756008)(68736007)(52536014)(86362001)(5024004)(99286004)(5660300002)(316002)(53936002)(71190400001)(6246003)(71200400001)(33656002)(6116002)(14444005)(7416002)(74316002)(66476007)(6506007)(8676002)(3846002)(76176011)(305945005)(53546011)(256004)(26005)(66556008)(6436002)(54906003)(11346002)(7736002)(446003)(478600001)(2906002)(6916009)(4326008)(81156014)(476003)(486006)(102836004)(55016002)(14454004)(229853002)(9686003);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR04MB6672;H:VE1PR04MB6655.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: XkbMvpKlQdyfWKTUWvaKj6q/wP8eKl98WasGmzd0Ahx7PlFD2yN0a+uYpbaeqQexZI25Tu0B6uM7PbbWI7O4okoIDRAYKtH9R23fhu2w9hLu/YOzrljlvejBJKSMaXmNRRp6Dgn3KzuqADxuEVSxARCih0p8whdhMEmz0CKG2IBEu7THcTAzkZM+sSvPUGhyJGVXAkrN65BKwxGUA8YTqC0jxkQTDWUAA+pOtfQEl9IPBD8NmxpA3HR/cEfRzZtcu09WHWrP0Kn4FV4fj2uRiipmVrKtylMF5xhkMvaAqk8hSnuqPEtQgIVdrIUe2p1tHjjm46ksI/AwGOI3MM13ucHcelQ/lIs4ePdmxmtUUDbmGyOR4RiP3JZvbW6g1JsnFJgWcsAjbktPjSvE2aPAhD/wj2F4BdV0+b2kZa5VDVI= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0030911f-d6cc-45df-6f5e-08d6f4999a96 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2019 09:36:27.9018 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ran.wang_1@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6672 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Hi Rafael, On Wednesday, June 19, 2019 06:45, Rafael J. Wysocki wrote: >=20 > On Monday, May 20, 2019 11:52:36 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. And is user's responsibility to identify if this > > wakeup source he is interested in. >=20 > I guess the idea here is that you need to walk wakeup devices and you not= iced > that there was a wakeup source object for each of them and those wakeup > source objects were on a list, so you could walk wakeup devices by walkin= g the > list of wakeup source objects. >=20 > That is fair enough, but the changelog above doesn't even talk about that= . How about this: "Providing a API for helping walk through all registered wakeup devices on = the list. It will be useful for SoC PMU driver to know which device will work as a wa= keup source then do specific HW programming for them." > > Signed-off-by: Ran Wang > > --- > > Change in v4: > > - None. > > > > Change in v3: > > - Adjust indentation of *attached_dev;. > > > > Change in v2: > > - None. > > > > drivers/base/power/wakeup.c | 18 ++++++++++++++++++ > > include/linux/pm_wakeup.h | 3 +++ > > 2 files changed, 21 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > > index 5b2b6a0..6904485 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,22 @@ 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 on= e. > > + */ > > +struct wakeup_source *wakeup_source_get_next(struct wakeup_source > > +*ws) { > > + struct list_head *ws_head =3D &wakeup_sources; > > + > > + if (ws) > > + return list_next_or_null_rcu(ws_head, &ws->entry, > > + struct wakeup_source, entry); > > + else > > + return list_entry_rcu(ws_head->next, > > + struct wakeup_source, entry); > > +} > > +EXPORT_SYMBOL_GPL(wakeup_source_get_next); >=20 > This needs to be arranged along the lines of > wakeup_sources_stats_seq_start/next/stop() > because of the SRCU protection of the list. Got it, how about this: 230 /** = =20 231 * wakeup_source_get_next - Get next wakeup source from the list = =20 232 * @ws: Previous wakeup source object, null means caller want first on= e. =20 233 */ = =20 234 struct wakeup_source *wakeup_source_get_next(struct wakeup_source *ws)= =20 235 { = =20 236 struct list_head *ws_head =3D &wakeup_sources; = =20 237 struct wakeup_source *next_ws =3D NULL; = =20 238 int idx; = =20 239 = =20 240 idx =3D srcu_read_lock(&wakeup_srcu); = =20 241 if (ws) = =20 242 next_ws =3D list_next_or_null_rcu(ws_head, &ws->entry,= =20 243 struct wakeup_source, entry); = =20 244 else = =20 245 next_ws =3D list_entry_rcu(ws_head->next, = =20 246 struct wakeup_source, entry); = =20 247 srcu_read_unlock(&wakeup_srcu, idx); = =20 248 = =20 249 return next_ws; = =20 250 } = =20 251 EXPORT_SYMBOL_GPL(wakeup_source_get_next); =20 > > > > /** > > * device_wakeup_attach - Attach a wakeup source object to a device ob= ject. > > @@ -242,6 +259,7 @@ static int device_wakeup_attach(struct device *dev, > struct wakeup_source *ws) > > return -EEXIST; > > } > > dev->power.wakeup =3D ws; > > + ws->attached_dev =3D dev; > > if (dev->power.wakeirq) > > device_wakeup_attach_irq(dev, dev->power.wakeirq); > > spin_unlock_irq(&dev->power.lock); > > diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h > > index 0ff134d..913b2fb 100644 > > --- a/include/linux/pm_wakeup.h > > +++ b/include/linux/pm_wakeup.h > > @@ -50,6 +50,7 @@ > > * @wakeup_count: Number of times the wakeup source might abort suspen= d. > > * @active: Status of the wakeup source. > > * @has_timeout: The wakeup source has been activated with a timeout. > > + * @attached_dev: The device it attached to > > */ > > struct wakeup_source { > > const char *name; > > @@ -70,6 +71,7 @@ struct wakeup_source { > > unsigned long wakeup_count; > > bool active:1; > > bool autosleep_enabled:1; > > + struct device *attached_dev; >=20 > Please (a) call it just dev and (b) move it up (before wakeirq, say) Got it, will update in next version. Thanks & Regards, Ran >=20 > > }; > > > > #ifdef CONFIG_PM_SLEEP > > @@ -101,6 +103,7 @@ static inline void device_set_wakeup_path(struct > > device *dev) extern void wakeup_source_remove(struct wakeup_source > > *ws); extern struct wakeup_source *wakeup_source_register(const char > > *name); extern void wakeup_source_unregister(struct wakeup_source > > *ws); > > +extern struct wakeup_source *wakeup_source_get_next(struct > > +wakeup_source *ws); > > extern int device_wakeup_enable(struct device *dev); extern int > > device_wakeup_disable(struct device *dev); extern void > > device_set_wakeup_capable(struct device *dev, bool capable); > > >=20 >=20 >=20