Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp753163pxy; Sun, 1 Aug 2021 01:04:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDVQkMoMuo6Bi28PXNumBHZkf9ZBQEgp13szZf56xJzaMW7Ekk3z6G3vS47xRs44BpkokX X-Received: by 2002:a5d:87d0:: with SMTP id q16mr8266316ios.109.1627805098082; Sun, 01 Aug 2021 01:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627805098; cv=none; d=google.com; s=arc-20160816; b=rQIbmDIcLCUiFyHi/biXoGlmG7y+T5Lz0jryJoGNxeTsJSiYQRlx9QUHfS1HCqteMv X8MTEKvxnBiJooRXvIAYnQLbm/RgSZTiS+t2MKSQmL6UaaR2vkWJEYkxs7pAIDqNUaFZ LAimQXWI7MXLRYPoHsM5eGehw3z/NWurK3OEDKUzWsLhLeIe2/VqNGEr/64CSFcKUstS gC3F73iBoihicHpUZ1uZnxWMxSg59V5Ri/T9lSu44LP6OSPHkvjiRSNWyazjAWRb3e3U b/W6uR9pCJaSBIyvJuSqkw+4skHea4l0D+14dcy9bLflNjkvhDH29ZhM8OoAUXLg0/oI traQ== 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:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=iUnvT3yBk3Ak2FNUwjA/dYWqqudAaqfeubdq+0me75I=; b=A/s8Lnig3A0XjMAgxzWXvlLwKrIsUM6rjuXNxqnImf26nEpLU7zu9lkAiQjvG3oJDb GADL07cS2wFUjU6/bm/txuhOSgRxHg4sOumhmJSgXgBJJW52BGiPwDauoQ1SQjChn2TX 3Xl2LEKb09xwOXP8DfYaWvlIeK8Wu1MREcWhtICL/FJa8MNh4ETZUwa78/N05uoBynQG N+k3RepIau390+EOnK2eFnV3MWXPGCWH5EtEt8aE2UT/05tC0qwxEyKKf34ZUFnYsTt7 PeFmC8oN9sG+LoCy38fWYikOkSvgxt+LI4sdeC6aN0OtiT3i0pkAFyheszWqTFiouBP3 jxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Bz8m1F01; dkim=neutral (no key) header.i=@suse.de; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si9938028ilu.53.2021.08.01.01.04.44; Sun, 01 Aug 2021 01:04:58 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Bz8m1F01; dkim=neutral (no key) header.i=@suse.de; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbhHAIEE (ORCPT + 99 others); Sun, 1 Aug 2021 04:04:04 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:34252 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbhHAIEE (ORCPT ); Sun, 1 Aug 2021 04:04:04 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1AD0421FF9; Sun, 1 Aug 2021 08:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627805036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iUnvT3yBk3Ak2FNUwjA/dYWqqudAaqfeubdq+0me75I=; b=Bz8m1F01OxpMp2gtaAHvBzOJRO0HAy73WEx9xUN92Y/V0shSQYitGik1zp0Pscj/82IJGD wPRJF0usS7ouGAqkZzqy56xr1qh8JY4xXqwp2FQ6bVWRWukcVZONk6sknAXhBZDfazny/n EjYPz12++B1KbP0pNi0DEsb6RjzvbsE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627805036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iUnvT3yBk3Ak2FNUwjA/dYWqqudAaqfeubdq+0me75I=; b=qjaqYRQ2CFcwE1tIRHdsUZGIYL0YSKnwYCNppSWb1qukP9Heb67yHuL3zOWdxpIO0esjiA 4SLzjXqMVShi38Bg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 0774FA3BA8; Sun, 1 Aug 2021 08:03:56 +0000 (UTC) Date: Sun, 01 Aug 2021 10:03:55 +0200 Message-ID: From: Takashi Iwai To: Vitaly Rodionov Cc: Jaroslav Kysela , Takashi Iwai , , , , Lucas Tanure , Stefan Binding Subject: Re: [PATCH v3 13/27] ALSA: hda/cs8409: Dont disable I2C clock between consecutive accesses In-Reply-To: <20210730151844.7873-14-vitalyr@opensource.cirrus.com> References: <20210730151844.7873-1-vitalyr@opensource.cirrus.com> <20210730151844.7873-14-vitalyr@opensource.cirrus.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Jul 2021 17:18:30 +0200, Vitaly Rodionov wrote: > > From: Lucas Tanure > > Only disable I2C clock 25 ms after not being used. > > The current implementation enables and disables the I2C clock for each > I2C transaction. Each enable/disable call requires two verb transactions. > This means each I2C transaction requires a total of four verb transactions > to enable and disable the clock. > However, if there are multiple consecutive I2C transactions, it is not > necessary to enable and disable the clock each time, instead it is more > efficient to enable the clock for the first transaction, and disable it > after the final transaction, which would improve performance. > This is achieved by using a timeout which disables the clock if no request > to enable the clock has occurred for 25 ms. > > Signed-off-by: Lucas Tanure > Signed-off-by: Vitaly Rodionov > Signed-off-by: Stefan Binding > --- > > Changes in v2: > - Improved delayed work start/cancel implementation, and re-worked commit message > adding more explanation why this was required. > > Changes in v3: > - Cancel the disable timer, but do not wait for any running disable functions to finish. > If the disable timer runs out before cancel, the delayed work thread will be blocked, > waiting for the mutex to become unlocked. This mutex will be locked for the duration of > any i2c transaction, so the disable function will run to completion immediately > afterwards in the scenario. The next enable call will re-enable the clock, regardless. This looks almost fine, but just a couple of thoughts: - cancel_delayed_work_sync() means to it might keep the i2c enabled after that point (just cancel the pending work). Would it cause a inconsistency afterwards? - A similar procedure is needed for suspend callback to cancel / flush the work. The shutdown is another question, but usually it's fine to without any special handling as long as the resource is kept. thanks, Takashi