2

I have a latency issue when using UART on Raspberry Pi 2 and I want to disable DMA when using UART driver. I know that the Raspberry Pi 2 uses ampa_pl011 and I don't want use DMA. Can you tell me how to do that on this driver?

I tried to comment this line in pl011_startup() function but seem that it not effect.

/* Startup DMA */
//pl011_dma_startup(uap);

Have anything more that we need to change?

goldilocks
  • 58,859
  • 17
  • 112
  • 227
dongpham
  • 31
  • 8

2 Answers2

1

If the device chip/implementation requires DMA - you can not disable it, because there will be no way to transfer data there and back again. And - about the latency - usind DMA reduces latency, definitely not increasing it! You should try a different timer HZ frequencies for your kernel config to play with latencies, but never disable a DMA! Also try to change the preemption/task-switching algorythm in your kernel config. It seems that your kernel does not fit your task.

UPDATE: here is the video https://youtu.be/b-wYeuuxZnc

Alexey Vesnin
  • 926
  • 9
  • 16
  • Thanks for your reply. Because I have same issue on freescale imx6 about latency , after that I resolved it by disable DMA in imx uart driver. How do you think if I do that on rpi2 ?
    1. used DMA in imx_startup function :

    https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/tty/serial/imx.c?id=abc7882aacdb4b0e110026bff9b52fb783f4ebd8 2. remove DMA in imx_startup function, I resolved by do like that : https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/tty/serial/imx.c?id=0c727a42043f79db210cdde0366f9137b9c6bf5a

    – dongpham Apr 02 '16 at 16:02
  • The source way seems reasonable too, but I'd recommend to try a different hz/taskswitching algo first. I'm currently having no trouble with rpi2 uart at all : pi@pi ~ $ uname -a Linux pi.local 4.1.15-rpi #1 Wed Jan 13 00:48:00 UTC 2016 armv6l GNU/Linux – Alexey Vesnin Apr 02 '16 at 16:10
  • Thanks . But not easy to upgrade to new kernel because my application base on UART is wrote with kernel 3.18. On this kernel version, will not happen if I use sample application on uart, just happen latency with my application. The same on imx6. – dongpham Apr 02 '16 at 16:18
  • About different hz/taskswitching. Can you tell me how to do that? – dongpham Apr 02 '16 at 16:21
  • make menuconfig and try to switch options in timer frequency and Preemption Type. Kernel 3.18 is way too old, try a mainline one? – Alexey Vesnin Apr 02 '16 at 16:30
  • Hi Alexey Vesnin. where I can change hz/taskswitching? I can't found it in menuconfig? – dongpham Apr 05 '16 at 03:20
  • @dongpham HZ is a timer frequency in CPU/General settings, preemption model should be around there. Do you need a video to point you to the exact options? – Alexey Vesnin Apr 05 '16 at 18:51
  • @dongpham My facebook is here and in my profile, video is on it's way – Alexey Vesnin Apr 06 '16 at 14:59
  • Hi Alexey ! This is config.gz file that I got from /proc/config.gz on rpi board. – dongpham Apr 08 '16 at 06:35
  • @dongpham OMG! You have 100HZ(!!!) kernel - of course it's laggy like hell [ CONFIG_HZ=100 in your config ]. Even a RT(RealTime) kernel won't give you a good speed! – Alexey Vesnin Apr 08 '16 at 09:32
  • Can you tell me what number we should to change for CONFIG_HZ? I will try again. But I can see this number is default when build kernel on imx6 and rpi. Thanks ! – dongpham Apr 08 '16 at 10:01
  • @dongpham I've pointed a video for you. If you will need further info - say it =) – Alexey Vesnin Apr 08 '16 at 10:47
  • As your video, I have tried it but still have latency over than 3ms. You can see wave form in this picture – dongpham Apr 08 '16 at 12:06
  • have you re-compiled and installed a new kernel? Which HZ you've used? can you post your new config.gz ? – Alexey Vesnin Apr 08 '16 at 12:08
  • I rebuild and already boot with new kernel, I used 1000HZ, no force preemption. – dongpham Apr 08 '16 at 12:10
  • post your new config.gz please - I'll try to edit it manually, or let's use a TeamViewer and I'll connect to you? – Alexey Vesnin Apr 08 '16 at 12:11
  • This is new config file, link . I will prepare at home for Teamviewer in tomorrow. Thanks so much Alex. – dongpham Apr 08 '16 at 12:17
  • by the way - why so old kernel? try 4.1 or 4.4 ? – Alexey Vesnin Apr 08 '16 at 12:23
  • And have you recompiled your software with a new kernel? – Alexey Vesnin Apr 08 '16 at 12:29
  • Hi Alex. Today, I already update kernel and my uart driver, application to 4.1 and config kernel same you but it still latency. you can see my config kernel 4.1 in this link – dongpham Apr 11 '16 at 06:23
  • @dongpham try to disable a tickless option - will it be better? if not - we will hack some kernel source then ;) Don't worry - we will crack it! – Alexey Vesnin Apr 11 '16 at 13:42
0

I have resolved my issue. Because my application just send 1 byte at time but FIFO in uart driver setting with 8 byte FIFO trigger. That's root cause, we just need reduce down to 1 byte FIFO trigger. Thanks everyone, Thanks Alex so much for your support.!

dongpham
  • 31
  • 8