summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-27 11:28:37 +0200
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-27 11:28:37 +0200
commitf6d5fecdd20b9fd9e8744d8f43fa276b73a1da78 (patch)
tree380734403931194b944466acbee3c340259a7ada
parente09544a2d3f44e96d01ed2bdcb4a4eb8eec26225 (diff)
Last minute changes to support multi-page size buffer offset alignments.
This will come in very handy for tiled buffers on intel hardware. Also add some padding to interface structures to allow future binary backwards compatible changes.
-rw-r--r--libdrm/xf86drm.c7
-rw-r--r--libdrm/xf86mm.h10
-rw-r--r--linux-core/drmP.h2
-rw-r--r--linux-core/drm_bo.c8
-rw-r--r--linux-core/drm_mm.c5
-rw-r--r--shared-core/drm.h2
6 files changed, 25 insertions, 9 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 9047c8db..ebf3f834 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2613,12 +2613,14 @@ static void drmBOCopyReply(const drm_bo_arg_reply_t *rep,
buf->start = rep->buffer_start;
buf->fenceFlags = rep->fence_flags;
buf->replyFlags = rep->rep_flags;
+ buf->pageAlignment = rep->page_alignment;
}
-int drmBOCreate(int fd, void *ttm, unsigned long start, unsigned long size,
- void *user_buffer, drm_bo_type_t type, unsigned mask,
+int drmBOCreate(int fd, unsigned long start, unsigned long size,
+ unsigned pageAlignment, void *user_buffer, drm_bo_type_t type,
+ unsigned mask,
unsigned hint, drmBO *buf)
{
drm_bo_arg_t arg;
@@ -2632,6 +2634,7 @@ int drmBOCreate(int fd, void *ttm, unsigned long start, unsigned long size,
req->hint = hint;
req->size = size;
req->type = type;
+ req->page_alignment = pageAlignment;
buf->virtual = NULL;
diff --git a/libdrm/xf86mm.h b/libdrm/xf86mm.h
index da868fe5..bd0d2812 100644
--- a/libdrm/xf86mm.h
+++ b/libdrm/xf86mm.h
@@ -99,6 +99,7 @@ typedef struct _drmFence{
unsigned type;
unsigned flags;
unsigned signaled;
+ unsigned pad[4]; /* for future expansion */
} drmFence;
typedef struct _drmBO{
@@ -113,9 +114,11 @@ typedef struct _drmBO{
unsigned long start;
unsigned replyFlags;
unsigned fenceFlags;
+ unsigned pageAlignment;
void *virtual;
void *mapVirtual;
int mapCount;
+ unsigned pad[8]; /* for future expansion */
} drmBO;
@@ -168,9 +171,10 @@ extern int drmBOCreateList(int numTarget, drmBOList *list);
* Buffer object functions.
*/
-extern int drmBOCreate(int fd, void *ttm, unsigned long start, unsigned long size,
- void *user_buffer, drm_bo_type_t type, unsigned mask,
- unsigned hint, drmBO *buf);
+extern int drmBOCreate(int fd, unsigned long start, unsigned long size,
+ unsigned pageAlignment,void *user_buffer,
+ drm_bo_type_t type, unsigned mask,
+ unsigned hint, drmBO *buf);
extern int drmBODestroy(int fd, drmBO *buf);
extern int drmBOReference(int fd, unsigned handle, drmBO *buf);
extern int drmBOUnReference(int fd, drmBO *buf);
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 1ed20b09..d02184c7 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1016,7 +1016,7 @@ typedef struct drm_buffer_object{
unsigned long buffer_start;
drm_bo_type_t type;
unsigned long offset;
-
+ uint32_t page_alignment;
atomic_t mapped;
uint32_t flags;
uint32_t mask;
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index 954b7a03..65e24fb6 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -571,7 +571,7 @@ int drm_bo_alloc_space(drm_buffer_object_t * buf, unsigned mem_type,
mutex_lock(&dev->struct_mutex);
do {
- node = drm_mm_search_free(mm, size, 0, 1);
+ node = drm_mm_search_free(mm, size, buf->page_alignment, 1);
if (node)
break;
@@ -599,7 +599,7 @@ int drm_bo_alloc_space(drm_buffer_object_t * buf, unsigned mem_type,
return -ENOMEM;
}
- node = drm_mm_get_block(node, size, 0);
+ node = drm_mm_get_block(node, size, buf->page_alignment);
mutex_unlock(&dev->struct_mutex);
BUG_ON(!node);
node->private = (void *)buf;
@@ -959,6 +959,7 @@ static void drm_bo_fill_rep_arg(drm_buffer_object_t * bo,
rep->buffer_start = bo->buffer_start;
rep->fence_flags = bo->fence_type;
rep->rep_flags = 0;
+ rep->page_alignment = bo->page_alignment;
if ((bo->priv_flags & _DRM_BO_FLAG_UNFENCED) || drm_bo_quick_busy(bo)) {
DRM_FLAG_MASKED(rep->rep_flags, DRM_BO_REP_BUSY,
@@ -1387,6 +1388,7 @@ int drm_buffer_object_create(drm_file_t * priv,
drm_bo_type_t type,
uint32_t mask,
uint32_t hint,
+ uint32_t page_alignment,
unsigned long buffer_start,
drm_buffer_object_t ** buf_obj)
{
@@ -1426,6 +1428,7 @@ int drm_buffer_object_create(drm_file_t * priv,
bo->num_pages = num_pages;
bo->node_card = NULL;
bo->node_ttm = NULL;
+ bo->page_alignment = page_alignment;
if (bo->type == drm_bo_type_fake) {
bo->offset = buffer_start;
bo->buffer_start = 0;
@@ -1516,6 +1519,7 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS)
req->type,
req->mask,
req->hint,
+ req->page_alignment,
req->buffer_start, &entry);
if (rep.ret)
break;
diff --git a/linux-core/drm_mm.c b/linux-core/drm_mm.c
index dcd55209..a5566b2f 100644
--- a/linux-core/drm_mm.c
+++ b/linux-core/drm_mm.c
@@ -147,7 +147,10 @@ drm_mm_node_t *drm_mm_get_block(drm_mm_node_t * parent,
drm_mm_node_t *align_splitoff = NULL;
drm_mm_node_t *child;
- unsigned tmp = size % alignment;
+ unsigned tmp = 0;
+
+ if (alignment)
+ tmp = size % alignment;
if (tmp) {
align_splitoff = drm_mm_split_at_start(parent, alignment - tmp);
diff --git a/shared-core/drm.h b/shared-core/drm.h
index 5784e59b..330aa3ff 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -770,6 +770,7 @@ typedef struct drm_bo_arg_request {
drm_bo_type_t type;
unsigned arg_handle;
drm_u64_t buffer_start;
+ unsigned page_alignment;
unsigned expand_pad[4]; /*Future expansion */
enum {
drm_bo_create,
@@ -804,6 +805,7 @@ typedef struct drm_bo_arg_reply {
drm_u64_t buffer_start;
unsigned fence_flags;
unsigned rep_flags;
+ unsigned page_alignment;
unsigned expand_pad[4]; /*Future expansion */
}drm_bo_arg_reply_t;