在 USB 设备内部调用 USB 批量发送消息时出现问题 Linux 内核模块

发布于 2024-12-23 13:53:13 字数 279 浏览 1 评论 0原文

我有一个处理 USB 设备的内核模块。

碰巧我可以成功向设备发送 USB 批量消息,但该操作是在二进制属性的回调下进行的。

然而,当有事情发生时,我需要执行一个特定的操作。发生这种情况时,我需要向设备发送批量消息。发生的地方是自己的设备数据收入回调。如果我在那个地方发送批量消息,我会遇到内核恐慌。

有人能告诉我为什么吗?

如果那不是进行此类操作的适当地点,我可以在哪里安全地进行此操作?我如何发出信号让该操作在另一个地方完成?计时器?

请就这个具体问题提出建议。

I have a kernel module in which I deal with USB devices.

It happens that I can successfully send a USB bulk message to a device, but that operation is being made under the callback of a binary attribute.

However, there is a specific operation that I need to do when something happens. When that happens, I need to send a bulk message to the device. The place in which that occurs is the own device data income callback. If I send the bulk message in that place I get a kernel panic.

Can someone tell me why?

If that is not a proper place to do such operation, where can I safely do it? How can I signal the operation to be done in another place? A Timer?

Please advice regarding this specific problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沦落红尘 2024-12-30 13:53:13

我设法通过以下方法解决了我面临的问题:

  • 创建一个工作任务
  • 将正在进行的处理放入工作任务例程中
  • 每当我有足够的数据来处理我需要的数据时,我就会安排该工作任务。

我认为这种方法会带来更好的设计,因为花在中断处理上的时间因此减少了。

我现在可以平静地调用 usb_bulk_msg(...),因为我不再处于中断上下文中。这确实是问题所在。

I managed to solve the problem I was facing with the following approach:

  • Created a work task
  • Placed the processing that was being made into a work task routine
  • I schedule that work task every time I have enough data to process what I need.

I think this approach leads to a better design since the time spent in the interruption handle is thus reduced.

I can now invoke usb_bulk_msg(...) peacefully since I'm not in an interrupt context anymore. That was indeed the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文