summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/drmP.h1
-rw-r--r--linux-core/drm_bufs.c35
-rw-r--r--shared-core/r128_cce.c2
-rw-r--r--shared-core/radeon_cp.c2
4 files changed, 33 insertions, 7 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index b095d86f..f3a76c2a 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -868,6 +868,7 @@ extern int drm_freebufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int drm_mapbufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+extern int drm_order(unsigned long size);
/* DMA support (drm_dma.h) */
extern int drm_dma_setup(drm_device_t * dev);
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index ca5aacae..8ade8f38 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -212,7 +212,7 @@ int drm_addmap(struct inode *inode, struct file *filp,
case _DRM_SHM:
map->handle = vmalloc_32(map->size);
DRM_DEBUG("%lu %d %p\n",
- map->size, get_order(map->size), map->handle);
+ map->size, drm_order(map->size), map->handle);
if (!map->handle) {
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return -ENOMEM;
@@ -440,7 +440,7 @@ int drm_addbufs_agp(struct inode *inode, struct file *filp,
return -EFAULT;
count = request.count;
- order = get_order(request.size);
+ order = drm_order(request.size);
size = 1 << order;
alignment = (request.flags & _DRM_PAGE_ALIGN)
@@ -609,7 +609,7 @@ int drm_addbufs_pci(struct inode *inode, struct file *filp,
return -EFAULT;
count = request.count;
- order = get_order(request.size);
+ order = drm_order(request.size);
size = 1 << order;
DRM_DEBUG("count=%d, size=%d (%d), order=%d, queue_count=%d\n",
@@ -835,7 +835,7 @@ int drm_addbufs_sg(struct inode *inode, struct file *filp,
return -EFAULT;
count = request.count;
- order = get_order(request.size);
+ order = drm_order(request.size);
size = 1 << order;
alignment = (request.flags & _DRM_PAGE_ALIGN)
@@ -1137,7 +1137,7 @@ int drm_markbufs(struct inode *inode, struct file *filp,
DRM_DEBUG("%d, %d, %d\n",
request.size, request.low_mark, request.high_mark);
- order = get_order(request.size);
+ order = drm_order(request.size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
entry = &dma->bufs[order];
@@ -1332,3 +1332,28 @@ int drm_mapbufs(struct inode *inode, struct file *filp,
return retcode;
}
+
+/**
+ * Compute size order. Returns the exponent of the smaller power of two which
+ * is greater or equal to given number.
+ *
+ * \param size size.
+ * \return order.
+ *
+ * \todo Can be made faster.
+ */
+int drm_order( unsigned long size )
+{
+ int order;
+ unsigned long tmp;
+
+ for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++)
+ ;
+
+ if (size & (size - 1))
+ ++order;
+
+ return order;
+}
+EXPORT_SYMBOL(drm_order);
+
diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c
index 4246cc7c..ad0a8814 100644
--- a/shared-core/r128_cce.c
+++ b/shared-core/r128_cce.c
@@ -541,7 +541,7 @@ static int r128_do_init_cce(drm_device_t * dev, drm_r128_init_t * init)
dev_priv->ring.end = ((u32 *) dev_priv->cce_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = get_order(init->ring_size / 8);
+ dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8);
dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1;
diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c
index 33a10ab5..36a77ad4 100644
--- a/shared-core/radeon_cp.c
+++ b/shared-core/radeon_cp.c
@@ -1202,7 +1202,7 @@ static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init)
dev_priv->ring.end = ((u32 *) dev_priv->cp_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = get_order(init->ring_size / 8);
+ dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8);
dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1;