From patchwork Fri Sep 15 21:38:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuogee Hsieh X-Patchwork-Id: 140931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1471419vqi; Fri, 15 Sep 2023 21:25:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOZr+stpDa7OaCvjqD/GE0bhxDVtC6GEeawynGxx7vdqMvAnlwO/TIp8ZBvQeIMpM8kg8y X-Received: by 2002:a17:902:f54c:b0:1bd:dbec:8673 with SMTP id h12-20020a170902f54c00b001bddbec8673mr8935368plf.11.1694838352009; Fri, 15 Sep 2023 21:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694838351; cv=none; d=google.com; s=arc-20160816; b=t+G988heIxleEvjfzuCPRHSN+y2mErDP9COiQ5HbbsSTN0jWf8EyS2GoDTLQQ5GPuI jpSXc/VOT3sMUBzqsiSRe4PIHkxpEmMuaEFNa/yMhSGyZXJp3Xtn1QHMrxshzr48gaD+ gyU+qp15wPsMlZxRkAzt1lFcVIxS43QzTB0fzDP2A4SzOvCWc/YTc1XOs+JYweRPpW3/ picAbiAL4cGFX2aa5KmE908b7aAI4fLg7npOMMz9oWQru8RWP+hyE+9/Knbz2tIa3wDb IC3Oec6nsgR4tpL2HZmjtUSmMU4BqxlMRBDgTnXpIf/gokPc+tFQtkaE6+GBsmrZltXc EyAA== 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=V4kVOKgck2xwpLN88VujySdujP0s0yj2kNuJri9+fn8=; fh=WdvorNt9W2LCUPiGPsn75/bW5381IkpXRxF82JgZV7c=; b=yxNoQkdRnHnMGp3SeLDZ4WIPnLgz1YfizqUFfuTqaXJjb1np3PbojLNTCH8q0fSIfs yEC+PrPuySOaXc+3zXncsFz/mtSmvPsAY6ury6Kem0iFMwIwZz5em4fdh1oq3b0sLjzS 85kBG2A9ll2a8sRSXY5vngj/tObr1RX7mZHa2qXxGHgAL6/Ddmc/PWDzO5X4rGVBlZ2N 91EnQ80EXt26Safn9OZayeDBZBLkRq9+b65iDOf3Io/cvxyJLtRuEmVQGrUZMBW/9j5o RMcvutJlaWl092hM9LzEn0Uaww7aeAeHFTAxZDI4WHKcEsn/+pJFK4J7E7logNusSkYj 8rrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UNilhdgi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w2-20020a1709026f0200b001c36018fdaasi4146335plk.219.2023.09.15.21.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 21:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UNilhdgi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 243F082A88B7; Fri, 15 Sep 2023 14:40:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237930AbjIOVjc (ORCPT + 29 others); Fri, 15 Sep 2023 17:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237861AbjIOVjM (ORCPT ); Fri, 15 Sep 2023 17:39:12 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 838C7B8; Fri, 15 Sep 2023 14:39:07 -0700 (PDT) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38FET77R029717; Fri, 15 Sep 2023 21:38:48 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=V4kVOKgck2xwpLN88VujySdujP0s0yj2kNuJri9+fn8=; b=UNilhdgiJ6WnNTUJPzBjn5iSqYmM/9+qKlQ6yWQE1YXAVKMspVGYy7PQ5we3fnotpQ0M dcvmqr880GquQKcI4oGEEiTSWdPcZnQthUl72tlrhDY4yugW5zjF748EdZTBVvFuk/xF jtekgEkak+QHuZDiWQVYz69a1EBBaQq3ps8hbsoRNqGJRAEe6VQl+pjmZZQmVGgdGIB+ YjzLSN9rtDCpfkirsQ16FKMgr0RSy3wYUddmn5+xwW2FW3GQY+OTiTa8/+ulNCgdEkhm DDFVubd2SQV3KX3ii3qjz122hzOYmDHcT2KHc0Yar9+UVlzXQLc7x02LTY60bUgc8qlp VA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t4fsfad1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 21:38:48 +0000 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 38FLclmQ014563 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 21:38:47 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.1118.36; Fri, 15 Sep 2023 14:38:46 -0700 From: Kuogee Hsieh To: , , , , , , , , , , CC: Kuogee Hsieh , , , , , , , Subject: [PATCH v3 7/7] drm/msm/dp: move of_dp_aux_populate_bus() to eDP probe() Date: Fri, 15 Sep 2023 14:38:21 -0700 Message-ID: <1694813901-26952-8-git-send-email-quic_khsieh@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1694813901-26952-1-git-send-email-quic_khsieh@quicinc.com> References: <1694813901-26952-1-git-send-email-quic_khsieh@quicinc.com> MIME-Version: 1.0 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-ORIG-GUID: L1UjIB69er1oqSTGghp4PQVpJJJcP_a1 X-Proofpoint-GUID: L1UjIB69er1oqSTGghp4PQVpJJJcP_a1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_18,2023-09-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150194 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 15 Sep 2023 14:40:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777166819795328739 X-GMAIL-MSGID: 1777166819795328739 Currently eDP population is done at msm_dp_modeset_init() which happen at binding time. Move eDP population to be done at display probe time so that probe deferral cases can be handled effectively. wait_for_hpd_asserted callback is added during drm_dp_aux_init() to ensure eDP's HPD is up before proceeding eDP population. Changes in v3: -- add done_probing callback into devm_of_dp_aux_populate_bus() Signed-off-by: Kuogee Hsieh --- drivers/gpu/drm/msm/dp/dp_aux.c | 25 ++++++++++++ drivers/gpu/drm/msm/dp/dp_display.c | 79 ++++++++++++++++++------------------- 2 files changed, 64 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c index 8fa93c5..79f0c6e 100644 --- a/drivers/gpu/drm/msm/dp/dp_aux.c +++ b/drivers/gpu/drm/msm/dp/dp_aux.c @@ -507,6 +507,21 @@ void dp_aux_unregister(struct drm_dp_aux *dp_aux) drm_dp_aux_unregister(dp_aux); } +static int dp_wait_hpd_asserted(struct drm_dp_aux *dp_aux, + unsigned long wait_us) +{ + int ret; + struct dp_aux_private *aux; + + aux = container_of(dp_aux, struct dp_aux_private, dp_aux); + + pm_runtime_get_sync(aux->dev); + ret = dp_catalog_aux_wait_for_hpd_connect_state(aux->catalog); + pm_runtime_put_sync(aux->dev); + + return ret; +} + struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, bool is_edp) { @@ -530,6 +545,16 @@ struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, aux->catalog = catalog; aux->retry_cnt = 0; + /* + * Use the drm_dp_aux_init() to use the aux adapter + * before registering aux with the DRM device. + */ + aux->dp_aux.name = "dpu_dp_aux"; + aux->dp_aux.dev = dev; + aux->dp_aux.transfer = dp_aux_transfer; + aux->dp_aux.wait_hpd_asserted = dp_wait_hpd_asserted; + drm_dp_aux_init(&aux->dp_aux); + return &aux->dp_aux; } diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b58cb02..886fae5 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -310,8 +310,6 @@ static void dp_display_unbind(struct device *dev, struct device *master, kthread_stop(dp->ev_tsk); - of_dp_aux_depopulate_bus(dp->aux); - dp_power_client_deinit(dp->power); dp_unregister_audio_driver(dev, dp->audio); dp_aux_unregister(dp->aux); @@ -1217,6 +1215,31 @@ static const struct msm_dp_desc *dp_display_get_desc(struct platform_device *pde return NULL; } +static int dp_auxbus_done_probe(struct drm_dp_aux *aux) +{ + int rc; + + rc = component_add(aux->dev, &dp_display_comp_ops); + if (rc) + DRM_ERROR("eDP component add failed, rc=%d\n", rc); + + return rc; +} + +static int dp_display_auxbus_population(struct dp_display_private *dp) +{ + struct device *dev = &dp->pdev->dev; + struct device_node *aux_bus; + int ret = 0; + + aux_bus = of_get_child_by_name(dev->of_node, "aux-bus"); + + if (aux_bus) + ret = devm_of_dp_aux_populate_bus(dp->aux, dp_auxbus_done_probe); + + return ret; +} + static int dp_display_probe(struct platform_device *pdev) { int rc = 0; @@ -1282,10 +1305,16 @@ static int dp_display_probe(struct platform_device *pdev) if (rc) return rc; - rc = component_add(&pdev->dev, &dp_display_comp_ops); - if (rc) { - DRM_ERROR("component add failed, rc=%d\n", rc); - dp_display_deinit_sub_modules(dp); + if (dp->dp_display.is_edp) { + rc = dp_display_auxbus_population(dp); + if (rc) + DRM_ERROR("eDP auxbus population failed, rc=%d\n", rc); + } else { + rc = component_add(&pdev->dev, &dp_display_comp_ops); + if (rc) { + DRM_ERROR("component add failed, rc=%d\n", rc); + dp_display_deinit_sub_modules(dp); + } } return rc; @@ -1296,14 +1325,13 @@ static int dp_display_remove(struct platform_device *pdev) struct dp_display_private *dp = dev_get_dp_display_private(&pdev->dev); component_del(&pdev->dev, &dp_display_comp_ops); - dp_display_deinit_sub_modules(dp); - platform_set_drvdata(pdev, NULL); - pm_runtime_put_sync_suspend(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_disable(&pdev->dev); + dp_display_deinit_sub_modules(dp); + return 0; } @@ -1432,31 +1460,10 @@ void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor) static int dp_display_get_next_bridge(struct msm_dp *dp) { - int rc; + int rc = 0; struct dp_display_private *dp_priv; - struct device_node *aux_bus; - struct device *dev; dp_priv = container_of(dp, struct dp_display_private, dp_display); - dev = &dp_priv->pdev->dev; - aux_bus = of_get_child_by_name(dev->of_node, "aux-bus"); - - if (aux_bus && dp->is_edp) { - /* - * The code below assumes that the panel will finish probing - * by the time devm_of_dp_aux_populate_ep_devices() returns. - * This isn't a great assumption since it will fail if the - * panel driver is probed asynchronously but is the best we - * can do without a bigger driver reorganization. - */ - rc = of_dp_aux_populate_bus(dp_priv->aux, NULL); - of_node_put(aux_bus); - if (rc) - goto error; - } else if (dp->is_edp) { - DRM_ERROR("eDP aux_bus not found\n"); - return -ENODEV; - } /* * External bridges are mandatory for eDP interfaces: one has to @@ -1469,17 +1476,9 @@ static int dp_display_get_next_bridge(struct msm_dp *dp) if (!dp->is_edp && rc == -ENODEV) return 0; - if (!rc) { + if (!rc) dp->next_bridge = dp_priv->parser->next_bridge; - return 0; - } -error: - if (dp->is_edp) { - of_dp_aux_depopulate_bus(dp_priv->aux); - dp_display_host_phy_exit(dp_priv); - dp_display_host_deinit(dp_priv); - } return rc; }