From f19d0ae349f091e90877dfc16ce5a32d86a27981 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sat, 29 Aug 2009 09:26:58 +0300 Subject: libdrm_radeon: add atomic operation for cs allocation. --- libdrm/radeon/radeon_cs.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libdrm/radeon/radeon_cs.h b/libdrm/radeon/radeon_cs.h index 45f7abad..1ee6e947 100644 --- a/libdrm/radeon/radeon_cs.h +++ b/libdrm/radeon/radeon_cs.h @@ -135,11 +135,8 @@ static inline int radeon_cs_write_reloc(struct radeon_cs *cs, static inline uint32_t __radeon_cs_alloc_section(struct radeon_cs *cs, uint32_t ndw) { - /* If we ever want to do parellel driver we need to change - this to atomic fetch and add operation. For now simple - read and add is enough. */ - uint32_t begin = cs->cdw; - cs->cdw += ndw; + /* Atomic operation for threading */ + uint32_t begin = __sync_fetch_and_add(&cs->cdw, ndw); /* Handle cs overflow */ if (begin + ndw > cs->ndw) { return (uint32_t)-ENOMEM; -- cgit v1.2.3