From patchwork Wed Jul 11 15:26:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10520139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A601F603D7 for ; Wed, 11 Jul 2018 15:26:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B82B291D9 for ; Wed, 11 Jul 2018 15:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1D8729216; Wed, 11 Jul 2018 15:26:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 873A4291D9 for ; Wed, 11 Jul 2018 15:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732902AbeGKPbb (ORCPT ); Wed, 11 Jul 2018 11:31:31 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34760 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732535AbeGKPbb (ORCPT ); Wed, 11 Jul 2018 11:31:31 -0400 Received: by mail-wm0-f65.google.com with SMTP id s13-v6so15476133wmc.1 for ; Wed, 11 Jul 2018 08:26:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IpMf43SxHsU/P9Qv31ErjWzKL8cC6JYxVZgS5hKmCMc=; b=mEz8iKUAf9Ym8tC7I8ho4faYI6FuKxleGBCYGkFg5OWxpPSrHcmNUrlB1hMQzE08zk Su0M9ijX4e4Jf9u+3pyYSdE2N9lhy660JirxUrVrtcttho4gdxyY6mdwO926GeXvLgrh uRuyHVWoQ8lDzHbqHeyld9BdLnHXjvTBkkspoPIKQu81M0AdZ6/U8nmlTacThU2R1oDn miOcB1P4hLkh3IwoRSrEEpKv0oBpXeWAthzHOHNwZo/tfD5N8ElyB4hrX9NphzRGX2KO 1nHyexaQXS/jyORM1pQTNPUd1XRFZbUjny55QPbo2wi5Rmu2NyoeI2M/GjnxJmGsEAar xrqw== X-Gm-Message-State: APt69E1Q7eJI0WGpss93LO/9it0A/8DCUzwXvrlzxxYbZgu0odqOKPvc R1SjPpNZ50+myPc/gj5eM9Gor0xw/Kg= X-Google-Smtp-Source: AAOMgpfXmY9R6kx7MNgkYDsuaLLhy9U5qJXWaVqES6e/ehqg0Y+QWTl3Vie3gGCWH1yQvyRzOvdIfg== X-Received: by 2002:a1c:9616:: with SMTP id y22-v6mr18517050wmd.72.1531322798190; Wed, 11 Jul 2018 08:26:38 -0700 (PDT) Received: from localhost.localdomain (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id d102-v6sm4633569wma.10.2018.07.11.08.26.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 08:26:37 -0700 (PDT) Date: Wed, 11 Jul 2018 17:26:35 +0200 From: Lorenzo Bianconi To: Jorge Ramirez-Ortiz Cc: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org Subject: Re: [PATCH] iio: imu: st_lsm6dsx: irq not handled unless data pushed to buffers Message-ID: <20180711152634.GB12995@localhost.localdomain> References: <1531297928-3824-1-git-send-email-jramirez@baylibre.com> <20180711122953.GC3871@localhost.localdomain> <2d1f0810-a6d0-3785-6692-003bb3f817e0@baylibre.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2d1f0810-a6d0-3785-6692-003bb3f817e0@baylibre.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Jul 11, Jorge Ramirez-Ortiz wrote: > On 07/11/2018 02:29 PM, Lorenzo Bianconi wrote: > > > Currently IRQ_NONE is returned only when there is no data on the fifo. > > > > > > When there is no data on the fifo the driver can not push to the > > > buffers and therefore user space readers polling for data available > > > will not be awoken and continue to wait. > > > > > > This commit just extends the same semantics to fifo read errors. > > Hi Jorge, > > > > IRQ_NONE is used to indicate this interrupt is not intended for this driver > > (this could happen if the irq line is in open-drain). If the interrupt is for > > st_lsm6dsx I would prefer to return IRQ_HANDLED even in case of error. > > yes I understand. > > This was just a trivial attempt (I guess a really bad idea) to get some > debug info (via /proc/irq/.../spurious) any time the driver read (spi/i2c) > fails when processing the data ready irq. > do you think it would make sense to add a dev_err to > st_lsm6dsx_i2c_read/st_lsm6dsx_spi_read? at the moment the driver would fail > silently do you mean something like (just compiled, not tested): Regards, Lorenzo > > thanks for coming back to me despite the bad patch > > > > > Regards, > > Lorenzo > > > > > Signed-off-by: Jorge Ramirez-Ortiz > > > --- > > > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c > > > index 4994f92..4959923 100644 > > > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c > > > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c > > > @@ -472,7 +472,7 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) > > > count = st_lsm6dsx_read_fifo(hw); > > > mutex_unlock(&hw->fifo_lock); > > > - return !count ? IRQ_NONE : IRQ_HANDLED; > > > + return (!count || count < 0) ? IRQ_NONE : IRQ_HANDLED; > > > } > > > static int st_lsm6dsx_buffer_preenable(struct iio_dev *iio_dev) > > > -- > > > 2.7.4 > > > > --- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -298,8 +298,11 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) err = regmap_bulk_read(hw->regmap, hw->settings->fifo_ops.fifo_diff.addr, &fifo_status, sizeof(fifo_status)); - if (err < 0) + if (err < 0) { + dev_err(hw->dev, "failed to read fifo status reg (err=%d)\n", + err); return err; + } if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK)) return 0; @@ -313,8 +316,12 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) for (read_len = 0; read_len < fifo_len; read_len += pattern_len) { err = st_lsm6dsx_read_block(hw, hw->buff, pattern_len); - if (err < 0) + if (err < 0) { + dev_err(hw->dev, + "failed to read pattern from fifo (err=%d)\n", + err); return err; + } /* * Data are written to the FIFO with a specific pattern @@ -385,8 +392,11 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) if (unlikely(reset_ts)) { err = st_lsm6dsx_reset_hw_ts(hw); - if (err < 0) + if (err < 0) { + dev_err(hw->dev, "failed to reset hw ts (err=%d)\n", + err); return err; + } } return read_len; }