Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7582755ybi; Thu, 1 Aug 2019 10:20:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/e3wVaHkronQrFt6U4Da1nC0Op8rFkRTRGxmrz9mLnrAA/S32uhUiD5jBxTBUYx7TZF/O X-Received: by 2002:a17:902:86:: with SMTP id a6mr40655322pla.244.1564680055473; Thu, 01 Aug 2019 10:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564680055; cv=none; d=google.com; s=arc-20160816; b=eoboulo8zrNu6pCvBXOvenLUPDfYZF0LmxzmHJocieizaOh9nvDdjkwebDAgUUgJIS KlfsCbYbh+HQcaNfSXXhGKCFxXhIViKM5dvVvBeFrAm/d/b7OUxBSgbzMNkZgGKLY+fe +3d1qKoqIxvh/nK7qyrrtK3ofZHyPy1kDsfaCiWdECVcbjnrYF8lKRHKi0/hEwVlTWIq bq1c3enuo2jU8n/bWG5KXKbqQ4zDn29B/wLjTBGUIuuUWITikKZXmSiSRpkyo4LcONGR sNt1ypA2mGrfmAC/nHJZcB57LuNBKW5YFy4n67E/7TyV0fkAf5lGWFZ4wKNXGwTICtzF Mw+g== 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:subject:to:from:cc :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=P4+QkcP5SWfnPke/f4WzJjlFeJ5WbmTA3DCQpoIEOwo=; b=VC6ux0yhYqY9gmPuWXx8Px/ceWRqP6j/kY5Z/o3PgLjaWzonEu0jAsKxDD1YlNTx5Z 3bPut3DJmkP6h0oLPAQGgAhlFCfu98kcmrabIGt5UsGtJpxp0kZmD6lkvEPRVPP8/GLa fkwOcqLOH6NXsCV/fF3XENsGd3fLt5bdIFXtM1GmBzBr2uULsM/i/vpfJnaliXs6q2x0 JGapHKRZaS8gx53M3DekotqnsARUdbGOf97DL81LQDF6I+aTM85sNIwZ9F9m25OaOT6a k1t/LhOdJC0rBWg9PLmrzk3g9OSKrvFkSJtDsKGZsM4XJawGCI37OKYREX1CbsQ+aLvu 5MYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=idub+EGE; 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 a21si34656731pgv.185.2019.08.01.10.20.39; Thu, 01 Aug 2019 10:20:55 -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=idub+EGE; 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 S1731238AbfHAPbp (ORCPT + 99 others); Thu, 1 Aug 2019 11:31:45 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35278 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbfHAPbp (ORCPT ); Thu, 1 Aug 2019 11:31:45 -0400 Received: by mail-pf1-f193.google.com with SMTP id u14so34293390pfn.2 for ; Thu, 01 Aug 2019 08:31:44 -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:cc:from:to:subject:user-agent:date; bh=P4+QkcP5SWfnPke/f4WzJjlFeJ5WbmTA3DCQpoIEOwo=; b=idub+EGEAbLZ4tR3sB6OGyyoDN4Dx3awXMt99vRAI6Vnr6fGz4v78jbzggQ/sTRIyj +1/kvEecNC+K6qLeXU+Yq9sjjIijHXv5jFkc817cZ96zXdImJ11+vBArzqkAgBz84UIo 1a+cU/uZf4LZsTAFIlOoXUcGu+1C6rHccPRKQ= 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:cc:from:to:subject :user-agent:date; bh=P4+QkcP5SWfnPke/f4WzJjlFeJ5WbmTA3DCQpoIEOwo=; b=njK4MhwObuPAEsUAcB3yOK4Iv2WOKiFA5Jp0sPjZSqHQVaHZe+WHiNJGvu0hFqulQr 1c7Szgp3UDd0bGWdFjy4eOvBmAMWcoaMotCPRQ8dZudEo+CpeW92GqAdt7Cu++77Zha6 cptJ+40bSNAWubmZYEkbXgukhs3y1R9V9zcDna69U7G33UrN+R5ynDXETVxmkUZeNKMV tswgF7kQkJRh3Nm639AG6jamGCkZVOliKF/2clC1r75BGgKctiIHjH9/RPMkJunt2ANM lQKUKOqDpHrpczBVmfI5lVgCyOI4iJLVmgBrCEYKTXMxLQ/Y/wqUYOVISrGu36aKhZTC jA1g== X-Gm-Message-State: APjAAAX1UbPvIOpmczam1vb7iNKol2Gx/CBgKg7xu79xSBv/LHzPALyt ILoDnXSJ7x2Q/uiIg5yMeMaikw== X-Received: by 2002:a63:29c4:: with SMTP id p187mr68449509pgp.330.1564673504344; Thu, 01 Aug 2019 08:31:44 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id d15sm16313360pjc.8.2019.08.01.08.31.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 08:31:43 -0700 (PDT) Message-ID: <5d4305df.1c69fb81.c4013.1950@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20190731215514.212215-1-trong@android.com> <32598586.Mjd66ZhNnG@kreacher> <6987393.M0uybTKmdI@kreacher> <5d42281c.1c69fb81.bcda1.71f5@mx.google.com> <5d423637.1c69fb81.62114.ca6f@mx.google.com> Cc: "Rafael J. Wysocki" , Tri Vo , "Rafael J. Wysocki" , Greg Kroah-Hartman , Viresh Kumar , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , LKML , Linux PM , "Cc: Android Kernel" From: Stephen Boyd To: "Rafael J. Wysocki" Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs User-Agent: alot/0.8.1 Date: Thu, 01 Aug 2019 08:31:42 -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-01 01:09:22) > On Thu, Aug 1, 2019 at 2:45 AM Stephen Boyd wrote: > > > > Quoting Stephen Boyd (2019-07-31 16:45:31) > > > > > > This approach also nicely detects duplicate wakeup source names in the > > > case that the string passed in to wakeup_source_register() is already > > > used on the virtual bus. > > > > This was clearly untested! Here's a better one. This is what I see on my > > device with this patch squashed in: > > > > localhost ~ # cat /sys/kernel/debug/wakeup_sources > > name active_count event_count wakeup_count expire_= count active_since total_time max_time last_change preve= nt_suspend_time > > 1-1.2.4.1 0 0 0 0 = 0 0 0 0 0 > > 1-1.1 0 0 0 0 = 0 0 0 0 0 > > gpio-keys 0 0 0 0 = 0 0 0 0 0 > > spi10.0 0 0 0 0 = 0 0 0 0 0 > > a88000.spi:ec@0:keyboard-controller 0 0 = 0 0 0 0 0 > > 0 0 > > alarmtimer 0 0 0 0 = 0 0 0 0 0 > > cros-ec-rtc.1.auto 0 0 0 = 0 0 0 0 0 > > 0 > > a8f8800.usb 0 0 0 0 = 0 0 0 0 0 > > a6f8800.usb 0 0 0 0 = 0 0 0 0 0 > > localhost ~ # ls -l /sys/class/wakeup/ > > total 0 > > lrwxrwxrwx. 1 root root 0 Jul 31 17:43 alarmtimer -> ../../devices/plat= form/soc/ac0000.geniqup/a88000.spi/spi_master/spi10/spi10.0/cros-ec-dev.0.a= uto/cros-ec-rtc.1.auto/rtc/rtc0/alarmtimer >=20 > So why is this not "(...)rtc0/wakeup/alarmtimer" ? >=20 > This particular bit looks kind of inconsistent. I believe this is the code you're looking for in drivers/base/core.c /* * If we have no parent, we live in "virtual". * Class-devices with a non class-device as parent, live * in a "glue" directory to prevent namespace collisions. */ if (parent =3D=3D NULL) parent_kobj =3D virtual_device_parent(dev); else if (parent->class && !dev->class->ns_type) return &parent->kobj; else parent_kobj =3D &parent->kobj; >=20 > I guess without your patch you'd see "(...)rtc0/wakeup/wakeup0" instead, = right? No, it would be rtc0/wakeup0. That's because rtc is a class, and rtc0 is part of that class, so we don't try to make a glue directory named after the class to avoid collisions (see class_dir_create_and_add() implementation). BTW, paths in /sys/devices aren't supposed to matter too much. In this case, I'd expect to see userspace looking at the /sys/class/wakeup path to follow the symlink to figure out what device triggered a wakeup. It can look at the 'device' symlink inside the directory for the wakeup device to figure out which one it is. Final thought, might want to suppress the power directory from being created for the wakeup class. It looks odd to have /sys/class/wakeup/wakeup0/power when the presumably does nothing.