Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2106427pxb; Fri, 29 Jan 2021 13:25:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4cXsw+pOy/39ssfYdMejglFTFbnM0ddl9e4oVCwszCXqqnuDnUhHll9ffeyOQg7oan+cx X-Received: by 2002:a17:906:7689:: with SMTP id o9mr6587719ejm.324.1611955519468; Fri, 29 Jan 2021 13:25:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611955519; cv=none; d=google.com; s=arc-20160816; b=eZjMR/FFJZQpqKHrfZJJmRY9nuexDM6h8Ms9MFFSrN/asi8UDbja/PP44uv6vddT55 k9xmmancTY4m8HFYHIB10iJlnjE8+Rc62bJ8TJYkSAjRFtLjfReP8EITit+B87H3Dsfb 06Cs4xH8Ws2wQuaMpKVojDigBHpBwOsZhROsvGZ43KsbY6qud/3oHGJC+vjzglUxKT8n bOWPvLOuCD1+GI/l7BnQTMZvo4oHGXlVWRA88xQo3a3SyQIRVrfnHSZpUhdwFaxG1U79 eQ7Y6OJWktzTVPlP31gbniHQyjCHboluLUEpHqEyVg3Gu54tZcypwE3cPgNm6vTdcBjQ wSbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=P+8t/e7z0nEhs8+icHxDTtHqG5N+fODjJqQwSGpBkX0=; b=OpCVm5kWkn3GRTXXDlc4Pmc9WeTCFAZmwKnXdwfTfLq7ZTQ4pEg/rPIWR1TMnhpoI0 b5xAoSWm0RERHXgwUlfRAQ9iwucbotVPwxVb8VZqkZTst32pWSVYwKRMkErYDb5HT2Rl 533SCzUWCHJ/AJuVEIYxWc+frJsxIomNENdl1cVydvrXqGfPYrQDzGSZ5gQx7C/GzOjs gLVKLSQPNVxWoPeKRochuFePYLNkw39qL/NzDJFYjlMgh+jWg84tgpFnnLTYP/uv2VIO QrfE3JqlyyFRpaDVTGkdilhtsZLHkFMmMV55clzKQANDDAJJM3dQ0qSp0sK18+mv5KWP qbcA== 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 ws14si5754014ejb.625.2021.01.29.13.24.54; Fri, 29 Jan 2021 13:25:19 -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 S233369AbhA2VYG (ORCPT + 99 others); Fri, 29 Jan 2021 16:24:06 -0500 Received: from mga06.intel.com ([134.134.136.31]:9705 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232776AbhA2VYF (ORCPT ); Fri, 29 Jan 2021 16:24:05 -0500 IronPort-SDR: B/YHyPl/so9M/APay8n/FyCmVMrrYqBaln1DLKVX3IOEc+lTuzEULWj1/PSbmdk9RxQSL8uJA3 MEL5Yuktjxmg== X-IronPort-AV: E=McAfee;i="6000,8403,9879"; a="242005593" X-IronPort-AV: E=Sophos;i="5.79,386,1602572400"; d="scan'208";a="242005593" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2021 13:22:19 -0800 IronPort-SDR: 8TLGKFkxh7yP7CkNxzB+YxP0Zrq2iIwPA5OEWVGItUxtV3d8iJghJPpWQwbX40LoPBcaFfGbW8 w6+hW1T+bo1A== X-IronPort-AV: E=Sophos;i="5.79,386,1602572400"; d="scan'208";a="370545067" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2021 13:22:14 -0800 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id D8B8B211D8; Fri, 29 Jan 2021 23:22:11 +0200 (EET) Date: Fri, 29 Jan 2021 23:22:11 +0200 From: Sakari Ailus To: "Rafael J. Wysocki" Cc: linux-i2c , Wolfram Sang , ACPI Devel Maling List , Linux Kernel Mailing List , Greg Kroah-Hartman , "Mani, Rajmohan" , Tomasz Figa , Bartosz Golaszewski , Bingbu Cao , Chiranjeevi Rapolu , Hyungwoo Yang , Linux Media Mailing List Subject: Re: [PATCH v9 1/7] ACPI: scan: Obtain device's desired enumeration power state Message-ID: <20210129212211.GK32460@paasikivi.fi.intel.com> References: <20200903081550.6012-1-sakari.ailus@linux.intel.com> <20210128232729.16064-1-sakari.ailus@linux.intel.com> <20210129164522.GJ32460@paasikivi.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 29, 2021 at 05:57:17PM +0100, Rafael J. Wysocki wrote: > On Fri, Jan 29, 2021 at 5:45 PM Sakari Ailus > wrote: > > > > Hi Rafael, > > > > Thanks for the comments. > > > > On Fri, Jan 29, 2021 at 03:07:57PM +0100, Rafael J. Wysocki wrote: > > > On Fri, Jan 29, 2021 at 12:27 AM Sakari Ailus > > > wrote: > > > > > > > > Store a device's desired enumeration power state in struct > > > > acpi_device_power_flags during acpi_device object's initialisation. > > > > > > > > Signed-off-by: Sakari Ailus > > > > --- > > > > drivers/acpi/scan.c | 6 ++++++ > > > > include/acpi/acpi_bus.h | 3 ++- > > > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > > > > index 1d7a02ee45e05..b077c645c9845 100644 > > > > --- a/drivers/acpi/scan.c > > > > +++ b/drivers/acpi/scan.c > > > > @@ -987,6 +987,8 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) > > > > > > > > static void acpi_bus_get_power_flags(struct acpi_device *device) > > > > { > > > > + unsigned long long pre; > > > > + acpi_status status; > > > > u32 i; > > > > > > > > /* Presence of _PS0|_PR0 indicates 'power manageable' */ > > > > @@ -1008,6 +1010,10 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) > > > > if (acpi_has_method(device->handle, "_DSW")) > > > > device->power.flags.dsw_present = 1; > > > > > > > > + status = acpi_evaluate_integer(device->handle, "_PRE", NULL, &pre); > > > > + if (ACPI_SUCCESS(status) && !pre) > > > > + device->power.flags.allow_low_power_probe = 1; > > > > > > While this is what has been discussed and thanks for taking it into > > > account, I'm now thinking that it may be cleaner to introduce a new > > > object to return the deepest power state of the device in which it can > > > be enumerated, say _DSE (Device State for Enumeration) such that 4 > > > means D3cold, 3 - D3hot and so on, so the above check can be replaced > > > with something like > > > > > > status = acpi_evaluate_integer(device->handle, "_PRE", NULL, &dse); > > > > s/_PRE/_DSE/ > > > > ? > > Yes, sorry. > > > > > > if (ACPI_FAILURE(status)) > > > > ACPI_SUCCESS? > > Yup. > > > > device->power.state_for_enumeratin = dse; > > > > > > And then, it is a matter of comparing ->power.state_for_enumeratin > > > with ->power.state and putting the device into D0 if the former is > > > shallower than the latter. > > > > > > What do you think? > > > > Sounds good. How about calling the function e.g. > > acpi_device_resume_for_probe(), so runtime PM could be used to resume the > > device if the function returns true? > > I'd rather try to power it up before enabling runtime PM, because in > order to do the latter properly, you need to know if the device is > active or suspended to start with. > > So you need something like (pseudo-code) > > if (this_device_needs_to_be_on(ACPI_COMPANION(dev))) { > acpi_device_set_power(ACPI_COMPANION(dev), ACPI_STATE_D0); > pm_runtime_set_active(dev); > } else { > pm_runtime_set_suspended(dev); I guess the else branch isn't needed? The device remains suspended if its state hasn't been changed. > } > > and then you can enable PM-runtime. Yes, agreed, this is what drivers should do. The I?C framework would use the function and conditionally power the device on before enabling runtime PM. This is how it's implemented by the set already but I think the change in semantics requires a little more still. -- Sakari Ailus