From patchwork Thu Oct 3 15:51:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175176 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp610869ill; Thu, 3 Oct 2019 10:13:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk13OZfkr8PGmJO/mKqaBkchNQQ7Dx1QW/KbagSvDsdyRljxeuyF3Jo3GIWVxKux43xaEh X-Received: by 2002:a17:906:cec3:: with SMTP id si3mr8617079ejb.145.1570122791588; Thu, 03 Oct 2019 10:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122791; cv=none; d=google.com; s=arc-20160816; b=Q15DgWdtAMJfttMKUlY7npY6ig1uB5Bgb6zq0YXJzxNW17OZ48mMJmqhPLSAOZoYWt 4qBgBGapU24B+6Y0fwB7BYw2OZlJDCsJhhVThjIpLDm8B4+/4eu0EjcPX0+msFp8xHku isdzdzHnMo/T3Lz6wypZ29vXjaM5GN3HyUOU2lYnm9DCLEN8hja7X4ijJgrRvFVXuKF5 ywbI5sVBA+Vho5fLFcOfVGzCIGE1CtafTrVdwl3y+V/uj6Sus2pfMkFYvL7VT+i4eDBc HcoSbkQ3gG9dI/+7Hd6cLrahUzf0v92foMRRlGX9h4yFvEK+foiQYarkE0vdQBLUEXnq 4Vlw== 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=uS3omDC5fL9ZppJQ/5196azGZw/FtRHQ9ADljr0/fK8=; b=zyNImr4eQw3Q7/p6xVR4317Dlfoh4vVKQ0m6LOyoZDQEm9qVBONBuWx8nWJlWDlrFU wNXY6Vwo33sR1A1PAXnEfd8ak/psiqzUIOvKuYD3YqknbglI+r6YEEikETmMRrSGYjed 7vLLOUXj5yDIpCEE4k5J4bZMs7fpg7dxXIxRktEcQitTMwynS4iSO635fO92cT2NurwA aX/eRRy8d9TjJ5nfeveAErDoCHYa/GYTcztnzkE2Jnr1MNe8h/BEZ2oqeiS5Xc++yJZq E0BqzPWi02frkuTiQuZNHIbaiFEsCFOPaUV6yUJSxUCY3+S3od2mvjoxJZL97ZJ5z6H5 /9WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aHW5YTuc; 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 se14si1584952ejb.322.2019.10.03.10.13.11; Thu, 03 Oct 2019 10:13:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b=aHW5YTuc; 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 S2392178AbfJCRNK (ORCPT + 27 others); Thu, 3 Oct 2019 13:13:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:34388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390021AbfJCQ3N (ORCPT ); Thu, 3 Oct 2019 12:29:13 -0400 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 A7B1B2054F; Thu, 3 Oct 2019 16:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120152; bh=izJSz9zwaSm5xge40Tyl2gKrXmgr/JkniLuCjKggVes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHW5YTuctuMvOAfWQga/eCXMRIMfjHYxmH6Y4/luSXjCTs+9dDgtfiYnuQe5Hc+Dh AW+tqbe7R6mMYGuQ80l82nihBGDIKhgkYpCN2DnWAedgILy7eqqkxCoeTq1SdRjAtK 4XSrJIm+9d47t0dmwmOiWkhoRtVLC40LnPhbVH4w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kunihiko Hayashi , Mark Brown , Sasha Levin Subject: [PATCH 5.2 115/313] ASoC: uniphier: Fix double reset assersion when transitioning to suspend state Date: Thu, 3 Oct 2019 17:51:33 +0200 Message-Id: <20191003154544.199923491@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kunihiko Hayashi [ Upstream commit c372a35550c8d60f673b20210eea58a06d6d38cb ] 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 Link: https://lore.kernel.org/r/1566281764-14059-1-git-send-email-hayashi.kunihiko@socionext.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/uniphier/aio-cpu.c | 31 +++++++++++++++++++++---------- sound/soc/uniphier/aio.h | 1 + 2 files changed, 22 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c index ee90e6c3937ce..2ae582a99b636 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 ca6ccbae0ee8c..a7ff7e556429b 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;