mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH 1/8] gpiolib: check the return value of gpio_chip::get_direction()
Date: Wed, 19 Feb 2025 10:13:58 +0100	[thread overview]
Message-ID: <7c045d13-146f-448c-ad73-60069059b242@samsung.com> (raw)
In-Reply-To: <CAMRc=MduJK0_gat2aVQbR9udYNj9oDcoN=me0wa4K6L8dX_52Q@mail.gmail.com>

On 19.02.2025 09:50, Bartosz Golaszewski wrote:
> On Wed, Feb 19, 2025 at 9:38 AM Marek Szyprowski
> <m.szyprowski@samsung.com> wrote:
>> On 10.02.2025 11:51, Bartosz Golaszewski wrote:
>>> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>>>
>>> As per the API contract - gpio_chip::get_direction() may fail and return
>>> a negative error number. However, we treat it as if it always returned 0
>>> or 1. Check the return value of the callback and propagate the error
>>> number up the stack.
>>>
>> This change breaks bcm2835 pincontrol/gpio driver (and probably others)
>> in next-20250218. The problem is that some gpio lines are initially
>> configured as alternate function (i.e. uart) and .get_direction returns
>> -EINVAL for them, what in turn causes the whole gpio chip fail to
>> register. Here is the log with WARN_ON() added to line
>> drivers/pinctrl/bcm/pinctrl-bcm2835.c:350 from Raspberry Pi 4B:
>>
>> Any suggestions how to fix this issue? Should we add
>> GPIO_LINE_DIRECTION_UNKNOWN?
>>
> That would be quite an intrusive change and not something for the
> middle of the release cycle. I think we need to revert to the previous
> behavior for this particular use-case: check ret for EINVAL and assume
> it means input as it's the "safe" setting. Now the question is - can
> this only happen during the chip registration or should we filter out
> EINVAL at each gpiod_get_direction() call?

IMHO it will be enough to use that workaround only in the 
gpiochip_add_data_with_key() function. The other functions modified by 
the $subject patch are strictly related to input or output gpio mode of 
operation, so having the line set to proper input/output state seems to 
be justified.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


  reply	other threads:[~2025-02-19  9:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10 10:51 [PATCH 0/8] gpiolib: sanitize return values of callbacks Bartosz Golaszewski
2025-02-10 10:51 ` [PATCH 1/8] gpiolib: check the return value of gpio_chip::get_direction() Bartosz Golaszewski
2025-02-19  2:42   ` Mark Brown
     [not found]   ` <CGME20250219083836eucas1p1b7ecc6e5fdc34d66ef7565bfcf399254@eucas1p1.samsung.com>
2025-02-19  8:38     ` Marek Szyprowski
2025-02-19  8:50       ` Bartosz Golaszewski
2025-02-19  9:13         ` Marek Szyprowski [this message]
2025-02-19  9:22           ` Bartosz Golaszewski
2025-02-25 13:19       ` Antonio Borneo
2025-02-10 10:51 ` [PATCH 2/8] gpiolib: sanitize the return value of gpio_chip::request() Bartosz Golaszewski
2025-02-10 10:51 ` [PATCH 3/8] gpiolib: sanitize the return value of gpio_chip::set_config() Bartosz Golaszewski
2025-02-10 10:51 ` [PATCH 4/8] gpiolib: sanitize the return value of gpio_chip::get() Bartosz Golaszewski
2025-02-24 16:30   ` Andy Shevchenko
2025-02-25 10:35     ` Bartosz Golaszewski
2025-02-10 10:51 ` [PATCH 5/8] gpiolib: sanitize the return value of gpio_chip::get_multiple() Bartosz Golaszewski
2025-02-10 10:52 ` [PATCH 6/8] gpiolib: sanitize the return value of gpio_chip::direction_output() Bartosz Golaszewski
2025-02-10 10:52 ` [PATCH 7/8] gpiolib: sanitize the return value of gpio_chip::direction_input() Bartosz Golaszewski
2025-02-10 10:52 ` [PATCH 8/8] gpiolib: sanitize the return value of gpio_chip::get_direction() Bartosz Golaszewski
2025-02-24 16:33   ` Andy Shevchenko
2025-02-24 19:55     ` Bartosz Golaszewski
2025-02-24 20:25       ` Andy Shevchenko
     [not found]   ` <CGME20250225101340eucas1p13c0c9cbc62ee7c9bfe964941c901bd1b@eucas1p1.samsung.com>
2025-02-25 10:13     ` Marek Szyprowski
2025-02-25 10:17       ` Bartosz Golaszewski
2025-02-14  9:21 ` [PATCH 0/8] gpiolib: sanitize return values of callbacks Linus Walleij
2025-02-17 10:51 ` (subset) " Bartosz Golaszewski
2025-02-24  9:05 ` Bartosz Golaszewski

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=7c045d13-146f-448c-ad73-60069059b242@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.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®