linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] gpio: mockup: misc updates
@ 2018-11-08 16:52 Bartosz Golaszewski
  2018-11-08 16:52 ` [PATCH 1/3] gpio: mockup: fix indicated direction Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-08 16:52 UTC (permalink / raw)
  To: Bamvor Jian Zhang, Linus Walleij, Uwe Kleine-König
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

The first patch is a fix that should go in for 4.20.

Next two patches introduce features for 4.21 - lock protection of the
dummy chip structures and implementation of the get_multiple() callback.

Bartosz Golaszewski (3):
  gpio: mockup: fix indicated direction
  gpio: mockup: add locking
  gpio: mockup: implement get_multiple()

 drivers/gpio/gpio-mockup.c | 71 +++++++++++++++++++++++++++++++++-----
 1 file changed, 62 insertions(+), 9 deletions(-)

-- 
2.19.1


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

* [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-08 16:52 [PATCH 0/3] gpio: mockup: misc updates Bartosz Golaszewski
@ 2018-11-08 16:52 ` Bartosz Golaszewski
  2018-11-08 20:35   ` Uwe Kleine-König
  2018-11-16 21:38   ` Linus Walleij
  2018-11-08 16:52 ` [PATCH 2/3] gpio: mockup: add locking Bartosz Golaszewski
  2018-11-08 16:52 ` [PATCH 3/3] gpio: mockup: implement get_multiple() Bartosz Golaszewski
  2 siblings, 2 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-08 16:52 UTC (permalink / raw)
  To: Bamvor Jian Zhang, Linus Walleij, Uwe Kleine-König
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
beginning") fixed an existing issue but broke libgpiod tests by
changing the default direction of dummy lines to output.

We don't break user-space so make gpio-mockup behave as before.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 drivers/gpio/gpio-mockup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 8269cffc2967..6a50f9f59c90 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -35,8 +35,8 @@
 #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
 
 enum {
-	GPIO_MOCKUP_DIR_OUT = 0,
-	GPIO_MOCKUP_DIR_IN = 1,
+	GPIO_MOCKUP_DIR_IN = 0,
+	GPIO_MOCKUP_DIR_OUT = 1,
 };
 
 /*
@@ -131,7 +131,7 @@ static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset)
 {
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
-	return chip->lines[offset].dir;
+	return !chip->lines[offset].dir;
 }
 
 static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
-- 
2.19.1


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

* [PATCH 2/3] gpio: mockup: add locking
  2018-11-08 16:52 [PATCH 0/3] gpio: mockup: misc updates Bartosz Golaszewski
  2018-11-08 16:52 ` [PATCH 1/3] gpio: mockup: fix indicated direction Bartosz Golaszewski
@ 2018-11-08 16:52 ` Bartosz Golaszewski
  2018-11-08 21:13   ` Uwe Kleine-König
  2018-11-16 21:43   ` Linus Walleij
  2018-11-08 16:52 ` [PATCH 3/3] gpio: mockup: implement get_multiple() Bartosz Golaszewski
  2 siblings, 2 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-08 16:52 UTC (permalink / raw)
  To: Bamvor Jian Zhang, Linus Walleij, Uwe Kleine-König
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

While no user reported any race condition problems with gpio-mockup,
let's be on the safe side and use a mutex when performing any changes
on the dummy chip structures.

Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 drivers/gpio/gpio-mockup.c | 50 ++++++++++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 6a50f9f59c90..3cd92912c414 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -54,6 +54,7 @@ struct gpio_mockup_chip {
 	struct gpio_mockup_line_status *lines;
 	struct irq_sim irqsim;
 	struct dentry *dbg_dir;
+	struct mutex lock;
 };
 
 struct gpio_mockup_dbgfs_private {
@@ -82,29 +83,53 @@ static int gpio_mockup_range_ngpio(unsigned int index)
 	return gpio_mockup_ranges[index * 2 + 1];
 }
 
-static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
+static int __gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
 {
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	return chip->lines[offset].value;
 }
 
-static void gpio_mockup_set(struct gpio_chip *gc,
-			    unsigned int offset, int value)
+static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
+{
+	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
+	int val;
+
+	mutex_lock(&chip->lock);
+	val = __gpio_mockup_get(gc, offset);
+	mutex_unlock(&chip->lock);
+
+	return val;
+}
+
+static void __gpio_mockup_set(struct gpio_chip *gc,
+			      unsigned int offset, int value)
 {
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	chip->lines[offset].value = !!value;
 }
 
+static void gpio_mockup_set(struct gpio_chip *gc,
+			   unsigned int offset, int value)
+{
+	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
+
+	mutex_lock(&chip->lock);
+	__gpio_mockup_set(gc, offset, value);
+	mutex_unlock(&chip->lock);
+}
+
 static void gpio_mockup_set_multiple(struct gpio_chip *gc,
 				     unsigned long *mask, unsigned long *bits)
 {
+	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 	unsigned int bit;
 
+	mutex_lock(&chip->lock);
 	for_each_set_bit(bit, mask, gc->ngpio)
-		gpio_mockup_set(gc, bit, test_bit(bit, bits));
-
+		__gpio_mockup_set(gc, bit, test_bit(bit, bits));
+	mutex_unlock(&chip->lock);
 }
 
 static int gpio_mockup_dirout(struct gpio_chip *gc,
@@ -112,8 +137,10 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
 {
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
-	gpio_mockup_set(gc, offset, value);
+	mutex_lock(&chip->lock);
+	__gpio_mockup_set(gc, offset, value);
 	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
+	mutex_unlock(&chip->lock);
 
 	return 0;
 }
@@ -122,7 +149,9 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
 {
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
+	mutex_lock(&chip->lock);
 	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
+	mutex_unlock(&chip->lock);
 
 	return 0;
 }
@@ -130,8 +159,13 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
 static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset)
 {
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
+	int direction;
 
-	return !chip->lines[offset].dir;
+	mutex_lock(&chip->lock);
+	direction = !chip->lines[offset].dir;
+	mutex_unlock(&chip->lock);
+
+	return direction;
 }
 
 static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
@@ -283,6 +317,8 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 			return -ENOMEM;
 	}
 
+	mutex_init(&chip->lock);
+
 	gc = &chip->gc;
 	gc->base = base;
 	gc->ngpio = ngpio;
-- 
2.19.1


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

* [PATCH 3/3] gpio: mockup: implement get_multiple()
  2018-11-08 16:52 [PATCH 0/3] gpio: mockup: misc updates Bartosz Golaszewski
  2018-11-08 16:52 ` [PATCH 1/3] gpio: mockup: fix indicated direction Bartosz Golaszewski
  2018-11-08 16:52 ` [PATCH 2/3] gpio: mockup: add locking Bartosz Golaszewski
@ 2018-11-08 16:52 ` Bartosz Golaszewski
  2018-11-08 20:36   ` Uwe Kleine-König
  2018-11-16 21:44   ` Linus Walleij
  2 siblings, 2 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-08 16:52 UTC (permalink / raw)
  To: Bamvor Jian Zhang, Linus Walleij, Uwe Kleine-König
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

We already support set_multiple(). Implement get_multiple() as well.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 drivers/gpio/gpio-mockup.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 3cd92912c414..a4c054cf9c5f 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -102,6 +102,22 @@ static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
 	return val;
 }
 
+static int gpio_mockup_get_multiple(struct gpio_chip *gc,
+				    unsigned long *mask, unsigned long *bits)
+{
+	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
+	unsigned int bit, val;
+
+	mutex_lock(&chip->lock);
+	for_each_set_bit(bit, mask, gc->ngpio) {
+		val = __gpio_mockup_get(gc, bit);
+		__assign_bit(bit, bits, val);
+	}
+	mutex_unlock(&chip->lock);
+
+	return 0;
+}
+
 static void __gpio_mockup_set(struct gpio_chip *gc,
 			      unsigned int offset, int value)
 {
@@ -327,6 +343,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 	gc->parent = dev;
 	gc->get = gpio_mockup_get;
 	gc->set = gpio_mockup_set;
+	gc->get_multiple = gpio_mockup_get_multiple;
 	gc->set_multiple = gpio_mockup_set_multiple;
 	gc->direction_output = gpio_mockup_dirout;
 	gc->direction_input = gpio_mockup_dirin;
-- 
2.19.1


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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-08 16:52 ` [PATCH 1/3] gpio: mockup: fix indicated direction Bartosz Golaszewski
@ 2018-11-08 20:35   ` Uwe Kleine-König
  2018-11-09 11:13     ` Bartosz Golaszewski
  2018-11-16 21:38   ` Linus Walleij
  1 sibling, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-08 20:35 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, linux-gpio, linux-kernel

Hello Bartosz,

On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> beginning") fixed an existing issue but broke libgpiod tests by
> changing the default direction of dummy lines to output.

The indicated commit only changed what was shown in debugfs, but didn't
touch the actual direction of a GPIO, doesn't it? If someone called
gpiod_get_direction before it would have returned "output", too, unless
I miss something.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 3/3] gpio: mockup: implement get_multiple()
  2018-11-08 16:52 ` [PATCH 3/3] gpio: mockup: implement get_multiple() Bartosz Golaszewski
@ 2018-11-08 20:36   ` Uwe Kleine-König
  2018-11-16 21:44   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-08 20:36 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, linux-gpio, linux-kernel

On Thu, Nov 08, 2018 at 05:52:55PM +0100, Bartosz Golaszewski wrote:
> We already support set_multiple(). Implement get_multiple() as well.
> 
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>


-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 2/3] gpio: mockup: add locking
  2018-11-08 16:52 ` [PATCH 2/3] gpio: mockup: add locking Bartosz Golaszewski
@ 2018-11-08 21:13   ` Uwe Kleine-König
  2018-11-16 21:43   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-08 21:13 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, linux-gpio, linux-kernel

On Thu, Nov 08, 2018 at 05:52:54PM +0100, Bartosz Golaszewski wrote:
> While no user reported any race condition problems with gpio-mockup,
> let's be on the safe side and use a mutex when performing any changes
> on the dummy chip structures.
> 
> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> ---
>  drivers/gpio/gpio-mockup.c | 50 ++++++++++++++++++++++++++++++++------
>  1 file changed, 43 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 6a50f9f59c90..3cd92912c414 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -54,6 +54,7 @@ struct gpio_mockup_chip {
>  	struct gpio_mockup_line_status *lines;
>  	struct irq_sim irqsim;
>  	struct dentry *dbg_dir;
> +	struct mutex lock;
>  };
>  
>  struct gpio_mockup_dbgfs_private {
> @@ -82,29 +83,53 @@ static int gpio_mockup_range_ngpio(unsigned int index)
>  	return gpio_mockup_ranges[index * 2 + 1];
>  }
>  
> -static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
> +static int __gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
>  {
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	return chip->lines[offset].value;
>  }
>  
> -static void gpio_mockup_set(struct gpio_chip *gc,
> -			    unsigned int offset, int value)
> +static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
> +{
> +	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
> +	int val;
> +
> +	mutex_lock(&chip->lock);
> +	val = __gpio_mockup_get(gc, offset);
> +	mutex_unlock(&chip->lock);
> +
> +	return val;
> +}

I think this function doesn't need locking. I returns a single value and
if there is a race and some other process currently changes the value it
matters little if the return value is zero or not.

But even with this kept unchanged the patch looks good.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks
Uwe


-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-08 20:35   ` Uwe Kleine-König
@ 2018-11-09 11:13     ` Bartosz Golaszewski
  2018-11-09 11:54       ` Uwe Kleine-König
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-09 11:13 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

czw., 8 lis 2018 o 21:35 Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> napisał(a):
>
> Hello Bartosz,
>
> On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > beginning") fixed an existing issue but broke libgpiod tests by
> > changing the default direction of dummy lines to output.
>
> The indicated commit only changed what was shown in debugfs, but didn't
> touch the actual direction of a GPIO, doesn't it? If someone called
> gpiod_get_direction before it would have returned "output", too, unless
> I miss something.
>

This commit (3edfb7bd76bd) sets the correct direction of the line by
actually calling get_direction() instead of assuming input if
direction_input is not NULL. It just so happened that previously the
default direction of gpio-mockup lines was output but it would be
displayed as input due to this inconsistency.

My commit fixes it by simply setting the value of GPIO_MOCKUP_DIR_IN
to 0 so that when we kzalloc the line structure, we'll get the right
direction automatically.

Bart

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 11:13     ` Bartosz Golaszewski
@ 2018-11-09 11:54       ` Uwe Kleine-König
  2018-11-09 12:24         ` Bartosz Golaszewski
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-09 11:54 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

Hello Bartosz,

On Fri, Nov 09, 2018 at 12:13:44PM +0100, Bartosz Golaszewski wrote:
> czw., 8 lis 2018 o 21:35 Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> napisał(a):
> > On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > > beginning") fixed an existing issue but broke libgpiod tests by
> > > changing the default direction of dummy lines to output.
> >
> > The indicated commit only changed what was shown in debugfs, but didn't
> > touch the actual direction of a GPIO, doesn't it? If someone called
> > gpiod_get_direction before it would have returned "output", too, unless
> > I miss something.
> >
> 
> This commit (3edfb7bd76bd) sets the correct direction of the line by
> actually calling get_direction() instead of assuming input if
> direction_input is not NULL. It just so happened that previously the
> default direction of gpio-mockup lines was output but it would be
> displayed as input due to this inconsistency.

Does the test that fails since 3edfb7bd76bd use debugfs/gpio to find out
the direction of a gpio? I'd say it's a bad idea to depend on this as
(AFAICT) debugfs is only a debug aid and you shouldn't depend on stuff
contained in it.

I'd weaken the commit log a bit to not claim that the commit broke
libgpiod but that it only made the inconsistency visible. After all this
commit didn't "change the default direction of dummy lines to output",
they were an output already before.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 11:54       ` Uwe Kleine-König
@ 2018-11-09 12:24         ` Bartosz Golaszewski
  2018-11-09 13:10           ` Uwe Kleine-König
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-09 12:24 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

pt., 9 lis 2018 o 12:54 Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> napisał(a):
>
> Hello Bartosz,
>
> On Fri, Nov 09, 2018 at 12:13:44PM +0100, Bartosz Golaszewski wrote:
> > czw., 8 lis 2018 o 21:35 Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > > > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > > > beginning") fixed an existing issue but broke libgpiod tests by
> > > > changing the default direction of dummy lines to output.
> > >
> > > The indicated commit only changed what was shown in debugfs, but didn't
> > > touch the actual direction of a GPIO, doesn't it? If someone called
> > > gpiod_get_direction before it would have returned "output", too, unless
> > > I miss something.
> > >
> >
> > This commit (3edfb7bd76bd) sets the correct direction of the line by
> > actually calling get_direction() instead of assuming input if
> > direction_input is not NULL. It just so happened that previously the
> > default direction of gpio-mockup lines was output but it would be
> > displayed as input due to this inconsistency.
>
> Does the test that fails since 3edfb7bd76bd use debugfs/gpio to find out
> the direction of a gpio? I'd say it's a bad idea to depend on this as
> (AFAICT) debugfs is only a debug aid and you shouldn't depend on stuff
> contained in it.
>

No, this is what we get from the LINEINFO ioctl(). I only use debugfs
for triggering dummy interrupts.

> I'd weaken the commit log a bit to not claim that the commit broke
> libgpiod but that it only made the inconsistency visible. After all this
> commit didn't "change the default direction of dummy lines to output",
> they were an output already before.
>

Well it did break the tests you know. ;)

I guess no harm in rewording the message.

Bart

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 12:24         ` Bartosz Golaszewski
@ 2018-11-09 13:10           ` Uwe Kleine-König
  2018-11-09 13:53             ` Bartosz Golaszewski
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-09 13:10 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

Hello,

On Fri, Nov 09, 2018 at 01:24:36PM +0100, Bartosz Golaszewski wrote:
> pt., 9 lis 2018 o 12:54 Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> napisał(a):
> > On Fri, Nov 09, 2018 at 12:13:44PM +0100, Bartosz Golaszewski wrote:
> > > czw., 8 lis 2018 o 21:35 Uwe Kleine-König
> > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > > > > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > > > > beginning") fixed an existing issue but broke libgpiod tests by
> > > > > changing the default direction of dummy lines to output.
> > > >
> > > > The indicated commit only changed what was shown in debugfs, but didn't
> > > > touch the actual direction of a GPIO, doesn't it? If someone called
> > > > gpiod_get_direction before it would have returned "output", too, unless
> > > > I miss something.
> > > >
> > >
> > > This commit (3edfb7bd76bd) sets the correct direction of the line by
> > > actually calling get_direction() instead of assuming input if
> > > direction_input is not NULL. It just so happened that previously the
> > > default direction of gpio-mockup lines was output but it would be
> > > displayed as input due to this inconsistency.
> >
> > Does the test that fails since 3edfb7bd76bd use debugfs/gpio to find out
> > the direction of a gpio? I'd say it's a bad idea to depend on this as
> > (AFAICT) debugfs is only a debug aid and you shouldn't depend on stuff
> > contained in it.
> 
> No, this is what we get from the LINEINFO ioctl(). I only use debugfs
> for triggering dummy interrupts.

A right, gpio_ioctl uses these flags, too.

> > I'd weaken the commit log a bit to not claim that the commit broke
> > libgpiod but that it only made the inconsistency visible. After all this
> > commit didn't "change the default direction of dummy lines to output",
> > they were an output already before.
> 
> Well it did break the tests you know. ;)

Which test failed exactly?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 13:10           ` Uwe Kleine-König
@ 2018-11-09 13:53             ` Bartosz Golaszewski
  2018-11-09 14:39               ` Uwe Kleine-König
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-09 13:53 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

pt., 9 lis 2018 o 14:10 Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> napisał(a):
>
> Hello,
>
> On Fri, Nov 09, 2018 at 01:24:36PM +0100, Bartosz Golaszewski wrote:
> > pt., 9 lis 2018 o 12:54 Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > On Fri, Nov 09, 2018 at 12:13:44PM +0100, Bartosz Golaszewski wrote:
> > > > czw., 8 lis 2018 o 21:35 Uwe Kleine-König
> > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > > > > > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > > > > > beginning") fixed an existing issue but broke libgpiod tests by
> > > > > > changing the default direction of dummy lines to output.
> > > > >
> > > > > The indicated commit only changed what was shown in debugfs, but didn't
> > > > > touch the actual direction of a GPIO, doesn't it? If someone called
> > > > > gpiod_get_direction before it would have returned "output", too, unless
> > > > > I miss something.
> > > > >
> > > >
> > > > This commit (3edfb7bd76bd) sets the correct direction of the line by
> > > > actually calling get_direction() instead of assuming input if
> > > > direction_input is not NULL. It just so happened that previously the
> > > > default direction of gpio-mockup lines was output but it would be
> > > > displayed as input due to this inconsistency.
> > >
> > > Does the test that fails since 3edfb7bd76bd use debugfs/gpio to find out
> > > the direction of a gpio? I'd say it's a bad idea to depend on this as
> > > (AFAICT) debugfs is only a debug aid and you shouldn't depend on stuff
> > > contained in it.
> >
> > No, this is what we get from the LINEINFO ioctl(). I only use debugfs
> > for triggering dummy interrupts.
>
> A right, gpio_ioctl uses these flags, too.
>
> > > I'd weaken the commit log a bit to not claim that the commit broke
> > > libgpiod but that it only made the inconsistency visible. After all this
> > > commit didn't "change the default direction of dummy lines to output",
> > > they were an output already before.
> >
> > Well it did break the tests you know. ;)
>
> Which test failed exactly?
>

All gpioinfo tests that check the output of this command and expect to
see input as line direction.

Bart

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 13:53             ` Bartosz Golaszewski
@ 2018-11-09 14:39               ` Uwe Kleine-König
  2018-11-09 15:24                 ` Bartosz Golaszewski
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-09 14:39 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

On Fri, Nov 09, 2018 at 02:53:16PM +0100, Bartosz Golaszewski wrote:
> pt., 9 lis 2018 o 14:10 Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> napisał(a):
> >
> > Hello,
> >
> > On Fri, Nov 09, 2018 at 01:24:36PM +0100, Bartosz Golaszewski wrote:
> > > pt., 9 lis 2018 o 12:54 Uwe Kleine-König
> > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > On Fri, Nov 09, 2018 at 12:13:44PM +0100, Bartosz Golaszewski wrote:
> > > > > czw., 8 lis 2018 o 21:35 Uwe Kleine-König
> > > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > > On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > > > > > > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > > > > > > beginning") fixed an existing issue but broke libgpiod tests by
> > > > > > > changing the default direction of dummy lines to output.
> > > > > >
> > > > > > The indicated commit only changed what was shown in debugfs, but didn't
> > > > > > touch the actual direction of a GPIO, doesn't it? If someone called
> > > > > > gpiod_get_direction before it would have returned "output", too, unless
> > > > > > I miss something.
> > > > > >
> > > > >
> > > > > This commit (3edfb7bd76bd) sets the correct direction of the line by
> > > > > actually calling get_direction() instead of assuming input if
> > > > > direction_input is not NULL. It just so happened that previously the
> > > > > default direction of gpio-mockup lines was output but it would be
> > > > > displayed as input due to this inconsistency.
> > > >
> > > > Does the test that fails since 3edfb7bd76bd use debugfs/gpio to find out
> > > > the direction of a gpio? I'd say it's a bad idea to depend on this as
> > > > (AFAICT) debugfs is only a debug aid and you shouldn't depend on stuff
> > > > contained in it.
> > >
> > > No, this is what we get from the LINEINFO ioctl(). I only use debugfs
> > > for triggering dummy interrupts.
> >
> > A right, gpio_ioctl uses these flags, too.
> >
> > > > I'd weaken the commit log a bit to not claim that the commit broke
> > > > libgpiod but that it only made the inconsistency visible. After all this
> > > > commit didn't "change the default direction of dummy lines to output",
> > > > they were an output already before.
> > >
> > > Well it did break the tests you know. ;)
> >
> > Which test failed exactly?
> >
> 
> All gpioinfo tests that check the output of this command and expect to
> see input as line direction.

This wasn't the answer I expected. The background of my question was:
This failing test seems to expect that a given GPIO is an input. If that
expectation already exists after the gpio is only requested, then the
test is broken and a fix is necessary there.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 14:39               ` Uwe Kleine-König
@ 2018-11-09 15:24                 ` Bartosz Golaszewski
  2018-11-09 17:03                   ` Uwe Kleine-König
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-09 15:24 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

pt., 9 lis 2018 o 15:39 Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> napisał(a):
>
> On Fri, Nov 09, 2018 at 02:53:16PM +0100, Bartosz Golaszewski wrote:
> > pt., 9 lis 2018 o 14:10 Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> napisał(a):
> > >
> > > Hello,
> > >
> > > On Fri, Nov 09, 2018 at 01:24:36PM +0100, Bartosz Golaszewski wrote:
> > > > pt., 9 lis 2018 o 12:54 Uwe Kleine-König
> > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > On Fri, Nov 09, 2018 at 12:13:44PM +0100, Bartosz Golaszewski wrote:
> > > > > > czw., 8 lis 2018 o 21:35 Uwe Kleine-König
> > > > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > > > On Thu, Nov 08, 2018 at 05:52:53PM +0100, Bartosz Golaszewski wrote:
> > > > > > > > Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> > > > > > > > beginning") fixed an existing issue but broke libgpiod tests by
> > > > > > > > changing the default direction of dummy lines to output.
> > > > > > >
> > > > > > > The indicated commit only changed what was shown in debugfs, but didn't
> > > > > > > touch the actual direction of a GPIO, doesn't it? If someone called
> > > > > > > gpiod_get_direction before it would have returned "output", too, unless
> > > > > > > I miss something.
> > > > > > >
> > > > > >
> > > > > > This commit (3edfb7bd76bd) sets the correct direction of the line by
> > > > > > actually calling get_direction() instead of assuming input if
> > > > > > direction_input is not NULL. It just so happened that previously the
> > > > > > default direction of gpio-mockup lines was output but it would be
> > > > > > displayed as input due to this inconsistency.
> > > > >
> > > > > Does the test that fails since 3edfb7bd76bd use debugfs/gpio to find out
> > > > > the direction of a gpio? I'd say it's a bad idea to depend on this as
> > > > > (AFAICT) debugfs is only a debug aid and you shouldn't depend on stuff
> > > > > contained in it.
> > > >
> > > > No, this is what we get from the LINEINFO ioctl(). I only use debugfs
> > > > for triggering dummy interrupts.
> > >
> > > A right, gpio_ioctl uses these flags, too.
> > >
> > > > > I'd weaken the commit log a bit to not claim that the commit broke
> > > > > libgpiod but that it only made the inconsistency visible. After all this
> > > > > commit didn't "change the default direction of dummy lines to output",
> > > > > they were an output already before.
> > > >
> > > > Well it did break the tests you know. ;)
> > >
> > > Which test failed exactly?
> > >
> >
> > All gpioinfo tests that check the output of this command and expect to
> > see input as line direction.
>
> This wasn't the answer I expected. The background of my question was:
> This failing test seems to expect that a given GPIO is an input. If that
> expectation already exists after the gpio is only requested, then the
> test is broken and a fix is necessary there.
>

The test is only expected to work with gpio-mockup which is a dummy
testing module. I believe its behavior should be as deterministic as
possible to the point where newly created chips always have the same
direction.

Bart

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 15:24                 ` Bartosz Golaszewski
@ 2018-11-09 17:03                   ` Uwe Kleine-König
  2018-11-09 17:23                     ` Bartosz Golaszewski
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-09 17:03 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

Hello Bartosz,

On Fri, Nov 09, 2018 at 04:24:10PM +0100, Bartosz Golaszewski wrote:
> pt., 9 lis 2018 o 15:39 Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> napisał(a):
> > On Fri, Nov 09, 2018 at 02:53:16PM +0100, Bartosz Golaszewski wrote:
> > > pt., 9 lis 2018 o 14:10 Uwe Kleine-König
> > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > Which test failed exactly?
> > >
> > > All gpioinfo tests that check the output of this command and expect to
> > > see input as line direction.
> >
> > This wasn't the answer I expected. The background of my question was:
> > This failing test seems to expect that a given GPIO is an input. If that
> > expectation already exists after the gpio is only requested, then the
> > test is broken and a fix is necessary there.
> 
> The test is only expected to work with gpio-mockup which is a dummy
> testing module. I believe its behavior should be as deterministic as
> possible to the point where newly created chips always have the same
> direction.

Given that the initial direction of a GPIO isn't fixed in my eyes the
test should be able to cope with both possibilities. I'd say it's a bug
in the test if it doesn't.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 17:03                   ` Uwe Kleine-König
@ 2018-11-09 17:23                     ` Bartosz Golaszewski
  2018-11-11 16:59                       ` Uwe Kleine-König
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-09 17:23 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

pt., 9 lis 2018 o 18:03 Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> napisał(a):
>
> Hello Bartosz,
>
> On Fri, Nov 09, 2018 at 04:24:10PM +0100, Bartosz Golaszewski wrote:
> > pt., 9 lis 2018 o 15:39 Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > On Fri, Nov 09, 2018 at 02:53:16PM +0100, Bartosz Golaszewski wrote:
> > > > pt., 9 lis 2018 o 14:10 Uwe Kleine-König
> > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > Which test failed exactly?
> > > >
> > > > All gpioinfo tests that check the output of this command and expect to
> > > > see input as line direction.
> > >
> > > This wasn't the answer I expected. The background of my question was:
> > > This failing test seems to expect that a given GPIO is an input. If that
> > > expectation already exists after the gpio is only requested, then the
> > > test is broken and a fix is necessary there.
> >
> > The test is only expected to work with gpio-mockup which is a dummy
> > testing module. I believe its behavior should be as deterministic as
> > possible to the point where newly created chips always have the same
> > direction.
>
> Given that the initial direction of a GPIO isn't fixed in my eyes the
> test should be able to cope with both possibilities. I'd say it's a bug
> in the test if it doesn't.
>

As I said before: it is and should be fixed in this specific case.
This isn't real hardware.

Bart

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-09 17:23                     ` Bartosz Golaszewski
@ 2018-11-11 16:59                       ` Uwe Kleine-König
  2018-11-12 14:14                         ` Bartosz Golaszewski
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-11 16:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

On Fri, Nov 09, 2018 at 06:23:01PM +0100, Bartosz Golaszewski wrote:
> pt., 9 lis 2018 o 18:03 Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> napisał(a):
> >
> > Hello Bartosz,
> >
> > On Fri, Nov 09, 2018 at 04:24:10PM +0100, Bartosz Golaszewski wrote:
> > > pt., 9 lis 2018 o 15:39 Uwe Kleine-König
> > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > On Fri, Nov 09, 2018 at 02:53:16PM +0100, Bartosz Golaszewski wrote:
> > > > > pt., 9 lis 2018 o 14:10 Uwe Kleine-König
> > > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > > Which test failed exactly?
> > > > >
> > > > > All gpioinfo tests that check the output of this command and expect to
> > > > > see input as line direction.
> > > >
> > > > This wasn't the answer I expected. The background of my question was:
> > > > This failing test seems to expect that a given GPIO is an input. If that
> > > > expectation already exists after the gpio is only requested, then the
> > > > test is broken and a fix is necessary there.
> > >
> > > The test is only expected to work with gpio-mockup which is a dummy
> > > testing module. I believe its behavior should be as deterministic as
> > > possible to the point where newly created chips always have the same
> > > direction.
> >
> > Given that the initial direction of a GPIO isn't fixed in my eyes the
> > test should be able to cope with both possibilities. I'd say it's a bug
> > in the test if it doesn't.
> >
> 
> As I said before: it is and should be fixed in this specific case.
> This isn't real hardware.

Not sure if we agree here yet. What do you want to fix? The driver or
the test?

In my eyes test driven development is great. But if something breaks
because the test is wrong, please don't "fix" the system to repair the
test, but modify the test to be able to handle reality.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-11 16:59                       ` Uwe Kleine-König
@ 2018-11-12 14:14                         ` Bartosz Golaszewski
  2018-11-13  6:57                           ` Uwe Kleine-König
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-12 14:14 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

niedz., 11 lis 2018 o 17:59 Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> napisał(a):
>
> On Fri, Nov 09, 2018 at 06:23:01PM +0100, Bartosz Golaszewski wrote:
> > pt., 9 lis 2018 o 18:03 Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> napisał(a):
> > >
> > > Hello Bartosz,
> > >
> > > On Fri, Nov 09, 2018 at 04:24:10PM +0100, Bartosz Golaszewski wrote:
> > > > pt., 9 lis 2018 o 15:39 Uwe Kleine-König
> > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > On Fri, Nov 09, 2018 at 02:53:16PM +0100, Bartosz Golaszewski wrote:
> > > > > > pt., 9 lis 2018 o 14:10 Uwe Kleine-König
> > > > > > <u.kleine-koenig@pengutronix.de> napisał(a):
> > > > > > > Which test failed exactly?
> > > > > >
> > > > > > All gpioinfo tests that check the output of this command and expect to
> > > > > > see input as line direction.
> > > > >
> > > > > This wasn't the answer I expected. The background of my question was:
> > > > > This failing test seems to expect that a given GPIO is an input. If that
> > > > > expectation already exists after the gpio is only requested, then the
> > > > > test is broken and a fix is necessary there.
> > > >
> > > > The test is only expected to work with gpio-mockup which is a dummy
> > > > testing module. I believe its behavior should be as deterministic as
> > > > possible to the point where newly created chips always have the same
> > > > direction.
> > >
> > > Given that the initial direction of a GPIO isn't fixed in my eyes the
> > > test should be able to cope with both possibilities. I'd say it's a bug
> > > in the test if it doesn't.
> > >
> >
> > As I said before: it is and should be fixed in this specific case.
> > This isn't real hardware.
>
> Not sure if we agree here yet. What do you want to fix? The driver or
> the test?
>
> In my eyes test driven development is great. But if something breaks
> because the test is wrong, please don't "fix" the system to repair the
> test, but modify the test to be able to handle reality.
>

No, we don't have an agreement. You think I should fix the test, I
think the dummy driver should continue behaving like before.

Given that there's no real hardware behind, the direction of newly
created dummy lines has always been deterministic - input. Certain
tests have been relying on it. I want to keep on doing it. There's no
harm. It's not broken logic as the very purpose of this module is to
allow for easy testing of the UAPI.

So unless something *else* is wrong with this patch, I intend to push
it upstream.

Best regards,
Bartosz Golaszewski

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-12 14:14                         ` Bartosz Golaszewski
@ 2018-11-13  6:57                           ` Uwe Kleine-König
  0 siblings, 0 replies; 24+ messages in thread
From: Uwe Kleine-König @ 2018-11-13  6:57 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

Hello Bartosz,

On Mon, Nov 12, 2018 at 03:14:31PM +0100, Bartosz Golaszewski wrote:
> > > As I said before: it is and should be fixed in this specific case.
> > > This isn't real hardware.

Not being "real hardware" is hardly an argument that matters here.

> > Not sure if we agree here yet. What do you want to fix? The driver or
> > the test?
> >
> > In my eyes test driven development is great. But if something breaks
> > because the test is wrong, please don't "fix" the system to repair the
> > test, but modify the test to be able to handle reality.
> >
> 
> No, we don't have an agreement. You think I should fix the test, I
> think the dummy driver should continue behaving like before.

It's arguable if after your patch the driver behaves as before. IMHO the
initial direction was output from the start before. This was just
shadowed by the an inconsitency that was fixed some time ago.

> Given that there's no real hardware behind, the direction of newly
> created dummy lines has always been deterministic - input. Certain
> tests have been relying on it. I want to keep on doing it. There's no
> harm. It's not broken logic as the very purpose of this module is to
> allow for easy testing of the UAPI.
> 
> So unless something *else* is wrong with this patch, I intend to push
> it upstream.

Note I don't oppose to the patch as is. Just the motiviation is wrong
and I'd do both: Modify the mockup driver to start with direction=input
and modify the tests to not expect this.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 1/3] gpio: mockup: fix indicated direction
  2018-11-08 16:52 ` [PATCH 1/3] gpio: mockup: fix indicated direction Bartosz Golaszewski
  2018-11-08 20:35   ` Uwe Kleine-König
@ 2018-11-16 21:38   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2018-11-16 21:38 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Uwe Kleine-König,
	open list:GPIO SUBSYSTEM, linux-kernel

On Thu, Nov 8, 2018 at 5:53 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> Commit 3edfb7bd76bd ("gpiolib: Show correct direction from the
> beginning") fixed an existing issue but broke libgpiod tests by
> changing the default direction of dummy lines to output.
>
> We don't break user-space so make gpio-mockup behave as before.
>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

Patch applied for fixes.

I browsed the debate here. I think this should be applied for
fixes, then if the test should be changed, we can do that for
devel in that case.

Yours,
Linus Walleij

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

* Re: [PATCH 2/3] gpio: mockup: add locking
  2018-11-08 16:52 ` [PATCH 2/3] gpio: mockup: add locking Bartosz Golaszewski
  2018-11-08 21:13   ` Uwe Kleine-König
@ 2018-11-16 21:43   ` Linus Walleij
  2018-11-19  9:09     ` Bartosz Golaszewski
  1 sibling, 1 reply; 24+ messages in thread
From: Linus Walleij @ 2018-11-16 21:43 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Uwe Kleine-König,
	open list:GPIO SUBSYSTEM, linux-kernel

On Thu, Nov 8, 2018 at 5:53 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> While no user reported any race condition problems with gpio-mockup,
> let's be on the safe side and use a mutex when performing any changes
> on the dummy chip structures.
>
> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

I tried to apply this but it failed, does it require patch 1?

I can pull in the next -rc after I merged the fix in that case
and we can apply on top.

__gpio_*
I tend to dislike __underscore_notation because I feel it
is semantically ambguous. I prefer a proper name, even
to the point that I prefer inner_function_foo over __foo,
but it's your driver and I might be a bit grumpy. :)

Yours,
Linus Walleij

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

* Re: [PATCH 3/3] gpio: mockup: implement get_multiple()
  2018-11-08 16:52 ` [PATCH 3/3] gpio: mockup: implement get_multiple() Bartosz Golaszewski
  2018-11-08 20:36   ` Uwe Kleine-König
@ 2018-11-16 21:44   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2018-11-16 21:44 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Uwe Kleine-König,
	open list:GPIO SUBSYSTEM, linux-kernel

On Thu, Nov 8, 2018 at 5:53 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> We already support set_multiple(). Implement get_multiple() as well.
>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

Waiting to see how I should apply patch 1+2 but all looks
good to me!

Yours,
Linus Walleij

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

* Re: [PATCH 2/3] gpio: mockup: add locking
  2018-11-16 21:43   ` Linus Walleij
@ 2018-11-19  9:09     ` Bartosz Golaszewski
  2018-11-20  8:46       ` Linus Walleij
  0 siblings, 1 reply; 24+ messages in thread
From: Bartosz Golaszewski @ 2018-11-19  9:09 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bamvor Jian Zhang, Uwe Kleine-König,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

pt., 16 lis 2018 o 22:43 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> On Thu, Nov 8, 2018 at 5:53 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> > While no user reported any race condition problems with gpio-mockup,
> > let's be on the safe side and use a mutex when performing any changes
> > on the dummy chip structures.
> >
> > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
>
> I tried to apply this but it failed, does it require patch 1?
>

Yes, because of the change in get_direction().

> I can pull in the next -rc after I merged the fix in that case
> and we can apply on top.
>

This is fine, it's aimed for 4.21 anyway.

> __gpio_*
> I tend to dislike __underscore_notation because I feel it
> is semantically ambguous. I prefer a proper name, even
> to the point that I prefer inner_function_foo over __foo,
> but it's your driver and I might be a bit grumpy. :)
>

I think this is a common and intuitive pattern in the kernel codebase.
Many subsystems and drivers use '__' to mark functions that execute
internal logic and expect certain locks to be held etc.

If you don't mind, I'd like to leave it like this.

Bart

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

* Re: [PATCH 2/3] gpio: mockup: add locking
  2018-11-19  9:09     ` Bartosz Golaszewski
@ 2018-11-20  8:46       ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2018-11-20  8:46 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bamvor Jian Zhang, Uwe Kleine-König,
	open list:GPIO SUBSYSTEM, linux-kernel

On Mon, Nov 19, 2018 at 10:09 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> pt., 16 lis 2018 o 22:43 Linus Walleij <linus.walleij@linaro.org> napisał(a):

> > __gpio_*
> > I tend to dislike __underscore_notation because I feel it
> > is semantically ambguous. I prefer a proper name, even
> > to the point that I prefer inner_function_foo over __foo,
> > but it's your driver and I might be a bit grumpy. :)
>
> I think this is a common and intuitive pattern in the kernel codebase.
> Many subsystems and drivers use '__' to mark functions that execute
> internal logic and expect certain locks to be held etc.

You say it yourself: interpretation depends on context.

I might be especially stupid for being unable to discern
meaning from context in these cases and so what is
intuitive for some is just not intuitive for me.

Example:
set_bit() vs __set_bit()

Apparently some kernel developers think it is completely
obvious that the latter is the unlocked non-atomic version
of set_bit(). However I was confused for years with no
idea as to what the difference was.

Had it simply been named set_bit_nonatomic(), at the
cost of a few characters, confusion on my part would be
avoided and at least to me the world would be a better
place.

> If you don't mind, I'd like to leave it like this.

No big deal, keep it as is :)

Yours,
Linus Walleij

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

end of thread, other threads:[~2018-11-20  8:48 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-08 16:52 [PATCH 0/3] gpio: mockup: misc updates Bartosz Golaszewski
2018-11-08 16:52 ` [PATCH 1/3] gpio: mockup: fix indicated direction Bartosz Golaszewski
2018-11-08 20:35   ` Uwe Kleine-König
2018-11-09 11:13     ` Bartosz Golaszewski
2018-11-09 11:54       ` Uwe Kleine-König
2018-11-09 12:24         ` Bartosz Golaszewski
2018-11-09 13:10           ` Uwe Kleine-König
2018-11-09 13:53             ` Bartosz Golaszewski
2018-11-09 14:39               ` Uwe Kleine-König
2018-11-09 15:24                 ` Bartosz Golaszewski
2018-11-09 17:03                   ` Uwe Kleine-König
2018-11-09 17:23                     ` Bartosz Golaszewski
2018-11-11 16:59                       ` Uwe Kleine-König
2018-11-12 14:14                         ` Bartosz Golaszewski
2018-11-13  6:57                           ` Uwe Kleine-König
2018-11-16 21:38   ` Linus Walleij
2018-11-08 16:52 ` [PATCH 2/3] gpio: mockup: add locking Bartosz Golaszewski
2018-11-08 21:13   ` Uwe Kleine-König
2018-11-16 21:43   ` Linus Walleij
2018-11-19  9:09     ` Bartosz Golaszewski
2018-11-20  8:46       ` Linus Walleij
2018-11-08 16:52 ` [PATCH 3/3] gpio: mockup: implement get_multiple() Bartosz Golaszewski
2018-11-08 20:36   ` Uwe Kleine-König
2018-11-16 21:44   ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).