drm/fb-helper: Fix hpd vs. initial config races
Subsystems (17)
PATCH v3 1/4 drm/fb-helper: Fix hpd vs. initial config races
From: Daniel Vetter <[email protected]>
Some drivers need to be able to have a perfect race-free fbcon setup. Current drivers only enable hotplug processing after the call to drm_fb_helper_initial_config which leaves a tiny but important race.
This race is especially noticable on embedded platforms where the driver itself enables the voltage for the hdmi output, since only then will monitors (after a bit of delay, as usual) respond by asserting the hpd pin.
Most of the infrastructure is already there with the split-out drm_fb_helper_init. And drm_fb_helper_initial_config already has all the required locking to handle concurrent hpd events since
commit 53f1904bced78d7c00f5d874c662ec3ac85d0f9f
Author: Daniel Vetter <[email protected]> Date: Thu Mar 20 14:26:35 2014 +0100
drm/fb-helper: improve drm_fb_helper_initial_config locking
The only missing bit is making drm_fb_helper_hotplug_event save against concurrent calls of drm_fb_helper_initial_config. The only unprotected bit is the check for fb_helper->fb.
With that drivers can first initialize the fb helper, then enabel hotplug processing and then set up the initial config all in a completely race-free manner. Update kerneldoc and convert i915 as a proof of concept.
Feature requested by Thierry since his tegra driver atm reliably boots slowly enough to misses the hotplug event for an external hdmi screen, but also reliably boots to quickly for the hpd pin to be asserted when the fb helper calls into the hdmi ->detect function.
---
Changes in v3:
- remove an additional occurrence of i915's enable_hotplug_processing that was introduced after the original patch
drivers/gpu/drm/drm_fb_helper.c | 11 +++++------ drivers/gpu/drm/i915/i915_dma.c | 3 --- drivers/gpu/drm/i915/i915_drv.c | 2 -- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/i915_irq.c | 4 ---- 5 files changed, 5 insertions(+), 16 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +5 -6
@@ -1613,8 +1613,10 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);* either the output polling work or a work item launched from the driver's * hotplug interrupt). * -* Note that the driver must ensure that this is only called _after_ the fb has -* been fully set up, i.e. after the call to drm_fb_helper_initial_config. +* Note that drivers may call this even before calling +* drm_fb_helper_initial_config but only aftert drm_fb_helper_init. This allows +* for a race-free fbcon setup and will make sure that the fbdev emulation will +* not miss any hotplug events. * * RETURNS: * 0 on success and a non-zero error code otherwise.
@@ -1624,11 +1626,8 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)struct drm_device *dev = fb_helper->dev;u32 max_width, max_height; -if (!fb_helper->fb) -return 0 ; -mutex_lock (&fb_helper->dev->mode_config.mutex); -if (!drm_fb_helper_is_bound (fb_helper)) { +if (!fb_helper->fb || !drm_fb_helper_is_bound (fb_helper)) { fb_helper->delayed_hotplug = true;mutex_unlock (&fb_helper->dev->mode_config.mutex);return 0 ;
drivers/gpu/drm/i915/i915_dma.c +0 -3
@@ -1377,9 +1377,6 @@ static int i915_load_modeset_init(struct drm_device *dev)*/ intel_fbdev_initial_config (dev); -/* Only enable hotplug handling once the fbdev is fully set up. */ - dev_priv->enable_hotplug_processing = true; -drm_kms_helper_poll_init (dev);return 0 ;
drivers/gpu/drm/i915/i915_drv.c +0 -2
@@ -521,7 +521,6 @@ static int i915_drm_freeze(struct drm_device *dev) }intel_runtime_pm_disable_interrupts (dev); - dev_priv->enable_hotplug_processing = false;intel_suspend_gt_powersave (dev);
@@ -659,7 +658,6 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)* notifications. * */ intel_hpd_init (dev); - dev_priv->enable_hotplug_processing = true;/* Config may have changed between suspend and resume */ drm_helper_hpd_irq_event (dev); }
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -1404,7 +1404,6 @@ struct drm_i915_private {u32 pipestat_irq_mask[I915_MAX_PIPES ];struct work_struct hotplug_work; -bool enable_hotplug_processing;struct {unsigned long hpd_last_jiffies;int hpd_cnt;
drivers/gpu/drm/i915/i915_irq.c +0 -4
@@ -1109,10 +1109,6 @@ static void i915_hotplug_work_func(struct work_struct *work)bool changed = false;u32 hpd_event_bits; -/* HPD irq before everything is fully set up. */ -if (!dev_priv->enable_hotplug_processing) -return ; -mutex_lock (&mode_config->mutex);DRM_DEBUG_KMS ("running encoder hotplug functions\n" );
Signature · 1 line
2.0.0
PATCH v3 2/4 drm: Constify struct drm_fb_helper_funcs
From: Thierry Reding <[email protected]>
There's no need for this to be modifiable. Make it const so that it can be put into the .rodata section.
--- drivers/gpu/drm/armada/armada_fbdev.c | 2 +- drivers/gpu/drm/ast/ast_fb.c | 2 +- drivers/gpu/drm/bochs/bochs_fbdev.c | 2 +- drivers/gpu/drm/cirrus/cirrus_fbdev.c | 2 +- drivers/gpu/drm/drm_fb_cma_helper.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +- drivers/gpu/drm/gma500/framebuffer.c | 2 +- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- drivers/gpu/drm/mgag200/mgag200_fb.c | 2 +- drivers/gpu/drm/msm/msm_fbdev.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/omapdrm/omap_fbdev.c | 2 +- drivers/gpu/drm/qxl/qxl_fb.c | 2 +- drivers/gpu/drm/radeon/radeon_fb.c | 2 +- drivers/gpu/drm/tegra/fb.c | 2 +- drivers/gpu/drm/udl/udl_fb.c | 2 +- include/drm/drm_fb_helper.h | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-)
drivers/gpu/drm/armada/armada_fbdev.c +1 -1
@@ -131,7 +131,7 @@ static int armada_fb_probe(struct drm_fb_helper *fbh,return ret; } -static struct drm_fb_helper_funcs armada_fb_helper_funcs = { +static const struct drm_fb_helper_funcs armada_fb_helper_funcs = { .gamma_set = armada_drm_crtc_gamma_set, .gamma_get = armada_drm_crtc_gamma_get, .fb_probe = armada_fb_probe,
drivers/gpu/drm/ast/ast_fb.c +1 -1
@@ -287,7 +287,7 @@ static void ast_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, *blue = ast_crtc->lut_b[regno] <<8 ; } -static struct drm_fb_helper_funcs ast_fb_helper_funcs = { +static const struct drm_fb_helper_funcs ast_fb_helper_funcs = { .gamma_set = ast_fb_gamma_set, .gamma_get = ast_fb_gamma_get, .fb_probe = astfb_create,
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
@@ -179,7 +179,7 @@ void bochs_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, *blue = regno; } -static struct drm_fb_helper_funcs bochs_fb_helper_funcs = { +static const struct drm_fb_helper_funcs bochs_fb_helper_funcs = { .gamma_set = bochs_fb_gamma_set, .gamma_get = bochs_fb_gamma_get, .fb_probe = bochsfb_create,
drivers/gpu/drm/cirrus/cirrus_fbdev.c +1 -1
@@ -288,7 +288,7 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,return 0 ; } -static struct drm_fb_helper_funcs cirrus_fb_helper_funcs = { +static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = { .gamma_set = cirrus_crtc_fb_gamma_set, .gamma_get = cirrus_crtc_fb_gamma_get, .fb_probe = cirrusfb_create,
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
@@ -327,7 +327,7 @@ err_drm_gem_cma_free_object:return ret; } -static struct drm_fb_helper_funcs drm_fb_cma_helper_funcs = { +static const struct drm_fb_helper_funcs drm_fb_cma_helper_funcs = { .fb_probe = drm_fbdev_cma_create, };
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -1
@@ -225,7 +225,7 @@ out:return ret; } -static struct drm_fb_helper_funcs exynos_drm_fb_helper_funcs = { +static const struct drm_fb_helper_funcs exynos_drm_fb_helper_funcs = { .fb_probe = exynos_drm_fbdev_create, };
drivers/gpu/drm/gma500/framebuffer.c +1 -1
@@ -561,7 +561,7 @@ static int psbfb_probe(struct drm_fb_helper *helper,return psbfb_create (psb_fbdev, sizes); } -static struct drm_fb_helper_funcs psb_fb_helper_funcs = { +static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { .gamma_set = psbfb_gamma_set, .gamma_get = psbfb_gamma_get, .fb_probe = psbfb_probe,
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
@@ -478,7 +478,7 @@ out:return true; } -static struct drm_fb_helper_funcs intel_fb_helper_funcs = { +static const struct drm_fb_helper_funcs intel_fb_helper_funcs = { .initial_config = intel_fb_initial_config, .gamma_set = intel_crtc_fb_gamma_set, .gamma_get = intel_crtc_fb_gamma_get,
drivers/gpu/drm/mgag200/mgag200_fb.c +1 -1
@@ -272,7 +272,7 @@ static int mga_fbdev_destroy(struct drm_device *dev,return 0 ; } -static struct drm_fb_helper_funcs mga_fb_helper_funcs = { +static const struct drm_fb_helper_funcs mga_fb_helper_funcs = { .gamma_set = mga_crtc_fb_gamma_set, .gamma_get = mga_crtc_fb_gamma_get, .fb_probe = mgag200fb_create,
drivers/gpu/drm/msm/msm_fbdev.c +1 -1
@@ -177,7 +177,7 @@ static void msm_crtc_fb_gamma_get(struct drm_crtc *crtc,DBG ("fbdev: get gamma" ); } -static struct drm_fb_helper_funcs msm_fb_helper_funcs = { +static const struct drm_fb_helper_funcs msm_fb_helper_funcs = { .gamma_set = msm_crtc_fb_gamma_set, .gamma_get = msm_crtc_fb_gamma_get, .fb_probe = msm_fbdev_create,
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -438,7 +438,7 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info) info->flags |=FBINFO_HWACCEL_DISABLED ; } -static struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = { +static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = { .gamma_set = nouveau_fbcon_gamma_set, .gamma_get = nouveau_fbcon_gamma_get, .fb_probe = nouveau_fbcon_create,
drivers/gpu/drm/omapdrm/omap_fbdev.c +1 -1
@@ -281,7 +281,7 @@ fail:return ret; } -static struct drm_fb_helper_funcs omap_fb_helper_funcs = { +static const struct drm_fb_helper_funcs omap_fb_helper_funcs = { .fb_probe = omap_fbdev_create, };
drivers/gpu/drm/qxl/qxl_fb.c +1 -1
@@ -660,7 +660,7 @@ static int qxl_fbdev_destroy(struct drm_device *dev, struct qxl_fbdev *qfbdev)return 0 ; } -static struct drm_fb_helper_funcs qxl_fb_helper_funcs = { +static const struct drm_fb_helper_funcs qxl_fb_helper_funcs = { .fb_probe = qxl_fb_find_or_create_single, };
drivers/gpu/drm/radeon/radeon_fb.c +1 -1
@@ -331,7 +331,7 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbreturn 0 ; } -static struct drm_fb_helper_funcs radeon_fb_helper_funcs = { +static const struct drm_fb_helper_funcs radeon_fb_helper_funcs = { .gamma_set = radeon_crtc_fb_gamma_set, .gamma_get = radeon_crtc_fb_gamma_get, .fb_probe = radeonfb_create,
drivers/gpu/drm/tegra/fb.c +1 -1
@@ -267,7 +267,7 @@ release:return err; } -static struct drm_fb_helper_funcs tegra_fb_helper_funcs = { +static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { .fb_probe = tegra_fbdev_probe, };
drivers/gpu/drm/udl/udl_fb.c +1 -1
@@ -550,7 +550,7 @@ out:return ret; } -static struct drm_fb_helper_funcs udl_fb_helper_funcs = { +static const struct drm_fb_helper_funcs udl_fb_helper_funcs = { .fb_probe = udlfb_create, };
include/drm/drm_fb_helper.h +1 -1
@@ -87,7 +87,7 @@ struct drm_fb_helper {struct drm_fb_helper_crtc *crtc_info;int connector_count;struct drm_fb_helper_connector **connector_info; -struct drm_fb_helper_funcs *funcs; +const struct drm_fb_helper_funcs *funcs;struct fb_info *fbdev;u32 pseudo_palette[17 ];struct list_head kernel_fb_list;
Signature · 1 line
2.0.0
PATCH v3 3/4 drm: Introduce drm_fb_helper_prepare()
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
To implement hotplug detection in a race-free manner, drivers must call drm_kms_helper_poll_init() before hotplug events can be triggered. Such events can be triggered right after any of the encoders or connectors are initialized. At the same time, if the drm_fb_helper_hotplug_event() helper is used by a driver, then the poll helper requires some parts of the FB helper to be initialized to prevent a crash.
At the same time, drm_fb_helper_init() requires information that is not necessarily available at such an early stage (number of CRTCs and connectors), so it cannot be used yet.
Add a new helper, drm_fb_helper_prepare(), that initializes the bare minimum needed to allow drm_kms_helper_poll_init() to execute and any subsequent hotplug events to be processed properly.
---
Changes in v3:
- fix inconsistency "second" -> "third" (Daniel Vetter)
Changes in v2:
- improve kernel-doc (Daniel Vetter)
drivers/gpu/drm/armada/armada_fbdev.c | 2 +- drivers/gpu/drm/ast/ast_fb.c | 4 ++- drivers/gpu/drm/bochs/bochs_fbdev.c | 3 +- drivers/gpu/drm/cirrus/cirrus_fbdev.c | 4 ++- drivers/gpu/drm/drm_fb_cma_helper.c | 3 +- drivers/gpu/drm/drm_fb_helper.c | 47 ++++++++++++++++++++++++------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +- drivers/gpu/drm/gma500/framebuffer.c | 3 +- drivers/gpu/drm/i915/intel_fbdev.c | 3 +- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 +- drivers/gpu/drm/msm/msm_fbdev.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 3 +- drivers/gpu/drm/omapdrm/omap_fbdev.c | 2 +- drivers/gpu/drm/qxl/qxl_fb.c | 5 +++- drivers/gpu/drm/radeon/radeon_fb.c | 4 ++- drivers/gpu/drm/tegra/fb.c | 4 +-- drivers/gpu/drm/udl/udl_fb.c | 3 +- include/drm/drm_fb_helper.h | 2 ++ 18 files changed, 72 insertions(+), 28 deletions(-)
drivers/gpu/drm/armada/armada_fbdev.c +1 -1
@@ -149,7 +149,7 @@ int armada_fbdev_init(struct drm_device *dev) priv->fbdev = fbh; - fbh->funcs = &armada_fb_helper_funcs; +drm_fb_helper_prepare (dev, fbh, &armada_fb_helper_funcs); ret =drm_fb_helper_init (dev, fbh,1 ,1 );if (ret) {
drivers/gpu/drm/ast/ast_fb.c +3 -1
@@ -328,8 +328,10 @@ int ast_fbdev_init(struct drm_device *dev)return -ENOMEM ; ast->fbdev = afbdev; - afbdev->helper.funcs = &ast_fb_helper_funcs;spin_lock_init (&afbdev->dirty_lock); + +drm_fb_helper_prepare (dev, &afbdev->helper, &ast_fb_helper_funcs); + ret =drm_fb_helper_init (dev, &afbdev->helper,1 ,1 );if (ret) {
drivers/gpu/drm/bochs/bochs_fbdev.c +2 -1
@@ -189,7 +189,8 @@ int bochs_fbdev_init(struct bochs_device *bochs) {int ret; - bochs->fb.helper.funcs = &bochs_fb_helper_funcs; +drm_fb_helper_prepare (bochs->dev, &bochs->fb.helper, + &bochs_fb_helper_funcs); ret =drm_fb_helper_init (bochs->dev, &bochs->fb.helper,1 ,1 );
drivers/gpu/drm/cirrus/cirrus_fbdev.c +3 -1
@@ -306,9 +306,11 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)return -ENOMEM ; cdev->mode_info.gfbdev = gfbdev; - gfbdev->helper.funcs = &cirrus_fb_helper_funcs;spin_lock_init (&gfbdev->dirty_lock); +drm_fb_helper_prepare (cdev->dev, &gfbdev->helper, + &cirrus_fb_helper_funcs); + ret =drm_fb_helper_init (cdev->dev, &gfbdev->helper, cdev->num_crtc,CIRRUSFB_CONN_LIMIT );if (ret) {
drivers/gpu/drm/drm_fb_cma_helper.c +2 -1
@@ -354,9 +354,10 @@ struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev,return ERR_PTR (-ENOMEM ); } - fbdev_cma->fb_helper.funcs = &drm_fb_cma_helper_funcs; helper = &fbdev_cma->fb_helper; +drm_fb_helper_prepare (dev, helper, &drm_fb_cma_helper_funcs); + ret =drm_fb_helper_init (dev, helper, num_crtc, max_conn_count);if (ret <0 ) {dev_err (dev->dev,"Failed to initialize drm fb helper.\n" );
drivers/gpu/drm/drm_fb_helper.c +37 -10
77 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +2 -1
@@ -266,7 +266,8 @@ int exynos_drm_fbdev_init(struct drm_device *dev)return -ENOMEM ; private->fb_helper = helper = &fbdev->drm_fb_helper; - helper->funcs = &exynos_drm_fb_helper_funcs; + +drm_fb_helper_prepare (dev, helper, &exynos_drm_fb_helper_funcs); num_crtc = dev->mode_config.num_crtc;
drivers/gpu/drm/gma500/framebuffer.c +2 -1
@@ -600,7 +600,8 @@ int psb_fbdev_init(struct drm_device *dev) } dev_priv->fbdev = fbdev; - fbdev->psb_fb_helper.funcs = &psb_fb_helper_funcs; + +drm_fb_helper_prepare (dev, &fbdev->psb_fb_helper, &psb_fb_helper_funcs);drm_fb_helper_init (dev, &fbdev->psb_fb_helper, dev_priv->ops->crtcs,INTELFB_CONN_LIMIT );
drivers/gpu/drm/i915/intel_fbdev.c +2 -1
@@ -649,7 +649,8 @@ int intel_fbdev_init(struct drm_device *dev)if (ifbdev ==NULL )return -ENOMEM ; - ifbdev->helper.funcs = &intel_fb_helper_funcs; +drm_fb_helper_prepare (dev, &ifbdev->helper, &intel_fb_helper_funcs); +if (!intel_fbdev_init_bios (dev, ifbdev)) ifbdev->preferred_bpp =32 ;
drivers/gpu/drm/mgag200/mgag200_fb.c +2 -1
@@ -293,9 +293,10 @@ int mgag200_fbdev_init(struct mga_device *mdev)return -ENOMEM ; mdev->mfbdev = mfbdev; - mfbdev->helper.funcs = &mga_fb_helper_funcs;spin_lock_init (&mfbdev->dirty_lock); +drm_fb_helper_prepare (mdev->dev, &mfbdev->helper, &mga_fb_helper_funcs); + ret =drm_fb_helper_init (mdev->dev, &mfbdev->helper, mdev->num_crtc,MGAG200FB_CONN_LIMIT );if (ret)
drivers/gpu/drm/msm/msm_fbdev.c +1 -1
@@ -197,7 +197,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) helper = &fbdev->base; - helper->funcs = &msm_fb_helper_funcs; +drm_fb_helper_prepare (dev, helper, &msm_fb_helper_funcs); ret =drm_fb_helper_init (dev, helper, priv->num_crtcs, priv->num_connectors);
drivers/gpu/drm/nouveau/nouveau_fbcon.c +2 -1
@@ -464,7 +464,8 @@ nouveau_fbcon_init(struct drm_device *dev) fbcon->dev = dev; drm->fbcon = fbcon; - fbcon->helper.funcs = &nouveau_fbcon_helper_funcs; + +drm_fb_helper_prepare (dev, &fbcon->helper, &nouveau_fbcon_helper_funcs); ret =drm_fb_helper_init (dev, &fbcon->helper, dev->mode_config.num_crtc,4 );
drivers/gpu/drm/omapdrm/omap_fbdev.c +1 -1
@@ -325,7 +325,7 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) helper = &fbdev->base; - helper->funcs = &omap_fb_helper_funcs; +drm_fb_helper_prepare (dev, helper, &omap_fb_helper_funcs); ret =drm_fb_helper_init (dev, helper, priv->num_crtcs, priv->num_connectors);
drivers/gpu/drm/qxl/qxl_fb.c +4 -1
@@ -676,9 +676,12 @@ int qxl_fbdev_init(struct qxl_device *qdev) qfbdev->qdev = qdev; qdev->mode_info.qfbdev = qfbdev; - qfbdev->helper.funcs = &qxl_fb_helper_funcs;spin_lock_init (&qfbdev->delayed_ops_lock);INIT_LIST_HEAD (&qfbdev->delayed_ops); + +drm_fb_helper_prepare (qdev->ddev, &qfbdev->helper, + &qxl_fb_helper_funcs); + ret =drm_fb_helper_init (qdev->ddev, &qfbdev->helper, qxl_num_crtc/* num_crtc - QXL supports just 1 */ ,QXLFB_CONN_LIMIT );
drivers/gpu/drm/radeon/radeon_fb.c +3 -1
@@ -353,7 +353,9 @@ int radeon_fbdev_init(struct radeon_device *rdev) rfbdev->rdev = rdev; rdev->mode_info.rfbdev = rfbdev; - rfbdev->helper.funcs = &radeon_fb_helper_funcs; + +drm_fb_helper_prepare (rdev->ddev, &rfbdev->helper, + &radeon_fb_helper_funcs); ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper, rdev->num_crtc,
drivers/gpu/drm/tegra/fb.c +1 -3
@@ -276,7 +276,6 @@ static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm,unsigned int num_crtc, unsigned int max_connectors) { - struct drm_fb_helper *helper; struct tegra_fbdev *fbdev;int err;
@@ -286,8 +285,7 @@ static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm,return ERR_PTR (-ENOMEM ); } - fbdev->base.funcs = &tegra_fb_helper_funcs; - helper = &fbdev->base; +drm_fb_helper_prepare (drm, &fbdev->base, &tegra_fb_helper_funcs); err =drm_fb_helper_init (drm, &fbdev->base, num_crtc, max_connectors);if (err <0 ) {
drivers/gpu/drm/udl/udl_fb.c +2 -1
@@ -583,7 +583,8 @@ int udl_fbdev_init(struct drm_device *dev)return -ENOMEM ; udl->fbdev = ufbdev; - ufbdev->helper.funcs = &udl_fb_helper_funcs; + +drm_fb_helper_prepare (dev, &ufbdev->helper, &udl_fb_helper_funcs); ret =drm_fb_helper_init (dev, &ufbdev->helper,1 ,1 );
include/drm/drm_fb_helper.h +2 -0
@@ -97,6 +97,8 @@ struct drm_fb_helper {bool delayed_hotplug; }; +void drm_fb_helper_prepare (struct drm_device *dev,struct drm_fb_helper *helper, +const struct drm_fb_helper_funcs *funcs);int drm_fb_helper_init (struct drm_device *dev,struct drm_fb_helper *helper,int crtc_count,int max_conn);
Signature · 1 line
2.0.0
PATCH v3 4/4 drm/tegra: Implement race-free hotplug detection
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
A race condition currently exists on Tegra, where it can happen that a monitor attached via HDMI isn't detected during the initial FB helper setup, but the hotplug event happens too early to be processed by the poll helpers because they haven't been initialized yet. This happens because on some boards the HDMI driver can control the regulator that supplies the +5V pin on the HDMI connector. Therefore depending on the timing between the initialization of the HDMI driver and the rest of DRM, it's possible that the monitor returns the hotplug signal right within the window where we would miss it.
Unfortunately, drm_kms_helper_poll_init() will wreak havoc when called before at least some parts of the FB helpers have been set up.
This commit fixes this by splitting out the minimum of initialization required to make drm_kms_helper_poll_init() work into a separate function that can be called early. It is then safe to move all of the poll helper initialization to an earlier point in time (before the HDMI output driver has a chance to enable the +5V supply). That way if the hotplug signal is returned before the initial FB helper setup, the monitor will be forcefully detected at that point, and if the hotplug signal is returned after that it will be properly handled by the poll helpers.
--- drivers/gpu/drm/tegra/drm.c | 8 ++++++-- drivers/gpu/drm/tegra/drm.h | 1 + drivers/gpu/drm/tegra/fb.c | 47 ++++++++++++++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 17 deletions(-)
drivers/gpu/drm/tegra/drm.c +6 -2
@@ -40,6 +40,12 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)drm_mode_config_init (drm); + err =tegra_drm_fb_prepare (drm); +if (err <0 ) +return err; + +drm_kms_helper_poll_init (drm); + err =host1x_device_init (device);if (err <0 )return err;
@@ -59,8 +65,6 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)if (err <0 )return err; -drm_kms_helper_poll_init (drm); -return 0 ; }
drivers/gpu/drm/tegra/drm.h +1 -0
@@ -280,6 +280,7 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, unsigned int index);bool tegra_fb_is_bottom_up (struct drm_framebuffer *framebuffer);bool tegra_fb_is_tiled (struct drm_framebuffer *framebuffer); +int tegra_drm_fb_prepare (struct drm_device *drm);int tegra_drm_fb_init (struct drm_device *drm);void tegra_drm_fb_exit (struct drm_device *drm);#ifdef CONFIG_DRM_TEGRA_FBDEV
drivers/gpu/drm/tegra/fb.c +32 -15
97 lines not on this page · raw message
Signature · 1 line
2.0.0
Re: [PATCH v3 2/4] drm: Constify struct drm_fb_helper_funcs
In reply to Thierry RedingQuoted 7 lines · Thierry Reding
From: Thierry Reding <[email protected]>
There's no need for this to be modifiable. Make it const so that it can be put into the .rodata section.
Reviewed-by Daniel Vetter <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Definitely a good thing. For Armada:
Signature · 2 lines
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly improving, and getting towards what was expected from it.