All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH xf86-video-amdgpu 1/3] modesetting: Use helper to fetch drmModeProperty(Blob)s
@ 2018-02-22 17:52 Michel Dänzer
       [not found] ` <20180222175253.13842-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2018-02-22 17:52 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Daniel Martin <consume.noise@gmail.com>

Replace the various loops to lookup drmModeProperty(Blob)s by
introducing helper functions.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>

(Ported from xserver commit f44935cdb7321af242ce9f242975f096807b97f7)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 128 +++++++++++++++++++++++++++-----------------------
 1 file changed, 70 insertions(+), 58 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index db4f15c23..98d2039d0 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1402,6 +1402,51 @@ drmmode_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes)
 	return MODE_OK;
 }
 
+static int
+koutput_get_prop_idx(int fd, drmModeConnectorPtr koutput,
+        int type, const char *name)
+{
+    int idx = -1;
+
+    for (int i = 0; i < koutput->count_props; i++) {
+        drmModePropertyPtr prop = drmModeGetProperty(fd, koutput->props[i]);
+
+        if (!prop)
+            continue;
+
+        if (drm_property_type_is(prop, type) && !strcmp(prop->name, name))
+            idx = i;
+
+        drmModeFreeProperty(prop);
+
+        if (idx > -1)
+            break;
+    }
+
+    return idx;
+}
+
+static int
+koutput_get_prop_id(int fd, drmModeConnectorPtr koutput,
+        int type, const char *name)
+{
+    int idx = koutput_get_prop_idx(fd, koutput, type, name);
+
+    return (idx > -1) ? koutput->props[idx] : -1;
+}
+
+static drmModePropertyBlobPtr
+koutput_get_prop_blob(int fd, drmModeConnectorPtr koutput, const char *name)
+{
+    drmModePropertyBlobPtr blob = NULL;
+    int idx = koutput_get_prop_idx(fd, koutput, DRM_MODE_PROP_BLOB, name);
+
+    if (idx > -1)
+        blob = drmModeGetPropertyBlob(fd, koutput->prop_values[idx]);
+
+    return blob;
+}
+
 static DisplayModePtr drmmode_output_get_modes(xf86OutputPtr output)
 {
 	drmmode_output_private_ptr drmmode_output = output->driver_private;
@@ -1409,29 +1454,16 @@ static DisplayModePtr drmmode_output_get_modes(xf86OutputPtr output)
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(output->scrn);
 	int i;
 	DisplayModePtr Modes = NULL, Mode;
-	drmModePropertyPtr props;
 	xf86MonPtr mon = NULL;
 
 	if (!koutput)
 		return NULL;
 
+	drmModeFreePropertyBlob(drmmode_output->edid_blob);
+
 	/* look for an EDID property */
-	for (i = 0; i < koutput->count_props; i++) {
-		props = drmModeGetProperty(pAMDGPUEnt->fd, koutput->props[i]);
-		if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
-			if (!strcmp(props->name, "EDID")) {
-				if (drmmode_output->edid_blob)
-					drmModeFreePropertyBlob
-					    (drmmode_output->edid_blob);
-				drmmode_output->edid_blob =
-				    drmModeGetPropertyBlob(pAMDGPUEnt->fd,
-							   koutput->prop_values
-							   [i]);
-			}
-		}
-		if (props)
-			drmModeFreeProperty(props);
-	}
+	drmmode_output->edid_blob =
+		koutput_get_prop_blob(pAMDGPUEnt->fd, koutput, "EDID");
 
 	if (drmmode_output->edid_blob) {
 		mon = xf86InterpretEDID(output->scrn->scrnIndex,
@@ -1875,7 +1907,6 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 	drmModeConnectorPtr koutput;
 	drmModeEncoderPtr *kencoders = NULL;
 	drmmode_output_private_ptr drmmode_output;
-	drmModePropertyPtr props;
 	drmModePropertyBlobPtr path_blob = NULL;
 	char name[32];
 	int i;
@@ -1887,17 +1918,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 	if (!koutput)
 		return 0;
 
-	for (i = 0; i < koutput->count_props; i++) {
-		props = drmModeGetProperty(pAMDGPUEnt->fd, koutput->props[i]);
-		if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
-			if (!strcmp(props->name, "PATH")) {
-				path_blob = drmModeGetPropertyBlob(pAMDGPUEnt->fd, koutput->prop_values[i]);
-				drmModeFreeProperty(props);
-				break;
-			}
-		}
-		drmModeFreeProperty(props);
-	}
+	path_blob = koutput_get_prop_blob(pAMDGPUEnt->fd, koutput, "PATH");
 
 	kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
 	if (!kencoders) {
@@ -1981,18 +2002,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 	/* work out the possible clones later */
 	output->possible_clones = 0;
 
-	for (i = 0; i < koutput->count_props; i++) {
-		props = drmModeGetProperty(pAMDGPUEnt->fd, koutput->props[i]);
-		if (props && (props->flags & DRM_MODE_PROP_ENUM)) {
-			if (!strcmp(props->name, "DPMS")) {
-				drmmode_output->dpms_enum_id =
-				    koutput->props[i];
-				drmModeFreeProperty(props);
-				break;
-			}
-		}
-		drmModeFreeProperty(props);
-	}
+	drmmode_output->dpms_enum_id =
+		koutput_get_prop_id(pAMDGPUEnt->fd, koutput, DRM_MODE_PROP_ENUM,
+				    "DPMS");
 
 	if (dynamic) {
 		output->randr_output = RROutputCreate(xf86ScrnToScreen(pScrn), output->name, strlen(output->name), output);
@@ -2693,7 +2705,7 @@ amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 		xf86OutputPtr output = config->output[i];
 		xf86CrtcPtr crtc = output->crtc;
 		drmmode_output_private_ptr drmmode_output = output->driver_private;
-		uint32_t con_id;
+		uint32_t con_id, idx;
 		drmModeConnectorPtr koutput;
 
 		if (!crtc || !drmmode_output->mode_output)
@@ -2704,22 +2716,22 @@ amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 		 * look for the link-status property
 		 */
 		koutput = drmModeGetConnectorCurrent(pAMDGPUEnt->fd, con_id);
-		for (j = 0; koutput && j < koutput->count_props; j++) {
-			drmModePropertyPtr props;
-			props = drmModeGetProperty(pAMDGPUEnt->fd, koutput->props[j]);
-			if (props && props->flags & DRM_MODE_PROP_ENUM &&
-			    !strcmp(props->name, "link-status") &&
-			    koutput->prop_values[j] == DRM_MODE_LINK_STATUS_BAD) {
-				/* the connector got a link failure, re-set the current mode */
-				drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
-						       crtc->x, crtc->y);
-
-				xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-					   "hotplug event: connector %u's link-state is BAD, "
-					   "tried resetting the current mode. You may be left "
-					   "with a black screen if this fails...\n", con_id);
-			}
-			drmModeFreeProperty(props);
+		if (!koutput)
+			continue;
+
+		idx = koutput_get_prop_idx(pAMDGPUEnt->fd, koutput,
+					   DRM_MODE_PROP_ENUM, "link-status");
+
+		if ((idx > -1) &&
+		    (koutput->prop_values[idx] == DRM_MODE_LINK_STATUS_BAD)) {
+			/* the connector got a link failure, re-set the current mode */
+			drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
+					       crtc->x, crtc->y);
+
+			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+				   "hotplug event: connector %u's link-state is BAD, "
+				   "tried resetting the current mode. You may be left"
+				   "with a black screen if this fails...\n", con_id);
 		}
 		drmModeFreeConnector(koutput);
 	}
-- 
2.16.1

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH xf86-video-amdgpu 2/3] modesetting: Reset output_id if drmModeGetConnector failed
       [not found] ` <20180222175253.13842-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2018-02-22 17:52   ` Michel Dänzer
  2018-02-22 17:52   ` [PATCH xf86-video-amdgpu 3/3] modesetting: Update property values at detect and uevent time Michel Dänzer
  1 sibling, 0 replies; 4+ messages in thread
From: Michel Dänzer @ 2018-02-22 17:52 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Daniel Martin <consume.noise@gmail.com>

If drmModeGetConnector() fails in drmmode_output_detect(), we have to
reset the output_id to -1 too.

Yet another spot leading to a potential NULL dereference when handling
the mode_output member as output_id was != -1. Though, this case should
be very hard to hit.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>

(Ported from xserver commit 6804875662363764683a86c1614e4cf3cc70a20a)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 98d2039d0..a90fdb642 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1378,8 +1378,10 @@ static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
 
 	drmmode_output->mode_output =
 	    drmModeGetConnector(pAMDGPUEnt->fd, drmmode_output->output_id);
-	if (!drmmode_output->mode_output)
+	if (!drmmode_output->mode_output) {
+		drmmode_output->output_id = -1;
 		return XF86OutputStatusDisconnected;
+	}
 
 	switch (drmmode_output->mode_output->connection) {
 	case DRM_MODE_CONNECTED:
-- 
2.16.1

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH xf86-video-amdgpu 3/3] modesetting: Update property values at detect and uevent time
       [not found] ` <20180222175253.13842-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  2018-02-22 17:52   ` [PATCH xf86-video-amdgpu 2/3] modesetting: Reset output_id if drmModeGetConnector failed Michel Dänzer
@ 2018-02-22 17:52   ` Michel Dänzer
       [not found]     ` <20180222175253.13842-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2018-02-22 17:52 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Keith Packard <keithp@keithp.com>

We were updating the link-status property when a uevent came in, but
we also want to update the non-desktop property, and potentially
others as well. We also want to check at detect time in case we don't
get a hotplug event.

This patch updates every property provided by the kernel, sending
changes to DIX so it can track things as well.

Signed-off-by: Keith Packard <keithp@keithp.com>

(Ported from xserver commit a12485ed846b852ca14d17d1e58c8b0f2399e577,
 slightly modifying logic to reduce indentation depth)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 104 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 86 insertions(+), 18 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index a90fdb642..746e52aa7 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1368,6 +1368,72 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
 	return 1;
 }
 
+/*
+ * Update all of the property values for an output
+ */
+static void
+drmmode_output_update_properties(xf86OutputPtr output)
+{
+	drmmode_output_private_ptr drmmode_output = output->driver_private;
+	int i, j, k;
+	int err;
+	drmModeConnectorPtr koutput;
+
+	/* Use the most recently fetched values from the kernel */
+	koutput = drmmode_output->mode_output;
+
+	if (!koutput)
+		return;
+
+	for (i = 0; i < drmmode_output->num_props; i++) {
+		drmmode_prop_ptr p = &drmmode_output->props[i];
+
+		for (j = 0; j < koutput->count_props; j++) {
+			if (koutput->props[j] != p->mode_prop->prop_id)
+				continue;
+
+			/* Check to see if the property value has changed */
+			if (koutput->prop_values[j] == p->value)
+				break;
+
+			p->value = koutput->prop_values[j];
+
+			if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) {
+				INT32 value = p->value;
+
+				err = RRChangeOutputProperty(output->randr_output,
+							     p->atoms[0], XA_INTEGER,
+							     32, PropModeReplace, 1,
+							     &value, FALSE, TRUE);
+				if (err != 0) {
+					xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+						   "RRChangeOutputProperty error, %d\n",
+						   err);
+				}
+			} else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
+				for (k = 0; k < p->mode_prop->count_enums; k++) {
+					if (p->mode_prop->enums[k].value == p->value)
+						break;
+				}
+				if (k < p->mode_prop->count_enums) {
+					err = RRChangeOutputProperty(output->randr_output,
+								     p->atoms[0], XA_ATOM,
+								     32, PropModeReplace, 1,
+								     &p->atoms[k + 1], FALSE,
+								     TRUE);
+					if (err != 0) {
+						xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+							   "RRChangeOutputProperty error, %d\n",
+							   err);
+					}
+				}
+			}
+
+			break;
+		}
+        }
+}
+
 static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
 {
 	/* go to the hw and retrieve a new output struct */
@@ -1383,6 +1449,8 @@ static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
 		return XF86OutputStatusDisconnected;
 	}
 
+	drmmode_output_update_properties(output);
+
 	switch (drmmode_output->mode_output->connection) {
 	case DRM_MODE_CONNECTED:
 		status = XF86OutputStatusConnected;
@@ -2707,35 +2775,35 @@ amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 		xf86OutputPtr output = config->output[i];
 		xf86CrtcPtr crtc = output->crtc;
 		drmmode_output_private_ptr drmmode_output = output->driver_private;
-		uint32_t con_id, idx;
-		drmModeConnectorPtr koutput;
+
+		drmmode_output_detect(output);
 
 		if (!crtc || !drmmode_output->mode_output)
 			continue;
 
-		con_id = drmmode_output->mode_output->connector_id;
 		/* Get an updated view of the properties for the current connector and
 		 * look for the link-status property
 		 */
-		koutput = drmModeGetConnectorCurrent(pAMDGPUEnt->fd, con_id);
-		if (!koutput)
-			continue;
+		for (j = 0; j < drmmode_output->num_props; j++) {
+			drmmode_prop_ptr p = &drmmode_output->props[j];
 
-		idx = koutput_get_prop_idx(pAMDGPUEnt->fd, koutput,
-					   DRM_MODE_PROP_ENUM, "link-status");
+			if (!strcmp(p->mode_prop->name, "link-status")) {
+				if (p->value != DRM_MODE_LINK_STATUS_BAD)
+					break;
 
-		if ((idx > -1) &&
-		    (koutput->prop_values[idx] == DRM_MODE_LINK_STATUS_BAD)) {
-			/* the connector got a link failure, re-set the current mode */
-			drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
-					       crtc->x, crtc->y);
+				/* the connector got a link failure, re-set the current mode */
+				drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
+						       crtc->x, crtc->y);
 
-			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "hotplug event: connector %u's link-state is BAD, "
-				   "tried resetting the current mode. You may be left"
-				   "with a black screen if this fails...\n", con_id);
+				xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+					   "hotplug event: connector %u's link-state is BAD, "
+					   "tried resetting the current mode. You may be left"
+					   "with a black screen if this fails...\n",
+					   drmmode_output->mode_output->connector_id);
+
+				break;
+			}
 		}
-		drmModeFreeConnector(koutput);
 	}
 
 	mode_res = drmModeGetResources(pAMDGPUEnt->fd);
-- 
2.16.1

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH xf86-video-amdgpu 3/3] modesetting: Update property values at detect and uevent time
       [not found]     ` <20180222175253.13842-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2018-02-23  5:17       ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2018-02-23  5:17 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: amd-gfx list

On Thu, Feb 22, 2018 at 12:52 PM, Michel Dänzer <michel@daenzer.net> wrote:
> From: Keith Packard <keithp@keithp.com>
>
> We were updating the link-status property when a uevent came in, but
> we also want to update the non-desktop property, and potentially
> others as well. We also want to check at detect time in case we don't
> get a hotplug event.
>
> This patch updates every property provided by the kernel, sending
> changes to DIX so it can track things as well.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
>
> (Ported from xserver commit a12485ed846b852ca14d17d1e58c8b0f2399e577,
>  slightly modifying logic to reduce indentation depth)
>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  src/drmmode_display.c | 104 +++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 86 insertions(+), 18 deletions(-)
>
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index a90fdb642..746e52aa7 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -1368,6 +1368,72 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
>         return 1;
>  }
>
> +/*
> + * Update all of the property values for an output
> + */
> +static void
> +drmmode_output_update_properties(xf86OutputPtr output)
> +{
> +       drmmode_output_private_ptr drmmode_output = output->driver_private;
> +       int i, j, k;
> +       int err;
> +       drmModeConnectorPtr koutput;
> +
> +       /* Use the most recently fetched values from the kernel */
> +       koutput = drmmode_output->mode_output;
> +
> +       if (!koutput)
> +               return;
> +
> +       for (i = 0; i < drmmode_output->num_props; i++) {
> +               drmmode_prop_ptr p = &drmmode_output->props[i];
> +
> +               for (j = 0; j < koutput->count_props; j++) {
> +                       if (koutput->props[j] != p->mode_prop->prop_id)
> +                               continue;
> +
> +                       /* Check to see if the property value has changed */
> +                       if (koutput->prop_values[j] == p->value)
> +                               break;
> +
> +                       p->value = koutput->prop_values[j];
> +
> +                       if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) {
> +                               INT32 value = p->value;
> +
> +                               err = RRChangeOutputProperty(output->randr_output,
> +                                                            p->atoms[0], XA_INTEGER,
> +                                                            32, PropModeReplace, 1,
> +                                                            &value, FALSE, TRUE);
> +                               if (err != 0) {
> +                                       xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
> +                                                  "RRChangeOutputProperty error, %d\n",
> +                                                  err);
> +                               }
> +                       } else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
> +                               for (k = 0; k < p->mode_prop->count_enums; k++) {
> +                                       if (p->mode_prop->enums[k].value == p->value)
> +                                               break;
> +                               }
> +                               if (k < p->mode_prop->count_enums) {
> +                                       err = RRChangeOutputProperty(output->randr_output,
> +                                                                    p->atoms[0], XA_ATOM,
> +                                                                    32, PropModeReplace, 1,
> +                                                                    &p->atoms[k + 1], FALSE,
> +                                                                    TRUE);
> +                                       if (err != 0) {
> +                                               xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
> +                                                          "RRChangeOutputProperty error, %d\n",
> +                                                          err);
> +                                       }
> +                               }
> +                       }
> +
> +                       break;
> +               }
> +        }
> +}
> +
>  static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
>  {
>         /* go to the hw and retrieve a new output struct */
> @@ -1383,6 +1449,8 @@ static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
>                 return XF86OutputStatusDisconnected;
>         }
>
> +       drmmode_output_update_properties(output);
> +
>         switch (drmmode_output->mode_output->connection) {
>         case DRM_MODE_CONNECTED:
>                 status = XF86OutputStatusConnected;
> @@ -2707,35 +2775,35 @@ amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode)
>                 xf86OutputPtr output = config->output[i];
>                 xf86CrtcPtr crtc = output->crtc;
>                 drmmode_output_private_ptr drmmode_output = output->driver_private;
> -               uint32_t con_id, idx;
> -               drmModeConnectorPtr koutput;
> +
> +               drmmode_output_detect(output);
>
>                 if (!crtc || !drmmode_output->mode_output)
>                         continue;
>
> -               con_id = drmmode_output->mode_output->connector_id;
>                 /* Get an updated view of the properties for the current connector and
>                  * look for the link-status property
>                  */
> -               koutput = drmModeGetConnectorCurrent(pAMDGPUEnt->fd, con_id);
> -               if (!koutput)
> -                       continue;
> +               for (j = 0; j < drmmode_output->num_props; j++) {
> +                       drmmode_prop_ptr p = &drmmode_output->props[j];
>
> -               idx = koutput_get_prop_idx(pAMDGPUEnt->fd, koutput,
> -                                          DRM_MODE_PROP_ENUM, "link-status");
> +                       if (!strcmp(p->mode_prop->name, "link-status")) {
> +                               if (p->value != DRM_MODE_LINK_STATUS_BAD)
> +                                       break;
>
> -               if ((idx > -1) &&
> -                   (koutput->prop_values[idx] == DRM_MODE_LINK_STATUS_BAD)) {
> -                       /* the connector got a link failure, re-set the current mode */
> -                       drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
> -                                              crtc->x, crtc->y);
> +                               /* the connector got a link failure, re-set the current mode */
> +                               drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
> +                                                      crtc->x, crtc->y);
>
> -                       xf86DrvMsg(scrn->scrnIndex, X_WARNING,
> -                                  "hotplug event: connector %u's link-state is BAD, "
> -                                  "tried resetting the current mode. You may be left"
> -                                  "with a black screen if this fails...\n", con_id);
> +                               xf86DrvMsg(scrn->scrnIndex, X_WARNING,
> +                                          "hotplug event: connector %u's link-state is BAD, "
> +                                          "tried resetting the current mode. You may be left"
> +                                          "with a black screen if this fails...\n",
> +                                          drmmode_output->mode_output->connector_id);
> +
> +                               break;
> +                       }
>                 }
> -               drmModeFreeConnector(koutput);
>         }
>
>         mode_res = drmModeGetResources(pAMDGPUEnt->fd);
> --
> 2.16.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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-23  5:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 17:52 [PATCH xf86-video-amdgpu 1/3] modesetting: Use helper to fetch drmModeProperty(Blob)s Michel Dänzer
     [not found] ` <20180222175253.13842-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-02-22 17:52   ` [PATCH xf86-video-amdgpu 2/3] modesetting: Reset output_id if drmModeGetConnector failed Michel Dänzer
2018-02-22 17:52   ` [PATCH xf86-video-amdgpu 3/3] modesetting: Update property values at detect and uevent time Michel Dänzer
     [not found]     ` <20180222175253.13842-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-02-23  5:17       ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.