From patchwork Thu Sep 21 22:20:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9964879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5203A6056E for ; Thu, 21 Sep 2017 22:30:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 416C429686 for ; Thu, 21 Sep 2017 22:30:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35E472968A; Thu, 21 Sep 2017 22:30:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42679296FC for ; Thu, 21 Sep 2017 22:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751792AbdIUWaE (ORCPT ); Thu, 21 Sep 2017 18:30:04 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:58400 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbdIUWaD (ORCPT ); Thu, 21 Sep 2017 18:30:03 -0400 Received: from 79.184.252.54.ipv4.supernova.orange.pl (79.184.252.54) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.82) id 80e658885752e48d; Fri, 22 Sep 2017 00:30:01 +0200 From: "Rafael J. Wysocki" To: Johannes Stezenbach Cc: Pierre-Louis Bossart , linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, Carlo Caione , Andy Shevchenko , Darren Hart , Enric Balletbo i Serra , Takashi Iwai , linux-acpi@vger.kernel.org Subject: Re: S0ix failure due to "clk: x86: Do not gate clocks enabled by the firmware" Date: Fri, 22 Sep 2017 00:20:55 +0200 Message-ID: <2582638.tGggrMFmYq@aspire.rjw.lan> In-Reply-To: <20170921162307.amdz2uyei7eackhs@sig21.net> References: <20170906204237.24x6fzlfmq7jmuce@sig21.net> <4036229.gTT6xKEFIS@aspire.rjw.lan> <20170921162307.amdz2uyei7eackhs@sig21.net> MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thursday, September 21, 2017 6:23:07 PM CEST Johannes Stezenbach wrote: > On Thu, Sep 21, 2017 at 04:21:46PM +0200, Rafael J. Wysocki wrote: > > So I would be inclined to think of that as a BIOS issue. > > OK, wrt $Subject it sparks the question how to fix the > issue exposed by commit d31fd43c0f9a4 "clk: x86: Do not > gate clocks enabled by the firmware". Add quirks to > the drivers for the devices that have the dangling > PowerResources and manually call _OFF/_ON during suspend/resume? Well, it may just be better to do that in the core at the suspend time, so I'm wondering if the appended patch makes any difference? --- drivers/acpi/power.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/acpi/sleep.h | 1 + 2 files changed, 37 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-clk" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pm/drivers/acpi/power.c =================================================================== --- linux-pm.orig/drivers/acpi/power.c +++ linux-pm/drivers/acpi/power.c @@ -64,6 +64,7 @@ struct acpi_power_resource { unsigned int ref_count; bool wakeup_enabled; struct mutex resource_lock; + bool suspended; }; struct acpi_power_resource_entry { @@ -839,6 +840,37 @@ int acpi_add_power_resource(acpi_handle } #ifdef CONFIG_ACPI_SLEEP +void acpi_suspend_power_resources(u32 acpi_state) +{ + struct acpi_power_resource *resource; + + mutex_lock(&power_resource_list_lock); + + list_for_each_entry(resource, &acpi_power_resource_list, list_node) { + int result, state; + + mutex_lock(&resource->resource_lock); + + result = acpi_power_get_state(resource->device.handle, &state); + if (result) { + mutex_unlock(&resource->resource_lock); + continue; + } + + if (state == ACPI_POWER_RESOURCE_STATE_ON + && resource->system_level < acpi_state) { + dev_info(&resource->device.dev, "Turning OFF\n"); + __acpi_power_off(resource); + resource->ref_count++; + resource->suspended = true; + } + + mutex_unlock(&resource->resource_lock); + } + + mutex_unlock(&power_resource_list_lock); +} + void acpi_resume_power_resources(void) { struct acpi_power_resource *resource; @@ -860,6 +892,10 @@ void acpi_resume_power_resources(void) && resource->ref_count) { dev_info(&resource->device.dev, "Turning ON\n"); __acpi_power_on(resource); + if (resource->suspended) { + resource->ref_count--; + resource->suspended = false; + } } mutex_unlock(&resource->resource_lock); Index: linux-pm/drivers/acpi/sleep.h =================================================================== --- linux-pm.orig/drivers/acpi/sleep.h +++ linux-pm/drivers/acpi/sleep.h @@ -5,6 +5,7 @@ extern void acpi_disable_wakeup_devices( extern struct list_head acpi_wakeup_device_list; extern struct mutex acpi_device_lock; +extern void acpi_suspend_power_resources(u32 acpi_state); extern void acpi_resume_power_resources(void); extern void acpi_turn_off_unused_power_resources(void);