Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20088027ybl; Sat, 4 Jan 2020 17:07:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwsreF3ExcfTEU4XXiglF4Mc9syNc+mb9gK27MPAmdFep9FfWil57PqxieVtsaGPRSAPVph X-Received: by 2002:a05:6830:144d:: with SMTP id w13mr6110354otp.235.1578186472023; Sat, 04 Jan 2020 17:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578186472; cv=none; d=google.com; s=arc-20160816; b=qQ0T22aROkTQot2YQZBiWbKBJsQAnvF2nM2ZvhxavKu+68w8+y7fDKadRVLZZtOeVA CZk4o3NWMmaSbxwaD6e2mcNA7OTFw4p0bccN3HIaOuP+/6js6ZLZmOxJCWQkSshL6Mev lHka8RgeWEu0rKwNIagT6THgx5KZ4+R/duEE3TFTGjcLhlTWXLrcaLnloXPt/C4I2k6n msD0/S2k+IN3rwiCHoo22ZHhoHQz0n8x5h6DSFJou8gHJP9RL0e7C+yce+y8iMBeamI9 5x2Iyhp+SA3fLh7j8LlWalSUsjTVsCY3xqeBzxuul6KPrhbG7W8sQrbdP6ZZWgoilSdb kmaw== 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:dkim-signature; bh=by4tfSoTAV+JLschlMD5HX37YOQ4eMnDIxNMWutbetQ=; b=OkagRQhWGvPaJKIU/ODYqMtPdFoheVLViXr2uCEj8k+QvvMT+Pz/CD3nICkw4jbtwd ioTq2S2Ep7sNoEt2tmPIRvp1Sjb3TvNHXEiM28q1ieax7HOl1Y9Vpn6M6cZuBsUbpxMd EQMvBFogigjJksaaV/3t/0BOkYEUIcTlDTG5DCIoyg4gy5UFtg7Xw7+uO/WjH56/a7qU 4KjlAqC2RvlOccjo6Yq5DMESwB8oRyhNGm8nFLR9FBZS5664tYsN8KWX7yfkOV1UpZ9j F2bgDdc8Yq64g6XKBPgkS8S+9Rb3/L5znlrR8Wm2Yp//pLJVlSmjm5tlwLpYBadRIcEK HWvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TBXFdNMs; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n85si30433881oig.191.2020.01.04.17.07.37; Sat, 04 Jan 2020 17:07:52 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=TBXFdNMs; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726383AbgAEBFm (ORCPT + 99 others); Sat, 4 Jan 2020 20:05:42 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:41439 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgAEBFl (ORCPT ); Sat, 4 Jan 2020 20:05:41 -0500 Received: by mail-lj1-f193.google.com with SMTP id h23so47424247ljc.8; Sat, 04 Jan 2020 17:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=by4tfSoTAV+JLschlMD5HX37YOQ4eMnDIxNMWutbetQ=; b=TBXFdNMs3yzXw1YnMJXgTBQFJXButI5L+HdktNwol6APbVGK7EZTS1tNN0nYoGxrq3 TkfXqOKziqWaka3isjmK2HFTl2VhSo53vTy+1d/9JZF5alXIeuaDVCm5d4J7BFV8VKlI etVU6iNQ0cxHxfnhJoKdDFRhdmkalGLtwDHGztzJCMN5HL9f22cDXx0bVK/Rchl+H41+ Tf2L1b2kSaaqhEbH/F93gTPFP4HJlOun+N2g6P8C1nvFv3rS05UYm4z9L6xaml12lp8t IQKJu3IDnabjapsewEM9VY7uJbjLzbuHOj3K61nEPhcAjV749IB5J7cpfrBPgd/SGZt3 DW8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=by4tfSoTAV+JLschlMD5HX37YOQ4eMnDIxNMWutbetQ=; b=BEuZ497Lwa+0QJxyhpMgTXLLbwGJC+EPdvFi0njOdSKffo10iaY4PhJqynAgJrj15B 3Fmfdo7mx9ub+TmIOFSZAHNsjxSOJtx6jHtw13dmE7EQgKNJsM4M2s1qCwndIj7p1MUM DcS7tbgt0US1gJhrQNhiroDTMPHIqNReRt3/rQHqR+/1cMTKJTpK8f78WKmj6KxDt9MX +6Gs3Q7NCBWGLyt5hMFe8kXM5Z+MeEwqWNB5CgnjulgF7FjIx52eWXUwrUZQfoRa+t0+ LqIfDReiBPDeUINzbh1IGFoQBi9PkGdz04b++yo2BNuwFNeAIyMLcc6xNULo05HQ0xDT F+hg== X-Gm-Message-State: APjAAAUJfEHCX5rwtwWsojzutmSFWEckAzpk44Vv0gVtI8S/7if4M5Jj dnR+C8mFIlBtycFMJr0H8R4V32+R X-Received: by 2002:a2e:9a51:: with SMTP id k17mr52823683ljj.206.1578186337852; Sat, 04 Jan 2020 17:05:37 -0800 (PST) Received: from [192.168.2.145] (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.googlemail.com with ESMTPSA id q26sm26874979lfc.52.2020.01.04.17.05.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 04 Jan 2020 17:05:37 -0800 (PST) Subject: Re: [PATCH v5 12/19] ASoC: tegra: Add initial parent configuration for audio mclk To: Sowjanya Komatineni , Mark Brown Cc: thierry.reding@gmail.com, jonathanh@nvidia.com, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, mperttunen@nvidia.com, gregkh@linuxfoundation.org, sboyd@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, pdeschrijver@nvidia.com, pgaikwad@nvidia.com, spujar@nvidia.com, josephl@nvidia.com, daniel.lezcano@linaro.org, mmaddireddy@nvidia.com, markz@nvidia.com, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org References: <1576880825-15010-1-git-send-email-skomatineni@nvidia.com> <1576880825-15010-13-git-send-email-skomatineni@nvidia.com> <20191225175736.GC27497@sirena.org.uk> <856d8a92-0c24-6722-952c-06b86c706e97@gmail.com> <576fca44-6734-5431-b523-512747a0bf12@gmail.com> From: Dmitry Osipenko Message-ID: <0f956c12-98cf-3466-f3ee-ffc3a23e3e3d@gmail.com> Date: Sun, 5 Jan 2020 04:05:36 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 04.01.2020 08:49, Sowjanya Komatineni пишет: > > On 1/2/20 8:12 AM, Dmitry Osipenko wrote: >> 02.01.2020 10:03, Sowjanya Komatineni пишет: >>> On 12/27/19 1:19 PM, Sowjanya Komatineni wrote: >>>> On 12/27/19 6:56 AM, Dmitry Osipenko wrote: >>>>> 25.12.2019 20:57, Mark Brown пишет: >>>>>> On Mon, Dec 23, 2019 at 12:14:34AM +0300, Dmitry Osipenko wrote: >>>>>>> 21.12.2019 01:26, Sowjanya Komatineni пишет: >>>>>>>> Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 >>>>>>>> through Tegra210 and currently Tegra clock driver does initial parent >>>>>>>> configuration for audio mclk "clk_out_1" and enables them by default. >>>>>> Please delete unneeded context from mails when replying.  Doing this >>>>>> makes it much easier to find your reply in the message, helping ensure >>>>>> it won't be missed by people scrolling through the irrelevant quoted >>>>>> material. >>>>> Ok >>>>> >>>>>>>> -    clk_disable_unprepare(data->clk_cdev1); >>>>>>>> -    clk_disable_unprepare(data->clk_pll_a_out0); >>>>>>>> -    clk_disable_unprepare(data->clk_pll_a); >>>>>>>> +    if (__clk_is_enabled(data->clk_cdev1)) >>>>>>>> +        clk_disable_unprepare(data->clk_cdev1); >>>>>>> The root of the problem is that you removed clocks enabling from >>>>>>> tegra_asoc_utils_init(). >>>> currently, audio mclk and its parent clocks enabling are from clock >>>> driver init and not from tegra_asoc_utils_init. >>>>>>> I'm not sure why clocks should be disabled during the rate-changing, >>>>>>> probably this action is not really needed. >>>>>> I know nothing about this particular device but this is not that >>>>>> unusual a restriction for audio hardware, you often can't >>>>>> robustly reconfigure the clocking for a device while it's active >>>>>> due to issues in the hardware.  You often see issues with FIFOs >>>>>> glitching or state machines getting stuck.  This may not be an >>>>>> issue here but if it's something that's documented as a >>>>>> requirement it's probably good to pay attention. >>>>> I don't know details about that hardware either, maybe it is simply not >>>>> safe to change PLL_A rate dynamically and then CLK_SET_RATE_GATE could >>>>> be used. >>>>> >>>>> If nobody knows for sure, then will be better to keep >>>>> tegra_asoc_utils_set_rate() unchanged. >>>> plla rate change through tegra_asoc_utils_set_rate() happens only when >>>> there is not active playback or record corresponding to this sound >>>> device. >>>> >>>> So, I don't see reason for disabling clock during rate change and not >>>> sure why we had this from the beginning. >>>> >>>> Thierry/Sameer, >>>> >>>> Can you please comment? >>>> >>>> Yes, we can use CLK_SET_RATE_GATE for PLLA and remove clock disabling >>>> before rate change. >>>> >>> PLLA is used for both I2S controller clock and also for audio mclk. I2S >>> driver suspend resume implementations takes care of enabling and >>> disabling I2S clock but audio mclk will be enabled during that time and >>> PLLA disable might not happen. So using CLK_SET_RATE_GATE prevents rate >>> change to happen and as rate change happens only when there is no active >>> audio record/playback, we can perform rate change without disable/enable >>> during rate change. >>> >>> So probably below changes should be good. >>> >>> * remove asoc_utils_set_rate call from asoc_utils_init as set_rate >>> happens during existing hw_params callback implementations in sound >>> drivers and there is no need to do rate change during asoc_utils_init. >>> * remove disable/enable clocks during rate change in asoc_utils_set_rate. >>> * add startup and shutdown snd_soc_ops callbacks to do enable and >>> disable audio mclk. >>> >> Sounds good, thanks. I'll be happy to review and test it. > > Regarding disabling audio mclk during PLLA rate change, no need to > explicitly disable PLLA on asoc utils as clock driver takes care of it > properly during pll rate change. > > But the downstream clock divider hardware can malfunction without > recovery when subject to unstable PLL output during locking, unless > clock is gated. > > So it is recommended to disable downstream clocks during PLL rate change. > > PLLA downstream clocks are I2S and audio mclk (cdev1/clk1 and extern1 > clocks) and I2S clock is disabled in I2S driver by PM runtime ops. The I2S driver uses asynchronous pm_runtime_put() and thus there is no guarantee that I2S clock is disabled at the time of changing PLLA rate. Could this be a problem? > For audio mclk, need to make sure mclk are disabled during rate change. > > So below are the changes to audio clocks that will be in next version. > > * remove tegra_asoc_utils_set_rate call from tegra_asoc_utils_init as > tegra_asoc_utils_set_rate happens during hw_params callback. > * add shutdown snd_soc_ops callbacks to disable of audio mclk. > * remove disable audio mclk (cdev1) and plla clocks prior to rate > change in tegra_asoc_utils_set_rate (as audio mclk will always be in > disabled state every time hw_param callback gets executed) and keep > audio mclk enable after the rate change in tegra_asoc_utils_set_rate. >