Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7851645rwr; Wed, 10 May 2023 13:39:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ531SpbUQDjAUW232LwJJgEhTpixGqdnHoqNiaNO0l3xpwJj1XiyCZsTYfInmO8IXx/L6oB X-Received: by 2002:a17:902:e549:b0:1ab:d6f:51b0 with SMTP id n9-20020a170902e54900b001ab0d6f51b0mr23570842plf.18.1683751190524; Wed, 10 May 2023 13:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683751190; cv=none; d=google.com; s=arc-20160816; b=mocVUr19feVRkpuLKROk/B0yUB70OD+HYnrrgBVspMGSjSagmYfQ/Py+4p4QDmGwd7 NViWcCtrb2nzBoSGKHQ/L3PCwZ3Vdekb/mRyxiZSxNvlz6nD9zC9HQ9z/D599fMAWEwh wpnFne8lvovrBN4X0IEX2J58IEkqO4wCUcO5KhqsGMiMPyBJNZqSalJC1Utb5bi7VpoA 9W90zlumk3hRIIakEjX34mrLzq38GncZFdy7ndbXLmOZ7iPg+Oa19IAeYzpQiwXo9AsQ wkrJNGykOMUinuDG9CLP90T944hBhDqpPgoZPtzyf5dB/bcGqD0KKTU78wPCOfAw6APm GvsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0pyAYYii88PNocNO2ga6rvzdS7SSDdvLuzat7AJ/Eoo=; b=GLrk/DnMoetfFY2kEQnL3Kh3O5uybLNqaJP/ffiUme32VJbqFDwPSeTqqRImmV/Z0D aileDiorsh+NHCbpWLbCda/05cMfoxNYJmR47wCz2RswNeGVj4iBm/4L1/yq3dATxvWn QHYLM93TnNSB5arduZKP40p36ofJ/D1TmotuuftQxnqtNEXy9rvL2lZAKNcP9OJxYRpm 5uBsng3PPMdEuOTNUZimovAr5UuwoudNfwX2qXINdRNFRah8wnFfOcMlH1qmv2OVsxXQ tmx7D6u5i+5+EawccmHXxSYsWGz7rZmDlN9vhrf1FvIevglGWLW5oFwOAVeudgt0+Dgn kIeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="gHrBE/Dj"; 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=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix1-20020a170902f80100b001a691f376e8si4705700plb.415.2023.05.10.13.39.35; Wed, 10 May 2023 13:39:50 -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=@quicinc.com header.s=qcppdkim1 header.b="gHrBE/Dj"; 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=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236534AbjEJUcW (ORCPT + 99 others); Wed, 10 May 2023 16:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236531AbjEJUcS (ORCPT ); Wed, 10 May 2023 16:32:18 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8C757D97; Wed, 10 May 2023 13:32:07 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34AKRTbY005331; Wed, 10 May 2023 20:31:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=0pyAYYii88PNocNO2ga6rvzdS7SSDdvLuzat7AJ/Eoo=; b=gHrBE/DjWZ159+Pa7hwpFDVUEoZqnAYO+Tvo6uIp9+E2C3wUt3r6DK3/ymPPJytGuhCk YO5J7Eijl1CEFVs6a3TKYleeRp1usCjrbyLA/3wJAb1u06XYDRv/xrTbqT4wyH62tJqq pmKcqAtif+HsQd4j/OqjORUfKJAPiikGht39fSOj49X0KG0XjY/sKwsSv4quOPd3s5f8 vwBt7Spah2UckW+HVc1u9gFD2K2SbPiUendgWMYPOEwExVbqDegXzRbMsCkxeSGfDRyF 577e+WMvyB43ZFACAIT+iKN8QGAz18YOrx7X6mKm/Jb7c30QlhJVwSIDuCT9/BOQKwJY Rw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qgdd9rpe4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 20:31:58 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34AKVMZB010765 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 20:31:22 GMT Received: from khsieh-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.986.42; Wed, 10 May 2023 13:31:21 -0700 From: Kuogee Hsieh To: , , , , , , , , , , CC: Kuogee Hsieh , , , , , , , Subject: [PATCH v1 2/2] drm/msm/dp: add mutex to protect internal_hpd against race condition between different threads Date: Wed, 10 May 2023 13:31:05 -0700 Message-ID: <1683750665-8764-3-git-send-email-quic_khsieh@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1683750665-8764-1-git-send-email-quic_khsieh@quicinc.com> References: <1683750665-8764-1-git-send-email-quic_khsieh@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: hgXO2gphRERLgHvcLi_l65kXXkJENZr_ X-Proofpoint-ORIG-GUID: hgXO2gphRERLgHvcLi_l65kXXkJENZr_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305100167 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Intrenal_hpd is referenced by event thread but set by drm bridge callback context. Add mutex to protect internal_hpd to avoid conflicts between threads. Signed-off-by: Kuogee Hsieh --- drivers/gpu/drm/msm/dp/dp_display.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 71aa944..b59ea7a 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1792,11 +1792,13 @@ void dp_bridge_hpd_enable(struct drm_bridge *bridge) dp = container_of(dp_display, struct dp_display_private, dp_display); + mutex_lock(&dp->event_mutex); dp_display->internal_hpd = true; dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_PLUG_INT_MASK | DP_DP_HPD_UNPLUG_INT_MASK, true); + mutex_unlock(&dp->event_mutex); } void dp_bridge_hpd_disable(struct drm_bridge *bridge) @@ -1807,11 +1809,13 @@ void dp_bridge_hpd_disable(struct drm_bridge *bridge) dp = container_of(dp_display, struct dp_display_private, dp_display); + mutex_lock(&dp->event_mutex); dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_PLUG_INT_MASK | DP_DP_HPD_UNPLUG_INT_MASK, false); dp_display->internal_hpd = false; + mutex_unlock(&dp->event_mutex); } void dp_bridge_hpd_notify(struct drm_bridge *bridge, @@ -1822,8 +1826,12 @@ void dp_bridge_hpd_notify(struct drm_bridge *bridge, struct dp_display_private *dp = container_of(dp_display, struct dp_display_private, dp_display); /* Without next_bridge interrupts are handled by the DP core directly */ - if (dp_display->internal_hpd) + mutex_lock(&dp->event_mutex); + if (dp_display->internal_hpd) { + mutex_unlock(&dp->event_mutex); return; + } + mutex_unlock(&dp->event_mutex); if (!dp->core_initialized) { drm_dbg_dp(dp->drm_dev, "not initialized\n"); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project