From patchwork Tue Oct 16 03:11:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10642929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9D7E3E9D for ; Tue, 16 Oct 2018 03:20:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7F0C29AD5 for ; Tue, 16 Oct 2018 03:20:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B60AF29B5F; Tue, 16 Oct 2018 03:20:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A415E29B08 for ; Tue, 16 Oct 2018 03:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=lemSduyRxSE5WgjqH9OVdE4Oak7zHAlQW2CWIfY5rr8=; b=Sd61OzYWsJthd7 MZ9zXOsxNMpR4P5oJupooe1R3zPg2+shsbTMDeU4awm2rISbfHvFIC4Qu4/B+dlLmJ1cqquK7urwj 7An2gSdKPlafdIgUIFe8yc5J8JDbe6IEHcyhQmRjA09YUliTx36hY52VlsJZJAvo/qQtjIxQbAcm1 HVJ53P7mUaDPG8P2Q6KX71Hm90u8okr/JOmX1U+Ov6Okv6RmFj5OAcVxxYNlxmLTtm/dV6095SW9e z61mLjK1z94hVSE5x+3OEq5r9chRSnq0cPD/wAz47INJ82+Y+ZQyxyyro9XSFsj+HKjpOUZjD/+oe lH5F/IVviYlwaOJm/Y8w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCFtY-00085F-4h; Tue, 16 Oct 2018 03:19:44 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCFtV-00081Z-DS for linux-arm-kernel@bombadil.infradead.org; Tue, 16 Oct 2018 03:19:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rAfgjoeXGtR6r3nDwvuQAB/E9x/hZxQ3I9y5hIuiEVA=; b=ZxnY4uliz7f1EQMMYyyl6paDT0 piKBF4bYcBIm+/0S7ZGxzdEc2VAx761NWE37iQ/OkkGTXIfRrCrZgR0FNrDMazVyed9wfxBLBK/IN 8/J1qw8EeQd2NfgIOzlA5vPGQvHDHK04KCTW2e/xVW7HmuUq3Onw2As1Lt6hN64JnkYxetlYJgjar jTL8XPL4o1kZbwmsEcYF+3LWwZrwY55o644Pap9m3+QP4c9qPo6gef01mcko/wegq//iGqQLCe80j YA8OTeXEV5I1GWKmI8owd+xMHqxl/PwzmqXIlYx4uhjScyHQrkWqCA1b3UAd4pRXP3Z4fdGihVWo4 mqpWJTGw==; Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCFm4-0006RE-JJ for linux-arm-kernel@lists.infradead.org; Tue, 16 Oct 2018 03:12:02 +0000 Received: by mail-pg1-x544.google.com with SMTP id v133-v6so10119971pgb.2 for ; Mon, 15 Oct 2018 20:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rAfgjoeXGtR6r3nDwvuQAB/E9x/hZxQ3I9y5hIuiEVA=; b=bOJ7fJA3J/kq3vduXD2OG/mdEl6NlGz5+q2Q0MLTEmqvwJlnB/a27FEFATCh8S1BXZ +i5epAPKRcBesQRu9WO7LlfCtP4gHyoKaPXRiI9FCdyOo/e/5H6iYjvaB6MlXNPTIff2 7af5NpoJOCUpbcyIGrzbC6dwIF0c43kFosqnmkjiA3BAaxsiOvJe3c25pFv1HMmVle7l RMWI5Ksl8uXQkpqXGZf7IeBOsSzKYW9eKMexeG9IMvUBx6sJVT2NWe+JEwPYd33AJMF0 7f4RN9+VGVS/YN57jGQS2nxFb2pqWvg8jkLmVuaqH9xgtlROk29sv6T43JURQLThBTMe thzA== 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:mime-version :content-transfer-encoding; bh=rAfgjoeXGtR6r3nDwvuQAB/E9x/hZxQ3I9y5hIuiEVA=; b=kjPLHzO6DXNkHACXrz1cm5JkGr59Y/9MwWdQT3HjUyFR/YViYplzmI6uL0QeAi0NZh KpC0KUr6jqtAkmtmXxv44T7v9KDzQjW9cVAC9YqaOvhfA0lsadG1KL13wV/g0pskuiJZ M1enFnGYMm1lMkMKLg9vwKHVRgaSi0PAnqO66fnX9RblgdDI+/9rhud/WY8pkSBonTVw LoJJxje0jTv7nYuJM9ldGvUiC0/SHSlvT85fqlyoAiN4YLokcYHXl/en40/rdsDlAeLZ JGWOOnSMDX70whJsd5YMkuljS46pKWFETZZWtxxQxVpTS/t9+uApWqj11tB/IjHv2z99 URLw== X-Gm-Message-State: ABuFfohj7dNg2Adn8UiLA81MeqBpxUwMH5ogRwaCunq2QDhAf9yUHmB/ IgXaGhanl5LPpJeLSeMA/Gc= X-Google-Smtp-Source: ACcGV60I40yj+sQX0D2fwRPKlop5ZUE7NotG3Jji/qeX46xVM/SxTqc4ZGPJruG7/cMTkvvoacQKgg== X-Received: by 2002:a63:84c1:: with SMTP id k184-v6mr18702852pgd.196.1539659508893; Mon, 15 Oct 2018 20:11:48 -0700 (PDT) Received: from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net. [216.71.193.140]) by smtp.gmail.com with ESMTPSA id o62-v6sm15364459pfb.0.2018.10.15.20.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:11:48 -0700 (PDT) From: Vasily Khoruzhick To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Maxime Ripard , Chen-Yu Tsai , Marcus Cooper , Yong Deng , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks Date: Mon, 15 Oct 2018 20:11:41 -0700 Message-Id: <20181016031141.16259-1-anarsoul@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181016_041200_844924_53292799 X-CRM114-Status: GOOD ( 18.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasily Khoruzhick Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP startup() and shutdown() hooks are called for both substreams, so stopping either substream when another is running breaks the latter. E.g. playback breaks if capture is stopped when playback is running. Move code from startup() and shutdown() to resume() and suspend() hooks respectively to fix this issue Signed-off-by: Vasily Khoruzhick Acked-by: Maxime Ripard --- v2: - rename from "ASoC: sun4i-i2s: don't try to start up or shut down DAI if it's active" - move code from startup/shutdown hooks into pm_runtime sound/soc/sunxi/sun4i-i2s.c | 61 +++++++++++++++---------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index a4aa931ebfae..daa6c08cffbc 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -644,40 +644,6 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } -static int sun4i_i2s_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - /* Enable the whole hardware block */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN); - - /* Enable the first output line */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_SDO_EN_MASK, - SUN4I_I2S_CTRL_SDO_EN(0)); - - - return clk_prepare_enable(i2s->mod_clk); -} - -static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - clk_disable_unprepare(i2s->mod_clk); - - /* Disable our output lines */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_SDO_EN_MASK, 0); - - /* Disable the whole hardware block */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_GL_EN, 0); -} - static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { @@ -695,8 +661,6 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = { .hw_params = sun4i_i2s_hw_params, .set_fmt = sun4i_i2s_set_fmt, .set_sysclk = sun4i_i2s_set_sysclk, - .shutdown = sun4i_i2s_shutdown, - .startup = sun4i_i2s_startup, .trigger = sun4i_i2s_trigger, }; @@ -869,6 +833,21 @@ static int sun4i_i2s_runtime_resume(struct device *dev) goto err_disable_clk; } + /* Enable the whole hardware block */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN); + + /* Enable the first output line */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_SDO_EN_MASK, + SUN4I_I2S_CTRL_SDO_EN(0)); + + ret = clk_prepare_enable(i2s->mod_clk); + if (ret) { + dev_err(dev, "Failed to enable module clock\n"); + goto err_disable_clk; + } + return 0; err_disable_clk: @@ -880,6 +859,16 @@ static int sun4i_i2s_runtime_suspend(struct device *dev) { struct sun4i_i2s *i2s = dev_get_drvdata(dev); + clk_disable_unprepare(i2s->mod_clk); + + /* Disable our output lines */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_SDO_EN_MASK, 0); + + /* Disable the whole hardware block */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_GL_EN, 0); + regcache_cache_only(i2s->regmap, true); clk_disable_unprepare(i2s->bus_clk);