All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
@ 2022-01-17 10:25 ` Paul Cercueil
  0 siblings, 0 replies; 14+ messages in thread
From: Paul Cercueil @ 2022-01-17 10:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-arm-kernel, linux-kernel, Paul Cercueil,
	Lorenzo Bianconi

Instead of returning an error if the watermark value is too high, which
the core will silently ignore anyway, limit the value to the hardware
FIFO size; a lower-than-requested value is still better than using the
default, which is usually 1.

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 727b4b6ac696..5fd46bf1a11b 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -54,6 +54,7 @@
 #include <linux/iio/sysfs.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/minmax.h>
 #include <linux/pm.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
@@ -1607,8 +1608,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
 	struct st_lsm6dsx_hw *hw = sensor->hw;
 	int err;
 
-	if (val < 1 || val > hw->settings->fifo_ops.max_size)
-		return -EINVAL;
+	val = clamp_val(val, 1, hw->settings->fifo_ops.max_size);
 
 	mutex_lock(&hw->conf_lock);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
@ 2022-01-17 10:25 ` Paul Cercueil
  0 siblings, 0 replies; 14+ messages in thread
From: Paul Cercueil @ 2022-01-17 10:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-arm-kernel, linux-kernel, Paul Cercueil,
	Lorenzo Bianconi

Instead of returning an error if the watermark value is too high, which
the core will silently ignore anyway, limit the value to the hardware
FIFO size; a lower-than-requested value is still better than using the
default, which is usually 1.

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 727b4b6ac696..5fd46bf1a11b 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -54,6 +54,7 @@
 #include <linux/iio/sysfs.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/minmax.h>
 #include <linux/pm.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
@@ -1607,8 +1608,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
 	struct st_lsm6dsx_hw *hw = sensor->hw;
 	int err;
 
-	if (val < 1 || val > hw->settings->fifo_ops.max_size)
-		return -EINVAL;
+	val = clamp_val(val, 1, hw->settings->fifo_ops.max_size);
 
 	mutex_lock(&hw->conf_lock);
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
  2022-01-17 10:25 ` Paul Cercueil
@ 2022-01-17 10:25   ` Paul Cercueil
  -1 siblings, 0 replies; 14+ messages in thread
From: Paul Cercueil @ 2022-01-17 10:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-arm-kernel, linux-kernel, Paul Cercueil,
	Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches

Instead of returning an error if the watermark value is too high, which
the core will silently ignore anyway, limit the value to the hardware
FIFO size; a lower-than-requested value is still better than using the
default, which is usually 1.

Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index 854b1f81d807..5cc84f4a17bb 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
 	int ret;
 
 	if (val > AT91_HWFIFO_MAX_SIZE)
-		return -EINVAL;
+		val = AT91_HWFIFO_MAX_SIZE;
 
 	if (!st->selected_trig->hw_trig) {
 		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");
-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
@ 2022-01-17 10:25   ` Paul Cercueil
  0 siblings, 0 replies; 14+ messages in thread
From: Paul Cercueil @ 2022-01-17 10:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: Alexandre Belloni, linux-iio, linux-kernel, Paul Cercueil,
	Ludovic Desroches, Eugen Hristev, linux-arm-kernel

Instead of returning an error if the watermark value is too high, which
the core will silently ignore anyway, limit the value to the hardware
FIFO size; a lower-than-requested value is still better than using the
default, which is usually 1.

Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index 854b1f81d807..5cc84f4a17bb 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
 	int ret;
 
 	if (val > AT91_HWFIFO_MAX_SIZE)
-		return -EINVAL;
+		val = AT91_HWFIFO_MAX_SIZE;
 
 	if (!st->selected_trig->hw_trig) {
 		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
  2022-01-17 10:25 ` Paul Cercueil
@ 2022-01-17 10:56   ` Lorenzo Bianconi
  -1 siblings, 0 replies; 14+ messages in thread
From: Lorenzo Bianconi @ 2022-01-17 10:56 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio,
	linux-arm-kernel, linux-kernel, Lorenzo Bianconi

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

> Instead of returning an error if the watermark value is too high, which
> the core will silently ignore anyway, limit the value to the hardware
> FIFO size; a lower-than-requested value is still better than using the
> default, which is usually 1.
> 

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 727b4b6ac696..5fd46bf1a11b 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -54,6 +54,7 @@
>  #include <linux/iio/sysfs.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> +#include <linux/minmax.h>
>  #include <linux/pm.h>
>  #include <linux/property.h>
>  #include <linux/regmap.h>
> @@ -1607,8 +1608,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
>  	int err;
>  
> -	if (val < 1 || val > hw->settings->fifo_ops.max_size)
> -		return -EINVAL;
> +	val = clamp_val(val, 1, hw->settings->fifo_ops.max_size);
>  
>  	mutex_lock(&hw->conf_lock);
>  
> -- 
> 2.34.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
@ 2022-01-17 10:56   ` Lorenzo Bianconi
  0 siblings, 0 replies; 14+ messages in thread
From: Lorenzo Bianconi @ 2022-01-17 10:56 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio,
	linux-arm-kernel, linux-kernel, Lorenzo Bianconi


[-- Attachment #1.1: Type: text/plain, Size: 1401 bytes --]

> Instead of returning an error if the watermark value is too high, which
> the core will silently ignore anyway, limit the value to the hardware
> FIFO size; a lower-than-requested value is still better than using the
> default, which is usually 1.
> 

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 727b4b6ac696..5fd46bf1a11b 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -54,6 +54,7 @@
>  #include <linux/iio/sysfs.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> +#include <linux/minmax.h>
>  #include <linux/pm.h>
>  #include <linux/property.h>
>  #include <linux/regmap.h>
> @@ -1607,8 +1608,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
>  	int err;
>  
> -	if (val < 1 || val > hw->settings->fifo_ops.max_size)
> -		return -EINVAL;
> +	val = clamp_val(val, 1, hw->settings->fifo_ops.max_size);
>  
>  	mutex_lock(&hw->conf_lock);
>  
> -- 
> 2.34.1
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
  2022-01-17 10:25   ` Paul Cercueil
@ 2022-01-22 17:04     ` Jonathan Cameron
  -1 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-01-22 17:04 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Lars-Peter Clausen, linux-iio, linux-arm-kernel, linux-kernel,
	Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches

On Mon, 17 Jan 2022 10:25:12 +0000
Paul Cercueil <paul@crapouillou.net> wrote:

> Instead of returning an error if the watermark value is too high, which
> the core will silently ignore anyway, limit the value to the hardware
> FIFO size; a lower-than-requested value is still better than using the
> default, which is usually 1.

There is another potential error condition in this function which will
also be ignored by the core.

As such whilst I agree this is a sensible thing to do in this
particular case I think we should also be handling the error in the core.

I think it would be better to clean that up at the same time
as these improvements - particularly as I'd guess you have a convenient
test setup to check the error unwind is correct?

Thanks,

Jonathan

> 
> Cc: Eugen Hristev <eugen.hristev@microchip.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> index 854b1f81d807..5cc84f4a17bb 100644
> --- a/drivers/iio/adc/at91-sama5d2_adc.c
> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
>  	int ret;
>  
>  	if (val > AT91_HWFIFO_MAX_SIZE)
> -		return -EINVAL;
> +		val = AT91_HWFIFO_MAX_SIZE;
>  
>  	if (!st->selected_trig->hw_trig) {
>  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
@ 2022-01-22 17:04     ` Jonathan Cameron
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-01-22 17:04 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Alexandre Belloni, Lars-Peter Clausen, linux-iio, linux-kernel,
	Ludovic Desroches, Eugen Hristev, linux-arm-kernel

On Mon, 17 Jan 2022 10:25:12 +0000
Paul Cercueil <paul@crapouillou.net> wrote:

> Instead of returning an error if the watermark value is too high, which
> the core will silently ignore anyway, limit the value to the hardware
> FIFO size; a lower-than-requested value is still better than using the
> default, which is usually 1.

There is another potential error condition in this function which will
also be ignored by the core.

As such whilst I agree this is a sensible thing to do in this
particular case I think we should also be handling the error in the core.

I think it would be better to clean that up at the same time
as these improvements - particularly as I'd guess you have a convenient
test setup to check the error unwind is correct?

Thanks,

Jonathan

> 
> Cc: Eugen Hristev <eugen.hristev@microchip.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> index 854b1f81d807..5cc84f4a17bb 100644
> --- a/drivers/iio/adc/at91-sama5d2_adc.c
> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
>  	int ret;
>  
>  	if (val > AT91_HWFIFO_MAX_SIZE)
> -		return -EINVAL;
> +		val = AT91_HWFIFO_MAX_SIZE;
>  
>  	if (!st->selected_trig->hw_trig) {
>  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
  2022-01-22 17:04     ` Jonathan Cameron
@ 2022-06-04 15:05       ` Jonathan Cameron
  -1 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-06-04 15:05 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Lars-Peter Clausen, linux-iio, linux-arm-kernel, linux-kernel,
	Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches

On Sat, 22 Jan 2022 17:04:47 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Mon, 17 Jan 2022 10:25:12 +0000
> Paul Cercueil <paul@crapouillou.net> wrote:
> 
> > Instead of returning an error if the watermark value is too high, which
> > the core will silently ignore anyway, limit the value to the hardware
> > FIFO size; a lower-than-requested value is still better than using the
> > default, which is usually 1.  
> 
> There is another potential error condition in this function which will
> also be ignored by the core.
> 
> As such whilst I agree this is a sensible thing to do in this
> particular case I think we should also be handling the error in the core.
> 
> I think it would be better to clean that up at the same time
> as these improvements - particularly as I'd guess you have a convenient
> test setup to check the error unwind is correct?

Hi Paul,

I was trawling through patchwork and realised this one is stalled.

Thoughts on the above?

Thanks,

Jonathan

> 
> Thanks,
> 
> Jonathan
> 
> > 
> > Cc: Eugen Hristev <eugen.hristev@microchip.com>
> > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> > ---
> >  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> > index 854b1f81d807..5cc84f4a17bb 100644
> > --- a/drivers/iio/adc/at91-sama5d2_adc.c
> > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> > @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
> >  	int ret;
> >  
> >  	if (val > AT91_HWFIFO_MAX_SIZE)
> > -		return -EINVAL;
> > +		val = AT91_HWFIFO_MAX_SIZE;
> >  
> >  	if (!st->selected_trig->hw_trig) {
> >  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");  
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
@ 2022-06-04 15:05       ` Jonathan Cameron
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-06-04 15:05 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Alexandre Belloni, Lars-Peter Clausen, linux-iio, linux-kernel,
	Ludovic Desroches, Eugen Hristev, linux-arm-kernel

On Sat, 22 Jan 2022 17:04:47 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Mon, 17 Jan 2022 10:25:12 +0000
> Paul Cercueil <paul@crapouillou.net> wrote:
> 
> > Instead of returning an error if the watermark value is too high, which
> > the core will silently ignore anyway, limit the value to the hardware
> > FIFO size; a lower-than-requested value is still better than using the
> > default, which is usually 1.  
> 
> There is another potential error condition in this function which will
> also be ignored by the core.
> 
> As such whilst I agree this is a sensible thing to do in this
> particular case I think we should also be handling the error in the core.
> 
> I think it would be better to clean that up at the same time
> as these improvements - particularly as I'd guess you have a convenient
> test setup to check the error unwind is correct?

Hi Paul,

I was trawling through patchwork and realised this one is stalled.

Thoughts on the above?

Thanks,

Jonathan

> 
> Thanks,
> 
> Jonathan
> 
> > 
> > Cc: Eugen Hristev <eugen.hristev@microchip.com>
> > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> > ---
> >  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> > index 854b1f81d807..5cc84f4a17bb 100644
> > --- a/drivers/iio/adc/at91-sama5d2_adc.c
> > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> > @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
> >  	int ret;
> >  
> >  	if (val > AT91_HWFIFO_MAX_SIZE)
> > -		return -EINVAL;
> > +		val = AT91_HWFIFO_MAX_SIZE;
> >  
> >  	if (!st->selected_trig->hw_trig) {
> >  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");  
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
  2022-06-04 15:05       ` Jonathan Cameron
@ 2022-06-04 22:41         ` Paul Cercueil
  -1 siblings, 0 replies; 14+ messages in thread
From: Paul Cercueil @ 2022-06-04 22:41 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, linux-iio, linux-arm-kernel, linux-kernel,
	Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches

Hi Jonathan,

Le sam., juin 4 2022 at 16:05:57 +0100, Jonathan Cameron 
<jic23@kernel.org> a écrit :
> On Sat, 22 Jan 2022 17:04:47 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
>>  On Mon, 17 Jan 2022 10:25:12 +0000
>>  Paul Cercueil <paul@crapouillou.net> wrote:
>> 
>>  > Instead of returning an error if the watermark value is too high, 
>> which
>>  > the core will silently ignore anyway, limit the value to the 
>> hardware
>>  > FIFO size; a lower-than-requested value is still better than 
>> using the
>>  > default, which is usually 1.
>> 
>>  There is another potential error condition in this function which 
>> will
>>  also be ignored by the core.
>> 
>>  As such whilst I agree this is a sensible thing to do in this
>>  particular case I think we should also be handling the error in the 
>> core.
>> 
>>  I think it would be better to clean that up at the same time
>>  as these improvements - particularly as I'd guess you have a 
>> convenient
>>  test setup to check the error unwind is correct?
> 
> Hi Paul,
> 
> I was trawling through patchwork and realised this one is stalled.
> 
> Thoughts on the above?

Totally forgot about this patch.

Aren't you afraid that if we start handling these errors in the core, 
we'll somehow break the ABI?

-Paul

> Thanks,
> 
> Jonathan
> 
>> 
>>  Thanks,
>> 
>>  Jonathan
>> 
>>  >
>>  > Cc: Eugen Hristev <eugen.hristev@microchip.com>
>>  > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
>>  > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>  > Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
>>  > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  > ---
>>  >  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
>>  >  1 file changed, 1 insertion(+), 1 deletion(-)
>>  >
>>  > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c 
>> b/drivers/iio/adc/at91-sama5d2_adc.c
>>  > index 854b1f81d807..5cc84f4a17bb 100644
>>  > --- a/drivers/iio/adc/at91-sama5d2_adc.c
>>  > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
>>  > @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct 
>> iio_dev *indio_dev, unsigned int val)
>>  >  	int ret;
>>  >
>>  >  	if (val > AT91_HWFIFO_MAX_SIZE)
>>  > -		return -EINVAL;
>>  > +		val = AT91_HWFIFO_MAX_SIZE;
>>  >
>>  >  	if (!st->selected_trig->hw_trig) {
>>  >  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");
>> 
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
@ 2022-06-04 22:41         ` Paul Cercueil
  0 siblings, 0 replies; 14+ messages in thread
From: Paul Cercueil @ 2022-06-04 22:41 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Alexandre Belloni, Lars-Peter Clausen, linux-iio, linux-kernel,
	Ludovic Desroches, Eugen Hristev, linux-arm-kernel

Hi Jonathan,

Le sam., juin 4 2022 at 16:05:57 +0100, Jonathan Cameron 
<jic23@kernel.org> a écrit :
> On Sat, 22 Jan 2022 17:04:47 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
>>  On Mon, 17 Jan 2022 10:25:12 +0000
>>  Paul Cercueil <paul@crapouillou.net> wrote:
>> 
>>  > Instead of returning an error if the watermark value is too high, 
>> which
>>  > the core will silently ignore anyway, limit the value to the 
>> hardware
>>  > FIFO size; a lower-than-requested value is still better than 
>> using the
>>  > default, which is usually 1.
>> 
>>  There is another potential error condition in this function which 
>> will
>>  also be ignored by the core.
>> 
>>  As such whilst I agree this is a sensible thing to do in this
>>  particular case I think we should also be handling the error in the 
>> core.
>> 
>>  I think it would be better to clean that up at the same time
>>  as these improvements - particularly as I'd guess you have a 
>> convenient
>>  test setup to check the error unwind is correct?
> 
> Hi Paul,
> 
> I was trawling through patchwork and realised this one is stalled.
> 
> Thoughts on the above?

Totally forgot about this patch.

Aren't you afraid that if we start handling these errors in the core, 
we'll somehow break the ABI?

-Paul

> Thanks,
> 
> Jonathan
> 
>> 
>>  Thanks,
>> 
>>  Jonathan
>> 
>>  >
>>  > Cc: Eugen Hristev <eugen.hristev@microchip.com>
>>  > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
>>  > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>  > Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
>>  > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  > ---
>>  >  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
>>  >  1 file changed, 1 insertion(+), 1 deletion(-)
>>  >
>>  > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c 
>> b/drivers/iio/adc/at91-sama5d2_adc.c
>>  > index 854b1f81d807..5cc84f4a17bb 100644
>>  > --- a/drivers/iio/adc/at91-sama5d2_adc.c
>>  > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
>>  > @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct 
>> iio_dev *indio_dev, unsigned int val)
>>  >  	int ret;
>>  >
>>  >  	if (val > AT91_HWFIFO_MAX_SIZE)
>>  > -		return -EINVAL;
>>  > +		val = AT91_HWFIFO_MAX_SIZE;
>>  >
>>  >  	if (!st->selected_trig->hw_trig) {
>>  >  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");
>> 
> 



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
  2022-06-04 22:41         ` Paul Cercueil
@ 2022-06-12  8:49           ` Jonathan Cameron
  -1 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-06-12  8:49 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Lars-Peter Clausen, linux-iio, linux-arm-kernel, linux-kernel,
	Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches

On Sat, 04 Jun 2022 23:41:02 +0100
Paul Cercueil <paul@crapouillou.net> wrote:

> Hi Jonathan,
> 
> Le sam., juin 4 2022 at 16:05:57 +0100, Jonathan Cameron 
> <jic23@kernel.org> a écrit :
> > On Sat, 22 Jan 2022 17:04:47 +0000
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >   
> >>  On Mon, 17 Jan 2022 10:25:12 +0000
> >>  Paul Cercueil <paul@crapouillou.net> wrote:
> >>   
> >>  > Instead of returning an error if the watermark value is too high,   
> >> which  
> >>  > the core will silently ignore anyway, limit the value to the   
> >> hardware  
> >>  > FIFO size; a lower-than-requested value is still better than   
> >> using the  
> >>  > default, which is usually 1.  
> >> 
> >>  There is another potential error condition in this function which 
> >> will
> >>  also be ignored by the core.
> >> 
> >>  As such whilst I agree this is a sensible thing to do in this
> >>  particular case I think we should also be handling the error in the 
> >> core.
> >> 
> >>  I think it would be better to clean that up at the same time
> >>  as these improvements - particularly as I'd guess you have a 
> >> convenient
> >>  test setup to check the error unwind is correct?  
> > 
> > Hi Paul,
> > 
> > I was trawling through patchwork and realised this one is stalled.
> > 
> > Thoughts on the above?  
> 
> Totally forgot about this patch.
> 
> Aren't you afraid that if we start handling these errors in the core, 
> we'll somehow break the ABI?
> 
Been a while, but I think my concern was more that there are other
error conditions in these calls.  Whilst we can indeed clamp the
watermark, the other conditions should probably be handled in the core.

I guess that doesn't mean i shouldn't take these in the meantime, just
that there is more work to do here and I was sneakily trying to make
it your problem *evil laugh*

As such, applied these two to, but if anyone has time to take a look
at handling the error returns in the core that would be great.

Applied to the togreg branch of iio.git and I'll push out as testing
later (on train with dodgy wifi) for 0-day to take a look.

Thanks,

Jonathan

> -Paul
> 
> > Thanks,
> > 
> > Jonathan
> >   
> >> 
> >>  Thanks,
> >> 
> >>  Jonathan
> >>   
> >>  >
> >>  > Cc: Eugen Hristev <eugen.hristev@microchip.com>
> >>  > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> >>  > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> >>  > Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> >>  > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> >>  > ---
> >>  >  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
> >>  >  1 file changed, 1 insertion(+), 1 deletion(-)
> >>  >
> >>  > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c   
> >> b/drivers/iio/adc/at91-sama5d2_adc.c  
> >>  > index 854b1f81d807..5cc84f4a17bb 100644
> >>  > --- a/drivers/iio/adc/at91-sama5d2_adc.c
> >>  > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> >>  > @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct   
> >> iio_dev *indio_dev, unsigned int val)  
> >>  >  	int ret;
> >>  >
> >>  >  	if (val > AT91_HWFIFO_MAX_SIZE)
> >>  > -		return -EINVAL;
> >>  > +		val = AT91_HWFIFO_MAX_SIZE;
> >>  >
> >>  >  	if (!st->selected_trig->hw_trig) {
> >>  >  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");  
> >>   
> >   
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iio: at91-sama5d2: Limit requested watermark value to hwfifo size
@ 2022-06-12  8:49           ` Jonathan Cameron
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-06-12  8:49 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Alexandre Belloni, Lars-Peter Clausen, linux-iio, linux-kernel,
	Ludovic Desroches, Eugen Hristev, linux-arm-kernel

On Sat, 04 Jun 2022 23:41:02 +0100
Paul Cercueil <paul@crapouillou.net> wrote:

> Hi Jonathan,
> 
> Le sam., juin 4 2022 at 16:05:57 +0100, Jonathan Cameron 
> <jic23@kernel.org> a écrit :
> > On Sat, 22 Jan 2022 17:04:47 +0000
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >   
> >>  On Mon, 17 Jan 2022 10:25:12 +0000
> >>  Paul Cercueil <paul@crapouillou.net> wrote:
> >>   
> >>  > Instead of returning an error if the watermark value is too high,   
> >> which  
> >>  > the core will silently ignore anyway, limit the value to the   
> >> hardware  
> >>  > FIFO size; a lower-than-requested value is still better than   
> >> using the  
> >>  > default, which is usually 1.  
> >> 
> >>  There is another potential error condition in this function which 
> >> will
> >>  also be ignored by the core.
> >> 
> >>  As such whilst I agree this is a sensible thing to do in this
> >>  particular case I think we should also be handling the error in the 
> >> core.
> >> 
> >>  I think it would be better to clean that up at the same time
> >>  as these improvements - particularly as I'd guess you have a 
> >> convenient
> >>  test setup to check the error unwind is correct?  
> > 
> > Hi Paul,
> > 
> > I was trawling through patchwork and realised this one is stalled.
> > 
> > Thoughts on the above?  
> 
> Totally forgot about this patch.
> 
> Aren't you afraid that if we start handling these errors in the core, 
> we'll somehow break the ABI?
> 
Been a while, but I think my concern was more that there are other
error conditions in these calls.  Whilst we can indeed clamp the
watermark, the other conditions should probably be handled in the core.

I guess that doesn't mean i shouldn't take these in the meantime, just
that there is more work to do here and I was sneakily trying to make
it your problem *evil laugh*

As such, applied these two to, but if anyone has time to take a look
at handling the error returns in the core that would be great.

Applied to the togreg branch of iio.git and I'll push out as testing
later (on train with dodgy wifi) for 0-day to take a look.

Thanks,

Jonathan

> -Paul
> 
> > Thanks,
> > 
> > Jonathan
> >   
> >> 
> >>  Thanks,
> >> 
> >>  Jonathan
> >>   
> >>  >
> >>  > Cc: Eugen Hristev <eugen.hristev@microchip.com>
> >>  > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> >>  > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> >>  > Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> >>  > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> >>  > ---
> >>  >  drivers/iio/adc/at91-sama5d2_adc.c | 2 +-
> >>  >  1 file changed, 1 insertion(+), 1 deletion(-)
> >>  >
> >>  > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c   
> >> b/drivers/iio/adc/at91-sama5d2_adc.c  
> >>  > index 854b1f81d807..5cc84f4a17bb 100644
> >>  > --- a/drivers/iio/adc/at91-sama5d2_adc.c
> >>  > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> >>  > @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct   
> >> iio_dev *indio_dev, unsigned int val)  
> >>  >  	int ret;
> >>  >
> >>  >  	if (val > AT91_HWFIFO_MAX_SIZE)
> >>  > -		return -EINVAL;
> >>  > +		val = AT91_HWFIFO_MAX_SIZE;
> >>  >
> >>  >  	if (!st->selected_trig->hw_trig) {
> >>  >  		dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");  
> >>   
> >   
> 
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-12  8:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 10:25 [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size Paul Cercueil
2022-01-17 10:25 ` Paul Cercueil
2022-01-17 10:25 ` [PATCH 2/2] iio: at91-sama5d2: " Paul Cercueil
2022-01-17 10:25   ` Paul Cercueil
2022-01-22 17:04   ` Jonathan Cameron
2022-01-22 17:04     ` Jonathan Cameron
2022-06-04 15:05     ` Jonathan Cameron
2022-06-04 15:05       ` Jonathan Cameron
2022-06-04 22:41       ` Paul Cercueil
2022-06-04 22:41         ` Paul Cercueil
2022-06-12  8:49         ` Jonathan Cameron
2022-06-12  8:49           ` Jonathan Cameron
2022-01-17 10:56 ` [PATCH 1/2] iio: imu: st_lsm6dsx: " Lorenzo Bianconi
2022-01-17 10:56   ` Lorenzo Bianconi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.