Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1941697rdb; Thu, 7 Dec 2023 13:12:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwcEBIYS7CPtrvETP4fbjLmnsjRMyfnS9aJeR+yaUUGE6T2v1wGRww0ArA8VkNtBM+Cn3Q X-Received: by 2002:a05:6a21:3102:b0:18f:97c:ba21 with SMTP id yz2-20020a056a21310200b0018f097cba21mr3913295pzb.123.1701983551720; Thu, 07 Dec 2023 13:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701983551; cv=none; d=google.com; s=arc-20160816; b=PqvjJjR6fT9BkdYlzYK9Uxu05wCvuKo3i7/NKai48mXuY5m6oTjmJe/M1ZM6G+cHug y+JD2ClgFvKUQow5WmWVyaGci/e+MECP8AD4dSZgAbJuGmbsyvd7vJH8Sd7jdcxSkHM7 NkO1Oco10rtwMofXqa59up30c6FVKEwqMLjMHMmz5+CGyMtGPptIdgJHqH3dJeNNwDZE s7oDcoX1i1aV+jWLFxUTRtkh6qNOBdInskB4lfELuwdYPbhlCPparm7fR500gOMiAnd1 PCAMsD31rjB9aFGhWaE7cbLikE5vCEgWiOdimIn4DHJfYJuUnVWfymM6cG1goGcE7VJB hgJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=BSRQxy5psYH5uD20R/p7gyihApNzq/uoFheJqEixpAs=; fh=ZR6V6D2WU0zyIjfQPX7YfmWZmlvbVzl0m0Qi5vpsgvY=; b=Ip0CPM6lrl+q/+GVpqjhOGiJE5jbWfsfUlB90GWS3YcNrQOk2x9zu3IfQ9lWbmQhxC NNEjHTB1X7/uJgSyEjzX+RsvnNBf3tjAn4nND/s2/9eX81+4xjhtbmcsVgmWAl6yDZn9 AYe9Fbk2Dog+Xs7r+FN7x4vAPWdruE/Y6uqQKImDmWggzyA+N5pIvvdGUai8v/aJj6Yn 47ANF6NgdCJk6+LbNo4Exkqt1qSc8UZTKvWxoT356qUzBA4plihMpofJ86cKzkQ2HpDN 1or/uu4YZnGVTJ3YiJx6WogS9P7GLvwdfFsBmsBF1gF9MWB+LxztKXo+zv2RuPDu/WBb CDEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q7-20020a17090a2dc700b00286b6bfe6dcsi1709785pjm.0.2023.12.07.13.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 13:12:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E2E518098FEE; Thu, 7 Dec 2023 13:12:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231699AbjLGVMO convert rfc822-to-8bit (ORCPT + 99 others); Thu, 7 Dec 2023 16:12:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjLGVMM (ORCPT ); Thu, 7 Dec 2023 16:12:12 -0500 Received: from irl.hu (irl.hu [95.85.9.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 204AFE9 for ; Thu, 7 Dec 2023 13:12:18 -0800 (PST) Received: from [192.168.2.4] (51b690cd.dsl.pool.telekom.hu [::ffff:81.182.144.205]) (AUTH: CRAM-MD5 soyer@irl.hu, ) by irl.hu with ESMTPSA id 00000000000718A4.000000006572352F.0011AF64; Thu, 07 Dec 2023 22:12:15 +0100 Message-ID: Subject: Re: [PATCH 03/16] ASoC: tas2781: disable regmap regcache From: Gergo Koteles To: Mark Brown Cc: Shenghao Ding , Kevin Lu , Baojun Xu , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Date: Thu, 07 Dec 2023 22:12:13 +0100 In-Reply-To: <5f3f0306-799f-4f3b-9e05-fbd300c59d5d@sirena.org.uk> References: <21a183b5a08cb23b193af78d4b1114cc59419272.1701906455.git.soyer@irl.hu> <0b836c10-b21b-4275-8dd0-254dd5467497@sirena.org.uk> <47097f19398808b64f4cc87c2a3c7cc462fb2416.camel@irl.hu> <5f3f0306-799f-4f3b-9e05-fbd300c59d5d@sirena.org.uk> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.50.1 (3.50.1-1.fc39) MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 07 Dec 2023 13:12:29 -0800 (PST) On Thu, 2023-12-07 at 20:36 +0000, Mark Brown wrote: > On Thu, Dec 07, 2023 at 09:19:34PM +0100, Gergo Koteles wrote: > > On Thu, 2023-12-07 at 18:20 +0000, Mark Brown wrote: > > > On Thu, Dec 07, 2023 at 12:59:44AM +0100, Gergo Koteles wrote: > > > > > The amp has 3 level addressing (BOOK, PAGE, REG). > > > > The regcache couldn't handle it. > > > > So the books aren't currently used so the driver actually works? > > > It writes to the book 0 and 8c. The initialization works with regcache, > > because it writes also the i2c devices. > > I can't see any references to 0x8c in the driver? The firmware has different programs. The programs have blocks, that the driver writes to the amplifier. The address comes from the blocks. > > > > > static int tas2781_system_suspend(struct device *dev) > > > > @@ -770,10 +758,7 @@ static int tas2781_system_suspend(struct device *dev) > > > > return ret; > > > > > > > > /* Shutdown chip before system suspend */ > > > > - regcache_cache_only(tas_priv->regmap, false); > > > > tasdevice_tuning_switch(tas_priv, 1); > > > > - regcache_cache_only(tas_priv->regmap, true); > > > > - regcache_mark_dirty(tas_priv->regmap); > > > > How can this work over system suspend? This just removes the cache with > > > no replacement so if the device looses power over suspend (which seems > > > likely) then all the register state will be lost. A similar issue may > > > potentially exist over runtime suspend on an ACPI system with > > > sufficiently heavily optimised power management. > > > In runtime_resume, only one of the two amplifiers goes back. > > The runtime_suspend sets the current book/prog/conf to -1 on all > > devices, and tas2781_hda_playback_hook will restore the > > program/configuration/profile with tasdevice_tuning_switch. > > What does "go back" mean? Sorry for imprecise wording. The speaker is silent, I didn't checked why, maybe the amp is in error state or something. > > > And only one, because tasdevice_change_chn_book directly changes the > > address of i2c_client, so the unlucky one gets invalid values in its > > actual book from regcache_sync. > > The code creates the impression that writing to one tas2781 writes to > all of them, is that not the case? > Yes, the tasdevice_* functions, but the regcache_sync doesn't know this. > > system_restore doesn't work at all, because regcache_cache_only stays > > true since system_suspend. > > Presumably the next runtime resume would make the device writable again? > Yes, then one of the speakers works. > > It works without the regcache functions. > > How would the devices get their configuration restored? > tasdevice_tuning_switch calls tasdevice_select_tuningprm_cfg which checks whether the devices needs a new program or configuration. the runtime_suspend and system resume set the devices cur_prog, cur_conf to -1. for (i = 0; i < tas_hda->priv->ndev; i++) { tas_hda->priv->tasdevice[i].cur_book = -1; tas_hda->priv->tasdevice[i].cur_prog = -1; tas_hda->priv->tasdevice[i].cur_conf = -1; } And the tasdevice_select_tuningprm_cfg checks with if (tas_priv->tasdevice[i].cur_prog != prm_no ... If needed, it writes the new program/configuration to the device. The tas2781_hda_playback_hook calls the tasdevice_tuning_switch > This sounds very much like a case of something working for your specific > system in your specific test through some external factor rather than > working by design, whatever problems might exist it seems fairly obvious > to inspection that this patch would make things worse for other systems. > > At a minimum this patch needs a much clearer changelog (all the patches > I looked at could use clearer changelogs) which explains what's going on > here, I would really expect to see something that replaces the use of > the cache sync to restore the device state for example.