[PATCH v15 34/34] drm debug

Ucan, Emre (ADITG/ESB) eucan at de.adit-jv.com
Tue Feb 6 07:29:41 UTC 2018


Hi,

Did you send this patch erroneously ? Weston will print out lots of logs after this patch.

Best regards

Emre Ucan
Engineering Software Base (ADITG/ESB)

Tel. +49 5121 49 6937

> -----Original Message-----
> From: wayland-devel [mailto:wayland-devel-
> bounces at lists.freedesktop.org] On Behalf Of Daniel Stone
> Sent: Montag, 5. Februar 2018 19:47
> To: wayland-devel at lists.freedesktop.org
> Subject: [PATCH v15 34/34] drm debug
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  libweston/compositor-drm.c | 59
> ++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 55 insertions(+), 4 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 48ce19c09..db9dc3cbe 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -876,14 +876,20 @@ drm_fb_addfb(struct drm_fb *fb)
>  	int i;
>  #endif
> 
> +	weston_log("addfb %d x %d: mod 0x%lux\n", fb->width, fb->height,
> fb->modifier);
> +
>  	/* If we have a modifier set, we must only use the WithModifiers
>  	 * entrypoint; we cannot import it through legacy ioctls. */
>  	if (fb->modifier != DRM_FORMAT_MOD_INVALID) {
>  		/* KMS demands that if a modifier is set, it must be the same
>  		 * for all planes. */
>  #ifdef HAVE_DRM_ADDFB2_MODIFIERS
> -		for (i = 0; i < (int) ARRAY_LENGTH(mods) && fb->handles[i];
> i++)
> +		for (i = 0; i < (int) ARRAY_LENGTH(mods) && fb->handles[i];
> i++) {
> +			weston_log("handle %d: %d, offset %d, stride
> %d\n", i, fb->handles[i], fb->offsets[i], fb->strides[i]);
>  			mods[i] = fb->modifier;
> +		}
> +		if (fb->modifier != DRM_FORMAT_MOD_INVALID)
> +			weston_log("modifier: 0x%lx\n", fb->modifier);
>  		ret = drmModeAddFB2WithModifiers(fb->fd, fb->width, fb-
> >height,
>  						 fb->format->format,
>  						 fb->handles, fb->strides,
> @@ -1053,6 +1059,7 @@ drm_fb_get_from_dmabuf(struct
> linux_dmabuf_buffer *dmabuf,
>  	memcpy(import_mod.offsets, dmabuf->attributes.offset,
>  	       sizeof(import_mod.fds));
> 
> +	weston_log("dmabuf modifier: 0x%lx\n", dmabuf-
> >attributes.modifier[0]);
>  	if (dmabuf->attributes.modifier[0] !=
> DRM_FORMAT_MOD_INVALID) {
>  		fb->bo = gbm_bo_import(backend->gbm,
> GBM_BO_IMPORT_FD_MODIFIER,
>  				       &import_mod,
> @@ -1099,7 +1106,7 @@ drm_fb_get_from_dmabuf(struct
> linux_dmabuf_buffer *dmabuf,
>  	}
> 
>  	if (drm_fb_addfb(fb) != 0) {
> -		weston_log("failed to create kms fb: %m\n");
> +		weston_log("failed to create dmabuf kms fb: %m\n");
>  		goto err_free;
>  	}
> 
> @@ -1170,7 +1177,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct
> drm_backend *backend,
>  	}
> 
>  	if (drm_fb_addfb(fb) != 0) {
> -		weston_log("failed to create kms fb: %m\n");
> +		weston_log("failed to create GBM kms fb: %m\n");
>  		goto err_free;
>  	}
> 
> @@ -1436,12 +1443,15 @@ drm_fb_get_from_view(struct
> drm_output_state *state, struct weston_view *ev)
> 
>  	dmabuf = linux_dmabuf_buffer_get(buffer->resource);
>  	if (dmabuf) {
> +		weston_log("want dmabuf for %d x %d\n", buffer->width,
> buffer->height);
>  		fb = drm_fb_get_from_dmabuf(dmabuf, b, is_opaque);
>  		if (!fb)
>  			return NULL;
>  	} else {
>  		struct gbm_bo *bo;
> 
> +		weston_log("want plain GBM for %d x %d\n", buffer->width,
> buffer->height);
> +
>  		if (!b->gbm)
>  			return NULL;
> 
> @@ -1506,6 +1516,7 @@ drm_output_state_alloc(struct drm_output
> *output,
>  	struct drm_output_state *state = zalloc(sizeof(*state));
> 
>  	assert(state);
> +	weston_log("%s: allocating output state\n", output->base.name);
>  	state->output = output;
>  	state->dpms = WESTON_DPMS_OFF;
>  	state->pending_state = pending_state;
> @@ -1722,6 +1733,7 @@ drm_output_update_complete(struct drm_output
> *output, uint32_t flags,
>  		struct drm_pending_state *pending =
> drm_pending_state_alloc(b);
>  		output->dpms_off_pending = 0;
>  		drm_output_get_disable_state(pending, output);
> +		weston_log("%s (con %d, crtc %d): applying DPMS off %p\n",
> output->base.name, output->connector_id, output->crtc_id, pending);
>  		drm_pending_state_apply_sync(pending);
>  		return;
>  	} else if (output->state_cur->dpms == WESTON_DPMS_OFF &&
> @@ -1731,11 +1743,14 @@ drm_output_update_complete(struct
> drm_output *output, uint32_t flags,
>  		 * away for DPMS off), or at any other random point. If the
>  		 * latter is true, then we cannot go through finish_frame,
>  		 * because the repaint machinery does not expect this. */
> +		weston_log("%s: DPMS off complete, outside repaint
> loop\n",
> +			   output->base.name);
>  		return;
>  	}
> 
>  	ts.tv_sec = sec;
>  	ts.tv_nsec = usec * 1000;
> +	weston_log("%s: finish_frame (update_complete)\n", output-
> >base.name);
>  	weston_output_finish_frame(&output->base, &ts, flags);
> 
>  	/* We can't call this from frame_notify, because the output's
> @@ -1758,6 +1773,7 @@ drm_output_assign_state(struct
> drm_output_state *state,
>  	struct drm_backend *b = to_drm_backend(output-
> >base.compositor);
>  	struct drm_plane_state *plane_state;
> 
> +	weston_log("[%s] assign_state, state_last is %p\n", output-
> >base.name, output->state_last);
>  	assert(!output->state_last);
> 
>  	if (mode == DRM_STATE_APPLY_ASYNC)
> @@ -2090,8 +2106,10 @@ drm_output_apply_state_legacy(struct
> drm_output_state *state)
>  		if (ret)
>  			weston_log("drmModeSetCrtc failed disabling:
> %m\n");
> 
> +		weston_log("[%s] sync assign_state %p from legacy DPMS
> OFF\n", output->base.name, state);
>  		drm_output_assign_state(state, DRM_STATE_APPLY_SYNC);
>  		weston_compositor_read_presentation_clock(output-
> >base.compositor, &now);
> +		weston_log("%s: finish_frame (legacy disable, sync)\n",
> output->base.name);
>  		drm_output_update_complete(output,
> 
> WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION,
>  					   now.tv_sec, now.tv_nsec / 1000);
> @@ -2129,6 +2147,8 @@ drm_output_apply_state_legacy(struct
> drm_output_state *state)
>  			weston_log("set mode failed: %m\n");
>  			goto err;
>  		}
> +	} else {
> +		weston_log("%s: legacy SetCrtc to kickstart\n", output-
> >base.name);
>  	}
> 
>  	if (drmModePageFlip(backend->drm.fd, output->crtc_id,
> @@ -2137,6 +2157,7 @@ drm_output_apply_state_legacy(struct
> drm_output_state *state)
>  		weston_log("queueing pageflip failed: %m\n");
>  		goto err;
>  	}
> +	weston_log("%s: flipped to buffer %d, %d x %d\n", output-
> >base.name, scanout_state->fb ? scanout_state->fb->fb_id : 0,
> scanout_state->dest_w, scanout_state->dest_h);
> 
>  	assert(!output->page_flip_pending);
> 
> @@ -2179,6 +2200,7 @@ drm_output_apply_state_legacy(struct
> drm_output_state *state)
>  		if (ret)
>  			weston_log("setplane failed: %d: %s\n",
>  				ret, strerror(errno));
> +		weston_log("%s: plane %d -> buffer %d, %d x %d (+%d
> %d)\n", output->base.name, p->plane_id, fb_id, ps->dest_w, ps->dest_h,
> ps->dest_x, ps->dest_y);
> 
>  		vbl.request.type |= drm_waitvblank_pipe(output);
> 
> @@ -2199,12 +2221,14 @@ drm_output_apply_state_legacy(struct
> drm_output_state *state)
>  						  output->connector_id,
>  						  dpms_prop->prop_id,
>  						  state->dpms);
> +		weston_log("%s: set DPMS prop to %d\n", output-
> >base.name, state->dpms);
>  		if (ret) {
>  			weston_log("DRM: DPMS: failed property set for
> %s\n",
>  				   output->base.name);
>  		}
>  	}
> 
> +	weston_log("[%s] assign async state %p from legacy on\n", output-
> >base.name, state);
>  	drm_output_assign_state(state, DRM_STATE_APPLY_ASYNC);
> 
>  	return 0;
> @@ -2294,6 +2318,7 @@ drm_output_apply_state_atomic(struct
> drm_output_state *state,
>  		*flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
> 
>  	if (state->dpms == WESTON_DPMS_ON) {
> +		weston_log("%s (con %d, crtc %d, flags 0x%x): applying
> output state: alive!\n", output->base.name, output->connector_id, output-
> >crtc_id, *flags);
>  		ret = drm_mode_ensure_blob(backend, current_mode);
>  		if (ret != 0)
>  			return ret;
> @@ -2304,6 +2329,7 @@ drm_output_apply_state_atomic(struct
> drm_output_state *state,
>  		ret |= connector_add_prop(req, output,
> WDRM_CONNECTOR_CRTC_ID,
>  					  output->crtc_id);
>  	} else {
> +		weston_log("%s (con %d, crtc %d): applying output state:
> DPMS OFF\n", output->base.name, output->connector_id, output->crtc_id);
>  		ret |= crtc_add_prop(req, output, WDRM_CRTC_MODE_ID,
> 0);
>  		ret |= crtc_add_prop(req, output, WDRM_CRTC_ACTIVE, 0);
>  		ret |= connector_add_prop(req, output,
> WDRM_CONNECTOR_CRTC_ID,
> @@ -2318,6 +2344,9 @@ drm_output_apply_state_atomic(struct
> drm_output_state *state,
>  	wl_list_for_each(plane_state, &state->plane_list, link) {
>  		struct drm_plane *plane = plane_state->plane;
> 
> +		if (plane_state->fb) {
> +			weston_log("%s: plane (%d, %d) -> (%d, %d) @ (%d,
> %d) %s\n", output->base.name, plane_state->src_w >> 16, plane_state-
> >src_h >> 16, plane_state->dest_w, plane_state->dest_h, plane_state-
> >dest_x, plane_state->dest_y, (plane_state->fb->type ==
> BUFFER_GBM_SURFACE) ? "gbm" : (plane_state->fb->type ==
> BUFFER_CLIENT) ? "client" : "other");
> +		}
>  		ret |= plane_add_prop(req, plane, WDRM_PLANE_FB_ID,
>  				      plane_state->fb ? plane_state->fb->fb_id
> : 0);
>  		ret |= plane_add_prop(req, plane, WDRM_PLANE_CRTC_ID,
> @@ -2393,6 +2422,8 @@ drm_pending_state_apply_atomic(struct
> drm_pending_state *pending_state,
>  						   props);
>  			drmModeFreeObjectProperties(props);
> 
> +			weston_log("disabling connector %d\n", *unused);
> +
>  			info = &infos[WDRM_CONNECTOR_CRTC_ID];
>  			err = drmModeAtomicAddProperty(req, *unused,
>  						       info->prop_id, 0);
> @@ -2442,6 +2473,8 @@ drm_pending_state_apply_atomic(struct
> drm_pending_state *pending_state,
>  				continue;
>  			}
> 
> +			weston_log("disabling crtc %d\n", *unused);
> +
>  			err = drmModeAtomicAddProperty(req, *unused,
>  						       info->prop_id, 0);
>  			if (err <= 0)
> @@ -2499,8 +2532,10 @@ drm_pending_state_apply_atomic(struct
> drm_pending_state *pending_state,
>  	}
> 
>  	wl_list_for_each_safe(output_state, tmp, &pending_state-
> >output_list,
> -			      link)
> +			      link) {
> +		weston_log("[%s] assign atomic async state %p\n",
> output_state->output->base.name, output_state);
>  		drm_output_assign_state(output_state, mode);
> +	}
> 
>  	b->state_invalid = false;
> 
> @@ -2699,6 +2734,7 @@ drm_output_start_repaint_loop(struct
> weston_output *output_base)
> 
>  	if (!output->scanout_plane->state_cur->fb) {
>  		/* We can't page flip if there's no mode set */
> +		weston_log("[%s] finish_frame (no fb)\n", output_base-
> >name);
>  		goto finish_frame;
>  	}
> 
> @@ -2730,6 +2766,7 @@ drm_output_start_repaint_loop(struct
> weston_output *output_base)
>  			millihz_to_nsec(output->base.current_mode-
> >refresh);
>  		if (timespec_to_nsec(&vbl2now) < refresh_nsec) {
>  			drm_output_update_msc(output,
> vbl.reply.sequence);
> +			weston_log("%s: finish frame (vblank paint-start)\n",
> output_base->name);
>  			weston_output_finish_frame(output_base, &ts,
> 
> 	WP_PRESENTATION_FEEDBACK_INVALID);
>  			return;
> @@ -2757,6 +2794,7 @@ drm_output_start_repaint_loop(struct
> weston_output *output_base)
> 
>  finish_frame:
>  	/* if we cannot page-flip, immediately finish frame */
> +	weston_log("%s: finish frame (no-time fallback)\n", output_base-
> >name);
>  	weston_output_finish_frame(output_base, NULL,
>  				   WP_PRESENTATION_FEEDBACK_INVALID);
>  }
> @@ -2807,6 +2845,7 @@ page_flip_handler(int fd, unsigned int frame,
> 
> WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
>  			 WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
> 
> +	weston_log("%s: flip complete\n", output->base.name);
>  	drm_output_update_msc(output, frame);
> 
>  	assert(!b->atomic_modeset);
> @@ -2884,6 +2923,8 @@ atomic_flip_handler(int fd, unsigned int frame,
> unsigned int sec,
> 
> WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
>  			 WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
> 
> +	weston_log("atomic flip handler: crtc %d\n", crtc_id);
> +
>  	/* During the initial modeset, we can disable CRTCs which we don't
>  	 * actually handle during normal operation; this will give us events
>  	 * for unknown outputs. Ignore them. */
> @@ -3208,6 +3249,7 @@ drm_output_propose_state(struct weston_output
> *output_base,
>  		}
>  	}
> 
> +	weston_log("[%s] propose state, last %p\n", output->base.name,
> output->state_last);
>  	assert(!output->state_last);
>  	state = drm_output_state_duplicate(output->state_cur,
>  					   pending_state,
> @@ -3725,9 +3767,13 @@ populate_format_modifiers(struct drm_plane
> *plane, const drmModePlane *kplane,
>  		uint32_t count_modifiers = 0;
>  		uint64_t *modifiers = NULL;
> 
> +                weston_log("format 0x%x: idx %d\n", blob_formats[i], i);
> +
>  		for (j = 0; j < fmt_mod_blob->count_modifiers; j++) {
>  			struct drm_format_modifier *mod =
> &blob_modifiers[j];
> 
> +			weston_log("    mod 0x%llx, offset %d, format mask
> 0x%llx\n", mod->modifier, mod->offset, mod->formats);
> +
>  			if ((i < mod->offset) || (i > mod->offset + 63))
>  				continue;
>  			if (!(mod->formats & (1 << (i - mod->offset))))
> @@ -4177,6 +4223,8 @@ drm_set_dpms(struct weston_output
> *output_base, enum dpms_enum level)
>  	struct drm_output_state *state;
>  	int ret;
> 
> +	weston_log("%s: set_dpms called %d, ps %p, cur %d\n",
> output_base->name, level, pending_state, output->state_cur->dpms);
> +
>  	if (output->state_cur->dpms == level)
>  		return;
> 
> @@ -4200,6 +4248,7 @@ drm_set_dpms(struct weston_output
> *output_base, enum dpms_enum level)
>  		if (state)
>  			drm_output_state_free(state);
>  		state = drm_output_get_disable_state(pending_state,
> output);
> +		weston_log("%s (con %d, crtc %d): replaced with disable
> state %p\n", output->base.name, output->connector_id, output->crtc_id,
> state);
>  		return;
>  	}
> 
> @@ -4208,6 +4257,7 @@ drm_set_dpms(struct weston_output
> *output_base, enum dpms_enum level)
>  	if (level == WESTON_DPMS_ON) {
>  		if (output->dpms_off_pending)
>  			output->dpms_off_pending = 0;
> +		weston_log("requesting repaint\n");
>  		weston_output_schedule_repaint(output_base);
>  		return;
>  	}
> @@ -4225,6 +4275,7 @@ drm_set_dpms(struct weston_output
> *output_base, enum dpms_enum level)
>  	pending_state = drm_pending_state_alloc(b);
>  	drm_output_get_disable_state(pending_state, output);
>  	ret = drm_pending_state_apply(pending_state);
> +	weston_log("%s (con %d, crtc %d): applied disable state\n", output-
> >base.name, output->connector_id, output->crtc_id);
>  	if (ret != 0)
>  		weston_log("drm_set_dpms: couldn't disable output?\n");
>  }
> --
> 2.14.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list