Commit ffd26641 authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/disp: expose head event class



Also fixes vblank interrupts being left enabled when they're not meant
to be as a result of races/bugs in previous event handling code.

v2:
- use ?: (lyude)

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 1d4dce28
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -761,7 +761,7 @@ static void nv_crtc_destroy(struct drm_crtc *crtc)
	nouveau_bo_unmap(nv_crtc->cursor.nvbo);
	nouveau_bo_unpin(nv_crtc->cursor.nvbo);
	nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
	nvif_notify_dtor(&nv_crtc->vblank);
	nvif_event_dtor(&nv_crtc->vblank);
	nvif_head_dtor(&nv_crtc->head);
	kfree(nv_crtc);
}
@@ -1280,13 +1280,13 @@ static const struct drm_plane_funcs nv04_primary_plane_funcs = {
	DRM_PLANE_NON_ATOMIC_FUNCS,
};

static int nv04_crtc_vblank_handler(struct nvif_notify *notify)
static int
nv04_crtc_vblank_handler(struct nvif_event *event, void *repv, u32 repc)
{
	struct nouveau_crtc *nv_crtc =
		container_of(notify, struct nouveau_crtc, vblank);
	struct nouveau_crtc *nv_crtc = container_of(event, struct nouveau_crtc, vblank);

	drm_crtc_handle_vblank(&nv_crtc->base);
	return NVIF_NOTIFY_KEEP;
	return NVIF_EVENT_KEEP;
}

int
@@ -1346,14 +1346,6 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
	if (ret)
		return ret;

	ret = nvif_notify_ctor(&disp->disp.object, "kmsVbl", nv04_crtc_vblank_handler,
			       false, NV04_DISP_NTFY_VBLANK,
			       &(struct nvif_notify_head_req_v0) {
				    .head = nv_crtc->index,
			       },
			       sizeof(struct nvif_notify_head_req_v0),
			       sizeof(struct nvif_notify_head_rep_v0),
			       &nv_crtc->vblank);

	return ret;
	return nvif_head_vblank_event_ctor(&nv_crtc->head, "kmsVbl", nv04_crtc_vblank_handler,
					   false, &nv_crtc->vblank);
}
+7 −13
Original line number Diff line number Diff line
@@ -517,7 +517,7 @@ nv50_head_destroy(struct drm_crtc *crtc)
{
	struct nv50_head *head = nv50_head(crtc);

	nvif_notify_dtor(&head->base.vblank);
	nvif_event_dtor(&head->base.vblank);
	nvif_head_dtor(&head->base.head);
	nv50_lut_fini(&head->olut);
	drm_crtc_cleanup(crtc);
@@ -555,15 +555,15 @@ nvd9_head_func = {
	.late_register = nv50_head_late_register,
};

static int nv50_head_vblank_handler(struct nvif_notify *notify)
static int
nv50_head_vblank_handler(struct nvif_event *event, void *repv, u32 repc)
{
	struct nouveau_crtc *nv_crtc =
		container_of(notify, struct nouveau_crtc, vblank);
	struct nouveau_crtc *nv_crtc = container_of(event, struct nouveau_crtc, vblank);

	if (drm_crtc_handle_vblank(&nv_crtc->base))
		nv50_crc_handle_vblank(nv50_head(&nv_crtc->base));

	return NVIF_NOTIFY_KEEP;
	return NVIF_EVENT_KEEP;
}

struct nv50_head *
@@ -629,14 +629,8 @@ nv50_head_create(struct drm_device *dev, int index)
	if (ret)
		return ERR_PTR(ret);

	ret = nvif_notify_ctor(&disp->disp->object, "kmsVbl", nv50_head_vblank_handler,
			       false, NV04_DISP_NTFY_VBLANK,
			       &(struct nvif_notify_head_req_v0) {
				    .head = nv_crtc->index,
			       },
			       sizeof(struct nvif_notify_head_req_v0),
			       sizeof(struct nvif_notify_head_rep_v0),
			       &nv_crtc->vblank);
	ret = nvif_head_vblank_event_ctor(&head->base.head, "kmsVbl", nv50_head_vblank_handler,
					  false, &nv_crtc->vblank);
	if (ret)
		return ERR_PTR(ret);

+0 −1
Original line number Diff line number Diff line
@@ -2,6 +2,5 @@
#ifndef __NVIF_CL0046_H__
#define __NVIF_CL0046_H__

#define NV04_DISP_NTFY_VBLANK                                              0x00
#define NV04_DISP_NTFY_CONN                                                0x01
#endif
+0 −11
Original line number Diff line number Diff line
@@ -52,17 +52,6 @@ struct nvif_notify_rep_v0 {
	__u8  data[];	/* reply data (below) */
};

struct nvif_notify_head_req_v0 {
	/* nvif_notify_req ... */
	__u8  version;
	__u8  head;
	__u8  pad02[6];
};

struct nvif_notify_head_rep_v0 {
	/* nvif_notify_rep ... */
};

struct nvif_notify_conn_req_v0 {
	/* nvif_notify_req ... */
	__u8  version;
+10 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#ifndef __NVIF_HEAD_H__
#define __NVIF_HEAD_H__
#include <nvif/object.h>
#include <nvif/event.h>
struct nvif_disp;

struct nvif_head {
@@ -10,4 +11,13 @@ struct nvif_head {

int nvif_head_ctor(struct nvif_disp *, const char *name, int id, struct nvif_head *);
void nvif_head_dtor(struct nvif_head *);

static inline int
nvif_head_id(struct nvif_head *head)
{
	return head->object.handle;
}

int nvif_head_vblank_event_ctor(struct nvif_head *, const char *name, nvif_event_func, bool wait,
				struct nvif_event *);
#endif
Loading