Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2403212ybl; Mon, 19 Aug 2019 01:16:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpFjd2WHCqrCkgAEf2JgQmY6PudHlYkvV/wdlUReZR+uZPln0sIVce0LfFcscqbFNaHGYo X-Received: by 2002:a63:69c1:: with SMTP id e184mr17993528pgc.198.1566202618247; Mon, 19 Aug 2019 01:16:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1566202618; cv=pass; d=google.com; s=arc-20160816; b=UFFTS/dNujCjo+I2B4rZSDtjxd8vCdaMxm4TrQI/ERyRVQCNgrCSCSROssmxUE+JHc HpE2fYM+ldflc4bmTkjEkJVBis1WZ1Lv/P9iUuEWz0lB1bd5mXLUJQUib+MB2v5mKgHf lKAFedKiW4sPwOSIBVYYiEuT+ajrFFzUxEUmkSxvlOB3u5qY1EHXbPz4lGfmYYvWMD1p NldZuT3ZzYw6Mya2PThxRPtVg0v3AtpmI1B1LrHG4iYlTcrkK63Q32Yf0EFHum7VL5i9 4f0gRJTPdYV011XTG6ICLzbO3Th3F/Txn7OM6RlinuKuZskBVQeQU6l5WyqxWQkkdgs6 Zy6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=1R4sHq13+IaHO8Cmfot74gAVxrLkdYHIEVatTcdtYAA=; b=s0xTfxDd+H24qkPTthex96YerAKqGU7eL2t++rGdBKa/A4FD8W4YjIBBau0j9InEKo xrG8yWtY+sdM9b/BXdM96yznERbVsVda2+86bKSFeFnvoGcVwiGNpcaxD257BlbqjjsC hBd8+YAOP3hXz5ubiFM9yyHsublQwwH6AVHI0eucZpOJR0XaHZovlzRHrspO9yV6FvyY yK0/vI5ttDmQnEKpD/MXnLCb48VH+D2FnS4+bp2kTsvY7tiqcESh8n5j9ntZqWxaZidO ubV6V3dBvw4vKjW6UbM0Yrgvmnw4zHUoyerZ9YeXFtDwzMQRTk0c+5L+x/TxL8EVB2bY 7JXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=qRuPGvY8; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si9879823pfe.235.2019.08.19.01.16.43; Mon, 19 Aug 2019 01:16:58 -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; dkim=pass header.i=@nxp.com header.s=selector2 header.b=qRuPGvY8; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbfHSIPR (ORCPT + 99 others); Mon, 19 Aug 2019 04:15:17 -0400 Received: from mail-eopbgr30068.outbound.protection.outlook.com ([40.107.3.68]:42734 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726366AbfHSIPQ (ORCPT ); Mon, 19 Aug 2019 04:15:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RDK3OMKIBi+VOMZFkiPDQpEjOnm6c3FOck72WAUYuCELnXFoFrGrmcRH54ozY43QzfBgqZqcjppMlvNig1uc3/ONxMK2sc2D+8QhRmYTFrCyVT3cDB1bkLAY8rv+k7wY8Bz/zXxA7Sl2St6Jvwm3ZYvS0auFgXK88PBDc7iUFBYuwSMbI+zp9YP6zQ7gDaQCVRFE5MEiEVk6Xnw88GvxArHo1JB2sMP3dNfrlekHifWCnwwyOjpRbk/jmJsY4k3vCy+Hbp4YXMmUtS/UZ7UzsAQ7B+9LDPn2MKEfdJKu921t9a1PKCs8sAbXGyrkJlOL56pIvWzXPvGhH6bwnktsKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1R4sHq13+IaHO8Cmfot74gAVxrLkdYHIEVatTcdtYAA=; b=axtTiLU4ylr+ZCoPn8gJwXQm+RFmb2fxj21d/mesYb5wcWKK0dPiaAQLbfr7CirRqSXPQ6fS4HvwGDrj5nRkyidAX8CkuH5kN9dsmaqXkjj7HOb5Rho2dSEO4hAAII7uvV3PKCNG2IkM6EbJbVoc/jLU4guKxvV6aLBMIWuBeKR1oMbckfZx9M28Zb8H5b68jmgtkxzc/nXEXdNVQFhuC65NLA1evlvSiCR8v+0okwr/wgD3VLMHYe3k8f8yjUkbDRcsIYOGXiYXCvOQozSKxgMKiOdvcb7KwZpH6cgZieKqfjZa0CK39REosUa8YR8sB0tjyqXFbZWSpB78how2/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none 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=1R4sHq13+IaHO8Cmfot74gAVxrLkdYHIEVatTcdtYAA=; b=qRuPGvY8/aVkILijABFrzdxs3xezzvxedjs3gq491zcVoI4nWvTgL2/I8Kue1JlYYuYzxd6DpUDh5Vg/rJm5FyuYFR/H+WGyf2U3ON0UIsUR9gdRsFCEJthFesUH12QsXrdaiRgrsrhKC63PAaedJCeU9SbmUNPpyFCmod8o2hk= Received: from DB8PR04MB6826.eurprd04.prod.outlook.com (52.133.240.82) by DB8PR04MB6761.eurprd04.prod.outlook.com (20.179.251.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 08:14:32 +0000 Received: from DB8PR04MB6826.eurprd04.prod.outlook.com ([fe80::ad63:e8df:f0c2:7246]) by DB8PR04MB6826.eurprd04.prod.outlook.com ([fe80::ad63:e8df:f0c2:7246%2]) with mapi id 15.20.2178.018; Mon, 19 Aug 2019 08:14:32 +0000 From: Ran Wang To: "Rafael J. Wysocki" CC: 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" Subject: RE: [PATCH v5 1/3] PM: wakeup: Add routine to help fetch wakeup source object. Thread-Topic: [PATCH v5 1/3] PM: wakeup: Add routine to help fetch wakeup source object. Thread-Index: AQHVQfPC8fuUrwx+d0SKWP625Z9OpabsZPGAgBWwP7A= Date: Mon, 19 Aug 2019 08:14:32 +0000 Message-ID: References: <20190724074722.12270-1-ran.wang_1@nxp.com> <4158639.B12JYek7R7@kreacher> In-Reply-To: <4158639.B12JYek7R7@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.198] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7024ef78-f04a-4d7a-b29b-08d7247d4416 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:DB8PR04MB6761; x-ms-traffictypediagnostic: DB8PR04MB6761: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1247; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(136003)(376002)(396003)(366004)(346002)(189003)(51914003)(199004)(478600001)(229853002)(6916009)(8936002)(6116002)(8676002)(81166006)(81156014)(3846002)(66446008)(64756008)(76116006)(66946007)(9686003)(6436002)(55016002)(66476007)(66556008)(7736002)(305945005)(7416002)(74316002)(26005)(53546011)(6506007)(53936002)(186003)(102836004)(2906002)(476003)(11346002)(486006)(446003)(5660300002)(66066001)(6246003)(14454004)(5024004)(7696005)(256004)(71200400001)(14444005)(71190400001)(52536014)(99286004)(316002)(54906003)(76176011)(25786009)(33656002)(86362001)(4326008)(473944003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB8PR04MB6761;H:DB8PR04MB6826.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: ClAH81fPqPTIE38CHMUl7jsd5XpSd2OmrOHQ0Ol/Pkp2Vi2doqzx/YPLiunYNfLQb5b2tmc4Omz9qKP5p1PneDVHak3mosR/4WIzt6VSq3ffYcukwKNHcAVVseLZLgpZlZKI5KJ4lkkuZOp9X+quLJZJdSBlqw17A6cVWnbi1wi5RVz9QKoRqIwl25mpWTe/n30h9U0z2ed/DKxM9R8l1BJG5Qi5gkWeOb6XIMh2RgeiSR6ZhO/ZC0FYKX2ko2TDXYLjmk1gtg7STDoSbgCfeOHSj70EII73YsinEeAnk/hE8WJP7Mkfr+Cx/AbNdgl3Tj64bmeRDjhTQqyLNUK8s2bW5+D/f82T1alWb3DJqF4VR4URCt8A+WZw2e+LMXEuZQjloKsTwdpWatSYBu3w7fvOQpqZP8GSUOqgS6OnNHE= 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: 7024ef78-f04a-4d7a-b29b-08d7247d4416 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 08:14:32.6873 (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: Yx15X8XyY62S0HxtKc7BKR/zlRhf10FWXwHYcgqR7P9kjh8/oBFHkeYn6p2uXHo83ANLf85h/5YHE8Ze61eSBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6761 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rafael, On Monday, August 05, 2019 17:59, Rafael J. Wysocki wrote: >=20 > 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 on= e. > > > > 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 on= e. > > + */ > > +struct wakeup_source *wakeup_source_get_next(struct wakeup_source > > +*ws) { > > + struct list_head *ws_head =3D &wakeup_sources; > > + struct wakeup_source *next_ws =3D NULL; > > + int idx; > > + > > + idx =3D srcu_read_lock(&wakeup_srcu); > > + if (ws) > > + next_ws =3D list_next_or_null_rcu(ws_head, &ws->entry, > > + struct wakeup_source, entry); > > + else > > + next_ws =3D list_entry_rcu(ws_head->next, > > + struct wakeup_source, entry); > > + srcu_read_unlock(&wakeup_srcu, idx); > > + >=20 > This is incorrect. >=20 > The SRCU cannot be unlocked until the caller of this is done with the obj= ect > returned by it, or that object can be freed while it is still being acces= sed. 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() =20 > 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 o= n? 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. Thanks & Regards, Ran