Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andy Shevchenko <andy@kernel.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, regressions@lists.linux.dev
Subject: Re: [PATCH v2] gpiolib: Fix triggering "kobject: 'gpiochipX' is not initialized, yet" kobject_get() errors
Date: Wed, 3 Apr 2024 10:17:43 +0200	[thread overview]
Message-ID: <0303f5f6-05f8-43c7-8922-11de2550d356@redhat.com> (raw)
In-Reply-To: <CAHp75VeJYASFaxwG2yuAdBLn7H5hK1BESP7p+3CzBVmNdCTpwg@mail.gmail.com>

Hi,

On 4/2/24 6:51 PM, Andy Shevchenko wrote:
> On Tue, Apr 2, 2024 at 7:43 PM Hans de Goede <hdegoede@redhat.com> wrote:
>>
>> When a gpiochip gets added by loading a module, then another driver may
>> be waiting for that gpiochip to load on the deferred-probe list.
>>
>> If the deferred-probe for the consumer of gpiochip then triggers between
>> the gpiodev_add_to_list_unlocked() calls which makes gpio_device_find()
>> see the chip and the gpiochip_setup_dev() later then gpio_device_find()
>> does a kobject_get() on an uninitialzed kobject since the kobject is
> 
> uninitialized

Bartosz, can you fix this up while merging or do you prefer a v3?


>> initialized by gpiochip_setup_dev() calling device_initialize():
>>
>>  arizona spi-10WM5102:00: cannot find GPIO chip arizona, deferring
>>  arizona spi-10WM5102:00: cannot find GPIO chip arizona, deferring
>>  ------------[ cut here ]------------
>>  kobject: 'gpiochip5' (00000000241466f2): is not initialized, yet kobject_get() is being called.
>>  WARNING: CPU: 3 PID: 42 at lib/kobject.c:640 kobject_get+0x43/0x70
>>  Call Trace:
>>   kobject_get
>>   gpio_device_find
>>   gpiod_find_and_request
>>   gpiod_get
>>   snd_byt_wm5102_mc_probe
>>
>> Not only is the device not initialized yet, but when the gpio-device is
>> added to the list things like the irqchip also have not been initialized
>> yet.
>>
>> So gpio_device_find() should really ignore the gpio-device until
>> gpiochip_add_data_with_key() is fully done. Add a device_is_registered()
>> check to gpio_device_find() to ignore gpio-devices on the list which are
>> not yet fully initialized.
> 
> Reviewed-by: Andy Shevchenko <andy@kernel.org>

Thank you for the review.

Regards,

Hans



  reply	other threads:[~2024-04-03  8:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 16:43 [PATCH v2] gpiolib: Fix triggering "kobject: 'gpiochipX' is not initialized, yet" kobject_get() errors Hans de Goede
2024-04-02 16:51 ` Andy Shevchenko
2024-04-03  8:17   ` Hans de Goede [this message]
2024-04-03 11: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=0303f5f6-05f8-43c7-8922-11de2550d356@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=regressions@lists.linux.dev \
    /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