From: Greg KH <gregkh@linuxfoundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Douglas Anderson <dianders@chromium.org>,
Linus Walleij <linus.walleij@linaro.org>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>, Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: ti-sn65dsi86: Fix multiple instances
Date: Mon, 21 Oct 2024 09:27:23 +0200 [thread overview]
Message-ID: <2024102137-repost-visiting-323d@gregkh> (raw)
In-Reply-To: <CAMuHMdUWAQKRy6F-zyCK6efhSYDRo2Go-f-=t2kRnPQoNdw0og@mail.gmail.com>
On Mon, Oct 21, 2024 at 08:58:30AM +0200, Geert Uytterhoeven wrote:
> Hi Greg,
>
> On Mon, Oct 21, 2024 at 8:39 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Sun, Oct 20, 2024 at 05:36:29PM +0300, Laurent Pinchart wrote:
> > > On Fri, Oct 18, 2024 at 04:31:21PM +0200, Greg KH wrote:
> > > > On Fri, Oct 18, 2024 at 05:25:22PM +0300, Laurent Pinchart wrote:
> > > > > On Fri, Oct 18, 2024 at 04:09:26PM +0200, Greg KH wrote:
> > > > > > On Fri, Oct 18, 2024 at 03:36:48PM +0200, Geert Uytterhoeven wrote:
> > > > > > > On Fri, Oct 18, 2024 at 3:10 PM Laurent Pinchart wrote:
> > > > > > > > On Fri, Oct 18, 2024 at 09:45:52AM +0200, Geert Uytterhoeven wrote:
> > > > > > > > > Each bridge instance creates up to four auxiliary devices with different
> > > > > > > > > names. However, their IDs are always zero, causing duplicate filename
> > > > > > > > > errors when a system has multiple bridges:
> > > > > > > > >
> > > > > > > > > sysfs: cannot create duplicate filename '/bus/auxiliary/devices/ti_sn65dsi86.gpio.0'
> > > > > > > > >
> > > > > > > > > Fix this by using a unique instance ID per bridge instance.
> > > > > > > >
> > > > > > > > Isn't this something that should be handled by the AUX core ? The code
> > > > > > > > below would otherwise need to be duplicated by all drivers, which seems
> > > > > > > > a burden we should avoid.
> > > > > > >
> > > > > > > According to the documentation, this is the responsibility of the caller
> > > > > > > https://elixir.bootlin.com/linux/v6.11.4/source/include/linux/auxiliary_bus.h#L81
> > > > > > > I believe this is the same for platform devices.
> > > > > > > See also the example at
> > > > > > > https://elixir.bootlin.com/linux/v6.11.4/source/include/linux/auxiliary_bus.h#L116
> > > > > > >
> > > > > > > Note: the platform bus supports PLATFORM_DEVID_AUTO, but the auxiliary
> > > > > > > bus does not.
> > > > > >
> > > > > > Yes, it does not as it's up to the caller to create a unique name, like
> > > > > > your patch here does. I'd argue that platform should also not do
> > > > > > automatic device ids, but that's a different argument :)
> > > > >
> > > > > __auxiliary_device_add() creates the device name with
> > > > >
> > > > > dev_set_name(dev, "%s.%s.%d", modname, auxdev->name, auxdev->id);
> > > > >
> > > > > I'm not calling for a PLATFORM_DEVID_AUTO-like feature here, but
> > > > > shouldn't the first component of the device name use the parent's name
> > > > > instead of the module name ?
> > > >
> > > > Why would the parent's name not be the module name? That name is
> > > > guaranteed unique in the system. If you want "uniqueness" within the
> > > > driver/module, use the name and id field please.
> > > >
> > > > That's worked well so far, but to be fair, aux devices are pretty new.
> > > > What problem is this naming scheme causing?
> > >
> > > Auxiliary devices are created as children of a parent device. When
> > > multiple instances of the same parent type exist, this will be reflected
> > > in the /sys/devices/ devices tree hierarchy without any issue. The
> > > problem comes from the fact the the auxiliary devices need a unique name
> > > for /sys/bus/auxialiary/devices/, where we somehow have to differenciate
> > > devices of identical types.
> > >
> > > Essentially, we're trying to summarize a whole hierarchy (path in
> > > /sys/devices/) into a single string. There are different ways to solve
> > > this. For platform devices, we use a device ID. For I2C devices, we use
> > > the parent's bus number. Other buses use different schemes.
> > >
> > > Geert's patch implements a mechanism in the ti-sn65dsi86 driver to
> > > handle this, and assign an id managed by the parent. In a sense we could
> > > consider this to be similar to what is done for I2C, where the bus
> > > number is also a property of the parent. However, the big difference is
> > > that the I2C bus number is managed by the I2C subsystem, while here the
> > > id is managed by the ti-sn65dsi86 driver, not by the auxiliary device
> > > core. This would require duplicating the same mechanism in every single
> > > driver creating auxiliary devices. This strikes me as a fairly bad idea.
> > > The problem should be solved by the core, not by individual drivers.
> >
> > The "id" is just a unique number, it is "managed" by the thing that is
> > creating the devices themselves, not the aux core code. I don't see why
> > the i2c bus number has to match the same number that the ti driver
> > creates, it could be anything, as long as it doesn't match anything else
> > currently created by that driver.
>
> Laurent does not say it has to match the i2c bus number.
> He does think the auxilliary bus should provide a mechanism to
> allocate these IDs (e.g. usin g AUX_DEVID_AUTO?).
As this is the first subsystem to ask for such a thing, I didn't think
it was needed, but the aux subsystem is new :)
> However, using i2c_client->adapter->nr instead of ida_alloc()
> in the TI driver does sound like a good idea to me...
Great!
> > If we had the aux core code create the id, it would just use a unique
> > counter, and that would not reflect any mapping to anything, so I don't
> > see how that is any different here.
>
> And then we would get something like:
>
> /sys/bus/auxiliary/devices
> ├── ti_sn65dsi86.gpio.0
> ├── ti_sn65dsi86.pwm.1
> ├── ti_sn65dsi86.aux.2
> ├── ti_sn65dsi86.bridge.3
> ├── ti_sn65dsi86.gpio.4
> ├── ti_sn65dsi86.pwm.5
> ├── ti_sn65dsi86.aux.6
> └── ti_sn65dsi86.bridge.7
>
> Which is similar to the first approach I tried (calling ida_alloc() in
> ti_sn65dsi86_add_aux_device() instead of ti_sn65dsi86_probe()).
That id scheme looks really odd, don't you think? Try using the
adapter->nr instead like other aux subsystems already do.
thanks,
greg k-h
next prev parent reply other threads:[~2024-10-21 7:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 7:45 [PATCH] drm/bridge: ti-sn65dsi86: Fix multiple instances Geert Uytterhoeven
2024-10-18 13:10 ` Laurent Pinchart
2024-10-18 13:36 ` Geert Uytterhoeven
2024-10-18 14:09 ` Greg KH
2024-10-18 14:25 ` Laurent Pinchart
2024-10-18 14:31 ` Greg KH
2024-10-20 14:36 ` Laurent Pinchart
2024-10-21 6:39 ` Greg KH
2024-10-21 6:58 ` Geert Uytterhoeven
2024-10-21 7:27 ` Greg KH [this message]
2024-10-21 8:23 ` Geert Uytterhoeven
2024-10-21 8:28 ` Laurent Pinchart
2024-10-21 8:47 ` Geert Uytterhoeven
2024-10-22 0:20 ` Doug Anderson
2024-10-22 7:11 ` Geert Uytterhoeven
2024-10-22 14:37 ` Doug Anderson
2024-10-28 13:34 ` Dmitry Baryshkov
2024-10-30 10:25 ` Geert Uytterhoeven
2024-10-30 10:28 ` Laurent Pinchart
2024-10-31 23:08 ` Dmitry Baryshkov
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=2024102137-repost-visiting-323d@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.