From owner-svn-src-head@FreeBSD.ORG Thu Aug 29 20:40:46 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 933D8816; Thu, 29 Aug 2013 20:40:46 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 711C527B9; Thu, 29 Aug 2013 20:40:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7TKektL083327; Thu, 29 Aug 2013 20:40:46 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7TKekBO083325; Thu, 29 Aug 2013 20:40:46 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201308292040.r7TKekBO083325@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 29 Aug 2013 20:40:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255041 - head/sys/dev/drm2 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2013 20:40:46 -0000 Author: jkim Date: Thu Aug 29 20:40:45 2013 New Revision: 255041 URL: http://svnweb.freebsd.org/changeset/base/255041 Log: Clarify confusions between atomic_t and bitmap. Fix bitmap operations accordingly. Modified: head/sys/dev/drm2/drmP.h head/sys/dev/drm2/drm_atomic.h Modified: head/sys/dev/drm2/drmP.h ============================================================================== --- head/sys/dev/drm2/drmP.h Thu Aug 29 19:52:18 2013 (r255040) +++ head/sys/dev/drm2/drmP.h Thu Aug 29 20:40:45 2013 (r255041) @@ -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; Modified: head/sys/dev/drm2/drm_atomic.h ============================================================================== --- head/sys/dev/drm2/drm_atomic.h Thu Aug 29 19:52:18 2013 (r255040) +++ head/sys/dev/drm2/drm_atomic.h Thu Aug 29 20:40:45 2013 (r255041) @@ -7,6 +7,7 @@ /*- * Copyright 2004 Eric Anholt + * Copyright 2013 Jung-uk Kim * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -32,10 +33,11 @@ #include __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); }