Re: bus_to_virt equivalent

From: Russell King
Date: Tue Nov 08 2005 - 17:53:43 EST


On Tue, Nov 08, 2005 at 02:47:00PM -0800, Anil kumar wrote:
> Hi Matthew,
>
> Thanks for the reply.
> I can store the returned dma_addr from
> pci_map_sg/single or pci_map_page in a driver
> structure.
>
> struct page *page =
> virt_to_page(Cmnd->request_buffer);
> unsigned long offset = ((unsigned
> long)Cmnd->request_buffer &
> ~PAGE_MASK);
> dma_addr_t busaddr =
> pci_map_page(hostdata->pci_dev,
>
> page, offset,
>
> Cmnd->request_bufflen,
>
> scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
>
> But how do I convert this returned "busaddr" into a
> virtual addr?

You don't - that's architecture implementation detail which drivers
have _zero_ business knowing about.

As far as you're concerned, the virtual address is Cmnd->request_buffer.

Anyway, you're using the wrong interface - pci_map_single() takes
a virtual address. No need to play around getting the offset and
struct page for pci_map_page() when pci_map_single() implements
what you require.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/