1 ================= 2 Linux I2C and DMA 3 ================= 4 5 Given that I2C is a low-speed bus, over which 6 transferred are small, it is not considered a 7 time of writing, only 10% of I2C bus master dr 8 implemented. And the vast majority of transact 9 DMA for it will likely add more overhead than 10 11 Therefore, it is *not* mandatory that the buff 12 It does not seem reasonable to apply additiona 13 rarely used. However, it is recommended to use 14 message size is likely applicable for DMA. Mos 15 around 8 bytes (as of today, this is mostly an 16 any message of 16 byte or larger, it is probab 17 note that other subsystems you use might add r 18 I2C bus master driver is using USB as a bridge 19 safe buffers always, because USB requires it. 20 21 Clients 22 ------- 23 24 For clients, if you use a DMA safe buffer in i 25 flag with it. Then, the I2C core and drivers k 26 on it. Note that using this flag is optional. 27 updated to use this flag will work like before 28 using an unsafe DMA buffer. To improve this si 29 more and more clients and host drivers is the 30 that setting this flag makes only sense in ker 31 copied into kernel space anyhow. The I2C core 32 buffers in kernel space are always DMA capable 33 SMBus transactions via I2C, the buffers for bl 34 of i2c_master_send() and i2c_master_recv() fun 35 variants (i2c_master_send_dmasafe() and i2c_ma 36 know their buffers are DMA safe. Users of i2c_ 37 I2C_M_DMA_SAFE flag manually. 38 39 Masters 40 ------- 41 42 Bus master drivers wishing to implement safe D 43 the I2C core. One gives you a DMA-safe buffer 44 certain threshold is met:: 45 46 dma_buf = i2c_get_dma_safe_msg_buf(msg 47 48 If a buffer is returned, it is either msg->buf 49 bounce buffer. But you don't need to care abou 50 returned buffer. If NULL is returned, the thre 51 buffer could not be allocated. Fall back to PI 52 53 In any case, a buffer obtained from above need 54 function ensures a potentially used bounce buf 55 56 i2c_put_dma_safe_msg_buf(dma_buf, msg, 57 58 The last argument 'xferred' controls if the bu 59 message or not. No syncing is needed in cases 60 there was no data transferred. 61 62 The bounce buffer handling from the core is ge 63 allocate a new bounce buffer. If you want a mo 64 reusing pre-allocated buffers), you are free t 65 66 Please also check the in-kernel documentation 67 driver can be used as a reference example how 68 69 Final note: If you plan to use DMA with I2C (o 70 make sure you have CONFIG_DMA_API_DEBUG enable 71 you find various issues which can be complex t
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.