I write this because I have some doubts about the behavior of DMA. I read about the location of PCI and how device drivers interact with the card, and I read about DMA. As I understand it, there is no DMA controller on PCI cards, instead they ask to be the bus master, and then they can receive the DMA address and transfer between the memory and the device (via the bus).
This DMA address is part of the RAM, in fact it is a physical address, and before you do anything, you need to convert it to something that your drivers can use, for example, in the kernel's virtual memory. I checked this with this code:
kernel_buff = pci_alloc_consistent(dev, PAGE_SIZE, &dma_addr);
pr_info("Kernel buffer - %12p , Dma_addr - %12p\n", kernel_buff, (void *)dma_addr );
pr_info( "Kernelbuffer - dma_addr - %12p\n", kernel_buff - dma_addr);
strcpy(kernel_buff, "Test dma\n");
ptest = (void *)dma_addr;
ptest = phys_to_virt((unsigned long)ptest);
pr_info("Ptest virtual memory(%p) containts - %s\n", ptest, (char *)ptest);
And the result was:
[425971.835669] Kernel buffer - ffff8800ca70a000 , Dma_addr - ca70a000
[425971.835671] Kernelbuffer - dma_addr - ffff880000000000
[425971.835673] Ptest virtual memory(ffff8800ca70a000) containts - Test dma
This is how I understood that DMA is part of RAM.
, .
, , , , , ? , ?
DMA.
/:
- , :
pci_resource_start
, ?
, ? / .
, DMA, / , , ?
, ( ) .