流映射的设置是通过调用dma_set_mask()来执行的 intdma_set_mask(struct device*dev,u64 mask); 一致分配的设置是通过调用dma_set_coherent_mask()来执行的 intdma_set_coherent_mask(struct device*dev,u64 mask); 这里,dev 是指向设备的设备结构的指针,mask 是描述设备支持的地址的哪些位的位掩码。 ...
coherent_dma_mask :用来分配连续一致性dma。 dma_mask:在dma_map_single->dma_map_page,dma_capable用。 先看默认设置。后续可以通过pci_set_dma_mask/pci_set_consistent_dma_mask分别设置 设置: int pci_setup_device(struct pci_dev *dev) { u32 class; u16 cmd; u8 hdr_type; int pos = 0; stru...
int dma_set_mask(struct device *dev, u64 mask); 通过调用 dma_set_coherent_mask() 来执行一致分配的设置: int dma_set_coherent_mask(struct device *dev, u64 mask); 在这里,dev 是指向设备的设备结构的指针,而 mask 是一个位掩码,描述了您的设备支持的地址位。通常,设备的设备结构嵌入在设备的总线...
dma_set_coherent_mask(structdevice *dev, u64 mask) 检查是否可能使用该掩码,并更新设备参数(如果可能)。 返回:如果成功则返回0,否则返回负错误。 u64 dma_get_required_mask(structdevice *dev) 此API返回平台要求的掩码,通常意味着返回的掩码是覆盖所有内存所需的最小掩码。检查所需的掩码使具有可变描述符大...
dma_mask表示的是该设备通过DMA方式可寻址的物理地址范围,coherent_dma_mask表示所有设备通过DMA方式可寻址的公共的物理地址范围, 因为不是所有的硬件设备都能够支持64bit的地址宽度。 /include/linux/dma-mapping.h /** Set both the DMA mask and the coherent DMA mask to the same thing.* Note that we do...
int dma_set_coherent_mask(struct device *dev, u64 mask); 前者是设定streaming类型的DMA地址掩码,后者是设定coherent类型的DMA地址掩码。为了更好的理解这些接口,我们聊聊参数和返回值。dev指向该设备的struct device对象,一般来说,这个struct device对象应该是嵌入在bus-specific 的实例中,例如对于PCI设备,有一个...
* Set both the DMA mask and the coherent DMA mask to the same thing. * Note that we don't check the return value from dma_set_coherent_mask() * as the DMA API guarantees that the coherent DMA mask can be set to * the same or smaller than the streaming DMA mask. */ static inli...
例如,可以使用dma_set_coherent_mask()来设置一致性掩码,以确保DMA传输的一致性。 3.使用合适的DMA引擎:Linux内核支持多种DMA引擎,每种DMA引擎有不同的特性和性能。选择合适的DMA引擎可以提高数据传输的效率。可以使用DMA API中的函数和宏来选择和配置DMA引擎。 4.处理中断和回调:DMA传输完成后,通常会触发一个...
int dma_set_coherent_mask(struct device *dev, u64 mask) Checks to see if the mask is possible and updates the device parameters if it is. Returns: 0 if successful and a negative error if not. 检查掩码是否可行,如果可行则更新设备参数。如果成功,则返回 0;如果不成功,则返回负错误。
其中的函数dma_set_mask_and_coherent()用于对dma_mask和coherent_dma_mask赋值。 dma_mask表示的是该设备通过DMA方式可寻址的物理地址范围,coherent_dma_mask表示所有设备通过DMA方式可寻址的公共的物理地址范围, 因为不是所有的硬件设备都能够支持64bit的地址宽度。