Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp997746ybl; Fri, 16 Aug 2019 07:20:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKaFAMna/yxo76LAjnRCMcMWYObhLFAXOyeL4tK7aJmRv+rde9HHU0huivfV4z8PcXM5ix X-Received: by 2002:a17:90a:5d0d:: with SMTP id s13mr7305540pji.139.1565965235482; Fri, 16 Aug 2019 07:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565965235; cv=none; d=google.com; s=arc-20160816; b=x+IKNvsMiuCfhZ9My+5QLSiJYsNbreFSyMY1jKP9Pty/seoYUoC8rmLJY+heTzTeeN 152HZIBLtDHwRrEliczuxlbTEGkaWBsxJyoOvqsl48b/uTl7FnyxF9nfH+G1YQvmdk0P vvH6DqzuYS3FcaPrZFx9ZdOGbc1Wer2fwZ3pNFxC0ogBi0mhd5bEOAwF0aSf3jPLUcma FCRcmyV0WymI4m5BKuJrjiDy2vXVT3jTf87JthbPnUPevDXzoKf/zdZMULOZLqitqA9i 7MyeZo1yboS7w5r7s+Xy1WOaFyodYZus9p30agK4GCzxgbfdg63EWKs01oxciyO3Urhy nE7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=tBN0L54QMtDYld2dZHBXnZOaHPOrCsY9yGKAHJ7HtJ0=; b=UIhIKM6YuJeGqqHj3PP3b7xuThvsGiebtF9CAaWXUofDPI1z64neutbCYYPWs6bHnD HdiGeRqQ1n44lOXW43XHFCpXletpQRoaxqENo7IfMQxa+yAK0Wf/eFM8T+abqXcz+JJv ece5+GsT0RFX6W7sNzfGcczlDL6kiRWv/bBHlHlJgt3g3qhR2eiA9goPCjibAk3N7epB iYZtMaEW8tWah2baKTwpD1IAkRrhsQAxDIG7tIfIWO5TzfUXlb8lwQXBYN9EXch9fHU8 +87SwW9iR4XP/DWs9Vr1WATFDUjw28Mk5o27znP30nDkyXA6PPsIIxQGBNQkoWrIOXDO 7oCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iLtynzXp; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si3104875pjb.82.2019.08.16.07.20.19; Fri, 16 Aug 2019 07:20:35 -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=@chromium.org header.s=google header.b=iLtynzXp; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727486AbfHPOTi (ORCPT + 99 others); Fri, 16 Aug 2019 10:19:38 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46161 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727217AbfHPOTh (ORCPT ); Fri, 16 Aug 2019 10:19:37 -0400 Received: by mail-pg1-f196.google.com with SMTP id m3so2425593pgv.13 for ; Fri, 16 Aug 2019 07:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:subject:from:cc:to:user-agent:date; bh=tBN0L54QMtDYld2dZHBXnZOaHPOrCsY9yGKAHJ7HtJ0=; b=iLtynzXp2unH1FB4V6Qf4QmIe20CFCYKaGvYyJveb4LxrCW63jAtA3i9KRJeoxmJJJ NK6IDGqtsnMNG1Kp/P8KjwSrredRdP9H3MvonGVmiFS3VouEsfA8pc2ebyf38oWLOigf gl3KBPJUfHK7xBL4pKE9E3qXAPNOFMF1nrZzY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:subject:from:cc:to :user-agent:date; bh=tBN0L54QMtDYld2dZHBXnZOaHPOrCsY9yGKAHJ7HtJ0=; b=Coz38mhjB/prDu9Dlb/ag9/QfCeVwSqjmlfH5rcD+myzKYyMqdkDLUL2u7Xj6I6sRF 7pc6hiy03WFixGQlp/WZyQ7fSaOtOe+ZiAXsI02nhEdDIi5av6ufrvXbQgCN5KsuLUi7 dcXyuLpCPlMgrVPdBvyYjFvgXj4cpxlLXriFMZB/sdOsi95CZ3iP2dhll3YtoyZA0S6G xZrAQEsuXqtiRVwv35klYFNuLpopXkRfI070T7LqaLF4PA2xZiHo1spQcjCRjMC0xQYa yRUlaTV2lhoxtCDKvFtw6plIJanAgs8oOEL/677pUGgtKRuJOCI0vEoA/zlr9aA2K880 R3qQ== X-Gm-Message-State: APjAAAUIMNaXh4D68XBWTlGBmQg8mw6l/XuScP3HKYJ5GMRYyWxfBxJv EPwunNHaBaAolGizqxVvT326nw== X-Received: by 2002:a62:198d:: with SMTP id 135mr10915627pfz.169.1565965176712; Fri, 16 Aug 2019 07:19:36 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id p1sm6067967pff.44.2019.08.16.07.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2019 07:19:35 -0700 (PDT) Message-ID: <5d56bb77.1c69fb81.58e9d.1f86@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <1565731976.8572.16.camel@lca.pw> <5d53b238.1c69fb81.d3cd3.cd53@mx.google.com> <20190814084014.GB52127@atomide.com> Subject: Re: "PM / wakeup: Show wakeup sources stats in sysfs" causes boot warnings From: Stephen Boyd Cc: Tony Lindgren , Qian Cai , Dmitry Torokhov , Peter Zijlstra , Greg Kroah-Hartman , "Rafael J. Wysocki" , Linux PM , LKML To: "Rafael J. Wysocki" , Tri Vo User-Agent: alot/0.8.1 Date: Fri, 16 Aug 2019 07:19:35 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Rafael J. Wysocki (2019-08-16 05:17:23) > On Wed, Aug 14, 2019 at 8:37 PM Tri Vo wrote: > > > > On Wed, Aug 14, 2019 at 1:40 AM Tony Lindgren wrote: > > > > > > * Stephen Boyd [691231 23:00]: > > > > I also notice that device_set_wakeup_capable() has a check to see i= f the > > > > device is registered yet and it skips creating sysfs entries for the > > > > device if it isn't created in sysfs yet. Why? Just so it can be cal= led > > > > before the device is created? I guess the same logic is handled by > > > > dpm_sysfs_add() if the device is registered after calling > > > > device_set_wakeup_*(). > > > > > > Hmm just guessing.. It's maybe because drivers can enable and disable > > > the wakeup capability at any point for example like driver/net drivers > > > do based on WOL etc? > > > > > > > There's two approaches I see: > > > > > > > > 1) Do a similar check for device_set_wakeup_enable() and skip > > > > adding the wakeup class until dpm_sysfs_add(). > > > > > > > > 2) Find each case where this happens and only call wakeup APIs > > > > on the device after the device is added. > > > > > > > > I guess it's better to let devices have wakeup modified on them bef= ore > > > > they're registered with the device core? > > > > > > I think we should at least initially handle case #1 above as multiple > > > places otherwise seem to break. Then maybe we could add a warning to > > > help fix all the #2 cases if needed? > > > > Makes sense. For case#1, we could also just register the wakeup source > > without specifying the parent device if the latter hasn't been > > registered yet. Userspace won't be able to associate a wakeup source > > to the parent device. But I think it's a reasonable fix, assuming we > > want to fix devices not being added before calling wakeup APIs #2. >=20 > Well, OK >=20 > I'm going to drop the entire series from linux-next at this point and > let's start over. I was going to send the first patch I floated as a more formal patch to be applied to the PM tree. I was waiting to see if the semantics of device_set_wakeup_*() could be clarified because I don't understand if they're allowed to be called before device_add(). >=20 > Also note that all of this is not an issue until we start to add > children under the device passed to device_set_wakeup_enable() and > friends so maybe that is not a good idea after all? My primary goal is to know what wakeup is associated with a device. If we delay creation of the sysfs node to the time that device_add() is called then it will allow device_set_wakeup_enable() to be called before the device is published to userspace. Is anything wrong with that? This seems to be the intention of the API based on the way device_set_wakeup_capable() is written. Furthermore, if we make this change then we don't need to fix various drivers to reorder calls to device_set_wakeup_enable() and device_add(), so it looks like the right approach. I'll send the patch over the list now and let you decide. I'll also send a patch for serio to have it operate on the device in a less racy way, but not necessarily after the device_add() is called.