From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE987C2D0A3 for ; Sun, 1 Nov 2020 20:56:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8754B221FC for ; Sun, 1 Nov 2020 20:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604264205; bh=dsMa3TCXszWbvbRQc/KWBwFjksO2n2oX+X3UrQ9io1U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=PaBREg1UwVZfwuAxZGS5Kz64t9libGDuZLjfNVXFHSGOxo2lvg3QegL+ueBlYPfCp bojk7VuafHlr6nO4XORwTrj7DLt/pcoHQIjMyDJo6xQ2hzOPJ4v9Zs4HaR8IttTMpE M34kMCY+zQqg+RjxERPNiKuA8w/iDD+3RTIwypLI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726873AbgKAU4p (ORCPT ); Sun, 1 Nov 2020 15:56:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:38544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726848AbgKAU4o (ORCPT ); Sun, 1 Nov 2020 15:56:44 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B09A21556; Sun, 1 Nov 2020 20:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604264204; bh=dsMa3TCXszWbvbRQc/KWBwFjksO2n2oX+X3UrQ9io1U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KJsZBsocwXu53N4e5mNzaArw8JTfUvh7dgrhY4Q+U5K4grQ/wAQ2W3cflw9SLhjtx oMynnfwTUmWkUfjcQ8r/kir7DCYFC6hjDT1jrOuXeAJGQ3UNoi93+PCGc+n7RFuePi tGprF6eSVR+VOO0mUZnLnKDyH+ljFw4EopjKIksY= Date: Sun, 1 Nov 2020 20:56:40 +0000 From: Jonathan Cameron To: Lorenzo Bianconi Cc: lorenzo.bianconi@redhat.com, linux-iio@vger.kernel.org Subject: Re: [PATCH v2] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout Message-ID: <20201101205640.1fbbceaa@archlinux> In-Reply-To: References: X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Sun, 1 Nov 2020 17:21:18 +0100 Lorenzo Bianconi wrote: > Set 10ms as minimum i2c slave configuration timeout since st_lsm6dsx > relies on accel ODR for i2c master clock and at high sample rates > (e.g. 833Hz or 416Hz) the slave sensor occasionally may need more cycles > than i2c master timeout (2s/833Hz + 1 ~ 3ms) to apply the configuration > resulting in an uncomplete slave configuration and a constant reading > from the i2c slave connected to st_lsm6dsx i2c master. > > Fixes: 8f9a5249e3d9 ("iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors") > Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support") > Signed-off-by: Lorenzo Bianconi Applied and marked for stable. Thanks, Jonathan > --- > Changes since v1: > - improve commit log > - add missing Fixes tags > --- > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c > index 8c8d8870ca07..99562ba85ee4 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c > @@ -156,11 +156,13 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { > static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw) > { > struct st_lsm6dsx_sensor *sensor; > - u32 odr; > + u32 odr, timeout; > > sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]); > odr = (hw->enable_mask & BIT(ST_LSM6DSX_ID_ACC)) ? sensor->odr : 12500; > - msleep((2000000U / odr) + 1); > + /* set 10ms as minimum timeout for i2c slave configuration */ > + timeout = max_t(u32, 2000000U / odr + 1, 10); > + msleep(timeout); > } > > /*