Skip to content

Commit 848bc59

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: dp: Avoid mutex locks if audio is not supported/enabled
If a controller (usually, eDP!) does not support audio, or audio is not enabled because the endpoint has no audio support, it's useless to lock a mutex only to unlock it right after because there's no .plugged_cb(). Check if the audio is supported and enabled before locking the mutex in mtk_dp_update_plugged_status(): if not, we simply return immediately. While at it, since the update_plugged_status_lock mutex would not be used if the controller doesn't support audio at all, initialize it only if `audio_supported` is true. Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Tested-by: Chen-Yu Tsai <[email protected]> Reviewed-by: Alexandre Mergnat <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 779b8d2 commit 848bc59

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,9 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
19481948

19491949
static void mtk_dp_update_plugged_status(struct mtk_dp *mtk_dp)
19501950
{
1951+
if (!mtk_dp->data->audio_supported || !mtk_dp->audio_enable)
1952+
return;
1953+
19511954
mutex_lock(&mtk_dp->update_plugged_status_lock);
19521955
if (mtk_dp->plugged_cb && mtk_dp->codec_dev)
19531956
mtk_dp->plugged_cb(mtk_dp->codec_dev,
@@ -2520,11 +2523,11 @@ static int mtk_dp_probe(struct platform_device *pdev)
25202523
return dev_err_probe(dev, ret,
25212524
"failed to request mediatek dptx irq\n");
25222525

2523-
mutex_init(&mtk_dp->update_plugged_status_lock);
2524-
25252526
platform_set_drvdata(pdev, mtk_dp);
25262527

25272528
if (mtk_dp->data->audio_supported) {
2529+
mutex_init(&mtk_dp->update_plugged_status_lock);
2530+
25282531
ret = mtk_dp_register_audio_driver(dev);
25292532
if (ret) {
25302533
dev_err(dev, "Failed to register audio driver: %d\n",

0 commit comments

Comments
 (0)