Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2897350ybh; Mon, 5 Aug 2019 08:34:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF1FOwL5u/FmwOg3UQgF25rStwVe0cWkRrNs18gTJOxo39gPKvMUmzT6d/XyE/VKzXf8dH X-Received: by 2002:a63:e70f:: with SMTP id b15mr137458290pgi.152.1565019264600; Mon, 05 Aug 2019 08:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565019264; cv=none; d=google.com; s=arc-20160816; b=Ty/Ek2ux21L531eBmH+Va5BCCwiRz6ZARNcvzk+ptf9fLISYdUUFncDv1GJ4KBXL5n qBA3TiNVL8hnMtBzxULbE6ei6PV2NKY2tEX/vCeDUPEDX/LETGSO7ooKyEGxS7iBD/Pb uXEwf8O5pmNL5yd64+t2hj/h90+kLSz6LRTwxQE7WSer9EB7SrL5CWIJ7YdBjlV2pIIw dqAmXOeKT2Emxpf2GhlMdKDWAXhiAWrwp+NTAqeWn0a65R18d13ofNt7TmXgJaU6Hb5h paOTCnuGs3P0rSq5OA6+FBybR882rnCOdYRxVKVEEXO8H3rDbh+lzkMTybzWt6rJmWRE Vclg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=qPXxlB4jToaUrBvnY+tigzxP9UJpDPIoKOe5LkaLFGU=; b=Svpds83sFAVjghUG4KQQrQAu5k0u0UmQDNtKpNavJYoeuvYAoAOohdPOBGQoa92I2/ TwnwYXlIwRU55xDzGZhdDQkiHiR4ahCknT3WA54FTg5P3MWXOXON/vcb7cnOUHnDr/eR kbVlET1UQPHD1A7Twxoyn0Je5wUbevb0JYfeRqQvnqBTtZKX48jiW6BTD1DKBuUyO4AA T6oalk4x4eH1BGxd3JVdJl01rNSdA2qyjcKF7uJxBKTnzQEooaZKTbbiLFKcyUAxZWJz YNo03XRpOqcIX9iVb+BpIsQm7GSvZYdZnXaM0n7bFnIaf+AvJpd8d/fd2frS4IJ6NNB4 3WSw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y63si43155637pgd.403.2019.08.05.08.34.09; Mon, 05 Aug 2019 08:34:24 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728932AbfHEPd1 (ORCPT + 99 others); Mon, 5 Aug 2019 11:33:27 -0400 Received: from mga17.intel.com ([192.55.52.151]:30103 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbfHEPd1 (ORCPT ); Mon, 5 Aug 2019 11:33:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2019 08:33:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,350,1559545200"; d="scan'208";a="164683077" Received: from nupurjai-mobl.amr.corp.intel.com (HELO [10.251.149.179]) ([10.251.149.179]) by orsmga007.jf.intel.com with ESMTP; 05 Aug 2019 08:33:25 -0700 Subject: Re: [alsa-devel] [RFC PATCH 23/40] soundwire: stream: fix disable sequence To: Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-24-pierre-louis.bossart@linux.intel.com> <20190805095620.GD22437@buildpc-HP-Z230> From: Pierre-Louis Bossart Message-ID: <12799e97-d6e3-5027-a409-0fe37dba86fd@linux.intel.com> Date: Mon, 5 Aug 2019 10:33:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190805095620.GD22437@buildpc-HP-Z230> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/5/19 4:56 AM, Sanyog Kale wrote: > On Thu, Jul 25, 2019 at 06:40:15PM -0500, Pierre-Louis Bossart wrote: >> When we disable the stream and then call hw_free, two bank switches >> will be handled and as a result we re-enable the stream on hw_free. >> > > I didnt quite get why there will be two bank switches as part of disable flow > which leads to enabling of stream? You have two bank switches, one to stop streaming and on in de-prepare. It's symmetrical with the start sequence, where we do a bank switch to prepare and another to enable. Let's assume we are using bank0 when streaming. Before the first bank switch, the channel_enable is set to false in the alternate bank1. When the bank switch happens, bank1 become active and the streaming stops. But bank0 registers have not been modified so when we do the second bank switch in de-prepare we make bank0 active, and the ch_enable bits are still set so streaming will restart... When we stop streaming, we need to make sure the ch_enable bits are cleared in the two banks. > >> Make sure the stream is disabled on both banks. >> >> TODO: we need to completely revisit all this and make sure we have a >> mirroring mechanism between current and alternate banks. >> >> Signed-off-by: Pierre-Louis Bossart >> --- >> drivers/soundwire/stream.c | 19 ++++++++++++++++++- >> 1 file changed, 18 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c >> index 53f5e790fcd7..75b9ad1fb1a6 100644 >> --- a/drivers/soundwire/stream.c >> +++ b/drivers/soundwire/stream.c >> @@ -1637,7 +1637,24 @@ static int _sdw_disable_stream(struct sdw_stream_runtime *stream) >> } >> } >> >> - return do_bank_switch(stream); >> + ret = do_bank_switch(stream); >> + if (ret < 0) { >> + dev_err(bus->dev, "Bank switch failed: %d\n", ret); >> + return ret; >> + } >> + >> + /* make sure alternate bank (previous current) is also disabled */ >> + list_for_each_entry(m_rt, &stream->master_list, stream_node) { >> + bus = m_rt->bus; >> + /* Disable port(s) */ >> + ret = sdw_enable_disable_ports(m_rt, false); >> + if (ret < 0) { >> + dev_err(bus->dev, "Disable port(s) failed: %d\n", ret); >> + return ret; >> + } >> + } >> + >> + return 0; >> } >> >> /** >> -- >> 2.20.1 >> >