From patchwork Mon Oct 30 13:22:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 159736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2208630vqb; Mon, 30 Oct 2023 06:23:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFB6v1aj/AFiVMQWp3E6ag84qGDMxFO1Lffk0grQyIr9zKvenDDUJI0x3zv+Psivo7OMnfm X-Received: by 2002:a05:6300:8083:b0:16b:d137:dfb3 with SMTP id ap3-20020a056300808300b0016bd137dfb3mr12574541pzc.59.1698672223074; Mon, 30 Oct 2023 06:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698672223; cv=none; d=google.com; s=arc-20160816; b=0QxTNsVHLJmuPdwt4nMtCAgqm3pX5pIvINEZMIQJ6xc7FA5edTabTmMXLV1z6zkYdJ azHkGBDyknGqjuE9yn4ApN8iwHkAnY4P/I5yoZBJTip9DSC3NSQnJz7A1xmVCSFaBJed fRZUWTgcAC9/5BLtPxmBjhbrofPsQlv+TA2TWv23wmlSQJC75EhCByj8swZYYvex476G xLWDcdDEaJ6vD7j23LgZ6Ft4UVEyaWcO3BjGyozrIkxaYpyQA2ZcfDcCIvpHVrNeIN16 Yl+kfDjXFUKiAOf8azZGRdyLn4AaXJph846JNqnf683qvjc5yf+V8aX+KvzxinvKPyfl hOaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=shcKmizxUENtP1Ih2Lsio0RlYzOJFfGzfA5YRFNBKz8=; fh=tAWvjMAEmVD3R8FzmIRYzQIb+yW9J+gWZJ2R8deHkVw=; b=xadpp1nXqTXuIHEmbAG/Rd+g/Jrou5lkh5wM6rDd8ULEgPFUafp0//HvnMAie+bx7S 77oLb9cGePNXSH7l6EOAAJGJC8vAw9LI4gUIT4tFLU+wQ34GmtZc2LP9C/cwc/4tRYT5 I8VsZgkSTcfVDtfX53OH45O/mQh8xm0M8UDFGwBsW4SKo/WTmOTPmSHGlllZFUHAu3p3 hSVKMeYqQXOieSR9sgVcW2UoUCVkAVQM6TczCHutBhBgGSCLdM9CY7H88xH4hTjJMbwC SzvzB2Ez1rjD2vj8BpOUoMyZzSEFCMvyRrtC0vswLBtuNAZg6wVDk8B0bldUds9wJtgp SLdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ayouEfh8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b00578a28df3e2si3033262pgb.816.2023.10.30.06.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:23:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ayouEfh8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A93AE80621D7; Mon, 30 Oct 2023 06:23:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233400AbjJ3NXR (ORCPT + 31 others); Mon, 30 Oct 2023 09:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233384AbjJ3NXL (ORCPT ); Mon, 30 Oct 2023 09:23:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A996BD6 for ; Mon, 30 Oct 2023 06:23:08 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id CC49E6607388; Mon, 30 Oct 2023 13:23:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698672187; bh=3dUd841wLvR/syQt4DasoXOByTVGgSmSqikDkfeYRv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ayouEfh8u3VjZQoJfUNqaL1sbnU0XUvwScA51bRYXidoKUIU/WrrDyTxp2rZzk/LP Lz6bliSbO/x++VGiLXTCQ6ZzPXf3YDlOvkarhJwtIUppx4ey32GL7oOqNi1TOMzNXD xdnxo2z4Eufu3n2Vcn8p63HOxr1zZPjlw6FbbLFRgPQno90w/DyNpCW2rTf5mBCj6p 8jRURbNTgJPcaYq7LiGcCknoQgGcfBP5X46xsGHN32maWsaCVY03uaeyKsHbG/vaRu B3u2Kt3FUjSW/1Bt6Ab9yNw984J1Psqv1J9ea8BC6R50iiYkFSkgYFaKqef0zf1OWs IUzLvoG0fQ7Rg== From: AngeloGioacchino Del Regno To: boris.brezillon@collabora.com Cc: robh@kernel.org, steven.price@arm.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, wenst@chromium.org, AngeloGioacchino Del Regno , kernel@collabora.com Subject: [PATCH 3/4] drm/panfrost: Implement ability to turn on/off regulators in suspend Date: Mon, 30 Oct 2023 14:22:56 +0100 Message-ID: <20231030132257.85379-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030132257.85379-1-angelogioacchino.delregno@collabora.com> References: <20231030132257.85379-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 30 Oct 2023 06:23:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781186924786363744 X-GMAIL-MSGID: 1781186924786363744 Some platforms/SoCs can power off the GPU entirely by completely cutting off power, greatly enhancing battery time during system suspend: add a new pm_feature GPU_PM_VREG_OFF to allow turning off the GPU regulators during full suspend only on selected platforms. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/panfrost/panfrost_device.c | 19 ++++++++++++++++++- drivers/gpu/drm/panfrost/panfrost_device.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 2022ed76a620..51b22eb0971d 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -431,10 +431,21 @@ static int panfrost_device_resume(struct device *dev) struct panfrost_device *pfdev = dev_get_drvdata(dev); int ret; + if (pfdev->comp->pm_features & BIT(GPU_PM_VREG_OFF)) { + unsigned long freq = pfdev->pfdevfreq.fast_rate; + struct dev_pm_opp *opp; + + opp = dev_pm_opp_find_freq_ceil(dev, &freq); + if (IS_ERR(opp)) + return PTR_ERR(opp); + dev_pm_opp_put(opp); + dev_pm_opp_set_opp(dev, opp); + } + if (pfdev->comp->pm_features & BIT(GPU_PM_CLK_DIS)) { ret = clk_enable(pfdev->clock); if (ret) - return ret; + goto err_clk; if (pfdev->bus_clock) { ret = clk_enable(pfdev->bus_clock); @@ -455,6 +466,9 @@ static int panfrost_device_resume(struct device *dev) err_bus_clk: if (pfdev->comp->pm_features & BIT(GPU_PM_CLK_DIS)) clk_disable(pfdev->clock); +err_clk: + if (pfdev->comp->pm_features & BIT(GPU_PM_VREG_OFF)) + dev_pm_opp_set_opp(dev, NULL); return ret; } @@ -474,6 +488,9 @@ static int panfrost_device_suspend(struct device *dev) clk_disable(pfdev->bus_clock); } + if (pfdev->comp->pm_features & BIT(GPU_PM_VREG_OFF)) + dev_pm_opp_set_opp(dev, NULL); + return 0; } diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index d7f179eb8ea3..0fc558db6bfd 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -28,9 +28,11 @@ struct panfrost_perfcnt; /** * enum panfrost_gpu_pm - Supported kernel power management features * @GPU_PM_CLK_DIS: Allow disabling clocks during system suspend + * @GPU_PM_VREG_OFF: Allow turning off regulators during system suspend */ enum panfrost_gpu_pm { GPU_PM_CLK_DIS, + GPU_PM_VREG_OFF, }; struct panfrost_features {