From patchwork Wed Aug 23 14:42:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110846 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031362ybm; Wed, 23 Aug 2017 07:42:18 -0700 (PDT) X-Received: by 10.25.228.194 with SMTP id x63mr959854lfi.218.1503499338034; Wed, 23 Aug 2017 07:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499338; cv=none; d=google.com; s=arc-20160816; b=sLTUnYDaPHUu2gEB7Xd+HodNAxXGxCKOHPHvBPF1rTnErZt2esJyYUwogkNZcB+dzE DymympcwctRXAqRGP0cVzGN/VP59UQJx5bd2tEYoZsj0T9QTTX0JJzIYe/hZTvD7Kwey 2lR0L2IuFE0wF3V3JuKqatmU8y0c8do5Fz2dTTLEnxdph8YKOVXQLRZ94xjlcWjiFtvk 3vog6gsffNWBPqOAJ1ncIz0KHaPZHHO+Lvv39wims7xnUl1ALFLoyyLvFD45QAstEl+F CXKA4wkmWOF4Mz8UkeuSH9wU2MlqJH33dPWhQZ2dmilWuw/jkdc7kJndWRHCrCTIqLXE tKHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=KzVpXfyc4xVzl22eZpEVfjyQDIR09PtoK3oRB7BB5a4=; b=fzOCmrAG4DVDqiP8jdcB5lAiAf+L8WJLT6WubXC+tL0xPy+ELIx9WpyB06TZ3z79fw KT5gi/ZLgvTYW1JZuFB7Uhe/xoY9YVVdnCSsAGII4Yaof+6D5B3UZnhpPmkKReUzbher KrgFayVzZwP3sL51aF/um/ofr8w9SV/AF3RrGB++HEpMjOwBxtW4AQ6JPJWPGTt0UQCH MfpTer/G7jeJyM3rhqog/wqqhP/Zc2b8CzDnA9AfZYf0/01LlFX5GKrOtfiSBGHCVD93 8TQ4KWG1WtC+nftKmODiQiwTJdScEuehfYVT3/AGJJMKHpGrc56t93s151kQTBk6Iuo5 EUew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMGGCVJr; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x232.google.com (mail-lf0-x232.google.com. [2a00:1450:4010:c07::232]) by mx.google.com with ESMTPS id 1si745715ljn.72.2017.08.23.07.42.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) client-ip=2a00:1450:4010:c07::232; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMGGCVJr; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x232.google.com with SMTP id g77so1535421lfg.1 for ; Wed, 23 Aug 2017 07:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KzVpXfyc4xVzl22eZpEVfjyQDIR09PtoK3oRB7BB5a4=; b=fMGGCVJrKuhg8VgM11uxUlqHOhu9636wl25qTqyIvIVof5a59Pahso49ocmXMl4LbN ZqOjulhcw27qjtfsvgIPeFja6hUZDLgucl0zrZZpQQ43hIe92IO4D8tZTGaGBG+0Oo84 e+JYrqjbSlSz9JDo28PCMnBzj0bH9bynw8J8k= 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:in-reply-to :references; bh=KzVpXfyc4xVzl22eZpEVfjyQDIR09PtoK3oRB7BB5a4=; b=AsACHUXx0xyRea0I26N1dISlKUM7g0N2+Mf5qaJ2piBpZjcJ+PTubjWqxlTwDrezm5 qTmYFqew0pAaSCJkIhV4JTUOiG6KqOIRiLZ1omL0jRuhRNOxNRLdcUpHyzzx7RHBkOBr g61ckBEWpVRgHLIL3Xz4uRn1pAX7ObQVRqpSSEsuh+g/wiopUpDABV7YC4RRXUgO0eQ8 5ZfmVjTxBz++Y46fYlz50hqQST5aCkdCKo7RuH3ILW2kbP9ICFUTfZbVEzRybARhnl06 y6hxPSezdw1Mu7VQj/H6rPQBPQQBzMgMoem2w8jDi993fOpEzcfywdnrxaOKyf5OnzbK MUPw== X-Gm-Message-State: AHYfb5jmp8I9bcgKOhUqZ4//C4R8vMW8Km/FOA+rKjqHYL0nHAzFZ2Fz 7NyL/dE3hJ7QKaWYYfs= X-Received: by 10.25.84.4 with SMTP id i4mr912192lfb.221.1503499337581; Wed, 23 Aug 2017 07:42:17 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:16 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 1/9] PM / ACPI: Restore acpi_subsys_complete() Date: Wed, 23 Aug 2017 16:42:01 +0200 Message-Id: <1503499329-28834-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> The commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware"), made PCI's and ACPI's ->complete() callbacks to be assigned to a new API called pm_complete_with_resume_check(), which was introduced in the same change. Later it turned out that using pm_complete_with_resume_check() isn't good enough for PCI, as it needs additional PCI specific checks, before deciding whether runtime resuming the device is needed when running the ->complete() callback. This leaves ACPI being the only user of pm_complete_with_resume_check(). Therefore let's restore ACPI's acpi_subsys_complete(), which was dropped in commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware"). This enables us to remove the pm_complete_with_resume_check() API in a following change, but it also enables ACPI to add more ACPI specific checks in acpi_subsys_complete() if it turns out that is needed. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/acpi/acpi_lpss.c | 2 +- drivers/acpi/device_pm.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 032ae44..0c84d15 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -894,7 +894,7 @@ static struct dev_pm_domain acpi_lpss_pm_domain = { #ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP .prepare = acpi_subsys_prepare, - .complete = pm_complete_with_resume_check, + .complete = acpi_subsys_complete, .suspend = acpi_subsys_suspend, .suspend_late = acpi_lpss_suspend_late, .resume_early = acpi_lpss_resume_early, diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index fbcc73f..632f214 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1020,6 +1020,23 @@ int acpi_subsys_prepare(struct device *dev) EXPORT_SYMBOL_GPL(acpi_subsys_prepare); /** + * acpi_subsys_complete - Finalize device's resume during system resume. + * @dev: Device to handle. + */ +void acpi_subsys_complete(struct device *dev) +{ + pm_generic_complete(dev); + /* + * If the device had been runtime-suspended before the system went into + * the sleep state it is going out of and it has never been resumed till + * now, resume it in case the firmware powered it up. + */ + if (dev->power.direct_complete && pm_resume_via_firmware()) + pm_request_resume(dev); +} +EXPORT_SYMBOL_GPL(acpi_subsys_complete); + +/** * acpi_subsys_suspend - Run the device driver's suspend callback. * @dev: Device to handle. * @@ -1087,7 +1104,7 @@ static struct dev_pm_domain acpi_general_pm_domain = { .runtime_resume = acpi_subsys_runtime_resume, #ifdef CONFIG_PM_SLEEP .prepare = acpi_subsys_prepare, - .complete = pm_complete_with_resume_check, + .complete = acpi_subsys_complete, .suspend = acpi_subsys_suspend, .suspend_late = acpi_subsys_suspend_late, .resume_early = acpi_subsys_resume_early, From patchwork Wed Aug 23 14:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110848 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031380ybm; Wed, 23 Aug 2017 07:42:19 -0700 (PDT) X-Received: by 10.46.7.67 with SMTP id i3mr1039760ljd.90.1503499339657; Wed, 23 Aug 2017 07:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499339; cv=none; d=google.com; s=arc-20160816; b=nPNgDwKBbq3cLMbXW4ncSUV97vGcYA8BbvS0RHPRcYcbwUhkgoqobTLsS91emZZtQ7 itly0+X5/QWQZWJpHs2nGon1xJehClb+oWt25c8wHFXO4MTVK2nPJ2BtOjeb1ONt8q9F sfrkwmzKrNiYhtLeeyUIqMndICBxR3RrVoUzeNSbWwWi+IMY82ARIvQHGaYyQ54dg6Te tuXnKk0g9BuRxPgNaUaPLWSmQqY2rkqAiOJyqxz5K58Gn77A3NhHKEfcVxYb68M4MW22 6DvVmkLs8mQPAgjqLma+WLjbo824cqZuoByvG/LG4wXRhIjQRvZaolkwP863HELX8b4Q eDdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=K+c1reHhAyzBsLbN0U8sxsB1BZjUOEtCkSCHqstB7PI=; b=y4tA2L9YsE4b+rnwce6sr6+zrO8P22hp7/ruzq7JXe9EUmNcPlY5wF9alzp08sUm4E 3M9CRIvc/Wg5LS/fjNA7fioDTcIBQHc+e8Mihl6nU21KNSogiu+tZnINy632lFJsmFmt 2q4ToszCs/FOuYZjdgTsdXnWYUSUHN9ZuoxGnuseeNtYvUk/2GKLgPI3sDmwdkKnImoz 6a1R6PC//di1yEBE8YFw4XtPGAYeGfPjZEmv1ccwmODWG+zaoiBB0sop8KY8X28yMweE +Nhjh9thZdeWC7MEbLKsAonXwUEUaKEfFVu8I7RwBNzxl1RsT2UdxfQPOo+MInMUQud5 uocQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QK3/ASKD; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x236.google.com (mail-lf0-x236.google.com. [2a00:1450:4010:c07::236]) by mx.google.com with ESMTPS id x26si766215ljd.237.2017.08.23.07.42.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) client-ip=2a00:1450:4010:c07::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QK3/ASKD; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x236.google.com with SMTP id y15so1334606lfd.5 for ; Wed, 23 Aug 2017 07:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K+c1reHhAyzBsLbN0U8sxsB1BZjUOEtCkSCHqstB7PI=; b=QK3/ASKDUq29BjRT0h5wCFBbo/xHmwRcz4HT1EIpiZLl3OHkBBN3F66qqhfqjlrBnT 8gwVCZU6iwKJpL5c7NU1jWm4qtwHSpZZ99ljTE4sdyBAcpOPfsrRrXg6Jq6WAUW1Ju3+ b3E6chswth4y4oVL145lto1LBq1H8MX7kfMrI= 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:in-reply-to :references; bh=K+c1reHhAyzBsLbN0U8sxsB1BZjUOEtCkSCHqstB7PI=; b=aZzzpoM5+cNs0VI5VTzYu67JHpt+oJtGTLlV2z9pFqvPLTMWT1cjrpvbYlE3uLUhFJ ofLizM3vdgoGGDhEnRIdOKD7DQOJ00fQigU3lPqaCIxpNwmM/f8lJuNysh4w7JPCxJQP CEIMahS7zGsq7j1k+N30Kzh2dzghnnpAH8iasWiPsVlk7lgtCchpIaquYrbIoF97KRe7 6BOS5/MIA6A4/vaVGUSiwb2W6z7NrS9mZehb+PSDp3vpcr3xeP7HpaaR3pnJxvpGFjSV jMVkedYaq5fyMuU9J5tS3lbA5wt3RSZrOzahDHgnhufyNOwhOAsgW+FNqnDTwdc6xJpT IT/g== X-Gm-Message-State: AHYfb5gtvggbLn3eii90yNGG9ioMeRIJUOVaZwpTmolg9t0Jx6PbY92N n/qN8z93YD23aUQ0yTE= X-Received: by 10.46.25.194 with SMTP id 63mr1396534ljz.21.1503499339264; Wed, 23 Aug 2017 07:42:19 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:18 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 2/9] PM / Sleep: Remove pm_complete_with_resume_check() Date: Wed, 23 Aug 2017 16:42:02 +0200 Message-Id: <1503499329-28834-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> According to recent changes for ACPI, the are longer any users of pm_complete_with_resume_check(), thus let's drop it. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/base/power/generic_ops.c | 23 ----------------------- include/linux/pm.h | 1 - 2 files changed, 24 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index 07c3c4a..b2ed606 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c @@ -9,7 +9,6 @@ #include #include #include -#include #ifdef CONFIG_PM /** @@ -298,26 +297,4 @@ void pm_generic_complete(struct device *dev) if (drv && drv->pm && drv->pm->complete) drv->pm->complete(dev); } - -/** - * pm_complete_with_resume_check - Complete a device power transition. - * @dev: Device to handle. - * - * Complete a device power transition during a system-wide power transition and - * optionally schedule a runtime resume of the device if the system resume in - * progress has been initated by the platform firmware and the device had its - * power.direct_complete flag set. - */ -void pm_complete_with_resume_check(struct device *dev) -{ - pm_generic_complete(dev); - /* - * If the device had been runtime-suspended before the system went into - * the sleep state it is going out of and it has never been resumed till - * now, resume it in case the firmware powered it up. - */ - if (dev->power.direct_complete && pm_resume_via_firmware()) - pm_request_resume(dev); -} -EXPORT_SYMBOL_GPL(pm_complete_with_resume_check); #endif /* CONFIG_PM_SLEEP */ diff --git a/include/linux/pm.h b/include/linux/pm.h index 47ded8a..a0ceecc 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -736,7 +736,6 @@ extern int pm_generic_poweroff_noirq(struct device *dev); extern int pm_generic_poweroff_late(struct device *dev); extern int pm_generic_poweroff(struct device *dev); extern void pm_generic_complete(struct device *dev); -extern void pm_complete_with_resume_check(struct device *dev); #else /* !CONFIG_PM_SLEEP */ From patchwork Wed Aug 23 14:42:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110849 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031408ybm; Wed, 23 Aug 2017 07:42:21 -0700 (PDT) X-Received: by 10.46.69.132 with SMTP id s126mr1158695lja.9.1503499341072; Wed, 23 Aug 2017 07:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499341; cv=none; d=google.com; s=arc-20160816; b=s7RR6R/NAF77IwhpyyG+O8DjgYaewc37cDkrnaq5BX9RJSOt8Zy50t3ncb/hrK6V9s HpSqnhxF48eRZFZndEypXk6rkgZvc+EfDBAlEX2mbDzBlv/cDgpfVwGd325l3sy9PhQL NrE7ZuOctWD0YYKVtYvqcf2TI+8ismGU+OBub86D1cwbt9fhWgret9Y4IJDip/4Z/Xie FjLWB274keKlWftULSN3VmU21t/O5MZc+k8ckjIt4f3tU2K/1tlP8C0etPQzkbN8kBPC 9IQJG/knkmtqDAPW89A9vnikvhW70yOgrCAK5zz/Fquyw660MPfPIdP707ncAxFG2YX0 orvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=4/W6OZ+A4Rz4hctfwlJI6a5jCkwwM43qZi+T3IcWlFs=; b=nZkQQzTilAjJwP2iIvvZmzMlIl4T53KWN3PnpMn3ei4vFsfwAWK+gbajeO63bEAiwK r/CjvHkUQR625t7XdpQO5sKGaNHuIItestG3lpInBilXvv9M9fM3Y4bIsggAYWTiq+mb bvbGGLtt0ezWVHi4DV8eRVEQ2C8bkE7US8bMMw6Ufg++CdE+sJD2xscKcCnRx1DqOR2A kzPj48M9mKudIBnA2g5EnTp/LSuEFDPZ10CqYD/oYOHuaA52T5ZNnD1nPqWlQWtMZk0f 29jD7ymCu+Twxbwa1Hpgt4Yt9FhUh3Q8ggXNUUIIMy4fqKi3Gf0en7yGFItZ6vUK9nl8 Ag/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZP9/pZzS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22d.google.com (mail-lf0-x22d.google.com. [2a00:1450:4010:c07::22d]) by mx.google.com with ESMTPS id r26si772957lje.50.2017.08.23.07.42.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) client-ip=2a00:1450:4010:c07::22d; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZP9/pZzS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22d.google.com with SMTP id l137so1426989lfg.3 for ; Wed, 23 Aug 2017 07:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4/W6OZ+A4Rz4hctfwlJI6a5jCkwwM43qZi+T3IcWlFs=; b=ZP9/pZzS1cSGSh0OxQT/y//rYdQFqMhJnodSRjERdabwOYiHF+l5+pIlecIH1rvGZ0 acN36gN9gjDpKNj9iz+AuGX3sYaDSRFCcePu2y6v0rWTMSrN3KMRKoJUiJxRU5532Iav Wbeqe4RLX+C94NB3ecq3D5/g7IxPN6PnbbHqs= 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:in-reply-to :references; bh=4/W6OZ+A4Rz4hctfwlJI6a5jCkwwM43qZi+T3IcWlFs=; b=qS8frXygNhvahcL+z2Lyjy5hjsgdVe02iAnBpZ/4Fcq7JSKu4odDcZyyEsyI4WKaL5 sQDp6OebVgWUAwz5Ai5C8E+kBxUtj5ntPvP7gkflA09SDbrnt8iL0CriuuanmQ2rZFHE K9Ksa1V2RAPKrKCN0hAj72a1y12Ce2zjAHBhkZ7uekLUnLRReFzJFeEy+xtc4WJvnn9w VgeGmL/n3A/fayfhiX2XlncBDNwTAFKnQqYU9zsPMmH/5MZeWdVMTGIHmW+IJOg+FQZY P/tKFN+QXOwKL6GoGrYxOONgiaVOxxzossr0B0YYdtOIZWMXAt+ndWwlFE23rrr9V1fn OEvA== X-Gm-Message-State: AHYfb5hMOLZ9G0NM5NEtyYM8ELCiJvbwVyc/F3n/B00vYY3mOvgyf3ms 8ES26WCzNQ8N6lQmi/8= X-Received: by 10.46.9.65 with SMTP id 62mr1166862ljj.177.1503499340683; Wed, 23 Aug 2017 07:42:20 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:20 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 3/9] PM / ACPI: Split code validating need for runtime resume in ->prepare() Date: Wed, 23 Aug 2017 16:42:03 +0200 Message-Id: <1503499329-28834-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> Move the code dealing with validation of whether runtime resuming the device is needed during system suspend. In this way it becomes more clear for what circumstances ACPI is prevented from trying the direct_complete path. Signed-off-by: Ulf Hansson --- Changes in v2: - Updated return expression for acpi_dev_needs_resume(). --- drivers/acpi/device_pm.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 632f214..5181057 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -989,6 +989,27 @@ int acpi_dev_resume_early(struct device *dev) } EXPORT_SYMBOL_GPL(acpi_dev_resume_early); +static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev) +{ + u32 sys_target = acpi_target_system_state(); + int ret, state; + + if (device_may_wakeup(dev) != !!adev->wakeup.prepare_count) + return true; + + if (sys_target == ACPI_STATE_S0) + return false; + + if (adev->power.flags.dsw_present) + return true; + + ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); + if (ret) + return true; + + return state != adev->power.state; +} + /** * acpi_subsys_prepare - Prepare device for system transition to a sleep state. * @dev: Device to prepare. @@ -996,26 +1017,16 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume_early); int acpi_subsys_prepare(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); - u32 sys_target; - int ret, state; + int ret; ret = pm_generic_prepare(dev); if (ret < 0) return ret; - if (!adev || !pm_runtime_suspended(dev) - || device_may_wakeup(dev) != !!adev->wakeup.prepare_count) - return 0; - - sys_target = acpi_target_system_state(); - if (sys_target == ACPI_STATE_S0) - return 1; - - if (adev->power.flags.dsw_present) + if (!adev || !pm_runtime_suspended(dev)) return 0; - ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); - return !ret && state == adev->power.state; + return !acpi_dev_needs_resume(dev, adev); } EXPORT_SYMBOL_GPL(acpi_subsys_prepare); From patchwork Wed Aug 23 14:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110850 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031435ybm; Wed, 23 Aug 2017 07:42:22 -0700 (PDT) X-Received: by 10.25.198.19 with SMTP id w19mr914567lff.211.1503499342509; Wed, 23 Aug 2017 07:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499342; cv=none; d=google.com; s=arc-20160816; b=TAOdTVBRhkKBBGwX7Natw3uUPNrvDVEms+OUVFIGohMCfMTrn25I9J2K7ZNhw/k6cd jY+GiUuWfOAb70kZvNU9EP01aKTcA+9i1i76YfrtZ/aPmec1khk4SaVHvCTfVlPio3wq eV0RhTY+lGlzyR8YUX5wsGlRR+gmmO+1cpjf54LSY61uxdA5EazSNScf6K9rJPTGsp2U n6SZ8AlCdHfgxLnpVl5ir90JGH4ibnYWdgPAHUz4XU9tITy5QiRjd/GmLwfVVf0JpyC1 wddsM+Ep6JFiZBD8Ba3wruBaui+FGTeIzdbFwPHg0BRzRZV+x7BdWkwdGxOUFLAihfr+ kixQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=VxCQHodaKHhG0+hTeLvSHBW3NEuDXnKN4by+eq4cwcM=; b=hUYAUNKJG0snYdGSJctrEoRTHHbkCXLKXBjXxWt6PrVPgOvEZ+TGxXki9e5k4WYkM5 OLW4Tomuoo7SqcSyr3UTaDlfPFJdeCRDnqb8R27nikQMKu8rUfuJHsWKm8OWef6/Atg1 mStnFxq4qkeQLG43Dgn7N+gERPBJHlGzE3y7t4DGFc2h/qRtxIZwbPn1vMKE9VHbYiq+ 33BnfeGndabvkhxLN/ZcocmhANY8Ky1qKD456KefkHZFz+2xnjsg0877VOgcIG01uzIo /8jbWRfigZNgJ0UwujV62kLQOJU4FVuL9QpRXzfxPFJJLGEsqsXC6sBS1iOOZakbqBse bz+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcmFdWaJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x230.google.com (mail-lf0-x230.google.com. [2a00:1450:4010:c07::230]) by mx.google.com with ESMTPS id n75si799209lja.41.2017.08.23.07.42.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) client-ip=2a00:1450:4010:c07::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcmFdWaJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x230.google.com with SMTP id d17so1564929lfe.0 for ; Wed, 23 Aug 2017 07:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VxCQHodaKHhG0+hTeLvSHBW3NEuDXnKN4by+eq4cwcM=; b=dcmFdWaJvixzT7Pue/FcXmWuNsI9f6cG8QJ9/+QVxpqRf8/7KPYdTXktvrE6ZEEO3h zLdFCHVxM+LffQaVchX0tjKI+l9HDEEQIV8t+bWpTlFqMvA/5lEBNH3asHpnZmN82edW nPDyxwvdt75Hg8J+JF/38ATlHJhJ7ViAwNngo= 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:in-reply-to :references; bh=VxCQHodaKHhG0+hTeLvSHBW3NEuDXnKN4by+eq4cwcM=; b=srp3FyjF+yR3lzt1mq849Gm+MnbTjnNSsShf1WIvDJYyuvux8vb+3ZPOUaFQEwkGog q7M4keYsef3fvBozHwuSnH8zeoJcF9V0lrupcP5kAaX1jM641D/qG4DYUmw5by46N89a DJBTmMkhMe2JCDqRtvJ1ro9SU1k3zf3K24jWbOrow7y0H9axXSO2zD4MZZq3pasuxc3x uv/q7PsuYqmiI+g8owHmQPJXgM+t5TgJwseHODoql9VAhExrLTQwjp53dNtcAlMY7G+6 KvQiWOKiT+kTFs/+A3Vbcj5PcdZU0AFzPMZxi48LyNOHZTi+svl2yXHRh3qCEtThz6jI tn8A== X-Gm-Message-State: AHYfb5ib6hMw7QEIsJ4gvEBh4jlW+Ph+Da4AqFgBEXeGf2n9ut9Ky0Ji 9plvu+UdeWL0F8pVu0M= X-Received: by 10.46.84.83 with SMTP id y19mr1129581ljd.167.1503499342117; Wed, 23 Aug 2017 07:42:22 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:21 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 4/9] PM / ACPI: Split acpi_lpss_suspend_late|resume_early() Date: Wed, 23 Aug 2017 16:42:04 +0200 Message-Id: <1503499329-28834-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> Move the code which is special to ACPI LPSS into separate functions. This may clarify the code a bit, but the main purpose of this change, is instead to prepare for additional changes on top. Ideally the following changes should then become easier to review. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/acpi/acpi_lpss.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 0c84d15..e726173 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -717,22 +717,28 @@ static void acpi_lpss_dismiss(struct device *dev) } #ifdef CONFIG_PM_SLEEP -static int acpi_lpss_suspend_late(struct device *dev) +static int lpss_suspend_late(struct device *dev) { struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); + + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) + acpi_lpss_save_ctx(dev, pdata); + + return acpi_dev_suspend_late(dev); +} + +static int acpi_lpss_suspend_late(struct device *dev) +{ int ret; ret = pm_generic_suspend_late(dev); if (ret) return ret; - if (pdata->dev_desc->flags & LPSS_SAVE_CTX) - acpi_lpss_save_ctx(dev, pdata); - - return acpi_dev_suspend_late(dev); + return lpss_suspend_late(dev); } -static int acpi_lpss_resume_early(struct device *dev) +static int lpss_resume_early(struct device *dev) { struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); int ret; @@ -746,6 +752,17 @@ static int acpi_lpss_resume_early(struct device *dev) if (pdata->dev_desc->flags & LPSS_SAVE_CTX) acpi_lpss_restore_ctx(dev, pdata); + return 0; +} + +static int acpi_lpss_resume_early(struct device *dev) +{ + int ret; + + ret = lpss_resume_early(dev); + if (ret) + return ret; + return pm_generic_resume_early(dev); } #endif /* CONFIG_PM_SLEEP */ From patchwork Wed Aug 23 14:42:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110851 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031479ybm; Wed, 23 Aug 2017 07:42:24 -0700 (PDT) X-Received: by 10.46.86.142 with SMTP id k14mr1504082lje.55.1503499344393; Wed, 23 Aug 2017 07:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499344; cv=none; d=google.com; s=arc-20160816; b=NNJFcjliyaK9K6nEq6ZtrHvJmnqAKga0xAWBbzWDdX+1limGL1UjzqdTLQqyWJU38Q NQKdcyreleE5ipeAwkMLhfpEf3bL+5MA11LrY/SFe6xZ2ZYRrLKKy6ZebkGWjS0OxMaS t20jSNdo38ynEwQsCu/vBYyt9Joivt3nFY7R4NuViVLXNWV9jEJpMCiH9kUpvqXmSSfT 2RoIgx+X1KP7LV7udJ9+oLYCcmrqdnKFSaW0MBOMLNvvUYRCcDNhdTN0XV+OYEKkKL0U ZNO4a8KXSuiPI071lLpHH3j7kSHTLDj+QPpKd+XcBaQ1Z1IEUPD2RgKSBcFOnVE8UgFT dfEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=eZED+UuPfl6DljeOBH8UB3GJkUVwVyCCf056rEWlHQY=; b=VYnb4QzJnxQ6ZCs4mwodV/7IHBwBZivmai/IwZmrTaOyS34eRNjEGH7wfUrtxLu55b 0p2myaRaX4JtOfBW1PWkdlgA97/ETIidvpAmAqe0YXJ7OAbto6+NK/XHuJ1aomIcPfmE /uG3DnW33p7v9t118Xr6WjQPKCUm9uiQ9YjasubKHKeDVdtysjnggi4XfXXULk87YD/W NReWQAWW60VEso6R6MvHzr21Kq5mp30+edyMD6U1aTjMvsQaGwS8gQCdLOR2XI9+eQh/ dJueNqxTuh+OjU/cVGc+OlSfOAnc2nuMozpQZT3dZOY/Sm0Cfqaqv7rDv1qZWpC0C4h/ B35A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GpEsEDMK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id a15si724950lfe.272.2017.08.23.07.42.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GpEsEDMK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x229.google.com with SMTP id d17so1565328lfe.0 for ; Wed, 23 Aug 2017 07:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eZED+UuPfl6DljeOBH8UB3GJkUVwVyCCf056rEWlHQY=; b=GpEsEDMK5hiAbDOsKVrQZBBK7urLrwbm8ykc3Irq4pH/xLv2p8BRD/dP1pmaW09WFp 7kMT2S7QWu0pwsRyWZiY0Jffy16e3Sy1oQZanQhj4tT0CmazPgWi/wFcSSoHo4/h5EMA uXsuymyEJ2wYbIhxu+bI9vlqtK9H8dmAIvsaw= 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:in-reply-to :references; bh=eZED+UuPfl6DljeOBH8UB3GJkUVwVyCCf056rEWlHQY=; b=gOkJEM8IWREey0KjYQy+FYzD0NlS0EiwkIQubitZwh5ytO0/jaeQlrYe0yWT4InLZ6 Vtvs3v2BPG08DQAxUkACugube2d68+JuD83rW/0ShsBlPT9R3YmprKSDTu0gZ/U/9r2n ph+bQuB6eVMsUwMfOsyZj0cI1HAOmEZECsJCaXDySXu4D423Doh8+koALTA0F3sNjHzN gwEONhgpPt6PzaJlunW+OAB8tpZkMcKqUdX79SJDjsBebwEmr6nWXTL7Mbg1CKynok2J PSIb1jNaV89XlMJgHOxr8s7obhVfQaqBQpnDOTBSUC96w1kxhxJvBkxpSINQgenDIS2R W4CA== X-Gm-Message-State: AHYfb5heNV5tkLozwF9i7AAdfeW1HE+uk7k55NC60Fvb/c4g5W3CVyBR nrJFHUhP9v9mpSW4K5o= X-Received: by 10.46.81.65 with SMTP id b1mr1170724lje.168.1503499343926; Wed, 23 Aug 2017 07:42:23 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:22 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 5/9] PM / ACPI: Provide option to disable direct_complete for ACPI devices Date: Wed, 23 Aug 2017 16:42:05 +0200 Message-Id: <1503499329-28834-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> In some cases a driver for an ACPI device needs to be able to prevent the ACPI PM domain from using the direct_complete path during system sleep. One typical case is when the driver for the device needs its device to stay runtime enabled, during the __device_suspend phase. This isn't the case when the direct_complete path is being executed by the PM core, as it then disables runtime PM for the device in __device_suspend(). Any following attempts to runtime resume the device after that point, just fails. A workaround to this problem is to let the driver runtime resume its device from its ->prepare() callback, as that would prevent the direct_complete path from being executed. However, that may often be a waste, especially if it turned out that no one really needed the device. For this reason, invent acpi_dev_disable|enable_direct_complete(), to allow drivers to inform the ACPI PM domain to change its default behaviour during system sleep, and thus control whether it may use the direct_complete path or not. Typically a driver should call acpi_dev_disable_direct_comlete() during ->probe() and acpi_dev_enable_direct_complete() in ->remove(). Signed-off-by: Ulf Hansson --- Changes in v2: - Moved the no_direct_complete flag to the struct acpi_device_power. --- drivers/acpi/device_pm.c | 38 +++++++++++++++++++++++++++++++++++++- include/acpi/acpi_bus.h | 1 + include/linux/acpi.h | 4 ++++ 3 files changed, 42 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 5181057..f7bf596 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -933,6 +933,41 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); #ifdef CONFIG_PM_SLEEP /** + * acpi_dev_disable_direct_complete - Disable the direct_complete path for ACPI. + * @dev: Device to disable the path for. + * + * Per default the ACPI PM domain tries to use the direct_complete path for its + * devices during system sleep. This function allows a user, typically a driver + * during probe, to disable the direct_complete path from being used by ACPI. + */ +void acpi_dev_disable_direct_complete(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev) + adev->power.no_direct_complete = true; +} +EXPORT_SYMBOL_GPL(acpi_dev_disable_direct_complete); + +/** + * acpi_dev_enable_direct_complete - Enable the direct_complete path for ACPI. + * @dev: Device to enable the path for. + * + * Enable the direct_complete path to be used during system suspend for the ACPI + * PM domain, which is the default option. Typically a driver that disabled the + * path during ->probe(), must call this function during ->remove() to re-enable + * the direct_complete path to be used by ACPI. + */ +void acpi_dev_enable_direct_complete(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev) + adev->power.no_direct_complete = false; +} +EXPORT_SYMBOL_GPL(acpi_dev_enable_direct_complete); + +/** * acpi_dev_suspend_late - Put device into a low-power state using ACPI. * @dev: Device to put into a low-power state. * @@ -1023,7 +1058,8 @@ int acpi_subsys_prepare(struct device *dev) if (ret < 0) return ret; - if (!adev || !pm_runtime_suspended(dev)) + if (!adev || adev->power.no_direct_complete || + !pm_runtime_suspended(dev)) return 0; return !acpi_dev_needs_resume(dev, adev); diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index dedf9d7..bdec5f2 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -285,6 +285,7 @@ struct acpi_device_power_state { struct acpi_device_power { int state; /* Current state */ + bool no_direct_complete; struct acpi_device_power_flags flags; struct acpi_device_power_state states[ACPI_D_STATE_COUNT]; /* Power states (D0-D3Cold) */ }; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index c1a5213..ec33c41 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -867,6 +867,8 @@ static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) #endif #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP) +void acpi_dev_disable_direct_complete(struct device *dev); +void acpi_dev_enable_direct_complete(struct device *dev); int acpi_dev_suspend_late(struct device *dev); int acpi_dev_resume_early(struct device *dev); int acpi_subsys_prepare(struct device *dev); @@ -876,6 +878,8 @@ int acpi_subsys_resume_early(struct device *dev); int acpi_subsys_suspend(struct device *dev); int acpi_subsys_freeze(struct device *dev); #else +static inline void acpi_dev_disable_direct_complete(struct device *dev) {} +static inline void acpi_dev_enable_direct_complete(struct device *dev) {} static inline int acpi_dev_suspend_late(struct device *dev) { return 0; } static inline int acpi_dev_resume_early(struct device *dev) { return 0; } static inline int acpi_subsys_prepare(struct device *dev) { return 0; } From patchwork Wed Aug 23 14:42:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110852 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031520ybm; Wed, 23 Aug 2017 07:42:26 -0700 (PDT) X-Received: by 10.25.42.82 with SMTP id f79mr1122054lfl.227.1503499346005; Wed, 23 Aug 2017 07:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499346; cv=none; d=google.com; s=arc-20160816; b=h4RfKJXnFgwAzxLoO2jSw3w917ywXgBrMOVmFmx0qx8MsmUapEzHu84uVj1nJ/ZEDV TJNaKr4Qo55kzhv4pcxKjoQ4Tjq5qJCgLeAMIpM9vahijF58TZZSyLuPgll5V47YeTD3 4t53KorHMCiaAxUCDIqcz07/4MtAEu5UXuXCl0FoiYBc5SDgYbZyvQ17xRDnswnd0jqj Orsxux4lrW06mHOiG1Pv1mUhEkUPyCUznzRlQQ8CkT2pqtBMtL0F/QqTCtEMFH2VBIT/ GY8lpZessBI4WEDLTXIb7PNQCjNr/ZHct6tf/TnWMroTPGSrN1qIhyn1K3FN/TTMAk7U Wk3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PlFC+LU83C6zTn+hEArZERKbVHODo8R4ush0GyoM5I4=; b=Nvi1yln6RSq9i80/M9zIwKxDhIe6qgz15096+Q5MDw8kMjbdE2MReTsUrsPqjzKHaQ ldQ/skwpCufCvuAAJOipM8xibjlAQCBAjxVMx63wgwdWeQdCVM73VqCekCh3LhMdGUYa C1D+xjBSHpdSmjA3QM2f5g0Sx3LVgBTUSlz/Drx9HIiTpfb093q337IsLfTgZcQbQP1d j/n+Pn3c2V9xOdQOl8PzQU0vcWOsQGNmfgaYd/IJMEFlWg0VyM+OPVdD7ftSBRRArKIZ m6h7d3No8Ww8BCsbYvhSin9RiooVg0xHJr746wncrbF/j97rR/XOq5MLhqRFP6iKUdhZ MUcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYGMg/RH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x231.google.com (mail-lf0-x231.google.com. [2a00:1450:4010:c07::231]) by mx.google.com with ESMTPS id 10si801694ljc.168.2017.08.23.07.42.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) client-ip=2a00:1450:4010:c07::231; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYGMg/RH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x231.google.com with SMTP id f7so1389179lfg.4 for ; Wed, 23 Aug 2017 07:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PlFC+LU83C6zTn+hEArZERKbVHODo8R4ush0GyoM5I4=; b=LYGMg/RHHGU+Akm2msQXYAh4T0r+IEhYoYNsebPPXUyO/ZO+Ss1udjI5C2Q5EKtCfL LI6iIYnZVFIFs9bclbKwjt6rIBGPosZf8XCVp15qGFrlfu3I6vLe4U9vMDNehyhYpMEy LONg9AUU3VC2ko9xKzvYkhJT31pW/Y0Gtiq84= 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:in-reply-to :references; bh=PlFC+LU83C6zTn+hEArZERKbVHODo8R4ush0GyoM5I4=; b=W++H/Wl4vBwoVYIcvprWiI9shobb+LRSRtryWUNX/JLwtGvS7BJyYjHDEd/HaSPffh hKKogXL/sRuc+CL0bpDBw4e1+hA4A+mr/b5KJaVhnXQlV3AxBzrYBZJM0a53HQ0vpYWs IWZFDxhkTAezTZcmPlEDnu5cdsYyag9ZGbLgQgIC2eH/LV7IZC2LmuEbrV0MsB5NrFxV LiPY9CJvXu2lxqFV2JyytK7HvOz9pZtMJ+5AGhQVosJNnJG/MTlqnx+WjfhqdPxFMksM 6LCyrT+eGqPHvkK1hJHrRLsI08BR7ZYGbeDvEuUkB9Ku726bZt9zdbCvNsKwqR1fEmnL 33vg== X-Gm-Message-State: AHYfb5h/CypJIIhszoschF3NU2ThA3wYQQo1SYalIvFiOtU7wBfOYHdK frcYaepUvhuhcm/YKJg= X-Received: by 10.46.21.71 with SMTP id 7mr1191744ljv.74.1503499345482; Wed, 23 Aug 2017 07:42:25 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:24 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 6/9] PM / ACPI: Enable the runtime PM centric approach for system sleep Date: Wed, 23 Aug 2017 16:42:06 +0200 Message-Id: <1503499329-28834-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> This change extends the interpretation of the ACPI's no_direct_complete flag to be used to enable the so called runtime PM centric approach, for devices being attached to the ACPI PM domain. The principle behind the runtime PM centric approach is to re-use the runtime PM callbacks to implement system sleep for drivers/subsystems. Moreover, using the runtime PM centric approach gives an optimized behaviour around avoiding to wake up a device from its low power state during system sleep, unless really needed. To deploy the runtime PM centric approach for a subsystem/driver, the following adaptations needs to be made. First, the runtime PM callbacks may be called when runtime PM has been disabled for the device. This serves as an indication for the callbacks to understand they are running in the system sleep sequence, instead of in the regular runtime PM path. In some cases, a callback needs to take different actions depending in what path it is being executed in, as is the case for the ACPI PM domain. In particular for the ACPI PM domain's ->runtime_suspend|resume() callbacks, when those finds runtime PM being disabled for the device, it instead executes the same operations as normally being run when ->suspend_late() and ->resume_early() callbacks are invoked during system sleep. Second, at the PM domain level, it is expected that the driver for the device makes use of pm_runtime_force_suspend|resume(), to re-use the runtime PM callbacks to put the device into low power state and to wake it up when needed during system sleep. For the ACPI PM domain's ->suspend_late() and ->resume_early() callbacks, it means bypassing the operations putting the device into low power state and the operations that wakes it up. Instead it shall invoke only the lower level ->suspend_late() and ->resume_early() callbacks for the driver, if present. Signed-off-by: Ulf Hansson --- Changes in v2: - Rebased. - Updated header for acpi_enable|disable_no_direct_complete(). --- drivers/acpi/acpi_lpss.c | 58 +++++++++++++++++++++++++++++++--------------- drivers/acpi/device_pm.c | 60 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 93 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index e726173..f0d1141 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -729,10 +729,11 @@ static int lpss_suspend_late(struct device *dev) static int acpi_lpss_suspend_late(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); int ret; ret = pm_generic_suspend_late(dev); - if (ret) + if (ret || adev->power.no_direct_complete) return ret; return lpss_suspend_late(dev); @@ -757,13 +758,23 @@ static int lpss_resume_early(struct device *dev) static int acpi_lpss_resume_early(struct device *dev) { - int ret; + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret = 0; - ret = lpss_resume_early(dev); - if (ret) - return ret; + if (!adev->power.no_direct_complete) + ret = lpss_resume_early(dev); - return pm_generic_resume_early(dev); + return ret ? ret : pm_generic_resume_early(dev); +} +#else +static inline int lpss_suspend_late(struct device *dev) +{ + return 0; +} + +static inline int lpss_resume_early(struct device *dev) +{ + return 0; } #endif /* CONFIG_PM_SLEEP */ @@ -861,6 +872,9 @@ static int acpi_lpss_runtime_suspend(struct device *dev) if (ret) return ret; + if (!pm_runtime_enabled(dev)) + return lpss_suspend_late(dev); + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) acpi_lpss_save_ctx(dev, pdata); @@ -882,21 +896,29 @@ static int acpi_lpss_runtime_resume(struct device *dev) struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); int ret; - /* - * This call is kept first to be in symmetry with - * acpi_lpss_runtime_suspend() one. - */ - if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available()) - lpss_iosf_exit_d3_state(); + if (pm_runtime_enabled(dev)) { + /* + * This call is kept first to be in symmetry with + * acpi_lpss_runtime_suspend() one. + */ + if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && + iosf_mbi_available()) + lpss_iosf_exit_d3_state(); - ret = acpi_dev_runtime_resume(dev); - if (ret) - return ret; + ret = acpi_dev_runtime_resume(dev); + if (ret) + return ret; - acpi_lpss_d3_to_d0_delay(pdata); + acpi_lpss_d3_to_d0_delay(pdata); - if (pdata->dev_desc->flags & LPSS_SAVE_CTX) - acpi_lpss_restore_ctx(dev, pdata); + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) + acpi_lpss_restore_ctx(dev, pdata); + + } else { + ret = lpss_resume_early(dev); + if (ret) + return ret; + } return pm_generic_runtime_resume(dev); } diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index f7bf596..b595968 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -913,7 +913,14 @@ EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); int acpi_subsys_runtime_suspend(struct device *dev) { int ret = pm_generic_runtime_suspend(dev); - return ret ? ret : acpi_dev_runtime_suspend(dev); + + if (ret) + return ret; + + if (!pm_runtime_enabled(dev)) + return acpi_dev_suspend_late(dev); + + return acpi_dev_runtime_suspend(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); @@ -926,7 +933,17 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); */ int acpi_subsys_runtime_resume(struct device *dev) { - int ret = acpi_dev_runtime_resume(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret = 0; + + if (!adev) + return 0; + + if (!pm_runtime_enabled(dev)) + ret = acpi_dev_resume_early(dev); + else + ret = acpi_dev_runtime_resume(dev); + return ret ? ret : pm_generic_runtime_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); @@ -939,6 +956,10 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); * Per default the ACPI PM domain tries to use the direct_complete path for its * devices during system sleep. This function allows a user, typically a driver * during probe, to disable the direct_complete path from being used by ACPI. + * Moreover, the ACPI PM domain expects and depends on that such driver deploys + * the runtime PM centric path for system sleep. In other words, the driver must + * make use of the pm_runtime_force_suspend|resume() helpers when implementing + * system sleep. */ void acpi_dev_disable_direct_complete(struct device *dev) { @@ -1072,13 +1093,21 @@ EXPORT_SYMBOL_GPL(acpi_subsys_prepare); */ void acpi_subsys_complete(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return; + pm_generic_complete(dev); /* * If the device had been runtime-suspended before the system went into * the sleep state it is going out of and it has never been resumed till - * now, resume it in case the firmware powered it up. + * now, resume it in case the firmware powered it up. Also resume it in + * case no_direct_complete is set for the device, to be sure the device + * are managed correctly when firmware has powered it up. */ - if (dev->power.direct_complete && pm_resume_via_firmware()) + if ((dev->power.direct_complete || adev->power.no_direct_complete) && + pm_resume_via_firmware()) pm_request_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_complete); @@ -1106,8 +1135,17 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend); */ int acpi_subsys_suspend_late(struct device *dev) { - int ret = pm_generic_suspend_late(dev); - return ret ? ret : acpi_dev_suspend_late(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret; + + if (!adev) + return 0; + + ret = pm_generic_suspend_late(dev); + if (ret || adev->power.no_direct_complete) + return ret; + + return acpi_dev_suspend_late(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); @@ -1121,7 +1159,15 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); */ int acpi_subsys_resume_early(struct device *dev) { - int ret = acpi_dev_resume_early(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret = 0; + + if (!adev) + return 0; + + if (!adev->power.no_direct_complete) + ret = acpi_dev_resume_early(dev); + return ret ? ret : pm_generic_resume_early(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); From patchwork Wed Aug 23 14:42:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110853 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031558ybm; Wed, 23 Aug 2017 07:42:27 -0700 (PDT) X-Received: by 10.46.76.9 with SMTP id z9mr1189558lja.134.1503499347435; Wed, 23 Aug 2017 07:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499347; cv=none; d=google.com; s=arc-20160816; b=gMeLyJomkjjJOdzvus/x4AVksQrXQ17sOy4+XRwJFAoKy1I5oMi4INjB84N2AfY7uk IVp4Yd+fZDxolh/AI2ce+R5jTOgJiii7/NrWF2t2nzZaDWht8wlSlnK2p2PYNbSNbKqk dDTVQJrP9/j2SQr5/0I5K9K4/voP+Wfc8Jd9QAPqpYt3sEM59loCXpATdHNlIwQdIkrf Uj7ozoVxS8ztjyQcjG7FlAPO4TG7EgJzAmR5wM7iqeG0iyo4ScenU+tVwGNY7LsFNRaT luVQKS7CMROullcmVx2Tvz03aDztopK08lozG3oyr1fFAyPXNx2kmZVSqIMW06yro8jN yDJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=cFtN7cmkVNQ4DEF3pHQhfXJjO7HTQgcgUFCs5qRmUEo=; b=0Qtss00DnFOxGk2HI8lzVaZqnQr4pqPDYao4iMzvK4e+dRkDGGfRWsRg0z5iUFuRdJ 5xRGizfmMw4R51F+jRILHAAfz7ES8tQfchiouhYymQrjQ4hD3iELXZmjbpH1qxjxfIIO 1uvOBRO2v9BFX7eDNB4JklFszdlWFaXyHck59mvuZd8f/2e4OUexV/MVsY9qFYtsClla 8Y14RSDJNacd+SzqaB7F+mqnM1WRuKC6pcK5j1W/k0+xc/LSam76RpNxosQEE3CfyQ+o rcnYqeQbgPE9O6HXuLE7fzqlMESnfDlyEwlTgwb0gttZLOyM4MEgBlMY6ZK/RhqkZrRC iQ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lj9VfaJ+; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x232.google.com (mail-lf0-x232.google.com. [2a00:1450:4010:c07::232]) by mx.google.com with ESMTPS id z2si756619lja.485.2017.08.23.07.42.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) client-ip=2a00:1450:4010:c07::232; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lj9VfaJ+; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x232.google.com with SMTP id l137so1428341lfg.3 for ; Wed, 23 Aug 2017 07:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cFtN7cmkVNQ4DEF3pHQhfXJjO7HTQgcgUFCs5qRmUEo=; b=Lj9VfaJ+xVEZHBDO4liUKOc2w96M80xH+qe9KbFA9TK173dHh6lFbDZXHMRFLAwGl1 Je2I3HUOai/jfX3qOGa3TSk51y2oRMfOIYy62NlCDWTnogRpOukA0FSq81U0+tYXba35 F6/w/F1XyUp68VtYFVkweY+u4xtHZpLsziTwk= 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:in-reply-to :references; bh=cFtN7cmkVNQ4DEF3pHQhfXJjO7HTQgcgUFCs5qRmUEo=; b=K+F6SJKA3yGgtcFivsuPd8NYNFCKf+7dedpp3eqMvgV92X6us0AzT5Ii8fucVYO2Hz xomMZz9r9xlg95uKoYgfrbO4uLjz7ntvVxRuuMIkbG+PKtIsHZv5eIpm8uTS+A1r4WUF qc3X8lJ5d5j6ViFlgXhnI9I14aEditJM9TpbeWtL8cSCiozIj3aON545b5O6JLdOtyVn EJAI+TJ0nUZvevDIjnbJ9tbhS7QHS0I3oAGFc4ZNf26USjrnnO0cIspXBkMJpvf89m0L +tN8v4GuiVBVcg82v9tD/lOJRnTpYEwt1KOm8pSJMaoeFkVTxp1H3v7Vrxnon1xfZb/E qaTg== X-Gm-Message-State: AHYfb5jPsBlk49cnk0OuW+MU7l29blWxNQfClycp41JjIDm067DKtqzn +Q4u1YcUWNq6UgxK2aY= X-Received: by 10.46.69.213 with SMTP id s204mr1196849lja.176.1503499346939; Wed, 23 Aug 2017 07:42:26 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:26 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 7/9] PM / ACPI: Avoid runtime resuming device in acpi_subsys_suspend|freeze() Date: Wed, 23 Aug 2017 16:42:07 +0200 Message-Id: <1503499329-28834-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> In the case when the no_direct_complete flag is set for the ACPI device, we can under some conditions during system sleep, avoid runtime resuming the device in acpi_subsys_suspend|freeze(). This means we can decrease the time needed for the device to enter its system sleep state, but also that we can avoid to waste power. More precisely, calling acpi_dev_needs_resume() from the acpi_subsys_suspend|freeze() in cases when the no_direct_complete flag has been set for the device, tells us if a runtime resume of the device is needed. Thus it may allow us to avoid it. Signed-off-by: Ulf Hansson --- Changes in v2: - Clarified changelog. - Improved comments is code. - Rebased. - Improved change to avoid open-coding. --- drivers/acpi/device_pm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index b595968..5dd23de 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1117,11 +1117,19 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete); * @dev: Device to handle. * * Follow PCI and resume devices suspended at run time before running their - * system suspend callbacks. + * system suspend callbacks. However, try to avoid it when no_direct_complete + * is set. */ int acpi_subsys_suspend(struct device *dev) { - pm_runtime_resume(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + + if (!adev->power.no_direct_complete || acpi_dev_needs_resume(dev, adev)) + pm_runtime_resume(dev); + return pm_generic_suspend(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_suspend); @@ -1178,13 +1186,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); */ int acpi_subsys_freeze(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + /* * This used to be done in acpi_subsys_prepare() for all devices and * some drivers may depend on it, so do it here. Ideally, however, * runtime-suspended devices should not be touched during freeze/thaw - * transitions. + * transitions. In case the no_direct_complete is set, try to avoid it. */ - pm_runtime_resume(dev); + if (!adev->power.no_direct_complete || acpi_dev_needs_resume(dev, adev)) + pm_runtime_resume(dev); + return pm_generic_freeze(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_freeze); From patchwork Wed Aug 23 14:42:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110854 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031585ybm; Wed, 23 Aug 2017 07:42:28 -0700 (PDT) X-Received: by 10.46.20.88 with SMTP id 24mr1024114lju.51.1503499348772; Wed, 23 Aug 2017 07:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499348; cv=none; d=google.com; s=arc-20160816; b=tv9+EMCMj0APqlajTZzkkc8XPUOK8V67wE9rZa+jO5+CH95FcLH7hk/jYmuU9HReUt l9b2fTl9PuHRDRWoKmhmSkxykAgOXvLcl9/DhqT2UaYMVkGzUfrDXWHT4InIQt/r7/tJ Eu+0qp666BOcxse2DGV7K/TuD26GleHkJyV52ehKvTuewvW7c0r81U023FS3f9iNVS53 mVHkIAqa0KO8kIh4kdBkA5960KszdNHo8pAaGFk9d6gDpQbM4N5LXe9PkiTGQypx85H7 QqN/417ZF16VU3J21vOHJwVHL1N4KCluSfSM31LAo/eeDRN1ho9BEWa7ru3bViNx20K3 tZrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OVyzB8N1P8QR0uR6qN7uOx0wtf9amaEOf3rrA1CA1zw=; b=Gxq+Y/p5B94zm+kTnHP+fsQLE4XPS8h4KIbwu6K0AlkhATlpqcWwn533vqFnFqiuhH Z2W+xZfy59/xfHrO8iBfduv/kCoB/wOQ9mSrAHjDOW9BXb3LlnXBe/A1eIab68UZdVUk ecIrCd3i5CEjELXFTcqmyedUWWR0e3qFOo03SjqQosisQykbCbVmfXYKEjHk4Nlac0dD CZyprC+3iJ6qLgqheYLF9Inj7HMmBnwAlOZtjwVRg0F+Foe6SiAxmUE39kQrFeC1YZoG ZAES8eQMp49UL+zySANBxHUrc+j7uUrzHRPD/0CgHx5oRJVpVMSVB6leA7mP4fTu/Ih8 VsuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D3pti5Mj; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22c as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22c.google.com (mail-lf0-x22c.google.com. [2a00:1450:4010:c07::22c]) by mx.google.com with ESMTPS id s20si753148ljd.478.2017.08.23.07.42.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22c as permitted sender) client-ip=2a00:1450:4010:c07::22c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D3pti5Mj; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22c as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22c.google.com with SMTP id l137so1428620lfg.3 for ; Wed, 23 Aug 2017 07:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OVyzB8N1P8QR0uR6qN7uOx0wtf9amaEOf3rrA1CA1zw=; b=D3pti5MjCzB25Uw4O9Du55Nck4nkOulWaFXDLmfaPXTfZj0A6TVUr10zmj6CL71p3K 3KM62TE2zpTJSmvVOjeJ9Q+P2vf6evsC6I16+Ea+GsQW6i4ena5Yfzlbb+LPlP+Un9nZ IiXwkawXlvXGYgroLOnTlcbJi5Jdo8aQxC7yg= 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:in-reply-to :references; bh=OVyzB8N1P8QR0uR6qN7uOx0wtf9amaEOf3rrA1CA1zw=; b=ck4Slgh/22YXBJGWBaHD0EdzAsXTsOKjZPwTGkW9YJO7eKya3OLUSMnWSZ/FRgEwkW /iaoJ+Ml6U6T55YLxsOXJYX/yQ04h6xnV6AoKq/bqbZvxT4ZDWvgn7uoStbyJlbtYvEQ XfNJ1hqRuKSn/LQCbDyhqr9qgTBvmnJHJVd316Rg1ASgO8Vk0cPrasKP1A7ah1/pcMJ0 Py4U5tqm7CXdwmrDgaSud/OiRBoKPEmvNNoZ80dqABthQ8YPnvs/YbVPsY1o2V15t5Nt eyVA+GfbcvDXVT7GSbLZCm3PAfmbQ5cynDxludjsZEV0d3G8W8cgesr88KSCWfhpnvg9 yeeA== X-Gm-Message-State: AHYfb5jot3fUUcTbAW1tydDdorx0YW2Txbu3zlqJv200+J3jWk2JkkMN j2TQx6Ni7N3Qn2H/8CY= X-Received: by 10.25.160.81 with SMTP id j78mr1143956lfe.192.1503499348358; Wed, 23 Aug 2017 07:42:28 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:27 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 8/9] i2c: designware: Don't resume device in the ->complete() callback Date: Wed, 23 Aug 2017 16:42:08 +0200 Message-Id: <1503499329-28834-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> In case the PM core is able to use the direct_complete path during system sleep for the i2c device, the device is runtime resumed in the ->complete() callback. For ACPI platforms this is needed to synchronize the power state of the device, while for non-ACPI platforms this is a waste. To better deal with this, let's drop the ->complete() callback from the i2c-dw-plat driver altogether, thus avoiding the runtime resume of the device. This change still plays well for the ACPI case, because the ACPI PM domain's ->complete() callback, assigned to acpi_subsys_complete(), already deals with runtime resuming the device in case it's needed. Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. --- drivers/i2c/busses/i2c-designware-platdrv.c | 8 -------- 1 file changed, 8 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 441afc7..fc6b99f 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -418,15 +418,8 @@ static int dw_i2c_plat_prepare(struct device *dev) { return pm_runtime_suspended(dev); } - -static void dw_i2c_plat_complete(struct device *dev) -{ - if (dev->power.direct_complete) - pm_request_resume(dev); -} #else #define dw_i2c_plat_prepare NULL -#define dw_i2c_plat_complete NULL #endif #ifdef CONFIG_PM @@ -462,7 +455,6 @@ static int dw_i2c_plat_suspend(struct device *dev) static const struct dev_pm_ops dw_i2c_dev_pm_ops = { .prepare = dw_i2c_plat_prepare, - .complete = dw_i2c_plat_complete, SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_resume, From patchwork Wed Aug 23 14:42:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 110855 Delivered-To: patches@linaro.org Received: by 10.37.128.210 with SMTP id c18csp7031617ybm; Wed, 23 Aug 2017 07:42:30 -0700 (PDT) X-Received: by 10.46.14.25 with SMTP id 25mr1380086ljo.35.1503499350279; Wed, 23 Aug 2017 07:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503499350; cv=none; d=google.com; s=arc-20160816; b=u5OjK6aQznziKx44dXx89PLq2uGtmbVJECJse/VqO0CiULs/7vv6s6h+ZW/UCDJNhm GdGSYkZaALG6hLPF8QrFosgndNCBhLBVoyZXuQb1EKKpQwaPDOb8ndyrFSAkg2Wq9s5K 17p4zj3lYrjkiqE7pCN+n48QaPugH25eBPIKTv4WpJSrEh6CizMEayPJm6TnsZcGfXOr g6q8zuXTSEIaSb5Ks7Ms5+f31c6BQUWPaKOdC+WEAjEWMXQvYUuwTWp6HV4Op5Ch3LiH sFjXWH7jYs3KnRCZWYHlw4xjFptvxepsrB0RNdi3jXaBKbl8EqOn8TZ1D+BFi0V5crZ5 itkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lDIBk2NR58Z+N9ZpbXrSJrmZ7UOKAB/wzTiHNYC4zVk=; b=gEUSo/KpQfpBCoqAqWS/MSB7ZLv1HHtQ3UaTsAuftV0ELL6C+uYPxHlP3ZP8ERpOc+ kmuTl1dt2SSqvDzeBGSqSQts+AStReuOG5qN7JDYs6hrX6ORPFRb0ij0/3wY9QTZFGjd 85iH4XNzhZlHNHFYBmaABCucWvrtELeV4/VzGBuQcFGvKA7UYUpb8oq1M1kHQ+/3kUxy UdTcZoHlnNn9r1l17rHLYT3y4jVl9i0hjYPgDZnL8kao4l0lUpXWRaH/O63tgQnYFp+v s3zKtzFKt8V6NVKqllvaTyT8r+awOE0VBLBy2EhKbl1gFFRa5rsMDONpVyZZVQN8QVqX e4yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ai6rmE0G; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id 3si763365ljv.298.2017.08.23.07.42.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 07:42:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ai6rmE0G; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x229.google.com with SMTP id k186so1477415lfe.2 for ; Wed, 23 Aug 2017 07:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lDIBk2NR58Z+N9ZpbXrSJrmZ7UOKAB/wzTiHNYC4zVk=; b=Ai6rmE0GDUJZyyYfHdMRzCny0jgZX8/RltAQdC+ktGqJ4msDwneXh/j8w/laUg1YWf Y3Uo4ywzczswim9hVcioLIn/Z47UZpEmPtutnHElpXyINa7kVUIMD5eD102Udya28BO8 0nEvu6vc6pjKPSN4DDhHNNzU5NLcruOUc9H34= 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:in-reply-to :references; bh=lDIBk2NR58Z+N9ZpbXrSJrmZ7UOKAB/wzTiHNYC4zVk=; b=oj8vxHDXgZhykX+zbpvLjjesYdMxQqZJA2FnUHZsIt9fqKYJPkajUrAnC3jOO06MOS 2qExaxx6EzMjQJKjt875aV/yB7nlTZlaagyFJZJI+sJETvzfRULfvYZHTO03ewGhokA/ p3jhPdQpF2HSYG8Ww2ZKn3FAxmQOM8HK90EbOYgwUmmC/xjPqPzpiFblVF3QhgT782kN Opva3qS0/4QdEN0EXHNP0bKNnLcRQjH8/fA7boYTvKXJ5WKGZQvCG7BuGLb5X+QFJ3Cy 0Oi1Iv8ZLrJabhREQz9FMk95DyFhwDvweefkSNJ+RvZ9VosXjSeNtl5sUVA4DTlRw+PN +osQ== X-Gm-Message-State: AHYfb5iCeGGb/m2+lUBQYmS+KrKEwvduq23BR6ZCyzIGbDr+xxyvjP0T dlklZwLIm/45C6YDaQY= X-Received: by 10.25.17.218 with SMTP id 87mr1134207lfr.129.1503499349823; Wed, 23 Aug 2017 07:42:29 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:29 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 9/9] i2c: designware: Deploy the runtime PM centric approach for system sleep Date: Wed, 23 Aug 2017 16:42:09 +0200 Message-Id: <1503499329-28834-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> Currently the device is runtime resumed in the i2c-dw-plat driver's ->suspend() callback, which is needed to manage system sleep properly. The particular reason for the runtime resume is because the PM core may unset the direct_complete flag for a parent device, in case its child device are being system suspended before. This leads to that the i2c-dw-plat driver's ->suspend() callback can be invoked when the device is runtime suspended. Runtime resuming the device in this scenario may be unnecessary, in case when the device is already in its proper lower power state for system sleep. This behaviour increases the time it takes to put the device into low power state, but means also a waste of power. Let's fix the behaviour by deploying the runtime PM centric path for system sleep, via assigning the pm_runtime_force_suspend|resume() helpers as the system sleep callbacks for the i2c-dw-plat driver. To deploy this, we must also make sure that the direct_complete path isn't used for the device. Therefore we drop the ->prepare() callback from the i2c-dw-plat driver and we inform the ACPI PM domain to not try out the direct_complete path for the device, as that is the default behaviour for the ACPI PM domain. Along with the runtime PM centric path, we also get some additional improvements of the behaviour during system sleep. More precisely: *) In case the device is/gets runtime resumed before the device_suspend() phase is entered, the PM core doesn't run the direct_complete path for the device during system sleep. During system resume, this lead to that the device will always be brought back to full power when the i2c-dw-plat driver's ->resume() callback is invoked. This may not be necessary, thus increasing the resume time for the device and wasting power. In the runtime PM centric path, the pm_runtime_force_resume() helper takes better care, as it resumes the device only in case it's really needed. Normally this means it can be postponed to be dealt with via regular calls to runtime PM (pm_runtime_get*()) instead. In other words, the device remains in its low power state until someone request a new i2c transfer, whenever that may be. **) In case the device is runtime suspended when the ->prepare() callback is invoked, the direct_complete path is tried by the PM core. If it succeeds, this leads to disabling runtime PM for the device in the device_suspend() phase. That is a problem in cases when others may need the device to be operational, as to be able send i2c transfers during the entire device_suspend() phase. By using the runtime PM centric path, we postpones runtime PM to be disabled for the device by the PM core to the regular device_suspend_late() phase. Signed-off-by: Ulf Hansson --- Changes in v2: - Rebased. - Clarify changelog. --- drivers/i2c/busses/i2c-designware-platdrv.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index fc6b99f..e0cbf5e 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -372,6 +372,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) if (ret) goto exit_probe; + acpi_dev_disable_direct_complete(&pdev->dev); return ret; exit_probe: @@ -387,6 +388,7 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) { struct dw_i2c_dev *dev = platform_get_drvdata(pdev); + acpi_dev_enable_direct_complete(&pdev->dev); pm_runtime_get_sync(&pdev->dev); i2c_del_adapter(&dev->adapter); @@ -413,15 +415,6 @@ static const struct of_device_id dw_i2c_of_match[] = { MODULE_DEVICE_TABLE(of, dw_i2c_of_match); #endif -#ifdef CONFIG_PM_SLEEP -static int dw_i2c_plat_prepare(struct device *dev) -{ - return pm_runtime_suspended(dev); -} -#else -#define dw_i2c_plat_prepare NULL -#endif - #ifdef CONFIG_PM static int dw_i2c_plat_runtime_suspend(struct device *dev) { @@ -434,7 +427,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev) return 0; } -static int dw_i2c_plat_resume(struct device *dev) +static int dw_i2c_plat_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); @@ -445,19 +438,11 @@ static int dw_i2c_plat_resume(struct device *dev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int dw_i2c_plat_suspend(struct device *dev) -{ - pm_runtime_resume(dev); - return dw_i2c_plat_runtime_suspend(dev); -} -#endif - static const struct dev_pm_ops dw_i2c_dev_pm_ops = { - .prepare = dw_i2c_plat_prepare, - SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) + SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, - dw_i2c_plat_resume, + dw_i2c_plat_runtime_resume, NULL) };