video/rockchip: rga2: fix a page count calc err

the driver has a bug in calc of page num when virtual
address may not 4k align

Change-Id: I65e8d3017a0365409a69e2edce12f2d302bca298
Signed-off-by: Shixiang Zheng <shixiang.zheng@rock-chips.com>
This commit is contained in:
Shixiang Zheng
2019-04-08 20:55:28 +08:00
committed by Tao Huang
parent 1df1aa9a81
commit a138e144d9

View File

@@ -168,49 +168,65 @@ static int rga2_buf_size_cal(unsigned long yrgb_addr, unsigned long uv_addr, uns
stride = (w * 4 + 3) & (~3);
size_yrgb = stride*h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_RGBX_8888 :
stride = (w * 4 + 3) & (~3);
size_yrgb = stride*h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_RGB_888 :
stride = (w * 3 + 3) & (~3);
size_yrgb = stride*h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_BGRA_8888 :
stride = (w * 4 + 3) & (~3);
size_yrgb = stride * h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_RGB_565 :
stride = (w*2 + 3) & (~3);
size_yrgb = stride * h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_RGBA_5551 :
stride = (w*2 + 3) & (~3);
size_yrgb = stride * h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_RGBA_4444 :
stride = (w*2 + 3) & (~3);
size_yrgb = stride * h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
case RGA2_FORMAT_BGR_888 :
stride = (w*3 + 3) & (~3);
size_yrgb = stride * h;
start = yrgb_addr >> PAGE_SHIFT;
pageCount = (size_yrgb + PAGE_SIZE - 1) >> PAGE_SHIFT;
end = yrgb_addr + size_yrgb;
end = (end + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
pageCount = end - start;
break;
/* YUV FORMAT */
@@ -423,9 +439,6 @@ static int rga2_MapUserMemory(struct page **pages, uint32_t *pageTable,
for (i = 0; i < pageCount; i++) {
/* Get the physical address from page struct. */
pageTable[i] = page_to_phys(pages[i]);
/* ensure dst not flush null cache */
if (writeFlag && i >= pageCount - 2)
break;
rga_dma_flush_page(pages[i]);
}
for (i = 0; i < result; i++)
@@ -475,8 +488,6 @@ static int rga2_MapUserMemory(struct page **pages, uint32_t *pageTable,
<< PAGE_SHIFT)) & ~PAGE_MASK));
pte_unmap_unlock(pte, ptl);
pageTable[i] = (uint32_t)Address;
if ( writeFlag && (i >= pageCount - 2))
break;
rga_dma_flush_page(pfn_to_page(pfn));
}
up_read(&current->mm->mmap_sem);
@@ -576,8 +587,6 @@ static int rga2_mmu_info_BitBlt_mode(struct rga2_reg *reg, struct rga2_req *req)
req->dst.vir_w,
req->dst.vir_h,
&DstStart);
/* if vir_address not 4k align need more page */
DstPageCount += 2;
if (DstPageCount == 0)
return -EINVAL;
}