This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM62X: SPI ioctl take over one second

Part Number: PROCESSOR-SDK-AM62X

Tool/software:

1. AM62x with 10.0 SDK linux 6.6.32 - RT

2. As following code, send - recv SPI message over ioctl , each 112 bytes 1ms

struct timespec time_start, time_end, time_end_spi;
struct timespec ns_sleep;
uint64_t max_diff;
uint32_t cycle_ns = 1000000;
time_start = {0, 0};
time_end = {0, 0};
ns_sleep = {0, 0};
max_diff = 0;
ns_sleep.tv_sec = 0;
ns_sleep.tv_nsec = 400000;

while(1) {
    clock_gettime(CLOCK_REALTIME, &time_end);
    max_diff = TIMESPEC2NS(time_end) - TIMESPEC2NS(time_start);
    if (max_diff < cycle_ns) {
        nanosleep(&ns_sleep, nullptr);
        continue;
    }
    clock_gettime(CLOCK_REALTIME, &time_start);
    
    // spi / ioctl codes
    struct spi_ioc_transfer tr ;
    memset(&tr,0,sizeof(struct spi_ioc_transfer));
    tr.tx_buf = (unsigned long)tx;
    tr.rx_buf = (unsigned long)rx;
    tr.len = 112;
    tr.delay_usecs = 0;
    tr.speed_hz = 24000000;
    tr.bits_per_word = 8;

    ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
    if (ret < 1)
        printf("can't send spi message");
 
    // test codes
    clock_gettime(CLOCK_REALTIME, &time_end_spi);   
    max_diff = TIMESPEC2NS(time_end_spi) - TIMESPEC2NS(time_start);
    
    // max_diff
    if(max_diff > 10000000) {
        // over 10ms, here we can max_diff over 1 seconds!!!
    }
}
      
3. sometimes ioctl takes 1 seconds
 
thanks for any help!
Regrads
  • Do you have any other activity in your system which could impact this behavior?

    While the kernel is "RT", userspace is not. So it's important to understand the whole system-wide picture here.

    You can also try to increase the scheduling priority of your userspace thread to see if that has an impact.

    Regards, Andreas