Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp852971lqc; Fri, 8 Mar 2024 13:46:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWLPq3s/zo7PM/S6hKwiMx9TKlNtrImX/vTPKwUCD5DqXEF7ETYLcBv7xIdpo17zb3PLa3fvZz1QosdJwEeQyODOmaOYkV51b5dxO9+pA== X-Google-Smtp-Source: AGHT+IGDIhz8RCwwOhKYEs565HZPZEmbNM22EaNUrXGpjJy8Jb2N3YJapumwllQB8YQVUvmABRx8 X-Received: by 2002:a50:c311:0:b0:566:ef9:30ce with SMTP id a17-20020a50c311000000b005660ef930cemr326720edb.3.1709934369156; Fri, 08 Mar 2024 13:46:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709934369; cv=pass; d=google.com; s=arc-20160816; b=BvVSWnTlP/pR83pBAV7y5WLsZAHj8POfJwMJ5A+BGivNTc519z/2NlNlO8hZ0WdDFd UNAYQGNuptUudnQg4XV4A5ZW7KZTW/ktiqAuQ/4n9CJm3BnpTvMxOzCOEd9leg1f53FQ e6PpNRqugMjskFbV8AVlklJcX7UjLZkQqRMcRCtGgdE150emHKdARlxNfjIRWMXo8EGZ tO8AOksWWNb82dYxy6j2e4iRmnAUVU4gVQfBESOL9vBuMMXDpcsfvrmq0Do2w5z+Hbuv BmrkrNt9AYq9YvxKY9IY4EQEAR+hhr4aH8mUQK1SGjwwc3ZUFVA46WVi4HMg8dSBUkhh UJwg== 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=ElXz0zLFBfK+NFE/x2AB4YD/fo4TcWOv2w2crSWLIPA=; fh=424xZoax3V8zoOTunw9aMLgTYU55tyi8czDmrOr0nSE=; b=u2UX3vs4qCtMsxg/TY3z0APfEj/8FxyselcVji0Leal9q6cnBJcjRlSc4m9+ljYKNq 7B0Bgx/RBfVz2/rsgMyPK3Y/qvG7462iqBAb+2JSI0+n+0mfab9KaALarCnYhBgbL9O1 Lrb5zy05k/g1pM53G8r9Og8iaoXImO3POuDYswLoC89KUPgbGdAck7sQDyosf8dp/q5y Z5bBD8PJdzLiMbCezRRiPCU6vPQLr97eqNA+grzBnSkITalv0ZrHXiKAwqErAAwrQHJG cQMwIDPpylQr1tWod2UwHnEVoHwWWy2/ac7rHQHb9oN9+v9ht4AD/ccyuU/dfjKRRduP XO3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kh40VIxG; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-97615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97615-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i2-20020a0564020f0200b00567ff59213bsi157679eda.679.2024.03.08.13.46.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 13:46:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kh40VIxG; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-97615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97615-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.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 E0E8E1F21D15 for ; Fri, 8 Mar 2024 21:46:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 849EB5FB8F; Fri, 8 Mar 2024 21:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="kh40VIxG" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 0766454BC8; Fri, 8 Mar 2024 21:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709934360; cv=none; b=fOxx9erfNz8fX7KPEHZI/Qwwxh5kd44liguf6xGtG6Oyn5/d0op90CzJjifpgmSiu60qz0pX7HzTYq/bY0kYcD9J49phB/Fmk5H/V6hGG7RMwMQ/yRZG+PXfbQ8Chy4aRBimBrM0q8MwTaJrDvP7abhd+rs5eLSDsIzfphc7x5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709934360; c=relaxed/simple; bh=zeaMyt8Z9//SRcrmUMuqCFWVUlPic2v3/bj3jT2ngTA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=HOgwDoqd41cEzIPp/gYbwXrV3k5Z3jXe/xejyGtTjzjJOHo5LJntpavbsyNjSaHUJcDgsqgRsgrif5Ngc1++xdAnujSIsqzBB8ck+q0UGwAqcXAaPrfOisWAKsulBI741OFFPYbCHblGUg0rk0nyo/UAjvp5ftB6JR92E/2JgK0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=kh40VIxG; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 428LhYQR022570; Fri, 8 Mar 2024 21:45:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=ElXz0zL FBfK+NFE/x2AB4YD/fo4TcWOv2w2crSWLIPA=; b=kh40VIxG+wfkj+Pnzgfs5rm 1LkvtFb/Z6X1K/h+D86e1sdx/IzHQDSUT+1HLvWdwB85SKifrIarA9bLl9tjX1Ta l94QwlqCkfZb0PbhEgWtILuTunCEIXqwf8Mi1wmHSd/inRWwaZ0dybeiej+Oxwu/ vPeeQAfItj5wQWNNpbIsRRAGoeN3JM2sLVqcwQJIixrimo1bDMMSQc0kULEJMlVh Fq2dEfDBPGcp3fbGUIEXTLX9P8g/iJPFH4wYfcZUkyR9n+lGKX8NBMiD3I/uSg75 1wUBOU6ceWSLDD/9xz/+L39uUQv8pJ/d5N1un6Z72EEcWZqVDvpj23t/9467Jvg= = Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wr7dp0h3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Mar 2024 21:45:42 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 428LjfNB012025 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 8 Mar 2024 21:45:41 GMT Received: from abhinavk-linux1.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 8 Mar 2024 13:45:40 -0800 From: Abhinav Kumar To: , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , "Daniel Vetter" , Kuogee Hsieh CC: , , , , , , Rob Clark , , Subject: [PATCH] drm/msm/dp: move link_ready out of HPD event thread Date: Fri, 8 Mar 2024 13:45:32 -0800 Message-ID: <20240308214532.1404038-1-quic_abhinavk@quicinc.com> X-Mailer: git-send-email 2.34.1 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-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: HIDzW2aHwYrro6-NY9LdusAP-dJvRFX0 X-Proofpoint-ORIG-GUID: HIDzW2aHwYrro6-NY9LdusAP-dJvRFX0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403080172 There are cases where the userspace might still send another frame after the HPD disconnect causing a modeset cycle after a disconnect. This messes the internal state machine of MSM DP driver and can lead to a crash as there can be an imbalance between bridge_disable() and bridge_enable(). This was also previously reported on [1] for which [2] was posted and helped resolve the issue by rejecting commits if the DP is not in connected state. The change resolved the bug but there can also be another race condition. If hpd_event_thread does not pick up the EV_USER_NOTIFICATION and process it link_ready will also not be set to false allowing the frame to sneak in. Lets move setting link_ready outside of hpd_event_thread() processing to eliminate a window of race condition. [1] : https://gitlab.freedesktop.org/drm/msm/-/issues/17 [2] : https://lore.kernel.org/all/1664408211-25314-1-git-send-email-quic_khsieh@quicinc.com/ Fixes: 8a3b4c17f863 ("drm/msm/dp: employ bridge mechanism for display enable and disable") Signed-off-by: Abhinav Kumar --- drivers/gpu/drm/msm/dp/dp_display.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 068d44eeaa07..e00092904ccc 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -345,8 +345,6 @@ static int dp_display_send_hpd_notification(struct dp_display_private *dp, dp->panel->downstream_ports); } - dp->dp_display.link_ready = hpd; - drm_dbg_dp(dp->drm_dev, "type=%d hpd=%d\n", dp->dp_display.connector_type, hpd); drm_bridge_hpd_notify(bridge, dp->dp_display.link_ready); @@ -399,6 +397,8 @@ static int dp_display_process_hpd_high(struct dp_display_private *dp) goto end; } + dp->dp_display.link_ready = true; + dp_add_event(dp, EV_USER_NOTIFICATION, true, 0); end: @@ -466,6 +466,8 @@ static int dp_display_notify_disconnect(struct device *dev) { struct dp_display_private *dp = dev_get_dp_display_private(dev); + dp->dp_display.link_ready = false; + dp_add_event(dp, EV_USER_NOTIFICATION, false, 0); return 0; @@ -487,6 +489,7 @@ static int dp_display_handle_port_status_changed(struct dp_display_private *dp) drm_dbg_dp(dp->drm_dev, "sink count is zero, nothing to do\n"); if (dp->hpd_state != ST_DISCONNECTED) { dp->hpd_state = ST_DISCONNECT_PENDING; + dp->dp_display.link_ready = false; dp_add_event(dp, EV_USER_NOTIFICATION, false, 0); } } else { -- 2.34.1