0
votes

I would like to alloc memory for a dma transfer between a PCI device and RAM. I am using the next function in order to alloc memory:

pci_alloc_consistent 

I want to alloc memory under 2GB. Otherwise, the pci device fail. But this function provides any address from my ram (4GB). Are there any solution?

BR

1

1 Answers

2
votes

You can call pci_set_coherent_dma_mask on the struct pci_dev *, or preferably call dma_set_coherent_mask on pcidev->dev to set the mask. Setting the mask to DMA_BIT_MASK(31) will restrict coherent mappings to the first 2 GiB. For consistency, you might also want to restrict the non-coherent mappings by calling pci_set_dma_mask or dma_set_mask.

A good place to call the above functions is from your PCI driver "probe" function.