freedreno/drm: notify valgrind about FD_BO_NOMAP maps
If the shader memory has been allocated with the FD_BO_NOMAP and got later allocated a memory chunk during fd_bo_upload(), this can result in the valgrind splat when it tries to release the free and/or cache the BO. To fix this issue, notify valgrind about newly mmaped shader memory. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26277>
This commit is contained in:
committed by
Marge Bot
parent
60686d4146
commit
fd6b3bf267
@@ -659,6 +659,16 @@ fd_bo_map(struct fd_bo *bo)
|
||||
return __fd_bo_map(bo);
|
||||
}
|
||||
|
||||
static void *
|
||||
fd_bo_map_for_upload(struct fd_bo *bo)
|
||||
{
|
||||
void *addr = __fd_bo_map(bo);
|
||||
if (bo->alloc_flags & FD_BO_NOMAP)
|
||||
VG_BO_MAPPED(bo);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void
|
||||
fd_bo_upload(struct fd_bo *bo, void *src, unsigned off, unsigned len)
|
||||
{
|
||||
@@ -667,7 +677,7 @@ fd_bo_upload(struct fd_bo *bo, void *src, unsigned off, unsigned len)
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy((uint8_t *)__fd_bo_map(bo) + off, src, len);
|
||||
memcpy((uint8_t *)fd_bo_map_for_upload(bo) + off, src, len);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -556,6 +556,12 @@ VG_BO_OBTAIN(struct fd_bo *bo)
|
||||
VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, 1);
|
||||
}
|
||||
}
|
||||
/* special case for fd_bo_upload */
|
||||
static inline void
|
||||
VG_BO_MAPPED(struct fd_bo *bo)
|
||||
{
|
||||
VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, 1);
|
||||
}
|
||||
#else
|
||||
static inline void
|
||||
VG_BO_ALLOC(struct fd_bo *bo)
|
||||
@@ -573,6 +579,10 @@ static inline void
|
||||
VG_BO_OBTAIN(struct fd_bo *bo)
|
||||
{
|
||||
}
|
||||
static inline void
|
||||
VG_BO_MAPPED(struct fd_bo *bo)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FD_DEFINE_CAST(parent, child) \
|
||||
|
||||
Reference in New Issue
Block a user