Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: "Hans de Goede" <hansg@kernel.org>,
	"Marek Vasut" <marek.vasut+bmc150@mailbox.org>,
	linux-iio@vger.kernel.org, "Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Julien Stephan" <jstephan@baylibre.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Salvatore Bonaccorso" <carnil@debian.org>
Subject: Re: [PATCH] iio: accel: bmc150: Do not configure IRQ registers if no IRQ connected
Date: Thu, 24 Jul 2025 14:41:19 +0100	[thread overview]
Message-ID: <20250724144119.399e977b@jic23-huawei> (raw)
In-Reply-To: <6oyvsvp2erynwu3evulbg6gtdryabeuoo46qzku2grxg3jxptf@jszhnvmj2ffc>

On Tue, 22 Jul 2025 10:55:29 +0200
Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:

> Hello,
> 
> On Mon, Jun 16, 2025 at 02:42:54PM +0200, Hans de Goede wrote:
> > > diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
> > > index 744a034bb8b5..1c3583ade2b4 100644
> > > --- a/drivers/iio/accel/bmc150-accel-core.c
> > > +++ b/drivers/iio/accel/bmc150-accel-core.c
> > > @@ -550,6 +550,9 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
> > >  	if (ret < 0)
> > >  		return ret;
> > >  
> > > +	if (!info)
> > > +		return 0;
> > > +
> > >  	/* map the interrupt to the appropriate pins */
> > >  	ret = regmap_update_bits(data->regmap, info->map_reg, info->map_bitmask,
> > >  				 (state ? info->map_bitmask : 0));  
> > 
> > AFAIK the proper fix would be to not register any IIO-triggers. This fix will
> > avoid the problem, but userspace might still try to use non-working triggers
> > which will now silently fail.  
> 
> I don't have a system that triggers the problem, but there is
> https://bugs.debian.org/1106411 which I guess is the same problem.
> 
> I think the suggestion to not register the triggers in the absence of an
> irq would be implemented by

I was going to say don't do this because it break other triggers being used with this
driver, but... 

We have a validate_trigger callback so this driver can only use a trigger registered
by this driver.  That's a bit of a horrible limitation that we tend to only do
if there is a nasty interaction between event handling and data acquisition.

Here there is such an interaction as a result (I think) of it handling the fifo
off the back of a trigger which is something we don't do in newer drivers.

So this is all a bit nasty but this should work and doesn't require a more
substantial rework.

I think there may be a similar issue though for the events.  For those
we need to switch to a different iio_info instance + different channel array
where the events stuff is all missing if we don't have an irq.

Jonathan




> 
> diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
> index be5fbb0c5d29..8d90802e65fd 100644
> --- a/drivers/iio/accel/bmc150-accel-core.c
> +++ b/drivers/iio/accel/bmc150-accel-core.c
> @@ -1687,18 +1687,18 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
>  		fifo_attrs = NULL;
>  	}
>  
> -	ret = iio_triggered_buffer_setup_ext(indio_dev,
> -					     &iio_pollfunc_store_time,
> -					     bmc150_accel_trigger_handler,
> -					     IIO_BUFFER_DIRECTION_IN,
> -					     &bmc150_accel_buffer_ops,
> -					     fifo_attrs);
> -	if (ret < 0) {
> -		dev_err(dev, "Failed: iio triggered buffer setup\n");
> -		goto err_disable_regulators;
> -	}
> -
>  	if (irq > 0) {
> +		ret = iio_triggered_buffer_setup_ext(indio_dev,
> +						     &iio_pollfunc_store_time,
> +						     bmc150_accel_trigger_handler,
> +						     IIO_BUFFER_DIRECTION_IN,
> +						     &bmc150_accel_buffer_ops,
> +						     fifo_attrs);
> +		if (ret < 0) {
> +			dev_err(dev, "Failed: iio triggered buffer setup\n");
> +			goto err_disable_regulators;
> +		}
> +
>  		ret = devm_request_threaded_irq(dev, irq,
>  						bmc150_accel_irq_handler,
>  						bmc150_accel_irq_thread_handler,
> 
> 
> But given that bmc150_accel_write_event_config() also calls
> bmc150_accel_set_interrupt() this might not be a complete fix.
> 
> Best regards
> Uwe


      parent reply	other threads:[~2025-07-24 13:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-13 12:45 [PATCH] iio: accel: bmc150: Do not configure IRQ registers if no IRQ connected Marek Vasut
2025-06-13 15:03 ` David Lechner
2025-06-13 15:09   ` Andy Shevchenko
2025-06-13 15:09 ` Andy Shevchenko
2025-06-13 17:02   ` Marek Vasut
2025-06-14 13:03     ` Jonathan Cameron
2025-06-16  8:47     ` Andy Shevchenko
2025-06-16 11:03       ` Marek Vasut
2025-06-16 11:09         ` Andy Shevchenko
2025-06-21 17:33           ` Marek Vasut
2025-06-23  7:19             ` Andy Shevchenko
2025-06-16 12:42 ` Hans de Goede
2025-06-21 17:17   ` Jonathan Cameron
2025-06-21 17:24     ` Marek Vasut
2025-06-21 20:14       ` Hans de Goede
2026-01-08 21:55         ` Marek Vasut
2026-01-09  9:24           ` Linus Walleij
2026-01-09 15:00             ` Marek Vasut
2025-07-22  8:55   ` Uwe Kleine-König
2025-07-22 14:48     ` Marek Vasut
2025-07-23 15:19       ` Andy Shevchenko
2025-10-01 18:25         ` Salvatore Bonaccorso
2025-11-15 18:23           ` Jonathan Cameron
2025-07-24 13:41     ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250724144119.399e977b@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=carnil@debian.org \
    --cc=dlechner@baylibre.com \
    --cc=hansg@kernel.org \
    --cc=jstephan@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=marek.vasut+bmc150@mailbox.org \
    --cc=nuno.sa@analog.com \
    --cc=peterz@infradead.org \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox