This is the 2nd four patches from my RFC series ("drm/dp: Improvements for DP AUX channel") [1]. I've broken the series in two so we can make progress on the two halves separately.
v2 of this series changes to add wait_hpd_asserted() instead of is_hpd_asserted(). This allows us to move the extra delay needed for ps8640 into the ps8640 driver itself.
The idea for this series came up during the review process of Sankeerth's series trying to add eDP for Qualcomm SoCs [2].
This _doesn't_ attempt to fix the Analogix driver. If this works out, ideally someone can post a patch up to do that.
[1] https://lore.kernel.org/r/20220409023628.2104952-1-dianders@chromium.org/ [2] https://lore.kernel.org/r/1648656179-10347-2-git-send-email-quic_sbillaka@qu...
Changes in v3: - Don't check "hpd_asserted" boolean when unset. - Handle errors from gpiod_get_value_cansleep() properly.
Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted()
Douglas Anderson (4): drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux drm/panel-edp: Take advantage of wait_hpd_asserted() in struct drm_dp_aux drm/panel: atna33xc20: Take advantage of wait_hpd_asserted() in struct drm_dp_aux drm/bridge: parade-ps8640: Provide wait_hpd_asserted() in struct drm_dp_aux
drivers/gpu/drm/bridge/parade-ps8640.c | 34 +++++++++------ drivers/gpu/drm/panel/panel-edp.c | 33 ++++++++++----- .../gpu/drm/panel/panel-samsung-atna33xc20.c | 41 +++++++++++++------ include/drm/dp/drm_dp_helper.h | 26 ++++++++++++ 4 files changed, 98 insertions(+), 36 deletions(-)
Sometimes it's useful for users of the DP AUX bus (like panels) to be able to poll HPD. Let's add a callback that allows DP AUX busses drivers to provide this.
Suggested-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org Signed-off-by: Douglas Anderson dianders@chromium.org --- Left Dmitry's Reviewed-by tag off since patch changed enough.
(no changes since v2)
Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted()
include/drm/dp/drm_dp_helper.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
+ /** + * @wait_hpd_asserted: wait for HPD to be asserted + * + * This is mainly useful for eDP panels drivers to wait for an eDP + * panel to finish powering on. This is an optional function. + * + * This function will efficiently wait for up to `wait_us` microseconds + * for HPD to be asserted and might sleep. + * + * This function returns 0 if HPD was asserted or -ETIMEDOUT if time + * expired and HPD wasn't asserted. This function should not print + * timeout errors to the log. + * + * The semantics of this function are designed to match the + * readx_poll_timeout() function. That means a `wait_us` of 0 means + * to wait forever. If you want to do a quick poll you could pass 1 + * for `wait_us`. + * + * NOTE: this function specifically reports the state of the HPD pin + * that's associated with the DP AUX channel. This is different from + * the HPD concept in much of the rest of DRM which is more about + * physical presence of a display. For eDP, for instance, a display is + * assumed always present even if the HPD pin is deasserted. + */ + int (*wait_hpd_asserted)(struct drm_dp_aux *aux, unsigned long wait_us); + /** * @i2c_nack_count: Counts I2C NACKs, used for DP validation. */
Quoting Douglas Anderson (2022-04-18 10:17:54)
Sometimes it's useful for users of the DP AUX bus (like panels) to be able to poll HPD. Let's add a callback that allows DP AUX busses drivers to provide this.
Suggested-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org Signed-off-by: Douglas Anderson dianders@chromium.org
Left Dmitry's Reviewed-by tag off since patch changed enough.
(no changes since v2)
Changes in v2:
- Change is_hpd_asserted() to wait_hpd_asserted()
include/drm/dp/drm_dp_helper.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
/**
* @wait_hpd_asserted: wait for HPD to be asserted
*
* This is mainly useful for eDP panels drivers to wait for an eDP
* panel to finish powering on. This is an optional function.
Is there any use for the opposite direction? For example, does anything care that HPD is deasserted?
*
* This function will efficiently wait for up to `wait_us` microseconds
* for HPD to be asserted and might sleep.
*
* This function returns 0 if HPD was asserted or -ETIMEDOUT if time
* expired and HPD wasn't asserted. This function should not print
* timeout errors to the log.
*
* The semantics of this function are designed to match the
* readx_poll_timeout() function. That means a `wait_us` of 0 means
* to wait forever. If you want to do a quick poll you could pass 1
* for `wait_us`.
It would also make sense to have a drm_dp_wait_hpd_asserted() API
int drm_dp_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us);
and then this aux function could be implemented in various ways. The API could poll if the aux can only read immediate state of HPD, or it could sleep (is sleeping allowed? that isn't clear) and wake up the process once HPD goes high. Or if this op isn't implemented maybe there's a fixed timeout member that is non-zero which means "sleep this long". Either way, making each drm_dp_aux implement that logic seems error prone vs. having the drm_dp_aux implement some function for
get_immediate_hpd(struct drm_dp_aux *aux)
or
notify_on_hpd(struct drm_dp_aux *auxstruct completion *comp)
*
* NOTE: this function specifically reports the state of the HPD pin
* that's associated with the DP AUX channel. This is different from
* the HPD concept in much of the rest of DRM which is more about
* physical presence of a display. For eDP, for instance, a display is
* assumed always present even if the HPD pin is deasserted.
*/
int (*wait_hpd_asserted)(struct drm_dp_aux *aux, unsigned long wait_us);
/** * @i2c_nack_count: Counts I2C NACKs, used for DP validation. */
Hi,
On Wed, May 11, 2022 at 6:58 PM Stephen Boyd swboyd@chromium.org wrote:
Quoting Douglas Anderson (2022-04-18 10:17:54)
Sometimes it's useful for users of the DP AUX bus (like panels) to be able to poll HPD. Let's add a callback that allows DP AUX busses drivers to provide this.
Suggested-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org Signed-off-by: Douglas Anderson dianders@chromium.org
Left Dmitry's Reviewed-by tag off since patch changed enough.
(no changes since v2)
Changes in v2:
- Change is_hpd_asserted() to wait_hpd_asserted()
include/drm/dp/drm_dp_helper.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
/**
* @wait_hpd_asserted: wait for HPD to be asserted
*
* This is mainly useful for eDP panels drivers to wait for an eDP
* panel to finish powering on. This is an optional function.
Is there any use for the opposite direction? For example, does anything care that HPD is deasserted?
Not that I'm aware of. Originally I was planning to have it so that a timeout of "0" meant to just poll without sleeping at all, but it ended up making the code a lot more complicated because everywhere else we had the "readx" semantics where 0 meant wait forever. It didn't seem worth it. I can go back to that behavior if need be.
*
* This function will efficiently wait for up to `wait_us` microseconds
* for HPD to be asserted and might sleep.
*
* This function returns 0 if HPD was asserted or -ETIMEDOUT if time
* expired and HPD wasn't asserted. This function should not print
* timeout errors to the log.
*
* The semantics of this function are designed to match the
* readx_poll_timeout() function. That means a `wait_us` of 0 means
* to wait forever. If you want to do a quick poll you could pass 1
* for `wait_us`.
It would also make sense to have a drm_dp_wait_hpd_asserted() API
int drm_dp_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us);
and then this aux function could be implemented in various ways. The API could poll if the aux can only read immediate state of HPD, or it could sleep (is sleeping allowed? that isn't clear) and wake up the process once HPD goes high. Or if this op isn't implemented maybe there's a fixed timeout member that is non-zero which means "sleep this long". Either way, making each drm_dp_aux implement that logic seems error prone vs. having the drm_dp_aux implement some function for
get_immediate_hpd(struct drm_dp_aux *aux)
There's a reason why I changed the API to "wait" from "get". If you can think of a good place to document this, I'm all ears.
The basic problem is ps8640 (my nemesis, apparently). On ps8640, because of the black box firmware blob that's on it, we have a crazy long delay in its runtime resume (300ms). So what happens with ps8640 is that if we make the API "get_immediate_hpd()" it wasn't so immediate. Even with autosuspend, that first "get" could take 300 ms, which really screwed with everyone else who was waiting with a 200 ms timeout.
Now, in theory, one could argue that the fact that ps8640 had a 300 ms sleep would mean that the very first "get" of the panel would already show HPD high. I don't know why that wasn't the case, but ps8640 is an annoying black box.
In general, though, the DP controller might need some amount of time to power itself back up and configure itself. Even though the ps8640 case is extreme, it wouldn't be totally extreme to assume that an AUX controller might take 20 ms or 50 ms to power up. That could still throw timings off. Implementing the API as a "wait" style API gets around this problem. Now the DP controller can take as long as it needs to power itself up and it can then wait with the requested timeout.
or
notify_on_hpd(struct drm_dp_aux *auxstruct completion *comp)
*
* NOTE: this function specifically reports the state of the HPD pin
* that's associated with the DP AUX channel. This is different from
* the HPD concept in much of the rest of DRM which is more about
* physical presence of a display. For eDP, for instance, a display is
* assumed always present even if the HPD pin is deasserted.
*/
int (*wait_hpd_asserted)(struct drm_dp_aux *aux, unsigned long wait_us);
/** * @i2c_nack_count: Counts I2C NACKs, used for DP validation. */
Quoting Doug Anderson (2022-05-12 16:24:13)
On Wed, May 11, 2022 at 6:58 PM Stephen Boyd swboyd@chromium.org wrote:
Quoting Douglas Anderson (2022-04-18 10:17:54)
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
/**
* @wait_hpd_asserted: wait for HPD to be asserted
*
* This is mainly useful for eDP panels drivers to wait for an eDP
* panel to finish powering on. This is an optional function.
Is there any use for the opposite direction? For example, does anything care that HPD is deasserted?
Not that I'm aware of. Originally I was planning to have it so that a timeout of "0" meant to just poll without sleeping at all, but it ended up making the code a lot more complicated because everywhere else we had the "readx" semantics where 0 meant wait forever. It didn't seem worth it. I can go back to that behavior if need be.
Got it.
*
* This function will efficiently wait for up to `wait_us` microseconds
* for HPD to be asserted and might sleep.
*
* This function returns 0 if HPD was asserted or -ETIMEDOUT if time
* expired and HPD wasn't asserted. This function should not print
* timeout errors to the log.
*
* The semantics of this function are designed to match the
* readx_poll_timeout() function. That means a `wait_us` of 0 means
* to wait forever. If you want to do a quick poll you could pass 1
* for `wait_us`.
It would also make sense to have a drm_dp_wait_hpd_asserted() API
int drm_dp_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us);
and then this aux function could be implemented in various ways. The API could poll if the aux can only read immediate state of HPD, or it could sleep (is sleeping allowed? that isn't clear) and wake up the process once HPD goes high. Or if this op isn't implemented maybe there's a fixed timeout member that is non-zero which means "sleep this long". Either way, making each drm_dp_aux implement that logic seems error prone vs. having the drm_dp_aux implement some function for
get_immediate_hpd(struct drm_dp_aux *aux)
There's a reason why I changed the API to "wait" from "get". If you can think of a good place to document this, I'm all ears.
The basic problem is ps8640 (my nemesis, apparently). On ps8640, because of the black box firmware blob that's on it, we have a crazy long delay in its runtime resume (300ms). So what happens with ps8640 is that if we make the API "get_immediate_hpd()" it wasn't so immediate. Even with autosuspend, that first "get" could take 300 ms, which really screwed with everyone else who was waiting with a 200 ms timeout.
Now, in theory, one could argue that the fact that ps8640 had a 300 ms sleep would mean that the very first "get" of the panel would already show HPD high. I don't know why that wasn't the case, but ps8640 is an annoying black box.
In general, though, the DP controller might need some amount of time to power itself back up and configure itself. Even though the ps8640 case is extreme, it wouldn't be totally extreme to assume that an AUX controller might take 20 ms or 50 ms to power up. That could still throw timings off. Implementing the API as a "wait" style API gets around this problem. Now the DP controller can take as long as it needs to power itself up and it can then wait with the requested timeout.
To clarify, are you saying that the 'wait' passed in will be added to whatever time it takes for the driver to runtime resume to check HPD status? Or is the driver supposed to subtract any time to power up from the 'wait' passed in and then poll or wait for an irq about HPD?
Would it be incorrect to somehow have the pm_runtime_get_sync() call in the mythical wrapper API with a ktime_get() before and after and then subtract that from the 'wait' time and call "get_immediate_hpd()"?
It would help me understand further if the 'wait' is described as a maximum time we're willing to wait or a minimum time we're willing to wait for hpd to be asserted. Usually a timeout is the maximum we're willing to wait so I think you're saying the wait is the maximum time after we know the drm_dp_aux is fully powered up and ready to check the state.
Hi,
On Thu, May 19, 2022 at 5:34 PM Stephen Boyd swboyd@chromium.org wrote:
Quoting Doug Anderson (2022-05-12 16:24:13)
On Wed, May 11, 2022 at 6:58 PM Stephen Boyd swboyd@chromium.org wrote:
Quoting Douglas Anderson (2022-04-18 10:17:54)
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
/**
* @wait_hpd_asserted: wait for HPD to be asserted
*
* This is mainly useful for eDP panels drivers to wait for an eDP
* panel to finish powering on. This is an optional function.
Is there any use for the opposite direction? For example, does anything care that HPD is deasserted?
Not that I'm aware of. Originally I was planning to have it so that a timeout of "0" meant to just poll without sleeping at all, but it ended up making the code a lot more complicated because everywhere else we had the "readx" semantics where 0 meant wait forever. It didn't seem worth it. I can go back to that behavior if need be.
Got it.
*
* This function will efficiently wait for up to `wait_us` microseconds
* for HPD to be asserted and might sleep.
*
* This function returns 0 if HPD was asserted or -ETIMEDOUT if time
* expired and HPD wasn't asserted. This function should not print
* timeout errors to the log.
*
* The semantics of this function are designed to match the
* readx_poll_timeout() function. That means a `wait_us` of 0 means
* to wait forever. If you want to do a quick poll you could pass 1
* for `wait_us`.
It would also make sense to have a drm_dp_wait_hpd_asserted() API
int drm_dp_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us);
and then this aux function could be implemented in various ways. The API could poll if the aux can only read immediate state of HPD, or it could sleep (is sleeping allowed? that isn't clear) and wake up the process once HPD goes high. Or if this op isn't implemented maybe there's a fixed timeout member that is non-zero which means "sleep this long". Either way, making each drm_dp_aux implement that logic seems error prone vs. having the drm_dp_aux implement some function for
get_immediate_hpd(struct drm_dp_aux *aux)
There's a reason why I changed the API to "wait" from "get". If you can think of a good place to document this, I'm all ears.
The basic problem is ps8640 (my nemesis, apparently). On ps8640, because of the black box firmware blob that's on it, we have a crazy long delay in its runtime resume (300ms). So what happens with ps8640 is that if we make the API "get_immediate_hpd()" it wasn't so immediate. Even with autosuspend, that first "get" could take 300 ms, which really screwed with everyone else who was waiting with a 200 ms timeout.
Now, in theory, one could argue that the fact that ps8640 had a 300 ms sleep would mean that the very first "get" of the panel would already show HPD high. I don't know why that wasn't the case, but ps8640 is an annoying black box.
In general, though, the DP controller might need some amount of time to power itself back up and configure itself. Even though the ps8640 case is extreme, it wouldn't be totally extreme to assume that an AUX controller might take 20 ms or 50 ms to power up. That could still throw timings off. Implementing the API as a "wait" style API gets around this problem. Now the DP controller can take as long as it needs to power itself up and it can then wait with the requested timeout.
To clarify, are you saying that the 'wait' passed in will be added to whatever time it takes for the driver to runtime resume to check HPD status? Or is the driver supposed to subtract any time to power up from the 'wait' passed in and then poll or wait for an irq about HPD?
So the "wait" time passed in is supposed to be the time from the panel datasheet that's the maximum it takes for HPD to go high after giving power to the panel. In theory, this wait time ought to be able to happen in parallel with the controller itself starting up. In that sense, going back to a polling mechanism again ought to work. ...but the polling mechanism _didn't_ work, so let's think more carefully about what might be going on.
So it's possible that somehow we're not waiting enough time in the parade's power on function. Maybe the chip isn't truly powered on and thus when we first poll it then we're always going to get back "HPD deasserted". ...or maybe it's powered on but the logic for HPD hasn't finished starting up yet, if that even makes sense. In that sense, we could probably go back to the polling mechanism again and just stick an even bigger hardcoded delay in the powerup.
I guess it's also possible (and probably more likely) that the parade chip is "debouncing" HPD here. The chip might be powered up OK and HPD may be asserted, but it's possible that the value we're reading has an intentional, chip-specific delay in it. The ti-sn65dsi86's builtin HPD pin did this which is why we didn't use it. See commit c2bfc223882d ("drm/bridge: ti-sn65dsi86: Remove the mystery delay"). If this is the case then an extra delay in "power on" won't _necessarily_ fix us.
Let's imagine:
1. The parade chip itself is already powered on, so runtime_resume for the parade chip is a no-op.
2. The parade has a 150 ms debounce on HPD.
3. The panel has a "max" HPD of 200 ms.
4. The panel's HPD actually comes up in 150 ms after the panel is powered.
In the above scenario, if we "poll" and timeout for 200 ms then we'll incorrectly believe that HPD is low at the end. We'll observe HPD going high at 300 ms, and I'll argue that in the above case we should wait until 350 ms before timing out (max HPD + debounce).
Would it be incorrect to somehow have the pm_runtime_get_sync() call in the mythical wrapper API with a ktime_get() before and after and then subtract that from the 'wait' time and call "get_immediate_hpd()"?
It would help me understand further if the 'wait' is described as a maximum time we're willing to wait or a minimum time we're willing to wait for hpd to be asserted. Usually a timeout is the maximum we're willing to wait so I think you're saying the wait is the maximum time after we know the drm_dp_aux is fully powered up and ready to check the state.
So where does that leave us? I'd still argue that the "wait" API gives us the most flexibility. The DP controller driver has the most knowledge about exactly how much extra time it might need to tack on. The amount of duplicated code is really quite minimal, especially with all of the helper functions. Even if the "debounce" isn't the explanation for the parade bridge chip, we know for sure that other bridge chips might not have the ability to read the raw HPD state and can only read the debounced state.
Aside from leaving the API as "wait", I guess the best thing I can think of would be to go back to polling and add another API that indicates the maximum debounce time for the HPD signal. That seems worse to me, though.
If the above convinces you that the "wait" API is correct, I can spin the patches and add some extra comments. It's probably a good idea to add an extra 300 ms to the timeout in the parade driver too. Assuming my theory about the debounce is correct then my current patches are relying on the extra delay in the parade bridge powerup to cover the debounce. It should also be noted that having a longer timeout isn't really a terrible thing. In a functioning system we should never hit it.
NOTE: after all the above discussion, it seems like the same arguments I made about the ti-sn65dsi86 might hold for the parade-ps8640: it would be better to just have the panel driver do the maximum delay and forget about trying to read HPD in the parade driver. Unfortunately, yet again I'm bumping up against the undocumented firmware blob for the parade chip. I have no idea how to tell the parade chip to ignore HPD. I'd also note that such a change would require "no-hpd" be added to existing device trees and thus would make old device trees incompatible.
-Doug
On 18/04/2022 20:17, Douglas Anderson wrote:
Sometimes it's useful for users of the DP AUX bus (like panels) to be able to poll HPD. Let's add a callback that allows DP AUX busses drivers to provide this.
Suggested-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org Signed-off-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org
Left Dmitry's Reviewed-by tag off since patch changed enough.
(no changes since v2)
Changes in v2:
Change is_hpd_asserted() to wait_hpd_asserted()
include/drm/dp/drm_dp_helper.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
- /**
* @wait_hpd_asserted: wait for HPD to be asserted
*
* This is mainly useful for eDP panels drivers to wait for an eDP
* panel to finish powering on. This is an optional function.
*
* This function will efficiently wait for up to `wait_us` microseconds
* for HPD to be asserted and might sleep.
*
* This function returns 0 if HPD was asserted or -ETIMEDOUT if time
* expired and HPD wasn't asserted. This function should not print
* timeout errors to the log.
*
* The semantics of this function are designed to match the
* readx_poll_timeout() function. That means a `wait_us` of 0 means
* to wait forever. If you want to do a quick poll you could pass 1
* for `wait_us`.
*
* NOTE: this function specifically reports the state of the HPD pin
* that's associated with the DP AUX channel. This is different from
* the HPD concept in much of the rest of DRM which is more about
* physical presence of a display. For eDP, for instance, a display is
* assumed always present even if the HPD pin is deasserted.
*/
- int (*wait_hpd_asserted)(struct drm_dp_aux *aux, unsigned long wait_us);
- /**
*/
- @i2c_nack_count: Counts I2C NACKs, used for DP validation.
Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will allow us to get more accurate delays also lets us take away the waiting in the AUX transfer functions of the eDP controller drivers.
Signed-off-by: Douglas Anderson dianders@chromium.org ---
(no changes since v2)
Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted()
drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 1732b4f56e38..086e0bf52fb9 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) return 0; }
+static bool panel_edp_can_read_hpd(struct panel_edp *p) +{ + return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted)); +} + static int panel_edp_prepare_once(struct panel_edp *p) { struct device *dev = p->base.dev; @@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) if (delay) msleep(delay);
- if (p->hpd_gpio) { + if (panel_edp_can_read_hpd(p)) { if (p->desc->delay.hpd_absent) hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; else hpd_wait_us = 2000000;
- err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, hpd_wait_us); - if (hpd_asserted < 0) - err = hpd_asserted; + if (p->hpd_gpio) { + err = readx_poll_timeout(gpiod_get_value_cansleep, + p->hpd_gpio, hpd_asserted, + hpd_asserted, 1000, hpd_wait_us); + if (hpd_asserted < 0) + err = hpd_asserted; + } else { + err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); + }
if (err) { if (err != -ETIMEDOUT) @@ -532,18 +541,22 @@ static int panel_edp_enable(struct drm_panel *panel) /* * If there is a "prepare_to_enable" delay then that's supposed to be * the delay from HPD going high until we can turn the backlight on. - * However, we can only count this if HPD is handled by the panel - * driver, not if it goes to a dedicated pin on the controller. + * However, we can only count this if HPD is readable by the panel + * driver. + * * If we aren't handling the HPD pin ourselves then the best we * can do is assume that HPD went high immediately before we were - * called (and link training took zero time). + * called (and link training took zero time). Note that "no-hpd" + * actually counts as handling HPD ourselves since we're doing the + * worst case delay (in prepare) ourselves. * * NOTE: if we ever end up in this "if" statement then we're * guaranteed that the panel_edp_wait() call below will do no delay. * It already handles that case, though, so we don't need any special * code for it. */ - if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd) + if (p->desc->delay.prepare_to_enable && + !panel_edp_can_read_hpd(p) && !p->no_hpd) delay = max(delay, p->desc->delay.prepare_to_enable);
if (delay)
On 18/04/2022 20:17, Douglas Anderson wrote:
Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will allow us to get more accurate delays also lets us take away the waiting in the AUX transfer functions of the eDP controller drivers.
Signed-off-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org
(no changes since v2)
Changes in v2:
Change is_hpd_asserted() to wait_hpd_asserted()
drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 1732b4f56e38..086e0bf52fb9 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) return 0; }
+static bool panel_edp_can_read_hpd(struct panel_edp *p) +{
- return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted));
+}
- static int panel_edp_prepare_once(struct panel_edp *p) { struct device *dev = p->base.dev;
@@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) if (delay) msleep(delay);
- if (p->hpd_gpio) {
- if (panel_edp_can_read_hpd(p)) { if (p->desc->delay.hpd_absent) hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; else hpd_wait_us = 2000000;
err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio,
hpd_asserted, hpd_asserted,
1000, hpd_wait_us);
if (hpd_asserted < 0)
err = hpd_asserted;
if (p->hpd_gpio) {
err = readx_poll_timeout(gpiod_get_value_cansleep,
p->hpd_gpio, hpd_asserted,
hpd_asserted, 1000, hpd_wait_us);
if (hpd_asserted < 0)
err = hpd_asserted;
} else {
err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us);
}
I'm close to thinking that this construct deserves a separate helper.
if (err) { if (err != -ETIMEDOUT)
@@ -532,18 +541,22 @@ static int panel_edp_enable(struct drm_panel *panel) /* * If there is a "prepare_to_enable" delay then that's supposed to be * the delay from HPD going high until we can turn the backlight on.
* However, we can only count this if HPD is handled by the panel
* driver, not if it goes to a dedicated pin on the controller.
* However, we can only count this if HPD is readable by the panel
* driver.
*
- If we aren't handling the HPD pin ourselves then the best we
- can do is assume that HPD went high immediately before we were
* called (and link training took zero time).
* called (and link training took zero time). Note that "no-hpd"
* actually counts as handling HPD ourselves since we're doing the
* worst case delay (in prepare) ourselves.
*/
- NOTE: if we ever end up in this "if" statement then we're
- guaranteed that the panel_edp_wait() call below will do no delay.
- It already handles that case, though, so we don't need any special
- code for it.
- if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd)
if (p->desc->delay.prepare_to_enable &&
!panel_edp_can_read_hpd(p) && !p->no_hpd)
delay = max(delay, p->desc->delay.prepare_to_enable);
if (delay)
Hi,
On Thu, Jun 2, 2022 at 8:12 AM Dmitry Baryshkov dmitry.baryshkov@linaro.org wrote:
On 18/04/2022 20:17, Douglas Anderson wrote:
Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will allow us to get more accurate delays also lets us take away the waiting in the AUX transfer functions of the eDP controller drivers.
Signed-off-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org
(no changes since v2)
Changes in v2:
Change is_hpd_asserted() to wait_hpd_asserted()
drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 1732b4f56e38..086e0bf52fb9 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) return 0; }
+static bool panel_edp_can_read_hpd(struct panel_edp *p) +{
return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted));
+}
- static int panel_edp_prepare_once(struct panel_edp *p) { struct device *dev = p->base.dev;
@@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) if (delay) msleep(delay);
if (p->hpd_gpio) {
if (panel_edp_can_read_hpd(p)) { if (p->desc->delay.hpd_absent) hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; else hpd_wait_us = 2000000;
err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio,
hpd_asserted, hpd_asserted,
1000, hpd_wait_us);
if (hpd_asserted < 0)
err = hpd_asserted;
if (p->hpd_gpio) {
err = readx_poll_timeout(gpiod_get_value_cansleep,
p->hpd_gpio, hpd_asserted,
hpd_asserted, 1000, hpd_wait_us);
if (hpd_asserted < 0)
err = hpd_asserted;
} else {
err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us);
}
I'm close to thinking that this construct deserves a separate helper.
Just to close the loop: I didn't try to create a helper for v5. I'm not completely convinced that this will be common. I would tend to expect that having HPD handled by a GPIO is somewhat rare. It's also fairly rare to have a panel that's not handled by the generic panel-edp. We ended up with the GPIO on trogdor because of the weird debouncing on sn85dsi86 and we ended up with one case of not using edp-panel on trogdor because of the weird power sequencing of the Samsung OLED panel that's on homestar.
I'd also note that the generic eDP panel has a special case for "timeout" which we don't have on the Samsung panel to handle at least one panel I found that sometimes simply didn't come up but then _would_ come up on a retry...
That doesn't mean we couldn't abstract it out later, of course. ;-)
-Doug
-Doug
Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will let us take away the waiting in the AUX transfer functions of the eDP controller drivers.
Signed-off-by: Douglas Anderson dianders@chromium.org ---
Changes in v3: - Don't check "hpd_asserted" boolean when unset. - Handle errors from gpiod_get_value_cansleep() properly.
Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted()
.../gpu/drm/panel/panel-samsung-atna33xc20.c | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c index 20666b6217e7..5ef1b4032c56 100644 --- a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c +++ b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c @@ -19,6 +19,10 @@ #include <drm/drm_edid.h> #include <drm/drm_panel.h>
+/* T3 VCC to HPD high is max 200 ms */ +#define HPD_MAX_MS 200 +#define HPD_MAX_US (HPD_MAX_MS * 1000) + struct atana33xc20_panel { struct drm_panel base; bool prepared; @@ -30,6 +34,7 @@ struct atana33xc20_panel {
struct regulator *supply; struct gpio_desc *el_on3_gpio; + struct drm_dp_aux *aux;
struct edid *edid;
@@ -79,7 +84,7 @@ static int atana33xc20_suspend(struct device *dev) static int atana33xc20_resume(struct device *dev) { struct atana33xc20_panel *p = dev_get_drvdata(dev); - bool hpd_asserted = false; + int hpd_asserted; int ret;
/* T12 (Power off time) is min 500 ms */ @@ -91,20 +96,28 @@ static int atana33xc20_resume(struct device *dev) p->powered_on_time = ktime_get();
/* - * Handle HPD. Note: if HPD is hooked up to a dedicated pin on the - * eDP controller then "no_hpd" will be false _and_ "hpd_gpio" will be - * NULL. It's up to the controller driver to wait for HPD after - * preparing the panel in that case. + * Note that it's possible that no_hpd is false, hpd_gpio is + * NULL, and wait_hpd_asserted is NULL. This is because + * wait_hpd_asserted() is optional even if HPD is hooked up to + * a dedicated pin on the eDP controller. In this case we just + * assume that the controller driver will wait for HPD at the + * right times. */ if (p->no_hpd) { - /* T3 VCC to HPD high is max 200 ms */ - msleep(200); - } else if (p->hpd_gpio) { - ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, 200000); - if (!hpd_asserted) - dev_warn(dev, "Timeout waiting for HPD\n"); + msleep(HPD_MAX_MS); + } else { + if (p->hpd_gpio) { + ret = readx_poll_timeout(gpiod_get_value_cansleep, + p->hpd_gpio, hpd_asserted, + hpd_asserted, 1000, HPD_MAX_US); + if (hpd_asserted < 0) + ret = hpd_asserted; + } else if (p->aux->wait_hpd_asserted) { + ret = p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US); + } + + if (ret) + dev_warn(dev, "Error waiting for HPD: %d\n", ret); }
return 0; @@ -263,6 +276,8 @@ static int atana33xc20_probe(struct dp_aux_ep_device *aux_ep) return -ENOMEM; dev_set_drvdata(dev, panel);
+ panel->aux = aux_ep->aux; + panel->supply = devm_regulator_get(dev, "power"); if (IS_ERR(panel->supply)) return dev_err_probe(dev, PTR_ERR(panel->supply),
On 18/04/2022 20:17, Douglas Anderson wrote:
Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will let us take away the waiting in the AUX transfer functions of the eDP controller drivers.
Signed-off-by: Douglas Anderson dianders@chromium.org
Changes in v3:
- Don't check "hpd_asserted" boolean when unset.
- Handle errors from gpiod_get_value_cansleep() properly.
Changes in v2:
Change is_hpd_asserted() to wait_hpd_asserted()
.../gpu/drm/panel/panel-samsung-atna33xc20.c | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c index 20666b6217e7..5ef1b4032c56 100644 --- a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c +++ b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c @@ -19,6 +19,10 @@ #include <drm/drm_edid.h> #include <drm/drm_panel.h>
+/* T3 VCC to HPD high is max 200 ms */ +#define HPD_MAX_MS 200 +#define HPD_MAX_US (HPD_MAX_MS * 1000)
- struct atana33xc20_panel { struct drm_panel base; bool prepared;
@@ -30,6 +34,7 @@ struct atana33xc20_panel {
struct regulator *supply; struct gpio_desc *el_on3_gpio;
struct drm_dp_aux *aux;
struct edid *edid;
@@ -79,7 +84,7 @@ static int atana33xc20_suspend(struct device *dev) static int atana33xc20_resume(struct device *dev) { struct atana33xc20_panel *p = dev_get_drvdata(dev);
- bool hpd_asserted = false;
int hpd_asserted; int ret;
/* T12 (Power off time) is min 500 ms */
@@ -91,20 +96,28 @@ static int atana33xc20_resume(struct device *dev) p->powered_on_time = ktime_get();
/*
* Handle HPD. Note: if HPD is hooked up to a dedicated pin on the
* eDP controller then "no_hpd" will be false _and_ "hpd_gpio" will be
* NULL. It's up to the controller driver to wait for HPD after
* preparing the panel in that case.
* Note that it's possible that no_hpd is false, hpd_gpio is
* NULL, and wait_hpd_asserted is NULL. This is because
* wait_hpd_asserted() is optional even if HPD is hooked up to
* a dedicated pin on the eDP controller. In this case we just
* assume that the controller driver will wait for HPD at the
*/ if (p->no_hpd) {* right times.
/* T3 VCC to HPD high is max 200 ms */
msleep(200);
- } else if (p->hpd_gpio) {
ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio,
hpd_asserted, hpd_asserted,
1000, 200000);
if (!hpd_asserted)
dev_warn(dev, "Timeout waiting for HPD\n");
msleep(HPD_MAX_MS);
- } else {
if (p->hpd_gpio) {
ret = readx_poll_timeout(gpiod_get_value_cansleep,
p->hpd_gpio, hpd_asserted,
hpd_asserted, 1000, HPD_MAX_US);
if (hpd_asserted < 0)
ret = hpd_asserted;
} else if (p->aux->wait_hpd_asserted) {
ret = p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US);
}
if (ret)
dev_warn(dev, "Error waiting for HPD: %d\n", ret);
I'd suggest reworking this to:
if (p->no_hpd) { msleep(); return 0; }
if (p->hpd_gpio) { ret = readx_poll_timeout(...)
if (ret) dev_warn() return ret; }
if (p->aux->wait_hpd_asserted) { ret = p->aux->wait.... if (ret) dev_warn(...) return ret; }
return 0;
}
return 0; @@ -263,6 +276,8 @@ static int atana33xc20_probe(struct dp_aux_ep_device *aux_ep) return -ENOMEM; dev_set_drvdata(dev, panel);
- panel->aux = aux_ep->aux;
- panel->supply = devm_regulator_get(dev, "power"); if (IS_ERR(panel->supply)) return dev_err_probe(dev, PTR_ERR(panel->supply),
This implements the callback added by the patch ("drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux").
With this change and all the two "DP AUX Endpoint" drivers changed to use wait_hpd_asserted(), we no longer need to have an long delay in the AUX transfer function. It's up to the panel code to make sure that the panel is powered now. If someone tried to call the aux transfer function without making sure the panel is powered we'll just get a normal transfer failure.
We'll still keep the wait for HPD in the pre_enable() function. Though it's probably not actually needed there, this driver is used in the old mode (pre-DP AUX Endpoints) and it may be important for those cases. If nothing else, it shouldn't cause any big problems.
Signed-off-by: Douglas Anderson dianders@chromium.org ---
(no changes since v2)
Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted()
drivers/gpu/drm/bridge/parade-ps8640.c | 34 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c index 9766cbbd62ad..2f19a8c89880 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -168,23 +168,30 @@ static bool ps8640_of_panel_on_aux_bus(struct device *dev) return true; }
-static int ps8640_ensure_hpd(struct ps8640 *ps_bridge) +static int _ps8640_wait_hpd_asserted(struct ps8640 *ps_bridge, unsigned long wait_us) { struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL]; - struct device *dev = &ps_bridge->page[PAGE2_TOP_CNTL]->dev; int status; - int ret;
/* * Apparently something about the firmware in the chip signals that * HPD goes high by reporting GPIO9 as high (even though HPD isn't * actually connected to GPIO9). */ - ret = regmap_read_poll_timeout(map, PAGE2_GPIO_H, status, - status & PS_GPIO9, 20 * 1000, 200 * 1000); + return regmap_read_poll_timeout(map, PAGE2_GPIO_H, status, + status & PS_GPIO9, wait_us / 10, wait_us); +}
- if (ret < 0) - dev_warn(dev, "HPD didn't go high: %d\n", ret); +static int ps8640_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us) +{ + struct ps8640 *ps_bridge = aux_to_ps8640(aux); + struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; + int ret; + + pm_runtime_get_sync(dev); + ret = _ps8640_wait_hpd_asserted(ps_bridge, wait_us); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev);
return ret; } @@ -323,9 +330,7 @@ static ssize_t ps8640_aux_transfer(struct drm_dp_aux *aux, int ret;
pm_runtime_get_sync(dev); - ret = ps8640_ensure_hpd(ps_bridge); - if (!ret) - ret = ps8640_aux_transfer_msg(aux, msg); + ret = ps8640_aux_transfer_msg(aux, msg); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev);
@@ -369,8 +374,8 @@ static int __maybe_unused ps8640_resume(struct device *dev) * Mystery 200 ms delay for the "MCU to be ready". It's unclear if * this is truly necessary since the MCU will already signal that * things are "good to go" by signaling HPD on "gpio 9". See - * ps8640_ensure_hpd(). For now we'll keep this mystery delay just in - * case. + * _ps8640_wait_hpd_asserted(). For now we'll keep this mystery delay + * just in case. */ msleep(200);
@@ -406,7 +411,9 @@ static void ps8640_pre_enable(struct drm_bridge *bridge) int ret;
pm_runtime_get_sync(dev); - ps8640_ensure_hpd(ps_bridge); + ret = _ps8640_wait_hpd_asserted(ps_bridge, 200 * 1000); + if (ret < 0) + dev_warn(dev, "HPD didn't go high: %d\n", ret);
/* * The Manufacturer Command Set (MCS) is a device dependent interface @@ -652,6 +659,7 @@ static int ps8640_probe(struct i2c_client *client) ps_bridge->aux.name = "parade-ps8640-aux"; ps_bridge->aux.dev = dev; ps_bridge->aux.transfer = ps8640_aux_transfer; + ps_bridge->aux.wait_hpd_asserted = ps8640_wait_hpd_asserted; drm_dp_aux_init(&ps_bridge->aux);
pm_runtime_enable(dev);
On 18/04/2022 20:17, Douglas Anderson wrote:
This implements the callback added by the patch ("drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux").
With this change and all the two "DP AUX Endpoint" drivers changed to use wait_hpd_asserted(), we no longer need to have an long delay in the AUX transfer function. It's up to the panel code to make sure that the panel is powered now. If someone tried to call the aux transfer function without making sure the panel is powered we'll just get a normal transfer failure.
We'll still keep the wait for HPD in the pre_enable() function. Though it's probably not actually needed there, this driver is used in the old mode (pre-DP AUX Endpoints) and it may be important for those cases. If nothing else, it shouldn't cause any big problems.
Signed-off-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org
Minor nit below
(no changes since v2)
Changes in v2:
Change is_hpd_asserted() to wait_hpd_asserted()
drivers/gpu/drm/bridge/parade-ps8640.c | 34 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c index 9766cbbd62ad..2f19a8c89880 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -168,23 +168,30 @@ static bool ps8640_of_panel_on_aux_bus(struct device *dev) return true; }
-static int ps8640_ensure_hpd(struct ps8640 *ps_bridge) +static int _ps8640_wait_hpd_asserted(struct ps8640 *ps_bridge, unsigned long wait_us) { struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL];
struct device *dev = &ps_bridge->page[PAGE2_TOP_CNTL]->dev; int status;
int ret;
/*
- Apparently something about the firmware in the chip signals that
- HPD goes high by reporting GPIO9 as high (even though HPD isn't
- actually connected to GPIO9).
*/
ret = regmap_read_poll_timeout(map, PAGE2_GPIO_H, status,
status & PS_GPIO9, 20 * 1000, 200 * 1000);
- return regmap_read_poll_timeout(map, PAGE2_GPIO_H, status,
status & PS_GPIO9, wait_us / 10, wait_us);
+}
- if (ret < 0)
dev_warn(dev, "HPD didn't go high: %d\n", ret);
+static int ps8640_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us) +{
- struct ps8640 *ps_bridge = aux_to_ps8640(aux);
- struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev;
- int ret;
- pm_runtime_get_sync(dev);
- ret = _ps8640_wait_hpd_asserted(ps_bridge, wait_us);
- pm_runtime_mark_last_busy(dev);
- pm_runtime_put_autosuspend(dev);
I'd add a note here, that the called should have already woken up the device.
return ret; } @@ -323,9 +330,7 @@ static ssize_t ps8640_aux_transfer(struct drm_dp_aux *aux, int ret;
pm_runtime_get_sync(dev);
- ret = ps8640_ensure_hpd(ps_bridge);
- if (!ret)
ret = ps8640_aux_transfer_msg(aux, msg);
- ret = ps8640_aux_transfer_msg(aux, msg); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev);
@@ -369,8 +374,8 @@ static int __maybe_unused ps8640_resume(struct device *dev) * Mystery 200 ms delay for the "MCU to be ready". It's unclear if * this is truly necessary since the MCU will already signal that * things are "good to go" by signaling HPD on "gpio 9". See
* ps8640_ensure_hpd(). For now we'll keep this mystery delay just in
* case.
* _ps8640_wait_hpd_asserted(). For now we'll keep this mystery delay
*/ msleep(200);* just in case.
@@ -406,7 +411,9 @@ static void ps8640_pre_enable(struct drm_bridge *bridge) int ret;
pm_runtime_get_sync(dev);
- ps8640_ensure_hpd(ps_bridge);
ret = _ps8640_wait_hpd_asserted(ps_bridge, 200 * 1000);
if (ret < 0)
dev_warn(dev, "HPD didn't go high: %d\n", ret);
/*
- The Manufacturer Command Set (MCS) is a device dependent interface
@@ -652,6 +659,7 @@ static int ps8640_probe(struct i2c_client *client) ps_bridge->aux.name = "parade-ps8640-aux"; ps_bridge->aux.dev = dev; ps_bridge->aux.transfer = ps8640_aux_transfer;
ps_bridge->aux.wait_hpd_asserted = ps8640_wait_hpd_asserted; drm_dp_aux_init(&ps_bridge->aux);
pm_runtime_enable(dev);
Hi,
On Mon, Apr 18, 2022 at 10:18 AM Douglas Anderson dianders@chromium.org wrote:
This is the 2nd four patches from my RFC series ("drm/dp: Improvements for DP AUX channel") [1]. I've broken the series in two so we can make progress on the two halves separately.
v2 of this series changes to add wait_hpd_asserted() instead of is_hpd_asserted(). This allows us to move the extra delay needed for ps8640 into the ps8640 driver itself.
The idea for this series came up during the review process of Sankeerth's series trying to add eDP for Qualcomm SoCs [2].
This _doesn't_ attempt to fix the Analogix driver. If this works out, ideally someone can post a patch up to do that.
[1] https://lore.kernel.org/r/20220409023628.2104952-1-dianders@chromium.org/ [2] https://lore.kernel.org/r/1648656179-10347-2-git-send-email-quic_sbillaka@qu...
Changes in v3:
- Don't check "hpd_asserted" boolean when unset.
- Handle errors from gpiod_get_value_cansleep() properly.
Changes in v2:
- Change is_hpd_asserted() to wait_hpd_asserted()
Douglas Anderson (4): drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux drm/panel-edp: Take advantage of wait_hpd_asserted() in struct drm_dp_aux drm/panel: atna33xc20: Take advantage of wait_hpd_asserted() in struct drm_dp_aux drm/bridge: parade-ps8640: Provide wait_hpd_asserted() in struct drm_dp_aux
drivers/gpu/drm/bridge/parade-ps8640.c | 34 +++++++++------ drivers/gpu/drm/panel/panel-edp.c | 33 ++++++++++----- .../gpu/drm/panel/panel-samsung-atna33xc20.c | 41 +++++++++++++------ include/drm/dp/drm_dp_helper.h | 26 ++++++++++++ 4 files changed, 98 insertions(+), 36 deletions(-)
It's been about 2 weeks and I haven't seen any review. Dmitry: since this came up due to your feedback, any chance you'd be willing to review at least the drm-framework pieces? Philip is no longer on the Chrome OS team, so I suspect he won't be reviewing the ps8640 patches. Stephen: maybe you'd be willing to?
Thanks!
-Doug
dri-devel@lists.freedesktop.org