简体   繁体   中英

functionality of pci_set_dma_mask

I am bit confused for pci_set_dma_mask. So can somebody explain me what exactly happens in below code.

#define DMA_64BIT_MASK DMA_BIT_MASK(64)
pci_set_dma_mask(dev, DMA_64BIT_MASK)

Regards Rabinarayan

Basically DMA_BIT_MASK(64) is a macro that returns a 64bit address of '1's. ie. 0xFFFF FFFF FFFF FFFF

If DMA_BIT_MASK(32) is used, it would be 0xFFFF FFFF

pci_set_dma_mask(dev, DMA_64BIT_MASK) is used to query the pcie device represented by dev : do you support 64-bit DMA? dev is provided when the standard kernel driver initialization routines are called.

From kernel documentation :

It returns zero if your card can perform DMA properly on the machine given the address mask you provided. In general, the device struct of your device is embedded in the bus-specific device struct of your device. For example, &pdev->dev is a pointer to the device struct of a PCI device (pdev is a pointer to the PCI device struct of your device).

If it returns non-zero, your device cannot perform DMA properly on this platform, and attempting to do so will result in undefined behavior. You must either use a different mask, or not use DMA.

AFAIK know, this function returns 0 if the PCI device in parameter can perform the DMA on the supported PCI address. If it returns a non-zero then your device cannot perform DMA and the DMA translation (if used) is unpredictable.

Regardless of my answer, I don't think SO is a place for this kind of question as this is not really a problem that can have an absolutely correct "answer" or "solution"...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM