xf86-video-intel: 7 commits - src/sna/blt.c src/sna/kgem.c src/sna/sna_display.c src/sna/sna_dri2.c src/sna/sna_driver.c src/sna/sna.h src/sna/sna_present.c src/sna/sna_video.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 1 18:15:31 UTC 2023


 src/sna/blt.c         |    2 -
 src/sna/kgem.c        |    2 -
 src/sna/sna.h         |    2 -
 src/sna/sna_display.c |   79 +++++---------------------------------------------
 src/sna/sna_dri2.c    |    7 ++--
 src/sna/sna_driver.c  |   12 ++-----
 src/sna/sna_present.c |   67 ++++++++++++++++++------------------------
 src/sna/sna_video.h   |    5 ++-
 8 files changed, 54 insertions(+), 122 deletions(-)

New commits:
commit b74b67f0f321875492968f7097b9d6e82a66d7df
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Fri Oct 28 08:42:40 2022 +0300

    sna: Shut up enum warns
    
    The libdrm enum usage is a mess, and modern gcc is unhappy about
    the implicit conversions:
    ../src/sna/sna_present.c:229:26: warning: implicit conversion from ‘enum <anonymous>’ to ‘enum drm_vblank_seq_type’ [-Wenum-conversion]
    
    Just cast to an integer type to silence the warns.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index b86dc97e..96be088a 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -226,7 +226,7 @@ static CARD32 sna_fake_vblank_handler(OsTimerPtr timer, CARD32 now, void *data)
 	assert(info->queued);
 
 	VG_CLEAR(vbl);
-	vbl.request.type = DRM_VBLANK_RELATIVE;
+	vbl.request.type = (uint32_t)DRM_VBLANK_RELATIVE;
 	vbl.request.sequence = 0;
 	if (sna_wait_vblank(info->sna, &vbl, sna_crtc_pipe(info->crtc)) == 0) {
 		ust = ust64(vbl.reply.tval_sec, vbl.reply.tval_usec);
@@ -261,7 +261,7 @@ static CARD32 sna_fake_vblank_handler(OsTimerPtr timer, CARD32 now, void *data)
 			 * Less than a millisecond for (hopefully) a rare case.
 			 */
 			DBG(("%s: blocking wait!\n", __FUNCTION__));
-			vbl.request.type = DRM_VBLANK_ABSOLUTE;
+			vbl.request.type = (uint32_t)DRM_VBLANK_ABSOLUTE;
 			vbl.request.sequence = info->target_msc;
 			if (sna_wait_vblank(info->sna, &vbl, sna_crtc_pipe(info->crtc)) == 0) {
 				ust = ust64(vbl.reply.tval_sec, vbl.reply.tval_usec);
@@ -430,7 +430,7 @@ sna_present_get_ust_msc(RRCrtcPtr crtc, CARD64 *ust, CARD64 *msc)
 	}
 
 	VG_CLEAR(vbl);
-	vbl.request.type = DRM_VBLANK_RELATIVE;
+	vbl.request.type = (uint32_t)DRM_VBLANK_RELATIVE;
 	vbl.request.sequence = 0;
 	if (sna_wait_vblank(sna, &vbl, sna_crtc_pipe(crtc->devPrivate)) == 0) {
 		*ust = ust64(vbl.reply.tval_sec, vbl.reply.tval_usec);
commit 1b69012e85bfc1dcc0b4fd32054def9451a3ea4f
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Fri Oct 28 08:42:53 2022 +0300

    sna: Don't redefine NV12 stuff if already defined
    
    Modern server headers already define NV12 for us. Avoid the
    redefine.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h
index 06d43796..25b97192 100644
--- a/src/sna/sna_video.h
+++ b/src/sna/sna_video.h
@@ -38,7 +38,9 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define FOURCC_XVMC (('C' << 24) + ('M' << 16) + ('V' << 8) + 'X')
 #define FOURCC_RGB565 ((16 << 24) + ('B' << 16) + ('G' << 8) + 'R')
 #define FOURCC_RGB888 ((24 << 24) + ('B' << 16) + ('G' << 8) + 'R')
+#ifndef FOURCC_NV12
 #define FOURCC_NV12 (('2' << 24) + ('1' << 16) + ('V' << 8) + 'N')
+#endif
 #define FOURCC_AYUV (('V' << 24) + ('U' << 16) + ('Y' << 8) + 'A')
 
 /*
@@ -71,7 +73,7 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 	XvTopToBottom \
 }
 
-/* no standard define for this */
+#ifndef XVIMAGE_NV12
 #define XVIMAGE_NV12 { \
 	FOURCC_NV12, XvYUV, LSBFirst,				\
 	{'N','V','1','2', 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
@@ -79,6 +81,7 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 	{'Y','U','V', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
 	XvTopToBottom \
 }
+#endif
 
 #define XVIMAGE_AYUV { \
 	FOURCC_AYUV, XvYUV, LSBFirst, \
commit 9aee418de6a7aee0602c271712b76b0ffe319ab7
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Mon Dec 9 16:27:17 2019 +0200

    sna: Eliminate sna_mode_wants_tear_free()
    
    The modparam checks performed by sna_mode_wants_tear_free() don't
    generally work when the server is running as a regular user. Hence
    we can't rely on them to indicate whether FBC/PSR/etc is enabled.
    Also the "Panel Self-Refresh" connector property doesn't actually
    exist so we can nuke that part as well. Let's just nuke the whole
    thing and assume we want dirtyfb always when tearfree is not enabled.
    
    I'll anyway want to enable FBC by default across the board soonish
    so the check wouldn't really buy us much (would just exclude i830
    and a few old desktop chipsets which don't have FBC hardware).
    
    Additionally if we don't have working dirtyfb we really should
    enable tearfree by default because otherwise we're going to
    get horrible lag due to missing frontbuffer flushes.
    
    Without WC mmaps we could in theory rely on the hw gtt tracking
    except the kernel no longer differentiates between GTT/WC/CPU
    access in its software frontbuffer tracking code so it'll just
    deactivate FBC even for a GTT mmap and potentially never re-enable
    it due to the missing frontbuffer flush from dirtyfb. So dirtyfb
    is always needed.
    
    v2: Rebase due to ppgtt->tear free logic
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 29d08a9b..f08f4d23 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -458,7 +458,6 @@ struct sna {
 
 bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna);
 bool sna_mode_fake_init(struct sna *sna, int num_fake);
-bool sna_mode_wants_tear_free(struct sna *sna);
 void sna_mode_adjust_frame(struct sna *sna, int x, int y);
 extern void sna_mode_discover(struct sna *sna, bool tell);
 extern void sna_mode_check(struct sna *sna);
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index a26f4906..15df51f6 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -7949,65 +7949,6 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna)
 	return scrn->modes != NULL;
 }
 
-bool
-sna_mode_wants_tear_free(struct sna *sna)
-{
-	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn);
-	bool found = false;
-	FILE *file;
-	int i;
-
-	file = fopen("/sys/module/i915/parameters/enable_fbc", "r");
-	if (file) {
-		int fbc_enabled = 0;
-		int value;
-
-		if (fscanf(file, "%d", &value) == 1)
-			fbc_enabled = value > 0;
-		fclose(file);
-
-		DBG(("%s: module parameter 'enable_fbc' enabled? %d\n",
-		     __FUNCTION__, fbc_enabled));
-
-		if (fbc_enabled)
-			return true;
-	}
-
-	for (i = 0; i < sna->mode.num_real_output; i++) {
-		struct sna_output *output = to_sna_output(config->output[i]);
-		int id = find_property(sna, output, "Panel Self-Refresh");
-		if (id == -1)
-			continue;
-
-		found = true;
-		if (output->prop_values[id] != -1) {
-			DBG(("%s: Panel Self-Refresh detected on %s\n",
-			     __FUNCTION__, config->output[i]->name));
-			return true;
-		}
-	}
-
-	if (!found) {
-		file = fopen("/sys/module/i915/parameters/enable_psr", "r");
-		if (file) {
-			int psr_enabled = 0;
-			int value;
-
-			if (fscanf(file, "%d", &value) == 1)
-				psr_enabled = value > 0;
-			fclose(file);
-
-			DBG(("%s: module parameter 'enable_psr' enabled? %d\n",
-			     __FUNCTION__, psr_enabled));
-
-			if (psr_enabled)
-				return true;
-		}
-	}
-
-	return false;
-}
-
 void
 sna_mode_set_primary(struct sna *sna)
 {
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index b0e16833..137f29e8 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -470,12 +470,7 @@ static bool enable_tear_free(struct sna *sna)
 	if (sna->kgem.has_full_ppgtt)
 		return true;
 
-	/*
-	 * Under certain conditions, we should enable TearFree by default,
-	 * for example when the hardware requires pageflipping to run within
-	 * its power/performance budget.
-	 */
-	if (sna_mode_wants_tear_free(sna))
+	if (!sna->kgem.has_dirtyfb)
 		return true;
 
 	return ENABLE_TEAR_FREE;
@@ -675,7 +670,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int probe)
 	}
 	scrn->currentMode = scrn->modes;
 
-	if (!setup_tear_free(sna) && sna_mode_wants_tear_free(sna))
+	if (!setup_tear_free(sna))
 		sna->kgem.needs_dirtyfb = sna->kgem.has_dirtyfb;
 
 	xf86SetGamma(scrn, zeros);
commit 2a0d4fb1697efa48cb1a124869d8c8bf58bad2ca
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Mon Jul 12 10:44:40 2021 +0300

    sna: Dump fences also on -ENOBUFS
    
    Since kernel commit 78d2ad7eb4e1 ("drm/i915/gt: Fix
    -EDEADLK handling regression") running out of fences
    will result in -ENOBUFS instead of -EDEADLK (the latter
    having been stolen by ww mutextes for their internal use).
    Adjust the fence dumping to expect either errno value.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 7b645da8..ac0b61d5 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -4263,7 +4263,7 @@ void _kgem_submit(struct kgem *kgem)
 
 		if (ret == -ENOSPC)
 			dump_gtt_info(kgem);
-		if (ret == -EDEADLK)
+		if (ret == -EDEADLK || ret == -ENOBUFS)
 			dump_fence_regs(kgem);
 
 		if (DEBUG_SYNC) {
commit f2c271130f33d0ec9a1f6400ddb288f6d776e0c8
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Thu Apr 21 15:38:45 2022 +0300

    sna: Don't emit sse2 code where not wanted
    
    Fix the s/push_options/pop_options/ pragma so that we don't
    emit sse2 in the codepaths that run on non-sse2 machines as well.
    Seems gcc has become much more aggressive in its sse2 usage
    recently and I'm now hitting sse2 instructions in
    choose_memcpy_tiled_x() on my non-sse2 P3 machine.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/blt.c b/src/sna/blt.c
index afc719f6..803c5142 100644
--- a/src/sna/blt.c
+++ b/src/sna/blt.c
@@ -631,7 +631,7 @@ memcpy_between_tiled_x__swizzle_0__sse2(const void *src, void *dst, int bpp,
 	}
 }
 
-#pragma GCC push_options
+#pragma GCC pop_options
 #endif
 
 fast void
commit 2b552ed7d528d24b688b992a5164e062827d0ccb
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Sun Mar 21 17:53:20 2021 +0200

    sna: Allow DRI3 on gen2/3
    
    Once we have DRI3 in Mesa i915 driver we can allow DRI3
    on gen2/3.
    
    But due to the supposed missing DRI2 fallback with older Mesa
    let's only do that if the user explicitly requests it. Note
    that when I tried this with modern Mesa that lacks i915 DRI3
    support things seemed to fall back to DRI2 just fine, but
    better safe than sorry I guess.
    
    Cc: Chris Wilson <chris at chris-wilson.co.uk>
    References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9734
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index d810b262..b0e16833 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -444,7 +444,8 @@ static void setup_dri(struct sna *sna)
 	sna->dri3.override =
 		!sna->dri3.available ||
 		xf86IsOptionSet(sna->Options, OPTION_DRI);
-	if (level >= 3 && sna->kgem.gen >= 040)
+	if (level >= 3 && (sna->kgem.gen >= 040 ||
+			   xf86IsOptionSet(sna->Options, OPTION_DRI)))
 		sna->dri3.enable = sna->dri3.available;
 #endif
 #if HAVE_DRI2
commit c14994713b87eef67037903f40819793d5959d10
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Sat Feb 13 14:44:08 2021 +0200

    sna: Fix async flips
    
    We need to wait for flip events even when doing async flips,
    otherwise the kernel will just hand us -EBUSY if we try to
    flip too fast.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index f2bc1896..29d08a9b 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -491,6 +491,7 @@ typedef void (*sna_flip_handler_t)(struct drm_event_vblank *e,
 extern bool sna_needs_page_flip(struct sna *sna, struct kgem_bo *bo);
 extern int sna_page_flip(struct sna *sna,
 			 struct kgem_bo *bo,
+			 bool async,
 			 sna_flip_handler_t handler,
 			 void *data);
 
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 874292bc..a26f4906 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -7143,6 +7143,7 @@ bool sna_needs_page_flip(struct sna *sna, struct kgem_bo *bo)
 int
 sna_page_flip(struct sna *sna,
 	      struct kgem_bo *bo,
+	      bool async,
 	      sna_flip_handler_t handler,
 	      void *data)
 {
@@ -7162,7 +7163,7 @@ sna_page_flip(struct sna *sna,
 	assert(!sna->mode.hidden);
 	assert(sna->scrn->vtSema);
 
-	if ((sna->flags & (data ? SNA_HAS_FLIP : SNA_HAS_ASYNC_FLIP)) == 0)
+	if ((sna->flags & (async ? SNA_HAS_ASYNC_FLIP : SNA_HAS_FLIP)) == 0)
 		return 0;
 
 	kgem_bo_submit(&sna->kgem, bo);
@@ -7186,7 +7187,7 @@ sna_page_flip(struct sna *sna,
 		assert(crtc->flip_bo == NULL);
 
 		assert_crtc_fb(sna, crtc);
-		if (data == NULL && crtc->bo == bo)
+		if (async && crtc->bo == bo)
 			goto next_crtc;
 
 		arg.crtc_id = __sna_crtc_id(crtc);
@@ -7224,7 +7225,7 @@ update_scanout:
 				crtc->bo = kgem_bo_reference(bo);
 				crtc->bo->active_scanout++;
 
-				if (data == NULL)
+				if (async)
 					goto next_crtc;
 
 				/* queue a flip in order to send the event */
@@ -7235,13 +7236,10 @@ update_scanout:
 		/* Only the reference crtc will finally deliver its page flip
 		 * completion event. All other crtc's events will be discarded.
 		 */
-		if (data) {
-			arg.user_data = (uintptr_t)crtc;
-			arg.flags = DRM_MODE_PAGE_FLIP_EVENT;
-		} else {
-			arg.user_data = 0;
-			arg.flags = DRM_MODE_PAGE_FLIP_ASYNC;
-		}
+		arg.user_data = (uintptr_t)crtc;
+		arg.flags = DRM_MODE_PAGE_FLIP_EVENT;
+		if (async)
+			arg.flags |= DRM_MODE_PAGE_FLIP_ASYNC;
 		arg.reserved = 0;
 
 retry_flip:
@@ -7281,7 +7279,7 @@ retry_flip:
 error:
 			xf86DrvMsg(sna->scrn->scrnIndex, X_ERROR,
 					"page flipping failed, on CRTC:%d (pipe=%d), disabling %s page flips\n",
-					__sna_crtc_id(crtc), __sna_crtc_pipe(crtc), data ? "synchronous": "asynchronous");
+					__sna_crtc_id(crtc), __sna_crtc_pipe(crtc), async ? "asynchronous": "synchronous");
 
 			if (count || crtc->bo == bo)
 				sna_mode_restore(sna);
diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index 4ee76627..4361af71 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -1963,8 +1963,8 @@ sna_dri2_flip(struct sna_dri2_event *info)
 	}
 
 	assert(!info->queued);
-	if (!sna_page_flip(info->sna, bo, sna_dri2_flip_handler,
-			   info->type == FLIP_ASYNC ? NULL : info))
+	if (!sna_page_flip(info->sna, bo, info->type == FLIP_ASYNC,
+			   sna_dri2_flip_handler, info))
 		return false;
 
 	DBG(("%s: queued flip=%p\n", __FUNCTION__, info->type == FLIP_ASYNC ? NULL : info));
@@ -2855,7 +2855,8 @@ sna_dri2_flip_continue(struct sna_dri2_event *info)
 		return false;
 
 	assert(!info->queued);
-	if (!sna_page_flip(info->sna, bo, sna_dri2_flip_handler, info))
+	if (!sna_page_flip(info->sna, bo, false,
+			   sna_dri2_flip_handler, info))
 		return false;
 
 	DBG(("%s: queued flip=%p\n", __FUNCTION__, info));
diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index 6bb7b927..b86dc97e 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -675,34 +675,6 @@ sna_present_check_flip(RRCrtcPtr crtc,
 	return TRUE;
 }
 
-static Bool
-flip__async(struct sna *sna,
-	    RRCrtcPtr crtc,
-	    uint64_t event_id,
-	    uint64_t target_msc,
-	    struct kgem_bo *bo)
-{
-	DBG(("%s(pipe=%d, event=%lld, handle=%d)\n",
-	     __FUNCTION__,
-	     pipe_from_crtc(crtc),
-	     (long long)event_id,
-	     bo->handle));
-
-	if (!sna_page_flip(sna, bo, NULL, NULL)) {
-		DBG(("%s: async pageflip failed\n", __FUNCTION__));
-		present_info.capabilities &= ~PresentCapabilityAsync;
-		return FALSE;
-	}
-
-	DBG(("%s: pipe=%d tv=%ld.%06d msc=%lld (target=%lld), event=%lld complete\n", __FUNCTION__,
-	     pipe_from_crtc(crtc),
-	     (long)(gettime_ust64() / 1000000), (int)(gettime_ust64() % 1000000),
-	     crtc ? (long long)sna_crtc_last_swap(crtc->devPrivate)->msc : 0LL,
-	     (long long)target_msc, (long long)event_id));
-	present_event_notify(event_id, gettime_ust64(), target_msc);
-	return TRUE;
-}
-
 static void
 present_flip_handler(struct drm_event_vblank *event, void *data)
 {
@@ -748,11 +720,12 @@ present_flip_handler(struct drm_event_vblank *event, void *data)
 }
 
 static Bool
-flip(struct sna *sna,
-     RRCrtcPtr crtc,
-     uint64_t event_id,
-     uint64_t target_msc,
-     struct kgem_bo *bo)
+do_flip(struct sna *sna,
+	RRCrtcPtr crtc,
+	uint64_t event_id,
+	uint64_t target_msc,
+	struct kgem_bo *bo,
+	bool async)
 {
 	struct sna_present_event *info;
 
@@ -774,7 +747,7 @@ flip(struct sna *sna,
 	info->target_msc = target_msc;
 	info->active = false;
 
-	if (!sna_page_flip(sna, bo, present_flip_handler, info)) {
+	if (!sna_page_flip(sna, bo, async, present_flip_handler, info)) {
 		DBG(("%s: pageflip failed\n", __FUNCTION__));
 		info_free(info);
 		return FALSE;
@@ -784,6 +757,26 @@ flip(struct sna *sna,
 	return TRUE;
 }
 
+static Bool
+flip__async(struct sna *sna,
+	    RRCrtcPtr crtc,
+	    uint64_t event_id,
+	    uint64_t target_msc,
+	    struct kgem_bo *bo)
+{
+	return do_flip(sna, crtc, event_id, target_msc, bo, true);
+}
+
+static Bool
+flip(struct sna *sna,
+     RRCrtcPtr crtc,
+     uint64_t event_id,
+     uint64_t target_msc,
+     struct kgem_bo *bo)
+{
+	return do_flip(sna, crtc, event_id, target_msc, bo, false);
+}
+
 static struct kgem_bo *
 get_flip_bo(PixmapPtr pixmap)
 {


More information about the xorg-commit mailing list