diff options
| author | Jonas Karlman <jonas@kwiboo.se> | 2019-04-21 04:25:50 -0400 |
|---|---|---|
| committer | Andrzej Hajda <a.hajda@samsung.com> | 2019-04-25 04:38:21 -0400 |
| commit | c4cba44eeecab9d5ccd3dd2d5520a7d1e5be544f (patch) | |
| tree | d2785f4d61c42d26fc3ea53d53609f84ef091c17 | |
| parent | 462ce5d963f18b71c63f6b7730a35a2ee5273540 (diff) | |
drm/bridge: dw-hdmi: fix SCDC configuration for ddc-i2c-bus
When ddc-i2c-bus property is used, a NULL pointer dereference is reported:
[ 31.041669] Unable to handle kernel NULL pointer dereference at virtual address 00000008
[ 31.041671] pgd = 4d3c16f6
[ 31.041673] [00000008] *pgd=00000000
[ 31.041678] Internal error: Oops: 5 [#1] SMP ARM
[ 31.041711] Hardware name: Rockchip (Device Tree)
[ 31.041718] PC is at i2c_transfer+0x8/0xe4
[ 31.041721] LR is at drm_scdc_read+0x54/0x84
[ 31.041723] pc : [<c073273c>] lr : [<c05926c4>] psr: 280f0013
[ 31.041725] sp : edffdad0 ip : 5ccb5511 fp : 00000058
[ 31.041727] r10: 00000780 r9 : edf91608 r8 : c11b0f48
[ 31.041728] r7 : 00000438 r6 : 00000000 r5 : 00000000 r4 : 00000000
[ 31.041730] r3 : edffdae7 r2 : 00000002 r1 : edffdaec r0 : 00000000
[ 31.041908] [<c073273c>] (i2c_transfer) from [<c05926c4>] (drm_scdc_read+0x54/0x84)
[ 31.041913] [<c05926c4>] (drm_scdc_read) from [<c0592858>] (drm_scdc_set_scrambling+0x30/0xbc)
[ 31.041919] [<c0592858>] (drm_scdc_set_scrambling) from [<c05cc0f4>] (dw_hdmi_update_power+0x1440/0x1610)
[ 31.041926] [<c05cc0f4>] (dw_hdmi_update_power) from [<c05cc574>] (dw_hdmi_bridge_enable+0x2c/0x70)
[ 31.041932] [<c05cc574>] (dw_hdmi_bridge_enable) from [<c05aed48>] (drm_bridge_enable+0x24/0x34)
[ 31.041938] [<c05aed48>] (drm_bridge_enable) from [<c0591060>] (drm_atomic_helper_commit_modeset_enables+0x114/0x220)
[ 31.041943] [<c0591060>] (drm_atomic_helper_commit_modeset_enables) from [<c05c3fe0>] (rockchip_atomic_helper_commit_tail_rpm+0x28/0x64)
hdmi->i2c may not be set when ddc-i2c-bus property is used in device tree.
Fix this by using hdmi->ddc as the i2c adapter when calling drm_scdc_*().
Also report that SCDC is not supported when there is no DDC bus.
Fixes: 264fce6cc2c1 ("drm/bridge: dw-hdmi: Add SCDC and TMDS Scrambling support")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/VE1PR03MB59031814B5BCAB2152923BDAAC210@VE1PR03MB5903.eurprd03.prod.outlook.com
| -rw-r--r-- | drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index b74ccb6a24c2..ab7968c8f6a2 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | |||
| @@ -1046,6 +1046,10 @@ static bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi) | |||
| 1046 | if (hdmi->version < 0x200a) | 1046 | if (hdmi->version < 0x200a) |
| 1047 | return false; | 1047 | return false; |
| 1048 | 1048 | ||
| 1049 | /* Disable if no DDC bus */ | ||
| 1050 | if (!hdmi->ddc) | ||
| 1051 | return false; | ||
| 1052 | |||
| 1049 | /* Disable if SCDC is not supported, or if an HF-VSDB block is absent */ | 1053 | /* Disable if SCDC is not supported, or if an HF-VSDB block is absent */ |
| 1050 | if (!display->hdmi.scdc.supported || | 1054 | if (!display->hdmi.scdc.supported || |
| 1051 | !display->hdmi.scdc.scrambling.supported) | 1055 | !display->hdmi.scdc.scrambling.supported) |
| @@ -1684,13 +1688,13 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, | |||
| 1684 | * Source Devices compliant shall set the | 1688 | * Source Devices compliant shall set the |
| 1685 | * Source Version = 1. | 1689 | * Source Version = 1. |
| 1686 | */ | 1690 | */ |
| 1687 | drm_scdc_readb(&hdmi->i2c->adap, SCDC_SINK_VERSION, | 1691 | drm_scdc_readb(hdmi->ddc, SCDC_SINK_VERSION, |
| 1688 | &bytes); | 1692 | &bytes); |
| 1689 | drm_scdc_writeb(&hdmi->i2c->adap, SCDC_SOURCE_VERSION, | 1693 | drm_scdc_writeb(hdmi->ddc, SCDC_SOURCE_VERSION, |
| 1690 | min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION)); | 1694 | min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION)); |
| 1691 | 1695 | ||
| 1692 | /* Enabled Scrambling in the Sink */ | 1696 | /* Enabled Scrambling in the Sink */ |
| 1693 | drm_scdc_set_scrambling(&hdmi->i2c->adap, 1); | 1697 | drm_scdc_set_scrambling(hdmi->ddc, 1); |
| 1694 | 1698 | ||
| 1695 | /* | 1699 | /* |
| 1696 | * To activate the scrambler feature, you must ensure | 1700 | * To activate the scrambler feature, you must ensure |
| @@ -1706,7 +1710,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, | |||
| 1706 | hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL); | 1710 | hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL); |
| 1707 | hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, | 1711 | hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, |
| 1708 | HDMI_MC_SWRSTZ); | 1712 | HDMI_MC_SWRSTZ); |
| 1709 | drm_scdc_set_scrambling(&hdmi->i2c->adap, 0); | 1713 | drm_scdc_set_scrambling(hdmi->ddc, 0); |
| 1710 | } | 1714 | } |
| 1711 | } | 1715 | } |
| 1712 | 1716 | ||
