fix[mpp_dmabuf]: fix align cache line size calculate err

Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: Ide7daa58b12b22dc115acbbb7a9b8e305a167d57
This commit is contained in:
Yandong Lin
2024-01-12 10:10:34 +08:00
parent 8103281b96
commit 0e03d3bc70
2 changed files with 5 additions and 4 deletions

View File

@@ -40,6 +40,7 @@
#define MPP_SWAP(type, a, b) do {type SWAP_tmp = b; b = a; a = SWAP_tmp;} while(0)
#define MPP_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
#define MPP_ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
#define MPP_ALIGN_DOWN(x, a) ((x)&~((a)-1))
#define MPP_ALIGN_GEN(x, a) (((x)+(a)-1)/(a)*(a))
#define MPP_VSWAP(a, b) { a ^= b; b ^= a; a ^= b; }

View File

@@ -72,8 +72,8 @@ MPP_RET mpp_dmabuf_sync_partial_begin(RK_S32 fd, RK_S32 ro, RK_U32 offset, RK_U3
return MPP_OK;
sync.flags = DMA_BUF_SYNC_START | (ro ? DMA_BUF_SYNC_READ : DMA_BUF_SYNC_RW);
sync.offset = offset / CACHE_LINE_SIZE;
sync.len = MPP_ALIGN(length, CACHE_LINE_SIZE);
sync.offset = MPP_ALIGN_DOWN(offset, CACHE_LINE_SIZE);
sync.len = MPP_ALIGN(length + offset - sync.offset, CACHE_LINE_SIZE);
ret = ioctl(fd, DMA_BUF_IOCTL_SYNC_PARTIAL, &sync);
if (ret) {
@@ -103,8 +103,8 @@ MPP_RET mpp_dmabuf_sync_partial_end(RK_S32 fd, RK_S32 ro, RK_U32 offset, RK_U32
return MPP_OK;
sync.flags = DMA_BUF_SYNC_END | (ro ? DMA_BUF_SYNC_READ : DMA_BUF_SYNC_RW);
sync.offset = offset / CACHE_LINE_SIZE;
sync.len = MPP_ALIGN(length, CACHE_LINE_SIZE);
sync.offset = MPP_ALIGN_DOWN(offset, CACHE_LINE_SIZE);
sync.len = MPP_ALIGN(length + offset - sync.offset, CACHE_LINE_SIZE);
ret = ioctl(fd, DMA_BUF_IOCTL_SYNC_PARTIAL, &sync);
if (ret) {