Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1229165ybt; Tue, 7 Jul 2020 10:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQV/O4d3EO/2Ggu72FXJlKAjB4RTrM5CIFNLYYmxr4s93vZlOdzZY3ItXZ9SkRoS3TDMMx X-Received: by 2002:a17:906:1455:: with SMTP id q21mr31681732ejc.139.1594142989252; Tue, 07 Jul 2020 10:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594142989; cv=none; d=google.com; s=arc-20160816; b=qZqQqSUeqsH6AbV2DoXgBVgBVPpvDZVzANDFVI2fbll8FF79z2HngckaSu/SjzgCJV EQn3bZBRDtdw7JyfoeHR1ik/19RUUEau6VLE8oV+q4Z6WH6Dk1WAI4MQl8S+M5hLVWYG sJ/LNZw7+buEJY7biYH9XksJ3F05/PRmgwu3rUCORcKtNL8eKp2xWHhmHMR8UPdqx20t cLbcG/z3cw4IN6/uPpjJqExJEJuTdTgiKiz4W2ouDviUj8mYCL03EP4H+Zv9ZKYb5s+A V7iZyWDQFs6zAtNmxeahODr8j2ixee2KePInSu5syC5zV5WUNiTZlwksKT08xnWCeYT7 z/tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GDk3o4K7Qdy44WeUL6xRZLs/1lKN7Q2+qDuM1ziAKUE=; b=ythmjOlAkYbRo0i8lWbw7jOfiwxmaZOkbhu3S7ErSoyhXlzd5ly95bh9/FHrRUGsQp 9iNsF5qUxIrOKWT2Exf910FsbsbiNkemiCGM4X2YqF2JNtiJrEuTm4PBEgO8Qw8Qpy4A SRHfLbnDFKeVjh6zLkXAtitJy6AYbQHopJfF5XLCThIYMDpoJzHLP4GMidPBHJVQclo9 yH3reeVVlpjGEkgktTgBs7Irb1hd0uilAyNeEG9+0NSDq8pMTZksOTa4a1IzzULAVrfY XpCNYs6ksiO73mMiw+MA1i/NNcu7aRvO/yEB4HfjFbfy65x9xRY2ZU3BPCj0j/IPYSlc Od6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AD6CoW2U; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-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. [23.128.96.18]) by mx.google.com with ESMTP id x5si14903927eje.481.2020.07.07.10.29.23; Tue, 07 Jul 2020 10:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AD6CoW2U; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-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 S1728183AbgGGR3A (ORCPT + 99 others); Tue, 7 Jul 2020 13:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbgGGR27 (ORCPT ); Tue, 7 Jul 2020 13:28:59 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F2C3C08C5E1 for ; Tue, 7 Jul 2020 10:28:59 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id o22so13750004pjw.2 for ; Tue, 07 Jul 2020 10:28:59 -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=GDk3o4K7Qdy44WeUL6xRZLs/1lKN7Q2+qDuM1ziAKUE=; b=AD6CoW2UICDWk/1zx/l6PEom5Vnjn8v6sAqR+Vebu1tpz3GUosmm3pgGhiWnNTMqEn m+gTH9ORFg6cG+8B+7LfOi7FXvVjWYao93wjk1OI12A4kbeZrQ1mKBOLdFjwX0/wEq0W NkqU+R92VjKbfG/v2osMCZiL9GgHrO1xI5Upo= 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=GDk3o4K7Qdy44WeUL6xRZLs/1lKN7Q2+qDuM1ziAKUE=; b=eQ8b95INMZ123O33lKFHSUb81rGXveGKAYPUCYZMyIvpSRTPBFQj0PAQACIry3QLIR jYCxzESpsglBgtOMYU/eMOpMbaxO7PJ4mE1TI2ySdtReSLTP1pSN7Z2XaWy8fbPzx6EK jn7M7lipXhVANPoarTIh+NtF2IMvTJT2bexzhExJwULL7bWyOvlTnwu7sryvT+FHwdtk a4mhomVNDsGgkmPOa9QBNGG/ZxAn+36uUqvy9A8Gs3XXOcw/4NOUHRkFGU1zd5EeldSZ gHLLGA8SBAwaYGvfoMgJtn/+tFnshFYfLpKuMAAlJZ3P8k65FkP+i+j/hSuqzLYOzSr1 PPcw== X-Gm-Message-State: AOAM530+9iHyUql+AJVajd9D7VIkKLzwdYdpuDGapLURbPBP/yiur9II JMRh4OgJ7o7Qrtzd8HJNyeuHU7wmI0o= X-Received: by 2002:a17:902:8d89:: with SMTP id v9mr45486975plo.191.1594142938963; Tue, 07 Jul 2020 10:28:58 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e15sm1414285pgt.17.2020.07.07.10.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 10:28:58 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , rafael.j.wysocki@intel.com, linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v5 0/1] power: Emit change uevent when updating sysfs Date: Tue, 7 Jul 2020 10:28:43 -0700 Message-Id: <20200707172845.4177903-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-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@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 v5: - Ignore return from kobject_uevent when adding to sysfs 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