From nobody Wed Nov 13 04:17:49 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 D7055EB64DC for ; Mon, 17 Jul 2023 14:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbjGQOPe (ORCPT ); Mon, 17 Jul 2023 10:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232080AbjGQOO6 (ORCPT ); Mon, 17 Jul 2023 10:14:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313FFE56 for ; Mon, 17 Jul 2023 07:14:54 -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 40DAB6607067; Mon, 17 Jul 2023 15:14:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689603292; bh=J2LXqbhqDnB0oQhrTOcYs4nhQoquh9K8gXsYFc7oo4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j1ny1loxOHOf9zcl/KK79tj3NsJz0oPSmAlAkp1qPQ2NYXQOfWrVJYlLXuekgp8J2 RTXY8WejsO1muPaJINn1hZueTEyLeLThMn8hLPj3meKOHj/uBJ8u5TgY1Uc+aUqYQ+ BILTe48I8ifL4h9AvEr9NmIdw4AlNIi4F6OiM2uG/OWF4FuV8QyXMRum9D3lDjNNcx SenSDurFDMFaCyRJXh9XGnnYIWF8eZHb1Ic4WKDvoWBgtEYb3Qjy7sGmxJf98TmqJP IaxK+xxz57OG4NUNyoSjNn9eoTlURsfOVcdRLwEz4WOx8gf3vMLDIgqzVXKBepvMNr x5A3kvwkoG2zw== 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 v6 11/11] drm/mediatek: dp: Don't register HPD interrupt handler for eDP case Date: Mon, 17 Jul 2023 16:14:38 +0200 Message-Id: <20230717141438.274419-12-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The interrupt handler for HPD is useful only if a display is actually supposed to be hotpluggable, as that manages the machinery to perform cable (un)plug detection, debouncing and setup for re-training. Since eDP panels are not supposed to be hotpluggable we can avoid using the HPD interrupts altogether and rely on HPD polling only for the suspend/resume case, saving us some spinlocking action and the overhead of interrupts firing at every suspend/resume cycle, achieving a faster (even if just slightly) display resume. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_dp.c | 81 ++++++++++++++++++------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/m= tk_dp.c index e74295ba9707..c06fcc7318e7 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2182,9 +2182,11 @@ static int mtk_dp_bridge_attach(struct drm_bridge *b= ridge, =20 mtk_dp->drm_dev =3D bridge->dev; =20 - irq_clear_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); - enable_irq(mtk_dp->irq); - mtk_dp_hwirq_enable(mtk_dp, true); + if (mtk_dp->bridge.type !=3D DRM_MODE_CONNECTOR_eDP) { + irq_clear_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + enable_irq(mtk_dp->irq); + mtk_dp_hwirq_enable(mtk_dp, true); + } =20 return 0; =20 @@ -2199,8 +2201,10 @@ static void mtk_dp_bridge_detach(struct drm_bridge *= bridge) { struct mtk_dp *mtk_dp =3D mtk_dp_from_bridge(bridge); =20 - mtk_dp_hwirq_enable(mtk_dp, false); - disable_irq(mtk_dp->irq); + if (mtk_dp->bridge.type !=3D DRM_MODE_CONNECTOR_eDP) { + mtk_dp_hwirq_enable(mtk_dp, false); + disable_irq(mtk_dp->irq); + } mtk_dp->drm_dev =3D NULL; mtk_dp_poweroff(mtk_dp); drm_dp_aux_unregister(&mtk_dp->aux); @@ -2579,40 +2583,44 @@ static int mtk_dp_probe(struct platform_device *pde= v) mtk_dp->dev =3D dev; mtk_dp->data =3D (struct mtk_dp_data *)of_device_get_match_data(dev); =20 - mtk_dp->irq =3D platform_get_irq(pdev, 0); - if (mtk_dp->irq < 0) - return dev_err_probe(dev, mtk_dp->irq, - "failed to request dp irq resource\n"); - - mtk_dp->next_bridge =3D devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); - if (IS_ERR(mtk_dp->next_bridge) && - PTR_ERR(mtk_dp->next_bridge) =3D=3D -ENODEV) - mtk_dp->next_bridge =3D NULL; - else if (IS_ERR(mtk_dp->next_bridge)) - return dev_err_probe(dev, PTR_ERR(mtk_dp->next_bridge), - "Failed to get bridge\n"); - ret =3D mtk_dp_dt_parse(mtk_dp, pdev); if (ret) return dev_err_probe(dev, ret, "Failed to parse dt\n"); =20 + /* + * Request the interrupt and install service routine only if we are + * on full DisplayPort. + * For eDP, polling the HPD instead is more convenient because we + * don't expect any (un)plug events during runtime, hence we can + * avoid some locking. + */ + if (mtk_dp->data->bridge_type !=3D DRM_MODE_CONNECTOR_eDP) { + mtk_dp->irq =3D platform_get_irq(pdev, 0); + if (mtk_dp->irq < 0) + return dev_err_probe(dev, mtk_dp->irq, + "failed to request dp irq resource\n"); + + spin_lock_init(&mtk_dp->irq_thread_lock); + + irq_set_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + ret =3D devm_request_threaded_irq(dev, mtk_dp->irq, mtk_dp_hpd_event, + mtk_dp_hpd_event_thread, + IRQ_TYPE_LEVEL_HIGH, dev_name(dev), + mtk_dp); + if (ret) + return dev_err_probe(dev, ret, + "failed to request mediatek dptx irq\n"); + + mtk_dp->need_debounce =3D true; + timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); + } + mtk_dp->aux.name =3D "aux_mtk_dp"; mtk_dp->aux.dev =3D dev; mtk_dp->aux.transfer =3D mtk_dp_aux_transfer; mtk_dp->aux.wait_hpd_asserted =3D mtk_dp_wait_hpd_asserted; drm_dp_aux_init(&mtk_dp->aux); =20 - spin_lock_init(&mtk_dp->irq_thread_lock); - - irq_set_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); - ret =3D devm_request_threaded_irq(dev, mtk_dp->irq, mtk_dp_hpd_event, - mtk_dp_hpd_event_thread, - IRQ_TYPE_LEVEL_HIGH, dev_name(dev), - mtk_dp); - if (ret) - return dev_err_probe(dev, ret, - "failed to request mediatek dptx irq\n"); - platform_set_drvdata(pdev, mtk_dp); =20 if (mtk_dp->data->audio_supported) { @@ -2634,9 +2642,6 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->bridge.of_node =3D dev->of_node; mtk_dp->bridge.type =3D mtk_dp->data->bridge_type; =20 - mtk_dp->need_debounce =3D true; - timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); - if (mtk_dp->bridge.type =3D=3D DRM_MODE_CONNECTOR_eDP) { /* * Set the data lanes to idle in case the bootloader didn't @@ -2647,6 +2652,9 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp_initialize_aux_settings(mtk_dp); mtk_dp_power_enable(mtk_dp); =20 + /* Disable HW interrupts: we don't need any for eDP */ + mtk_dp_hwirq_enable(mtk_dp, false); + /* * Power on the AUX to allow reading the EDID from aux-bus: * please note that it is necessary to call power off in the @@ -2692,7 +2700,8 @@ static int mtk_dp_remove(struct platform_device *pdev) =20 pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); - del_timer_sync(&mtk_dp->debounce_timer); + if (mtk_dp->data->bridge_type !=3D DRM_MODE_CONNECTOR_eDP) + del_timer_sync(&mtk_dp->debounce_timer); platform_device_unregister(mtk_dp->phy_dev); if (mtk_dp->audio_pdev) platform_device_unregister(mtk_dp->audio_pdev); @@ -2706,7 +2715,8 @@ static int mtk_dp_suspend(struct device *dev) struct mtk_dp *mtk_dp =3D dev_get_drvdata(dev); =20 mtk_dp_power_disable(mtk_dp); - mtk_dp_hwirq_enable(mtk_dp, false); + if (mtk_dp->bridge.type !=3D DRM_MODE_CONNECTOR_eDP) + mtk_dp_hwirq_enable(mtk_dp, false); pm_runtime_put_sync(dev); =20 return 0; @@ -2718,7 +2728,8 @@ static int mtk_dp_resume(struct device *dev) =20 pm_runtime_get_sync(dev); mtk_dp_init_port(mtk_dp); - mtk_dp_hwirq_enable(mtk_dp, true); + if (mtk_dp->bridge.type !=3D DRM_MODE_CONNECTOR_eDP) + mtk_dp_hwirq_enable(mtk_dp, true); mtk_dp_power_enable(mtk_dp); =20 return 0; --=20 2.40.1