Skip to content
Snippets Groups Projects
Commit 21253572 authored by Xiaojun.Chen's avatar Xiaojun.Chen Committed by Gianfranco Mariotti
Browse files

LF-6205 [#imx-2897] openCV test ends in kernel panic


CL485410 [KERNEL SPACE] dev64x_234062: Merge CL484068 from dev64x. Check memory is allocated from reserved memory or not when wrap user memory. If the memory is allocated from the reserved memory, won't do cache operation for it. Add the gckOS as input parameter for import_page_map()/import_pfn_map() and import_physical_map() to transmit the info of reserved memory range by os->device. [Wang.Zijian]

Signed-off-by: default avatarXiaojun.Chen <xiaojun.chen@versilicon.com>
Signed-off-by: default avatarEric Guo <eric.guo@nxp.com>
parent 7baf88a0
No related branches found
No related tags found
1 merge request!156Draft: [i.MX] mxc: gpu-viv: apply patches
......@@ -115,9 +115,10 @@ struct um_desc
size_t pageCount;
size_t extraPage;
unsigned int alloc_from_res;
};
static int import_physical_map(struct um_desc *um, unsigned long phys)
static int import_physical_map(gckOS Os, struct um_desc *um, unsigned long phys)
{
um->type = UM_PHYSICAL_MAP;
um->physical = phys & PAGE_MASK;
......@@ -125,7 +126,32 @@ static int import_physical_map(struct um_desc *um, unsigned long phys)
return 0;
}
static int import_page_map(struct um_desc *um,
static gceSTATUS
phy_is_from_reserved(IN gckOS Os,
IN gctPHYS_ADDR_T Physical)
{
gceSTATUS status = gcvSTATUS_NOT_FOUND;
gckGALDEVICE device = Os->device;
if (device->contiguousSize) {
if ((Physical >= device->contiguousBase) &&
(Physical <= device->contiguousBase + device->contiguousSize)) {
status = gcvSTATUS_OK;
return status;
}
}
if (device->externalSize) {
if ((Physical >= device->externalBase) &&
(Physical <= device->externalBase + device->externalSize)) {
status = gcvSTATUS_OK;
return status;
}
}
return status;
}
static int import_page_map(gckOS Os, struct um_desc *um,
unsigned long addr, size_t page_count, size_t size)
{
int i;
......@@ -184,7 +210,10 @@ static int import_page_map(struct um_desc *um,
++um->chunk_count;
}
}
if (gcmIS_SUCCESS(phy_is_from_reserved(Os, (gctPHYS_ADDR_T)page_to_pfn(pages[0]) << PAGE_SHIFT)))
um->alloc_from_res = 1;
if (!um->alloc_from_res) {
#if gcdUSE_Linux_SG_TABLE_API
result = sg_alloc_table_from_pages(&um->sgt, pages, page_count,
addr & ~PAGE_MASK, size, GFP_KERNEL | gcdNOWARN);
......@@ -207,7 +236,8 @@ static int import_page_map(struct um_desc *um,
printk("[galcore]: %s: dma_map_sg failed\n", __FUNCTION__);
goto error;
}
dma_sync_sg_for_cpu(galcore_device, um->sgt.sgl, um->sgt.nents, DMA_FROM_DEVICE);
}
um->type = UM_PAGE_MAP;
um->pages = pages;
......@@ -228,7 +258,7 @@ static int import_page_map(struct um_desc *um,
}
static int import_pfn_map(struct um_desc *um,
static int import_pfn_map(gckOS Os, struct um_desc *um,
unsigned long addr, size_t pfn_count)
{
int i;
......@@ -343,9 +373,11 @@ static int import_pfn_map(struct um_desc *um,
++um->chunk_count;
}
}
if (gcmIS_SUCCESS(phy_is_from_reserved(Os, (gctPHYS_ADDR_T)pfns[0] << PAGE_SHIFT)))
um->alloc_from_res = 1;
if (pageCount == pfn_count)
{
if (pageCount == pfn_count && !um->alloc_from_res) {
#if gcdUSE_Linux_SG_TABLE_API
result = sg_alloc_table_from_pages(&um->sgt, pages, pfn_count,
addr & ~PAGE_MASK, pfn_count * PAGE_SIZE, GFP_KERNEL | gcdNOWARN);
......@@ -396,7 +428,6 @@ static int import_pfn_map(struct um_desc *um,
return -ENOTTY;
}
static gceSTATUS
_Import(
IN gckOS Os,
......@@ -513,17 +544,17 @@ _Import(
if (Physical != gcvINVALID_PHYSICAL_ADDRESS)
{
result = import_physical_map(UserMemory, Physical);
result = import_physical_map(Os, UserMemory, Physical);
}
else
{
if (vm_flags & VM_PFNMAP)
{
result = import_pfn_map(UserMemory, memory, pageCount);
result = import_pfn_map(Os, UserMemory, memory, pageCount);
}
else
{
result = import_page_map(UserMemory, memory, pageCount, Size);
result = import_page_map(Os, UserMemory, memory, pageCount, Size);
}
}
......@@ -801,7 +832,7 @@ _UserMemoryCache(
struct um_desc *um = Mdl->priv;
enum dma_data_direction dir;
if (um->type == UM_PHYSICAL_MAP)
if (um->type == UM_PHYSICAL_MAP || um->alloc_from_res)
{
_MemoryBarrier();
return gcvSTATUS_OK;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment