Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp753236pxb; Thu, 30 Sep 2021 16:57:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyHmK9soCn565h4qqLZTSm8BFcoPuU2/2USiWgZKJFWdqBC0tssaWEbCAaqZqWfmB5ebn6 X-Received: by 2002:a17:903:208a:b0:13e:2dcd:f4de with SMTP id d10-20020a170903208a00b0013e2dcdf4demr6658378plc.80.1633046222846; Thu, 30 Sep 2021 16:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633046222; cv=none; d=google.com; s=arc-20160816; b=ccUj1H77AZ/TPUCDEqDqX2rrIR0WSNLlFxkaS1I9jMS/tv6yeZwSNqyaNUoMk0Ejz8 klfFWQA60d8U6qOFLfczaJQlyJmk3fY90dTPHgtcvJc6JFQG4SgLjdri6bovw2fdGNbP GhxfpxSn2oZRhZODd5QtL3h6fU0fMxJma0RJmxeONY/tTiWFlGgV5DnKW1tSB8SDwD7Q ah25hCCkx1iQ1mixSzrdqxzY2wP2MLm0skDw1ol96sWmVT2B0CAPusCT3On8+e0RT+rG /Zitrxb2OVkdh0g5sv5Cz6nf27SmaZADD1d6exEKHh9pE/dDYeRw6SobIzNh8ZbFBPyX MCxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=nYmfd2dluEWzPcEWiLNOUUmO0HLa5wXNfxqFlDr1yWs=; b=a/T9IkrYBOnV6LE1FEx+ODGQzZDqiNCCu4jQZePhwUor1EzUbL5oAlTaASR/2wX+F9 3DQKnwSshzf4LtTPovofQOFtmAlI8jJAhj+LWgoXT4H/Yb0cezZO/lH/keS9hFD9/1em P5LxuQOrRhkKhsWn7V1WhUdLBKwENu4XyoXXLROOrmMQUyVzXYK+TpITmgP2gQ//yr8D OeA+RIevr0qlGMQKeyyJbiWAEs7GOepeFNpVCR+ts4AsEOMItdNBBV+BzoEZc44C5njA jTzh80qb3cfZAHQYyzrM/B0gOCtmeVmCLyfZBs3WOJoMkICNJlbBgWnYsCaSUsG/sGhf X74w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id pf11si8373183pjb.30.2021.09.30.16.56.48; Thu, 30 Sep 2021 16:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1350540AbhI3Xz0 (ORCPT + 99 others); Thu, 30 Sep 2021 19:55:26 -0400 Received: from mga11.intel.com ([192.55.52.93]:9674 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230218AbhI3XzZ (ORCPT ); Thu, 30 Sep 2021 19:55:25 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10123"; a="222118539" X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="222118539" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 16:53:42 -0700 X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="521394356" Received: from lcalx-mobl1.amr.corp.intel.com (HELO [10.212.88.180]) ([10.212.88.180]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 16:53:41 -0700 Subject: Re: [EXTERNAL] Re: [PATCH] ASoC: max98373: Mark cache dirty before entering sleep To: Ryan Lee , Mark Brown Cc: "lgirdwood@gmail.com" , "perex@perex.cz" , "tiwai@suse.com" , "yung-chuan.liao@linux.intel.com" , "guennadi.liakhovetski@linux.intel.com" , "alsa-devel@alsa-project.org" , "linux-kernel@vger.kernel.org" , "sathya.prakash.m.r@intel.com" , "ryan.lee.maxim@gmail.com" References: <20210924221305.17886-1-ryans.lee@maximintegrated.com> <1b21bbf1-12c7-726d-bff8-76ec88ff8635@linux.intel.com> <20210927160622.GE4199@sirena.org.uk> <7b8c3875-3f12-f3cb-7da8-4e850e59ee2b@linux.intel.com> From: Pierre-Louis Bossart Message-ID: <15dd3868-7023-67c2-991c-a0083f59f0b5@linux.intel.com> Date: Thu, 30 Sep 2021 18:53:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > I tried to find the reason why the amp was not detached from the bus properly and > found information about CLOCK_STOP_NOW bit in 0x0044 SCP_Ctrl register. > It seems like 0x2(ClockStopNow) needs to be configured before the host CLOCK STOP. > I was able to get a good result if I add this command in the amp driver suspend function. > The amp driver receives the detachment event and register restoration was done properly > after the audio resume. > I can modify the amp driver for this change but it looks like this needs to be done > from the host side. May I have a comment on this? Thanks. This register is already taken care of in drivers/soundwire/intel.c and cadence_master.c for pm_runtime suspend, the sequence uses sdw_cdns_clock_stop(), which will try and prepare devices for clock-stop with a callback, in case any imp-def registers is required, then it will call sdw_bus_clk_stop() which does a broadcast write: sdw_bus_clk_stop(struct sdw_bus *bus) { int ret; /* * broadcast clock stop now, attached Slaves will ACK this, * unattached will ignore */ ret = sdw_bwrite_no_pm(bus, SDW_BROADCAST_DEV_NUM, SDW_SCP_CTRL, SDW_SCP_CTRL_CLK_STP_NOW); if (ret < 0) { if (ret != -ENODATA) dev_err(bus->dev, "ClockStopNow Broadcast msg failed %d\n", ret); return ret; } The codec driver is not supposed to set this bit on its own, what this indicates is that the clock will actually stop at the end of the frame. Only the master/controller driver can transmit this - there's a very strong reason why its a bus functionality. The other point is that on pm_runtime resume, the Intel host will start a SEVERE_RESET sequence. That's a bit different from the 'traditional' description of the clock stop due to a power optimization on the Intel side (see more below), but doing a reset has precedence over any other configuration that might have happened before the clock stopped so the amplifier SHALL transition to UNATTACHED on a reset. Somehow it looks like the amplifiers don't see the clock stopped and don't see the reset, that's rather surprising. If this happens for system suspend/resume, then it's a different story: we don't use the clock stop mode at all, the bus will be completely reconfigured. You could try to see if the results change by using the 'traditional' clock stop mode with a kernel module parameters option snd-sof-intel-hda-common sdw_clock_stop_quirks=0 the default is SDW_INTEL_CLK_STOP_BUS_RESET /* * Require a bus reset (and complete re-enumeration) when exiting * clock stop modes. This may be needed if the controller power was * turned off and all context lost. This quirk shall not be used if a * Slave device needs to remain enumerated and keep its context, * e.g. to provide the reasons for the wake, report acoustic events or * pass a history buffer. */ #define SDW_INTEL_CLK_STOP_BUS_RESET BIT(3) In this case, the bus will not be reset, I wonder if this is the part that's problematic for the amplifier. Hope this helps -Pierre