public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: how to get virtual address from dma address
@ 2001-10-03 16:37 Linux Bigot
  2001-10-03 19:32 ` Ben Collins
  0 siblings, 1 reply; 31+ messages in thread
From: Linux Bigot @ 2001-10-03 16:37 UTC (permalink / raw)
  To: jes; +Cc: linux-kernel

Please tell me why can't I use bus_to_virt().

Thanks


-----Original Message-----
From:	Jes Sorensen [SMTP:jes@sunsite.dk]
Sent:	Wednesday, October 03, 2001 11:26 AM
To:	Linux Bigot
Cc:	linux-kernel@vger.kernel.org
Subject:	Re: how to get virtual address from dma
address

>>>>> "Linux" == Linux Bigot <linuxopinion@yahoo.com>
writes:

Linux> All programmers I am relatively new to linux
kernel. Please
Linux> advise what is the safe way to get the original
virtaul address
Linux> from dma address e.g.,

You have to store the address you pass to
pci_map_single() somewhere
in your data structures together with the dma address.

Jes
-
To unsubscribe from this list: send the line
"unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at 
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com

^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: how to get virtual address from dma address
@ 2001-10-03 22:44 James Bottomley
  2001-10-04  0:24 ` David S. Miller
  2001-10-05 14:06 ` Jes Sorensen
  0 siblings, 2 replies; 31+ messages in thread
From: James Bottomley @ 2001-10-03 22:44 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Linux Bigot, linux-kernel

> Linux> All programmers I am relatively new to linux kernel. Please
> Linux> advise what is the safe way to get the original virtaul address
> Linux> from dma address e.g.,

> You have to store the address you pass to pci_map_single() somewhere
> in your data structures together with the dma address.

Yes, but speaking as someone who had to use a large hammer to convert his 
driver from bus_to_virt et al.,  it does seem rather hard not to have the 
equivalent for the new pci_dma paradigm.  It does present an obstacle 
persuading people to convert drivers, particularly if the hardware is going to 
present a linked list of addresses (as SCSI hardware often does).

After all, whatever device maps between the io bus and the memory bus, it must 
always map a given dma_addr_t to a known physical address.  It can't be that 
hard to provide an an API in the kernel which can compute this relationship 
(although I can see it may be expensive to walk iommu page tables).  I'm only 
really asking for a dma_addr_t to virtual address by the way.  I see that 
mapping the other way would be problematic.

James Bottomley



^ permalink raw reply	[flat|nested] 31+ messages in thread
[parent not found: <Pine.LNX.4.21.0110031525370.14852-100000@pogo.esscom.com>]
* Re: how to get virtual address from dma address
@ 2001-10-03 21:30 Manfred Spraul
  0 siblings, 0 replies; 31+ messages in thread
From: Manfred Spraul @ 2001-10-03 21:30 UTC (permalink / raw)
  To: Linux Bigot; +Cc: linux-kernel

> Then why isn't there a call like pci_unmap_single()

<<< linux/include/asm-i386/pci.h:
/* Unmap a single streaming mode DMA translation.  The dma_addr and size
 * must match what was provided for in a previous pci_map_single call.
All
 * other usages are undefined.
 *
 * After this call, reads by the cpu to the buffer are guarenteed to see
 * whatever the device wrote there.
 */
static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t
dma_addr,
                                    size_t size, int direction)
<<<<

Please try to store both the dma address and the virtual address in your
driver and use pci_map_single().
I'm aware of one case where that's not possible: if your hardware builds
a linked list of finished commands, and that list is in DMA addresses,
not virtual addresses.
I think both sym53c8xx and one of the USB controllers (usb-ohci.c?) have
that problem, they use a hash table for the reverse dma address->linear
address mapping.

I hope that answers your question.

--
    Manfred


^ permalink raw reply	[flat|nested] 31+ messages in thread
* how to get virtual address from dma address
@ 2001-10-03 14:11 Linux Bigot
  2001-10-03 15:25 ` Jes Sorensen
  0 siblings, 1 reply; 31+ messages in thread
From: Linux Bigot @ 2001-10-03 14:11 UTC (permalink / raw)
  To: linux-kernel

All programmers

I am relatively new to linux kernel. Please advise
what is the safe way to get the original virtaul
address from dma address e.g., 


dma_addr = pci_map_single(dev, vaddr, sizeof(struct
some), PCI_DMA_BIDIRECTIONAL);

issue_command_to_the_controller();

my_isr()
{
    struct some *some;

    dma_addr = this_address_completed();

--->some = how_to_get_from_dma_addr(dma_addr);
}

Would ioremap work.

TIA
   


__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2001-10-08 21:11 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-03 16:37 how to get virtual address from dma address Linux Bigot
2001-10-03 19:32 ` Ben Collins
2001-10-03 21:11   ` Linux Bigot
2001-10-03 21:23     ` Ben Collins
  -- strict thread matches above, loose matches on Subject: below --
2001-10-03 22:44 James Bottomley
2001-10-04  0:24 ` David S. Miller
2001-10-04 10:11   ` BALBIR SINGH
2001-10-04 11:16     ` David S. Miller
2001-10-04 15:37   ` James Bottomley
2001-10-05 14:06 ` Jes Sorensen
2001-10-06  8:06   ` Paul Mackerras
2001-10-06  8:38     ` David S. Miller
2001-10-06 12:18       ` Paul Mackerras
2001-10-06 14:45         ` James Bottomley
2001-10-06 16:51           ` Gérard Roudier
2001-10-06 17:23         ` Jes Sorensen
2001-10-07  2:13           ` Paul Mackerras
2001-10-07 17:40             ` Jes Sorensen
2001-10-07  7:21           ` Gérard Roudier
2001-10-07 16:23             ` James Bottomley
2001-10-07 18:24               ` Gérard Roudier
2001-10-07 23:02                 ` James Bottomley
2001-10-08 21:06                   ` Gérard Roudier
     [not found]       ` <mailman.1002371041.9232.linux-kernel2news@redhat.com>
2001-10-06 18:19         ` Pete Zaitcev
     [not found]   ` <mailman.1002355920.6872.linux-kernel2news@redhat.com>
2001-10-06 18:04     ` Pete Zaitcev
     [not found] <Pine.LNX.4.21.0110031525370.14852-100000@pogo.esscom.com>
2001-10-03 21:48 ` Linux Bigot
2001-10-03 22:03   ` Ben Collins
2001-10-05 14:04   ` Jes Sorensen
2001-10-03 21:30 Manfred Spraul
2001-10-03 14:11 Linux Bigot
2001-10-03 15:25 ` Jes Sorensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox