将设备驱动程序代码映射到逻辑分析仪波形
根据 SDIO 规范,操作顺序(对于写入事务)如下所示:
Command53 -- CommandLatency -- Command53Response -- ResponseLatency -- startbit -- write-number-of-bytes -- CRC -- endbit -- WriteLatency - - 起始位--CRC--结束位--忙位。
在SDIO UART驱动程序的基准测试过程中,我得到的时间值超出了预期。发现大量延迟,尤其是在写入事务期间。
延迟的原因可能是调度程序将处理器时间分配给其他进程、工作队列延迟等。
我想分析和了解延迟。了解设备驱动程序代码和逻辑分析仪波形之间的映射可能会带来一些提示。
有人可以解释一下吗?
谢谢。
编辑1: 对不起!我假设了一些事情。
在 sdio_uart_transmit_chars() 有一个对 sdio_out()
的调用,它又调用 sdio_writeb() 并且此调用按字节(一次一个字节)写入 SDIO UART 设备。我修改了驱动程序以使用 sdio_writesb ()即多字节模式。这相对减少了写入X字节所需的时间。有趣的是,随着写入数据大小的增加,WriteLatency 呈指数增长(如上所述)。
这种延迟可能是由多种原因造成的。我想了解这些原因。
设置:我使用 Linux (v 2.6.32) 笔记本电脑和可加载内核模块(已修改 sdio_uart.c)
编辑2:
在这个问题中添加“SDIO”可能会产生误导..(目前不确定)。延迟的原因对于与硬件交互时的任何设备驱动程序来说都是通用的,并且可能与 SDIO 写入过程无关。
如果有人可以向我指出相关的在线资源,我很乐意在这里探索和更新结果。
希望这次我增加了更多的清晰度。如果我的问题仍然不清楚,请发表评论。
感谢您抽出时间。
编辑3:
是的,我正在查看逻辑分析器(LA)上的信号,并且写入期间和写入之间的延迟比我预期的要长。
给出关于时间值的想法:
对于 512 字节传输:在硬件级别理论上写入应花费 50 微秒 (us),但实际上我需要 200 us。
这150我们的差距就是我想了解的。
注:
1) 我对时间值进行四舍五入以简化情况。
2)所有时间值都是在内核级别计算的,这里不涉及用户空间问题。
As per SDIO specification, the sequence of operations (for write transaction) take place as:
Command53 -- CommandLatency -- Command53Response -- ResponseLatency -- startbit -- write-number-of-bytes -- CRC -- endbit -- WriteLatency -- startbit -- CRC -- endbit -- busybit.
During benchmarking of SDIO UART driver, the time values which I got were more than expected. A lot of latency was found especially during write transaction.
Reasons for latency could be scheduler allocating processor time to other processes, delay in work queues, etc.
I would like to analyze and understand the latency. May be understanding the mapping between the device driver code and the Logic Analyzer waveform can lead to some cue.
Can somebody shed some light on this?
Thank you.
EDIT 1:
Sorry! I assumed a few things.
In sdio_uart_transmit_chars() there is a call to sdio_out()
which in turn calls sdio_writeb() and this call writes byte wise (one byte at a time) to a SDIO UART device. I modified the driver to use sdio_writesb() i.e. multi-byte mode. This reduced the time taken to write X bytes relatively. Interestingly, with increase in size of write data, there was exponential increase in WriteLatency (as mentioned above).
This latency could be because of many reasons. I would like to understand these reasons.
Setup: I am using Linux (v 2.6.32) laptop and a loadable kernel module (which is modified sdio_uart.c)
EDIT 2:
May be adding 'SDIO' in this question is misleading..(not sure at the moment). The reasons for delay could be generic to any device driver while interacting with the hardware and it may be independent of SDIO write process.
If somebody can point me to related online resource, I would be happy to explore and update the result here.
Hope I added more clarity this time. Please comment if I the question is still not clear.
Thank you for your time.
EDIT 3:
Yes, I am looking at the signals on Logic Analyzer (LA) and there are longer delays during and between writes than I expected.
To give an idea about time values:
For 512 bytes transfer: At the hardware level theoretically the write should take 50 micro seconds (us), however in reality I got 200 us.
This gap of 150 us is what I want to understand.
Note:
1) I am rounding off the time values to simplify the case.
2) All the time values are calculated at Kernel level and no user space issue is involved here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
值得关注的一件事是,您的 sd 接口是否通过 DMA 运行,以便驱动程序可以对状态机进行编程,然后它自己运行,或者如果获取消息需要驱动程序重复服务,这可能会被其他驱动程序延迟内核义务。
您还可以查看是否存在 I/O 瓶颈,例如 SD 接口或其挂起的任何总线是否也用于其他用途?
最后,您可以寻找提高优先级的方法。在极端情况下,您可以切换到实时 SD 驱动程序而不是普通驱动程序。
One thing worth looking at is if your sd interface functions by DMA, such that the driver can program the state machine and then it just runs by itself, or if getting the message out requires repetitive service by the driver, which might be delayed by other kernel obligations.
You could also see if there may be an I/O bottleneck, for example is the SD interface or whatever bus it hangs off of also used for something else?
Finally you could search for ways to increase the priority. At an extreme, you could switch to a real time SD driver rather than a normal one.