Message ID | 20230717141438.274419-8-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1156358vqt; Mon, 17 Jul 2023 07:46:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlFE1lemgrjcj/xy2LRdsis09h2xE8cYCyb0OLWLmSKLzPH6cj78FuybJ8kipOEGQ8dHeZ/S X-Received: by 2002:a17:906:224a:b0:993:d700:8a46 with SMTP id 10-20020a170906224a00b00993d7008a46mr12051719ejr.16.1689605161001; Mon, 17 Jul 2023 07:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689605160; cv=none; d=google.com; s=arc-20160816; b=y8z3UNu38ggfYU0P/pouSeEDjF3pugaJ1rHTIUKVjCXIGKj3pKJNJx4tqIJre6TDVt EDERwp54urwfZG25wt6ZmpHfQHr31VJ5jANo2785JLTC1y4L6Q1rItejO6YkRCyBlYVK brdRf+Ru0JFkb85NvxASZDsTLRG2t6STWXOn6NJFWrwNhZoF02HnMmuDSecDcR0mc3Hh xu6f5wrE5Z3CpTfRWVQ4T7IOdqsKhoCdLDRu1/xqlnUzlYjgIWPRrBWMRS4ZI+vST5sV mXEvvGX/t4stAGVUe+K4xs9bqSkBBya8em/WTQaSqteLeBOECzLorZbvTWE/v2dCJYGi qMzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aqbKB86/LbL3sdzeGEOcFBV3rRwthUI8e8p6KoL3keE=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=Q+iWxOi2Iy74G57qc5z9coFdwNON4HkU5u5N8nqQgbkMT3PVCaauMVob2loDWzPjyR CUd4IDaaIhi2YgPPMAlWvQJDHXWkdxDgiL3TYV0yzc50TOWjwaSfmu9sfwZZGq/BfgPr RHR5aQ4iUMuv7qnsgmnz0HdJn4u9jY9Km8xLq6W2qf2+YN9B8AjD1ryWvJd/wska/miT Q1dKDX0HkQJs/98G94ApyUl8V3bagO6mo2WDVzThtamal9opuIFy/1oOIkUE+PVMIQQv IgrWZJKdGlWuPzy++YWxjUBlOZiMakViB+01uv5BbLJxKY74btGeAVcJ9V8S7195S3QF XCuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AK4xXbN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a1709063e4200b0098d1c816d43si12979765eji.85.2023.07.17.07.45.35; Mon, 17 Jul 2023 07:46:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AK4xXbN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbjGQOPO (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Mon, 17 Jul 2023 10:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbjGQOOz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 10:14:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FA4810F1 for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 07:14:51 -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 CCCD5660706D; Mon, 17 Jul 2023 15:14:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689603289; bh=CefhFqQ/uXdHAnQ63I1hQJ7LyexCUl3QyjqRS2AFcCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AK4xXbN33T2/2nMWz2vsx9EJjM6mHcA2ztaFJcKg0UWMS1zcZoQV6NAURVx5D7+zx xMePh/F61DvLmxQjqAvz5kIDFwtRsvj9ZOv3FS3XaAfdjopyE2dNKbwKYf+znv9TxA tmOKJWMVAvgenCdvRRAgO+CFWvc1pjiFhZCmWSIclWe7BBsyps67eV/bnBwi7EGu0/ geiKRDPPE9sdD2UKYJPHtDIZtXj6oj7Kimy6XpkvwRDqK2yE01oj4GjhZZ7ZJlZMR9 aZregpCBwM2QekulpgNx6+k5dvY8Ov4oGdYWcMNlWb9yryyYBsC90ZxXfl3R2Y0PB5 ApKCB2TeqVGJQ== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 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 v6 07/11] drm/mediatek: dp: Avoid mutex locks if audio is not supported/enabled Date: Mon, 17 Jul 2023 16:14:34 +0200 Message-Id: <20230717141438.274419-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> References: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771679421771066416 X-GMAIL-MSGID: 1771679421771066416 |
Series |
MediaTek DisplayPort: support eDP and aux-bus
|
|
Commit Message
AngeloGioacchino Del Regno
July 17, 2023, 2:14 p.m. UTC
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 <angelogioacchino.delregno@collabora.com>
---
drivers/gpu/drm/mediatek/mtk_dp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On 17/07/2023 16:14, AngeloGioacchino Del Regno wrote: > 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. Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Hi, Angelo: On Mon, 2023-07-17 at 16:14 +0200, AngeloGioacchino Del Regno wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > 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. Reviewed-by: CK Hu <ck.hu@mediatek.com> > > Signed-off-by: AngeloGioacchino Del Regno < > angelogioacchino.delregno@collabora.com> > --- > 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/mtk_dp.c > index 83e55f8dc84a..c1d1a882f1db 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dp.c > +++ b/drivers/gpu/drm/mediatek/mtk_dp.c > @@ -1948,6 +1948,9 @@ static int mtk_dp_dt_parse(struct mtk_dp > *mtk_dp, > > 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, > @@ -2520,11 +2523,11 @@ static int mtk_dp_probe(struct > platform_device *pdev) > return dev_err_probe(dev, ret, > "failed to request mediatek dptx > irq\n"); > > - mutex_init(&mtk_dp->update_plugged_status_lock); > - > platform_set_drvdata(pdev, mtk_dp); > > if (mtk_dp->data->audio_supported) { > + mutex_init(&mtk_dp->update_plugged_status_lock); > + > ret = mtk_dp_register_audio_driver(dev); > if (ret) { > dev_err(dev, "Failed to register audio driver: > %d\n", > -- > 2.40.1
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 83e55f8dc84a..c1d1a882f1db 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1948,6 +1948,9 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp, 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, @@ -2520,11 +2523,11 @@ static int mtk_dp_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "failed to request mediatek dptx irq\n"); - mutex_init(&mtk_dp->update_plugged_status_lock); - platform_set_drvdata(pdev, mtk_dp); if (mtk_dp->data->audio_supported) { + mutex_init(&mtk_dp->update_plugged_status_lock); + ret = mtk_dp_register_audio_driver(dev); if (ret) { dev_err(dev, "Failed to register audio driver: %d\n",