0fc3d13758ab98c324fa5dfd4ddf34f02a31de03
[openwrt/staging/pepe2k.git] /
1 From ef8be75663178c0720d0944d9305f624776fc91c Mon Sep 17 00:00:00 2001
2 From: Sandor Yu <Sandor.yu@nxp.com>
3 Date: Thu, 17 Oct 2019 16:29:49 +0800
4 Subject: [PATCH] drm: mhdp: add mutex lock to mhdp register access function
5
6 Add muxtex lock to mhdp registers access functions
7 that could avoid race condition between cec thread and hdmi video.
8
9 Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
10 ---
11 drivers/gpu/drm/bridge/cadence/cdns-dp-core.c | 1 +
12 drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c | 1 +
13 drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c | 8 ++++++++
14 include/drm/bridge/cdns-mhdp-common.h | 1 +
15 4 files changed, 11 insertions(+)
16
17 --- a/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
18 +++ b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
19 @@ -410,6 +410,7 @@ static int __cdns_dp_probe(struct platfo
20 int ret;
21
22 mutex_init(&mhdp->lock);
23 + mutex_init(&mhdp->iolock);
24
25 INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
26
27 --- a/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c
28 +++ b/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c
29 @@ -411,6 +411,7 @@ static int __cdns_hdmi_probe(struct plat
30 int ret;
31
32 mutex_init(&mhdp->lock);
33 + mutex_init(&mhdp->iolock);
34
35 INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
36
37 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c
38 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c
39 @@ -75,6 +75,8 @@ u32 cdns_mhdp_bus_read(struct cdns_mhdp_
40 {
41 u32 val;
42
43 + mutex_lock(&mhdp->iolock);
44 +
45 if (mhdp->bus_type == BUS_TYPE_LOW4K_SAPB) {
46 /* Remap address to low 4K SAPB bus */
47 writel(offset >> 12, mhdp->regs_sec + 0xc);
48 @@ -88,12 +90,16 @@ u32 cdns_mhdp_bus_read(struct cdns_mhdp_
49 else
50 val = readl(mhdp->regs_base + offset);
51
52 + mutex_unlock(&mhdp->iolock);
53 +
54 return val;
55 }
56 EXPORT_SYMBOL(cdns_mhdp_bus_read);
57
58 void cdns_mhdp_bus_write(u32 val, struct cdns_mhdp_device *mhdp, u32 offset)
59 {
60 + mutex_lock(&mhdp->iolock);
61 +
62 if (mhdp->bus_type == BUS_TYPE_LOW4K_SAPB) {
63 /* Remap address to low 4K SAPB bus */
64 writel(offset >> 12, mhdp->regs_sec + 0xc);
65 @@ -106,6 +112,8 @@ void cdns_mhdp_bus_write(u32 val, struct
66 writel(val, mhdp->regs_sec + offset);
67 else
68 writel(val, mhdp->regs_base + offset);
69 +
70 + mutex_unlock(&mhdp->iolock);
71 }
72 EXPORT_SYMBOL(cdns_mhdp_bus_write);
73
74 --- a/include/drm/bridge/cdns-mhdp-common.h
75 +++ b/include/drm/bridge/cdns-mhdp-common.h
76 @@ -685,6 +685,7 @@ struct cdns_mhdp_device {
77 bool plugged;
78 bool is_hpd;
79 struct mutex lock;
80 + struct mutex iolock;
81
82 int irq[IRQ_NUM];
83