Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp462610ybl; Tue, 28 Jan 2020 06:21:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxXqmGxLegPVdJQ3HbwZlMSA7lBSqff08fmzzgk9lL/t1Vuigb5h6lztvIN9FyGBFCuMWOr X-Received: by 2002:aca:2207:: with SMTP id b7mr3028260oic.109.1580221277353; Tue, 28 Jan 2020 06:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221277; cv=none; d=google.com; s=arc-20160816; b=cvhTVM/ARYeEmygrxWVmL3eJVnizAY2cDWTR0ZTyii6LOGTO4MPpueXvYA33s6MJit sYsw5Dzm8pLG63JB/mmuRdEfAD/BBdAKsoeYqE8sXns6nwUET9mbwdaH2JP3nLAcefVV 4aG0S6YS9FDED7TrWVQrRUHDcPeSBpxcK0uZ5zvSIf1hldGYvPpjoSuUNG0ENctdsXSn ZluGdtpbzR+Bnv2plh54hatUGI9fvFwwl2XP5Zz/YwdXRsWFyFmlPaJu8uzjRuD2YfHD CfjUHXoBOJjyMxewyPjeAvTZCmFbZw7bWimevHiJa60axENIWWdSKmpjhFJ7gndovVWj 8bgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K7GmfBlwJVfgLP74JKsQCkwuhcM5NKcb6Z2+lZYLPI4=; b=ZnJ6IZIqq+ws4gtcT1fXgVIDN61rqTZp+ZM2ROEsreLXO5AyWb4DDvbcPOfCrSWU8/ MIyrUMIfNeKfsGOSPZCU9j/USkoiWOQNhWgEPpuWg3jpobi/L24T+cuvFYD4qVxksWTn haIB4JQPI0gyoq34iQQAoUKMeuV3M0NAbDVcROdYjuRmdppN2Q3AX9SdZCQ5DdX1a1+N UcFUq9DBKkCV0bOOnvnaqlYQ5nvXaWqdmteVrYaLpRjkbbPSR2pUpDvAxAlqQhrPmAPc T51fn05DRnLv0AOhlhlk0fZyQzlY77zzzCXdK9qoRL+uc71E9aJOQTbCaa/MAZKrYbCI WN0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z7kKD7Q9; 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 p3si5241572oih.186.2020.01.28.06.21.05; Tue, 28 Jan 2020 06:21:17 -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=@kernel.org header.s=default header.b=Z7kKD7Q9; 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 S1731041AbgA1OUN (ORCPT + 99 others); Tue, 28 Jan 2020 09:20:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:44948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730811AbgA1OUM (ORCPT ); Tue, 28 Jan 2020 09:20:12 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D74DF2071E; Tue, 28 Jan 2020 14:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221211; bh=+8X1MENOY7tI9xG5PPzTrYYKY96vWn3iZaaJ4qyL2kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7kKD7Q9z2AMB03Zp4+DYnWU1BldtH9I+3bKzvWTEwHuvqnZ/TipsJ+f/6QpSR5Nj zCCOob/tNASEyCwnULcguHVLDX1cL9l7McLiNX88YS5wJCRsTfk+7gk9jbPj3mx/Rb P5dBbpmuv1OLgR8QVB3oa9fKlrATof22bD5GG2tM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sameer Pujar , Jon Hunter , Vinod Koul , Sasha Levin Subject: [PATCH 4.9 133/271] dmaengine: tegra210-adma: restore channel status Date: Tue, 28 Jan 2020 15:04:42 +0100 Message-Id: <20200128135902.499662626@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sameer Pujar [ Upstream commit f33e7bb3eb922618612a90f0a828c790e8880773 ] Status of ADMA channel registers is not saved and restored during system suspend. During active playback if system enters suspend, this results in wrong state of channel registers during system resume and playback fails to resume properly. Fix this by saving following channel registers in runtime suspend and restore during runtime resume. * ADMA_CH_LOWER_SRC_ADDR * ADMA_CH_LOWER_TRG_ADDR * ADMA_CH_FIFO_CTRL * ADMA_CH_CONFIG * ADMA_CH_CTRL * ADMA_CH_CMD * ADMA_CH_TC Runtime PM calls will be inovked during system resume path if a playback or capture needs to be resumed. Hence above changes work fine for system suspend case. Fixes: f46b195799b5 ("dmaengine: tegra-adma: Add support for Tegra210 ADMA") Signed-off-by: Sameer Pujar Reviewed-by: Jon Hunter Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/tegra210-adma.c | 46 ++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c index e9e46a5207452..8c3cab463354f 100644 --- a/drivers/dma/tegra210-adma.c +++ b/drivers/dma/tegra210-adma.c @@ -98,6 +98,7 @@ struct tegra_adma_chan_regs { unsigned int src_addr; unsigned int trg_addr; unsigned int fifo_ctrl; + unsigned int cmd; unsigned int tc; }; @@ -127,6 +128,7 @@ struct tegra_adma_chan { enum dma_transfer_direction sreq_dir; unsigned int sreq_index; bool sreq_reserved; + struct tegra_adma_chan_regs ch_regs; /* Transfer count and position info */ unsigned int tx_buf_count; @@ -635,8 +637,30 @@ static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec, static int tegra_adma_runtime_suspend(struct device *dev) { struct tegra_adma *tdma = dev_get_drvdata(dev); + struct tegra_adma_chan_regs *ch_reg; + struct tegra_adma_chan *tdc; + int i; tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD); + if (!tdma->global_cmd) + goto clk_disable; + + for (i = 0; i < tdma->nr_channels; i++) { + tdc = &tdma->channels[i]; + ch_reg = &tdc->ch_regs; + ch_reg->cmd = tdma_ch_read(tdc, ADMA_CH_CMD); + /* skip if channel is not active */ + if (!ch_reg->cmd) + continue; + ch_reg->tc = tdma_ch_read(tdc, ADMA_CH_TC); + ch_reg->src_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_SRC_ADDR); + ch_reg->trg_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_TRG_ADDR); + ch_reg->ctrl = tdma_ch_read(tdc, ADMA_CH_CTRL); + ch_reg->fifo_ctrl = tdma_ch_read(tdc, ADMA_CH_FIFO_CTRL); + ch_reg->config = tdma_ch_read(tdc, ADMA_CH_CONFIG); + } + +clk_disable: clk_disable_unprepare(tdma->ahub_clk); return 0; @@ -645,7 +669,9 @@ static int tegra_adma_runtime_suspend(struct device *dev) static int tegra_adma_runtime_resume(struct device *dev) { struct tegra_adma *tdma = dev_get_drvdata(dev); - int ret; + struct tegra_adma_chan_regs *ch_reg; + struct tegra_adma_chan *tdc; + int ret, i; ret = clk_prepare_enable(tdma->ahub_clk); if (ret) { @@ -654,6 +680,24 @@ static int tegra_adma_runtime_resume(struct device *dev) } tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd); + if (!tdma->global_cmd) + return 0; + + for (i = 0; i < tdma->nr_channels; i++) { + tdc = &tdma->channels[i]; + ch_reg = &tdc->ch_regs; + /* skip if channel was not active earlier */ + if (!ch_reg->cmd) + continue; + tdma_ch_write(tdc, ADMA_CH_TC, ch_reg->tc); + tdma_ch_write(tdc, ADMA_CH_LOWER_SRC_ADDR, ch_reg->src_addr); + tdma_ch_write(tdc, ADMA_CH_LOWER_TRG_ADDR, ch_reg->trg_addr); + tdma_ch_write(tdc, ADMA_CH_CTRL, ch_reg->ctrl); + tdma_ch_write(tdc, ADMA_CH_FIFO_CTRL, ch_reg->fifo_ctrl); + tdma_ch_write(tdc, ADMA_CH_CONFIG, ch_reg->config); + tdma_ch_write(tdc, ADMA_CH_CMD, ch_reg->cmd); + } + return 0; } -- 2.20.1