summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b06cb75)
raw | patch | inline | side by side (parent: b06cb75)
author | Jerome Glisse <jglisse@redhat.com> | |
Thu, 14 Jan 2010 10:24:16 +0000 (11:24 +0100) | ||
committer | Jerome Glisse <jglisse@redhat.com> | |
Thu, 14 Jan 2010 10:24:16 +0000 (11:24 +0100) |
diff --git a/radeon/radeon_bo.c b/radeon/radeon_bo.c
index eb3a1bc8c6dfb458e44b7f3f01f9b07aeb64196d..6a0f8e7926709309dc784f199a48d96b928c0b49 100644 (file)
--- a/radeon/radeon_bo.c
+++ b/radeon/radeon_bo.c
+/*
+ * Copyright © 2008 Dave Airlie
+ * Copyright © 2008 Jérôme Glisse
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Dave Airlie
+ * Jérôme Glisse <glisse@freedesktop.org>
+ */
#include <radeon_bo.h>
#include <radeon_bo_int.h>
-void radeon_bo_debug(struct radeon_bo *bo,
- const char *op)
+void radeon_bo_debug(struct radeon_bo *bo, const char *op)
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
}
struct radeon_bo *radeon_bo_open(struct radeon_bo_manager *bom,
- uint32_t handle,
- uint32_t size,
- uint32_t alignment,
- uint32_t domains,
- uint32_t flags)
+ uint32_t handle,
+ uint32_t size,
+ uint32_t alignment,
+ uint32_t domains,
+ uint32_t flags)
{
struct radeon_bo *bo;
bo = bom->funcs->bo_open(bom, handle, size, alignment, domains, flags);
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
if (!boi->bom->funcs->bo_wait)
- return 0;
+ return 0;
return boi->bom->funcs->bo_wait(boi);
}
-int radeon_bo_is_busy(struct radeon_bo *bo,
- uint32_t *domain)
+int radeon_bo_is_busy(struct radeon_bo *bo, uint32_t *domain)
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
return boi->bom->funcs->bo_is_busy(boi, domain);
}
int radeon_bo_set_tiling(struct radeon_bo *bo,
- uint32_t tiling_flags, uint32_t pitch)
+ uint32_t tiling_flags, uint32_t pitch)
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
return boi->bom->funcs->bo_set_tiling(boi, tiling_flags, pitch);
}
int radeon_bo_get_tiling(struct radeon_bo *bo,
- uint32_t *tiling_flags, uint32_t *pitch)
+ uint32_t *tiling_flags, uint32_t *pitch)
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
return boi->bom->funcs->bo_get_tiling(boi, tiling_flags, pitch);
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
if (boi->bom->funcs->bo_is_static)
- return boi->bom->funcs->bo_is_static(boi);
+ return boi->bom->funcs->bo_is_static(boi);
return 0;
}
-int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo,
- struct radeon_cs *cs)
+int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo, struct radeon_cs *cs)
{
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
return boi->cref > 1;
src_domain = boi->space_accounted & 0xffff;
if (!src_domain)
- src_domain = boi->space_accounted >> 16;
+ src_domain = boi->space_accounted >> 16;
return src_domain;
}
diff --git a/radeon/radeon_bo.h b/radeon/radeon_bo.h
index beb2369880ab2fcd7a11f914ca8dcf7a97fd7bf4..8859c2c3f714563ee21542d8669c2386ab2a8c30 100644 (file)
--- a/radeon/radeon_bo.h
+++ b/radeon/radeon_bo.h
-/*
+/*
* Copyright © 2008 Jérôme Glisse
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
struct radeon_bo_manager;
-void radeon_bo_debug(struct radeon_bo *bo,
- const char *op);
+void radeon_bo_debug(struct radeon_bo *bo, const char *op);
struct radeon_bo *radeon_bo_open(struct radeon_bo_manager *bom,
- uint32_t handle,
- uint32_t size,
- uint32_t alignment,
- uint32_t domains,
- uint32_t flags);
+ uint32_t handle,
+ uint32_t size,
+ uint32_t alignment,
+ uint32_t domains,
+ uint32_t flags);
void radeon_bo_ref(struct radeon_bo *bo);
struct radeon_bo *radeon_bo_unref(struct radeon_bo *bo);
int radeon_bo_set_tiling(struct radeon_bo *bo, uint32_t tiling_flags, uint32_t pitch);
int radeon_bo_get_tiling(struct radeon_bo *bo, uint32_t *tiling_flags, uint32_t *pitch);
int radeon_bo_is_static(struct radeon_bo *bo);
-int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo,
- struct radeon_cs *cs);
+int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo, struct radeon_cs *cs);
uint32_t radeon_bo_get_handle(struct radeon_bo *bo);
uint32_t radeon_bo_get_src_domain(struct radeon_bo *bo);
#endif
diff --git a/radeon/radeon_bo_gem.c b/radeon/radeon_bo_gem.c
index 9bf119a6444a1981a7048b4acc77917548ab640c..bc8058d8d49a32539980f3fc7a9e44772c8a3c1f 100644 (file)
--- a/radeon/radeon_bo_gem.c
+++ b/radeon/radeon_bo_gem.c
-/*
+/*
* Copyright © 2008 Dave Airlie
* Copyright © 2008 Jérôme Glisse
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
return 0;
}
if (bo_gem->priv_ptr) {
- goto wait;
+ goto wait;
}
boi->ptr = NULL;
args.domain = 0;
ret = drmCommandWriteRead(boi->bom->fd, DRM_RADEON_GEM_BUSY,
- &args, sizeof(args));
+ &args, sizeof(args));
*domain = args.domain;
return ret;
}
static int bo_set_tiling(struct radeon_bo_int *boi, uint32_t tiling_flags,
- uint32_t pitch)
+ uint32_t pitch)
{
struct drm_radeon_gem_set_tiling args;
int r;
args.pitch = pitch;
r = drmCommandWriteRead(boi->bom->fd,
- DRM_RADEON_GEM_SET_TILING,
- &args,
- sizeof(args));
+ DRM_RADEON_GEM_SET_TILING,
+ &args,
+ sizeof(args));
return r;
}
static int bo_get_tiling(struct radeon_bo_int *boi, uint32_t *tiling_flags,
- uint32_t *pitch)
+ uint32_t *pitch)
{
struct drm_radeon_gem_set_tiling args;
int r;
args.handle = boi->handle;
r = drmCommandWriteRead(boi->bom->fd,
- DRM_RADEON_GEM_GET_TILING,
- &args,
- sizeof(args));
+ DRM_RADEON_GEM_GET_TILING,
+ &args,
+ sizeof(args));
if (r)
- return r;
+ return r;
*tiling_flags = args.tiling_flags;
*pitch = args.pitch;
flink.handle = bo->handle;
r = drmIoctl(boi->bom->fd, DRM_IOCTL_GEM_FLINK, &flink);
if (r) {
- return r;
+ return r;
}
*name = flink.name;
return 0;
diff --git a/radeon/radeon_bo_gem.h b/radeon/radeon_bo_gem.h
index 4a8df9adf24dc7405fe1905dd22b888835b88692..c56c58e985a3aec963d5c95c007f45bb41186e71 100644 (file)
--- a/radeon/radeon_bo_gem.h
+++ b/radeon/radeon_bo_gem.h
-/*
+/*
* Copyright © 2008 Dave Airlie
* Copyright © 2008 Jérôme Glisse
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
diff --git a/radeon/radeon_bo_int.h b/radeon/radeon_bo_int.h
index 190c332475ba732edce6ef926985b68e002eab89..9589ead100e517ea44c62d484e9359b0f69e4b0c 100644 (file)
--- a/radeon/radeon_bo_int.h
+++ b/radeon/radeon_bo_int.h
int (*bo_wait)(struct radeon_bo_int *bo);
int (*bo_is_static)(struct radeon_bo_int *bo);
int (*bo_set_tiling)(struct radeon_bo_int *bo, uint32_t tiling_flags,
- uint32_t pitch);
+ uint32_t pitch);
int (*bo_get_tiling)(struct radeon_bo_int *bo, uint32_t *tiling_flags,
- uint32_t *pitch);
+ uint32_t *pitch);
int (*bo_is_busy)(struct radeon_bo_int *bo, uint32_t *domain);
int (*bo_is_referenced_by_cs)(struct radeon_bo_int *bo, struct radeon_cs *cs);
};
diff --git a/radeon/radeon_cs.h b/radeon/radeon_cs.h
index 0954ca0736ac3465ff486a764c4a142536c833d9..49d5d9a62929c2b0b6af2271be5464d7bd495532 100644 (file)
--- a/radeon/radeon_cs.h
+++ b/radeon/radeon_cs.h
-/*
+/*
* Copyright © 2008 Nicolai Haehnle
* Copyright © 2008 Jérôme Glisse
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
struct radeon_cs_manager;
extern struct radeon_cs *radeon_cs_create(struct radeon_cs_manager *csm,
- uint32_t ndw);
+ uint32_t ndw);
extern int radeon_cs_begin(struct radeon_cs *cs,
- uint32_t ndw,
- const char *file,
- const char *func, int line);
+ uint32_t ndw,
+ const char *file,
+ const char *func, int line);
extern int radeon_cs_end(struct radeon_cs *cs,
- const char *file,
- const char *func,
- int line);
+ const char *file,
+ const char *func,
+ int line);
extern int radeon_cs_emit(struct radeon_cs *cs);
extern int radeon_cs_destroy(struct radeon_cs *cs);
extern int radeon_cs_erase(struct radeon_cs *cs);
extern void radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit);
extern void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *data);
extern int radeon_cs_write_reloc(struct radeon_cs *cs,
- struct radeon_bo *bo,
- uint32_t read_domain,
- uint32_t write_domain,
- uint32_t flags);
+ struct radeon_bo *bo,
+ uint32_t read_domain,
+ uint32_t write_domain,
+ uint32_t flags);
/*
* add a persistent BO to the list
* is a state emission with a color/textures etc followed by a bunch of vertices.
*/
void radeon_cs_space_add_persistent_bo(struct radeon_cs *cs,
- struct radeon_bo *bo,
- uint32_t read_domains,
- uint32_t write_domain);
+ struct radeon_bo *bo,
+ uint32_t read_domains,
+ uint32_t write_domain);
/* reset the persistent BO list */
void radeon_cs_space_reset_bos(struct radeon_cs *cs);
* a temporary BO is like a DMA buffer, which gets flushed with the
* command buffer */
int radeon_cs_space_check_with_bo(struct radeon_cs *cs,
- struct radeon_bo *bo,
- uint32_t read_domains,
- uint32_t write_domain);
+ struct radeon_bo *bo,
+ uint32_t read_domains,
+ uint32_t write_domain);
static inline void radeon_cs_write_dword(struct radeon_cs *cs, uint32_t dword)
{
@@ -130,12 +130,12 @@ static inline void radeon_cs_write_qword(struct radeon_cs *cs, uint64_t qword)
}
static inline void radeon_cs_write_table(struct radeon_cs *cs,
- void *data, uint32_t size)
+ void *data, uint32_t size)
{
memcpy(cs->packets + cs->cdw, data, size * 4);
cs->cdw += size;
if (cs->section_ndw) {
- cs->section_cdw += size;
+ cs->section_cdw += size;
}
}
#endif
diff --git a/radeon/radeon_cs_gem.h b/radeon/radeon_cs_gem.h
index 5efd146f6b3d7990320223fa44b52a6a3090404e..5dea38ad2415d86ef262e2b8bfbda4d0740713be 100644 (file)
--- a/radeon/radeon_cs_gem.h
+++ b/radeon/radeon_cs_gem.h
-/*
+/*
* Copyright © 2008 Nicolai Haehnle
* Copyright © 2008 Jérôme Glisse
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
index b8054e13dce47a16745adc297e8aae5834b65b57..208e1bbf9ba3d6a6cd07274914bc605373ad8f64 100644 (file)
--- a/radeon/radeon_cs_space.c
+++ b/radeon/radeon_cs_space.c
-/*
+/*
* Copyright © 2009 Red Hat Inc.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
@@ -50,54 +50,54 @@ static inline int radeon_cs_setup_bo(struct radeon_cs_space_check *sc, struct ra
/* legacy needs a static check */
if (radeon_bo_is_static((struct radeon_bo *)sc->bo)) {
- bo->space_accounted = sc->new_accounted = (read_domains << 16) | write_domain;
- return 0;
+ bo->space_accounted = sc->new_accounted = (read_domains << 16) | write_domain;
+ return 0;
}
/* already accounted this bo */
if (write_domain && (write_domain == bo->space_accounted)) {
- sc->new_accounted = bo->space_accounted;
- return 0;
+ sc->new_accounted = bo->space_accounted;
+ return 0;
}
if (read_domains && ((read_domains << 16) == bo->space_accounted)) {
- sc->new_accounted = bo->space_accounted;
- return 0;
+ sc->new_accounted = bo->space_accounted;
+ return 0;
}
if (bo->space_accounted == 0) {
- if (write_domain == RADEON_GEM_DOMAIN_VRAM)
- sizes->op_vram_write += bo->size;
- else if (write_domain == RADEON_GEM_DOMAIN_GTT)
- sizes->op_gart_write += bo->size;
- else
- sizes->op_read += bo->size;
- sc->new_accounted = (read_domains << 16) | write_domain;
+ if (write_domain == RADEON_GEM_DOMAIN_VRAM)
+ sizes->op_vram_write += bo->size;
+ else if (write_domain == RADEON_GEM_DOMAIN_GTT)
+ sizes->op_gart_write += bo->size;
+ else
+ sizes->op_read += bo->size;
+ sc->new_accounted = (read_domains << 16) | write_domain;
} else {
- uint16_t old_read, old_write;
-
- old_read = bo->space_accounted >> 16;
- old_write = bo->space_accounted & 0xffff;
-
- if (write_domain && (old_read & write_domain)) {
- sc->new_accounted = write_domain;
- /* moving from read to a write domain */
- if (write_domain == RADEON_GEM_DOMAIN_VRAM) {
- sizes->op_read -= bo->size;
- sizes->op_vram_write += bo->size;
- } else if (write_domain == RADEON_GEM_DOMAIN_GTT) {
- sizes->op_read -= bo->size;
- sizes->op_gart_write += bo->size;
- }
- } else if (read_domains & old_write) {
- sc->new_accounted = bo->space_accounted & 0xffff;
- } else {
- /* rewrite the domains */
- if (write_domain != old_write)
- fprintf(stderr,"WRITE DOMAIN RELOC FAILURE 0x%x %d %d\n", bo->handle, write_domain, old_write);
- if (read_domains != old_read)
- fprintf(stderr,"READ DOMAIN RELOC FAILURE 0x%x %d %d\n", bo->handle, read_domains, old_read);
- return RADEON_CS_SPACE_FLUSH;
- }
+ uint16_t old_read, old_write;
+
+ old_read = bo->space_accounted >> 16;
+ old_write = bo->space_accounted & 0xffff;
+
+ if (write_domain && (old_read & write_domain)) {
+ sc->new_accounted = write_domain;
+ /* moving from read to a write domain */
+ if (write_domain == RADEON_GEM_DOMAIN_VRAM) {
+ sizes->op_read -= bo->size;
+ sizes->op_vram_write += bo->size;
+ } else if (write_domain == RADEON_GEM_DOMAIN_GTT) {
+ sizes->op_read -= bo->size;
+ sizes->op_gart_write += bo->size;
+ }
+ } else if (read_domains & old_write) {
+ sc->new_accounted = bo->space_accounted & 0xffff;
+ } else {
+ /* rewrite the domains */
+ if (write_domain != old_write)
+ fprintf(stderr,"WRITE DOMAIN RELOC FAILURE 0x%x %d %d\n", bo->handle, write_domain, old_write);
+ if (read_domains != old_read)
+ fprintf(stderr,"READ DOMAIN RELOC FAILURE 0x%x %d %d\n", bo->handle, read_domains, old_read);
+ return RADEON_CS_SPACE_FLUSH;
+ }
}
return 0;
}
@@ -113,48 +113,48 @@ static int radeon_cs_do_space_check(struct radeon_cs_int *cs, struct radeon_cs_s
/* check the totals for this operation */
if (cs->bo_count == 0 && !new_tmp)
- return 0;
+ return 0;
memset(&sizes, 0, sizeof(struct rad_sizes));
/* prepare */
for (i = 0; i < cs->bo_count; i++) {
- ret = radeon_cs_setup_bo(&cs->bos[i], &sizes);
- if (ret)
- return ret;
+ ret = radeon_cs_setup_bo(&cs->bos[i], &sizes);
+ if (ret)
+ return ret;
}
if (new_tmp) {
- ret = radeon_cs_setup_bo(new_tmp, &sizes);
- if (ret)
- return ret;
+ ret = radeon_cs_setup_bo(new_tmp, &sizes);
+ if (ret)
+ return ret;
}
-
+
if (sizes.op_read < 0)
- sizes.op_read = 0;
+ sizes.op_read = 0;
/* check sizes - operation first */
if ((sizes.op_read + sizes.op_gart_write > csm->gart_limit) ||
- (sizes.op_vram_write > csm->vram_limit)) {
- return RADEON_CS_SPACE_OP_TO_BIG;
+ (sizes.op_vram_write > csm->vram_limit)) {
+ return RADEON_CS_SPACE_OP_TO_BIG;
}
-
+
if (((csm->vram_write_used + sizes.op_vram_write) > csm->vram_limit) ||
- ((csm->read_used + csm->gart_write_used + sizes.op_gart_write + sizes.op_read) > csm->gart_limit)) {
- return RADEON_CS_SPACE_FLUSH;
+ ((csm->read_used + csm->gart_write_used + sizes.op_gart_write + sizes.op_read) > csm->gart_limit)) {
+ return RADEON_CS_SPACE_FLUSH;
}
-
+
csm->gart_write_used += sizes.op_gart_write;
csm->vram_write_used += sizes.op_vram_write;
csm->read_used += sizes.op_read;
/* commit */
for (i = 0; i < cs->bo_count; i++) {
- bo = cs->bos[i].bo;
- bo->space_accounted = cs->bos[i].new_accounted;
+ bo = cs->bos[i].bo;
+ bo->space_accounted = cs->bos[i].new_accounted;
}
if (new_tmp)
- new_tmp->bo->space_accounted = new_tmp->new_accounted;
-
+ new_tmp->bo->space_accounted = new_tmp->new_accounted;
+
return RADEON_CS_SPACE_OK;
}
@@ -164,10 +164,10 @@ void radeon_cs_space_add_persistent_bo(struct radeon_cs *cs, struct radeon_bo *b
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
int i;
for (i = 0; i < csi->bo_count; i++) {
- if (csi->bos[i].bo == boi &&
- csi->bos[i].read_domains == read_domains &&
- csi->bos[i].write_domain == write_domain)
- return;
+ if (csi->bos[i].bo == boi &&
+ csi->bos[i].read_domains == read_domains &&
+ csi->bos[i].write_domain == write_domain)
+ return;
}
radeon_bo_ref(bo);
i = csi->bo_count;
@@ -181,7 +181,7 @@ void radeon_cs_space_add_persistent_bo(struct radeon_cs *cs, struct radeon_bo *b
}
static int radeon_cs_check_space_internal(struct radeon_cs_int *cs,
- struct radeon_cs_space_check *tmp_bo)
+ struct radeon_cs_space_check *tmp_bo)
{
int ret;
int flushed = 0;
again:
ret = radeon_cs_do_space_check(cs, tmp_bo);
if (ret == RADEON_CS_SPACE_OP_TO_BIG)
- return -1;
+ return -1;
if (ret == RADEON_CS_SPACE_FLUSH) {
- (*cs->space_flush_fn)(cs->space_flush_data);
- if (flushed)
- return -1;
- flushed = 1;
- goto again;
+ (*cs->space_flush_fn)(cs->space_flush_data);
+ if (flushed)
+ return -1;
+ flushed = 1;
+ goto again;
}
return 0;
}
int radeon_cs_space_check_with_bo(struct radeon_cs *cs,
- struct radeon_bo *bo,
- uint32_t read_domains, uint32_t write_domain)
+ struct radeon_bo *bo,
+ uint32_t read_domains, uint32_t write_domain)
{
struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
struct radeon_cs_space_check temp_bo;
-
+
int ret = 0;
if (bo) {
- temp_bo.bo = boi;
- temp_bo.read_domains = read_domains;
- temp_bo.write_domain = write_domain;
- temp_bo.new_accounted = 0;
+ temp_bo.bo = boi;
+ temp_bo.read_domains = read_domains;
+ temp_bo.write_domain = write_domain;
+ temp_bo.new_accounted = 0;
}
ret = radeon_cs_check_space_internal(csi, bo ? &temp_bo : NULL);
struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
int i;
for (i = 0; i < csi->bo_count; i++) {
- radeon_bo_unref((struct radeon_bo *)csi->bos[i].bo);
- csi->bos[i].bo = NULL;
- csi->bos[i].read_domains = 0;
- csi->bos[i].write_domain = 0;
- csi->bos[i].new_accounted = 0;
+ radeon_bo_unref((struct radeon_bo *)csi->bos[i].bo);
+ csi->bos[i].bo = NULL;
+ csi->bos[i].read_domains = 0;
+ csi->bos[i].write_domain = 0;
+ csi->bos[i].new_accounted = 0;
}
csi->bo_count = 0;
}
-
-