Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1270101pxa; Thu, 20 Aug 2020 07:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtpk2nJvlEoEULAVKNwH0yyqeKyB//x2L4uM/KXuEpzouf68qGW33L8OMWTZo2wDFp9te1 X-Received: by 2002:a05:6402:b99:: with SMTP id cf25mr2945756edb.340.1597932709677; Thu, 20 Aug 2020 07:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597932709; cv=none; d=google.com; s=arc-20160816; b=VXnUObtO9iZI1Vn/alv1TLgC9C/ooZlmiqZvzRioHXg9kMYhwHnrQA15SWBjkDlJ8f 2RsUKF0u42A6OiUQiQg9n1OlOBTC/8mg05ZjcyIVkOCf699NdyLO3bWRNsLisD7Fqkuj 9rO4VF72M34Pfotf+f8hGyctSrB4Tsjvi3GopihjQdc5+xfeE1PE4Vk/9DOdosBYRLeQ 29IwAByIul6hgOgalfUsFzn9fvEBFvKlAW2qIXWxEwH+aGPJSq42B+MZSF/f8O7S91kw Nj51zs75qQ3pso9DhAB2sIBNAlO7nTVH/vwi7mAAObR3lGJ0l3qSos5p6JLJpSL9ASeO A7ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ws/YWDH5qzIAMcq4Sl2n0t9AdM1v8Qr0u/xuG8Xw5ck=; b=jpq4hO/bpe4VwPOY03CyE3MliZ8LkmQmH2igw0nKUg5dXIG5lQOuRlO5h6J14WHPaG Ro5M3s5sR7gII/TlISvwp0I49C1xsntU+qDyvOAUxdgsV0GuNna1Pum91FOia6jm3gkE cwWZMsiPOl0JJ3dNQgosa1VvVUM66fPspBYAu3paPtDNI8VWlL1cKQVEcQwtNpoa2MMT kI9n2da8z+8lecMLBFKocTWpCyrkHivo60MYGbA71pU+ykXvr9SxEL2d25RJlkdUge6j hKmRhk01fvAswNRp0326tKfBcvJOkZh0u+f1OUWnYLOjAB4t8OY9TPVZMIty7q6oooiQ x54w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HJGmxLDP; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si1250795ejj.573.2020.08.20.07.11.25; Thu, 20 Aug 2020 07:11:49 -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=@kernel.org header.s=default header.b=HJGmxLDP; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729258AbgHTN5a (ORCPT + 99 others); Thu, 20 Aug 2020 09:57:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:34302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbgHTJZo (ORCPT ); Thu, 20 Aug 2020 05:25:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 023312075E; Thu, 20 Aug 2020 09:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915528; bh=eoztplTus6nq3nSYjpveHlTWmwLp66x9zB5eAk6dUkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HJGmxLDP8PmdO7AZM9E/rS/TYSBRglWqtEl3tmtBoBUO2QWhwmumgK1ELnV1JMm1Q w/6vn6bR0XHWXnTqkz3z2l7+0X3iIJLei+2BNoZPfx3jbxPIsMppyHnR7r8KBIzbRw MW5/u2gz2GWpJyQXs/Dzvs5vZf68PnYzZ6bZT4vw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Nyekjaer , Lorenzo Bianconi , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.8 046/232] iio: imu: st_lsm6dsx: reset hw ts after resume Date: Thu, 20 Aug 2020 11:18:17 +0200 Message-Id: <20200820091615.011803854@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi commit a1bab9396c2d98c601ce81c27567159dfbc10c19 upstream. Reset hw time samples generator after system resume in order to avoid disalignment between system and device time reference since FIFO batching and time samples generator are disabled during suspend. Fixes: 213451076bd3 ("iio: imu: st_lsm6dsx: add hw timestamp support") Tested-by: Sean Nyekjaer Signed-off-by: Lorenzo Bianconi Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 +-- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 23 +++++++++++++++-------- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -436,8 +436,7 @@ int st_lsm6dsx_update_watermark(struct s u16 watermark); int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable); int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw); -int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, - enum st_lsm6dsx_fifo_mode fifo_mode); +int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u32 odr, u8 *val); --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -184,8 +184,8 @@ static int st_lsm6dsx_update_decimators( return err; } -int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, - enum st_lsm6dsx_fifo_mode fifo_mode) +static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, + enum st_lsm6dsx_fifo_mode fifo_mode) { unsigned int data; @@ -302,6 +302,18 @@ static int st_lsm6dsx_reset_hw_ts(struct return 0; } +int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw) +{ + int err; + + /* reset hw ts counter */ + err = st_lsm6dsx_reset_hw_ts(hw); + if (err < 0) + return err; + + return st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT); +} + /* * Set max bulk read to ST_LSM6DSX_MAX_WORD_LEN/ST_LSM6DSX_MAX_TAGGED_WORD_LEN * in order to avoid a kmalloc for each bus access @@ -675,12 +687,7 @@ int st_lsm6dsx_update_fifo(struct st_lsm goto out; if (fifo_mask) { - /* reset hw ts counter */ - err = st_lsm6dsx_reset_hw_ts(hw); - if (err < 0) - goto out; - - err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT); + err = st_lsm6dsx_resume_fifo(hw); if (err < 0) goto out; } --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2458,7 +2458,7 @@ static int __maybe_unused st_lsm6dsx_res } if (hw->fifo_mask) - err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT); + err = st_lsm6dsx_resume_fifo(hw); return err; }