Module Name: src
Committed By: riastradh
Date: Mon Aug 27 13:55:46 UTC 2018
Modified Files:
src/sys/external/bsd/drm2/include/linux: reservation.h
src/sys/external/bsd/drm2/linux: linux_reservation.c
Log Message:
Apparently one can reserve_shared only once in a row. Simplify.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/include/linux/reservation.h
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_reservation.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/include/linux/reservation.h
diff -u src/sys/external/bsd/drm2/include/linux/reservation.h:1.5 src/sys/external/bsd/drm2/include/linux/reservation.h:1.6
--- src/sys/external/bsd/drm2/include/linux/reservation.h:1.5 Mon Aug 27 13:33:59 2018
+++ src/sys/external/bsd/drm2/include/linux/reservation.h Mon Aug 27 13:55:46 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: reservation.h,v 1.5 2018/08/27 13:33:59 riastradh Exp $ */
+/* $NetBSD: reservation.h,v 1.6 2018/08/27 13:55:46 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -44,7 +44,6 @@ struct reservation_object {
struct fence __rcu *robj_fence;
struct reservation_object_list __rcu *robj_list;
struct reservation_object_list __rcu *robj_prealloc;
- uint32_t robj_nreserved;
};
struct reservation_object_list {
Index: src/sys/external/bsd/drm2/linux/linux_reservation.c
diff -u src/sys/external/bsd/drm2/linux/linux_reservation.c:1.2 src/sys/external/bsd/drm2/linux/linux_reservation.c:1.3
--- src/sys/external/bsd/drm2/linux/linux_reservation.c:1.2 Mon Aug 27 13:35:35 2018
+++ src/sys/external/bsd/drm2/linux/linux_reservation.c Mon Aug 27 13:55:46 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_reservation.c,v 1.2 2018/08/27 13:35:35 riastradh Exp $ */
+/* $NetBSD: linux_reservation.c,v 1.3 2018/08/27 13:55:46 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.2 2018/08/27 13:35:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.3 2018/08/27 13:55:46 riastradh Exp $");
#include <linux/fence.h>
#include <linux/reservation.h>
@@ -89,7 +89,6 @@ reservation_object_init(struct reservati
robj->robj_fence = NULL;
robj->robj_list = NULL;
robj->robj_prealloc = NULL;
- robj->robj_nreserved = 0;
}
/*
@@ -162,12 +161,13 @@ reservation_object_get_list(struct reser
/*
* reservation_object_reserve_shared(robj)
*
- * Reserve space in robj to add a shared fence.
+ * Reserve space in robj to add a shared fence. To be used only
+ * once before calling reservation_object_add_shared_fence.
*
* Caller must have robj locked.
*
- * Internally, we start with room for four entries and double
- * whenever we run out. This is not guaranteed.
+ * Internally, we start with room for four entries and double if
+ * we don't have enough. This is not guaranteed.
*/
int
reservation_object_reserve_shared(struct reservation_object *robj)
@@ -180,21 +180,27 @@ reservation_object_reserve_shared(struct
list = robj->robj_list;
prealloc = robj->robj_prealloc;
- /* If there's too many objects reserved already, fail. */
- if (robj->robj_nreserved == UINT32_MAX)
- return -ENOMEM;
-
- /* Bump the number of objects reserved. */
- n = ++robj->robj_nreserved;
-
- /* If there's enough room in the existing list, stop here. */
- if (list != NULL && n < list->shared_max)
- return 0;
+ /* If there's an existing list, check it for space. */
+ if (list != NULL) {
+ /* If there's too many already, give up. */
+ if (list->shared_count == UINT32_MAX)
+ return -ENOMEM;
+
+ /* Add one more. */
+ n = list->shared_count + 1;
+
+ /* If there's enough for one more, we're done. */
+ if (n <= list->shared_max)
+ return 0;
+ } else {
+ /* No list already. We need space for 1. */
+ n = 1;
+ }
/* If not, maybe there's a preallocated list ready. */
if (prealloc != NULL) {
/* If there's enough room in it, stop here. */
- if (n < prealloc->shared_max)
+ if (n <= prealloc->shared_max)
return 0;
/* Try to double its capacity. */