Charles Brown wrote: > Grant, > > Early on I was using the altpciechdma driver as reference, but the > hardware engineer doesn't want me controlling the DMA on the card. So, > we're just using memcpy_toio/fromio. > > That design also has the card providing host->board IO memory using > BAR0 and board->host using BAR2, but the HW engineer only wants to > provide host->board memory in BAR0, and me to provide the memory for > board->host - by allocating appropriate memory and handing back a > physical address. He has BAR2 set to 0. > > At this point, my best reference has been discarded, and I'm looking > for another. So, I'll track down the two you mention. In the > meanintime, my code snippets are below - I've left out all my debug > printk's and error checking cruft. The iomstart is an address > calculated from /proc/iomem, hence my mis-calling it "I/O memory". > > Thank you for spending some time with me on this. > > --CB > > /** start address for iomem block to allocate for read space */ > unsigned long iomstart = 0, iomlength = 0; > module_param(iomstart,ulong,0); > module_param(iomlength,ulong,0); > > ...snip... > > void alt_onInit(void) > { > int i, status = 0; > struct resource * resource = NULL; > > /* request IO memory for incoming data */ > resource = request_mem_region(iomstart, iomlength, DEVNAME); Ehm, no, this functions is to request a memory range for something supplied from a hardware device, not you requesting RAM to pass to the device. I would have done it like this: void __iomem *mem; void *outmem; dma_addr_t outmem_phys; // enable device (managed mode) pcim_enable_device(pdev); // claim BARs pci_request_regions(pdev, DRIVER_NAME); // map BAR0, full size mem = pcim_iomap(pdev, 0, 0); // get memory that is usable by DMA outmem = pci_alloc_consistent(pdev, PAGE_SIZE, &outmem_phys); // tell board about it memcpy_toio(dest + 4, &outmem_phys, sizeof(outmem_phys)); Greetings, Eike
Attachment:
signature.asc
Description: This is a digitally signed message part.