linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sankeerth Billakanti (QUIC)" <quic_sbillaka@quicinc.com>
To: "dmitry.baryshkov@linaro.org" <dmitry.baryshkov@linaro.org>,
	"Vinod Polimera (QUIC)" <quic_vpolimer@quicinc.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"freedreno@lists.freedesktop.org"
	<freedreno@lists.freedesktop.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"dianders@chromium.org" <dianders@chromium.org>,
	"swboyd@chromium.org" <swboyd@chromium.org>,
	"Kalyan Thota (QUIC)" <quic_kalyant@quicinc.com>,
	"Sankeerth Billakanti (QUIC)" <quic_sbillaka@quicinc.com>,
	"Vishnuvardhan Prodduturi (QUIC)" <quic_vproddut@quicinc.com>,
	"Aravind Venkateswaran (QUIC)" <quic_aravindh@quicinc.com>,
	"Abhinav Kumar (QUIC)" <quic_abhinavk@quicinc.com>,
	"Kuogee Hsieh (QUIC)" <quic_khsieh@quicinc.com>
Subject: RE: [v3 3/5] drm/bridge: add psr support during panel bridge enable & disable sequence
Date: Wed, 29 Jun 2022 13:48:31 +0000	[thread overview]
Message-ID: <MW4PR02MB71863059F56CA1A32C4E1655E1BB9@MW4PR02MB7186.namprd02.prod.outlook.com> (raw)
In-Reply-To: <47324fb3-c0d1-4839-8db1-c819c7389de7@linaro.org>

Hi Dmitry,

>On 21/06/2022 13:53, Vinod Polimera wrote:
>> This change avoids panel prepare/unprepare based on self-refresh
>> state.
>>
>> Signed-off-by: Sankeerth Billakanti <quic_sbillaka@quicinc.com>
>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>> Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com>
>> ---
>>   drivers/gpu/drm/bridge/panel.c | 102
>+++++++++++++++++++++++++++++++++++++++--
>>   1 file changed, 98 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/panel.c
>> b/drivers/gpu/drm/bridge/panel.c index 59a3496..6b09ae0 100644
>> --- a/drivers/gpu/drm/bridge/panel.c
>> +++ b/drivers/gpu/drm/bridge/panel.c
>> @@ -41,6 +41,40 @@ static int panel_bridge_connector_get_modes(struct
>drm_connector *connector)
>>   	return drm_panel_get_modes(panel_bridge->panel, connector);
>>   }
>>
>> +static struct drm_crtc *bridge_drm_get_old_connector_crtc(struct
>drm_encoder *encoder,
>> +							struct
>drm_atomic_state *state) {
>> +	struct drm_connector *connector;
>> +	struct drm_connector_state *conn_state;
>> +
>> +	connector = drm_atomic_get_old_connector_for_encoder(state,
>encoder);
>> +	if (!connector)
>> +		return NULL;
>> +
>> +	conn_state = drm_atomic_get_old_connector_state(state,
>connector);
>> +	if (!conn_state)
>> +		return NULL;
>> +
>> +	return conn_state->crtc;
>> +}
>> +
>> +static struct drm_crtc *bridge_drm_get_new_connector_crtc(struct
>drm_encoder *encoder,
>> +							struct
>drm_atomic_state *state) {
>> +	struct drm_connector *connector;
>> +	struct drm_connector_state *conn_state;
>> +
>> +	connector = drm_atomic_get_new_connector_for_encoder(state,
>encoder);
>> +	if (!connector)
>> +		return NULL;
>> +
>> +	conn_state = drm_atomic_get_new_connector_state(state,
>connector);
>> +	if (!conn_state)
>> +		return NULL;
>> +
>> +	return conn_state->crtc;
>> +}
>
>As I wrote earlier, this should become generic drm helpers.
>

Yes, will move it.

>> +
>>   static const struct drm_connector_helper_funcs
>>   panel_bridge_connector_helper_funcs = {
>>   	.get_modes = panel_bridge_connector_get_modes, @@ -108,30
>+142,90
>> @@ static void panel_bridge_detach(struct drm_bridge *bridge)
>>   		drm_connector_cleanup(connector);
>>   }
>>
>> -static void panel_bridge_atomic_pre_enable(struct drm_bridge *bridge)
>> +static void panel_bridge_atomic_pre_enable(struct drm_bridge *bridge,
>> +					struct drm_bridge_state
>*old_bridge_state)
>
>This must be a part of the previous patch?
>

Yes, it should be moved to that patch.

>>   {
>>   	struct panel_bridge *panel_bridge =
>> drm_bridge_to_panel_bridge(bridge);
>> +	struct drm_atomic_state *old_state = old_bridge_state->base.state;
>> +	struct drm_encoder *encoder = bridge->encoder;
>> +	struct drm_crtc *crtc;
>> +	struct drm_crtc_state *old_crtc_state;
>> +
>> +	crtc = bridge_drm_get_new_connector_crtc(encoder, old_state);
>> +	if (!crtc)
>> +		return;
>
>Why? And why do you ask for the new crtc from the old state?
>

If the previous bridge disable and post_disable calls were issued just to enter psr,
then the panel power and backlight will still be on.

We need to know the psr status of the old state of the crtc to decide whether to
enable the panel power or just early return.

old_state is the atomic_state object. Will change the variable name to atomic_state.

>> +
>> +	old_crtc_state = drm_atomic_get_old_crtc_state(old_state, crtc);
>> +
>> +	/* Don't touch the panel if we're coming back from self refresh state
>*/
>> +	if (old_crtc_state && old_crtc_state->self_refresh_active)
>> +		return;
>>
>>   	drm_panel_prepare(panel_bridge->panel);
>>   }
>>
>> -static void panel_bridge_atomic_enable(struct drm_bridge *bridge)
>> +static void panel_bridge_atomic_enable(struct drm_bridge *bridge,
>> +					struct drm_bridge_state
>*old_bridge_state)
>>   {
>>   	struct panel_bridge *panel_bridge =
>> drm_bridge_to_panel_bridge(bridge);
>> +	struct drm_atomic_state *old_state = old_bridge_state->base.state;
>> +	struct drm_encoder *encoder = bridge->encoder;
>> +	struct drm_crtc *crtc;
>> +	struct drm_crtc_state *old_crtc_state;
>> +
>> +	crtc = bridge_drm_get_new_connector_crtc(encoder, old_state);
>> +	if (!crtc)
>> +		return;
>> +
>> +	old_crtc_state = drm_atomic_get_old_crtc_state(old_state, crtc);
>> +
>> +	/* Don't touch the panel if we're coming back from self refresh state
>*/
>> +	if (old_crtc_state && old_crtc_state->self_refresh_active)
>> +		return;
>>
>>   	drm_panel_enable(panel_bridge->panel);
>>   }
>>
>> -static void panel_bridge_atomic_disable(struct drm_bridge *bridge)
>> +static void panel_bridge_atomic_disable(struct drm_bridge *bridge,
>> +					struct drm_bridge_state
>*old_bridge_state)
>>   {
>>   	struct panel_bridge *panel_bridge =
>> drm_bridge_to_panel_bridge(bridge);
>> +	struct drm_atomic_state *old_state = old_bridge_state->base.state;
>> +	struct drm_encoder *encoder = bridge->encoder;
>> +	struct drm_crtc *crtc;
>> +	struct drm_crtc_state *new_crtc_state;
>> +
>> +	crtc = bridge_drm_get_old_connector_crtc(encoder, old_state);
>> +	if (!crtc)
>> +		return;
>> +
>> +	new_crtc_state = drm_atomic_get_new_crtc_state(old_state, crtc);
>
>This doesn't sound right too.
>

There is a risk of crtc being deallocated if the disable call came during screen off.
To be on safer side, we are getting the old crtc and check for the appropriate crtc state.
I believe the old_state variable name is causing a confusion. I will change the name to
atomic_state.

>> +
>> +	/* Don't do a full disable on PSR transitions if new state is self refresh
>state */
>> +	if (new_crtc_state && new_crtc_state->self_refresh_active)
>> +		return;
>>
>>   	drm_panel_disable(panel_bridge->panel);
>>   }
>>
>> -static void panel_bridge_atomic_post_disable(struct drm_bridge
>> *bridge)
>> +static void panel_bridge_atomic_post_disable(struct drm_bridge *bridge,
>> +					struct drm_bridge_state
>*old_bridge_state)
>>   {
>>   	struct panel_bridge *panel_bridge =
>> drm_bridge_to_panel_bridge(bridge);
>> +	struct drm_atomic_state *old_state = old_bridge_state->base.state;
>> +	struct drm_encoder *encoder = bridge->encoder;
>> +	struct drm_crtc *crtc;
>> +	struct drm_crtc_state *new_crtc_state;
>> +
>> +	crtc = bridge_drm_get_old_connector_crtc(encoder, old_state);
>> +	if (!crtc)
>> +		return;
>> +
>> +	new_crtc_state = drm_atomic_get_new_crtc_state(old_state, crtc);
>> +
>> +	/* Don't do unprepare on PSR transitions if new state is self refresh
>state */
>> +	if (new_crtc_state && new_crtc_state->self_refresh_active)
>> +		return;
>>
>>   	drm_panel_unprepare(panel_bridge->panel);
>>   }
>
>
>--
>With best wishes
>Dmitry

Thank you,
Sankeerth

  reply	other threads:[~2022-06-29 13:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 10:53 [v3 0/5] Add PSR support for eDP Vinod Polimera
2022-06-21 10:53 ` [v3 1/5] drm/msm/dp: Add basic " Vinod Polimera
2022-06-21 18:53   ` Dmitry Baryshkov
2022-06-29 13:38     ` Sankeerth Billakanti (QUIC)
2022-06-21 10:53 ` [v3 2/5] drm/bridge: use atomic enable/disable callbacks for panel bridge functions Vinod Polimera
2022-06-21 18:54   ` Dmitry Baryshkov
2022-06-21 18:56     ` Dmitry Baryshkov
2022-06-21 10:53 ` [v3 3/5] drm/bridge: add psr support during panel bridge enable & disable sequence Vinod Polimera
2022-06-21 18:59   ` Dmitry Baryshkov
2022-06-29 13:48     ` Sankeerth Billakanti (QUIC) [this message]
2022-06-21 10:53 ` [v3 4/5] drm/msm/disp/dpu1: use atomic enable/disable callbacks for encoder functions Vinod Polimera
2022-06-21 19:00   ` Dmitry Baryshkov
2022-06-21 10:53 ` [v3 5/5] drm/msm/disp/dpu1: add PSR support for eDP interface in dpu driver Vinod Polimera
2022-06-21 19:09   ` Dmitry Baryshkov
2022-06-22 21:21   ` kernel test robot
2022-06-21 18:40 ` [v3 0/5] Add PSR support for eDP 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=MW4PR02MB71863059F56CA1A32C4E1655E1BB9@MW4PR02MB7186.namprd02.prod.outlook.com \
    --to=quic_sbillaka@quicinc.com \
    --cc=devicetree@vger.kernel.org \
    --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=quic_abhinavk@quicinc.com \
    --cc=quic_aravindh@quicinc.com \
    --cc=quic_kalyant@quicinc.com \
    --cc=quic_khsieh@quicinc.com \
    --cc=quic_vpolimer@quicinc.com \
    --cc=quic_vproddut@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=swboyd@chromium.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;
as well as URLs for NNTP newsgroup(s).