From patchwork Tue Nov 3 15:06:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11877945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3101C2D0A3 for ; Tue, 3 Nov 2020 15:08:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70E28221FB for ; Tue, 3 Nov 2020 15:08:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QFHki1Y/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bhgffm5o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70E28221FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g91QR2+8h9T63SdkvdfzyggWws1OtgdQ8fNsDInF9jI=; b=QFHki1Y/1q48LIWHQqPvmAHLJ /Qp6KK5vbq82FtDpQATIPlW2w88b2Qi18isma1udtVFMd4IPH8/E8W8Aig1PhLLt1LLD7n4O7Ow1N tbzweKKR+S0UvrIcakwxm6nXal+Nji8fkF+2UcbNhneaKbCJiDKOn8UgnZ7bL8XguJBTygCSAmmBw Vebp8BY7AAvK75tOWK03Qj4eht0k/+oKVDpYIYieljUsL2mFW+NEya10t8fj42svnsA7g1kqUu9Zb 1Mv6yFaLCSE6c+tU5/T6sCRmpVwuwdWxknGV4u5eVprmN+3aeHweuc8NtY9QXgvMeQjsPNTdd5Gp8 KafwLAmjw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZxtx-0004Mz-At; Tue, 03 Nov 2020 15:07:13 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZxtR-0004D6-Un for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2020 15:06:43 +0000 Received: by mail-lf1-x144.google.com with SMTP id i6so22643621lfd.1 for ; Tue, 03 Nov 2020 07:06:41 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ueiVlvCkRERA4jFBXY1LOeFsJ+G2JGqDIygbStmt2x4=; b=bhgffm5oQBW+6fiSHYCs6cMG+QkEaPHFd8ayqp4qY5zdtYkfBN2A+kFDYhKWnmfXzC j31r1S3NxiL6kuZsmKzUYk3FcmMlgywkkt8fF5kDxv0SV8wOTLMywc9VNNorK9LWJbdY c0jaEBrXboRtNdLTy2dEGzEl5e95vlr7fOWCbiREMddju+X5bn7IIePh1uxU2R01scl5 Vtqvr6G3wMJPKZWQG4Vm6V5zPfQXKqWrs2bMn3vqRN6Xbh6KEfiZXqyBxcpJ08QUjLYt BQhwZ1okgi1J9Cn3QOOVooDMLTvpRiX52jRnjz2T3hlha2XPCUFAsKXH1QyhVIfpEn3o keMA== 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:mime-version:content-transfer-encoding; bh=ueiVlvCkRERA4jFBXY1LOeFsJ+G2JGqDIygbStmt2x4=; b=RxUH25K7QSiY9Dc9zKVCTvJiTmcX2yodWcA/XNMYRsud4kA5Se1JI8oKP8RCa0LDqy 1pQzzm2/BUnSx4Wkd++QUhngkO9G6M+cqJQ8orUTy8VBUXO1kpSxwWjKHd41X6yOUrnl I8JD+ZUrdR2zbSw22BVuur7lkb3eXGqk9yPrEVAc8s9pYLUZy97jPRwkpA4je8d7Ult0 +SdXUr2Doa1N1gXt2toQLg/iymxkjIfc4Ca8mmmXTIM+iBHzq9jVOr9h0QIhbjc2fhvx ZovjI9LyUYcpCyYRxrICjABrr9ZcIVpLsjL3/B8c+iGmT5Qo8Ejwqu1XLCb4NakZWMFn Exig== X-Gm-Message-State: AOAM533NzXGBVNoemQvOSEwCVUPQ1y1YUpAg7r0k9/++Lhy3XAOZXV9C 00QaKMbDCluC3TNQmU3Xotx2ig== X-Google-Smtp-Source: ABdhPJzvL548jIVHWEK3wkLNGd36Uico9ujbUgT1crbH/MUPdlT1HtTLICOjJpYtlqeLXhhVMoqNnQ== X-Received: by 2002:a19:7e85:: with SMTP id z127mr4717457lfc.493.1604415998774; Tue, 03 Nov 2020 07:06:38 -0800 (PST) Received: from localhost.localdomain (h-155-4-131-134.NA.cust.bahnhof.se. [155.4.131.134]) by smtp.gmail.com with ESMTPSA id a25sm3522169lfo.141.2020.11.03.07.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 07:06:36 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 1/3] PM: domains: Rename pm_genpd_syscore_poweroff|poweron() Date: Tue, 3 Nov 2020 16:06:25 +0100 Message-Id: <20201103150627.233438-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201103150627.233438-1-ulf.hansson@linaro.org> References: <20201103150627.233438-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201103_100642_078157_FC57CADB X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Alexandre Torgue , Stephen Boyd , Daniel Lezcano , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Lukasz Luba Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To better describe what the pm_genpd_syscore_poweroff|poweron() functions actually do, let's rename them to dev_pm_genpd_suspend|resume() and update the rather few callers of them accordingly (a couple of clocksource drivers). Moreover, let's take the opportunity to add some documentation of these exported functions, as that is currently missing. Cc: Daniel Lezcano Cc: Thomas Gleixner Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. --- drivers/base/power/domain.c | 35 +++++++++++++++++++++-------------- drivers/clocksource/sh_cmt.c | 8 ++++---- drivers/clocksource/sh_mtu2.c | 4 ++-- drivers/clocksource/sh_tmu.c | 8 ++++---- include/linux/pm_domain.h | 8 ++++---- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 743268996336..9b4881b67683 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1363,14 +1363,7 @@ static void genpd_complete(struct device *dev) genpd_unlock(genpd); } -/** - * genpd_syscore_switch - Switch power during system core suspend or resume. - * @dev: Device that normally is marked as "always on" to switch power for. - * - * This routine may only be called during the system core (syscore) suspend or - * resume phase for devices whose "always on" flags are set. - */ -static void genpd_syscore_switch(struct device *dev, bool suspend) +static void genpd_switch_state(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; @@ -1387,17 +1380,31 @@ static void genpd_syscore_switch(struct device *dev, bool suspend) } } -void pm_genpd_syscore_poweroff(struct device *dev) +/** + * dev_pm_genpd_suspend - Synchronously try to suspend the genpd for @dev + * @dev: The device that is attached to the genpd, that can be suspended. + * + * This routine should typically be called for a device that needs to be + * suspended during the syscore suspend phase. + */ +void dev_pm_genpd_suspend(struct device *dev) { - genpd_syscore_switch(dev, true); + genpd_switch_state(dev, true); } -EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweroff); +EXPORT_SYMBOL_GPL(dev_pm_genpd_suspend); -void pm_genpd_syscore_poweron(struct device *dev) +/** + * dev_pm_genpd_resume - Synchronously try to resume the genpd for @dev + * @dev: The device that is attached to the genpd, which needs to be resumed. + * + * This routine should typically be called for a device that needs to be resumed + * during the syscore resume phase. + */ +void dev_pm_genpd_resume(struct device *dev) { - genpd_syscore_switch(dev, false); + genpd_switch_state(dev, false); } -EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron); +EXPORT_SYMBOL_GPL(dev_pm_genpd_resume); #else /* !CONFIG_PM_SLEEP */ diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 760777458a90..7275d95de435 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -658,7 +658,7 @@ static void sh_cmt_clocksource_suspend(struct clocksource *cs) return; sh_cmt_stop(ch, FLAG_CLOCKSOURCE); - pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); + dev_pm_genpd_suspend(&ch->cmt->pdev->dev); } static void sh_cmt_clocksource_resume(struct clocksource *cs) @@ -668,7 +668,7 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs) if (!ch->cs_enabled) return; - pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); + dev_pm_genpd_resume(&ch->cmt->pdev->dev); sh_cmt_start(ch, FLAG_CLOCKSOURCE); } @@ -760,7 +760,7 @@ static void sh_cmt_clock_event_suspend(struct clock_event_device *ced) { struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); - pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); + dev_pm_genpd_suspend(&ch->cmt->pdev->dev); clk_unprepare(ch->cmt->clk); } @@ -769,7 +769,7 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); clk_prepare(ch->cmt->clk); - pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); + dev_pm_genpd_resume(&ch->cmt->pdev->dev); } static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch, diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index bfccb31e94ad..169a1fccc497 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -297,12 +297,12 @@ static int sh_mtu2_clock_event_set_periodic(struct clock_event_device *ced) static void sh_mtu2_clock_event_suspend(struct clock_event_device *ced) { - pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); + dev_pm_genpd_suspend(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); } static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) { - pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); + dev_pm_genpd_resume(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); } static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index d41df9ba3725..b00dec0655cb 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -292,7 +292,7 @@ static void sh_tmu_clocksource_suspend(struct clocksource *cs) if (--ch->enable_count == 0) { __sh_tmu_disable(ch); - pm_genpd_syscore_poweroff(&ch->tmu->pdev->dev); + dev_pm_genpd_suspend(&ch->tmu->pdev->dev); } } @@ -304,7 +304,7 @@ static void sh_tmu_clocksource_resume(struct clocksource *cs) return; if (ch->enable_count++ == 0) { - pm_genpd_syscore_poweron(&ch->tmu->pdev->dev); + dev_pm_genpd_resume(&ch->tmu->pdev->dev); __sh_tmu_enable(ch); } } @@ -394,12 +394,12 @@ static int sh_tmu_clock_event_next(unsigned long delta, static void sh_tmu_clock_event_suspend(struct clock_event_device *ced) { - pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->tmu->pdev->dev); + dev_pm_genpd_suspend(&ced_to_sh_tmu(ced)->tmu->pdev->dev); } static void sh_tmu_clock_event_resume(struct clock_event_device *ced) { - pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->tmu->pdev->dev); + dev_pm_genpd_resume(&ced_to_sh_tmu(ced)->tmu->pdev->dev); } static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 1ad0ec481416..a8f93328daec 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -280,11 +280,11 @@ static inline int dev_pm_genpd_remove_notifier(struct device *dev) #endif #ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP -void pm_genpd_syscore_poweroff(struct device *dev); -void pm_genpd_syscore_poweron(struct device *dev); +void dev_pm_genpd_suspend(struct device *dev); +void dev_pm_genpd_resume(struct device *dev); #else -static inline void pm_genpd_syscore_poweroff(struct device *dev) {} -static inline void pm_genpd_syscore_poweron(struct device *dev) {} +static inline void dev_pm_genpd_suspend(struct device *dev) {} +static inline void dev_pm_genpd_resume(struct device *dev) {} #endif /* OF PM domain providers */ From patchwork Tue Nov 3 15:06:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11877941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAE1FC388F7 for ; Tue, 3 Nov 2020 15:07:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23D2F221FB for ; Tue, 3 Nov 2020 15:07:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="M/rnJ/Ma"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aKENhJfJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23D2F221FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ru5vqkgeH11z48Kh/3zXug8ykKy8I62Ezw0iwNyV0Cc=; b=M/rnJ/MaCAcsOaSoPQ5eCd+Dw Ca9GVvoyi9XcjlgfSGvuhYgIHACz2DN3qGGJcC3RPrUDumGxo9Co8MkDmMw50Tt7azjnHX78Z41+l 11+r6wOLdPpIb0I+iqQDx64LxmJb859pmuQAd6ZyweyvdgucxO+F/6cFuJBI6c3q0rC0tbkoqx+cp rFb1LxlTeeZ218kChoDLOq5+cRW4zI2BzQSpUiCvMV9KYMzfu/ufQsAtRSkiybc+tzG0PTa5VmjGW 0AyV/aFSAlHPOxS/cJPa0pZ07akMuuvTZ+okNZ2R442+hzkyJhPOQRdX6UYHU3Di/zmnGzA7E/eBp e8txZXcGg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZxtk-0004IR-5Q; Tue, 03 Nov 2020 15:07:00 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZxtR-0004D8-P8 for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2020 15:06:42 +0000 Received: by mail-lj1-x243.google.com with SMTP id m16so19407340ljo.6 for ; Tue, 03 Nov 2020 07:06:41 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Kdoh+vwsEl16Yv/ER7Hhev3sO3MvjrueZiYq3HqyYgg=; b=aKENhJfJOgbz3Z80D8/HTRaDGis97wYnQ7c6Vk5LMIdkp8+btBMJV85vwFmdaGqtZF vFuuCdmCgskoX9lAVsxq/VPlWhlkNHoVsfpTfzgaX/qylT3wlmo/wmvTOWqjEWXQOGZO C+Ym+Aa5KsYsi+XPAU2q7FVpk4MUL/mqpaSCcABHwobDjgiiAY54kWsCwAUjl4rel6LN 5a4j7hHlgD8opdaOnLOipRT3Dm36PXH1KvC08Ht+19WwE4t76ZeMwJAE2gz715MYk9z+ FP8b0XmmZLYrVI7AvWawpeKptZfmj1Tj2VAjFaFRJ9z4rLGSuwc7VB8er4C12yb2fg9Y lREg== 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:mime-version:content-transfer-encoding; bh=Kdoh+vwsEl16Yv/ER7Hhev3sO3MvjrueZiYq3HqyYgg=; b=hII4p8lXUIlHZlv+jSslQ3TNGpwJrFGEq1cLAeQRVh5SRHs1WmXblyqNNPfCtiFOC3 8NhKjisgj/xDriSVv/mABstylpWX/kicBPvZabtO0mB5GGmZz6wMNNdvq70ahHSCp9tM vIUy3gjE7F8GXeARokfa257YPVWXfuiuDCfkq7IEemlbCj9xVujcFRc8hWzRiNhUpjBg 12bnhhSPvuENsNkarbrIW9e7Tt9Zrw1cANEjdC6ccXd/LPI1zZLLxVqi3cQyQOh7oUkT OqO/nzlMOEGp9jxm1zqr0ekrehGVzniAHP0569jtHa1y/I3KUdNJtTUXwVROsPya9tDf 9gtQ== X-Gm-Message-State: AOAM5336eiyABqRmI8cz38URIcvcn+ASam2vIw5Zr/0IT+9JQQPHcPoG 29xr0IVsFglEJ91fYKYwelPccQ== X-Google-Smtp-Source: ABdhPJxL5L/dqtMLU8eglrRK4+pkCsIeAA+kIcRq8/oJXsL1Sx/dg6nEod+1dvGOt0AnvFCnoqtwgg== X-Received: by 2002:a2e:7c17:: with SMTP id x23mr9593284ljc.366.1604416000443; Tue, 03 Nov 2020 07:06:40 -0800 (PST) Received: from localhost.localdomain (h-155-4-131-134.NA.cust.bahnhof.se. [155.4.131.134]) by smtp.gmail.com with ESMTPSA id a25sm3522169lfo.141.2020.11.03.07.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 07:06:39 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 2/3] PM: domains: Enable dev_pm_genpd_suspend|resume() for suspend-to-idle Date: Tue, 3 Nov 2020 16:06:26 +0100 Message-Id: <20201103150627.233438-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201103150627.233438-1-ulf.hansson@linaro.org> References: <20201103150627.233438-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201103_100641_862412_B8AC5723 X-CRM114-Status: GOOD ( 17.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Alexandre Torgue , Stephen Boyd , Daniel Lezcano , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Lukasz Luba Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The dev_pm_genpd_suspend|resume() have so far only been used during the syscore suspend/resume phases. However, during suspend-to-idle, where the syscore phases doesn't exist, similar operations are sometimes needed. An existing example are the timekeeping_suspend|resume() functions, which are being called both through a registered syscore ops during the syscore phases, but also as regular functions calls from cpuidle (via tick_freeze()) during suspend-to-idle. For similar reasons, let's enable the dev_pm_genpd_suspend|resume() APIs to be re-used for corresponding CPU devices that are attached to a genpd, during suspend-to-idle. Signed-off-by: Ulf Hansson --- Changes in v2: - Renamed and add documentation of the APIs. - Updated the commit message and its header. --- drivers/base/power/domain.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 9b4881b67683..4a55f3c949ae 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1366,18 +1366,27 @@ static void genpd_complete(struct device *dev) static void genpd_switch_state(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; + bool use_lock; genpd = dev_to_genpd_safe(dev); if (!genpd) return; + use_lock = genpd_is_irq_safe(genpd); + + if (use_lock) + genpd_lock(genpd); + if (suspend) { genpd->suspended_count++; - genpd_sync_power_off(genpd, false, 0); + genpd_sync_power_off(genpd, use_lock, 0); } else { - genpd_sync_power_on(genpd, false, 0); + genpd_sync_power_on(genpd, use_lock, 0); genpd->suspended_count--; } + + if (use_lock) + genpd_unlock(genpd); } /** @@ -1385,7 +1394,9 @@ static void genpd_switch_state(struct device *dev, bool suspend) * @dev: The device that is attached to the genpd, that can be suspended. * * This routine should typically be called for a device that needs to be - * suspended during the syscore suspend phase. + * suspended during the syscore suspend phase. It may also be called during + * suspend-to-idle to suspend a corresponding CPU device that is attached to a + * genpd. */ void dev_pm_genpd_suspend(struct device *dev) { @@ -1398,7 +1409,8 @@ EXPORT_SYMBOL_GPL(dev_pm_genpd_suspend); * @dev: The device that is attached to the genpd, which needs to be resumed. * * This routine should typically be called for a device that needs to be resumed - * during the syscore resume phase. + * during the syscore resume phase. It may also be called during suspend-to-idle + * to resume a corresponding CPU device that is attached to a genpd. */ void dev_pm_genpd_resume(struct device *dev) {