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=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no 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 E1168C433E0 for ; Tue, 7 Jul 2020 16:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAB04206E2 for ; Tue, 7 Jul 2020 16:24:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="a6KuHtzO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbgGGQY3 (ORCPT ); Tue, 7 Jul 2020 12:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbgGGQY2 (ORCPT ); Tue, 7 Jul 2020 12:24:28 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC16C061755 for ; Tue, 7 Jul 2020 09:24:28 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id w2so19433456pgg.10 for ; Tue, 07 Jul 2020 09:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5rypinuxXWPOxBq0owicS6HAyIDLu+UTWiTWHRsqzsM=; b=a6KuHtzO7bUw2Zu7AcFiqm+FYYpWbMKNAVPXezA5PYDzrmI6qmmgD8/HhryzwUeqcM r4J7H8s+/yyJHzZaS+AzzQTcMDOXUmuX6CxLKeatH/MfvudUFah7Q+a3LqlIeGMgY32X ruNb6uhgvj3iJJGUAnSAFfRuhQXM850/1dplw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5rypinuxXWPOxBq0owicS6HAyIDLu+UTWiTWHRsqzsM=; b=nNhr184fRV49e0DL7cV3tYxAt/I35b4SWZ7qWzbUqefMtThtlWneheRfPuar2nz93Q xyE01MvgzqUfogyToL+3Bt+OQCQ8Fv4CiJx8ceMYkDmM++ZzFIgz7qn28Ix2NwBd3Y+E uOOfzpFrNPhd3o5J3GVdJgAfNLZp7o2hj9DGrL6p1AaWuSe/6Yzz/o5tnFdLcKdEN0UV CMMHzokrLpb+C3OifinGPyRVRacsivfHEHpDJVc3deYSOHgAUidJTYK/Hlsc7paSY3T/ WYz9sX4EyCiEbJjFAK3c6fmFw4vg0Prkb9oxl6WpBS1wgg2m18UJmPwbh73s/mLdp1WF 9KZg== X-Gm-Message-State: AOAM533v/dCOijque8E0DeWSXTGOiHi5YP59XroOnNnhE2hfJSqhLKDG We7QxPmUPZcl7+i57Bb21G32jQ== X-Google-Smtp-Source: ABdhPJxmzVAmqiU/WipgiQj/0Er/2Olj3Fa/b4b8Nji1KGrP79hTlLqseViA/H+Uj3J2c0s/KP1Aow== X-Received: by 2002:a05:6a00:790:: with SMTP id g16mr13906032pfu.36.1594139068170; Tue, 07 Jul 2020 09:24:28 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id s10sm3758196pjf.3.2020.07.07.09.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 09:24:27 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v4 0/1] power: Emit change uevent when updating sysfs Date: Tue, 7 Jul 2020 09:24:16 -0700 Message-Id: <20200707162417.3514284-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi linux-pm, ChromeOS has a udev rule to chown the `power/wakeup` attribute so that the power manager can modify it during runtime. (https://source.chromium.org/chromiumos/chromiumos/codesearch/+/master:src/platform2/power_manager/udev/99-powerd-permissions.rules) In our automated tests, we found that the `power/wakeup` attributes weren't being chown-ed for some boards. On investigating, I found that when the drivers probe and call device_set_wakeup_capable, no uevent was being emitted for the newly added power/wakeup attribute. This was manifesting at boot on some boards (Marvell SDIO bluetooth and Broadcom Serial bluetooth drivers) or during usb disconnects during resume (Realtek btusb driver with reset resume quirk). It seems reasonable to me that changes to the attributes of a device should cause a changed uevent so I have added that here. Here's an example of the kernel events after toggling the authorized bit of /sys/bus/usb/devices/1-3/ $ echo 0 > /sys/bus/usb/devices/1-3/authorized KERNEL[27.357994] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill1 (rfkill) KERNEL[27.358049] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[27.358458] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[27.358486] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[27.358529] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) $ echo 1 > /sys/bus/usb/devices/1-3/authorized KERNEL[36.415749] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[36.415798] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[36.417414] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[36.417447] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[36.417481] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Series-version 4 update: Tested again on device and verified it's working as expected: KERNEL[52.678174] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[52.678211] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[52.678251] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[52.679721] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[52.679772] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[56.022259] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[56.022306] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[56.022488] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[56.022531] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill3 (rfkill) KERNEL[56.023392] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Thanks Abhishek Changes in v4: - Fix warning where returning from void and tested on device Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err Abhishek Pandit-Subedi (1): power: Emit changed uevent on wakeup_sysfs_add/remove drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.27.0.212.ge8ba1cc988-goog