From patchwork Tue Oct 3 07:11: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: 114667 Delivered-To: patches@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1552804qgn; Tue, 3 Oct 2017 00:11:21 -0700 (PDT) X-Received: by 10.46.31.17 with SMTP id f17mr2502517ljf.102.1507014680973; Tue, 03 Oct 2017 00:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507014680; cv=none; d=google.com; s=arc-20160816; b=qjIy0KjaOO/ODPctP50dpsLBcxYyGwBYzGvwiKjXi6YNNjr6dKgPtIH5KnDUtBijDH NW90tt2lDF/A8eQmo3+SYWfLtLRPzoXGOcTYoIu1yhzuzLDIRVcu2RXQLofF7RYPsBBo FUsqnllR0dZTGqxa9G4RTQXwwSVI+5yB5Fu3yfWT75GynIA1Z8iPFHQRNAThhvpXcp18 IzeeyVea+kPrwWUJGJDmgMieITv1D5WD6EivS1hZxI7Ep/0FEC54PGGFc+DqDYVdPS42 u4c0n0raf1vLoDNPWqX18+cxEbN6eTu0KjbD7Do3KDL9/dqQhwgKIeBxwrRCQyUwDMuN s2rQ== 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=7/Ou5jvJLbGAZcm2TFdgdYXlrcHEFB/3t5Dk+B/DuAc=; b=YmRDZ7kSXhdn0MJQD148EugE5bIawiCaxuPB6pmfDx+xFL5cAaUJXHINYf+jKLwLK4 /+Imtr2rNPTJxsjG6Wez4ntqNamwcfgov3ZSZDF9y51Pz9VByjiaeiE1dX9DWfLdAFQk NCu8iS1fNBjYrfJ/CC8hDeO17CIWrJcZ+Ffpb37ysfYZdDI4rQ31rt7jxvVl12BYWrup SNLxJRJ8AyXr6WUT5iWVzx+8xSihdXsZD0xmqd5VEzi/RPTROJ4WMCRwyZU4a3NflW9g Ibx6Myhp+z2p3cTCOvF+i55lG7WCUjs1KlEVIRIbwYKr36HtgnOSU8C8+tCvi5KRuqO1 nY6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3kHgv5N; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id q7sor1816798lfq.42.2017.10.03.00.11.20 for (Google Transport Security); Tue, 03 Oct 2017 00:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3kHgv5N; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=7/Ou5jvJLbGAZcm2TFdgdYXlrcHEFB/3t5Dk+B/DuAc=; b=d3kHgv5Nn0gCQI65sPpJFFohR9oy4v0O4CypDbsPHubwDI8041upNfYW0Qn5zRNpgL EY+WczKkJIKtnJX5izkVQwhdZLMiu/fNk5RftVR4DjpgSYdE45Bzo7KB+FINVPmKHLnj Pg+KorSEll4ZNUJYY/E3C5ZpP0Y4fO05loFD8= 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=7/Ou5jvJLbGAZcm2TFdgdYXlrcHEFB/3t5Dk+B/DuAc=; b=s1oKij+F+PBsDudSGT2lPqWy0uWvbrmabvcYaNNGGug8QNUqid2tZGdOSPnkWV+gC1 iqZCPE2LpTY9m8MY8o8xiCK0VKRRGrqXWe3aeAgyd8di2TpbqoN4AUkzmaTqC66LOhhV gZDnZ10LiT0fTgZElA3P1ILmFPv6ea3WZJ/FbkQ2FQjvVjyh2lz2ZjoLaYHLVD2UIwPn B+vAsohkwEveJXkzyRgaItu8hp/GbpKlMjUKKfSgvNEDwaLqKfTb6roXi07hVCeJ9pj5 Qq6rZ5U09pyncczXkiEIUJZ6MjfsKTte9gRRGbyoisb5FMBadOHGkskxXCk1ilDQvS2v WY0A== X-Gm-Message-State: AMCzsaV0uVSl0NHUn0TtyC7cT92dsZEj4dU4Df8a+4ClJAFhwe/gCQKY XuOkEiUQaUZBnfGDfiz2NHw+RL2l X-Google-Smtp-Source: AOwi7QD6+6Nzy+1jGeKnLNABNPuueThpP63emMynTXAFWgBOp8VY5UmPdsF5gnOmIcTDyWp4OMzNfQ== X-Received: by 10.25.104.22 with SMTP id d22mr5295464lfc.41.1507014680609; Tue, 03 Oct 2017 00:11: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 x13sm2764497ljb.23.2017.10.03.00.11.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 00:11:19 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Subject: [PATCH 1/4] PM / ACPI: Restore acpi_subsys_complete() Date: Tue, 3 Oct 2017 09:11:06 +0200 Message-Id: <1507014669-1502-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507014669-1502-1-git-send-email-ulf.hansson@linaro.org> References: <1507014669-1502-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 --- 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 Tue Oct 3 07:11: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: 114668 Delivered-To: patches@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1552825qgn; Tue, 3 Oct 2017 00:11:22 -0700 (PDT) X-Received: by 10.46.9.80 with SMTP id 77mr8333370ljj.54.1507014682168; Tue, 03 Oct 2017 00:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507014682; cv=none; d=google.com; s=arc-20160816; b=qHLaTMdq/CgUgV0UhDf20chh4by+W5zpV9mvZ0LImRgjLLiyJcntEBudjdIiw9QIUP c2zMA4bWFlL1c+XJvU6h41rGAuyqiRxyhhuUi3ATJRQRkQU8Rf6E1rUbhB8ek3CT/4hC DNQdbhN9XA3503Vk0hqt6/0HCWM8huVahVxq3TZo9XG+Xto7Z2THh64Rwpq3OCbJM7bJ yE53W0w99aXpyFQGJLO3Ac+3LZj+J3wPjyHdlPv5wjv+C6wuwJEJJk7hfNTsGRdAphUw ULW8JBUNIdAbv048rAEQDP9cNdK9mpTcsxN3tcl67T4M7jS/a+5ShCFsYEh7443urnHq TgVA== 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=iqv9kBCSzA1A+6P8VBA/P0yTMVdNQ7u2KuKUSyBmKOw=; b=SmJ6GBwxKpsCnXdNI0xy+iDsKo8gVrLna48Ffy6JABki5oAFpx62WSTtoTsgLNGzoA ulki0Hw6QkqrW+0Dd1Oowi/zCCuQ5xClIcTs24SaVuY3jomgMt5bHIaahN18Gi8fDI1P 75p6791YwLJp+bHu59zUkhQ9BkO/si3thrneIiH9LbYgQ7PLeBoNZ3w5FSYa3XexH/+4 iz8NVpI7yxkhJ+Kg+18xZKKlAuc3og7Gktw/iyyPootJENWstqvC5jrEHJe7LisUE8sa C2DhuDP72HzKW2DJBY1M5b7175bmyIFBCwyjO8pED3x328KywDPkg4tcDF+5H4hPkzZ5 woZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=US4pP1QZ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id o193sor1800776lfo.96.2017.10.03.00.11.22 for (Google Transport Security); Tue, 03 Oct 2017 00:11:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=US4pP1QZ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=iqv9kBCSzA1A+6P8VBA/P0yTMVdNQ7u2KuKUSyBmKOw=; b=US4pP1QZwjybzQEF2U8E7sx71aVAYA2Rl7Z7WNF6Yst9Dt7kWf3JUZr+pkgu5ZV3Jn FndKredbTDLYnXtzsxTDznK4Q3K5EvdhSMfv6/nNjLHTW9T7VAE660tXNpMy3RFCUw8r kEyJ8a4PDZ2c5f3lhkXprC8ceD13gq982I7zU= 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=iqv9kBCSzA1A+6P8VBA/P0yTMVdNQ7u2KuKUSyBmKOw=; b=b01QVNa/pxl+8bxLpivHZBkMnH2N4mn8omFJtfBq4IETasFfbt15fFieJtXv0TBHee wyxXR1yk6z0K5hhuKZinwMczuvwZDqBAJskR/P2Sn4qmjD0mmptqHap9gCTo+9C/q9NS BJMBc7HGavGGD3vRv3AZRHMVBzSNuhSDj895gWlzeGxtNS6400e5qTeHWSf8fjSsbyXz aMtoad6twIRyo7YjkcxJFbcEWQOBRfxA1UXnEwBIA/jrZU1kASP1QeIPC9efQU6e1hXy RPel5hM61JKkr+y5UQUd2X7H7//OVnmtmHbHBTh4DaSeFtb9wIQ5MhM5XewfiqMSDGFq GEPw== X-Gm-Message-State: AMCzsaXEbfLn3coFFNK0xq+l9822U0L+ce1zz5AGrjmTDg2jdpZl0pjD AoooDRZJlWye0u5ugud62fMuCHMi X-Google-Smtp-Source: AOwi7QDygXbJLYEvklaidIaVmyQaOqH6SjEXF7TxmVLSWAKWRp6cPcOnwvv400sD9RNicz3QP/ojzQ== X-Received: by 10.25.40.193 with SMTP id o184mr4741561lfo.136.1507014681829; Tue, 03 Oct 2017 00:11:21 -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 x13sm2764497ljb.23.2017.10.03.00.11.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 00:11:21 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Subject: [PATCH 2/4] PM / Sleep: Remove pm_complete_with_resume_check() Date: Tue, 3 Oct 2017 09:11:07 +0200 Message-Id: <1507014669-1502-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507014669-1502-1-git-send-email-ulf.hansson@linaro.org> References: <1507014669-1502-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 --- 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 Tue Oct 3 07:11: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: 114669 Delivered-To: patches@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1552840qgn; Tue, 3 Oct 2017 00:11:23 -0700 (PDT) X-Received: by 10.46.42.3 with SMTP id q3mr7686634ljq.191.1507014683417; Tue, 03 Oct 2017 00:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507014683; cv=none; d=google.com; s=arc-20160816; b=NDvDGcZT1nE4bTRpvEqGAg5I9Fn+BF6OeuOmj/nHS26cKU+dVPsaBGkHR09QvwQvCT ex0FY9NiQBWIrFHSEZ3QpovjkHKSdKfaZhrCy3IZ97Afyfzsch9drQBvS2T1Rdqjm0gy Cpx5ycnkjcXk+ysDegBCpIKOnD2+CLs58o6GS2RutXNyGmQQKqtVCwywW/Mvn8NnFnxV t4/HsD7s95S9Nh5qypE5FqyMLrU6FBzPXEB5Cb6nHQM6LAJPcmJI8dnuhAIUlwUWHXlH rJPMOkSE6/dmhBaeySeEDDalK9mauQd6sJx1NN6Cr80uS+XwQRDCyd0ehwImhHnTwWk8 YrXQ== 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=b/5PXwmf1jNxWtUEybtkUD/Hn5S35dwcZ4666wjykUU=; b=U1Zo6P/mNZrhmP9auZammEcy0n9CQ+httXM3kd3q0FFvh7mwJBwVFPX4b18yUgAH3Q 7Nqpo6IHuBHVNqgdhqt/Lh3pqiaBseOAY9PTrsVkTvgytwDo4vNQe3yAC6c0cwXkcfZ3 6aHO9S+PzGP00YaWTDvnLoJN8PA/NhbXPrRbVCpMJudT/q6Bm7JoOXKeuwmqmRdxfIax 4fikMbL4GW3C6DGoG58Igsdtz5cDRKYwXRGlkJVO1i7HIedeIlumNovbtBFWi2M3Y/LQ 32lPhtF8lxHX2p5/+XxT5ZbXfAZmb54JpTKiB7gIHX6H42+7gO9lZIchzVrLvBvyxb4K lKXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AbwxFldD; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id t17sor1809631lfi.74.2017.10.03.00.11.23 for (Google Transport Security); Tue, 03 Oct 2017 00:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AbwxFldD; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=b/5PXwmf1jNxWtUEybtkUD/Hn5S35dwcZ4666wjykUU=; b=AbwxFldDb+IfNuZ+NjEvbN/DrM0z9ZBO5bklgTotH5o19TAt/rhp+9Rh9Z7Pr44mPP bPaRnJedWarSYoeF9O0Rf82dt7Oz2aJtErmc4Vk5vqxhzzhj5RAILZBHXS1idgVFz9mo YtTcLQf0ML3WqZghvNC34jpAh2XERMYJefDxc= 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=b/5PXwmf1jNxWtUEybtkUD/Hn5S35dwcZ4666wjykUU=; b=m3DCNF8F0COskJZz0CXGzH7UCisiqyCvQ8Z6z/uGz7vGIPTs8QJd4NgbKozqqJQRIq wa3FTLGH/Pquhl7ycXhKCIQddALOGFfdzEuXsC8WQD9DVxpFkUsKv2qvWHgvVZMiaeTH wc2emcS986COAG58WyOqRvUJlAVdge7VMwRHdDu85JDGHCzrCB4thv/EMI87DFvSOtUn 8klU5ru3B683PJp3oVxlGaPLF/MN3IfB28yqiZpTjmyhg5fQhBb0TUk6vBzjkgEwa/w1 6xswq6W1B/Dal1vAcAvCGaw9L3tarsmQZ+29I8u9dgi7DocgiH94DW4wl3DkNK81C6X1 K89A== X-Gm-Message-State: AMCzsaVs0PdzzNm+h4HoFc505yWcQ8x0jFgqkKm+6HsJrQXxxkhkz8Gq 95DrSTKqEgsNcsAfY1lW2HzEnv+1 X-Google-Smtp-Source: AOwi7QCVP5tChGw2NpXCsB/cR3h2sB4tUoiw6Db/opEn0ur73lb63MK0skn76JzyxUhb0UjKF7wocw== X-Received: by 10.25.27.71 with SMTP id b68mr5677462lfb.125.1507014683080; Tue, 03 Oct 2017 00:11: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 x13sm2764497ljb.23.2017.10.03.00.11.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 00:11:22 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Subject: [PATCH 3/4] PM / ACPI: Split code validating need for runtime resume in ->prepare() Date: Tue, 3 Oct 2017 09:11:08 +0200 Message-Id: <1507014669-1502-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507014669-1502-1-git-send-email-ulf.hansson@linaro.org> References: <1507014669-1502-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 --- 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 Tue Oct 3 07:11: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: 114670 Delivered-To: patches@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1552854qgn; Tue, 3 Oct 2017 00:11:24 -0700 (PDT) X-Received: by 10.25.115.137 with SMTP id h9mr456403lfk.230.1507014684753; Tue, 03 Oct 2017 00:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507014684; cv=none; d=google.com; s=arc-20160816; b=tt5BMqjiy6+JWNzNvCIAaIPU4vioIhEcI41hiMniGe4IgSre2aOiBGO9RsPDfzPj+5 cT+oj9lkc9AQDzfLmXMfT8ym+5+egdJNuGwxUqH0EJqj8SDuU+l1ecfaSTnekS1tdZZt MIYRu9lJVj/mmBy/or6dDam9cQQ4LTqYFAsDON/OoyUPmefpIU0XE5ZcV6GKsjITpXzV ZTdV4E/MXSEW8py459N+ek22UFhEHR7y2iTv8BBY+so42OoT4z5ecBBtIgpiOiIHykXJ 5bqvZSBDq3VTLRcstgxvvW0saCVu7ffOhy9WIKUFJ+0L85aiSrmLO8EOeBURuEJNwT8r w43A== 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=i9LTPr3NQP6LXkf5acmqRvL/6PLCvp3g7LDHFKZztS8=; b=C4LMrekX5phJ7PuzlnAepVo8B0R2J8m54UqvrV/oal9ioNfzWJ3QhmIxP2yaXpNWVS J9/3CvJwXeqpCWcPwxdr1Y0GsHSfWxdlZRDefhRbz5QzUB7kZEY2SFvXh8LH3vn8zq9O XBvFuwoR6pCopFjdCUa5aHhsf/PDF+7ubohc//7cidAkcnw1pxm+qaR99Adhul8868tA X2dN8LhVB6WdZk37xSl0flUzo4sYZgWeZC93H3dYpxoEvk9mKf9eOrUkU6bxC8nZgDSv R7CVrwwQ9iKJVggKevnjrnXsIwm496M1KJW8wQ0Qlp9FoLuzXW7xh2aGzQIUff7Oqei+ 8Gew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Skkvt44F; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 63sor1847445lfr.66.2017.10.03.00.11.24 for (Google Transport Security); Tue, 03 Oct 2017 00:11:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Skkvt44F; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=i9LTPr3NQP6LXkf5acmqRvL/6PLCvp3g7LDHFKZztS8=; b=Skkvt44FG9DdSGr4QSidD9nCkqLB1CFZWMCsbOjbxQhOhNpK6udll017Nefps0gAqS VnTBVNgQW5nE4fa54XMSqu+trEIC+TG1iG+fbSBzkKwdESzR5G9iVpqXLAPGWH5+aWbc v8IH7z8ZmqIm3ZpYleOcWon2+UPJFDmmH0OpY= 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=i9LTPr3NQP6LXkf5acmqRvL/6PLCvp3g7LDHFKZztS8=; b=W5UK12bYtcEaNt2f6dZoS2NJZMbKCcWqF1gnPWkdR/sipbFlIvsYqksLVLC1EYfbYP 454XOMm4ggNB2Ev6FVkXbxdfVsrquHkwyXTxwDOCY3N1LCsy/OGnDSeq9sEMkPlRlM8p EOg6g/rWpfFXIwXYNK8o0giba7E1DzCsvPbpaVVwKvO0ESmyc9wLvKRFe4sHuHmIf79c tEQ+Sxon+hhHHKYqgUlEEk7flm/M+Ne8UsllK5WHPbUTqjk89Qkt7OIc+IqU2/O9/1ET F3gUVqrzowkpGB5wzG8xappe1d8yEQLq9qV/zTUOEdV3UHy32e5uXsyPcjAuQOWOTOUA 5o2g== X-Gm-Message-State: AMCzsaUdi/k7qbz/8fTViyEsIektS3NvlAy5oQwtqOozx/cXArZ9Uw7S r4IeCD/8V66T1B00FhUvHxC0UFWd X-Google-Smtp-Source: AOwi7QB282XjNqqwVFdIF4iAnD1h3qIlNyS4PahGjRRSBLBNOsfPNiddw//BzJutEZZTileTZsqJ6g== X-Received: by 10.25.56.80 with SMTP id d16mr5185690lfj.157.1507014684410; Tue, 03 Oct 2017 00:11:24 -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 x13sm2764497ljb.23.2017.10.03.00.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 00:11:23 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Subject: [PATCH 4/4] PM / ACPI: Split acpi_lpss_suspend_late|resume_early() Date: Tue, 3 Oct 2017 09:11:09 +0200 Message-Id: <1507014669-1502-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507014669-1502-1-git-send-email-ulf.hansson@linaro.org> References: <1507014669-1502-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 --- 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 */