Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4047175ima; Mon, 4 Feb 2019 09:19:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IaKST9haeOQkDpJFYJaOsK8VT7q9soPjM0+bsTlNZIM4O49tsrB/Gw8fkqBdoI7zZXmBTc9 X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr411165plk.291.1549300762276; Mon, 04 Feb 2019 09:19:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549300762; cv=none; d=google.com; s=arc-20160816; b=koGgUn4LqtefH64cNDx1JPcDHeD71x9T9jVWhqD/MXPqxEOOdGpWaaSLYD83IoOqgW VAl2hfzjIebn7ADQWl5OfOrepKzvvRKc42qzmK1SBrNVY8e/6cPRbD2KOTQvedDujwKA MGy32+4FADhdwgJ9c2u19dgiRyCsFd7hS7oBifkcqC3r/5778KlIJmMO57A/y1cahWvd nxgNHcZyiNFMwXnTMCxG1mzrgtv7rTKHBd80FkWp7UZZK9sZ59dN5gy7SK15ybsp+QID zwUAXCOnKO9kMR6jXMIDKKkUEMKRL0uD9TUnjNYdYt5z5/K5yhzfu/ZzlFuQL1n8zvVM TtXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature; bh=jPtPBsBInw97zTRFklH4SUCzcPAfuPn6IHr0M6TkkTE=; b=uc+y1qD6Mxu4huE8pBiH2Ho2tk5cC3ktm5VfouL4fOWcs/P6KFUew5ppNyFBCa59v3 YrRs2kYNboPyoQy8FpsTDJfw24mQh9CaibB1KQ5C9gzfZWZBRNfXyBKwORqWayf2dGlQ qrxAmBr1MJoBzQ9ImTmjskoFlsPpybCPorlr+t5K0XLe7M+YtEin9bPXpx5631MFmeSR WFSNuSo/Rd7cHvMQomnqaGu3XW0pyuHUUSfNk+wgd0OW7E8CeqfA3mKUQqupsN2PSRHR UVzZDQLN19NNPZZCHXH7QdonvVNarluAhsvByuf/+8ICt+IN1JYXFPZcrePB70cbT3eL IpIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=NbgnyqIt; dkim=pass header.i=@codeaurora.org header.s=default header.b=IivKEMTk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si515766pfa.99.2019.02.04.09.19.04; Mon, 04 Feb 2019 09:19:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=NbgnyqIt; dkim=pass header.i=@codeaurora.org header.s=default header.b=IivKEMTk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731756AbfBDQQC (ORCPT + 99 others); Mon, 4 Feb 2019 11:16:02 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:49852 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731713AbfBDQP4 (ORCPT ); Mon, 4 Feb 2019 11:15:56 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7F2F0609C6; Mon, 4 Feb 2019 16:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1549296955; bh=DANfYZAr0IJ7iZWclKlp3WcOd2dppQW1UEMJ5r7u6SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbgnyqIt8MaHK+cIR3ahr884umyo/+prOD3p3t3w8dSAyI+ppT7kRcl1JKaiRqDIC AR/OLRfaNL3uY7hbCUjST/SOrSDsyd5YX+ari7sHE0D/aTocABfTtTLTolSSn48n52 jXkyJxs2s1wFT/uaBmnAcGU7f9rvynA/lCqPTxrs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from jcrouse1-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 687C360960; Mon, 4 Feb 2019 16:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1549296954; bh=DANfYZAr0IJ7iZWclKlp3WcOd2dppQW1UEMJ5r7u6SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IivKEMTkP+US1FDeSE9pjOun8KsgOTyqCnTvn73jmUUf4cUwh/n6jHTXe2jSyyGjw +TrAds4wtgOCh/qhoMTwzU1KWn/Rt7EeOFDw51tErPVDt8fheRu/erzSEjktYkZ3UO 3lYok4FmaXOUrQFaV8AcuKQk5waCbniN5v4W8scs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 687C360960 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, Stephen Boyd , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sharat Masetty , Andy Gross , Douglas Anderson , Rob Clark , David Airlie , Mamta Shukla , Daniel Vetter Subject: [PATCH v1 3/6] drm/msm/gpu: Attach to the GPU GX power domain Date: Mon, 4 Feb 2019 09:15:41 -0700 Message-Id: <1549296944-17285-4-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549296944-17285-1-git-send-email-jcrouse@codeaurora.org> References: <1549296944-17285-1-git-send-email-jcrouse@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 99.999% of the time during normal operation the GMU is responsible for power and clock control on the GX domain and the CPU remains blissfully unaware. However, there is one situation where the CPU needs to get involved: The power sequencing rules dictate that the GX needs to be turned off before the CX so that the CX can be turned on before the GX during power up. During normal operation when the CPU is taking down the CX domain a stop command is sent to the GMU which turns off the GX domain and then the CPU handles the CX domain. But if the GMU happened to be unresponsive while the GX domain was left then the CPU will need to step in and turn off the GX domain before resetting the CX and rebooting the GMU. This unfortunately means that the CPU needs to be marginally aware of the GX domain even though it is expected to usually keep its hands off. To support this we create a semi-disabled GX power domain that does nothing to the hardware on power up but tries to shut it down normally on power down. In this method the reference counting is correct and we can step in with the pm_runtime_put() at the right time during the failure path. This patch sets up the connection to the GX power domain and does the magic to "enable" and disable it at the right points. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 41 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 2 ++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index f1baf64f..a527c50 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -2,6 +2,7 @@ /* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. */ #include +#include #include #include @@ -671,6 +672,16 @@ int a6xx_gmu_reset(struct a6xx_gpu *a6xx_gpu) gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS3_DRV0_STATUS, val, (val & 1), 100, 1000); + /* + * Depending on the state of the GMU at this point the GX domain might + * have been left on. Hardware sequencing rules state that the GX has to + * be turned off before the CX domain so this is that one time that + * that calling pm_runtime_put_sync() is expected to do something useful + * (turn off the headswitch) + */ + if (!IS_ERR(gmu->gxpd)) + pm_runtime_put_sync(gmu->gxpd); + /* Disable the resources */ clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks); pm_runtime_put_sync(gmu->dev); @@ -732,6 +743,14 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu) /* Set the GPU to the highest power frequency */ __a6xx_gmu_set_freq(gmu, gmu->nr_gpu_freqs - 1); + /* + * "enable" the GX power domain which won't actually do anything but it + * will make sure that the refcounting is correct in case we need to + * bring down the GX after a GMU failure + */ + if (!IS_ERR(gmu->gxpd)) + pm_runtime_get(gmu->gxpd); + out: /* Make sure to turn off the boot OOB request on error */ if (ret) @@ -803,6 +822,14 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu) /* Tell RPMh to power off the GPU */ a6xx_rpmh_stop(gmu); + /* + * Mark the GPU power domain as off. During the shutdown process the GMU + * should actually turn off the power so this is really just a + * houskeeping step + */ + if (!IS_ERR(gmu->gxpd)) + pm_runtime_put_sync(gmu->gxpd); + clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks); pm_runtime_put_sync(gmu->dev); @@ -1172,9 +1199,15 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) if (IS_ERR_OR_NULL(gmu->mmio)) return; - pm_runtime_disable(gmu->dev); a6xx_gmu_stop(a6xx_gpu); + pm_runtime_disable(gmu->dev); + + if (!IS_ERR(gmu->gxpd)) { + pm_runtime_disable(gmu->gxpd); + dev_pm_domain_detach(gmu->gxpd, false); + } + a6xx_gmu_irq_disable(gmu); a6xx_gmu_memory_free(gmu, gmu->hfi); @@ -1233,6 +1266,12 @@ int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node) if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0) goto err; + /* + * Get a link to the GX power domain to reset the GPU in case of GMU + * crash + */ + gmu->gxpd = dev_pm_domain_attach_by_name(gmu->dev, "gx"); + /* Get the power levels for the GMU and GPU */ a6xx_gmu_pwrlevels_probe(gmu); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h index 8081083..078d418 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h @@ -55,6 +55,8 @@ struct a6xx_gmu { struct iommu_domain *domain; u64 uncached_iova_base; + struct device *gxpd; + int idle_level; struct a6xx_gmu_bo *hfi; -- 2.7.4