Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105558
b: refs/heads/master
c: 6b51d51
h: refs/heads/master
v: v3
  • Loading branch information
Timur Tabi authored and Linus Torvalds committed Jul 24, 2008
1 parent 1cd6949 commit 53b0ef3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c25826a7cf1c61b5c6e6db8365172eb97ef39ef3
refs/heads/master: 6b51d51a9d24719f905ba9657b29e04efd82a7ea
60 changes: 22 additions & 38 deletions trunk/drivers/video/fsl-diu-fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,58 +279,42 @@ static struct diu_hw dr = {

static struct diu_pool pool;

/* To allocate memory for framebuffer. First try __get_free_pages(). If it
* fails, try rh_alloc. The reason is __get_free_pages() cannot allocate
* very large memory (more than 4MB). We don't want to allocate all memory
* in rheap since small memory allocation/deallocation will fragment the
* rheap and make the furture large allocation fail.
/**
* fsl_diu_alloc - allocate memory for the DIU
* @size: number of bytes to allocate
* @param: returned physical address of memory
*
* This function allocates a physically-contiguous block of memory.
*/

static void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys)
static void *fsl_diu_alloc(size_t size, phys_addr_t *phys)
{
void *virt;

pr_debug("size=%lu\n", size);
pr_debug("size=%zu\n", size);

virt = (void *)__get_free_pages(GFP_DMA | __GFP_ZERO, get_order(size));
virt = alloc_pages_exact(size, GFP_DMA | __GFP_ZERO);
if (virt) {
*phys = virt_to_phys(virt);
pr_debug("virt %p, phys=%llx\n", virt, (uint64_t) *phys);
return virt;
}
if (!diu_ops.diu_mem) {
printk(KERN_INFO "%s: no diu_mem."
" To reserve more memory, put 'diufb=15M' "
"in the command line\n", __func__);
return NULL;
}

virt = (void *)rh_alloc(&diu_ops.diu_rh_info, size, "DIU");
if (virt) {
*phys = virt_to_bus(virt);
memset(virt, 0, size);
pr_debug("virt=%p phys=%llx\n", virt,
(unsigned long long)*phys);
}

pr_debug("rh virt=%p phys=%llx\n", virt, (unsigned long long)*phys);

return virt;
}

static void fsl_diu_free(void *p, unsigned long size)
/**
* fsl_diu_free - release DIU memory
* @virt: pointer returned by fsl_diu_alloc()
* @size: number of bytes allocated by fsl_diu_alloc()
*
* This function releases memory allocated by fsl_diu_alloc().
*/
static void fsl_diu_free(void *virt, size_t size)
{
pr_debug("p=%p size=%lu\n", p, size);
pr_debug("virt=%p size=%zu\n", virt, size);

if (!p)
return;

if ((p >= diu_ops.diu_mem) &&
(p < (diu_ops.diu_mem + diu_ops.diu_size))) {
pr_debug("rh\n");
rh_free(&diu_ops.diu_rh_info, (unsigned long) p);
} else {
pr_debug("dma\n");
free_pages((unsigned long)p, get_order(size));
}
if (virt && size)
free_pages_exact(virt, size);
}

static int fsl_diu_enable_panel(struct fb_info *info)
Expand Down

0 comments on commit 53b0ef3

Please sign in to comment.