Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp496344lqb; Thu, 14 Mar 2024 18:51:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7K9ksrH9UmL0pB6cxl8+Z3nHZD6o6nmppPsja7+DcxFp7DBDjVn52HCPHH+DYiVQYKrj+mkrEhuoGjpP5XlE/eIfLudqFXTi0olf2PA== X-Google-Smtp-Source: AGHT+IF9zNnSjj7NDO6kRRpPPEMRYqD63bpgd+i0z3WASt6HMxZbeZDcGj+GphogR9QZiFbgZwDg X-Received: by 2002:a17:906:f194:b0:a46:6067:97e9 with SMTP id gs20-20020a170906f19400b00a46606797e9mr1904298ejb.75.1710467514826; Thu, 14 Mar 2024 18:51:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710467514; cv=pass; d=google.com; s=arc-20160816; b=S63J9VrjPdzoyYjyihf/vOXdRJhunasrMvX/AK1ALQ8Os5iHzGa4ErvAEVrrQeMaBd ORQ8ggVAV0cxrvCpbKtcy9e8CYb0CagTiScwgoIbI4+/FY7aN0qjKGVfr80ezpskprEU cKfJCzKOxu/DGcB5QPTT29h2NIq+uU+aGRPRAtgIaZn0wx8vhfrqi5qwcoOGM4oMnYH1 DgWiGh/3mp/gRt50G1be9mreExyLw4/SU3mUB369npkZqJqouGCL86YwFIorLlxUXiAu ZQ3hqYdw/7Xd+3CR8TezBauQLSpiQu/0SShf62LKRe1hyLQfkZUUSxYsiegr00igwJEt XfOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=3XtRxBr8QsjZPZc+HT3MG5xiCdCMjVj6cC1ntJAiCs0=; fh=2Jhq+s1oEno0Wdpr3S2XahJkHb2gW8VLXJDbs9t9iNw=; b=r2KiSHKSkzye5jDP7j9GaA2oA4MJUhOsWqPLQDettpFX68KvedZvzmojk8Vr9uWX33 g+ggQ6JmIpuAO2EMkQPqCXxdD+tpHtVIcdGB8Csjk1THMNRjx4BhAh8GPzC5l7JLN2Vt cPSz5QnpW5lzuTM96d05YC05ggMN0cVq/wyQ4nar+5Gje/al2C9dqgN6BpdsGJHjb9FY fGkHTDbqGdNSv34yVwGgh05CEN1pA9gmoSV9BfA15EszseOY4mM2Naoe1oalXHA6xzi+ mPx8aUn64l7IkOjyxnQfOO1yV7S7MIRgYVQQlwed8ixPmMYoYF6XfDxQbVLliv93/g/G 2GaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=FqcQPsmf; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-103974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gs31-20020a1709072d1f00b00a465f6365a9si1278467ejc.848.2024.03.14.18.51.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 18:51:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=FqcQPsmf; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-103974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4CB491F229C7 for ; Fri, 15 Mar 2024 01:51:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52929613A; Fri, 15 Mar 2024 01:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="FqcQPsmf" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B981F46AB for ; Fri, 15 Mar 2024 01:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710467507; cv=none; b=bL1CYgdeqqmT3HMMOzD0WyjHEcaAnA+lrJA0mu7AInDzF/CmMTylFctnFwwtS0Z58VMFc5RzvFINfLBpimJHqUKMzdDKK9L1R7UoWDO+xQqrcNv5wuakuw2HICEhk2/B45wQlng7oaxfByDOWwARMCc8NGTXXk5RDxo3lZJjDrQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710467507; c=relaxed/simple; bh=HUIs/wmjmeQILPr8/MQm/pblJj4sQOKycFQ4qKLkjZE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=uX92YgL8md/jXRLJSPR2F8LH/+wyQmk3U84rC4ssUWu55fYaHBVC/OtbmlG41A+X+SCYQS1oF1QFsIEtBI+4sw1eZxid8WMv+4PxatsNMTtzlH1MRMtEDkOcWgYVPsIeRWj9odL6LC877h/p61mfN1H98TehA/HBvyfb1nN4CjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=FqcQPsmf; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 917ef8b0e26e11ee935d6952f98a51a9-20240315 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=3XtRxBr8QsjZPZc+HT3MG5xiCdCMjVj6cC1ntJAiCs0=; b=FqcQPsmf/zEF+QB2NaDbLNGZQzULFuSDTcVrquCY+Tkjj+XCgNIC7nvTr827LW61aVrurXpa+rE36b9tox8eAmP5i/LNVpUNy5+RM27TMbsUk6rE9gfwR75fX9hgaHrRfh50OWsY6jPUxov1Axj1c3RNUr54el/P2Cu1eBF91fs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:33b1d753-1eff-4879-8081-d374ea47e259,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6f543d0,CLOUDID:32378581-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 917ef8b0e26e11ee935d6952f98a51a9-20240315 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 310660803; Fri, 15 Mar 2024 09:51:41 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 15 Mar 2024 09:51:39 +0800 Received: from mszsdhlt06.gcn.mediatek.inc (10.16.6.206) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 15 Mar 2024 09:51:38 +0800 From: Liankun Yang To: , , , , , , , , CC: , , , Subject: [PATCH v1 1/1] drm/mediatek/ dp: Adjust bandwidth limit for DP Date: Fri, 15 Mar 2024 09:52:26 +0800 Message-ID: <20240315015233.2023-1-liankun.yang@mediatek.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--3.870500-8.000000 X-TMASE-MatchedRID: aNLZUNMgA8DqDJGloYB7/lu4M/xm4KZeB3WB/vm5tBhvOxpHnc6c8tAO OSAF0cTNjhjs4bjZeL60WiAfCTDLxQDNPxu11HXj4pdq9sdj8LVYN1akkye0qOWPsfbn1jth8TF JvgPXI7A4hXsmqdKfO3aeDhnWViUE0lwI2rCt62G4jAucHcCqncnlJe2gk8vI6dkNekyzYlk+xn rY8SIOUkT88A7P9JJ2kiyjM1Ze4W0Pv5/+N9RjErqQyAveNtg65hCwQ3LNHZ2HegbyfstkOnnUb FaXoymeQc1jtbpiLH2AMuqetGVetnyef22ep6XYymsk/wUE4hqrBS4T8labToBwhkOTCouh1zSU gYfoEuN+67+mR/pqXYPIuqi1bh4/LrruoM7sUMSL8WaUGCH4mw5CO1gbP3VdOM8jHJvq79Wbjw+ lQ+OHZvNho9kAt8htLJl1Svx/Hh8xu7K+8aG0gLDxBQ/q2QPNQwymtxuJ6y0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.870500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 2C05BDA06252C926B0A273E8E84954F6A0B77910A9C2749658F0FB14B43045232000:8 X-MTK: N By adjusting the order of link training and relocating it to HPD, link training can identify the usability of each lane in the current link. It also supports handling signal instability and weakness due to environmental issues, enabling the acquisition of a stable bandwidth for the current link. Subsequently, DP work can proceed based on the actual maximum bandwidth. It should training in the hpd event thread. Check the mode with lane count and link rate of training. Signed-off-by: Liankun Yang --- drivers/gpu/drm/mediatek/mtk_dp.c | 57 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 2136a596efa1..14da6077f947 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1870,6 +1870,7 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev) struct mtk_dp *mtk_dp = dev; unsigned long flags; u32 status; + int ret; if (mtk_dp->need_debounce && mtk_dp->train_info.cable_plugged_in) msleep(100); @@ -1888,9 +1889,28 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev) memset(&mtk_dp->info.audio_cur_cfg, 0, sizeof(mtk_dp->info.audio_cur_cfg)); + mtk_dp->enabled = false; + /* 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->need_debounce = false; mod_timer(&mtk_dp->debounce_timer, jiffies + msecs_to_jiffies(100) - 1); + } else { + mtk_dp_aux_panel_poweron(mtk_dp, true); + + ret = mtk_dp_parse_capabilities(mtk_dp); + if (ret) + drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n"); + + /* Training */ + ret = mtk_dp_training(mtk_dp); + if (ret) + drm_err(mtk_dp->drm_dev, "Training failed, %d\n", ret); + + mtk_dp->enabled = true; } } @@ -2057,16 +2077,6 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); - /* - * Parse capability here to let atomic_get_input_bus_fmts and - * mode_valid use the capability to calculate sink bitrates. - */ - if (mtk_dp_parse_capabilities(mtk_dp)) { - drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n"); - kfree(new_edid); - new_edid = NULL; - } - if (new_edid) { struct cea_sad *sads; @@ -2243,14 +2253,10 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, return; } - mtk_dp_aux_panel_poweron(mtk_dp, true); - - /* Training */ - ret = mtk_dp_training(mtk_dp); - if (ret) { - drm_err(mtk_dp->drm_dev, "Training failed, %d\n", ret); - goto power_off_aux; - } + /* power on aux */ + mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, + DP_PWR_STATE_BANDGAP_TPLL_LANE, + DP_PWR_STATE_MASK); ret = mtk_dp_video_config(mtk_dp); if (ret) @@ -2269,7 +2275,6 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, sizeof(mtk_dp->info.audio_cur_cfg)); } - mtk_dp->enabled = true; mtk_dp_update_plugged_status(mtk_dp); return; @@ -2284,16 +2289,10 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge, { struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge); - mtk_dp->enabled = false; mtk_dp_update_plugged_status(mtk_dp); mtk_dp_video_enable(mtk_dp, false); mtk_dp_audio_mute(mtk_dp, true); - if (mtk_dp->train_info.cable_plugged_in) { - 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, @@ -2310,10 +2309,10 @@ mtk_dp_bridge_mode_valid(struct drm_bridge *bridge, { struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge); u32 bpp = info->color_formats & DRM_COLOR_FORMAT_YCBCR422 ? 16 : 24; - u32 rate = min_t(u32, drm_dp_max_link_rate(mtk_dp->rx_cap) * - drm_dp_max_lane_count(mtk_dp->rx_cap), - drm_dp_bw_code_to_link_rate(mtk_dp->max_linkrate) * - mtk_dp->max_lanes); + + u32 lane_count_min = mtk_dp->train_info.lane_count; + u32 rate = drm_dp_bw_code_to_link_rate(mtk_dp->train_info.link_rate) * + lane_count_min; if (rate < mode->clock * bpp / 8) return MODE_CLOCK_HIGH; -- 2.43.0