public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Andy Shevchenko <andy@kernel.org>, Kate Hsuan <hpa@redhat.com>,
	Tsuchiya Yuto <kitakar@gmail.com>,
	Yury Luneff <yury.lunev@gmail.com>,
	Nable <nable.maininbox@googlemail.com>,
	andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH 1/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper function
Date: Fri, 19 May 2023 10:55:42 +0200	[thread overview]
Message-ID: <cb4e56fd-0745-6040-6d93-bd8eb1d23ce1@redhat.com> (raw)
In-Reply-To: <ZGcl7+cKu0/h43YC@kekkonen.localdomain>

Hi Sakari,

On 5/19/23 09:31, Sakari Ailus wrote:
> Hi Hans,
> 
> On Thu, May 18, 2023 at 05:32:06PM +0200, Hans de Goede wrote:
>> On x86/ACPI platforms the GPIO resources do not provide information
>> about which GPIO resource maps to which connection-id. So e.g.
>> gpiod_get(devg, "reset") does not work.
>>
>> On devices with an Intel IPU3 or newer ISP there is a special ACPI
>> INT3472 device describing the GPIOs and instantiating of the i2c_client
>> for a sensor is deferred until the INT3472 driver has been bound based
>> on the sensor ACPI device having a _DEP on the INT3472 ACPI device.
>>
>> This allows the INT3472 driver to add the necessary GPIO lookups
>> without needing any special ACPI handling in the sensor driver.
>>
>> Unfortunately this does not work on devices with an atomisp2 ISP,
>> there the _DSM describing the GPIOs is part of the sensor ACPI device
>> itself, rather then being part of a separate ACPI device.
>>
>> IOW there is no separate firmware-node to which we can bind to register
>> the GPIO lookups (and also no way to defer creating the sensor i2c_client).
>>
>> This unfortunately means that all sensor drivers which may be used on
>> BYT or CHT hw need some code to deal with ACPI integration.
>>
>> This patch adds a new v4l2_acpi_parse_sensor_gpios() helper function
>> for this, which does all the necessary work. This minimizes the
>> (unavoidable) change to sensor drivers for ACPI integration to just
>> adding a single line calling this void function to probe().
> 
> I'd rather avoid making changes to sensor drivers due to this hack. At the
> very least it must be labelled so: this has no more to do with ACPI
> standard than that this information happens to be located in an ACPI table.

IMHO this is definitely a problem with a mismatch between how the ACPI spec.
describes GPIOs vs the linux GPIO APIs which are based on the DT model

Almost all drivers which deal with ACPI enumerated devices also have to
deal with this mismatch. Most drivers come with their own acpi_gpio_mapping
table and call devm_acpi_dev_add_driver_gpios() before doing any gpiod_get()
calls because of this. This is in no way unique to sensor drivers.

The only way around this is embedding DT bits inside ACPI and if anything
the embedding DT bits inside ACPI is the hack here.

Anyways whether this is a hack or not is bikeshedding. But your calling
it a hack seems to come from a somewhat devicetree centric view; at least
doing the DT embedding thing is certainly the exception and not the rule
in the ACPI world since most ACPI tables are written for Windows which
does not use the embedded DT bits.

The Intel ISP/IPU sensor GPIO handling is a bit special because instead
of having a simple index -> connection-id mapping it involves a _DSM,
but that part is all abstracted away inside the new helper and actually
avoids the need to have an acpi_gpio_mapping per sensor-driver, which would
be the normal way to deal with this and which would actually mean a lot
more code per driver.

> Although if the number of those drivers would be small, this could be just
> undesirable but still somehow acceptable. And I wouldn't expect new sensors
> to be paired with the IPU2 anymore. How many drivers there would be
> roughly? I think I've seen ten-ish sensor drivers with the atomisp driver.

About ten-ish drivers sounds right.

> Isn't it possible to create a device for this purpose and use software
> nodes for the GPIOs? I guess that would be a hack as well and you'd somehow
> have to initialise this via other route than driver probe.

This creates unsolvable probe-ordering problems. At a minimum we would
need some check inside sensor drivers for them to return -EPROBE_DEFER
until the GPIO mappings are added through some other means. Note that
without the mappings gpiod_get will return -ENOENT, so we cannot just
use its return value.

And if we need some changes anyways just adding the single line call
to the new helper seems both the least invasive and the easiest.

Regards,

Hans



  reply	other threads:[~2023-05-19  8:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 15:32 [PATCH 0/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper + gc0310 sensor driver Hans de Goede
2023-05-18 15:32 ` [PATCH 1/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper function Hans de Goede
2023-05-18 16:36   ` Andy Shevchenko
2023-05-18 16:57     ` Hans de Goede
2023-05-19 10:19       ` Andy Shevchenko
2023-05-18 19:48   ` kernel test robot
2023-05-19  7:31   ` Sakari Ailus
2023-05-19  8:55     ` Hans de Goede [this message]
2023-05-19 10:21       ` Andy Shevchenko
2023-05-19 10:58       ` Sakari Ailus
2023-05-19 11:55         ` Hans de Goede
2023-05-19 12:16           ` Sakari Ailus
2023-05-19 13:08             ` Hans de Goede
2023-05-19 14:01               ` Sakari Ailus
2023-05-19 14:39                 ` Hans de Goede
2023-05-24 12:16                   ` Sakari Ailus
2023-05-18 15:32 ` [PATCH 2/9] media: atomisp: Switch to v4l2_acpi_parse_sensor_gpios() Hans de Goede
2023-05-18 15:32 ` [PATCH 3/9] media: atomisp: gc0310: Turn into standard v4l2 sensor driver Hans de Goede
2023-05-18 15:32 ` [PATCH 4/9] media: atomisp: gc0310: Drop XXGC0310 ACPI hardware-id Hans de Goede
2023-05-19 10:24   ` Andy Shevchenko
2023-05-18 15:32 ` [PATCH 5/9] media: atomisp: gc0310: Fix double free in gc0310_remove() Hans de Goede
2023-05-18 15:32 ` [PATCH 6/9] media: atomisp: gc0310: Cleanup includes Hans de Goede
2023-05-18 15:32 ` [PATCH 7/9] media: atomisp: gc0310: Remove gc0310_s_config() function Hans de Goede
2023-05-19 10:32   ` Andy Shevchenko
2023-05-19 10:35     ` Hans de Goede
2023-05-18 15:32 ` [PATCH 8/9] media: atomisp: gc0310: Remove gc0310.h Hans de Goede
2023-05-18 15:32 ` [PATCH 9/9] media: Move gc0310 sensor drivers to drivers/media/i2c/ Hans de Goede
2023-05-21  1:13   ` kernel test robot
2023-05-18 16:02 ` [PATCH 0/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper + gc0310 sensor driver Andy Shevchenko
2023-05-18 16:49   ` Hans de Goede
2023-05-19 12:14 ` Andy Shevchenko

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=cb4e56fd-0745-6040-6d93-bd8eb1d23ce1@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andrey.i.trufanov@gmail.com \
    --cc=andy@kernel.org \
    --cc=fabioaiuto83@gmail.com \
    --cc=hpa@redhat.com \
    --cc=kitakar@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=nable.maininbox@googlemail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yury.lunev@gmail.com \
    /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