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
6 Add muxtex lock to mhdp registers access functions
7 that could avoid race condition between cec thread and hdmi video.
9 Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
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(+)
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
22 mutex_init(&mhdp->lock);
23 + mutex_init(&mhdp->iolock);
25 INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
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
32 mutex_init(&mhdp->lock);
33 + mutex_init(&mhdp->iolock);
35 INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
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_
43 + mutex_lock(&mhdp->iolock);
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_
50 val = readl(mhdp->regs_base + offset);
52 + mutex_unlock(&mhdp->iolock);
56 EXPORT_SYMBOL(cdns_mhdp_bus_read);
58 void cdns_mhdp_bus_write(u32 val, struct cdns_mhdp_device *mhdp, u32 offset)
60 + mutex_lock(&mhdp->iolock);
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);
68 writel(val, mhdp->regs_base + offset);
70 + mutex_unlock(&mhdp->iolock);
72 EXPORT_SYMBOL(cdns_mhdp_bus_write);
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 {
80 + struct mutex iolock;