diff options
author | jkim <jkim@FreeBSD.org> | 2013-08-29 20:40:45 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2013-08-29 20:40:45 +0000 |
commit | 6603a737409dde47b24e10b3389b8369f4a0d5e1 (patch) | |
tree | 39797d08036846b48835a0dbdc7407ce2bbd0082 /sys/dev/drm2 | |
parent | fcdbf70fd9ffe66a2cd744ca6626d7f87b39e593 (diff) | |
download | FreeBSD-src-6603a737409dde47b24e10b3389b8369f4a0d5e1.zip FreeBSD-src-6603a737409dde47b24e10b3389b8369f4a0d5e1.tar.gz |
Clarify confusions between atomic_t and bitmap. Fix bitmap operations
accordingly.
Diffstat (limited to 'sys/dev/drm2')
-rw-r--r-- | sys/dev/drm2/drmP.h | 2 | ||||
-rw-r--r-- | sys/dev/drm2/drm_atomic.h | 30 |
2 files changed, 19 insertions, 13 deletions
diff --git a/sys/dev/drm2/drmP.h b/sys/dev/drm2/drmP.h index c9997d7..624a316 100644 --- a/sys/dev/drm2/drmP.h +++ b/sys/dev/drm2/drmP.h @@ -961,7 +961,7 @@ struct drm_device { drm_agp_head_t *agp; drm_sg_mem_t *sg; /* Scatter gather memory */ - atomic_t *ctx_bitmap; + u_long *ctx_bitmap; void *dev_private; unsigned int agp_buffer_token; drm_local_map_t *agp_buffer_map; diff --git a/sys/dev/drm2/drm_atomic.h b/sys/dev/drm2/drm_atomic.h index b4ef0fb..e52d349 100644 --- a/sys/dev/drm2/drm_atomic.h +++ b/sys/dev/drm2/drm_atomic.h @@ -7,6 +7,7 @@ /*- * Copyright 2004 Eric Anholt + * Copyright 2013 Jung-uk Kim <jkim@FreeBSD.org> * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -32,10 +33,11 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -typedef uint32_t atomic_t; +typedef u_int atomic_t; typedef uint64_t atomic64_t; -#define BITS_TO_LONGS(x) howmany(x, sizeof(long) * NBBY) +#define BITS_PER_LONG (sizeof(long) * NBBY) +#define BITS_TO_LONGS(x) howmany(x, BITS_PER_LONG) #define atomic_read(p) (*(volatile u_int *)(p)) #define atomic_set(p, v) do { *(u_int *)(p) = (v); } while (0) @@ -58,23 +60,27 @@ typedef uint64_t atomic64_t; #define atomic_xchg(p, v) atomic_swap_int(p, v) #define atomic64_xchg(p, v) atomic_swap_64(p, v) +#define __bit_word(b) ((b) / BITS_PER_LONG) +#define __bit_mask(b) (1UL << (b) % BITS_PER_LONG) +#define __bit_addr(p, b) ((volatile u_long *)(p) + __bit_word(b)) + #define clear_bit(b, p) \ - atomic_clear_int((volatile u_int *)(p) + (b) / 32, 1 << (b) % 32) + atomic_clear_long(__bit_addr(p, b), __bit_mask(b)) #define set_bit(b, p) \ - atomic_set_int((volatile u_int *)(p) + (b) / 32, 1 << (b) % 32) + atomic_set_long(__bit_addr(p, b), __bit_mask(b)) #define test_bit(b, p) \ - ((atomic_read((volatile u_int *)(p) + (b) / 32) & (1 << (b) % 32)) != 0) + ((atomic_read(__bit_addr(p, b)) & __bit_mask(b)) != 0) -static __inline int -find_first_zero_bit(volatile void *p, int max) +static __inline u_long +find_first_zero_bit(const u_long *p, u_long max) { - volatile int *np = p; - int i, n; + u_long i, n; - for (i = 0; i < max / (NBBY * sizeof(int)); i++) { - n = ~np[i]; + KASSERT(max % BITS_PER_LONG == 0, ("invalid bitmap size %lu", max)); + for (i = 0; i < max / BITS_PER_LONG; i++) { + n = ~p[i]; if (n != 0) - return (i * NBBY * sizeof(int) + ffs(n) - 1); + return (i * BITS_PER_LONG + ffsl(n) - 1); } return (max); } |