From patchwork Tue Oct 15 15:04:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 3045931 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 69B2B9F2B7 for ; Tue, 15 Oct 2013 15:06:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39646201DC for ; Tue, 15 Oct 2013 15:06:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F94A20212 for ; Tue, 15 Oct 2013 15:06:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932794Ab3JOPGM (ORCPT ); Tue, 15 Oct 2013 11:06:12 -0400 Received: from mga02.intel.com ([134.134.136.20]:47445 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932760Ab3JOPGL (ORCPT ); Tue, 15 Oct 2013 11:06:11 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 15 Oct 2013 08:05:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,499,1378882800"; d="scan'208";a="419473028" Received: from unknown (HELO localhost) ([10.255.21.19]) by orsmga002.jf.intel.com with ESMTP; 15 Oct 2013 08:05:47 -0700 From: Lan Tianyu To: lenb@kernel.org, rjw@rjwysocki.net Cc: Lan Tianyu , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/3] ACPI/POWER: Call acpi_power_resume_dependent() directly in the acpi_power_on_unlocked() Date: Tue, 15 Oct 2013 23:04:53 +0800 Message-Id: <1381849493-7977-4-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1381849493-7977-1-git-send-email-tianyu.lan@intel.com> References: <1381849493-7977-1-git-send-email-tianyu.lan@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP acpi_power_resume_dependent() purposes to resume power resource's dependent physical devices after turning on the related power resource. But current it runs in the workqueue, pm_request_resume() can't check the right runtime pm state just after turning on power resource. This will cause infinite loop between resume and suspend in some cases that turn on power resource in the pm runtime resume callback(e,g usb port). This patch is to fix the issue via calling acpi_power_resume_dependent() directly instead of running it in a workqueue. Signed-off-by: Lan Tianyu --- drivers/acpi/power.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 3fc2873..5e4991b 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -62,7 +62,6 @@ ACPI_MODULE_NAME("power"); struct acpi_power_dependent_device { struct list_head node; struct acpi_device *adev; - struct work_struct work; }; struct acpi_power_resource { @@ -235,14 +234,12 @@ static int acpi_power_get_list_state(struct list_head *list, int *state) return 0; } -static void acpi_power_resume_dependent(struct work_struct *work) +static void acpi_power_resume_dependent(struct acpi_power_dependent_device *dep) { - struct acpi_power_dependent_device *dep; struct acpi_device_physical_node *pn; struct acpi_device *adev; int state; - dep = container_of(work, struct acpi_power_dependent_device, work); adev = dep->adev; if (acpi_power_get_inferred_state(adev, &state)) return; @@ -294,7 +291,7 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource) struct acpi_power_dependent_device *dep; list_for_each_entry(dep, &resource->dependent, node) - schedule_work(&dep->work); + acpi_power_resume_dependent(dep); } } return result; @@ -414,7 +411,6 @@ static void acpi_power_add_dependent(struct acpi_power_resource *resource, goto out; dep->adev = adev; - INIT_WORK(&dep->work, acpi_power_resume_dependent); list_add_tail(&dep->node, &resource->dependent); out: @@ -425,23 +421,16 @@ static void acpi_power_remove_dependent(struct acpi_power_resource *resource, struct acpi_device *adev) { struct acpi_power_dependent_device *dep; - struct work_struct *work = NULL; mutex_lock(&resource->resource_lock); list_for_each_entry(dep, &resource->dependent, node) if (dep->adev == adev) { list_del(&dep->node); - work = &dep->work; break; } mutex_unlock(&resource->resource_lock); - - if (work) { - cancel_work_sync(work); - kfree(dep); - } } static struct attribute *attrs[] = {