call wake_up_interruptible() cost strange thing

Hello,

I write a driver on tx2, using interrupt to let user know that transmission done is done.When it get an interrupt, it would use wake_up_interruptible() to wake up a queue, which is poll_wait in .poll function. I print before and after calling wake_up_interruptible() function. from the kernel message, I see that this function call needs about some milliseconds, usually 5-10ms. I also use it on a PC with the same ubuntu 16.04 system, the function only costs some microseconds (us). Is there some quick method to use interrupt?

hello shconan,

wake_up_interruptible() function call is waiting for the wait_queue_head.
you should review your interrupt functions.

moreover, if you’re adding debug prints to evaluate system timing.
please execute below commands to ignore console prints get more accurate results.
thanks

sudo dmesg --console-off

Hi JerryChang,

Thank u a lot. Your suggestion works really well and soon solve my question. using dmesg --console-off works and it only cost little time.
In another way, I also use a reg to store the dma finish state and query it in loops in user application, that also works.

However, since it use little time, there exists another problem. I use mmap as this link (https://devtalk.nvidia.com/default/topic/1014290/jetson-tx2/how-to-map-kernel-memory-to-user-memory-/1) says to get memory fast. I print some values of the memories in user mode. Most of the time, the value is correct. But sometimes, the values of two times are equal, i.e. I print mem[0] after two dmas and get the same values.

I use pci_alloc_consistent to alloc buffers. I tried to use pgprot_noncache() function, but it make dma too slow. I didn’t disable smmu since everything looked work well. Is there any help about this?

Thanks a lot.

hello shconan,

could you help us narrow down the issue?
please check this both from kernel and user-space side.
thanks

Hi JerryChang,

Sorry for reply late.

If I do memcpy in kernel side, such as memcpy() in read function, all the values seem correct while it costs much time, several microseconds. If I do memcpy in user-space, the values are the same as mmap memory, which shows that wrong values as I described above.

I also searched from the internet, and found use dma_sync_single_for_cpu function could solve this problem, which also need some time cost.

If you have other suggestions, plz let me know. thx a lot

hello shconan,

since wake_up_interruptible() function call works as expect.
your following question looks like timing issue, which i would suggest you file a new topic with appropriate titles.
thanks

Hi JerryChang,

Thx for your suggestion. Sorry for continueing the following question. I would file a new topic for a new question and here this topic should be closed.

Thx a lot for your help.