Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11717001ybi; Thu, 25 Jul 2019 22:22:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTmmRsFE9hSatEQXPnwm5PSDwz235QwgxVNxVeFKkTKzu+MNpaVT7UyDDCSOMaxfTZPY/7 X-Received: by 2002:a17:90a:2486:: with SMTP id i6mr95271359pje.125.1564118547184; Thu, 25 Jul 2019 22:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564118547; cv=none; d=google.com; s=arc-20160816; b=KJerBfDqUYmktGb5apB3KP+6NeaFyPlDwQPSCBkY/QyTFT6l1Zj3zQ5GlVIoPL+7jn i6VSCSTBC10M2Ib3lSCS70cJX/zTftcECRYdexfNKE2SQ/c7NIA/VSVsNsI2RcNm8OBm bA0pyaJqnoJ0447avkgnIg4M+2Al94HpJy122AXEmt98DXNDVrNyy/P6SqvQui6fZkRM eZlDnAJm9PyaVIMP9Ap0qlrz8ErkpjWNL/jR0AVeUCK5gRQVwcB+UBln6VuvkSXFdn2m 8AsG9iWWZ9qYaE6qiAweAacILMI2utUWE0NgwYwu/FO4L3Jo0XIfSlxmEXKSW+Svv/lo Js+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=uRaRxYRs3d1fqgSA5cpB4VnJJNTxEm58b5tmoc7Bj0I=; b=LPSszmZCyz2HIYzwhNJw7C7ptCMBj3+M9EXoijnXqZOwM+sQ+9Z7uuSnMXIlY3/9Xz lfCjY++6ffV76KSHT3q3J2gTRWfQZbYvl9rxA8gziP8T90O++0D6FoeiEZYtQpLO5uIf QiQAJqHbtEqngrsWCgOsoOC7/ITIoQ5PzZm3tsVqwoQ1MJ5jSRyOf+UlxGMq1bLe1TUr g0h/geaRk1UH3YyGjyj90t3PQOwmYgpJfFL/7KgUkXACvm+nMNh9oZToAgusNcO/Hgl8 vj+FQBjCT3OzcoSRDMRk9P6V5kmoeHyWj3CsAIOcqCNaJmn9laX7dq5PxpICM7Jf0c+p Ee8Q== 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 v4si10115362pgf.470.2019.07.25.22.22.11; Thu, 25 Jul 2019 22:22:27 -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 S1726065AbfGZFTz (ORCPT + 99 others); Fri, 26 Jul 2019 01:19:55 -0400 Received: from mga17.intel.com ([192.55.52.151]:9678 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbfGZFTz (ORCPT ); Fri, 26 Jul 2019 01:19:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2019 22:19:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,309,1559545200"; d="scan'208";a="369939671" Received: from yungchua-mobl.ccr.corp.intel.com (HELO [10.252.184.27]) ([10.252.184.27]) by fmsmga006.fm.intel.com with ESMTP; 25 Jul 2019 22:19:52 -0700 Subject: Re: [alsa-devel] [RFC PATCH 26/40] soundwire: cadence_master: fix divider setting in clock register To: Pierre-Louis Bossart , alsa-devel@alsa-project.org Cc: tiwai@suse.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, slawomir.blauciak@intel.com, Sanyog Kale , Rander Wang References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-27-pierre-louis.bossart@linux.intel.com> From: Bard liao Message-ID: Date: Fri, 26 Jul 2019 13:19:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190725234032.21152-27-pierre-louis.bossart@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/26/2019 7:40 AM, Pierre-Louis Bossart wrote: > From: Rander Wang > > The existing code uses an OR operation which would mix the original > divider setting with the new one, resulting in an invalid > configuration that can make codecs hang. > > Add the mask definition and use cdns_updatel to update divider > > Signed-off-by: Rander Wang > Signed-off-by: Pierre-Louis Bossart > --- > drivers/soundwire/cadence_master.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c > index 10ebcef2e84e..18c6ac026e85 100644 > --- a/drivers/soundwire/cadence_master.c > +++ b/drivers/soundwire/cadence_master.c > @@ -57,6 +57,7 @@ > #define CDNS_MCP_SSP_CTRL1 0x28 > #define CDNS_MCP_CLK_CTRL0 0x30 > #define CDNS_MCP_CLK_CTRL1 0x38 > +#define CDNS_MCP_CLK_MCLKD_MASK GENMASK(7, 0) > > #define CDNS_MCP_STAT 0x40 > > @@ -988,9 +989,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns) > /* Set clock divider */ > divider = (prop->mclk_freq / prop->max_clk_freq) - 1; > val = cdns_readl(cdns, CDNS_MCP_CLK_CTRL0); Do we still need to read cdns_readl(cdns, CDNS_MCP_CLK_CTRL0) after this change? > - val |= divider; > - cdns_writel(cdns, CDNS_MCP_CLK_CTRL0, val); > - cdns_writel(cdns, CDNS_MCP_CLK_CTRL1, val); > + > + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0, > + CDNS_MCP_CLK_MCLKD_MASK, divider); > + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1, > + CDNS_MCP_CLK_MCLKD_MASK, divider); > > pr_err("plb: mclk %d max_freq %d divider %d register %x\n", > prop->mclk_freq, > @@ -1064,8 +1067,7 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params) > mcp_clkctrl_off = CDNS_MCP_CLK_CTRL0; > > mcp_clkctrl = cdns_readl(cdns, mcp_clkctrl_off); Same here. > - mcp_clkctrl |= divider; > - cdns_writel(cdns, mcp_clkctrl_off, mcp_clkctrl); > + cdns_updatel(cdns, mcp_clkctrl_off, CDNS_MCP_CLK_MCLKD_MASK, divider); > > pr_err("plb: mclk * 2 %d curr_dr_freq %d divider %d register %x\n", > prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR,