All of lore.kernel.org
 help / color / mirror / Atom feed
* 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-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
[parent not found: <20050825165333.3D585339DD@sc8-sf-spam1.sourceforge.net>]

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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.