mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.caveayland@nutanix.com>
To: wbg@kernel.org, linus.walleij@linaro.org, brgl@bgdev.pl,
	andriy.shevchenko@linux.intel.com, mwalle@kernel.org,
	broonie@kernel.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: gpio: gpio-pci-idio-16 regression after LTS upgrade
Date: Mon, 6 Oct 2025 09:37:14 +0100	[thread overview]
Message-ID: <9b0375fd-235f-4ee1-a7fa-daca296ef6bf@nutanix.com> (raw)

Hi all,

As part of our internal vfio testing here at Nutanix we make use of an 
emulated gpio-pci-idio-16 device. Recently we've upgraded our LTS kernel 
and found that the device stops working which I've bisected down to this 
commit:

$ git bisect bad
73d8f3efc5c2b757ab06685741df01eaed8090c4 is the first bad commit
commit 73d8f3efc5c2b757ab06685741df01eaed8090c4
Author: William Breathitt Gray <william.gray@linaro.org>
Date:   Thu Aug 10 18:00:40 2023 -0400

     gpio: pci-idio-16: Migrate to the regmap API

     The regmap API supports IO port accessors so we can take advantage of
     regmap abstractions rather than handling access to the device registers
     directly in the driver. Migrate the pci-idio-16 module to the new
     idio-16 library interface leveraging the gpio-regmap API.

     Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
     Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
     Link: 
https://lore.kernel.org/r/5ba5405c64aca984d5cf3bdbdffa04c325e5a147.1680618405.git.william.gray@linaro.org/
     Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
     Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
     Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

  drivers/gpio/Kconfig            |   2 +-
  drivers/gpio/gpio-pci-idio-16.c | 294 
+++++++++-------------------------------
  2 files changed, 62 insertions(+), 234 deletions(-)


With this commit when the gpio-pci-idio16 module fails upon load as below:

[    0.266606] pci-idio-16 0000:00:03.0: error -EINVAL: Unable to 
initialize register map
[    0.266867] pci-idio-16: probe of 0000:00:03.0 failed with error -22

After some more debugging I was able to determine that the failure was 
due to the regmap cache failing initialisation in 
drivers/base/regmap/regcache-flat.c::regcache_flat_init() because 
max_register wasn't set on the regmap. I was able to fix that fairly 
easily with this:


diff --git a/drivers/gpio/gpio-pci-idio-16.c 
b/drivers/gpio/gpio-pci-idio-16.c
index 44c0a21b1d1d..55be571b5cca 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -41,6 +41,7 @@ static const struct regmap_config 
idio_16_regmap_config = {
         .reg_stride = 1,
         .val_bits = 8,
         .io_port = true,
+  .max_register = 0x7,
         .wr_table = &idio_16_wr_table,
         .rd_table = &idio_16_rd_table,
         .volatile_table = &idio_16_rd_table,


Okay so the module now loads, but all of my gpios are now inputs!

root@debian12:~# gpioinfo
gpiochip0 - 32 lines:
     line   0:       "OUT0"       unused   input  active-high
     line   1:       "OUT1"       unused   input  active-high
     line   2:       "OUT2"       unused   input  active-high
     line   3:       "OUT3"       unused   input  active-high
     line   4:       "OUT4"       unused   input  active-high
     line   5:       "OUT5"       unused   input  active-high
     line   6:       "OUT6"       unused   input  active-high
     line   7:       "OUT7"       unused   input  active-high
     line   8:       "OUT8"       unused   input  active-high
     line   9:       "OUT9"       unused   input  active-high
     line  10:      "OUT10"       unused   input  active-high
     line  11:      "OUT11"       unused   input  active-high
     line  12:      "OUT12"       unused   input  active-high
     line  13:      "OUT13"       unused   input  active-high
     line  14:      "OUT14"       unused   input  active-high
     line  15:      "OUT15"       unused   input  active-high
     line  16:       "IIN0"       unused   input  active-high
     line  17:       "IIN1"       unused   input  active-high
     line  18:       "IIN2"       unused   input  active-high
     line  19:       "IIN3"       unused   input  active-high
     line  20:       "IIN4"       unused   input  active-high
     line  21:       "IIN5"       unused   input  active-high
     line  22:       "IIN6"       unused   input  active-high
     line  23:       "IIN7"       unused   input  active-high
     line  24:       "IIN8"       unused   input  active-high
     line  25:       "IIN9"       unused   input  active-high
     line  26:      "IIN10"       unused   input  active-high
     line  27:      "IIN11"       unused   input  active-high
     line  28:      "IIN12"       unused   input  active-high
     line  29:      "IIN13"       unused   input  active-high
     line  30:      "IIN14"       unused   input  active-high
     line  31:      "IIN15"       unused   input  active-high

root@debian12:~# gpioget 0 0
gpioget: error reading GPIO values: Input/output error

which also output:

[  329.529321] gpio-512 (gpioget): gpiod_direction_input: missing 
direction_input() operation and line is output

My guess is that this is because 
drivers/gpio/gpio-regmap.c::gpio_regmap_get_direction() isn't able to 
can't handle the situation where lines 0-15 are outputs and lines 16-31 
are inputs, compared with the old idio_16_gpio_get_direction() function 
it replaced.

What would be the best way forward? Possibly add the .get_direction 
callback to the gpio_regmap_config? Or is there another way to have 
mixed inputs and outputs with the gpio_regmap API?


Many thanks,

Mark.


             reply	other threads:[~2025-10-06  8:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-06  8:37 Mark Cave-Ayland [this message]
2025-10-07  8:16 ` William Breathitt Gray
2025-10-09  9:05   ` Mark Cave-Ayland
2025-10-09  9:49     ` William Breathitt Gray
2025-10-14  9:03       ` Michael Walle
2025-10-14 11:21         ` Ioana Ciornei
2025-10-14 11:25           ` Michael Walle
2025-10-14 11:40             ` Ioana Ciornei
2025-10-12 14:22 ` William Breathitt Gray
2025-10-13 10:32   ` Mark Cave-Ayland

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=9b0375fd-235f-4ee1-a7fa-daca296ef6bf@nutanix.com \
    --to=mark.caveayland@nutanix.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mwalle@kernel.org \
    --cc=wbg@kernel.org \
    /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

all inboxes | Powered by JetHome®