Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1946968pxb; Fri, 5 Feb 2021 05:38:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaDq5CJZnhDZ1ukYsB9OABy6MNU8BSscq8oEHEFJ7XIhaqde8nYA9xYeSEJHi6yyaIPpHC X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr3403063edv.131.1612532325087; Fri, 05 Feb 2021 05:38:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612532325; cv=none; d=google.com; s=arc-20160816; b=WXkXTYqEveQjcgUSoSsIFJGYRbD0Ko6n/7AjAxU2v32fT7JkNKhwGWW4goOKyPiOcZ 06zZmnpliEZdY2h8DiDe8uspQa29zMS/Dh8woaGgiYU15HQQXcPEqZdJf7+Gl/0E0Pyc NztTu006e8/W2bVVM03rD7T1n6VMNB7+aFDKTwU4Jh4h44WgRUXsJ3pR8IP9sQMWQnIx 5PH1o8kQ/80MZUmIWKWlak1gs+mv8CAn7uQS8J6O70Ta9KdMNWM/EO9rQfQkjcbBm2Gv iVDd8BGjtHZshCoYZHhevfZ8ICfYI1afHSUwDsTg858mF3fpu+5N/cec+05XXwR1POfE Fx0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=ypLtyJEDvBzv4v0AaBh9Bw9skqoM3EhDdVcGdy4meGw=; b=imSww6NeHBJLNb6OZzDhxWNKsSrJ12BEzeUbu+UwGbKkZdLQjePYGCtlpKd9m5eo/l 8UX0NNCKrDSa329r02J1AFNKSquAZf9xELe4Rc/XM6ns7jb2OIvU5FE3UzQ+JuqSflEL j2bUTAnxfLzBFWFTWx9cw7r6ChtV6AwgH8aKABcr7FD/BZjcnVNIfe/5WM0qyb9ONHRu sRlGPGIIvVaC31684fowUYon2N70ck8C2GgVD+7sA4UyVnb6gB7tRfIB6YBVexTu88jK vWRzCQ6WdPJ3FVBQt+vyk3WmmtlmB9fOrN9ZkQmZg1nIZ030kpD+eqKhUXtbZKhB3xnL Fz7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si5774154edd.161.2021.02.05.05.38.19; Fri, 05 Feb 2021 05:38:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbhBENg6 (ORCPT + 99 others); Fri, 5 Feb 2021 08:36:58 -0500 Received: from mga12.intel.com ([192.55.52.136]:60933 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbhBENcR (ORCPT ); Fri, 5 Feb 2021 08:32:17 -0500 IronPort-SDR: Nwo79IGYWACtfeBduVxN6zwVZzOXTf3WM5iRVIIG6BCkbMQc3r/Dwm7xEGv0qNiZPuxauOKNCG +X4CYvTJkJ+w== X-IronPort-AV: E=McAfee;i="6000,8403,9885"; a="160589442" X-IronPort-AV: E=Sophos;i="5.81,154,1610438400"; d="scan'208";a="160589442" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 05:24:57 -0800 IronPort-SDR: 3bagWk4ieSh14Im4ioZBhHx7ofbCZFl1vELks+rDk6fQj6QdMIrEGvtzwLd6ZjUTYSPi/25Yno lOM/DDvfizCQ== X-IronPort-AV: E=Sophos;i="5.81,154,1610438400"; d="scan'208";a="373390605" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 05:24:53 -0800 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 7F8AA20168; Fri, 5 Feb 2021 15:24:51 +0200 (EET) Received: from sailus by punajuuri.localdomain with local (Exim 4.92) (envelope-from ) id 1l816f-0005GC-7e; Fri, 05 Feb 2021 15:25:05 +0200 From: Sakari Ailus To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , rajmohan.mani@intel.com, Tomasz Figa , Bartosz Golaszewski , Bingbu Cao , Chiranjeevi Rapolu , Hyungwoo Yang , linux-media@vger.kernel.org Subject: [PATCH v10 0/7] Support running driver's probe for a device powered off Date: Fri, 5 Feb 2021 15:24:58 +0200 Message-Id: <20210205132505.20173-1-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello everyone, These patches enable calling (and finishing) a driver's probe function without powering on the respective device on busses where the practice is to power on the device for probe. While it generally is a driver's job to check the that the device is there, there are cases where it might be undesirable. (In this case it stems from a combination of hardware design and user expectations; see below.) The downside with this change is that if there is something wrong with the device, it will only be found at the time the device is used. In this case (the camera sensors + EEPROM in a sensor) I don't see any tangible harm from that though. An indication both from the driver and the firmware is required to allow the device's power state to remain off during probe (see the second patch). The use case is such that there is a privacy LED next to an integrated user-facing laptop camera, and this LED is there to signal the user that the camera is recording a video or capturing images. That LED also happens to be wired to one of the power supplies of the camera, so whenever you power on the camera, the LED will be lit, whether images are captured from the camera --- or not. There's no way to implement this differently without additional software control (allowing of which is itself a hardware design decision) on most CSI-2-connected camera sensors as they simply have no pin to signal the camera streaming state. This is also what happens during driver probe: the camera will be powered on by the I²C subsystem calling dev_pm_domain_attach() and the device is already powered on when the driver's own probe function is called. To the user this visible during the boot process as a blink of the privacy LED, suggesting that the camera is recording without the user having used an application to do that. From the end user's point of view the behaviour is not expected and for someone unfamiliar with internal workings of a computer surely seems quite suspicious --- even if images are not being actually captured. I've tested these on linux-next master. since v9 : - Use _DSE object designed for the very purpose of designating intended device probe power state instead of _PRE. - Rework documentation to reflect the property to _DSE changes (missed in v9). - Put maximum device enumeration power state in struct acpi_device_power, instead of a flag in struct acpi_device_power_flags. The default is ACPI_STATE_D0. - i2c_acpi_allow_low_power_probe() now returns true if the desired power state is greater or equal to the current device power state. - Rename local variable low_power as off_during_probe. since v8 : - Make use of ACPI _PRE object instead of a _DSD property (new patch, 1st), align documentation with that. - Added a blank line. - Rebased on current linux-next master. since v7 : - Reorder documentation patch right after the implemenation in the I²C framework. - Rename allow-low-power-probe property as i2c-allow-low-power-probe. - Remove extra "property" from the description of the i2c-allow-low-power-probe property and mention it's a device property. - Add an example to the documentation and refer to the _DSD property spec. since v6 : - Use u32 for the flags field in struct i2c_driver. - Use acpi_dev_get_property to read the allow-low-power-probe property. since v5 : - Identify sensors when they're first powered on. In previous versions, if this wasn't in probe, it was not done at all. - Return allow_low_power_probe() only for ACPI devices, i.e. OF systems are not affected by these changes. - Document that I2C_DRV_FL_ALLOW_LOW_POWER_PROBE flag only applies to ACPI drivers. - Fix extra regulator_disable in at24 driver's remove function when the device was already in low power state. since v4 : - Rename "probe-low-power" property as "allow-low-power-probe". This is taken into account in function and file naming, too. - Turn probe_low_power field in struct i2c_driver into flags field. - Rebase on Wolfram's i2c/for-next branch that contains the removal of the support for disabling I²C core IRQ mappings (commit 0c2a34937f7e4c4776bb261114c475392da2355c). - Change wording for "allow-low-power-probe" property in ACPI documentation. since v3 : - Rework the 2nd patch based on Rafael's comments - Rework description of the ACPI low power state helper function, according to Rafael's text. - Rename and rework the same function as acpi_dev_state_low_power(). - Reflect the changes in commit message as well. - Added a patch to document the probe-low-power _DSD property. since v2 : - Remove extra CONFIG_PM ifdefs; these are not needed. - Move the checks for power state hints from drivers/base/dd.c to drivers/i2c/i2c-base-core.c; these are I²C devices anyway. - Move the probe_low_power field from struct device_driver to struct i2c_driver. since v1: - Rename probe_powered_off struct device field as probe_low_power and reflect the similar naming to the patches overall. - Work with CONFIG_PM disabled, too. Rajmohan Mani (1): media: i2c: imx319: Support probe while the device is off Sakari Ailus (6): ACPI: scan: Obtain device's desired enumeration power state i2c: Allow an ACPI driver to manage the device's power state during probe Documentation: ACPI: Document _DSE object usage for enum power state ACPI: Add a convenience function to tell a device is in low power state ov5670: Support probe whilst the device is in a low power state at24: Support probing while off Documentation/firmware-guide/acpi/index.rst | 1 + .../firmware-guide/acpi/low-power-probe.rst | 69 +++++++++++++++++ drivers/acpi/device_pm.c | 23 ++++++ drivers/acpi/scan.c | 4 + drivers/i2c/i2c-core-acpi.c | 10 +++ drivers/i2c/i2c-core-base.c | 9 ++- drivers/media/i2c/imx319.c | 72 +++++++++++------- drivers/media/i2c/ov5670.c | 76 +++++++++++-------- drivers/misc/eeprom/at24.c | 43 ++++++----- include/acpi/acpi_bus.h | 1 + include/linux/acpi.h | 6 ++ include/linux/i2c.h | 19 +++++ 12 files changed, 255 insertions(+), 78 deletions(-) create mode 100644 Documentation/firmware-guide/acpi/low-power-probe.rst -- 2.20.1