drm/exynos: fimd: clear channel before enabling iommu
If any fimd channel was already active, initializing iommu will result in a PAGE FAULT (e.e. u-boot could have turned on the display and not disabled it before the kernel starts). This patch checks if any channel is active before initializing iommu and disables it. Signed-off-by: Akshu Agrawal <akshu.a@samsung.com> Signed-off-by: Prathyush K <prathyush.k@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
This commit is contained in:
parent
5ce405be56
commit
f13bdbd1fb
|
@ -143,6 +143,48 @@ static inline struct fimd_driver_data *drm_fimd_get_driver_data(
|
||||||
return (struct fimd_driver_data *)of_id->data;
|
return (struct fimd_driver_data *)of_id->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr)
|
||||||
|
{
|
||||||
|
struct fimd_context *ctx = mgr->ctx;
|
||||||
|
|
||||||
|
if (ctx->suspended)
|
||||||
|
return;
|
||||||
|
|
||||||
|
atomic_set(&ctx->wait_vsync_event, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wait for FIMD to signal VSYNC interrupt or return after
|
||||||
|
* timeout which is set to 50ms (refresh rate of 20).
|
||||||
|
*/
|
||||||
|
if (!wait_event_timeout(ctx->wait_vsync_queue,
|
||||||
|
!atomic_read(&ctx->wait_vsync_event),
|
||||||
|
HZ/20))
|
||||||
|
DRM_DEBUG_KMS("vblank wait timed out.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void fimd_clear_channel(struct exynos_drm_manager *mgr)
|
||||||
|
{
|
||||||
|
struct fimd_context *ctx = mgr->ctx;
|
||||||
|
int win, ch_enabled = 0;
|
||||||
|
|
||||||
|
DRM_DEBUG_KMS("%s\n", __FILE__);
|
||||||
|
|
||||||
|
/* Check if any channel is enabled. */
|
||||||
|
for (win = 0; win < WINDOWS_NR; win++) {
|
||||||
|
u32 val = readl(ctx->regs + SHADOWCON);
|
||||||
|
if (val & SHADOWCON_CHx_ENABLE(win)) {
|
||||||
|
val &= ~SHADOWCON_CHx_ENABLE(win);
|
||||||
|
writel(val, ctx->regs + SHADOWCON);
|
||||||
|
ch_enabled = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait for vsync, as disable channel takes effect at next vsync */
|
||||||
|
if (ch_enabled)
|
||||||
|
fimd_wait_for_vblank(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
static int fimd_mgr_initialize(struct exynos_drm_manager *mgr,
|
static int fimd_mgr_initialize(struct exynos_drm_manager *mgr,
|
||||||
struct drm_device *drm_dev, int pipe)
|
struct drm_device *drm_dev, int pipe)
|
||||||
{
|
{
|
||||||
|
@ -169,8 +211,14 @@ static int fimd_mgr_initialize(struct exynos_drm_manager *mgr,
|
||||||
drm_dev->vblank_disable_allowed = true;
|
drm_dev->vblank_disable_allowed = true;
|
||||||
|
|
||||||
/* attach this sub driver to iommu mapping if supported. */
|
/* attach this sub driver to iommu mapping if supported. */
|
||||||
if (is_drm_iommu_supported(ctx->drm_dev))
|
if (is_drm_iommu_supported(ctx->drm_dev)) {
|
||||||
|
/*
|
||||||
|
* If any channel is already active, iommu will throw
|
||||||
|
* a PAGE FAULT when enabled. So clear any channel if enabled.
|
||||||
|
*/
|
||||||
|
fimd_clear_channel(mgr);
|
||||||
drm_iommu_attach_device(ctx->drm_dev, ctx->dev);
|
drm_iommu_attach_device(ctx->drm_dev, ctx->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -324,25 +372,6 @@ static void fimd_disable_vblank(struct exynos_drm_manager *mgr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr)
|
|
||||||
{
|
|
||||||
struct fimd_context *ctx = mgr->ctx;
|
|
||||||
|
|
||||||
if (ctx->suspended)
|
|
||||||
return;
|
|
||||||
|
|
||||||
atomic_set(&ctx->wait_vsync_event, 1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* wait for FIMD to signal VSYNC interrupt or return after
|
|
||||||
* timeout which is set to 50ms (refresh rate of 20).
|
|
||||||
*/
|
|
||||||
if (!wait_event_timeout(ctx->wait_vsync_queue,
|
|
||||||
!atomic_read(&ctx->wait_vsync_event),
|
|
||||||
HZ/20))
|
|
||||||
DRM_DEBUG_KMS("vblank wait timed out.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void fimd_win_mode_set(struct exynos_drm_manager *mgr,
|
static void fimd_win_mode_set(struct exynos_drm_manager *mgr,
|
||||||
struct exynos_drm_overlay *overlay)
|
struct exynos_drm_overlay *overlay)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue