* I can't get mapping ram work (Arm kernel 2.4 )
[not found] <20050825165333.3D585339DD@sc8-sf-spam1.sourceforge.net>
@ 2005-08-25 17:19 ` ruben quiñones ruiz
2005-08-25 17:57 ` Antonino A. Daplas
0 siblings, 1 reply; 5+ messages in thread
From: ruben quiñones ruiz @ 2005-08-25 17:19 UTC (permalink / raw)
To: linux-fbdev-devel
Hello everybody,
I'm developing a framebuffer display driver with an armv5 based architecture
.
I've been able to send commands and display what I want using the Ioctl
methods (the display works fine).
But now I want to add the framebuffer funcionality , so I wrote:
static int slcdc_mmap(struct file *filp, struct vm_area_struct *vma)
{
unsigned long page,pos;
unsigned long start = (unsigned long)vma->vm_start;
unsigned long size = (unsigned long)(vma->vm_end-vma->vm_start);
printk("\nMMAP CALLED");
if(size > SLCDC_DATA_MEM_SIZE)
return -EINVAL;
pos = (unsigned long)slcdc_par.v_screen_start_address;
while(size>0){
page = virt_to_phys((void*)pos);
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
// This is an IO map - tell maydump to skip this VMA
vma->vm_flags |= VM_IO;
vma->vm_flags |= VM_RESERVED;
if(remap_page_range(start,page,PAGE_SIZE,PAGE_SHARED)){
printk("\n\nERRORRRR!!!!!!!!");
return -EAGAIN;
}
start+= PAGE_SIZE;
pos+= PAGE_SIZE;
size-= PAGE_SIZE;
}
return 0;
}
Where slcdc_par.v_screen_start_address; is the virtual adress of the
databuffer that must be sent (via a dma provided by the Cpu).
In user-space:
if(( pMapeo= (char *) mmap(NULL, screensize, PROT_READ |
PROT_WRITE,MAP_SHARED,fichero,0))==NULL) {
printf("Error al proyectar el archivo en memoria\n");
return(4);
}
if ((int)pMapeo == -1) {
printf("Error: failed to map device to memory.\n");
exit(4);
}
else
printf("\ntoro Ok %x",pMapeo);
memset(pMapeo,0xffff,screensize);
for (aux=0;aux<screensize;aux++){
printf("\n mapeo = %d",*(pMapeo+aux));
}
aux=ioctl(fichero,SLCDC_CMD_RAMWR,&prueba);
I call to mmap and write successfully (printf shows all 0xff ...) and after
that, I call the RAMWR ioctl:
case SLCDC_CMD_RAMWR:
printk("RAMWR ");
for (i=0;i<8;i++){
for (j=0;j<127;j++){
printk("\n Databuffer=%d",*(databuffer+i*128+j));
}
...send the data...
}
break;
Where databuffer is the physical address of
slcdc_par.v_screen_start_address;
But, when I run it, printk shows that the memory is filled with 0's instead
of the data written in user-space...
It seems like remap_page_range didn't work but I've been reading about all
this process in google and I haven't found the solution to my problem... (if
anyone wants to see how I initialize the buffer I'll post it... )
Yours faithfully,
Rubén Quiñones Ruiz -UAH University - Spain
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't get mapping ram work (Arm kernel 2.4 )
2005-08-25 17:19 ` ruben quiñones ruiz
@ 2005-08-25 17:57 ` Antonino A. Daplas
0 siblings, 0 replies; 5+ messages in thread
From: Antonino A. Daplas @ 2005-08-25 17:57 UTC (permalink / raw)
To: linux-fbdev-devel; +Cc: ruben quiñones ruiz
ruben quiñones ruiz wrote:
> Hello everybody,
>
> I'm developing a framebuffer display driver with an armv5 based
> architecture .
> I've been able to send commands and display what I want using the Ioctl
> methods (the display works fine).
>
> But now I want to add the framebuffer funcionality , so I wrote:
>
> static int slcdc_mmap(struct file *filp, struct vm_area_struct *vma)
> {
> unsigned long page,pos;
> unsigned long start = (unsigned long)vma->vm_start;
> unsigned long size = (unsigned long)(vma->vm_end-vma->vm_start);
> printk("\nMMAP CALLED");
> if(size > SLCDC_DATA_MEM_SIZE)
> return -EINVAL;
> pos = (unsigned long)slcdc_par.v_screen_start_address;
> while(size>0){
> page = virt_to_phys((void*)pos);
> vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> // This is an IO map - tell maydump to skip this VMA
> vma->vm_flags |= VM_IO;
> vma->vm_flags |= VM_RESERVED;
> if(remap_page_range(start,page,PAGE_SIZE,PAGE_SHARED)){
> printk("\n\nERRORRRR!!!!!!!!");
> return -EAGAIN;
> }
> start+= PAGE_SIZE;
> pos+= PAGE_SIZE;
> size-= PAGE_SIZE;
> }
>
> return 0;
> }
>
> Where slcdc_par.v_screen_start_address; is the virtual adress of the
> databuffer that must be sent (via a dma provided by the Cpu).
How did you allocate this buffer? Is is system RAM? If it's system RAM,
did you use kmalloc, vmalloc or __get_free_pages. (kmalloc, vmalloc usually
do not work, you have to use __get_free_pages).
Tony
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't get mapping ram work (Arm kernel 2.4 )
@ 2005-08-25 18:05 ruben quiñones ruiz
2005-08-26 2:05 ` Antonino A. Daplas
0 siblings, 1 reply; 5+ messages in thread
From: ruben quiñones ruiz @ 2005-08-25 18:05 UTC (permalink / raw)
To: linux-fbdev-devel
TONY wrote:
-----------
How did you allocate this buffer? Is is system RAM? If it's system RAM,
did you use kmalloc, vmalloc or __get_free_pages. (kmalloc, vmalloc usually
do not work, you have to use __get_free_pages).
Tony
---------
Hi Tony, yeah , I use __get_free_pages : (this function is called in int
init_module(void) )
int slcdc_init_buffer(void)
{
u_int required_pages;
u_int extra_pages;
u_int order;
struct page *page;
u16 *allocated_region;
printk("slcdc data buffer size = %x \n",(unsigned int)SLCDC_DATA_MEM_SIZE);
if(g_slcdc_dbuffer_address != NULL)
return -EINVAL;
if(g_slcdc_cbuffer_address != NULL)
return -EINVAL;
/*find order required to allocate enough memory for it*/
required_pages = SLCDC_DATA_MEM_SIZE >> PAGE_SHIFT;
for (order = 0; required_pages >> order; order++){;}
extra_pages = (1 << order) - required_pages;
printk("PAGE_SHIFT=0x%x required_pages=0x%x\n",PAGE_SHIFT,required_pages);
printk("extra_page=0x%x \n",extra_pages);
if((allocated_region = (u_char *)__get_free_pages(GFP_KERNEL | GFP_DMA,
order)) == NULL)
{
printk("can not allocated memory\n");
return -ENOMEM;
}
g_slcdc_dbuffer_address = (u_char *)allocated_region + (extra_pages <<
PAGE_SHIFT);
g_slcdc_dbuffer_phyaddress = (u_char
*)__virt_to_phys((u_long)g_slcdc_dbuffer_address);
printk("g_slcdc_dbuffer_address=0x%x \n",(unsigned
int)g_slcdc_dbuffer_address);
/* Free all pages that we don't need but were given to us because */
/* __get_free_pages() works on powers of 2. */
for (;extra_pages;extra_pages--)
free_page((u_int)allocated_region + ((extra_pages-1) << PAGE_SHIFT));
/* Set reserved flag for fb memory to allow it to be remapped into */
/* user space by the common fbmem driver using remap_page_range(). */
for(page = virt_to_page(g_slcdc_dbuffer_address);
page < virt_to_page(g_slcdc_dbuffer_address + SLCDC_DATA_MEM_SIZE);
page++)
{
mem_map_reserve(page);
}
slcdc_par.screen_start_address
=(u_char*)((u_long)g_slcdc_dbuffer_phyaddress);
slcdc_par.v_screen_start_address
=(u_char*)((u_long)g_slcdc_dbuffer_address);
printk("startaddr= 0x%x, phyaddr=0x%x , size=0x%x \n",(unsigned
int)slcdc_par.screen_start_address,(unsigned
int)slcdc_par.v_screen_start_address,(unsigned int)SLCDC_DATA_MEM_SIZE);
memset(slcdc_par.v_screen_start_address,0,SLCDC_DATA_MEM_SIZE);
g_slcdc_cbuffer_address =
consistent_alloc(GFP_KERNEL|GFP_DMA,(SLCDC_CMD_MEM_SIZE+4),&g_slcdc_cbuffer_phyaddress);
g_slcdc_cbuffer_address = (u_long)g_slcdc_cbuffer_address & 0xfffffff4;
g_slcdc_cbuffer_phyaddress = (u_long)g_slcdc_cbuffer_phyaddress &
0xfffffff4;
printk("slcdc data buffer address = %x cmd buffer address= %x \n",(unsigned
int)slcdc_par.screen_start_address,(unsigned int) g_slcdc_cbuffer_address);
return 0;
}
I think , I must have a stupid error that fuck's me.. but I don't find it
:-p
Yours Faithfully,
Rubén Quiñones Ruiz -- UAH University -- Spain
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't get mapping ram work (Arm kernel 2.4 )
2005-08-25 18:05 I can't get mapping ram work (Arm kernel 2.4 ) ruben quiñones ruiz
@ 2005-08-26 2:05 ` Antonino A. Daplas
0 siblings, 0 replies; 5+ messages in thread
From: Antonino A. Daplas @ 2005-08-26 2:05 UTC (permalink / raw)
To: linux-fbdev-devel
ruben quiñones ruiz wrote:
> TONY wrote:
> -----------
> How did you allocate this buffer? Is is system RAM? If it's system RAM,
> did you use kmalloc, vmalloc or __get_free_pages. (kmalloc, vmalloc usually
> do not work, you have to use __get_free_pages).
> Tony
> ---------
>
> Hi Tony, yeah , I use __get_free_pages : (this function is called in int
> init_module(void) )
>
Hmm, I don't see anything obviously wrong with the code. Maybe you can
post this at the ARM mailing list (linux-arm-kernel@lists.arm.linux.org.uk).
Tony
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't get mapping ram work (Arm kernel 2.4 )
@ 2005-08-26 8:07 ruben quiñones ruiz
0 siblings, 0 replies; 5+ messages in thread
From: ruben quiñones ruiz @ 2005-08-26 8:07 UTC (permalink / raw)
To: linux-fbdev-devel
Tony wrote:
Hmm, I don't see anything obviously wrong with the code. Maybe you can
post this at the ARM mailing list (linux-arm-kernel@lists.arm.linux.org.uk).
Tony
Thanks for the answer... I'm suscribing in the Arm mailing list :-)
On the other hand, I have another GPL driver for another display using the
same code that works perfectly.. so I thought it was a stupid mistake...
Best Regards,
Rubén Quiñones Ruiz --UAH University -- Spain
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-08-26 8:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-25 18:05 I can't get mapping ram work (Arm kernel 2.4 ) ruben quiñones ruiz
2005-08-26 2:05 ` Antonino A. Daplas
-- strict thread matches above, loose matches on Subject: below --
2005-08-26 8:07 ruben quiñones ruiz
[not found] <20050825165333.3D585339DD@sc8-sf-spam1.sourceforge.net>
2005-08-25 17:19 ` ruben quiñones ruiz
2005-08-25 17:57 ` Antonino A. Daplas
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).