2010-03-03 15 views
6

Estoy portando/depurando un controlador de dispositivo (que es usado por otro módulo kernel) y mirando hacia un callejón sin salida porque dma_sync_single_for_device() falla con un kernel oops.Dónde comenzar a aprender sobre Linux DMA/controladores de dispositivo/asignación de memoria

No tengo ni idea de qué se supone que tiene que hacer esa función y Google realmente no ayuda, por lo que probablemente necesite aprender más sobre este tema en total.

La pregunta es, ¿por dónde empezar?

Oh sí, en caso de que sea pertinente, el código se supone para funcionar en un PowerPC (y el Linux es OpenWRT)

EDIT: recursos en línea preferible (libros toman unos días para ser entregado :)

+0

Podría ayudar a tener el rastreo de oops (en forma simbólica). Eso no se supone que suceda, como probablemente hayas adivinado. La razón más probable es que se llame dos veces en la misma región DMA. –

+0

En realidad, creo que voy a publicar una nueva pregunta sobre esto (ya que el problema ocurre con 2.6.30.10, pero no en 2.6.23) – Kimvais

Respuesta

9

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

Bo OKS:

Linux Kernel Development (2nd Edition)

Essential Linux Device Drivers (Sólo los primeros 4 - 5 capítulos)

recursos útiles:

the Linux Cross Reference (investigable Kernel Fuente para todos los núcleos)

API changes in the 2.6 kernel series


dma_sync_single_for_device llama dma_sync_single_range_for_cpu un poco más arriba en el archivo y esta es la fuente de documentación (supongo que a pesar de que esto es para armar la interfaz y el comportamiento son los mismos):

/** 
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 */ 
3

Los capítulos de la Linux Device Drivers book (en la misma serie que Understanding the Linux Kernel, recomendado por @Matthew Flaschen) podría ser útil.

Puede descargar los capítulos indiivudales del LWN Website. Chapter 16 trata con DMA.

Cuestiones relacionadas