Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp747238ybn; Tue, 24 Sep 2019 08:54:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYtRYYSJSczXUWmfujisAm37fUxmyUKA5dU2II05e3jy6EU5X82CWE/Ia4Gzp2IEPJue9L X-Received: by 2002:adf:e7ca:: with SMTP id e10mr2978299wrn.234.1569340480992; Tue, 24 Sep 2019 08:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569340480; cv=none; d=google.com; s=arc-20160816; b=0E686Uv4kw2uzKrv5POAoWlihNmDKMKqSfG4nQlJb4t0tWdtMMKXY/S9pp0rManL5j ymFgWvas1QmnspDAiggvEusuTw1e46qfg7imZDH2CFlneU6y46I0F5WaSpOMwX6rhqFO Qr+10863eCAO/BqvDz4/EMOMUW93vsmIE/oMQlTJm1gX1Q/lkipKTZG1cEheHG/R7Ueh gN4JKBFLqhnLM80NaF0ihlN8806BmhGV3KL4lTZ3nrifY+b1ySkiP6mcat67UPsORjjG PgGFTfT//Xpj9lImOUThFFpzsXSZy8RbdeNcz7RqgpJqQz3WOCqaAfWaZwR51cq4Ckc0 tNRA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uS3omDC5fL9ZppJQ/5196azGZw/FtRHQ9ADljr0/fK8=; b=amePI0XtR/tlVTEQ2TX+lfgqzE64APTPtFhGTpvWf4D1f4ajlT7w4MoCBw6Tg+c0EF OQP6wmNQNszPozyrl6GjfERYPiH2XG5NTePijnT2qSeUJ9shIPP5WfELgWY0SQZYwgqA J64JeLapWCagIi1VXSNn9JswJAXe3zuZb8yi8W12xMhLcTYLJVLllNd1z/P0pbIIw9XO niu1TMFHGvk98CISXI39WDAD5bBCce7fMk8LyoV1z+oKVLn6AJj/zqEZ5g9rMuk+P6Kp b8p854+UyAdHumQrfxevPD6p6w+GldHf/RaB3zFmd4KW7qGgpNJTZ2o14sMA+k99Es1O jocw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Sp3/G2sL"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d58si1437953eda.62.2019.09.24.08.54.17; Tue, 24 Sep 2019 08:54:40 -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="Sp3/G2sL"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439157AbfIVTfY (ORCPT + 99 others); Sun, 22 Sep 2019 15:35:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390269AbfIVSqu (ORCPT ); Sun, 22 Sep 2019 14:46:50 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 756032196E; Sun, 22 Sep 2019 18:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569178009; bh=izJSz9zwaSm5xge40Tyl2gKrXmgr/JkniLuCjKggVes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sp3/G2sLfRqtwimhfVb8FvYY0mqAOYeU/QrQa/0NVRD+lI0C2PqBSGcAy0rpE4u8Y 3xgTJ3qqdEYin5FRsps8ij0d22zKhtamQfGEpFJFCa0QW563evuwahbsiwF34MrtHu wSlQUMu/xNZSFFNzLMkzWZ84dnoSqhsdd/6xj6q4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kunihiko Hayashi , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.3 096/203] ASoC: uniphier: Fix double reset assersion when transitioning to suspend state Date: Sun, 22 Sep 2019 14:42:02 -0400 Message-Id: <20190922184350.30563-96-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922184350.30563-1-sashal@kernel.org> References: <20190922184350.30563-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit 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(-) 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; -- 2.20.1