From: Yakir Yang <ykk@rock-chips.com>
To: Sean Paul <seanpaul@chromium.org>
Cc: "Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Inki Dae" <inki.dae@samsung.com>,
"David Airlie" <airlied@linux.ie>,
"Tomeu Vizoso" <tomeu.vizoso@collabora.com>,
"Mika Kahola" <mika.kahola@intel.com>,
"Stéphane Marchesin" <marcheu@chromium.org>,
"Tomasz Figa" <tfiga@chromium.org>,
"Douglas Anderson" <dianders@chromium.org>,
"Thierry Reding" <treding@nvidia.com>,
"Krzysztof Kozlowski" <k.kozlowski@samsung.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Javier Martinez Canillas" <javier@osg.samsung.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v2 2/2] drm/bridge: analogix_dp: detect Sink PSR state after configuring the PSR
Date: Fri, 9 Sep 2016 17:15:37 +0800 [thread overview]
Message-ID: <a0b12086-ea57-2e10-bd25-d1e209bedd1d@rock-chips.com> (raw)
In-Reply-To: <CAOw6vb+apDfnqLtr3TDNxEzKe_kREeabevh4B6Z9wRquLRn6ag@mail.gmail.com>
On 09/08/2016 10:12 PM, Sean Paul wrote:
> On Wed, Sep 7, 2016 at 11:48 PM, Yakir Yang <ykk@rock-chips.com> wrote:
>> Make sure the request PSR state could effect in analogix_dp_send_psr_spd()
>> function, or printing the error Sink PSR state if we failed to effect
>> the request PSR setting.
>>
>
> Let's change to:
>
> Make sure the request PSR state takes effect in analogix_dp_send_psr_spd()
> function, or print the sink PSR error state if we failed to apply the
> requested PSR
> setting.
Done,
>> Signed-off-by: Yakir Yang <ykk@rock-chips.com>
>> ---
>> Changes in v2:
>> - A bunch of good fixes from Sean
>>
>> drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++----
>> drivers/gpu/drm/bridge/analogix/analogix_dp_core.h | 4 ++--
>> drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 25 ++++++++++++++++++++--
>> 3 files changed, 27 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> index 5fe3982..c0ce16a 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> @@ -116,8 +116,7 @@ int analogix_dp_enable_psr(struct device *dev)
>> psr_vsc.DB0 = 0;
>> psr_vsc.DB1 = EDP_VSC_PSR_STATE_ACTIVE | EDP_VSC_PSR_CRC_VALUES_VALID;
>>
>> - analogix_dp_send_psr_spd(dp, &psr_vsc);
>> - return 0;
>> + return analogix_dp_send_psr_spd(dp, &psr_vsc);
>> }
>> EXPORT_SYMBOL_GPL(analogix_dp_enable_psr);
>>
>> @@ -139,8 +138,7 @@ int analogix_dp_disable_psr(struct device *dev)
>> psr_vsc.DB0 = 0;
>> psr_vsc.DB1 = 0;
>>
>> - analogix_dp_send_psr_spd(dp, &psr_vsc);
>> - return 0;
>> + return analogix_dp_send_psr_spd(dp, &psr_vsc);
>> }
>> EXPORT_SYMBOL_GPL(analogix_dp_disable_psr);
>>
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
>> index a15f076..6c07a50 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
>> @@ -247,8 +247,8 @@ void analogix_dp_config_video_slave_mode(struct analogix_dp_device *dp);
>> void analogix_dp_enable_scrambling(struct analogix_dp_device *dp);
>> void analogix_dp_disable_scrambling(struct analogix_dp_device *dp);
>> void analogix_dp_enable_psr_crc(struct analogix_dp_device *dp);
>> -void analogix_dp_send_psr_spd(struct analogix_dp_device *dp,
>> - struct edp_vsc_psr *vsc);
>> +int analogix_dp_send_psr_spd(struct analogix_dp_device *dp,
>> + struct edp_vsc_psr *vsc);
>> ssize_t analogix_dp_transfer(struct analogix_dp_device *dp,
>> struct drm_dp_aux_msg *msg);
>> #endif /* _ANALOGIX_DP_CORE_H */
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
>> index a4d17b8..09d703b 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
>> @@ -1004,10 +1004,12 @@ void analogix_dp_enable_psr_crc(struct analogix_dp_device *dp)
>> writel(PSR_VID_CRC_ENABLE, dp->reg_base + ANALOGIX_DP_CRC_CON);
>> }
>>
>> -void analogix_dp_send_psr_spd(struct analogix_dp_device *dp,
>> - struct edp_vsc_psr *vsc)
>> +int analogix_dp_send_psr_spd(struct analogix_dp_device *dp,
>> + struct edp_vsc_psr *vsc)
>> {
>> + unsigned long timeout;
>> unsigned int val;
>> + u8 sink;
>>
>> /* don't send info frame */
>> val = readl(dp->reg_base + ANALOGIX_DP_PKT_SEND_CTL);
>> @@ -1048,6 +1050,25 @@ void analogix_dp_send_psr_spd(struct analogix_dp_device *dp,
>> val = readl(dp->reg_base + ANALOGIX_DP_PKT_SEND_CTL);
>> val |= IF_EN;
>> writel(val, dp->reg_base + ANALOGIX_DP_PKT_SEND_CTL);
>> +
>> + timeout = jiffies + msecs_to_jiffies(DP_TIMEOUT_LOOP_COUNT);
> Mismatched units here. DP_TIMEOUT_LOOP_COUNT is defined as number of
> retries, whereas you're using it as number of ms. Fortunately, the
> retry number is so high that this works out :)
>
> In a separate patch preceding this one, can you change
> DP_TIMEOUT_LOOP_COUNT to DP_TIMEOUT_LOOP_MS and alter the other
> timeout loops to use time_before() like this one instead of blindly
> looping 100 times? After that, you can use DP_TIMEOUT_LOOP_MS here.
Done, and after do some experiments, I found we need to set the timeout
to 300ms. Cause in some case we would take about 290ms here to get the
right psr state.
>> + while (time_before(jiffies, timeout)) {
>> + val = drm_dp_dpcd_readb(&dp->aux, DP_PSR_STATUS, &sink);
>> + if (val != 1) {
>> + dev_err(dp->dev, "PSR_STATUS read failed ret=%d", val);
>> + return val;
> Ok, since this is my snippet this comment is my fault, and I apologize
> for that :). However, this could return 0. If drm_dp_dpcd_readb
> returns 0, you probably want to retry (same as -EBUSY).
done, just return -EBUSY
>
>> + }
>> +
>> + if (vsc->DB1 && sink == DP_PSR_SINK_ACTIVE_RFB ||
>> + !vsc->DB1 && sink == DP_PSR_SINK_INACTIVE)
>> + break;
>> +
>> + usleep_range(1000, 1500);
>> + }
>> +
>> + dev_warn(dp->dev, "Failed to effect PSR: %x", sink);
> Nit: I think you want to say "PSR failed to take effect" or "Failed to
> apply PSR"
Done
- Yakir
> Sean
>
>> +
>> + return -ETIMEDOUT;
>> }
>>
>> ssize_t analogix_dp_transfer(struct analogix_dp_device *dp,
>> --
>> 1.9.1
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
next prev parent reply other threads:[~2016-09-09 9:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-08 3:48 [PATCH v2 1/2] drm/bridge: analogix_dp: Remove duplicated code v2 Yakir Yang
2016-09-08 3:48 ` [PATCH v2 2/2] drm/bridge: analogix_dp: detect Sink PSR state after configuring the PSR Yakir Yang
2016-09-08 14:12 ` Sean Paul
2016-09-09 9:15 ` Yakir Yang [this message]
2016-09-09 9:44 ` [PATCH v3 2/3] drm/bridge: analogix_dp: use jiffies to simulate timeout loop Yakir Yang
2016-09-12 13:51 ` Sean Paul
2016-09-20 2:18 ` Yakir Yang
2016-09-09 9:45 ` [PATCH v3 3/3] drm/bridge: analogix_dp: detect Sink PSR state after configuring the PSR Yakir Yang
2016-09-12 13:52 ` Sean Paul
2016-09-20 2:22 ` Yakir Yang
2016-09-08 13:50 ` [PATCH v2 1/2] drm/bridge: analogix_dp: Remove duplicated code v2 Sean Paul
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=a0b12086-ea57-2e10-bd25-d1e209bedd1d@rock-chips.com \
--to=ykk@rock-chips.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=inki.dae@samsung.com \
--cc=javier@osg.samsung.com \
--cc=jingoohan1@gmail.com \
--cc=k.kozlowski@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=marcheu@chromium.org \
--cc=mika.kahola@intel.com \
--cc=seanpaul@chromium.org \
--cc=tfiga@chromium.org \
--cc=tomeu.vizoso@collabora.com \
--cc=treding@nvidia.com \
/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).