From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org,
Mark Rutland <mark.rutland@arm.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
devicetree@vger.kernel.org, David Airlie <airlied@linux.ie>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Jacopo Mondi <jacopo+renesas@jmondi.org>,
Daniel Vetter <daniel.vetter@intel.com>,
Peter Rosin <peda@axentia.se>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 7/7] drm/i2c: tda998x: register as a drm bridge
Date: Fri, 20 Apr 2018 11:24:09 +0100 [thread overview]
Message-ID: <20180420102408.GW16141@n2100.armlinux.org.uk> (raw)
In-Reply-To: <2556566.3fxMPoIyx0@avalon>
On Fri, Apr 20, 2018 at 01:06:49PM +0300, Laurent Pinchart wrote:
> Hi Peter,
>
> Thank you for the patch.
>
> On Thursday, 19 April 2018 19:27:51 EEST Peter Rosin wrote:
> > This makes this driver work with all(?) drivers that are not
> > componentized and instead expect to connect to a panel/bridge. That
> > said, the only one tested is atmel_hlcdc.
> >
> > This hooks the relevant work function previously called by the encoder
> > and the component also to the bridge, since the encoder goes away when
> > connecting to the bridge interface of the driver and the equivalent of
> > bind/unbind of the component is handled by bridge attach/detach.
> >
> > The lifetime requirements of a bridge and a component are slightly
> > different, which is the reason for struct tda998x_bridge.
>
> Couldn't you move the allocation and initialization (tda998x_create) of the
> tda998x_priv structure to probe time ? I think you wouldn't need a separate
> structure in that case. Unless I'm mistaken there would be an added benefit of
> separating component and bridge initialization, resulting in the encoder not
> being initialized at all if the component isn't used. You wouldn't need to add
> a local_encoder parameter to the tda998x_init() function.
No, I don't like that idea one bit, as I've stated in the past about the
component API. The same (probably) goes for the bridge stuff too.
Consider the following:
Your DRM system is initialised. You then remove a module, which results
in the DRM system being torn down. You re-insert the module (eg, having
made a change to it). The DRM system is then re-initialised.
At this point, what is the state of variables such as priv->is_on if
you allocate the structure at probe time?
What about all the other variables in the driver private structure - are
you sure that the driver can cope with random values from the previous
"usage" remaining there?
At the moment, this isn't a concern for the driver because we
dev_kzalloc() the structure in the bind callback. Move that to the
probe function, and the structure is no longer re-initialised each
time, and so it retains the previous state. The driver is not setup
to cope with that.
So, to work around that, you would need to reinitialise _everything_
in the structure that the driver requires, which IMHO is a very
open to bugs (eg, if a member is missed, or added without the
necessary re-initialisation), _especially_ when this is not a path
that will get regular testing.
If you want to do this for a subset of data, it would be much better
to separate them into independent structures (maybe one embedded into
the other) so that this problem can not occur. That way, a subset
of the data can be memset() when bound to the rest of the DRM system
ensuring a consistent driver state and still achieve what you're
suggesting.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
next prev parent reply other threads:[~2018-04-20 10:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 16:27 [PATCH v3 0/7] Add tda998x (HDMI) support to atmel-hlcdc Peter Rosin
2018-04-19 16:27 ` [PATCH v3 1/7] dt-bindings: display: bridge: lvds-transmitter: add ti,ds90c185 Peter Rosin
2018-04-19 16:27 ` [PATCH v3 2/7] dt-bindings: display: atmel: optional video-interface of endpoints Peter Rosin
2018-04-19 16:27 ` [PATCH v3 3/7] drm: of: introduce drm_of_media_bus_fmt Peter Rosin
2018-04-19 16:27 ` [PATCH v3 4/7] drm/atmel-hlcdc: support bus-width (12/16/18/24) in endpoint nodes Peter Rosin
2018-04-21 16:19 ` Boris Brezillon
2018-04-21 22:13 ` Peter Rosin
2018-04-19 16:27 ` [PATCH v3 5/7] drm/i2c: tda998x: find the drm_device via the drm_connector Peter Rosin
2018-04-20 9:41 ` Laurent Pinchart
2018-04-19 16:27 ` [PATCH v3 6/7] drm/i2c: tda998x: split encoder and component functions from the work Peter Rosin
2018-04-20 9:51 ` Laurent Pinchart
2018-04-19 16:27 ` [PATCH v3 7/7] drm/i2c: tda998x: register as a drm bridge Peter Rosin
2018-04-20 10:06 ` Laurent Pinchart
2018-04-20 10:24 ` Russell King - ARM Linux [this message]
2018-04-20 13:28 ` Peter Rosin
2018-04-20 10:41 ` kbuild test robot
2018-04-20 10:49 ` Peter Rosin
2018-04-20 10:53 ` Russell King - ARM Linux
2018-04-20 13:09 ` Peter Rosin
2018-04-20 12:00 ` Russell King - ARM Linux
2018-04-20 8:52 ` [PATCH v3 0/7] Add tda998x (HDMI) support to atmel-hlcdc jacopo mondi
2018-04-20 10:18 ` Laurent Pinchart
2018-04-20 11:05 ` Peter Rosin
2018-04-20 11:38 ` jacopo mondi
2018-04-20 12:55 ` Peter Rosin
2018-04-21 8:38 ` Laurent Pinchart
2018-04-21 15:05 ` Peter Rosin
2018-04-20 11:22 ` jacopo mondi
2018-04-21 8:20 ` Laurent Pinchart
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=20180420102408.GW16141@n2100.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=airlied@linux.ie \
--cc=alexandre.belloni@bootlin.com \
--cc=boris.brezillon@free-electrons.com \
--cc=daniel.vetter@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacopo+renesas@jmondi.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peda@axentia.se \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).