From nobody Wed Nov 13 04:23:55 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FE94EB64DD for ; Thu, 13 Jul 2023 09:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbjGMJDX (ORCPT ); Thu, 13 Jul 2023 05:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233092AbjGMJCl (ORCPT ); Thu, 13 Jul 2023 05:02:41 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EC541FD6 for ; Thu, 13 Jul 2023 02:02:04 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8076B660704D; Thu, 13 Jul 2023 10:02:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689238923; bh=NMuVgXQ6Qjy3BdWmPVtPkoI8nFYNk0R0kZnUi72bcUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WkhpeUUxO+3xSnTQ35z3XbVV2rHwJNTrRQg5Ck6cmLCWKohFM2zZg+tnCkY0f63iB iPVSXbVdk9Z6zQgRJ3FiPv4xHXWHCai8WfW6TZeVrImlhoofDn1dreoFtXSDpvue1v d95gdwgcBuwEqhexoCsS/iseJHUVRRcYc9QjQlLQZrn9EhtJ3u5n+hGYd/DnfIH0ke TAUbClg2YkkB5tbR9Q8KxwD/iSar1W48pY8W6+zwvqYKvfSXW8l3bgf6LSv5IjCzOD 9HBw4znE5eLjRe5ulHHA4hb4fa2LL2Sovv//1xXPxeXV4uBw1lMPzyFIFREZ8DI4kr MBo5J8XINbp8g== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v5 06/10] drm/mediatek: dp: Avoid mutex locks if audio is not supported/enabled Date: Thu, 13 Jul 2023 11:01:48 +0200 Message-Id: <20230713090152.140060-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713090152.140060-1-angelogioacchino.delregno@collabora.com> References: <20230713090152.140060-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- drivers/gpu/drm/mediatek/mtk_dp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/m= tk_dp.c index d67dbafbac8e..3cb234b502a5 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1943,6 +1943,9 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp, =20 static void mtk_dp_update_plugged_status(struct mtk_dp *mtk_dp) { + if (!mtk_dp->data->audio_supported || !mtk_dp->audio_enable) + return; + mutex_lock(&mtk_dp->update_plugged_status_lock); if (mtk_dp->plugged_cb && mtk_dp->codec_dev) mtk_dp->plugged_cb(mtk_dp->codec_dev, @@ -2515,11 +2518,11 @@ static int mtk_dp_probe(struct platform_device *pde= v) return dev_err_probe(dev, ret, "failed to request mediatek dptx irq\n"); =20 - mutex_init(&mtk_dp->update_plugged_status_lock); - platform_set_drvdata(pdev, mtk_dp); =20 if (mtk_dp->data->audio_supported) { + mutex_init(&mtk_dp->update_plugged_status_lock); + ret =3D mtk_dp_register_audio_driver(dev); if (ret) { dev_err(dev, "Failed to register audio driver: %d\n", --=20 2.40.1