From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754450AbbGPNMp (ORCPT ); Thu, 16 Jul 2015 09:12:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40671 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbbGPNMo (ORCPT ); Thu, 16 Jul 2015 09:12:44 -0400 Date: Thu, 16 Jul 2015 15:12:38 +0200 Message-ID: From: Takashi Iwai To: Nariman Poushin Cc: broonie@kernel.org, alsa-devel@alsa-project.org, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, peter.ujfalusi@ti.com, bardliao@realtek.com, lee.jones@linaro.org, laurent.pinchart+renesas@ideasonboard.com, sameo@linux.intel.com, patches@opensource.wolfsonmicro.com, Paul.Handrigan@cirrus.com, tony@atomide.com, lars@metafoo.de, dmurphy@ti.com, linux-omap@vger.kernel.org, oder_chiou@realtek.com, brian.austin@cirrus.com, support.opensource@diasemi.com, gregkh@linuxfoundation.org, dmitry.torokhov@gmail.com, lgirdwood@gmail.com Subject: Re: [alsa-devel] [PATCH 2/2] V4 regmap: Apply optional delay in multi_reg_write/register_patch In-Reply-To: <1436885152-19850-2-git-send-email-nariman@opensource.wolfsonmicro.com> References: <1436885152-19850-1-git-send-email-nariman@opensource.wolfsonmicro.com> <1436885152-19850-2-git-send-email-nariman@opensource.wolfsonmicro.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/24.5 (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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 14 Jul 2015 16:45:52 +0200, Nariman Poushin wrote: > > We treat a delay in a sequence the same way we treat a page change as > they are logically similar in that you can coalesce all write before > a delay (in the same way you can coalesce all writes before a page > change is needed) > > Signed-off-by: Nariman Poushin > --- > drivers/base/regmap/regmap.c | 65 ++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 59 insertions(+), 6 deletions(-) > > diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c > index 0a849ee..a67473c2 100644 > --- a/drivers/base/regmap/regmap.c > +++ b/drivers/base/regmap/regmap.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > #define CREATE_TRACE_POINTS > #include "trace.h" > @@ -47,6 +48,17 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg, > static int _regmap_bus_raw_write(void *context, unsigned int reg, > unsigned int val); > > +static void regmap_sequence_delay(unsigned int delay_us) > +{ > + /* For small delays it isn't worth setting up the hrtimers > + * so fall back on udelay > + */ > + if (delay_us < 10) > + udelay(delay_us); > + else > + usleep_range(delay_us, delay_us * 2); > +} I think usleep_range() can't be used for fast_io, which is performed inside a spinlock. And, the locking can't be known explicitly, e.g. the caller may set its own config->lock, so even the check for fast_io isn't enough. Takashi