From patchwork Thu Mar 30 14:20: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: 77204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1169350vqo; Thu, 30 Mar 2023 07:29:45 -0700 (PDT) X-Google-Smtp-Source: AKy350Zju7pbnHuA/TtFL3l0Mgf9xWM79i2rFJYkYFq/JK2eOboJk9veOk7hYkSXnabr32Qetsul X-Received: by 2002:a05:6a00:4e:b0:625:dcc1:620b with SMTP id i14-20020a056a00004e00b00625dcc1620bmr24319756pfk.34.1680186585156; Thu, 30 Mar 2023 07:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186585; cv=none; d=google.com; s=arc-20160816; b=ZN8sPi7Uo+WPDiIe6wIHJfPtkoFeYdzbfy9dzJThTXn6JdSJ8zeX0b9bfxIieMDAYe dp+UtClSngZqt3b7oeZeZEBFeiGD//buG/DgadUYvicpSPs7Cqi0VebxdqiXtkyovd6o hz4yFMZIJgcgQENO36OdwE7YFsBIuIr+jhlkSvMGZyVETl/F2svHiUWa//EcxxTwDYjV DKWcsZRsAQ7lb7WSa+xzxLhqryQbluTfGZ29XWjlfvSzn/S1/A/bx+BE1AS0KGonZP1D PbIM8InEShMApLSOypPxUNFEBUCFh3TxS3lUCl4bRgji6XZntKsd+fScAFoO0e9AtsvX bARw== 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=lJqNDVu4EGG/p7XFokZHaC0agsmW8XJKZdrEkFr0+G6QvUTUbcfMAPtj1QDsXnpg6Q 3kV27kvr02EEES2SFloAL4tumfHKwGDcCSb+fp+xT1oS87Z4CkN42MEH6/Q0Wl1iORZf vKoFlVXsar+9WZyHf3Z0IjNdI/La+hYvWhoAC4hbxadfn09wSuHsfBCnZERSfgbp2RTe tK+YfSiREUShlbSXz4AAmSQfR9/RI7g8ahxPSqtJtrUOZLl+xhL9wYkTPS/AvKCGWPUJ X9ntOctccanJbPUzY/qkr9c8Sfc0PQV0IEBbT1ka2g/3vBfywVraajRITda+rmKEaBWe OHbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fPKMaUB9; 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 e123-20020a636981000000b0050f817e8564si26147205pgc.86.2023.03.30.07.29.30; Thu, 30 Mar 2023 07:29:45 -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=fPKMaUB9; 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 S232372AbjC3OUr (ORCPT + 99 others); Thu, 30 Mar 2023 10:20:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232296AbjC3OUn (ORCPT ); Thu, 30 Mar 2023 10:20: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 5930C114 for ; Thu, 30 Mar 2023 07:20:42 -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 7587D6603182; Thu, 30 Mar 2023 15:20:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186041; bh=aTfefQf7wUPldM8GfwxyIBQhpoEf1h/RP3aMOHoG5mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPKMaUB9pcKRhv67iSyOx+sUENsvJDupMI3jonnm9Rm8BPcttpu+7x3p4EEQsiW9C yz6VK78dYKCALS6f4jauo7bR8O/uLpxVSENMCprMBm9+fYlG0nz2tzq5AYz4owxxX7 Pp8RicYGQGWQea6wDJ+Qky/Y4617oEjcXcSl2m4KgpTEwhk3i4sAYAtcKVoMlD/rh3 DXXWsQPAxnj4eXifnCESevLdl9IoUAbJhpPr0gHV5xwdZizK517iTFTDpseamSiYNe bj+Z4bQAc5kwvIcmIbH/S2UinzEC+t8iOLv9x20s7RG7wA+wkYliZQv0CSLXX6rw98 K1iPrA0Y0Vk+w== 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 v2 1/8] drm/mediatek: dp: Cache EDID for eDP panel Date: Thu, 30 Mar 2023 16:20:28 +0200 Message-Id: <20230330142035.191399-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761803328834905583?= X-GMAIL-MSGID: =?utf-8?q?1761803328834905583?= 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:20: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: 77198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1167162vqo; Thu, 30 Mar 2023 07:26:14 -0700 (PDT) X-Google-Smtp-Source: AKy350aneVYDnCCq6tpMhpR6+GtMIWs8Amiq+RkMIry1rCcnNsCXaSJfiPIUPD2AdMB1VlEVeWJx X-Received: by 2002:a62:38cb:0:b0:626:7c4:9f38 with SMTP id f194-20020a6238cb000000b0062607c49f38mr21902768pfa.31.1680186374555; Thu, 30 Mar 2023 07:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186374; cv=none; d=google.com; s=arc-20160816; b=vlkURFS2H3t+1S8F1+TXUIVt0qemEJ+Ty5nsm2huGn09sd2vJCRSNUjD/XsJcSmS5A GNXdgxH46RPx+DEhtFyZgSZxhPnXXeXkQ764LYCwYyQujvpmFsE+IrJ5aqv0eLjkdO8D 7GHjkwpgDAB7wEsInyhHVaEHnNAres4CRUTxKJsN9BOUgU3R2BbGqJPIbDscOwKJTh5r n+gG2w4JMxYLiXq+e6Pv+WUXfFV7icvhuZNFrFEYvxbnBPemKyLchSgtHqTiwPpAzIEX npKSSc8htQy7GuOBM/Lb/KkLKhY9qDJrqKx6hZXss0Le3K5o/j8hwoyba79hjfjtvPVV Crvw== 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=d1KqHWwtiSnu/HQ9j+AcbEknUUP9ESzdOpx6KLHR5u21Fch1D6eCgB92fzj0l1iBub sFdqdo0QPoKPhKFe5cfJOmlUSrWmauw7pk8xfxhgqf/6cfSSvMo6Zu56im7RC5yqAKNi PwEddCU5Q8ejkL1wRYfoZ81LVVT3BHwiqiq1xmvTDu8dl8OdTTEIsYIr1Ms4Baspt9Wg K86bw/lBoLeUDb7sG81BE0Vf7TM11nOEvxy0pHTErEBng6+jDcl0PEAj0NnyxZjoJHVx 8KTWufwY74Sza1TcY/y2dvhsbSi0AV3RFufhyO5EqZPkWIbBz4pwB3aYtrxmDnH/cAPF R71Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cmNm9GUr; 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 n8-20020a654888000000b005134209f98bsi1391222pgs.480.2023.03.30.07.26.01; Thu, 30 Mar 2023 07:26:14 -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=cmNm9GUr; 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 S232387AbjC3OUu (ORCPT + 99 others); Thu, 30 Mar 2023 10:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbjC3OUo (ORCPT ); Thu, 30 Mar 2023 10:20: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 16CDB126 for ; Thu, 30 Mar 2023 07:20:43 -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 466326603188; Thu, 30 Mar 2023 15:20:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186041; bh=IS0da1vr/9JtA9BZ0bqYXl4kxrPBhntX0yK9vYbXQe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmNm9GUrXZ1goxAMnVTinMesGeXyqZZgfnNqDakJ28ylnpLG2Wjo12UhUq0jqFutf lpxLpcQK4fR26/fKufBGpLZoITp3dPCR9xj9IrEx+4QcicMg6Uff0knwJ3g9OZ1MEI mcYF1yIXnfaw0niCgkmn1S9P8MXXdRl+hPJeuNA475q2uAi9sGKrZrGSpqWXKJwVBO I3eiCOtJXgci6UWFhvfyMZjlI/1ziY/tdzeeOS55kp4Jz0Fq+d0YMl7ApUyY4fmULp W9JmZCOdhrWdvclW5vT13e0Ci5J7JmOlTY+C5qCAjxqBAPFxBAkj7ho9FY3dtU8MWn rjySkUSxZtDtw== 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 v2 2/8] drm/mediatek: dp: Move AUX and panel poweron/off sequence to function Date: Thu, 30 Mar 2023 16:20:29 +0200 Message-Id: <20230330142035.191399-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761803107852696293?= X-GMAIL-MSGID: =?utf-8?q?1761803107852696293?= 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:20: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: 77200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1168341vqo; Thu, 30 Mar 2023 07:28:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YBHPYzE8JDSTN+12xlsotssWJzk2miCtUUSjlN/eB7wCDavX0vjChwYz56kW602WX1sZFr X-Received: by 2002:a17:90b:4d83:b0:23f:9445:318e with SMTP id oj3-20020a17090b4d8300b0023f9445318emr6583694pjb.3.1680186484964; Thu, 30 Mar 2023 07:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186484; cv=none; d=google.com; s=arc-20160816; b=wAtAzbu8aamUwHEeLi8U8K/o5237JbQr118SMDx7AoxptqDF8qcN1ybe7B5YDB4MmD +xeeqE7e8tn71IwfeaekIeDOaAlX3DYWnzTgd5ZtyKMPO9Esl1+AiLhkeii+RC2C8vbA DoagnNrgbQM1XEJrprXWL7mSobuzeV7mCg2mLbMX769h6q/f2lJXQWaDK8t7sGDt4tyE uW8Io9AFHQEB311tvj1KrvBKtvHKXgVuk6Pp1Nqr2EHJk/Uokt/i2zbXrSedQzAPlnc2 GhdA6CpQPQ7qEAr4TZhiHLdk9sPONmpez7zcKFnOTIOb5URXpao3oCHOmU+GShZ40SoV WEcA== 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=KSGFrfznkdJ6m7dJ/2wozNEjT03hH0aoyG40QZC8MslUgu4lixiauk1tcUGVwCSih9 9ZT36qQmkEp3WbhfzqNj1I5P8XYnaut6KbgIE0pxaUPq2qEpx/LxNFgkPUC1a3RZtd4y QiMCz2Hipf6n5CFvZDp0IIRaNZ9+L7tfWSYXx/roz5cZ0bv+/cRu9yiiyoj6077J5Jdi TPWshlsOt/ydS/r4NKB8Cly10syia9Dn1yd3sAz4/Pv+Ps1zjlsYM31DX6DeU85ZScoE AWYTc3uCJsAQYg3nDRrudopE+q8iE74fAcWJu/y0Bxn+uXRXx5NSrnSikjRswLnGMCbf fy3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=G+N7Mm5p; 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 p12-20020a170902e74c00b001a045fcd743si36109716plf.142.2023.03.30.07.27.46; Thu, 30 Mar 2023 07:28: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=G+N7Mm5p; 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 S232403AbjC3OUy (ORCPT + 99 others); Thu, 30 Mar 2023 10:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232329AbjC3OUo (ORCPT ); Thu, 30 Mar 2023 10:20: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 DAF99EE for ; Thu, 30 Mar 2023 07:20:43 -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 166E9660000E; Thu, 30 Mar 2023 15:20:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186042; bh=l7DxgZbkLf1a/NAX8ACnOYom2qi3A95N4rbvhFxlUX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G+N7Mm5p05ibAjldy0ztpMj2bog3cgiYrH6vEB4EDL/2kVNHu6Wdcd/0CHcpnOdy9 PkVQnTF0JZowrF0aJhNMRqikGo19zxRYJs4VBNIYHpcZkbxAwcxPJyWJsmTFP2WOKP qRFrx3+GiO52hsZejPFSNbIxuhdi/m7u+k92akp2y3bLcHD+00rp0OeqLNsOoG3LJO 0/KzS5KP4piExrR/Fn3UropaOKfZRXV85m7umZK0qYDVE/pbOEkwZbFvHZk+cv1hxl oATil3lGCIuzoPjuCCCGmLV+eF4EhdQB0opGbFPK3sFE2vW1gsrWQG7zqXXhRN4d5Z Y4V30RHoIja9A== 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 v2 3/8] drm/mediatek: dp: Always return connected status for eDP in .detect() Date: Thu, 30 Mar 2023 16:20:30 +0200 Message-Id: <20230330142035.191399-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761803223929907644?= X-GMAIL-MSGID: =?utf-8?q?1761803223929907644?= 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:20: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: 77211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1177281vqo; Thu, 30 Mar 2023 07:41:24 -0700 (PDT) X-Google-Smtp-Source: AKy350bL/JxZZhtcpfAsOqYhCAAidVWZNCKaNyNaSPZiiQRA+rHYbqmBN/uTayTeaaVFBUHKkql6 X-Received: by 2002:a17:906:6b8b:b0:93f:9b68:a0f4 with SMTP id l11-20020a1709066b8b00b0093f9b68a0f4mr6828678ejr.26.1680187284054; Thu, 30 Mar 2023 07:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187284; cv=none; d=google.com; s=arc-20160816; b=NoALaRW4Oixb3xU/bhB9Cm79yFEyEpETQEInrJxYSINrcZfGUgWqgpUNmrrSvdZVgw mfcOzF78ivUn2+zWnGmcqH7NY99ayptU3p8TmTgbYg/ITdoSeR40Hq0stoDpz6daPScq SBwsw66UJHDXencL+Ow4dZmsC9uV9O/R2PH+i82hmnxwbRuT1H+tE3IDdd6XZRCOf5Z9 h94AwD46vBo/jSvp+/+IJuAVUv0rR+OF0V2EaffTHhgf7WuSYauocdeUsC0X/eod6jkq vwHnGpaBmZ/1OPJnt+lpiC9K4nGqViPZBRtrvv7v9FphQ2xFpl2sDB11lWoDK5TI8T2L pvpg== 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=YehO5J4j8f7n5dOO4uK0L9ctQB8Cm3Iyhtt6w3bR1VXoUh9tYSJpTwHKkQgmeqadNJ 4aYCZaBFjAdHR0QLD1s8gJD5kgRN6O/rLHdS3+dsdA5Fpf80cv/2c1VmpUTM1bVnPErw gEz3sTQnoSZZ13VV+kPMEv+I0qavyaNzdpTQ8bEChrCssf8CxDb+/rVwW0NN1WOHOvp4 i3GDMEpWDqlgVXuF2L2nieRTVy4n2sQPg4HNSxce7mtON5PSFxXwQc38pwN37eVXEv4i jznJvyGYGqiHdx4lmjQp5lCKxfl8j06axaZFWAw7GnuHVjRR0qzYfWO5uzaqrkF3/FfD UL7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=E3kmtNCg; 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 t18-20020a170906269200b008cd525eac74si32039945ejc.836.2023.03.30.07.40.59; Thu, 30 Mar 2023 07:41:24 -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=E3kmtNCg; 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 S232386AbjC3OU4 (ORCPT + 99 others); Thu, 30 Mar 2023 10:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbjC3OUp (ORCPT ); Thu, 30 Mar 2023 10:20: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 B2580AC for ; Thu, 30 Mar 2023 07:20: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 DD27F6600011; Thu, 30 Mar 2023 15:20:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186043; bh=3ZbLGCMsG/gn15JDSWm25FtN0N4B/ueru9VCCfJiapw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3kmtNCgUZL+OdsGrOaq9hF2DNEwCFoZ1/UMI9b4gxV4utcQ2iiSrW28KKmGfKIy8 yvbC697ZegPXuvwYgghQbwC8QYgRjuQiD6dKZS8BmEWrpk1VHkokcIH0cZ3+SQMb3I ctszC4j/dCXFhGXaVCB+vbqob83p64wUJGdcb0uaWB401uwPIGVHBMpTiMB58JRxX0 QyblxFaz9rMWY1x8idFdkXoei+EY/I8uw+IcOWazPdkMdjUSiktIXqVGqlHNvwRbDT re1e7kDDFEK2zn3Io98oyupnqDztiO3SgCAyuyBDLutKgNkair+RYilKSFAD6ng1IH TbeEZmpuakYJw== 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 v2 4/8] drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel Date: Thu, 30 Mar 2023 16:20:31 +0200 Message-Id: <20230330142035.191399-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761804061614774848?= X-GMAIL-MSGID: =?utf-8?q?1761804061614774848?= 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:20:32 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: 77216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1178568vqo; Thu, 30 Mar 2023 07:43:25 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9VR1fxKGjAbOlMcYAoU5osq9Dw1zT1pw5O2++3Ob4Z96PxHf9/Q+3J5be1l08bP7/Gz30 X-Received: by 2002:a17:906:3149:b0:884:930:b017 with SMTP id e9-20020a170906314900b008840930b017mr23690555eje.60.1680187405643; Thu, 30 Mar 2023 07:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187405; cv=none; d=google.com; s=arc-20160816; b=eSomR8fqQ8YO4wlkJl+zIhi0KMLuJsQDCrIKrP8TbVkWX9q56Rm2cI72s9yntwSkoq bpOSelFc27nN5Dk2RK/LlCUsRnMVtFELke9CR8efgW/d0TI7DvPD3BYmMeNzPPI9mIqd 1XbANe28ZuF+k5nGz4rEp9kULJsg9e5ZdF7QEcFhR3Eb5LXEhj+lp5i3czTiukd3m7D/ MMmd4VnSmau5n1hquHA9idkceVtRcxHEUUASXS39n5RhNKhMUQ2iV98bQN3cd44vkkVe 0/AL8Bk5Qj60YYUdeZgIh/hO4XCHIC/4gN3gjDN0FWjL2KjQI8AldFo/izd3CFP2uosk QzXw== 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=gqJCPs5qR7+yBX+9TyHaL/I3c9W5y5t110OtFR+yUpdYITOW9M0tlJVzh5YllIm/nR d2MC/4KQ7zHj3gqWx4v6frUVxanLym0wTOQRF7vngmtINbvCugbF4A3iE5y8nhW4RN6b 5zuocmEZMCl950jrGgiJeg+o08jxXRqiIPAJIS0SXCK9+1MS7q0MbHnQw402OtrWeqkx ezJmqnZE1Dr+qZeRvETJV0r3pWveXd7NMrGRutCEgGsaxrwDfC+fB+FOaWl+UWPoWlCT FIz9bCVgI5CAVng800+I8m2Z3XtEfXSI60wEfuTWL22eVNOc78eW6gQSHC3wAW26ToCS HRyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ddYdW2du; 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 h28-20020a1709070b1c00b0091f4b3423d4si19623576ejl.670.2023.03.30.07.43.01; Thu, 30 Mar 2023 07:43: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=ddYdW2du; 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 S232425AbjC3OVA (ORCPT + 99 others); Thu, 30 Mar 2023 10:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbjC3OUq (ORCPT ); Thu, 30 Mar 2023 10:20: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 81D45EE for ; Thu, 30 Mar 2023 07:20: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 BB7AD66030CD; Thu, 30 Mar 2023 15:20:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186044; bh=dxC6MHx3NJXRAEW1ywTcNfOZX7I8dn5v2i9D/PKGK9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddYdW2due7/9HVKbxzYtu9mprbB08wIKWQvw7V7jkmkq3Tr9/fDFlQC3KR66FRz8g lE4wuH0bQKrkItvUv+pc5Zb70A4A02tzNvtQTwEcRLWnny8xPpwWZrjNT3QzKmIHQv 9aa/dQlKmuuENG556zDsKvgmZ646n+THpfldeBu6TYfglRdRkOWEQiexg1kKsSUJRB ECqUUtIbWd9WoLI1g2qTsGTSVZeYa/u/YVfAJpodGlxby0xCbzMrJuKy8BSlFGOgHI d3TJKp+Bw60mMFEDn85JzOwAvEH4IBPkP3w4RM9RimqfIYbeEPh2J6rE3xUjbEj3zU ROLlnEE8/NoPQ== 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 v2 5/8] drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer() Date: Thu, 30 Mar 2023 16:20:32 +0200 Message-Id: <20230330142035.191399-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761804188929781516?= X-GMAIL-MSGID: =?utf-8?q?1761804188929781516?= 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:20:33 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: 77201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1168546vqo; Thu, 30 Mar 2023 07:28:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ajg5T3DJ1FdodOnz4CoLoa3a8mwqLnP9OFY78ZDNEcMDG4QXoK+UrH73Ai2m4JkDpCho6e X-Received: by 2002:aa7:95a4:0:b0:628:cff:1440 with SMTP id a4-20020aa795a4000000b006280cff1440mr23493397pfk.28.1680186509167; Thu, 30 Mar 2023 07:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186509; cv=none; d=google.com; s=arc-20160816; b=lVx5/qn5+jyXrkuwi4/mrJBjuKKruK2sbKlDZ0PEN60BXKVOMcIIvbWuRoJThRN5IY Ey79k1Bk7xr4/zk1kI/pOIpRKazL6L73uY6yC95BeGfCDrJEYIVFYNdok4sgITD/M/k6 lIsi5c5om72R/Y9U/0UOfEldyFIcVWPQ8haboHDg0kRQbD9rnWgvw2w9SqoIntn/D7o5 Ga+vbd7grzSSyUKPYIro9LgspplzM+pG3ddgkcqWaze+jAbY+3RplrgX6vioVuLkyXyw zFTvkDBkR/71UPprXnVPR16MxUI/0+dtBeOppGnbyu8saBF7i3F5yDGlTl0isdy896x+ wfOw== 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=QoS0mpKu/2p8ZlUObs7+ssvThHIEhQ1J5huFkOrtNj4XJ2b8DqxmlNL1knp0HMNT1l /LOQhoFZ/lHsfExLpezrZuYvh2Wx0YxbGUeWplvbC5ADisxBZVsKVE2CNlqRJ0GKfKsd MEOleVf1mpqGi5w3TigkSSVfaRxG9fhmaZSbooi8941UI+ovyNK7Kx2a4QK/36dsbfDy sG+tGOY6xD0TeXimgyYKCR3dBiwPgTTF5xPAp5EvGyHBG3Ry6o+oLjInpM73wVt5tDoq G5uL+T7p5xqWnD2QWBhw2fU6vgSvVfjArhZ4cRr78I3iq2Q2cjEhitqKRAh2DLgfsPfm igFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dFFKk7tk; 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 c8-20020a056a00248800b005a7def83ee0si35949625pfv.210.2023.03.30.07.28.15; Thu, 30 Mar 2023 07:28:29 -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=dFFKk7tk; 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 S232405AbjC3OVC (ORCPT + 99 others); Thu, 30 Mar 2023 10:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232363AbjC3OUr (ORCPT ); Thu, 30 Mar 2023 10:20:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65F872686 for ; Thu, 30 Mar 2023 07:20:46 -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 8C811660318D; Thu, 30 Mar 2023 15:20:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186045; bh=piJKx8AJRTNo3xZLCBhwQ0b5ZyuIg8W2w0zGxP4Udgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFFKk7tkMdrxgV29TKXItcjQ8VK6+yTcAue+SKpS+dJlxyYCh033az1Fbx04nLkhx aPIuM9EbxrSdmPUVssrVecUq99vE9/S+MyAe9v5/Z/dLyyA6Efpyf7WOGsuBGtij4x tw+ehm7xwuXINyeL0jdJDY2ybUhQwtct+TWywgZPsgx3w4xjv7tShHr1MgRBT3bM6v n7NUnuYhFeswARfyaJDECrwXzMjGP+JG2HJD+u8nszbq9F+VhG70DohMamZWWZrEv+ +DvXJtl45u/WRfNXeoEqLlCCcvjjLMKKqac1tTf+Z+T8rq97l/tn2jgUAtaNTBe3YV hE+H66Ni5DtMQ== 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 v2 6/8] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Thu, 30 Mar 2023 16:20:33 +0200 Message-Id: <20230330142035.191399-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761803248706411856?= X-GMAIL-MSGID: =?utf-8?q?1761803248706411856?= 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:20:34 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: 77210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1176248vqo; Thu, 30 Mar 2023 07:39:44 -0700 (PDT) X-Google-Smtp-Source: AKy350by26mq8gQr9ksDxK9XjouM2YcpOh5XbH5EtieSX3pr2pBaK11WcYIZqV/higPus+4TADFt X-Received: by 2002:a17:906:fc5:b0:928:de2a:8a3f with SMTP id c5-20020a1709060fc500b00928de2a8a3fmr24082837ejk.31.1680187184627; Thu, 30 Mar 2023 07:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187184; cv=none; d=google.com; s=arc-20160816; b=XRTu2vgOAhM3zFNGEYR1ZsX6EedAtluUYShOxi+FvRTwc3m+Q7vkajSmHVaD4dsnhT OOMPufDQzVjkq75EAK3So2I8h9yTm/gMsLsS/x0tfHR3UQVUNBsu1L8bPVJDt8mriY6T 7qy1q7x2HncnxtCgus5RxxVmRZIGr+h0XoyNS3Pa6F+++pwqhXj4DFyMZ2EVfuR+pGCY 5D3KCgso+0mKKIpfgYR7mbCVMjcm2xNnapupLnP1CDFJZhgiP3LYevE73suLh4kOUYKT 45PbAKlvD3k/E3ldaHgCa5SfF1vT2tEYgJ0EtzK54QDdPW6AsWEhlk4fLdmiDvTVS0VI iXSA== 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=XTvZrTwigv8qei3m83a4vt8Hm1naTpPkHMn6P9PkNvJ+4snWTb3dRc7QT0o9LM/+ml LYDAVdm4VzgZ1xonp+o/Wkgc+nY80dRVjestHS52vtUagyKuM4E1M3ODRhBh1CY2b4HD 56BbzIx0wwKybAckmpeEYMbwl0jluoici624R9HhaqY0p0lFab03m7YB7csV8UWYdegY bgT+aEGEdjDKykdT7wtjWtm7lwLnRUlIsWXCmliHxnykfpYtW8JmKSqlCr7PbRBW5L10 5g0CYr5e3OktsyIA8o2BjlXFO4cuYH52GHaatzs9fuSFec8u7RssthJh8x1xyKC0ifxs 5QXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QLBEtwjs; 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 f14-20020a1709067f8e00b0092fd743c0e5si33877447ejr.184.2023.03.30.07.39.20; Thu, 30 Mar 2023 07:39:44 -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=QLBEtwjs; 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 S232453AbjC3OVF (ORCPT + 99 others); Thu, 30 Mar 2023 10:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbjC3OUs (ORCPT ); Thu, 30 Mar 2023 10:20:48 -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 2ACAA7EC3 for ; Thu, 30 Mar 2023 07:20:47 -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 5DA05660318E; Thu, 30 Mar 2023 15:20:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186046; bh=/+IRk8GyWs1c9yVT0iTCxo8DT1414PGgt9mTBDTdxe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLBEtwjs1qWVOhMCWnpkoysjK4MG8i+7/i3SkOc7q7YkVyGAsieH7Z6KkH67kMdcu FalAsEghikxy0Hl80qt3tLP8SNP+Erca+YxndYwhgTG7VPxUMFCzsW+Vljpwa6kFvD 9irU1kRogE8aACWBb/4mjholJmELhB0aVoKnOSpu8ibSVbf650lb6vybCnwrOHmXTN uT6vq6M967cvkaSvUiuBmjJM/GofLGZDnlCnz8x0yMuwBYOFfHKnBf4QoTRlGQAruX 4/a1BgN8l5U05ieQrbWo9roJEdtiUVf/AIGdZgOhetV/MmskbKjHUPEg/l68X9zcP/ k8j281uu3nZAg== 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 v2 7/8] drm/mediatek: dp: Use devm variant of drm_bridge_add() Date: Thu, 30 Mar 2023 16:20:34 +0200 Message-Id: <20230330142035.191399-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761803957084569485?= X-GMAIL-MSGID: =?utf-8?q?1761803957084569485?= 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:20:35 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: 77251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1239722vqo; Thu, 30 Mar 2023 09:09:24 -0700 (PDT) X-Google-Smtp-Source: AKy350aNdBbhkeuKcVlSx/RBc8Btz57lpw5Cx35ho72BGUBq/p6ThI7+167EcXxtFUHimAIrjMWf X-Received: by 2002:a62:1812:0:b0:627:a283:5a04 with SMTP id 18-20020a621812000000b00627a2835a04mr17864735pfy.27.1680192564014; Thu, 30 Mar 2023 09:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680192563; cv=none; d=google.com; s=arc-20160816; b=mCuZKLcfAbd0R+NDB39S66F9aJmUedMmD1imBxjedb8Ge3Cmzq6XaG98c0G9S7iIm8 w7L+4FVSmqhH43qKYmf3b1H8tAFjAVItdYmkoweXHNFkiyD5ddUIyUMZrlaD7QyzPDux vx15FoYTRU3fnckFHJE9DL2SK/Dnh41vdHrzMLFa85A8n79MGlsjdRCzqehwuQkU90wr OBjTDN3R6ye+1fm7lb3DlqfTDmhqSXGga9uqa9Ug0hvu7dCgzY+Q37Zqa8Cbe+gTKndO QdS5o/zUKAFsviSg3tkdzTlqr01fiRj5ZI34CM5ZYbC0qDG/bzYkqG1giGSsLYy1T3Fq BhTw== 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=g1pi/LmcYvgRJKtK+5aOFQrHIoqs9g5cUAm11ovUN7pAPI5TwlWNttq4/TyL2DTiK0 /5aKdzCKBIiJAUKH+VDJfNbevTn4W8vC1LGyVP2ts9MjqfavrShT1tp6TQ7mmrjVTyPb 5s7FldkKcKIo52N4QAGCUF1I/Yyzcwtxo+p64/jFgHjoAyBKIHpcBoINXdoC8TGpZnHD iJh5jQ3TyYEaLMv0FB7SJ04mZuPoVQeFSiAJZQu3uX9jEcT63ALZIiJ3uA2bwdah83P1 FS1T1m5o8m6HK9/ZLCz6iSiHxWl57cWUAF5sojVwsaSVZAk9eNfRrnwcrcLJajg0eKOC qjYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J6eT9hop; 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 19-20020a621813000000b0062d93688db0si132865pfy.94.2023.03.30.09.09.10; Thu, 30 Mar 2023 09:09:23 -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=J6eT9hop; 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 S232442AbjC3OVI (ORCPT + 99 others); Thu, 30 Mar 2023 10:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232296AbjC3OUt (ORCPT ); Thu, 30 Mar 2023 10:20:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDB3BB8E for ; Thu, 30 Mar 2023 07:20:47 -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 2ECB76603188; Thu, 30 Mar 2023 15:20:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186046; bh=eZ/KgEJ3/NtZRipFLNfrQ0jkavJVDGo3ZnqqWIgjfIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6eT9hopJTfhMn18I6oYzTmUvqzKs9vpBPbgqF+fdtu07yw0ynkbWdjWHyPuL3UU/ U1+dQxHJeYgxp8f1RgMMd8xdqLEy/ZyckdVQ76gyCZp+RLx44/v0LZF1FOGjsXZ37l ISC4MY4EgB+xvKC1hWdanMhrrhPx3/D889LgWNuqmjC81Exa1CGvh84e7AhXKa/R+t 2bNxMulH4r6fZJF+9KdEPHJHYygNVyJqATnz8FrfK2WUhoExVBi6mXZXIxmraHpbDj BlUBvN9AaVujKIKBfTe6+jZTfs3vQmQLSAYlTQx7GCUgbOFM0NEGHRwd87c/QxOcE9 /pbZfV4lK7Nbw== 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 v2 8/8] drm/mediatek: dp: Add support for embedded DisplayPort aux-bus Date: Thu, 30 Mar 2023 16:20:35 +0200 Message-Id: <20230330142035.191399-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-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?1761809598178165029?= X-GMAIL-MSGID: =?utf-8?q?1761809598178165029?= 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);