mirror of
https://github.com/genesi/linux-legacy.git
synced 2026-09-24 15:44:22 +00:00
amd-gpu: cut down the "hal" by moving some single-use functions
move kgsl_hal_alloc/freephysical to where they get used..
This commit is contained in:
@@ -63,41 +63,6 @@ extern int gpu_2d_irq, gpu_3d_irq;
|
||||
extern int enable_mmu;
|
||||
|
||||
|
||||
KGSLHAL_API int
|
||||
kgsl_hal_allocphysical(unsigned int virtaddr, unsigned int numpages, unsigned int scattergatterlist[])
|
||||
{
|
||||
/* allocate physically contiguous memory */
|
||||
|
||||
int i;
|
||||
void *va;
|
||||
|
||||
va = kgsl_mem_entry_alloc(virtaddr, numpages*PAGE_SIZE);
|
||||
|
||||
if (!va)
|
||||
return GSL_FAILURE_OUTOFMEM;
|
||||
|
||||
for (i = 0; i < numpages; i++) {
|
||||
scattergatterlist[i] = page_to_phys(vmalloc_to_page(va));
|
||||
va += PAGE_SIZE;
|
||||
}
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------- */
|
||||
|
||||
KGSLHAL_API int
|
||||
kgsl_hal_freephysical(unsigned int virtaddr, unsigned int numpages, unsigned int scattergatterlist[])
|
||||
{
|
||||
/* free physical memory */
|
||||
|
||||
kgsl_mem_entry_free(virtaddr);
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
||||
KGSLHAL_API int
|
||||
kgsl_hal_init(void)
|
||||
{
|
||||
|
||||
@@ -114,8 +114,6 @@ KGSLHAL_API int kgsl_hal_getshmemconfig(gsl_shmemconfig_t *config);
|
||||
KGSLHAL_API int kgsl_hal_getdevconfig(unsigned int device_id, struct kgsl_devconfig *config);
|
||||
KGSLHAL_API int kgsl_hal_setpowerstate(unsigned int device_id, int state, unsigned int value);
|
||||
KGSLHAL_API unsigned int kgsl_hal_getchipid(unsigned int device_id);
|
||||
KGSLHAL_API int kgsl_hal_allocphysical(unsigned int virtaddr, unsigned int numpages, unsigned int scattergatterlist[]);
|
||||
KGSLHAL_API int kgsl_hal_freephysical(unsigned int virtaddr, unsigned int numpages, unsigned int scattergatterlist[]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/mm.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#include <linux/mxc_kgsl.h>
|
||||
@@ -70,6 +71,10 @@
|
||||
((memdesc->priv & GSL_EXTALLOC_MASK) >> GSL_EXTALLOC_SHIFT)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// aperture index in shared memory object
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -209,7 +214,37 @@ kgsl_sharedmem_close(struct kgsl_sharedmem *shmem)
|
||||
return (result);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int kgsl_sharedmem_allocphysical(unsigned int virtaddr, unsigned int numpages, unsigned int scattergatterlist[])
|
||||
{
|
||||
/* allocate physically contiguous memory */
|
||||
|
||||
int i;
|
||||
void *va;
|
||||
|
||||
va = kgsl_mem_entry_alloc(virtaddr, numpages*PAGE_SIZE);
|
||||
|
||||
if (!va)
|
||||
return GSL_FAILURE_OUTOFMEM;
|
||||
|
||||
for (i = 0; i < numpages; i++) {
|
||||
scattergatterlist[i] = page_to_phys(vmalloc_to_page(va));
|
||||
va += PAGE_SIZE;
|
||||
}
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
int kgsl_sharedmem_freephysical(unsigned int virtaddr, unsigned int numpages, unsigned int scattergatterlist[])
|
||||
{
|
||||
/* free physical memory */
|
||||
|
||||
kgsl_mem_entry_free(virtaddr);
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
kgsl_sharedmem_alloc0(unsigned int device_id, unsigned int flags, int sizebytes, struct kgsl_memdesc *memdesc)
|
||||
@@ -361,13 +396,13 @@ KGSL_MEM_VDBG( "--> int kgsl_sharedmem_alloc(unsigned int dev
|
||||
if (scatterlist.pages)
|
||||
{
|
||||
// allocate physical pages
|
||||
result = kgsl_hal_allocphysical(memdesc->gpuaddr, scatterlist.num, scatterlist.pages);
|
||||
result = kgsl_sharedmem_allocphysical(memdesc->gpuaddr, scatterlist.num, scatterlist.pages);
|
||||
if (result == GSL_SUCCESS)
|
||||
{
|
||||
result = kgsl_mmu_map(mmu, memdesc->gpuaddr, &scatterlist, flags, current->tgid);
|
||||
if (result != GSL_SUCCESS)
|
||||
{
|
||||
kgsl_hal_freephysical(memdesc->gpuaddr, scatterlist.num, scatterlist.pages);
|
||||
kgsl_sharedmem_freephysical(memdesc->gpuaddr, scatterlist.num, scatterlist.pages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,8 +437,6 @@ kgsl_sharedmem_alloc(unsigned int device_id, unsigned int flags, int sizebytes,
|
||||
return status;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
kgsl_sharedmem_free0(struct kgsl_memdesc *memdesc, unsigned int pid)
|
||||
{
|
||||
@@ -427,7 +460,7 @@ kgsl_sharedmem_free0(struct kgsl_memdesc *memdesc, unsigned int pid)
|
||||
|
||||
if (!GSL_MEMDESC_EXTALLOC_ISMARKED(memdesc))
|
||||
{
|
||||
status |= kgsl_hal_freephysical(memdesc->gpuaddr, memdesc->size / PAGE_SIZE, NULL);
|
||||
status |= kgsl_sharedmem_freephysical(memdesc->gpuaddr, memdesc->size / PAGE_SIZE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user