linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Timur Tabi <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org, linux-fbdev-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fsl-diu-fb: Update Freescale DIU driver to use page_alloc_exact()
Date: Mon, 30 Jun 2008 13:24:26 -0700	[thread overview]
Message-ID: <20080630132426.a89c32b0.akpm@linux-foundation.org> (raw)
In-Reply-To: <1214325853-26150-1-git-send-email-timur@freescale.com>

On Tue, 24 Jun 2008 11:44:13 -0500
Timur Tabi <timur@freescale.com> wrote:

> Update the Freescale DIU driver to use page_alloc_exact() to allocate a
> DMA buffer.  This also eliminates the rheap-based memory allocator.  We
> can do this now because commit 6ccf61f9 allows us to allocate 8MB physically-
> contiguous memory blocks.
> 
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
> 
> My other patch, "Add alloc_pages_exact() and free_pages_exact()", must be
> applied first, otherwise drivers/video/fsl-diu-fb.c will not compile.
> 
>  drivers/video/fsl-diu-fb.c |   59 +++++++++++++++----------------------------
>  1 files changed, 21 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
> index 0a27853..d15d265 100644
> --- a/drivers/video/fsl-diu-fb.c
> +++ b/drivers/video/fsl-diu-fb.c
> @@ -279,58 +279,41 @@ 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.
>   */
> -
> -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=%u\n", size);

Nope, this will generate warnings on some architectures.

The way to print a size_t is with %zu or %zd.  I guess the latter is for
ssize_t.


> -	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, (uint64_t) *phys);

This is also incorrect.  We cannot pass u64 or uint64_t into printk at
all.  We do not know what type the architectures uses to implement
them.  It should be cast to a known type.  In this case `unsigned long
long'.

  reply	other threads:[~2008-06-30 20:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24 16:44 [PATCH] fsl-diu-fb: Update Freescale DIU driver to use page_alloc_exact() Timur Tabi
2008-06-30 20:24 ` Andrew Morton [this message]
2008-07-04 10:32   ` Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080630132426.a89c32b0.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=timur@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).