Skip to content

Commit 83c0bcb

Browse files
lynxeye-devairlied
authored andcommitted
drm: tegra: protect DC register access with mutex
Window properties are programmed through a shared aperture and have to happen atomically. Also we do the read-update-write dance on some of the shared regs. To make sure that different functions don't stumble over each other protect the register access with a mutex. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 4026bfb commit 83c0bcb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

drivers/gpu/drm/tegra/dc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
171171
return err;
172172
}
173173

174+
mutex_lock(&dc->regs_mutex);
175+
174176
/* program display mode */
175177
tegra_dc_set_timings(dc, mode);
176178

@@ -269,6 +271,8 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
269271
tegra_dc_writel(dc, 0xff00, DC_WIN_BLEND_NOKEY);
270272
tegra_dc_writel(dc, 0xff00, DC_WIN_BLEND_1WIN);
271273

274+
mutex_unlock(&dc->regs_mutex);
275+
272276
return 0;
273277
}
274278

@@ -287,6 +291,8 @@ static void tegra_crtc_prepare(struct drm_crtc *crtc)
287291
else
288292
syncpt = SYNCPT_VBLANK0;
289293

294+
mutex_lock(&dc->regs_mutex);
295+
290296
/* initialize display controller */
291297
tegra_dc_writel(dc, 0x00000100, DC_CMD_GENERAL_INCR_SYNCPT_CNTRL);
292298
tegra_dc_writel(dc, 0x100 | syncpt, DC_CMD_CONT_SYNCPT_VSYNC);
@@ -320,6 +326,8 @@ static void tegra_crtc_prepare(struct drm_crtc *crtc)
320326

321327
value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
322328
tegra_dc_writel(dc, value, DC_CMD_INT_ENABLE);
329+
330+
mutex_unlock(&dc->regs_mutex);
323331
}
324332

325333
static void tegra_crtc_commit(struct drm_crtc *crtc)
@@ -330,6 +338,8 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
330338

331339
update_mask = GENERAL_ACT_REQ | WIN_A_ACT_REQ;
332340

341+
mutex_lock(&dc->regs_mutex);
342+
333343
tegra_dc_writel(dc, update_mask << 8, DC_CMD_STATE_CONTROL);
334344

335345
value = tegra_dc_readl(dc, DC_CMD_INT_ENABLE);
@@ -341,6 +351,8 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
341351
tegra_dc_writel(dc, value, DC_CMD_INT_MASK);
342352

343353
tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
354+
355+
mutex_unlock(&dc->regs_mutex);
344356
}
345357

346358
static void tegra_crtc_load_lut(struct drm_crtc *crtc)
@@ -747,6 +759,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
747759
return -ENOMEM;
748760

749761
INIT_LIST_HEAD(&dc->list);
762+
mutex_init(&dc->regs_mutex);
750763
dc->dev = &pdev->dev;
751764

752765
dc->clk = devm_clk_get(&pdev->dev, NULL);

drivers/gpu/drm/tegra/drm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct tegra_dc {
8484

8585
struct clk *clk;
8686

87+
struct mutex regs_mutex;
8788
void __iomem *regs;
8889
int irq;
8990

0 commit comments

Comments
 (0)