From: Kuogee Hsieh <quic_khsieh@quicinc.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: <freedreno@lists.freedesktop.org>, <quic_sbillaka@quicinc.com>,
<quic_abhinavk@quicinc.com>, <airlied@gmail.com>,
<linux-arm-msm@vger.kernel.org>, <robdclark@gmail.com>,
<dri-devel@lists.freedesktop.org>, <dianders@chromium.org>,
<vkoul@kernel.org>, <agross@kernel.org>, <daniel@ffwll.ch>,
<marijn.suijten@somainline.org>, <dmitry.baryshkov@linaro.org>,
<quic_jesszhan@quicinc.com>, <swboyd@chromium.org>,
<sean@poorly.run>, <linux-kernel@vger.kernel.org>
Subject: Re: [Freedreno] [PATCH v1 2/5] drm/msm/dp: incorporate pm_runtime framework into DP driver
Date: Tue, 25 Jul 2023 15:25:48 -0700 [thread overview]
Message-ID: <44299d05-d411-e9c4-7b96-84efb28d47c9@quicinc.com> (raw)
In-Reply-To: <0ac305d2-d0a9-cdfb-9be8-243402d865e7@quicinc.com>
On 7/10/2023 9:22 AM, Kuogee Hsieh wrote:
>
> On 7/8/2023 7:52 PM, Bjorn Andersson wrote:
>> On Fri, Jul 07, 2023 at 04:52:20PM -0700, Kuogee Hsieh wrote:
>>> Incorporating pm runtime framework into DP driver so that power
>>> and clock resource handling can be centralized allowing easier
>>> control of these resources in preparation of registering aux bus
>>> uring probe.
>>>
>>> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
>>> ---
>>> drivers/gpu/drm/msm/dp/dp_aux.c | 3 ++
>>> drivers/gpu/drm/msm/dp/dp_display.c | 75
>>> +++++++++++++++++++++++++++++--------
>>> 2 files changed, 63 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c
>>> b/drivers/gpu/drm/msm/dp/dp_aux.c
>>> index 8e3b677..c592064 100644
>>> --- a/drivers/gpu/drm/msm/dp/dp_aux.c
>>> +++ b/drivers/gpu/drm/msm/dp/dp_aux.c
>>> @@ -291,6 +291,7 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux
>>> *dp_aux,
>>> return -EINVAL;
>>> }
>>> + pm_runtime_get_sync(dp_aux->dev);
>>> mutex_lock(&aux->mutex);
>>> if (!aux->initted) {
>>> ret = -EIO;
>>> @@ -364,6 +365,8 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux
>>> *dp_aux,
>>> exit:
>>> mutex_unlock(&aux->mutex);
>>> + pm_runtime_mark_last_busy(dp_aux->dev);
>>> + pm_runtime_put_autosuspend(dp_aux->dev);
>>> return ret;
>>> }
>>> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c
>>> b/drivers/gpu/drm/msm/dp/dp_display.c
>>> index 76f1395..2c5706a 100644
>>> --- a/drivers/gpu/drm/msm/dp/dp_display.c
>>> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
>>> @@ -309,6 +309,10 @@ 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;
>>> @@ -320,9 +324,8 @@ static void dp_display_unbind(struct device
>>> *dev, struct device *master,
>>> struct dp_display_private *dp = dev_get_dp_display_private(dev);
>>> struct msm_drm_private *priv = dev_get_drvdata(master);
>>> - /* disable all HPD interrupts */
>>> - if (dp->core_initialized)
>>> - dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK,
>>> false);
>>> + pm_runtime_dont_use_autosuspend(dev);
>>> + pm_runtime_disable(dev);
>>> kthread_stop(dp->ev_tsk);
>>> @@ -466,10 +469,12 @@ static void dp_display_host_init(struct
>>> dp_display_private *dp)
>>> dp->dp_display.connector_type, dp->core_initialized,
>>> dp->phy_initialized);
>>> - dp_power_init(dp->power);
>>> - dp_ctrl_reset_irq_ctrl(dp->ctrl, true);
>>> - dp_aux_init(dp->aux);
>>> - dp->core_initialized = true;
>>> + if (!dp->core_initialized) {
>>> + dp_power_init(dp->power);
>>> + dp_ctrl_reset_irq_ctrl(dp->ctrl, true);
>>> + dp_aux_init(dp->aux);
>>> + dp->core_initialized = true;
>> There are two cases that queries core_initialized, both of those are
>> done to avoid accessing the DP block without it first being powered up.
>> With the introduction of runtime PM, it seems reasonable to just power
>> up the block in those two code paths (and remove the variable).
>>
>>> + }
>>> }
>>> static void dp_display_host_deinit(struct dp_display_private *dp)
>>> @@ -478,10 +483,12 @@ static void dp_display_host_deinit(struct
>>> dp_display_private *dp)
>>> dp->dp_display.connector_type, dp->core_initialized,
>>> dp->phy_initialized);
>>> - dp_ctrl_reset_irq_ctrl(dp->ctrl, false);
>>> - dp_aux_deinit(dp->aux);
>>> - dp_power_deinit(dp->power);
>>> - dp->core_initialized = false;
>>> + if (dp->core_initialized) {
>>> + dp_ctrl_reset_irq_ctrl(dp->ctrl, false);
>>> + dp_aux_deinit(dp->aux);
>>> + dp_power_deinit(dp->power);
>>> + dp->core_initialized = false;
>>> + }
>>> }
>>> static int dp_display_usbpd_configure_cb(struct device *dev)
>>> @@ -1304,6 +1311,39 @@ static int dp_display_remove(struct
>>> platform_device *pdev)
>>> dp_display_deinit_sub_modules(dp);
>>> platform_set_drvdata(pdev, NULL);
>>> + pm_runtime_put_sync_suspend(&pdev->dev);
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static int dp_pm_runtime_suspend(struct device *dev)
>>> +{
>>> + struct platform_device *pdev = to_platform_device(dev);
>>> + struct msm_dp *dp_display = platform_get_drvdata(pdev);
>> platform_get_drvdata() is a wrapper for dev_get_drvdata(&pdev->dev), so
>> there's no need to resolve the platform_device first...
>>
>>> + struct dp_display_private *dp;
>>> +
>>> + dp = container_of(dp_display, struct dp_display_private,
>>> dp_display);
>>> +
>>> + dp_display_host_phy_exit(dp);
>>> + dp_catalog_ctrl_hpd_enable(dp->catalog);
>>> + dp_display_host_deinit(dp);
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static int dp_pm_runtime_resume(struct device *dev)
>>> +{
>>> + struct platform_device *pdev = to_platform_device(dev);
>>> + struct msm_dp *dp_display = platform_get_drvdata(pdev);
>>> + struct dp_display_private *dp;
>>> +
>>> + dp = container_of(dp_display, struct dp_display_private,
>>> dp_display);
>>> +
>>> + dp_display_host_init(dp);
>>> + if (dp_display->is_edp) {
>>> + dp_catalog_ctrl_hpd_enable(dp->catalog);
>>> + dp_display_host_phy_init(dp);
>>> + }
>>> return 0;
>>> }
>>> @@ -1409,6 +1449,7 @@ static int dp_pm_suspend(struct device *dev)
>>> }
>>> static const struct dev_pm_ops dp_pm_ops = {
>>> + SET_RUNTIME_PM_OPS(dp_pm_runtime_suspend, dp_pm_runtime_resume,
>>> NULL)
>>> .suspend = dp_pm_suspend,
>>> .resume = dp_pm_resume,
>>> };
>>> @@ -1493,10 +1534,6 @@ static int dp_display_get_next_bridge(struct
>>> msm_dp *dp)
>>> aux_bus = of_get_child_by_name(dev->of_node, "aux-bus");
>>> if (aux_bus && dp->is_edp) {
>>> - dp_display_host_init(dp_priv);
>>> - dp_catalog_ctrl_hpd_enable(dp_priv->catalog);
>>> - dp_display_host_phy_init(dp_priv);
>> I'm probably just missing it, but how do we get here with the host
>> powered up and the phy initialized?
>
> if (!dp->core_initialized) is at dp_display_host_init()
>
>>
>>> -
>>> /*
>>> * The code below assumes that the panel will finish probing
>>> * by the time devm_of_dp_aux_populate_ep_devices() returns.
>>> @@ -1604,6 +1641,7 @@ void dp_bridge_atomic_enable(struct drm_bridge
>>> *drm_bridge,
>>> dp_hpd_plug_handle(dp_display, 0);
>>> mutex_lock(&dp_display->event_mutex);
>>> + pm_runtime_get_sync(&dp_display->pdev->dev);
>>> state = dp_display->hpd_state;
>>> if (state != ST_DISPLAY_OFF && state != ST_MAINLINK_READY) {
>>> @@ -1684,6 +1722,8 @@ void dp_bridge_atomic_post_disable(struct
>>> drm_bridge *drm_bridge,
>>> }
>>> drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type);
>>> +
>>> + pm_runtime_put_sync(&dp_display->pdev->dev);
>>> mutex_unlock(&dp_display->event_mutex);
>>> }
>>> @@ -1723,6 +1763,8 @@ void dp_bridge_hpd_enable(struct drm_bridge
>>> *bridge)
>>> struct dp_display_private *dp = container_of(dp_display,
>>> struct dp_display_private, dp_display);
>>> mutex_lock(&dp->event_mutex);
>>> + pm_runtime_get_sync(&dp->pdev->dev);
>>> +
>>> dp_catalog_ctrl_hpd_enable(dp->catalog);
>>> /* enable HDP interrupts */
>>> @@ -1744,6 +1786,9 @@ void dp_bridge_hpd_disable(struct drm_bridge
>>> *bridge)
>>> dp_catalog_ctrl_hpd_disable(dp->catalog);
>>> dp_display->internal_hpd = false;
>>> +
>>> + pm_runtime_mark_last_busy(&dp->pdev->dev);
>>> + pm_runtime_put_autosuspend(&dp->pdev->dev);
>>> mutex_unlock(&dp->event_mutex);
>>> }
>> The runtime_get/put in dp_bridge_hpd_enable() and disable matches my
>> expectations. But in the case that we have an external HPD source, where
>> will the power be turned on?
>>
>> Note that you can test this on your device by routing the HPD GPIO to a
>> display-connector instance and wiring this to the DP node. In the same
>> way it's done here:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/qcom/sa8295p-adp.dts#n28
>>
at sc7280, gpio-47 has function 2 as dp-hot-plug pin. but it does not
has function for general purpose pin.
Just curious, to work with external HPD source,
1) which DRM_BRIDGE_OP_xxx should be used for bridge->ops?
2) are both .hpd_enable and .hpd_disable have to be populated?
>>
>> Regards,
>> Bjorn
>>
>>> --
>>> 2.7.4
>>>
next prev parent reply other threads:[~2023-07-26 0:05 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 23:52 [PATCH v1 0/5] incorporate pm runtime framework and eDP clean up Kuogee Hsieh
2023-07-07 23:52 ` [PATCH v1 1/5] drm/msm/dp: remove pm_runtime_xxx() from dp_power.c Kuogee Hsieh
2023-07-08 0:06 ` Dmitry Baryshkov
2023-07-09 17:21 ` [Freedreno] " Abhinav Kumar
2023-07-09 18:00 ` Dmitry Baryshkov
2023-07-09 20:32 ` Abhinav Kumar
2023-07-10 17:25 ` Kuogee Hsieh
2023-07-10 18:00 ` Dmitry Baryshkov
2023-07-09 2:34 ` Bjorn Andersson
2023-07-09 17:26 ` Abhinav Kumar
2023-07-07 23:52 ` [PATCH v1 2/5] drm/msm/dp: incorporate pm_runtime framework into DP driver Kuogee Hsieh
2023-07-08 0:04 ` Dmitry Baryshkov
2023-07-10 16:18 ` Kuogee Hsieh
2023-07-10 18:09 ` Dmitry Baryshkov
2023-07-17 21:39 ` Kuogee Hsieh
2023-07-09 2:52 ` Bjorn Andersson
2023-07-10 16:22 ` Kuogee Hsieh
2023-07-25 22:25 ` Kuogee Hsieh [this message]
2023-07-25 22:33 ` [Freedreno] " Dmitry Baryshkov
2023-07-25 23:26 ` Kuogee Hsieh
2023-07-25 23:28 ` Dmitry Baryshkov
2023-07-07 23:52 ` [PATCH v1 3/5] drm/msm/dp: delete EV_HPD_INIT_SETUP Kuogee Hsieh
2023-07-08 0:07 ` Dmitry Baryshkov
2023-07-08 0:34 ` Dmitry Baryshkov
2023-07-10 16:52 ` Kuogee Hsieh
2023-07-10 18:15 ` Dmitry Baryshkov
2023-07-07 23:52 ` [PATCH v1 4/5] drm/msm/dp: move relevant dp initialization code from bind() to probe() Kuogee Hsieh
2023-07-08 0:11 ` Dmitry Baryshkov
2023-07-10 16:57 ` Kuogee Hsieh
2023-07-10 18:13 ` Dmitry Baryshkov
2023-07-17 17:16 ` Kuogee Hsieh
2023-07-17 17:22 ` Dmitry Baryshkov
2023-07-17 20:38 ` Kuogee Hsieh
2023-07-09 3:09 ` Bjorn Andersson
2023-07-07 23:52 ` [PATCH v1 5/5] drm/msm/dp: move of_dp_aux_populate_bus() to probe for eDP Kuogee Hsieh
2023-07-08 0:32 ` Dmitry Baryshkov
[not found] ` <2278c46c-cb2c-2842-ab20-e6a334fe002b@quicinc.com>
2023-07-10 18:24 ` Dmitry Baryshkov
2023-07-20 20:27 ` Kuogee Hsieh
2023-07-20 22:19 ` Dmitry Baryshkov
2023-07-08 0:38 ` [PATCH v1 0/5] incorporate pm runtime framework and eDP clean up Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44299d05-d411-e9c4-7b96-84efb28d47c9@quicinc.com \
--to=quic_khsieh@quicinc.com \
--cc=agross@kernel.org \
--cc=airlied@gmail.com \
--cc=andersson@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_jesszhan@quicinc.com \
--cc=quic_sbillaka@quicinc.com \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
--cc=swboyd@chromium.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®