Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32580472rwd; Fri, 7 Jul 2023 17:01:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlEENyUULWsNbLgzUWv6XjXtfegBx63MO8qsTHinJthWsSv8aE/qes9WWxTLIfj/rJJP5PDK X-Received: by 2002:a05:6402:549:b0:51e:ec0:fd84 with SMTP id i9-20020a056402054900b0051e0ec0fd84mr4160074edx.40.1688774495936; Fri, 07 Jul 2023 17:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688774495; cv=none; d=google.com; s=arc-20160816; b=rglmXm1qPbMR45JQYlSedtGdPs6yUXM5oT0VxcozoGQojSurrSGlncF3XEIQy5Cpfm duFpb43mZbTU8QCdtqa9V4a38hSeC5Jw4noIXljO9LGECgpe5OdK8gBGd6MKNTy819Hc +ckvhpA87IsMgEn9plVCGllT8LEn/FpJEtdkxGv7OefEq2tfpLTZP/iTxpPCyjUGpGc5 DMWZ8IdqvzNrOdkzRsKCYu05+/2peJdl3jgTSR1UTy7oTAz94zWwcMAXaEeMN7/2/ZVZ qXWmlJuDMjec9aUEwmsCnAc2H/lOS4pMrlVgjGbF9so90UXtnJpHeuumVkvZTRBQOBLM tAsQ== 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=ylCRsELIkSO/B+Vi8xmHnIIicn3kFn6CvvT2dhwEhHc=; fh=iLBDXtppA26XbUzg3OoIf+Xf8T8VNt57htQsV5BwKSs=; b=jMbUxctWNEqpIEKbe8Advs+AWfbx41lExK+BFfydvJqqRHaoA7lHzGoioGsffyuokl L3LPOQTGyBxy3+9+T+uE03YG2dGg1I4fqXorsZ5gOXxxLJzNM92RGGBgqgf/8PvKoGAi 2eCN9D+aarXlPgp65IX1X964eqQCEcdWIO7islEkVHGJ5jRSMGVVebD8TVRBCtWgrQZM EMbNf7Wj2Pv0Kpe9BESrjfwUBGymLb4rjHvvRv2iuShDqU4jy2wEwWVO8wgHLDQO+Q9f NovGCSjO5ICjlCldQfdUVrzDJed4TYo1VV4m0DnQx2pJJByAMzmY6ebuFhA3hCMEs9+7 pFCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FT+GoO2N; 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 b9-20020aa7d489000000b0051dd2d2cfb8si3008227edr.644.2023.07.07.17.01.12; Fri, 07 Jul 2023 17:01:35 -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=FT+GoO2N; 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 S232404AbjGGXxT (ORCPT + 99 others); Fri, 7 Jul 2023 19:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231845AbjGGXxJ (ORCPT ); Fri, 7 Jul 2023 19:53:09 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 111C42115; Fri, 7 Jul 2023 16:53:08 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 367NeIr2014616; Fri, 7 Jul 2023 23:52:59 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=ylCRsELIkSO/B+Vi8xmHnIIicn3kFn6CvvT2dhwEhHc=; b=FT+GoO2NihvMlCBDBSjns/WJ4sILaZ6PSQBSxoV4BUNwGtYXnQuoMh44ZEQhXDl+0YXm wZVdIXas+mc218Px57ADp22dFDA5S89E3NhTePwZR3rpDQXo9WhenOKJtChMUjeUi/O0 gnVlOK42sWPWyWZtOExRBLGmeWW2UxkTPmp6QXWPg1/BvgQVsTzLOVsasUYe6hhP2BE0 1OnAnbDtzgyyKX2Xgej4u2dNYGOp548oXd/EBIu7QXYiV0vios6cGpYCT+I5Jmb3bIGS kDoCEvmELG9klF9iEJHe/mfz8JhKeyG6yQaJ+POBJmw8t7B0fRQ/lK6nBTJ78S/Zl1QT HA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rpfyw9tqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Jul 2023 23:52:59 +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 367NqwN3028905 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 7 Jul 2023 23:52:58 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.30; Fri, 7 Jul 2023 16:52:57 -0700 From: Kuogee Hsieh To: , , , , , , , , , , CC: Kuogee Hsieh , , , , , , , Subject: [PATCH v1 5/5] drm/msm/dp: move of_dp_aux_populate_bus() to probe for eDP Date: Fri, 7 Jul 2023 16:52:23 -0700 Message-ID: <1688773943-3887-6-git-send-email-quic_khsieh@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688773943-3887-1-git-send-email-quic_khsieh@quicinc.com> References: <1688773943-3887-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: PDap4BDcQG3Dy6E9IrlLTeW9-D4eBcDR X-Proofpoint-ORIG-GUID: PDap4BDcQG3Dy6E9IrlLTeW9-D4eBcDR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-07_14,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307070217 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 Move of_dp_aux_populate_bus() to dp_display_probe() for eDP from dp_display_bind() so that probe deferral cases can be handled effectively 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, 65 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c index c592064..c1baffb 100644 --- a/drivers/gpu/drm/msm/dp/dp_aux.c +++ b/drivers/gpu/drm/msm/dp/dp_aux.c @@ -505,6 +505,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) { @@ -528,6 +543,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 185f1eb..7ed4bea 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -302,10 +302,6 @@ static int dp_display_bind(struct device *dev, struct device *master, goto end; } - pm_runtime_enable(dev); - pm_runtime_set_autosuspend_delay(dev, 1000); - pm_runtime_use_autosuspend(dev); - return 0; end: return rc; @@ -322,8 +318,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); @@ -1245,6 +1239,29 @@ static const struct msm_dp_desc *dp_display_get_desc(struct platform_device *pde return NULL; } +static void of_dp_aux_depopulate_bus_void(void *data) +{ + of_dp_aux_depopulate_bus(data); +} + +static int dp_display_auxbus_emulation(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, NULL); + + devm_add_action_or_reset(dev, of_dp_aux_depopulate_bus_void, + dp->aux); + } + + return ret; +} + static int dp_display_probe(struct platform_device *pdev) { int rc = 0; @@ -1290,8 +1307,18 @@ static int dp_display_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &dp->dp_display); + pm_runtime_enable(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); + pm_runtime_use_autosuspend(&pdev->dev); + dp_display_request_irq(dp); + if (dp->dp_display.is_edp) { + rc = dp_display_auxbus_emulation(dp); + if (rc) + DRM_ERROR("eDP aux-bus emulation failed, rc=%d\n", rc); + } + rc = component_add(&pdev->dev, &dp_display_comp_ops); if (rc) { DRM_ERROR("component add failed, rc=%d\n", rc); @@ -1306,11 +1333,14 @@ 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_dont_use_autosuspend(&pdev->dev); + pm_runtime_disable(&pdev->dev); pm_runtime_put_sync_suspend(&pdev->dev); + dp_display_deinit_sub_modules(dp); + return 0; } @@ -1514,31 +1544,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 @@ -1551,17 +1560,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; } -- 2.7.4