从哪里开始学习 Linux DMA/设备驱动/内存分配

发布于 08-24 04:32 字数 247 浏览 9 评论 0原文

我正在移植/调试设备驱动程序(由另一个内核模块使用)并面临死胡同,因为 dma_sync_single_for_device() 因内核错误而失败。

我不知道这个函数应该做什么,而且谷歌搜索也没有什么帮助,所以我可能需要了解更多关于这个东西的知识。

问题是,从哪里开始呢?

哦,是的,如果相关的话,代码应该在 PowerPC 上运行(Linux 是 OpenWRT)

编辑: 最好有在线资源(书籍需要几天才能送达:)

I'm porting / debugging a device driver (that is used by another kernel module) and facing a dead end because dma_sync_single_for_device() fails with an kernel oops.

I have no clue what that function is supposed to do and googling does not really help, so I probably need to learn more about this stuff in total.

The question is, where to start?

Oh yeah, in case it is relevant, the code is supposed to run on a PowerPC (and the linux is OpenWRT)

EDIT:
On-line resources preferrable (books take a few days to be delivered :)

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

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

发布评论

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

评论(3

动听の歌2024-08-31 04:32:49

在线:

Linuxlab 分配器剖析

了解 Linux 虚拟内存管理器

Linux 设备驱动程序,第三版

Linux 内核模块编程指南

在 Linux 中编写设备驱动程序:简要教程

书籍:

Linux 内核开发(第二版)

基本 Linux 设备驱动程序(仅前 4 - 5 章)

有用的资源:

Linux 交叉参考(所有内核的可搜索内核源代码)

2.6 内核系列中的 API 更改


dma_sync_single_for_device 进一步调用 dma_sync_single_range_for_cpu在文件中,这是源文档(我假设即使这是针对arm的,接口和行为是相同的):

/**
 380 * dma_sync_single_range_for_cpu
 381 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
 382 * @handle: DMA address of buffer
 383 * @offset: offset of region to start sync
 384 * @size: size of region to sync
 385 * @dir: DMA transfer direction (same as passed to dma_map_single)
 386 *
 387 * Make physical memory consistent for a single streaming mode DMA
 388 * translation after a transfer.
 389 *
 390 * If you perform a dma_map_single() but wish to interrogate the
 391 * buffer using the cpu, yet do not wish to teardown the PCI dma
 392 * mapping, you must call this function before doing so.  At the
 393 * next point you give the PCI dma address back to the card, you
 394 * must first the perform a dma_sync_for_device, and then the
 395 * device again owns the buffer.
 396 */

On-line:

Anatomy of the Linux slab allocator

Understanding the Linux Virtual Memory Manager

Linux Device Drivers, Third Edition

The Linux Kernel Module Programming Guide

Writing device drivers in Linux: A brief tutorial

Books:

Linux Kernel Development (2nd Edition)

Essential Linux Device Drivers ( Only the first 4 - 5 chapters )

Useful Resources:

the Linux Cross Reference ( Searchable Kernel Source for all Kernels )

API changes in the 2.6 kernel series


dma_sync_single_for_device calls dma_sync_single_range_for_cpu a little further up in the file and this is the source documentation ( I assume that even though this is for arm the interface and behavior are the same ):

/**
 380 * dma_sync_single_range_for_cpu
 381 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
 382 * @handle: DMA address of buffer
 383 * @offset: offset of region to start sync
 384 * @size: size of region to sync
 385 * @dir: DMA transfer direction (same as passed to dma_map_single)
 386 *
 387 * Make physical memory consistent for a single streaming mode DMA
 388 * translation after a transfer.
 389 *
 390 * If you perform a dma_map_single() but wish to interrogate the
 391 * buffer using the cpu, yet do not wish to teardown the PCI dma
 392 * mapping, you must call this function before doing so.  At the
 393 * next point you give the PCI dma address back to the card, you
 394 * must first the perform a dma_sync_for_device, and then the
 395 * device again owns the buffer.
 396 */
清君侧2024-08-31 04:32:49

Linux Device Drivers 一书(与 Understanding the Linux Kernel 同系列,由 @Matthew Flaschen 推荐)可能会有用。

您可以从LWN 网站下载各个章节。 第 16 章涉及 DMA。

The chapters of the Linux Device Drivers book (in the same series as Understanding the Linux Kernel, recommended by @Matthew Flaschen) might be useful.

You can download the indiivudal chapters from the LWN Website. Chapter 16 deals with DMA.

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