[PATCH xf86-video-amdgpu 01/12] Add explicit AMDGPU_DRM_QUEUE_ERROR define

Michel Dänzer michel at daenzer.net
Thu Sep 8 10:02:34 UTC 2016


From: Michel Dänzer <michel.daenzer at amd.com>

Should make the amdgpu_drm_queue_alloc error handling clearer, and gets
rid of a compile warning about it returning NULL.

(Ported from radeon commit a37af701768b12d86868a831a79f1e02ee4968cf)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_dri2.c      | 4 ++--
 src/amdgpu_drm_queue.c | 7 ++++---
 src/amdgpu_drm_queue.h | 2 ++
 src/amdgpu_kms.c       | 4 ++--
 src/amdgpu_present.c   | 2 +-
 src/drmmode_display.c  | 2 +-
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 1cbf1eb..31ac3f3 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -1035,7 +1035,7 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
 	drm_queue_seq = amdgpu_drm_queue_alloc(crtc, client, AMDGPU_DRM_QUEUE_ID_DEFAULT,
 					       wait_info, amdgpu_dri2_frame_event_handler,
 					       amdgpu_dri2_frame_event_abort);
-	if (!drm_queue_seq) {
+	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "Allocating DRM queue event entry failed.\n");
 		goto out_complete;
@@ -1183,7 +1183,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
 	drm_queue_seq = amdgpu_drm_queue_alloc(crtc, client, AMDGPU_DRM_QUEUE_ID_DEFAULT,
 					       swap_info, amdgpu_dri2_frame_event_handler,
 					       amdgpu_dri2_frame_event_abort);
-	if (!drm_queue_seq) {
+	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "Allocating DRM queue entry failed.\n");
 		goto blit_fallback;
diff --git a/src/amdgpu_drm_queue.c b/src/amdgpu_drm_queue.c
index 562a11a..e8810fd 100644
--- a/src/amdgpu_drm_queue.c
+++ b/src/amdgpu_drm_queue.c
@@ -92,10 +92,11 @@ amdgpu_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
 
 	e = calloc(1, sizeof(struct amdgpu_drm_queue_entry));
 	if (!e)
-		return NULL;
+		return AMDGPU_DRM_QUEUE_ERROR;
+
+	if (_X_UNLIKELY(amdgpu_drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR))
+		amdgpu_drm_queue_seq++;
 
-	if (!amdgpu_drm_queue_seq)
-		amdgpu_drm_queue_seq = 1;
 	e->seq = amdgpu_drm_queue_seq++;
 	e->client = client;
 	e->crtc = crtc;
diff --git a/src/amdgpu_drm_queue.h b/src/amdgpu_drm_queue.h
index b4d4009..36ee900 100644
--- a/src/amdgpu_drm_queue.h
+++ b/src/amdgpu_drm_queue.h
@@ -31,6 +31,8 @@
 
 #include <xf86Crtc.h>
 
+#define AMDGPU_DRM_QUEUE_ERROR 0
+
 #define AMDGPU_DRM_QUEUE_CLIENT_DEFAULT serverClient
 #define AMDGPU_DRM_QUEUE_ID_DEFAULT ~0ULL
 
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index d9f15a4..9f023cf 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -426,7 +426,7 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc)
 					       drmmode_crtc,
 					       amdgpu_scanout_update_handler,
 					       amdgpu_scanout_update_abort);
-	if (!drm_queue_seq) {
+	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "amdgpu_drm_queue_alloc failed for scanout update\n");
 		return;
@@ -480,7 +480,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 					       AMDGPU_DRM_QUEUE_ID_DEFAULT,
 					       drmmode_crtc, NULL,
 					       amdgpu_scanout_flip_abort);
-	if (!drm_queue_seq) {
+	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "Allocating DRM event queue entry failed.\n");
 		return;
diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index edfccb1..192c410 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -170,7 +170,7 @@ amdgpu_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 					       event_id, event,
 					       amdgpu_present_vblank_handler,
 					       amdgpu_present_vblank_abort);
-	if (!drm_queue_seq) {
+	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 		free(event);
 		return BadAlloc;
 	}
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index fdd5922..3063fac 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2537,7 +2537,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 						       flipdata,
 						       drmmode_flip_handler,
 						       drmmode_flip_abort);
-		if (!drm_queue_seq) {
+		if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 				   "Allocating DRM queue event entry failed.\n");
 			goto error;
-- 
2.9.3



More information about the amd-gfx mailing list