From 66bbafb6f9d44da3baddac6d948ba361182dde2a Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 20 Aug 2009 17:57:37 +0300 Subject: [PATCH] radeon: Check from kernel if dma buffer is idle. This makes sure that objects are leaving wait list only when they are processed by gpu. Signed-off-by: Pauli Nieminen --- src/mesa/drivers/dri/radeon/radeon_bo_drm.h | 12 ++++++++++++ src/mesa/drivers/dri/radeon/radeon_bo_legacy.c | 13 +++++++++++++ src/mesa/drivers/dri/radeon/radeon_dma.c | 9 ++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_drm.h b/src/mesa/drivers/dri/radeon/radeon_bo_drm.h index 8789e3ab09b..24ba0fa2f30 100644 --- a/src/mesa/drivers/dri/radeon/radeon_bo_drm.h +++ b/src/mesa/drivers/dri/radeon/radeon_bo_drm.h @@ -73,6 +73,7 @@ struct radeon_bo_funcs { uint32_t pitch); int (*bo_get_tiling)(struct radeon_bo *bo, uint32_t *tiling_flags, uint32_t *pitch); + int (*bo_is_busy)(struct radeon_bo *bo, uint32_t *domain); }; struct radeon_bo_manager { @@ -170,6 +171,15 @@ static inline int _radeon_bo_wait(struct radeon_bo *bo, return bo->bom->funcs->bo_wait(bo); } +static inline int _radeon_bo_is_busy(struct radeon_bo *bo, + uint32_t *domain, + const char *file, + const char *func, + int line) +{ + return bo->bom->funcs->bo_is_busy(bo, domain); +} + static inline int radeon_bo_set_tiling(struct radeon_bo *bo, uint32_t tiling_flags, uint32_t pitch) { @@ -203,5 +213,7 @@ static inline int radeon_bo_is_static(struct radeon_bo *bo) _radeon_bo_debug(bo, opcode, __FILE__, __FUNCTION__, __LINE__) #define radeon_bo_wait(bo) \ _radeon_bo_wait(bo, __FILE__, __func__, __LINE__) +#define radeon_bo_is_busy(bo, domain) \ + _radeon_bo_is_busy(bo, busy, domain, __FILE__, __func__, __LINE__) #endif diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c index b1cc155f71a..a10c6b73abc 100644 --- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c +++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c @@ -542,6 +542,18 @@ static int bo_unmap(struct radeon_bo *bo) return 0; } +static int bo_is_busy(struct radeon_bo *bo, uint32_t *domain) +{ + *domain = 0; + if (bo->domains & RADEON_GEM_DOMAIN_GTT) + *domain = RADEON_GEM_DOMAIN_GTT; + else + *domain = RADEON_GEM_DOMAIN_CPU; + if (legacy_is_pending(bo)) + return -EBUSY; + else + return 0; +} static int bo_is_static(struct radeon_bo *bo) { @@ -559,6 +571,7 @@ static struct radeon_bo_funcs bo_legacy_funcs = { bo_is_static, NULL, NULL, + bo_is_busy }; static int bo_vram_validate(struct radeon_bo *bo, diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c index 7e6b74add86..a1835427f19 100644 --- a/src/mesa/drivers/dri/radeon/radeon_dma.c +++ b/src/mesa/drivers/dri/radeon/radeon_dma.c @@ -30,6 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ +#include #include "radeon_common.h" #include "main/simple_list.h" @@ -302,7 +303,13 @@ void radeonReturnDmaRegion(radeonContextPtr rmesa, int return_bytes) static int radeon_bo_is_idle(struct radeon_bo* bo) { - return bo->cref == 1; + uint32_t domain; + int ret = radeon_bo_is_busy(bo, &domain); + if (ret == -EINVAL) { + WARN_ONCE("Your libdrm or kernel doesn't have support for busy query.\n" + "This may cause small performance drop for you.\n"); + } + return ret != -EBUSY; } void radeonReleaseDmaRegions(radeonContextPtr rmesa) -- 2.30.2