Re: The inherent defect of the AMDGPU driver about hotplug

2020-06-15 Thread Aaron Chou
Yes, I agree.

On Tue, Jun 16, 2020 at 3:08 AM Alex Deucher  wrote:
>
> On Mon, Jun 15, 2020 at 5:30 AM Aaron Chou  wrote:
> >
> > About one month ago, I have asked a question about HDMI hotplug, the link 
> > is:
> >
> > https://gitlab.freedesktop.org/drm/amd/-/issues/1135#note_492460
> >
> > And I have put one patch to fix this, as follows:
> >
> >  39 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> >  40 index f355d9a752d2..ee657db9a228 100644
> >  41 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> >  42 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> >  43 @@ -973,7 +973,7 @@ amdgpu_connector_dvi_detect(struct
> > drm_connector *connector, bool force)
> >  44 const struct drm_encoder_helper_funcs *encoder_funcs;
> >  45 int r;
> >  46 enum drm_connector_status ret =
> > connector_status_disconnected;
> >  47 -   bool dret = false, broken_edid = false;
> >  48 +   bool dret = false, broken_edid = false, undefined_flag =
> > false;
> >  49
> >  50 if (!drm_kms_helper_is_poll_worker()) {
> >  51 r = pm_runtime_get_sync(connector->dev->dev);
> >  52 @@ -988,7 +988,12 @@ amdgpu_connector_dvi_detect(struct
> > drm_connector *connector, bool force)
> >  53
> >  54 if (amdgpu_connector->ddc_bus)
> >  55 dret = amdgpu_display_ddc_probe(amdgpu_connector,
> > false);
> >  56 -   if (dret) {
> >  57 +
> >  58 +   /* Check the HDMI HPD pin status again */
> >  59 +   if (!amdgpu_display_hpd_sense(adev,
> > amdgpu_connector->hpd.hpd))
> >  60 +   undefined_flag = true;
> >  61 +
> >  62 +   if (dret && !undefined_flag) {
> >  63 amdgpu_connector->detected_by_load = false;
> >  64 amdgpu_connector_free_edid(connector);
> >  65 amdgpu_connector_get_edid(connector);
> >
> > Maybe the fix is sloppy, so I write the another patch:
> >
> >  16 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> >  17 index c770d73352a7..bb59ebc9a6c8 100644
> >  18 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> >  19 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> >  20 @@ -991,6 +991,7 @@ amdgpu_connector_dvi_detect(struct
> > drm_connector *connector, bool force)
> >  21 if (amdgpu_connector->ddc_bus)
> >  22 dret = amdgpu_display_ddc_probe(amdgpu_connector,
> > false);
> >  23 if (dret) {
> >  24 +   schedule_work(>hotplug_work);
> >  25 amdgpu_connector->detected_by_load = false;
> >  26 amdgpu_connector_free_edid(connector);
> >  27 amdgpu_connector_get_edid(connector);
> >
> > Which is better, or neither?
>
> As per the last discussion:
>
> "This is the part I don't understand.  The logic already checks the HPD
> status in amdgpu_connector_check_hpd_status_unchanged().  Does it
> still report connected at that point?  After that it tries to read the
> EDID in amdgpu_display_ddc_probe().  If the monitor is disconnected,
> there should be no EDID so dret should be false.  We should try and
> figure out why the first HPD check reports connected and the EDID
> probe returns true."
>
> There is already an HPD probe in the current logic.  We should try and
> understand why we need a second one rather than just adding one.  Does
> a delay at the top of that function help?
>
> Alex
>
> >
> > --
> > Regards,
> > Aaron
> > ___
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


The inherent defect of the AMDGPU driver about hotplug

2020-06-15 Thread Aaron Chou
About one month ago, I have asked a question about HDMI hotplug, the link is:

https://gitlab.freedesktop.org/drm/amd/-/issues/1135#note_492460

And I have put one patch to fix this, as follows:

 39 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
 40 index f355d9a752d2..ee657db9a228 100644
 41 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
 42 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
 43 @@ -973,7 +973,7 @@ amdgpu_connector_dvi_detect(struct
drm_connector *connector, bool force)
 44 const struct drm_encoder_helper_funcs *encoder_funcs;
 45 int r;
 46 enum drm_connector_status ret =
connector_status_disconnected;
 47 -   bool dret = false, broken_edid = false;
 48 +   bool dret = false, broken_edid = false, undefined_flag =
false;
 49
 50 if (!drm_kms_helper_is_poll_worker()) {
 51 r = pm_runtime_get_sync(connector->dev->dev);
 52 @@ -988,7 +988,12 @@ amdgpu_connector_dvi_detect(struct
drm_connector *connector, bool force)
 53
 54 if (amdgpu_connector->ddc_bus)
 55 dret = amdgpu_display_ddc_probe(amdgpu_connector,
false);
 56 -   if (dret) {
 57 +
 58 +   /* Check the HDMI HPD pin status again */
 59 +   if (!amdgpu_display_hpd_sense(adev,
amdgpu_connector->hpd.hpd))
 60 +   undefined_flag = true;
 61 +
 62 +   if (dret && !undefined_flag) {
 63 amdgpu_connector->detected_by_load = false;
 64 amdgpu_connector_free_edid(connector);
 65 amdgpu_connector_get_edid(connector);

Maybe the fix is sloppy, so I write the another patch:

 16 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
 17 index c770d73352a7..bb59ebc9a6c8 100644
 18 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
 19 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
 20 @@ -991,6 +991,7 @@ amdgpu_connector_dvi_detect(struct
drm_connector *connector, bool force)
 21 if (amdgpu_connector->ddc_bus)
 22 dret = amdgpu_display_ddc_probe(amdgpu_connector,
false);
 23 if (dret) {
 24 +   schedule_work(>hotplug_work);
 25 amdgpu_connector->detected_by_load = false;
 26 amdgpu_connector_free_edid(connector);
 27 amdgpu_connector_get_edid(connector);

Which is better, or neither?

--
Regards,
Aaron
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/admgpu: check HDMI HPD status after ddc probe

2020-05-10 Thread Aaron Chou
On Sat, May 9, 2020 at 9:35 PM Alex Deucher  wrote:
>
> On Sat, May 9, 2020 at 1:48 AM Binbin Zhou  wrote:
> >
> > Now, we check the presence of the EDID to determine if there is a monitor
> > present.
> >
> > DVI-I connectors have both analog and digital encoders and the HPD pin
> > is only reliable on the digital part.
> >
> > But when I pull out the Radeon HD8570's HDMI connector, the HDMI status
> > in system is still perform connected.
> >
> > asd@asd-PC:~$ cat /sys/class/drm/card0-HDMI-A-1/status
> > connected
> >
> > At this moment, if I want to read the EDID by /dev/i2c-X with I2C
> > driver, there is no EDID can be read.
> >
> > Dmesg witha drm.debug=0x6, we can find the following message:
> >
> > [drm:drm_helper_hpd_irq_event] [CONNECTOR:41:HDMI-A-1] status
> > updated from connected to connected
> >
> > Based on the appearance, I thought to check the HPD status again, because
> > the HPD status is perform disconnected, after amdgpu_display_ddc_probe().
> > If the amdgpu_display_hpd_sense() return false, I think the HDMI connector
> > status is undefined, and just return disconnected simply.
> >
> > I'm not sure if it happened to other AMD cards.
>
> This is the part I don't understand.  The logic already checks the HPD
> status in amdgpu_connector_check_hpd_status_unchanged().  Does it
> still report connected at that point?  After that it tires to read the
> EDID in amdgpu_display_ddc_probe().  If the monitor is disconnected,
> there should be no EDID so dret should be false.  We should try and
> figure out why the first HPD check reports connected and the EDID
> probe returns true.
>
> Alex

Emm.
I have tried with Radeon driver, it is the same.
And In the Mint system, I find if I pick out the HDMI connector, I can
see the status is still connected,
At the moment, If I do the xrandr command or open the Setting->Display
application, the HDMI status will refresh to disconnected.
The operation means to detect the display again.

Does the phenomenon meet the expectation?

Regards.
Aaron.
>
> >
> > Signed-off-by: Binbin Zhou 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 9 +++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > index f355d9a752d2..ee657db9a228 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > @@ -973,7 +973,7 @@ amdgpu_connector_dvi_detect(struct drm_connector 
> > *connector, bool force)
> > const struct drm_encoder_helper_funcs *encoder_funcs;
> > int r;
> > enum drm_connector_status ret = connector_status_disconnected;
> > -   bool dret = false, broken_edid = false;
> > +   bool dret = false, broken_edid = false, undefined_flag = false;
> >
> > if (!drm_kms_helper_is_poll_worker()) {
> > r = pm_runtime_get_sync(connector->dev->dev);
> > @@ -988,7 +988,12 @@ amdgpu_connector_dvi_detect(struct drm_connector 
> > *connector, bool force)
> >
> > if (amdgpu_connector->ddc_bus)
> > dret = amdgpu_display_ddc_probe(amdgpu_connector, false);
> > -   if (dret) {
> > +
> > +   /* Check the HDMI HPD pin status again */
> > +   if (!amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd))
> > +   undefined_flag = true;
> > +
> > +   if (dret && !undefined_flag) {
> > amdgpu_connector->detected_by_load = false;
> > amdgpu_connector_free_edid(connector);
> > amdgpu_connector_get_edid(connector);
> > --
> > 2.17.1
> >
> > ___
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


A curious phenomenon in HDMI hotplug.

2020-05-05 Thread Aaron Chou
Hi all:

I'm a newer about the amdgpu driver.
I have a question about it.
In my company, there are some experiments about HDMI hotplug.
First, I introduce the lab environment:
cpu: huawei kunpeng
os: uos
kernel: 4.19.90
video card: Radeon HD 700

the lab step is:
1, I connect the hdmi and vga with the expand mode;
2. I disconnect the hdmi connector, but the app display in the hdmi is
not back to vga, and the mode is still expand mode.

I found when I disconnect the hdmi connector, the sys files about HDMI
are keep the connection status.
Such as the value of /sys/class/drm/card0-HDMI-A-1/status is
connected, and I can read the edid file correctly.
At this moment, I use I2C driver to read the edid via /dev/i2c-X. I
can not get the edid value.

In kernel source ,I found the suspicious points in
amdgpu_connector_dvi_detect() (amdgpu_connector.c)

In amdgpu_connector_dvi_detect() function,
The hpd status was correctly through the amdgpu_display_hpd_sence(),
but the ddc probe operation is successed via
amdgpu_display_ddc_probe()

I am so confused.

Is it a normal behavior?

I have written a workaround patch to fix this problem.

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index c770d73352a7..4809ceb56f5e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -975,7 +975,7 @@ amdgpu_connector_dvi_detect(struct drm_connector
*connector, bool force)
const struct drm_encoder_helper_funcs *encoder_funcs;
int r;
enum drm_connector_status ret = connector_status_disconnected;
-   bool dret = false, broken_edid = false;
+   bool dret = false, broken_edid = false, unknown_status = false;

if (!drm_kms_helper_is_poll_worker()) {
r = pm_runtime_get_sync(connector->dev->dev);
@@ -990,7 +990,11 @@ amdgpu_connector_dvi_detect(struct drm_connector
*connector, bool force)

if (amdgpu_connector->ddc_bus)
dret = amdgpu_display_ddc_probe(amdgpu_connector, false);
-   if (dret) {
+
+   if (!amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd))
+   unknown_status = true;
+
+   if (dret && !unknown_status) {
amdgpu_connector->detected_by_load = false;
amdgpu_connector_free_edid(connector);
amdgpu_connector_get_edid(connector);

Is it correctly.

Best Wishes!

Aaron.
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx