From patchwork Thu Mar 30 14:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1173398vqo; Thu, 30 Mar 2023 07:35:15 -0700 (PDT) X-Google-Smtp-Source: AKy350Y/4SUMJCbgxx0dGHleqnlwl+iycfnDbjp01n32MfgKt6+g7qFo/7WoWNHWlk70AHjkpeAw X-Received: by 2002:aa7:d552:0:b0:4fb:ec6a:2357 with SMTP id u18-20020aa7d552000000b004fbec6a2357mr21924457edr.34.1680186915264; Thu, 30 Mar 2023 07:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186915; cv=none; d=google.com; s=arc-20160816; b=J5Z01gEnthv+Sm+kVD1FQfZgD/mbupc7g3uJ+uhGoVi3iq+WQtvywU5XH0nmDWWYLK aKCCokeWTTrXVuY4fDggpf1+xKtZFlR60F+TWfJBAQMCSK2gso1i96oN0l9wQPnqNNkt Gvq/PkhdxNAJkkUwu6ux6K/SWhnWLdlie2zWiROAD/esvr4JoQlshEcg/zPdNXMn9jpS eh2vZO61huCA8yfRM2xzzeYCn8FT37wH9vwwN0CBHYg9MVRqOP3fL7IwpCDqh9O/JP9o WDr2/RLxkB7duLxynQWR3v6gUBX+itpKu3GHZuhK34nyVn5uuk72q8/KDxdrwulcm4dY 6eew== 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=mVHWryi7FLI6xgM1V7O/CpgS+CHXop+pa1pZRj1UBLM=; b=0pLh6N/wTX1J7CTYXrn43a/7o9jgwEob3FQxWXAGzU+6j6rb1Zgi7z28qChoS3BOxC MhJ0cUkg8V1zk9W9EdbhuQBbpo9/nY3+WHPYK4mmNpfxqGoAugXeWEGCLIGri2llFSs6 bnVAaXKqvoZ4t4RynciYi+PbEY8rXevaUHc3SW34jeZLeXScDOucEx2VCzMbOdv/l9NA zvhFjw3c7yznkbDkPP6RFB9ES8YNMvX8BgjOazTMevPwns4UOUnAESsYQ85fDpvY1KUg hu5gwsE0CSOf3UTQB1pPTFGvm1DvQlvlcAcvgsbMfy99ml/g5ugN90e1tCJfwOF0rMX+ 2/vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="j/hJlZxO"; 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 v24-20020aa7d658000000b00501dd8e9f9dsi1084550edr.370.2023.03.30.07.34.49; Thu, 30 Mar 2023 07:35:15 -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="j/hJlZxO"; 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 S232399AbjC3OQy (ORCPT + 99 others); Thu, 30 Mar 2023 10:16:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232267AbjC3OQn (ORCPT ); Thu, 30 Mar 2023 10:16:43 -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 0534EAF32 for ; Thu, 30 Mar 2023 07:16:38 -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 2B96F660310D; Thu, 30 Mar 2023 15:16:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185796; bh=aTfefQf7wUPldM8GfwxyIBQhpoEf1h/RP3aMOHoG5mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/hJlZxOEbaGyp+oaQoR1ff6jbmyH6VOaZJTv1qkCUr5ZN+0HOzujNwZvlNSON4Wm XoW+9USRjLmb7oA6Kc3IMqnzPhTlo882s0QEJs5JX/ZUsdunMcOkutO9RYERJSJAEc MP1cf6Xna9f/NN/2VVwr7aLZi0JfG1AQedugoImdSJ8eZKozW6kYU/L6pazR2AdpZf QP5uT5uRBpvtgi50o47j1vmpHdURXbCPGoGycob2nHfcY+VRMoDlWhZXmyCdgvlnOY E/VqX4LjIOJQhZ7E/qAC26gGrBzLhL0DXtnmpRarUfJiWXVEcRUWS3uOOVJlQSOmFm +HfruHQvhoLvQ== 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 Subject: [PATCH v1 1/8] drm/mediatek: dp: Cache EDID for eDP panel Date: Thu, 30 Mar 2023 16:16:23 +0200 Message-Id: <20230330141631.190528-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761803674494497858?= X-GMAIL-MSGID: =?utf-8?q?1761803674494497858?= Since eDP panels are not removable it is safe to cache the EDID: this will avoid a relatively long read transaction at every PM resume that is unnecessary only in the "special" case of eDP, hence speeding it up a little, as from now on, as resume operation, we will perform only link training. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 1f94fcc144d3..84f82cc68672 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -118,6 +118,7 @@ struct mtk_dp { const struct mtk_dp_data *data; struct mtk_dp_info info; struct mtk_dp_train_info train_info; + struct edid *edid; struct platform_device *phy_dev; struct phy *phy; @@ -1993,7 +1994,11 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, usleep_range(2000, 5000); } - new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); + /* eDP panels aren't removable, so we can return a cached EDID. */ + if (mtk_dp->edid && mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + new_edid = drm_edid_duplicate(mtk_dp->edid); + else + new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); /* * Parse capability here to let atomic_get_input_bus_fmts and @@ -2022,6 +2027,10 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); } + /* If this is an eDP panel and the read EDID is good, cache it for later */ + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && !mtk_dp->edid && new_edid) + mtk_dp->edid = drm_edid_duplicate(new_edid); + return new_edid; } From patchwork Thu Mar 30 14:16:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1177964vqo; Thu, 30 Mar 2023 07:42:30 -0700 (PDT) X-Google-Smtp-Source: AKy350br9rgJUfQvYBizcAhTXE5udc3EOC1mLW3SIfKncuaKegTtJjdKKIstqwy6NofJQKL+Jc1E X-Received: by 2002:aa7:9578:0:b0:627:e49a:871a with SMTP id x24-20020aa79578000000b00627e49a871amr21551730pfq.23.1680187350674; Thu, 30 Mar 2023 07:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187350; cv=none; d=google.com; s=arc-20160816; b=ma4C3Ws4RF1cBjb70YvzDOr3pTzU+yceDzngq1WbMM1Psv1EIvvgyUnUYY/V0dYMvv t4RSCNZtRC1Dj+9R6UpX4NDqBLMJU65wcQgSbdw4tX4rSL9+Ifwxbb7owjgEj9/FDtz0 YfpyYs41+f59Ux/Gzbn7D3UaZi0RNzg1ZOHXKFsEilBOpUb2HNXAUI7o3CkjrO3NJiZo IzOQkDzhqQkZmIGdHeSCUmqdvrolDQHe/dUBBkdFYb4qCBoi+VOE/zu+pZlDOlrWHecd 0pVhuGP/YhKRDJ/hmfhDO12+DU7aG+Cm0Drg/SVcj/zYKBt+fRezaG10QAVLLyn3iNyR f3+g== 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=J5DWD32OWLq13uaRlJE+1ppOi8qnCqTf5ZEGPUBOy/k=; b=oN/bu7LsXfSZJbnR2KrZxyg/uHYEybiZpnxvapWm7jpiNWJgZgfTi/sC4cWT+Ny35m 3rRqxKyIQV7UCnfseziWN8YMmYF0Gi5oMJCvyQG0kQe6INO0k2EH2uT6Gwful1wAzjNm X4AvoBg1L5l8mVXOt+DXSLfFVqXDuJknhMj/Nxzfigzn9AGBebYzALAoIsPLQzf3qM9Y xr2KquwHAJ9VMTwvQPcBHbXsyDUlvWki0lorPJd3P39JZ+FyFv+PC7bJqsNktZsqe0Lb 0pLTU4eozU5udIC4NBgmXhfgPIpKfbLft0oXrWxEyTSJKlSWrOIHetfXJxxTs36l3C3V avzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QX3hEc5b; 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 k8-20020a056a00168800b00626140fb579si35175334pfc.243.2023.03.30.07.42.16; Thu, 30 Mar 2023 07:42:30 -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=QX3hEc5b; 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 S232414AbjC3OQ5 (ORCPT + 99 others); Thu, 30 Mar 2023 10:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232279AbjC3OQo (ORCPT ); Thu, 30 Mar 2023 10:16:44 -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 B25887AB9 for ; Thu, 30 Mar 2023 07:16:38 -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 E2F986603182; Thu, 30 Mar 2023 15:16:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185797; bh=IS0da1vr/9JtA9BZ0bqYXl4kxrPBhntX0yK9vYbXQe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QX3hEc5bIjfn/9HXK/jajCuVuMbQRrBZ8Loplcaqwr1QocxrJZ+zBv6+c6/DiAeZT Mv9JHPxihln/XNGYfeDfp1/N5615fjGs0C69afbiTYj7CNa9UkY01gbQuwqkDlWmIQ H6ayZp7oNoT/5bQF7LALmtquNP1OT/YJuSj3dOwuj1yahcObgPHsM625uehycHYJ58 7x9x9+WynBYqBPMs2fjKBk5Sr7PRD0DH1uvCA2MV3p1HvDFKPizrYT8YorV2w/3KUZ PiAiqC7EisBDt9NjH+/48UPpci82qDhXFAG2yRAzDo0QVbV5Y1f8Zgy/MTbZ6evud8 YIWllQ4Fi/lmA== 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 Subject: [PATCH v1 2/8] drm/mediatek: dp: Move AUX and panel poweron/off sequence to function Date: Thu, 30 Mar 2023 16:16:24 +0200 Message-Id: <20230330141631.190528-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761804131449576964?= X-GMAIL-MSGID: =?utf-8?q?1761804131449576964?= Everytime we run bridge detection and/or EDID read we run a poweron and poweroff sequence for both the AUX and the panel; moreover, this is also done when enabling the bridge in the .atomic_enable() callback. Move this power on/off sequence to a new mtk_dp_aux_panel_poweron() function as to commonize it. Note that, before this commit, in mtk_dp_bridge_atomic_enable() only the AUX was getting powered on but the panel was left powered off if the DP cable wasn't plugged in while now we unconditionally send a D0 request and this is done for two reasons: - First, whether this request fails or not, it takes the same time and anyway the DP hardware won't produce any error (or, if it does, it's ignorable because it won't block further commands) - Second, training the link between a sleeping/standby/unpowered display makes little sense. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 76 ++++++++++++------------------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 84f82cc68672..76ea94167531 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1253,6 +1253,29 @@ static void mtk_dp_audio_mute(struct mtk_dp *mtk_dp, bool mute) val[2], AU_TS_CFG_DP_ENC0_P0_MASK); } +static void mtk_dp_aux_panel_poweron(struct mtk_dp *mtk_dp, bool pwron) +{ + if (pwron) { + /* power on aux */ + mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, + DP_PWR_STATE_BANDGAP_TPLL_LANE, + DP_PWR_STATE_MASK); + + /* power on panel */ + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); + usleep_range(2000, 5000); + } else { + /* power off panel */ + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); + usleep_range(2000, 3000); + + /* power off aux */ + mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, + DP_PWR_STATE_BANDGAP_TPLL, + DP_PWR_STATE_MASK); + } +} + static void mtk_dp_power_enable(struct mtk_dp *mtk_dp) { mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_RESET_AND_PROBE, @@ -1937,16 +1960,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) if (!mtk_dp->train_info.cable_plugged_in) return ret; - if (!enabled) { - /* power on aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL_LANE, - DP_PWR_STATE_MASK); + if (!enabled) + mtk_dp_aux_panel_poweron(mtk_dp, true); - /* power on panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - usleep_range(2000, 5000); - } /* * Some dongles still source HPD when they do not connect to any * sink device. To avoid this, we need to read the sink count @@ -1958,16 +1974,8 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) if (DP_GET_SINK_COUNT(sink_count)) ret = connector_status_connected; - if (!enabled) { - /* power off panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); - usleep_range(2000, 3000); - - /* power off aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL, - DP_PWR_STATE_MASK); - } + if (!enabled) + mtk_dp_aux_panel_poweron(mtk_dp, false); return ret; } @@ -1983,15 +1991,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, if (!enabled) { drm_atomic_bridge_chain_pre_enable(bridge, connector->state->state); - - /* power on aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL_LANE, - DP_PWR_STATE_MASK); - - /* power on panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - usleep_range(2000, 5000); + mtk_dp_aux_panel_poweron(mtk_dp, true); } /* eDP panels aren't removable, so we can return a cached EDID. */ @@ -2015,15 +2015,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, } if (!enabled) { - /* power off panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); - usleep_range(2000, 3000); - - /* power off aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL, - DP_PWR_STATE_MASK); - + mtk_dp_aux_panel_poweron(mtk_dp, false); drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); } @@ -2188,15 +2180,7 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, return; } - /* power on aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL_LANE, - DP_PWR_STATE_MASK); - - if (mtk_dp->train_info.cable_plugged_in) { - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - usleep_range(2000, 5000); - } + mtk_dp_aux_panel_poweron(mtk_dp, true); /* Training */ ret = mtk_dp_training(mtk_dp); From patchwork Thu Mar 30 14:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1162515vqo; Thu, 30 Mar 2023 07:19:25 -0700 (PDT) X-Google-Smtp-Source: AKy350btxhJPfleOwUeWFO+N4grrSeIhdEKjwTvzOqk++ew2I8OhBRj1+o213adQ3v8jHU1bnptt X-Received: by 2002:a05:6402:386:b0:4ac:ce82:9825 with SMTP id o6-20020a056402038600b004acce829825mr21907266edv.16.1680185965380; Thu, 30 Mar 2023 07:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680185965; cv=none; d=google.com; s=arc-20160816; b=JIzRM8sCXhYHaz/EdwXbg8kEnM7BRUA0gfTEuO0sk+6j26zpyRdHHm7drMvefUmYVT wuOHTufDhA5HGKxKCgytPKR1FGMSK/BM14a1RdEfzCNTmGClYaL+vvkRntezYeWCl0oh YTK/RHK7kHcO6rOat8M1Gge16cOI2X+zWdSLg9xQS0AY8LF58Ui2WoWvoArBPG3jeCEZ yKKaO6j0G+MS5NWMFWXfyH/k2t03AQiKVX7SNIFXEdUL/5ATt31X//dmuj/cXnhUr7Au +qvNz5StxMV2kqiFimmVagfTLBtcXXzBXwQw/cvxFnAr5MQnZuDpF/7GMkSYIQq8ZcKQ Zusg== 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=SA7K1DKPDuni2CUxMFtz6LVzpvZXN/0fsgagtyIjImk=; b=lXgYmm46FkVio+t6ldkryu5Z++tnSePb1PSw3OABdHHbYZxH4xiuBOxBeU59iUzRKq isVJuwyt59APiYsLlNIz+6RKKq2nKw0SdXiSsVEnjhqxsPghE1cZlQvOwAvvOWTtfun7 nf8l0v2GNDw1MxK8F5hNxempzSj1TTlDgveaW9Und8LP1JCLfuRRHRIBpI5XXGEJXMqM ZmQCjyOFUCQlnyfYEjZNqEgUHJzIceoDrsZ3K88hT0P4Qq8tR1MzZ4nesA618X5bnyZs JY1xfcb7EOcevm3YneAMIWjy4A+pM+wnP69GYjrpie/javjf9AbMFPqAFt/QyN5meEec y+yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kok26pBY; 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 l20-20020aa7cad4000000b005004b4ca08dsi34336828edt.599.2023.03.30.07.19.01; Thu, 30 Mar 2023 07:19:25 -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=kok26pBY; 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 S232348AbjC3OQt (ORCPT + 99 others); Thu, 30 Mar 2023 10:16:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232270AbjC3OQn (ORCPT ); Thu, 30 Mar 2023 10:16:43 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B93CFB440 for ; Thu, 30 Mar 2023 07:16:39 -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 A63066603189; Thu, 30 Mar 2023 15:16:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185798; bh=l7DxgZbkLf1a/NAX8ACnOYom2qi3A95N4rbvhFxlUX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kok26pBYezCXLsDqlPBv2AAuuArwPCPm1egmztLbAPV5WKAfc+jLvl0aZaf7UVrMA l/Zhteq7VX7hcsoAwMknWLdZJSAi0O4Fio6waFY2Pr41THlth0BFXPi7deedr5xEPx 63S5QwMCvF8YA8KpXRt4nGT2Bbp9ceXaYVJWGp0vlqzDh7pToyaxp32L6x/UyxUfqA fyP/CP3Dd38Pm2kh/s0Kc5VQgkfuSADcIxGEzExSKXZ5eri9mqF5FyFPQFjDsvy8As aVx2r8UUvdYP8QRJJQzMoOvO7cYfz8rI5M7yGvor11hIymYm9ybjXMJMXn6rqzRX0K C6cNQX6P9RCxQ== 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 Subject: [PATCH v1 3/8] drm/mediatek: dp: Always return connected status for eDP in .detect() Date: Thu, 30 Mar 2023 16:16:25 +0200 Message-Id: <20230330141631.190528-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761802678553053258?= X-GMAIL-MSGID: =?utf-8?q?1761802678553053258?= If this is an eDP panel it's not removable, hence it's always connected: as a shortcut, always return connector_status_connected in the .detect() callback for eDP connector, avoiding a poweron, a check for sink count and a poweroff. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 76ea94167531..c82dd1f0675d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1957,6 +1957,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) bool enabled = mtk_dp->enabled; u8 sink_count = 0; + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + return connector_status_connected; + if (!mtk_dp->train_info.cable_plugged_in) return ret; From patchwork Thu Mar 30 14:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1178956vqo; Thu, 30 Mar 2023 07:44:04 -0700 (PDT) X-Google-Smtp-Source: AKy350a9MCedwdxKwUVE2JB9aPiWKc+6bk/dPNDPG0hXZAB5fvmpDHY1ZIrSH66+2D9z7hRQsLPs X-Received: by 2002:a17:902:cec6:b0:19a:ad2f:2df9 with SMTP id d6-20020a170902cec600b0019aad2f2df9mr26307225plg.55.1680187444572; Thu, 30 Mar 2023 07:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187444; cv=none; d=google.com; s=arc-20160816; b=w4SAfH7VVi16L50M02ZIMTnV9Y3No5PUFVhgKI2Pd8P8KGbokzd3CfdByguhCrSXpc LJQcbHHxe1ycsFmaWUZ9Yqd6L3ctbCMVUbdYLoefEV4rVzERevVP3Pxe07CZKcoGTZai 3HV6CEXZeV5f/OEog2H+FhmJwU505jsh7DZzcNN26cxEa+qq/HHLBYJLesvp/Qmu2QWm OdRsS5Ddefn696uZWMv/uEuKsD7BJ5RRl2UAfbqKEXtlZHfd31bYJYeOrpsYH3yuby7r wVM4bpoRjlzmRSXUmFFnN87VZyH68iJcsdNhuKR9zo5N2Je57LzlUCKJtPMC3bZDXlA1 KBoA== 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=nCg5ICz9XbPYs8GpKnZD2kdwz9IxKkREMg8mLvGBySg=; b=yqfiOwEmQ++iPORLuJbd+9w5XM9uL6PZA7tzx17WcGZUgN7pnyhya20Bq7U+FnpKGy CHT9o+vmUvf1Fy4ChYzPiN9vpy8zlJnJCi3vqy9M1EpIlasbcV7/uyYscRxdfRNR4juc eh2ttsAGPez8tDge+Fg0hVW58zB5ZNXbFunofxh+qiWQn39QMeFuIIwJLKrgFLQiVEgS 8MpjwpJgNfBEoTBJev7UyeO3bEQtpecHWjZoy3eWAIsnoBOMY+V80KN4knSFF/Sfoocn stcakae4ipsFTrT/MGTy6UJM6S/em1KSfAX1U4GqZnpkmtfTxuLD8jK8u5S9rp/3roGh n9QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=E3prFSel; 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 j12-20020a170903024c00b00194a5108613si36553176plh.177.2023.03.30.07.43.48; Thu, 30 Mar 2023 07:44:04 -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=E3prFSel; 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 S232371AbjC3OQv (ORCPT + 99 others); Thu, 30 Mar 2023 10:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232272AbjC3OQo (ORCPT ); Thu, 30 Mar 2023 10:16:44 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 323A3B761 for ; Thu, 30 Mar 2023 07:16:40 -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 696766603188; Thu, 30 Mar 2023 15:16:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185799; bh=3ZbLGCMsG/gn15JDSWm25FtN0N4B/ueru9VCCfJiapw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3prFSel4ya0ptVFTP/t3CCVEDXD5CPfqu6LP2Idm1G5ho0artipcCQ2GfC454Sy7 EIZ4hfEH11GN0Uhap+714IMBcw9PbSA/qraXh50zxLr0lEhdpODjwoW2OjkHS1d+/c KTMsAvlq0ExWjJpeGvkQK/LAPqjkkGM9mpjLd2KEUZditEbQaGlvqob0dJ2MhhAU86 Ab1Vu7dDjeaItWiawNG3GTrrm8ZCNjuo7RLS3cF+gDxO/RUizb72gxeqU4WLT3G335 1AMNT7iLCp7Xw5aWznxtXwJkrb3AaKgh8+AR+d2D3T21+LXsMZkEYrw+Ol3DuW9JEn ZSCTYBFt8tWyQ== 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 Subject: [PATCH v1 4/8] drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel Date: Thu, 30 Mar 2023 16:16:26 +0200 Message-Id: <20230330141631.190528-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761804229689307758?= X-GMAIL-MSGID: =?utf-8?q?1761804229689307758?= eDP panels are not removable: at PM resume, the cable will obviously still be plugged in. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index c82dd1f0675d..ac21eca0e20e 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2607,6 +2607,9 @@ static int mtk_dp_resume(struct device *dev) mtk_dp_hwirq_enable(mtk_dp, true); mtk_dp_power_enable(mtk_dp); + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + mtk_dp->train_info.cable_plugged_in = true; + return 0; } #endif From patchwork Thu Mar 30 14:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1171618vqo; Thu, 30 Mar 2023 07:32:36 -0700 (PDT) X-Google-Smtp-Source: AKy350b4y1Y8jdSL2hqVwq8NXN0cMEQT8z2OmypDNwhExgwu8b61kWJXctz1c2lxWWuY2+Eb3k8R X-Received: by 2002:a17:906:49ca:b0:878:545b:e540 with SMTP id w10-20020a17090649ca00b00878545be540mr24766417ejv.51.1680186755907; Thu, 30 Mar 2023 07:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186755; cv=none; d=google.com; s=arc-20160816; b=ZxIshIEmo/jDRdwWqoCtF2lxKLi36rH3AJjRU9w0+KauzjN+HE+dGJlnfc7BYHCzZG 32edZy1it7B+r40AbyC6AmUsy1LKrQP+Y93u1rfVw6m1mSSvmL465WYVXD2aMn+UG4+w rqd+HruBjPVzd49mJh4mfQhXIIig0p7yD5+7XwDMsuNO+bF8ZDmbL6i2NMTKOsz4fX0q N7UKauqb/9/CRhfBx5jEFxpNPt4t9L/17zvwWHNCbqgA4RqQnrwC1RD32GCo1/IKBMxW SX9UcNbJOW1Oaog13V/+CkcCTQ8DfOlkOm4fjb1mOy2TtSDDO++9jjtQRQmIGAkthXfG JRYg== 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=6FtVoiMV/omg48bRFmqt6pDYPYlhyrqg6evx0w4MWTE=; b=ga4RkpUrXEnIZLSZialCJbdG5tk8iXoD9+0P2zR8GGi7ghk37xs6qbynMmQ+pGbbJz YD+pv1M2lH3OhEX+BgLEgCqDXAB7mRNHnHYi+Irci5JWdPrroktoUoHeyxioQF8AM7aj BWV8449mqw5Clzdg7skm9BdzPWPz0S6Dhhx+tJ+cFwbIrBQ7H6OvgQw9W/MzvjHgSo+Z Hw+nCRxUA3Gx84ZVu05RHfQGYR8EgBpcKrNex3xsWAbcrggPTvVWwzWnAq2ReyJS2ehR LcJ+F3R1F28a52cPM4Lrvr1JQiX4jB5RGsPeZ6bTcEhbK4eXD4hUAMCR6FUFmQka/REp 08cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="lxDdzA/s"; 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 n5-20020a170906688500b009320276666asi33920072ejr.793.2023.03.30.07.32.10; Thu, 30 Mar 2023 07:32:35 -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="lxDdzA/s"; 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 S232424AbjC3ORA (ORCPT + 99 others); Thu, 30 Mar 2023 10:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232266AbjC3OQp (ORCPT ); Thu, 30 Mar 2023 10:16:45 -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 238E72681 for ; Thu, 30 Mar 2023 07:16:44 -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 EC1E3660318A; Thu, 30 Mar 2023 15:16:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185800; bh=dxC6MHx3NJXRAEW1ywTcNfOZX7I8dn5v2i9D/PKGK9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxDdzA/skgD2ZgYdNlhX2IjyvEpd6f4YTDdMHHtsEDnq4u3PwMSSw+jGBl2NgXFOv fH4mkU7RvKer8Fz4LPpZdqJ/SpAkgocyp0wbF8XDnNRs1xF1zngb/WTffZibApmXK9 wcMF08O+71aHB/mjQlkigk+uwSGmwssq5A0aJY0naSk5PgwGh7n6xxiqsogSq7Tgl7 5ngx85N5LQ9KSB6HOVHe0ucb3hWFkndrBOFVIJPfWiCmb4r0L5woxvsw/5Q9t5x7xZ N7x0H4VlheGIcQpatW3ETkuOlzs11cYH9cEH6R5Jm60AJF9bbu6AN/nlOEzih51gfd 7BCMvtRa1IJSA== 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 Subject: [PATCH v1 5/8] drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer() Date: Thu, 30 Mar 2023 16:16:28 +0200 Message-Id: <20230330141631.190528-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761803507489374776?= X-GMAIL-MSGID: =?utf-8?q?1761803507489374776?= Change logging from drm_{err,info}() to dev_{err,info}() in functions mtk_dp_aux_transfer() and mtk_dp_aux_do_transfer(): this will be essential to avoid getting NULL pointer kernel panics if any kind of error happens during AUX transfers happening before the bridge is attached. This may potentially start happening in a later commit implementing aux-bus support, as AUX transfers will be triggered from the panel driver (for EDID) before the mtk-dp bridge gets attached, and it's done in preparation for the same. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index ac21eca0e20e..19b145cf2e05 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -849,7 +849,7 @@ static int mtk_dp_aux_do_transfer(struct mtk_dp *mtk_dp, bool is_read, u8 cmd, u32 phy_status = mtk_dp_read(mtk_dp, MTK_DP_AUX_P0_3628) & AUX_RX_PHY_STATE_AUX_TX_P0_MASK; if (phy_status != AUX_RX_PHY_STATE_AUX_TX_P0_RX_IDLE) { - drm_err(mtk_dp->drm_dev, + dev_err(mtk_dp->dev, "AUX Rx Aux hang, need SW reset\n"); return -EIO; } @@ -2061,7 +2061,7 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, is_read = true; break; default: - drm_err(mtk_aux->drm_dev, "invalid aux cmd = %d\n", + dev_err(mtk_dp->dev, "invalid aux cmd = %d\n", msg->request); ret = -EINVAL; goto err; @@ -2077,7 +2077,7 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, to_access); if (ret) { - drm_info(mtk_dp->drm_dev, + dev_info(mtk_dp->dev, "Failed to do AUX transfer: %d\n", ret); goto err; } From patchwork Thu Mar 30 14:16:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1178240vqo; Thu, 30 Mar 2023 07:42:55 -0700 (PDT) X-Google-Smtp-Source: AKy350YTjOHHIyYxg67kz66/Dt4tpA7nGNEtYHLiZ1FRY438ZU8uM3+476ttvzdJ7xh1lx9+4v9h X-Received: by 2002:a62:38cb:0:b0:626:7c4:9f38 with SMTP id f194-20020a6238cb000000b0062607c49f38mr21962865pfa.31.1680187375413; Thu, 30 Mar 2023 07:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187375; cv=none; d=google.com; s=arc-20160816; b=q3Y8AbdhRfXpVlc6iBh95XSnKKdgDdKNU7K+O1w/81a2GyvCJciQ40JCHEqts5O+vL voC9bbujvGezsUlVYL3+0FVQli43Eeyd20scWZ6d0inPRkYzglTAcm87FVdaiGOroSqC AyjjSXp7Bs8eQALijUflDmj0CXranDadDpaKNNfhOffNkiS+jRKzTMqIhX1phd05dQ1h 1JLcogitakhqFFE7FMxQxezO4CuY48qfK+C7qZtA9/H0SRMFROlYll95WFG0QSkCGi6A F56I0NM+3ntljN3Dp0eNPBHXS/lNc7EAXEV4uqL64Grdm94Gu4OnChn48a/MojULaskX T0bg== 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=5aR76aUK66V+oOGD/BsUrwTZt7JhshN2uJKaf7z8324=; b=WrsAkuH+Ss36nIvX0qwIA1dLLPdnyOaSesn6v7LKAxODiYRtdQ5hUCMTDOcOvgfEa+ Bi3UyQxszwpPC/m2FtGp4BcW3pqGqInjWdGKlVihejSyYLFBasO8eMyFL/WE3s72f9EL U2ignlTpYXPQp8VMKzY8Ul797c4IPP7Z9G5eyhFW1Onv9X+5y3um/13HwLJlR5byoaKy dIckUiaQt7exabRIrmFeKSXRRjJgW9zaP31k+s+lg+PssfnX/pyfhB3jm1+3p3ud4eDv uHpN2f6+TmnStkJPs4sC2ucr/Cm9KdEEovkqMMJCzLBUQea4PkrY4YW/SStV9Wh+WmOm JHxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=g5L7QZxG; 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 t185-20020a6381c2000000b0051334c90cbbsi12787690pgd.22.2023.03.30.07.42.41; Thu, 30 Mar 2023 07:42:55 -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=g5L7QZxG; 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 S232369AbjC3ORJ (ORCPT + 99 others); Thu, 30 Mar 2023 10:17:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232312AbjC3OQr (ORCPT ); Thu, 30 Mar 2023 10:16:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED6F7EC3 for ; Thu, 30 Mar 2023 07:16:44 -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 B0189660318D; Thu, 30 Mar 2023 15:16:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185801; bh=piJKx8AJRTNo3xZLCBhwQ0b5ZyuIg8W2w0zGxP4Udgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g5L7QZxGqzl2u0VKcmghM/MMjLooj5fsprmmNQ9NEj9rz+nlXW064NZKV3CImYyKK myo7/zMZP7GvqUYgajmGscUekHcWXfmcVEOrYNBZ9T6/q6YmrWabn9DH2Ub+kU+FLq VGgc6DHaLln0II3Le7D9oGMrlC2v/kfJQ9ZMy6fTJ8mLC8vb520n4hWeTYANCmqwZb vDaEkOA4ZPCucDZF5Ul2dxqjS8g7vl39rZ4F48SS04zYlBX3yOUCfyN1OSDTxtccYf fQ18iC69YmxonW4mxJR+372XwGMsKFdyvLPeIwBI9hRQHvIwaj57QnI5bZX92Gn6L5 WiEnKbtTGqtXg== 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 Subject: [PATCH v1 6/8] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Thu, 30 Mar 2023 16:16:29 +0200 Message-Id: <20230330141631.190528-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761804157060521433?= X-GMAIL-MSGID: =?utf-8?q?1761804157060521433?= In preparation for implementing support for aux-bus in this driver, add a IRQ_NOAUTOEN flag to the event interrupt that we request at probe time and manage the enablement of the ISR at bridge_attach and detach time. When aux-bus will be implemented, enabling the interrupt before attaching the bridge will create an event storm and hang the kernel during boot. In any case, the interrupt handler anyway requires resources that are initialized by mtk_dp_bridge_attach(), so it cannot do anything meaningful without... and even crash, but that's not happening in the current code because the HW remains unpowered until resources are made available. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 19b145cf2e05..6aaf162a6bfe 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -100,6 +100,7 @@ struct mtk_dp_efuse_fmt { struct mtk_dp { bool enabled; bool need_debounce; + int irq; u8 max_lanes; u8 max_linkrate; u8 rx_cap[DP_RECEIVER_CAP_SIZE]; @@ -2148,6 +2149,8 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge, mtk_dp->drm_dev = bridge->dev; + irq_clear_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + enable_irq(mtk_dp->irq); mtk_dp_hwirq_enable(mtk_dp, true); return 0; @@ -2164,6 +2167,7 @@ static void mtk_dp_bridge_detach(struct drm_bridge *bridge) struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge); mtk_dp_hwirq_enable(mtk_dp, false); + disable_irq(mtk_dp->irq); mtk_dp->drm_dev = NULL; mtk_dp_poweroff(mtk_dp); drm_dp_aux_unregister(&mtk_dp->aux); @@ -2482,7 +2486,7 @@ static int mtk_dp_probe(struct platform_device *pdev) { struct mtk_dp *mtk_dp; struct device *dev = &pdev->dev; - int ret, irq_num; + int ret; mtk_dp = devm_kzalloc(dev, sizeof(*mtk_dp), GFP_KERNEL); if (!mtk_dp) @@ -2491,9 +2495,9 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->dev = dev; mtk_dp->data = (struct mtk_dp_data *)of_device_get_match_data(dev); - irq_num = platform_get_irq(pdev, 0); - if (irq_num < 0) - return dev_err_probe(dev, irq_num, + mtk_dp->irq = 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 = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); @@ -2514,7 +2518,8 @@ static int mtk_dp_probe(struct platform_device *pdev) spin_lock_init(&mtk_dp->irq_thread_lock); - ret = devm_request_threaded_irq(dev, irq_num, mtk_dp_hpd_event, + irq_set_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + ret = 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); From patchwork Thu Mar 30 14:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1166997vqo; Thu, 30 Mar 2023 07:25:56 -0700 (PDT) X-Google-Smtp-Source: AK7set/ErX4wuxVD7CPrNkP0G1FNkdvIKn2Ri3Nah/L+KPb8VdA0sh5q7zJZ0WVsA5796ux9oUak X-Received: by 2002:a05:6a20:a82a:b0:db:1b41:704 with SMTP id cb42-20020a056a20a82a00b000db1b410704mr18817217pzb.16.1680186356095; Thu, 30 Mar 2023 07:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186356; cv=none; d=google.com; s=arc-20160816; b=Kcz3U0adPLUgR7OgkwPo62a66oxoWPL4g4m+pR9eGxhkF63bvTxQ4C99qRfAZtBZJr 9XEyhBcjWoXkYgs2gVPFM9mlGSC21rEbxIKAi7yPznzCQZzbmbx7NtBsZQpk9LjAQyO0 vMZTdID3bqh7OhkDzX7ZNss8CJS8KeYQNluuih9esc/q4qI/LtxN6j4i7PDF9aQeV+FC Bo6bQhZKfTVAJ+uGG2j6eXge2+sgK62gQZycEqVVTE42wsaMTrBA+oB3e1of2BgOz8dN XWYmL3JC9UsGdfdRViiE/Ahx4TrfTlLjOzhSYESDL5MATMzL1OQNGjF7SsPv6S17tyHj QpDw== 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=FPL/NFW6a4XbVx65QKR0eZskSslmSBbVywRw1jCRzh4=; b=Ifszc6YpBfQciwMFRrehRIIY/OPT7kM3i8mXhNkETNyWO6K425QWtficfQ0aVYozxD 4mPqA5Cl5NElpzlb1jmDxPTTGs5uLJkEeXc9QcwKbfoq+Jed6ecZWACAyK5cRSliP9FL P62vcPjPm4lXHgC8VH/I4GlWWuwLje4+GjCoLZJwgzqR4W4wKTLutseW7OP8eMYIitE3 rE7wX6xXX3ghgiTLeFUFELc0cDU7cPYzhWuuByCn/yeEakaLgMKywhOYqTEHFi8qqpKI 5xAy60UGrV1+fJX2b45wlOU8B9UjjwnkZNuRVXr9n9IGWGx5GKNg9OIMtMM5IpGI7l3J J+tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aK3ZHmDB; 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 u63-20020a638542000000b00513234112acsi15378482pgd.888.2023.03.30.07.25.42; Thu, 30 Mar 2023 07:25:56 -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=aK3ZHmDB; 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 S232356AbjC3ORG (ORCPT + 99 others); Thu, 30 Mar 2023 10:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbjC3OQq (ORCPT ); Thu, 30 Mar 2023 10:16:46 -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 CCA8C5FE5 for ; Thu, 30 Mar 2023 07:16:44 -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 6D5746603191; Thu, 30 Mar 2023 15:16:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185802; bh=/+IRk8GyWs1c9yVT0iTCxo8DT1414PGgt9mTBDTdxe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aK3ZHmDBVuEE2y80vMNCLAu6pwbfIkiUbL6aB4ukEEV+bjKDFx4xHQDIpmj7woNhm qrpd0m5OYgs86EzB8GKfAnLOVxB4fDmC+24RMfnCc2o2S1N2grVnj39w6HZga+2/1y VU1vFAwybwNulwZ4ibH9HlEQqQnekLBOHnigwSQdsMo5Bm4i0QL+klWEC5NPzoSxo1 X3xcKSN2TxINeDjkb2YsCfxdJhh5DJa63YxP71NoERP/VpsGCPtp9oxZIoZgM0GJlC GHiye2YoUQMFPlc8CTiQrDkqjH0wC1mGGIyvGu6VfdWGU/1XrM3OirRI3tinrlos16 0sZF23fDOPXlw== 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 Subject: [PATCH v1 7/8] drm/mediatek: dp: Use devm variant of drm_bridge_add() Date: Thu, 30 Mar 2023 16:16:30 +0200 Message-Id: <20230330141631.190528-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761803088561590951?= X-GMAIL-MSGID: =?utf-8?q?1761803088561590951?= In preparation for adding support for aux-bus, which will add a code path that may fail after the drm_bridge_add() call, change that to devm_drm_bridge_add() to simplify failure paths later. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 6aaf162a6bfe..62d53c4b3feb 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2565,7 +2565,7 @@ static int mtk_dp_probe(struct platform_device *pdev) DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; mtk_dp->bridge.type = mtk_dp->data->bridge_type; - drm_bridge_add(&mtk_dp->bridge); + devm_drm_bridge_add(dev, &mtk_dp->bridge); mtk_dp->need_debounce = true; timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); From patchwork Thu Mar 30 14:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 77221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1180417vqo; Thu, 30 Mar 2023 07:46:20 -0700 (PDT) X-Google-Smtp-Source: AKy350b4cx6FQ9qwBd/bPPSZACsJgByNn8T9nP6SBoqgbjmjC0E+akTLhxJZnl7gTUtw9fvgyCzd X-Received: by 2002:a17:906:fa0b:b0:8b8:c06e:52d8 with SMTP id lo11-20020a170906fa0b00b008b8c06e52d8mr23390485ejb.36.1680187580484; Thu, 30 Mar 2023 07:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187580; cv=none; d=google.com; s=arc-20160816; b=MEpnbXJGLmoq0wuj4TgZ4rs4ZOXs+QsoSuiBZ+b76n9EmUEtUdOUFgTPBd7h5wrR+W X1OFAnB7AJN0PfOo970TmqFLGy3RyokRKvj/ouCWIUR5haGAPkoUwkjk3f3zIQGIDKqG RC2+D1XSwBWiyZA8zy8zItjo9QCXcQc769XPD9xt4Jp03zlVj7W7sOi5ug4+V7wUyA9b dSZsCAWE63MDdF4rD2I5rQ8Bb7Xm0TWrm6upQav4VDbgApjwHkSh1lwWYG6E7aUapaaF Ab0XTiI4Fn0hZeNPHLIZqQoKRiGr+a2VY9RseDTOurVDLekJglcI//y/ZMH6tlkIm/Bb Tq/w== 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=hCVZf8/29WGYT30PSsvdyMj8mlVRvLlPog6iZa30nLM=; b=jUQ//uL2BMIm6dtjvO9vziZXIiwfBYptgYPjlDJML8sqxnJfe3cFN298n8OvxVK3zt 6AqraTKAFmmiQ5kDJzJhscootH9zfdqxZUGKXgNYYRsJW8eXMmeTQ9Xfqgm/eN2kUy5E mXlGVc4iRgZBM8E9Pxg9C4zA3eZC5KVKq1zdfekIn22VNp+JhcCuyxyHseuFD/jVYQbF QSygGxG+c4cv84TJ/1xIuDRCVFWu9/cvC5meuxLJHejgmEXaanCJf1z3yo74JneLYsau RroH76/nYH1cEYfabTVELY2JIy56mqJM3gC8fn2OGeEOGbKGvk2FoVU4NWveeIhkDFiK j16g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CHlMbLXE; 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 sz6-20020a1709078b0600b00932a14e4d4fsi13352688ejc.146.2023.03.30.07.45.55; Thu, 30 Mar 2023 07:46:20 -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=CHlMbLXE; 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 S232456AbjC3ORM (ORCPT + 99 others); Thu, 30 Mar 2023 10:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbjC3OQr (ORCPT ); Thu, 30 Mar 2023 10:16:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D69DAD27 for ; Thu, 30 Mar 2023 07:16:45 -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 325CD6603195; Thu, 30 Mar 2023 15:16:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680185802; bh=eZ/KgEJ3/NtZRipFLNfrQ0jkavJVDGo3ZnqqWIgjfIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CHlMbLXEvdEzvbDBs1TW7oa3xwSEoHjM2bENO0R5QP5j4s7rodfj4FGELpctOY9Ji ohQqqKGmadC97bCZnJnFQdzs95a1lseDpDPM5beVOboMscZkrRP98Eo4cCelKGsJ7Y WLgVPbegbzQWjritLRSisAzr3XcTxEMqJuFU8C03YuC5wmkDHB7PLTRMbUQzwLpqPq C8bnz4FihZx0Orfs6jYQxlmNGxKmzcEdn1By6XRVWlJ308SGaQbNkcXBy+hZ6ZGLDf fqrEvvx6WdLvc8hlWCNEH+vaFT3AKwOLqZH1ccCJWaaEKu4wfN7D92E4krjoMC7e22 Qltm04JGgSvjw== 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 Subject: [PATCH v1 8/8] drm/mediatek: dp: Add support for embedded DisplayPort aux-bus Date: Thu, 30 Mar 2023 16:16:31 +0200 Message-Id: <20230330141631.190528-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> References: <20230330141631.190528-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761804239218236286?= X-GMAIL-MSGID: =?utf-8?q?1761804372553517422?= For the eDP case we can support using aux-bus on MediaTek DP: this gives us the possibility to declare our panel as generic "panel-edp" which will automatically configure the timings and available modes via the EDID that we read from it. To do this, move the panel parsing at the end of the probe function so that the hardware is initialized beforehand and also power it on as, when we populate the aux-bus, the panel driver will trigger an EDID read as panel detection. **** CUT **** Also, since the DP IP will always trigger a HPD interrupt at this stage, it was necessary to add a new `bridge_attached` member to the mtk_dp structure to make sure that `drm_helper_hpd_irq_event()` will not be called before the bridge gets actually attached, or otherwise we will get a NULL pointer KP due to mtk_dp->bridge.dev being uninitialized. **** CUT **** Last but not least, since now the AUX transfers can happen in the separated aux-bus, it was necessary to add an exclusion for the cable_plugged_in check in `mtk_dp_aux_transfer()` and the easiest way to do this is to simply ignore checking that when the bridge type is eDP. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 56 +++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 62d53c4b3feb..f62ef24db67d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -4,6 +4,7 @@ * Copyright (c) 2022 BayLibre */ +#include #include #include #include @@ -2041,7 +2042,8 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, mtk_dp = container_of(mtk_aux, struct mtk_dp, aux); - if (!mtk_dp->train_info.cable_plugged_in) { + if (mtk_dp->bridge.type != DRM_MODE_CONNECTOR_eDP && + !mtk_dp->train_info.cable_plugged_in) { ret = -EAGAIN; goto err; } @@ -2153,6 +2155,11 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge, enable_irq(mtk_dp->irq); mtk_dp_hwirq_enable(mtk_dp, true); + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP /* && panel_on_aux_bus() */) { + mtk_dp->train_info.cable_plugged_in = true; + drm_helper_hpd_irq_event(mtk_dp->drm_dev); + } + return 0; err_bridge_attach: @@ -2482,6 +2489,20 @@ static int mtk_dp_register_audio_driver(struct device *dev) return PTR_ERR_OR_ZERO(mtk_dp->audio_pdev); } +static int mtk_dp_edp_link_panel(struct drm_dp_aux *mtk_aux) +{ + struct mtk_dp *mtk_dp = container_of(mtk_aux, struct mtk_dp, aux); + struct device *dev = mtk_aux->dev; + struct drm_bridge *panel_aux_bridge; + + panel_aux_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); + if (IS_ERR(panel_aux_bridge)) + return PTR_ERR(panel_aux_bridge); + + mtk_dp->next_bridge = panel_aux_bridge; + return 0; +} + static int mtk_dp_probe(struct platform_device *pdev) { struct mtk_dp *mtk_dp; @@ -2500,21 +2521,14 @@ static int mtk_dp_probe(struct platform_device *pdev) return dev_err_probe(dev, mtk_dp->irq, "failed to request dp irq resource\n"); - mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); - if (IS_ERR(mtk_dp->next_bridge) && - PTR_ERR(mtk_dp->next_bridge) == -ENODEV) - mtk_dp->next_bridge = 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 = mtk_dp_dt_parse(mtk_dp, pdev); if (ret) return dev_err_probe(dev, ret, "Failed to parse dt\n"); - drm_dp_aux_init(&mtk_dp->aux); mtk_dp->aux.name = "aux_mtk_dp"; + mtk_dp->aux.dev = dev; mtk_dp->aux.transfer = mtk_dp_aux_transfer; + drm_dp_aux_init(&mtk_dp->aux); spin_lock_init(&mtk_dp->irq_thread_lock); @@ -2570,6 +2584,28 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->need_debounce = true; timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) { + /* Need to power on HW because aux-bus will read EDID */ + mtk_dp_aux_panel_poweron(mtk_dp, true); + + ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, NULL); + + /* Power off AUX and panel now as detection is done. */ + mtk_dp_aux_panel_poweron(mtk_dp, false); + + /* We ignore -ENODEV error, as the panel may not be on aux-bus */ + if (ret && ret != -ENODEV) + return ret; + + /* + * Here we don't ignore any error, as if there's no panel to + * link, eDP is not configured correctly and will be unusable. + */ + ret = mtk_dp_edp_link_panel(&mtk_dp->aux); + if (ret) + return ret; + } + pm_runtime_enable(dev); pm_runtime_get_sync(dev);