From patchwork Mon May 15 03:27:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 93839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6636753vqo; Sun, 14 May 2023 20:30:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Mtcm548G/U3vf4hUYcJRO3N8MASFcEXgPw49Nt61klQO1dYai07mMtbrhWdrm2aU4Ka7n X-Received: by 2002:a05:6a20:1612:b0:105:fd78:cb50 with SMTP id l18-20020a056a20161200b00105fd78cb50mr3274964pzj.42.1684121417272; Sun, 14 May 2023 20:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684121417; cv=none; d=google.com; s=arc-20160816; b=oI9xOLfZYg6qLvRNuqj7On8dvqviJjwWRgI0CECVMZTnCrk8KHxrwLMSQw1t7nixis h2TeThAtaB9Zk5euFoQC4zjAZKesYfs36Z0dfRSJv8W5N4DqmFhyLpyNXd8aKKAfWJV2 jaKjpTlvwBwyuV6aE1ZVsAkoWfC+H9fiY7haGlrBzhFAE8vJaFnscZv17qormvEhhFAt G8aM5LG+7+R98b5lkoB5oYo0I5EFn0i+5ToY/tRnvemfpp9h4LfirBJkxbi5TXYIDoGV gHsTie2GwJZ5PwvDphR1r72q+ndYxIA/K1soy3xd1vLiJHsQLuO5QaIpYyClf+e6lOJQ KA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4SirNCBuCga9+B7l7p460elPYFjZs/qJNA13GSD3Dy0=; b=QGyVB71Ul4kT97SggLaNj50FLuP7mOCtF6SRaclQCHcQURyHjwEo1BkSn2kR2F68Ec Qv1hN3T94g9m1uJQb94htwTFeqbeMTCOflAk2ia0EYxt38mXXl4GmUVe5dJMgwtUKKsU EMnfE9c/p37iU2G/7aZotr+kdkAJTW7knpT78YD8QefqiZhRcrn6pbpGm67G6rW9v6Zs rwdMCzu889CiV4msddItYm45tLhob1z8ooj6VgYwXyPUFhYP3AdLXk11Mn4j4xngTLb8 Jb6u1DbBuzu8tpj2QYk9MWKEJiufV67LmPjHCmHsxWr5DjnBeeMBBhTvoxUjpX+1Zqbt mcXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gfBJlpIF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f25-20020aa79699000000b00643b1616d7csi16062980pfk.77.2023.05.14.20.30.02; Sun, 14 May 2023 20:30:17 -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=gfBJlpIF; 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 S238964AbjEOD3E (ORCPT + 99 others); Sun, 14 May 2023 23:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238336AbjEOD23 (ORCPT ); Sun, 14 May 2023 23:28:29 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3BE1BF8; Sun, 14 May 2023 20:27:59 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34F2rj7K000901; Mon, 15 May 2023 03:27:51 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-transfer-encoding : content-type; s=qcppdkim1; bh=4SirNCBuCga9+B7l7p460elPYFjZs/qJNA13GSD3Dy0=; b=gfBJlpIFei3QlkXIQTvZq6iR2euiXOpQdqnkLaS8UdjqHdORbdOPbWa0QgDxsFPD6qL5 9xZDijylBKzlmsOvGzlwWjMs39zxykW/uaXl2LuBISLfw09XbPxKUqUfk3W7eKAGlJ+z shCnIY6bevqOWQqc8RA9sdgLbThiqXQ0vsphBkDet0uiykFff0HYKYgPOjMhLioaNXWF 3u03+yblM/fucCqKA+r9FHlGPw3K1+RVGN+nQ7oMh4Q9PcxB1ExQ5A9/rwn1gbds8hW5 kVrQnn9lt6CzLwP7uPz7VFfzUVdHAmKK+e4EKsyxWddMEqW42rBL/A0SOCs4COdkGwZY vQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qj08mjtqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2023 03:27:50 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34F3Rohs004946 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2023 03:27:50 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Sun, 14 May 2023 20:27:50 -0700 From: Bjorn Andersson To: Vinod Koul , Kishon Vijay Abraham I , Johan Hovold CC: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , , , , , Johan Hovold Subject: [PATCH v3 3/8] phy: qcom-qmp-combo: Extend phy_mutex to all phy_ops Date: Sun, 14 May 2023 20:27:38 -0700 Message-ID: <20230515032743.400170-4-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230515032743.400170-1-quic_bjorande@quicinc.com> References: <20230515032743.400170-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: _76B2N_t0ZQUrZN6-8mbc6nV-NzRTSOg X-Proofpoint-GUID: _76B2N_t0ZQUrZN6-8mbc6nV-NzRTSOg 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-15_01,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 spamscore=0 mlxscore=0 adultscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305150028 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765929299531552444?= X-GMAIL-MSGID: =?utf-8?q?1765929299531552444?= The phy core ensures mutual exclusion across the ops for a given phy, but the upcoming introduction of USB Type-C orientation switching might race with the DisplayPort phy operations. So extend the mutual exclusion to cover the remaining ops as well, to avoid concurrent reconfiguration of the hardware. Reported-by: Johan Hovold Reviewed-by: Johan Hovold Signed-off-by: Bjorn Andersson --- Changes since v2: - None Changes since v1: - New patch drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 8918ba2b18a4..6baacdf3a4cb 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -2437,12 +2437,16 @@ static int qmp_combo_dp_configure(struct phy *phy, union phy_configure_opts *opt struct qmp_combo *qmp = phy_get_drvdata(phy); const struct qmp_phy_cfg *cfg = qmp->cfg; + mutex_lock(&qmp->phy_mutex); + memcpy(&qmp->dp_opts, dp_opts, sizeof(*dp_opts)); if (qmp->dp_opts.set_voltages) { cfg->configure_dp_tx(qmp); qmp->dp_opts.set_voltages = 0; } + mutex_unlock(&qmp->phy_mutex); + return 0; } @@ -2450,11 +2454,16 @@ static int qmp_combo_dp_calibrate(struct phy *phy) { struct qmp_combo *qmp = phy_get_drvdata(phy); const struct qmp_phy_cfg *cfg = qmp->cfg; + int ret = 0; + + mutex_lock(&qmp->phy_mutex); if (cfg->calibrate_dp_phy) - return cfg->calibrate_dp_phy(qmp); + ret = cfg->calibrate_dp_phy(qmp); - return 0; + mutex_unlock(&qmp->phy_mutex); + + return ret; } static int qmp_combo_com_init(struct qmp_combo *qmp) @@ -2578,6 +2587,8 @@ static int qmp_combo_dp_power_on(struct phy *phy) void __iomem *tx = qmp->dp_tx; void __iomem *tx2 = qmp->dp_tx2; + mutex_lock(&qmp->phy_mutex); + qmp_combo_dp_serdes_init(qmp); qmp_combo_configure_lane(tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1); @@ -2589,6 +2600,8 @@ static int qmp_combo_dp_power_on(struct phy *phy) /* Configure link rate, swing, etc. */ cfg->configure_dp_phy(qmp); + mutex_unlock(&qmp->phy_mutex); + return 0; } @@ -2596,9 +2609,13 @@ static int qmp_combo_dp_power_off(struct phy *phy) { struct qmp_combo *qmp = phy_get_drvdata(phy); + mutex_lock(&qmp->phy_mutex); + /* Assert DP PHY power down */ writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL); + mutex_unlock(&qmp->phy_mutex); + return 0; }