From patchwork Sun Oct 21 15:39:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10650871 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 7B25A1815 for ; Sun, 21 Oct 2018 15:40:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 684D7287BE for ; Sun, 21 Oct 2018 15:40:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C28B287C2; Sun, 21 Oct 2018 15:40:45 +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 DA580287BE for ; Sun, 21 Oct 2018 15:40:44 +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=b23500fQHMnj9hQMsPT+soDeU7fMIx/g24BKnye7F4o=; b=rkVfJYhsDeV6z3 Vz9Q/4D/Nfo+PIGOEoHLUyLxCMIN009JmAIPBrMUNIqs/wfeZcBjiI1rTlecVYkZDwlBMT1KBlcRe 9LRCQrt62f2JOPJxM8/PL7mZxZJlGEH2wyoTIGTk1iFU2Bwskry1Hksy9xW1ZQxuyii8h7RyNU9ex u49edGH65UVnSMisBfOa9aynrm6+CEbOlRoaCafB3Hv+HP2OVHqxrVywK5pSYmjzpghqZmKuvVM6v 54FerzMBE1rBXZ53o6x9fFcqgUeFaOtBu9fhuQuVcPLtc1RJ7vEWe83u0HRtgE8+Hv8W6P8avkHdx xOwfnUzpNZEy5/VEysBQ==; 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 1gEFqC-0008SR-02; Sun, 21 Oct 2018 15:40:32 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gEFq7-0008Rg-Rd for linux-arm-kernel@lists.infradead.org; Sun, 21 Oct 2018 15:40:29 +0000 Received: by mail-pf1-x444.google.com with SMTP id f29-v6so18680324pff.5 for ; Sun, 21 Oct 2018 08:40:17 -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=Qwaxx+OtLNbLtbE8BdDeZ5GJxl78zvCl9FJNsYQwhY8=; b=OnYPHG30LWrHb99IQKHCrCAETwxWzTUUJwKWSOgiEDGVyKwA5zA1uSu9wiBcPyv0lH JdwWEJRl33COJYFkLr4xCGceKaGQVOrSJFIhhosT2HawxFBHBeKMlyPBMhldPaGsx6pj cD1YdaMWvFZGZpgKDj2uv+qTgxmbuy9OL9pRKBC278xF0FgxR65WGfqPgsaeNQbwRiuy pOq/HkBH8u5TZ3/INAbOc4N1gS9T96NeN2KTBOyyQsJhmoUveVKHlcVuiiLxxTP4cKw2 ev3ilR7dsYlCK5eXM0x2Ta3LcxsJ/t93EheQVKdHizHykoNCp3S4sthLXlPRZcqqX2gy Zdgg== 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=Qwaxx+OtLNbLtbE8BdDeZ5GJxl78zvCl9FJNsYQwhY8=; b=eX3xmsCEUhP4MQUWCZiK6DeUuC0t7Ym3WJMOFIeQ0MHgxgSOpBv3nsBEXzhil2HgRv Y5ZgW9ZGvo2KRtrUz4CgbsPxQEu08KS7bjxhowYQhrLoVrHRA5T6NNFLpmExDSkb56TQ 9Gkatc/CVtBEmTX1ZR5Fc4pGSa6D32CmaCwAssuG2ikknnqR0ZYxJTFXPu6mG86A8+Mn pmzGELPLHwYVIT74YcCN41khdvQC9oq4LsI2uvZEIFQgw8wew2QldqxPBEetCk1kP3iK FwNwhUUvABb0C1vhYoFhuBtqi9Z2dB2rnbHBkZc5oFrqq5hGv4sp16gX0Njvvt3hXPd0 iz6A== X-Gm-Message-State: ABuFfohRhgrNbl7H8xzDlkcQ7tvWs7wa01kM6CxtkdnqbbD0hizhfog/ 5EHDISZzp4PpHldVK5rkkHo= X-Google-Smtp-Source: ACcGV624WR5Z27oZxwFOtrv2WvDx2VauBLcIrOj/JVi9yBu1fYlzYEZhqLU6bnU1PD2xhEZKv+YEGg== X-Received: by 2002:a62:85cb:: with SMTP id m72-v6mr42076131pfk.173.1540136416571; Sun, 21 Oct 2018 08:40:16 -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 k70-v6sm36103547pfc.76.2018.10.21.08.40.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 08:40:16 -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 RESEND v2] ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks Date: Sun, 21 Oct 2018 08:39:11 -0700 Message-Id: <20181021153912.29185-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-20181021_084027_919917_23E8D2C6 X-CRM114-Status: GOOD ( 15.16 ) 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);