From: Daniel Vetter <daniel@ffwll.ch>
To: Andrea Merello <andrea.merello@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 1/3] drm/bridge: introduce bridge detaching mechanism
Date: Thu, 25 Aug 2016 08:43:21 +0200 [thread overview]
Message-ID: <20160825064321.GG10980@phenom.ffwll.local> (raw)
In-Reply-To: <1472040361-17884-1-git-send-email-andrea.merello@gmail.com>
On Wed, Aug 24, 2016 at 02:05:59PM +0200, Andrea Merello wrote:
> Up to now, once a bridge has been attached to a DRM device, it cannot
> be undone.
>
> In particular you couldn't rmmod/insmod a DRM driver that uses a bridge,
> because the bridge would remain bound to the first (dead) driver instance.
>
> This patch fixes this by introducing drm_encoder_detach() and a ->detach
> callback in drm_bridge_funcs for the bridge to be notified about detaches.
>
> It's DRM/KMS driver responsibility to call drm_encoder_detach().
>
> While adding the bridge detach callback, with its kerneldoc, I also added
> kerneldoc for attach callback.
>
> Suggested-by: Daniel Vetter <daniel@ffwll.ch>
> Suggested-by: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> ---
> drivers/gpu/drm/drm_bridge.c | 26 ++++++++++++++++++++++++++
> include/drm/drm_crtc.h | 17 +++++++++++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 2555430..a77b3e0 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -125,6 +125,32 @@ int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge)
> EXPORT_SYMBOL(drm_bridge_attach);
>
> /**
> + * drm_bridge_detach - deassociate given bridge from its DRM device
> + *
> + * @bridge: bridge control structure
> + *
> + * called by a kms driver to unlink the given bridge from its DRM device
> + *
> + * Note that tearing down links between the bridge and our encoder/bridge
> + * objects needs to be handled by the kms driver itself
> + *
Empty line, and we do full sentences (including capitalization and
punctuation) in the full kernel-doc paragraphs.
> + */
> +void drm_bridge_detach(struct drm_bridge *bridge)
> +{
> + if (WARN_ON(!bridge))
> + return;
> +
> + if (WARN_ON(!bridge->dev))
> + return;
> +
> + if (bridge->funcs->detach)
> + bridge->funcs->detach(bridge);
> +
> + bridge->dev = NULL;
> +}
> +EXPORT_SYMBOL(drm_bridge_detach);
> +
> +/**
> * DOC: bridge callbacks
> *
> * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index b618b50..5e25e23 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1765,9 +1765,25 @@ struct drm_plane {
> * @attach: Called during drm_bridge_attach
> */
> struct drm_bridge_funcs {
> + /**
> + * @attach:
> + *
> + * This callback is invoked whenever our bridge is being attached.
... attached to a &drm_encoder. Similar for @detach.
Also I think we should mentation that these callbacks are optional, like
with the others. Just noticed that that remark is missing for @mode_fixup,
can you pls add it too?
lgtm otherwise.
-Daniel
> + *
> + * RETURNS:
> + *
> + * Zero on success, error code on failure
> + */
> int (*attach)(struct drm_bridge *bridge);
>
> /**
> + * @detach:
> + *
> + * This callback is invoked whenever our bridge is being detached.
> + */
> + void (*detach)(struct drm_bridge *bridge);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The paramater
> @@ -3196,6 +3212,7 @@ extern int drm_bridge_add(struct drm_bridge *bridge);
> extern void drm_bridge_remove(struct drm_bridge *bridge);
> extern struct drm_bridge *of_drm_find_bridge(struct device_node *np);
> extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge);
> +extern void drm_bridge_detach(struct drm_bridge *bridge);
>
> bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
> const struct drm_display_mode *mode,
> --
> 2.7.4
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2016-08-25 6:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 12:05 [PATCH v2 1/3] drm/bridge: introduce bridge detaching mechanism Andrea Merello
2016-08-24 12:06 ` [PATCH v2 2/3] drm: simple_kms_helper: make connector optional at init time Andrea Merello
2016-08-25 6:45 ` Daniel Vetter
2016-08-24 12:06 ` [PATCH v2 3/3] drm: simple_kms_helper: add support for bridges Andrea Merello
2016-08-25 6:47 ` Daniel Vetter
2016-08-25 6:43 ` Daniel Vetter [this message]
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=20160825064321.GG10980@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=andrea.merello@gmail.com \
--cc=dri-devel@lists.freedesktop.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 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.