Пример #1
0
unsigned long s3c_g3d_reserve_chunk(struct file* filp, unsigned int size)
{
	unsigned int loop_i, loop_j;

	unsigned int uiRequsetBlock = (int)(size / G3D_CHUNK_SIZE);

	if (size % G3D_CHUNK_SIZE > 0)
		printk("s3c_g3d_reserve_chunk : wrong estimated reserve memory\n");

	unsigned int uiMemMask = genMemmapMask(uiRequsetBlock);

 	for(loop_i = 0; loop_i < G3D_CHUNK_NUM - (uiRequsetBlock -1); loop_i++ ) {

		if ((g_uiFreeMemMap & (uiMemMask << loop_i)) == (uiMemMask << loop_i)) // check free memory at memory map
		{
			for(loop_j = loop_i; loop_j < loop_i + uiRequsetBlock ; loop_j++ )
			{
				g3d_bootm[loop_j].in_used = G3D_CHUCNK_RESERVED;
				g3d_bootm[loop_j].file_desc_id = (int)filp->private_data;
		 	}

			g_uiFreeMemMap &= ~(uiMemMask << loop_i); // remove free chunk block at memory map
			register_alloc_info(loop_i,uiMemMask << loop_i);

			printRemainChunk();
			return g3d_bootm[loop_i].phy_addr;
		}
	}

	printk("s3c_g3d_reserve_chunk failed : Cannot find adequate memory!\n");
    
	return 0;
}
Пример #2
0
unsigned long s3c_g3d_reserve_chunk(struct file* filp, unsigned int size)
{
	unsigned int loop_i, loop_j;

	unsigned int uiRequsetBlock = (int)(size / G3D_CHUNK_SIZE);
	unsigned long long uiMemMask = genMemmapMask(uiRequsetBlock);

	int chunk_start_num;
	int chunk_end_num;
	int enable_lmk = 0;

	unsigned int id = (unsigned int)filp->private_data;

	if (size % G3D_CHUNK_SIZE > 0)
		printk("s3c_g3d_reserve_chunk : wrong estimated reserve memory\n");

	if(!alloc_info_head)
	{
		chunk_start_num = 0;
		chunk_end_num = G3D_UI_CHUNK_NUM;
	}
	else if(alloc_info_head->file_desc_id==id) {
		chunk_start_num = 0;
		chunk_end_num = G3D_UI_CHUNK_NUM;
	}
	else{	
		chunk_start_num = G3D_UI_CHUNK_NUM;
		chunk_end_num = G3D_CHUNK_NUM;
		enable_lmk = 1;
	}
#ifdef LMK_PRC_KILL
        if(enable_lmk)  low_memory_killer(uiRequsetBlock,uiMemMask,id);
#endif

 	for(loop_i = chunk_start_num; loop_i < chunk_end_num - (uiRequsetBlock -1); loop_i++ ) {

		if ((g_uiFreeMemMap & (uiMemMask << loop_i)) == (uiMemMask << loop_i)) // check free memory at memory map
		{
			for(loop_j = loop_i; loop_j < loop_i + uiRequsetBlock ; loop_j++ )
			{
				g3d_bootm[loop_j].in_used = G3D_CHUCNK_RESERVED;
				g3d_bootm[loop_j].file_desc_id = (int)filp->private_data;
		 	}

			g_uiFreeMemMap &= ~(uiMemMask << loop_i); // remove free chunk block at memory map
			register_alloc_info(loop_i,uiMemMask << loop_i);

			printRemainChunk();
			return g3d_bootm[loop_i].phy_addr;
		}
	}

	printk("s3c_g3d_reserve_chunk failed : Cannot find adequate memory!\n");
    
	return 0;
}
Пример #3
0
unsigned long s3c_g3d_available_chunk_size(unsigned int request_size, unsigned int id)
{
	unsigned int loop_i, loop_j;

	unsigned int uiRequsetBlock = (int)(request_size / G3D_CHUNK_SIZE);
	unsigned long long uiMemMask = genMemmapMask(uiRequsetBlock);

	int chunk_start_num;
	int chunk_end_num;
	int enable_lmk;

	if (request_size % G3D_CHUNK_SIZE > 0)
		uiRequsetBlock += 1;


	if(!alloc_info_head)
	{
		enable_lmk = 0;
		chunk_start_num = 0;
		chunk_end_num = G3D_UI_CHUNK_NUM;
	}
	else if(alloc_info_head->file_desc_id==id) {
		enable_lmk = 0;
		chunk_start_num = 0;
		chunk_end_num = G3D_UI_CHUNK_NUM;
	}
	else{	
		enable_lmk = 1;
		chunk_start_num = G3D_UI_CHUNK_NUM;
		chunk_end_num = G3D_CHUNK_NUM;
	}
	
	for(loop_j = 0; loop_j < 3; loop_j++ ) {
		for(loop_i = chunk_start_num; loop_i < chunk_end_num - (uiRequsetBlock -1) ; loop_i++ ) {
		
			if ((g_uiFreeMemMap & (uiMemMask << loop_i)) == (uiMemMask << loop_i))
				return G3D_CHUNK_SIZE * uiRequsetBlock;			
		}
                if(loop_j <= 1){
		if(enable_lmk) low_memory_killer(uiRequsetBlock,uiMemMask,id);

		mutex_unlock(&mem_alloc_lock);
		printk("wait 0.%d sec to get releaing memory\n", loop_j);
		msleep(1);	
		mutex_lock(&mem_alloc_lock);
	}
	}

	printk("s3c_g3d_available_chunk_size failed : %s cannot find adequate memory!\n", enable_lmk ? "3D apps":"Surfaceflinger");
    
	return 0;
}
Пример #4
0
unsigned long s3c_g3d_available_chunk_size(unsigned int request_size, unsigned int id)
{
	unsigned int loop_i, loop_j;

	unsigned int uiRequsetBlock = (int)(request_size / G3D_CHUNK_SIZE);
	if (request_size % G3D_CHUNK_SIZE > 0)
		uiRequsetBlock += 1;

	unsigned int uiMemMask = genMemmapMask(uiRequsetBlock);
	int chunk_num;
	int need_safe = 0;

	
	if(alloc_info_head && alloc_info_head->file_desc_id==id) {
		need_safe = 1;
		chunk_num = G3D_SAFE_CHUNK_NUM;
	}
	else{	
		need_safe = 0;
		chunk_num = G3D_CHUNK_NUM;
	}

	for(loop_j = 0; loop_j < 10; loop_j++ ) {
		for(loop_i = 0; loop_i < chunk_num - (uiRequsetBlock -1) ; loop_i++ ) {
		
			if ((g_uiFreeMemMap & (uiMemMask << loop_i)) == (uiMemMask << loop_i))
				return G3D_CHUNK_SIZE * uiRequsetBlock;			
		}

		low_memory_killer(uiRequsetBlock,uiMemMask,id,need_safe);

		mutex_unlock(&mem_alloc_lock);
		printk("wait 0.%d sec to get releaing memory\n", loop_j);
		msleep(100);	
		mutex_lock(&mem_alloc_lock);
	}

	printk("s3c_g3d_available_chunk_size failed : Cannot find adequate memory!\n");
    
	return 0;
}
Пример #5
0
void s3c_g3d_release_chunk(unsigned int phy_addr, int size)
{
	unsigned int loop_i, loop_j;
	struct mm_struct *mm = current->mm;

	unsigned int uiRequsetBlock = (int)(size / G3D_CHUNK_SIZE);
	unsigned int uiMemMask = genMemmapMask(uiRequsetBlock);	

	for(loop_i = 0; loop_i < G3D_CHUNK_NUM - (uiRequsetBlock - 1); loop_i++ ) {
		if( g3d_bootm[loop_i].phy_addr == phy_addr ) {

			if ((g_uiFreeMemMap & (uiMemMask << loop_i)) != 0) // check free memory at memory map
			{
				printk("s3c_g3d_release_chunk : memory map is crashed");
				break;
			}
	
			do_munmap(mm, g3d_bootm[loop_i].vir_addr, size);
			g_uiFreeMemMap |= (uiMemMask << loop_i); // add free chunk block at memory map
			unregister_alloc_info(loop_i,uiMemMask << loop_i);

			for(loop_j = loop_i; loop_j < loop_i + uiRequsetBlock ; loop_j++ )
			{
				g3d_bootm[loop_j].in_used = G3D_CHUCNK_AVALIABLE;
				g3d_bootm[loop_j].file_desc_id = 0;
			}
	
			break;
		}
	}

	if(loop_i >= G3D_CHUNK_NUM)
		printk("s3c_g3d_release_chunk failed : Cannot find the phys_addr : 0x%p\n", (void*)phy_addr);

	printRemainChunk();	
}