Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: TCM access on s3c6410 - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

TCM access on s3c6410 Rate Topic: -----

#1 User is offline   Zova 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 09-June 11

Posted 22 July 2011 - 03:30 AM

Hi all,
I'm trying to use the TCM provided by S3c6410, which contains 16K ITCM and 16K DTCM.
Yeah, after a lot of searches and readings, I secceeded to write a simple driver to setup I/D-TCMs, and by issuing insmod to enable TCM at some physical memory address (not assigned according to system memory map in UM) when startup.
I wrote a very simple example to test. I got results show that the L1 cache + TCM way is even slower than just using L1 cache. Here's the code of the example:
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include <string.h>
 
#define MAP_SIZE 8192 
#define MAP_MASK (MAP_SIZE-1)

off_t dphybase = 0x0c002000;
off_t dphybase2 = 0x0c004000;
 
 
int main(){
    	struct timeval startTime;
    	struct timeval endTime;
    	char ram_buff[MAP_SIZE], ram_buff2[MAP_SIZE], ch;
    	char* tcm_buff;
    	char* tcm_buff2;
    	int i, mdesc, span, mag=10*MAP_SIZE, k;
 
    	if((mdesc = open("/dev/mem",O_RDWR)) == 0) {
            	perror("Error openning file /dev/mem");
            	return;
    	}
 
    	tcm_buff = (char *)mmap(0, MAP_SIZE,PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, mdesc, dphybase&~MAP_MASK);
    	tcm_buff2 = (char *)mmap(0, MAP_SIZE,PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, mdesc, dphybase2&~MAP_MASK);
 
    	if((tcm_buff == (void*)-1)) {
            	perror("Error mapping");
            	return;
    	}
 
    	for(i=0;i<MAP_SIZE;i++){
            	ram_buff[i] = i%128;
            	ram_buff2[i] = i%128;
            	tcm_buff[i] = i%128;
            	tcm_buff2[i] = i%128;
    	}
 
    	/*
    	* time ram_buff access
    	*/
    	memset(&startTime, 0, sizeof(struct timeval));
    	memset(&endTime, 0, sizeof(struct timeval));
    	gettimeofday(&startTime, (struct timezone *) NULL);
    	//read every one byte
    	for(k=0;k<mag;k++)
    	for(i=0;i<MAP_SIZE;i++) {
            	ch = ram_buff[i];
            	//ch += ram_buff2[i];
            	//ram_buff[i] = ch;
    	}
            	//printf("%d ", ram_buff[i]);   
 
    	//printf("\n");
 
    	gettimeofday(&endTime, (struct timezone *) NULL);
 
 
    	span = (endTime.tv_sec - startTime.tv_sec) * 1000000LL;
    	span += (endTime.tv_usec - startTime.tv_usec);
    	printf("Total time of ram_buffer access: %ld\n", span);
 
 
    	/*
    	* time tcm_buff access
    	*/
    	memset(&startTime, 0, sizeof(struct timeval));
    	memset(&endTime, 0, sizeof(struct timeval));
    	gettimeofday(&startTime, (struct timezone *) NULL);
    	//read every one byte
    	for(k=0;k<mag;k++)
    	for(i=0;i<MAP_SIZE;i++){
            	ch = tcm_buff[i];
            	//ch += tcm_buff2[i];
            	//tcm_buff[i] = ch;
            	//printf("%d ", tcm_buff[i]);
    	}
    	//printf("\n");
 
    	gettimeofday(&endTime, (struct timezone *) NULL);
 
 
    	span = (endTime.tv_sec - startTime.tv_sec) * 1000000LL;
    	span += (endTime.tv_usec - startTime.tv_usec);
    	printf("Total time of tcm_buffer access: %ld\n", span);
    	munmap(tcm_buff, MAP_SIZE);
    	return 0;
}

output:
Total time of ram_buffer access: 16888375
Total time of tcm_buffer access: 21927893



As shown in the code, I choose /dev/mem + mmap to operate on TCM.

Q1. Something wrong with my example or is it properate to test efficiecy of TCM vs. Cache and to conclude that TCM's slower?

I doubted about the physical address assigned to TCM(the UM does not show where they are assigned!!! WHY?), so I tried 0x0C002000 and 0x80004000, but results didn't change. Maybe both of them are wrong location as arm info center says TCM's base address can be anywhere. ANYWHERE maybe somewhere aleady given to other devices...
So, question 2, anyone knows where to put TCMs in system memory map?

Q3. If my example is right, then what may be the cause of the lose to cache?
Q4. What's secure/non-secure access to TCM? I may config TCM as secure or non-secure according to here, but how do I know the access to TCM is secure or not?

Thanks,
Zova
0

#2 User is offline   Zova 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 09-June 11

Posted 23 July 2011 - 04:25 AM

up
0

#3 User is offline   Zova 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 09-June 11

Posted 27 July 2011 - 01:19 AM

Anyone knows how to disable cache on ARM1176ZJF-S?
I want to try to disable Cache to check it TCM really works. I read related topics in info center.It seems that I need to disable MMU first? :huh: And I find some discussions on the web, showing:

MMU
/ \
Cache TCM

Is that right? Or it may be this since info center says disabling MMU does NOT influence TCM:

MMU
|
Cache TCM

Please help me out.

This post has been edited by Zova: 27 July 2011 - 01:20 AM

0

#4 User is offline   Zova 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 09-June 11

Posted 01 August 2011 - 03:03 AM

From the Ref, I find out that's L1 DMA for TCM blocks transfering. Right now, I use the open("/dev/mem") + mmap to directly read/write the virtual address returned by mmap, like var = tcm_addr[i] or tcm_addr[i] = var in user space. Since a dedicated L1 DMA is provided, does it mean the direct access to TCM like I did above is wrong?? Do I need to transfer blocks from main memory to TCM each time I want to put data to it?
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic