Raw I/O to shared memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm having a problem where the method I am using for translation from virtual 
to physical address is not reliable.

I am working on an application where multiple programs access a shared memory 
segmet allocated with shmget(), and a device must directly access the memory.

I am using kiobuf_map_user() and virt_to_bus() to create a page table the 
hardware uses to convert a user logical address into a PCI bus address for 
the shared memory.

Sometimes it comes up working fine, and seems to continue to work until the 
system is restarted.  Other times after a restart, the virt_to_bus() returns 
0x40000000 for every address.  I've tried __pa() instead of virt_to_bus, but 
it had the same result.  This is on an x86 type CPU, so virt_to_bus() is the 
same as virt_to_phys().

My driver module is like this:
	unsigned int	user_virtual_address;		// task virtual shared memory address
	struct kiobuf	*iobuf;				// structure containing map info
	long			pci_address;			// bus address for the hardware to use

	if (map_user_kiobuf(READ, iobuf, (unsigned long) user_virtual_address, 1) != 
0)
		pci_address = virt_to_bus(page_address(iobuf->maplist[0]));

I believe map_user_kiobuf() forces the pages in, but I also tried adding 
mem_map_reserve(virt_to_page(page_address(iobuf->maplist[0]))); before 
virt_to_bus() and had the same result.

Can anyone tell me how I can reliably translate a user virtual address for 
host dram into a PCI bus address?

Dave Z



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux