From patchwork Tue Aug 20 06:16:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 171770 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3967758ily; Mon, 19 Aug 2019 23:16:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWZ8cpwQKWmSJ50wkkr992lzBVg3VxN4NzRZIa8ER1wr3DNev8+tdNevKHszVQcpPzwYdb X-Received: by 2002:aa7:939c:: with SMTP id t28mr19183402pfe.111.1566281782063; Mon, 19 Aug 2019 23:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566281782; cv=none; d=google.com; s=arc-20160816; b=rNxgZcWTYYj3KvbqlTzg4H0fhHi7ZfoNN4KLpEz/p2r0v4AfZMayAg12lGvitEh096 YJ3NfJyJBBx/2eS4QDhG3yXrSoqvK5uABkYik0WdxxNup/d9wzriFBF59g7COYRJvpQO Kq53IB15zcL2hfUA9wT9w8noPuly10Qt10TdLJ63Z9gWOQFfIrt9L7tykXpphSZm1hiO 1IyZOd4dYokUHuml/y8n2iMSpMUkQLQSTspjZTBxFv1XtmaSiBVXNnfNgo32buouZmli UX5N2mTCBzyVPHTP56rthq+T1OEnqyilSIEfGWmdhOVsfeQVqRInf1Ihh28KWKHF09tj 7mgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=PuQHcpW6fjCVuNtXh5uEv34XSZqwGLFnHjBlF5ScE8g=; b=PYafLb3m469/zoO3/vJHaFetETAhfx0NUSUuSwkHA9aWhXAruE6FniFVDUBh/9cTDK qlr0LXDWa+VLoyRBVVabvukyVk4Ad2bD57ylW4O2rBMhdTz9g4/OMXIZtSJ2ch8LPCUR ksNSimE63LCv5Lw4QEBk0kw1jUKfghsAwmpXeuQ8tFyjkbUE7hlUBIEH7ay4CemOE0IG /d7uo9aJOoMcfZGF66qpLvbIXu9vXeZSmpBS/agUFmaZsmyoAgRev4t/zV8sYpQ5e8TZ ZXo+45ydbQ+kqIjHIbBXmJBAeEMSNGbYwz3rxcGHlSzptftJ9ZAkLrF8lluTlCcusCcr i+wQ== ARC-Authentication-Results: i=1; mx.google.com; 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 gn1si11564621plb.9.2019.08.19.23.16.21; Mon, 19 Aug 2019 23:16:22 -0700 (PDT) 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; 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 S1729245AbfHTGQU (ORCPT + 28 others); Tue, 20 Aug 2019 02:16:20 -0400 Received: from mx.socionext.com ([202.248.49.38]:58469 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728960AbfHTGQU (ORCPT ); Tue, 20 Aug 2019 02:16:20 -0400 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 20 Aug 2019 15:16:18 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id CFEDF605F8; Tue, 20 Aug 2019 15:16:18 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Tue, 20 Aug 2019 15:16:18 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 4DF4B1A04FC; Tue, 20 Aug 2019 15:16:18 +0900 (JST) From: Kunihiko Hayashi To: alsa-devel@alsa-project.org, Mark Brown , Liam Girdwood Cc: Masami Hiramatsu , Jassi Brar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH] ASoC: uniphier: Fix double reset assersion when transitioning to suspend state Date: Tue, 20 Aug 2019 15:16:04 +0900 Message-Id: <1566281764-14059-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When transitioning to supend state, uniphier_aio_dai_suspend() is called and asserts reset lines and disables clocks. However, if there are two or more DAIs, uniphier_aio_dai_suspend() are called multiple times, and double reset assersion will cause. This patch defines the counter that has the number of DAIs at first, and whenever uniphier_aio_dai_suspend() are called, it decrements the counter. And only if the counter is zero, it asserts reset lines and disables clocks. In the same way, uniphier_aio_dai_resume() are called, it increments the counter after deasserting reset lines and enabling clocks. Fixes: 139a34200233 ("ASoC: uniphier: add support for UniPhier AIO CPU DAI driver") Signed-off-by: Kunihiko Hayashi --- sound/soc/uniphier/aio-cpu.c | 31 +++++++++++++++++++++---------- sound/soc/uniphier/aio.h | 1 + 2 files changed, 22 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c index ee90e6c..2ae582a 100644 --- a/sound/soc/uniphier/aio-cpu.c +++ b/sound/soc/uniphier/aio-cpu.c @@ -424,8 +424,11 @@ int uniphier_aio_dai_suspend(struct snd_soc_dai *dai) { struct uniphier_aio *aio = uniphier_priv(dai); - reset_control_assert(aio->chip->rst); - clk_disable_unprepare(aio->chip->clk); + aio->chip->num_wup_aios--; + if (!aio->chip->num_wup_aios) { + reset_control_assert(aio->chip->rst); + clk_disable_unprepare(aio->chip->clk); + } return 0; } @@ -439,13 +442,15 @@ int uniphier_aio_dai_resume(struct snd_soc_dai *dai) if (!aio->chip->active) return 0; - ret = clk_prepare_enable(aio->chip->clk); - if (ret) - return ret; + if (!aio->chip->num_wup_aios) { + ret = clk_prepare_enable(aio->chip->clk); + if (ret) + return ret; - ret = reset_control_deassert(aio->chip->rst); - if (ret) - goto err_out_clock; + ret = reset_control_deassert(aio->chip->rst); + if (ret) + goto err_out_clock; + } aio_iecout_set_enable(aio->chip, true); aio_chip_init(aio->chip); @@ -458,7 +463,7 @@ int uniphier_aio_dai_resume(struct snd_soc_dai *dai) ret = aio_init(sub); if (ret) - goto err_out_clock; + goto err_out_reset; if (!sub->setting) continue; @@ -466,11 +471,16 @@ int uniphier_aio_dai_resume(struct snd_soc_dai *dai) aio_port_reset(sub); aio_src_reset(sub); } + aio->chip->num_wup_aios++; return 0; +err_out_reset: + if (!aio->chip->num_wup_aios) + reset_control_assert(aio->chip->rst); err_out_clock: - clk_disable_unprepare(aio->chip->clk); + if (!aio->chip->num_wup_aios) + clk_disable_unprepare(aio->chip->clk); return ret; } @@ -619,6 +629,7 @@ int uniphier_aio_probe(struct platform_device *pdev) return PTR_ERR(chip->rst); chip->num_aios = chip->chip_spec->num_dais; + chip->num_wup_aios = chip->num_aios; chip->aios = devm_kcalloc(dev, chip->num_aios, sizeof(struct uniphier_aio), GFP_KERNEL); diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index ca6ccba..a7ff7e5 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -285,6 +285,7 @@ struct uniphier_aio_chip { struct uniphier_aio *aios; int num_aios; + int num_wup_aios; struct uniphier_aio_pll *plls; int num_plls;