[Top] [All Lists]

Re: pci_alloc_consistent usage

Subject: Re: pci_alloc_consistent usage
From: Atsushi Nemoto <>
Date: Tue, 27 May 2003 19:07:49 +0900 (JST)
In-reply-to: <>
Organization: TOSHIBA Personal Computer System Corporation
Original-recipient: rfc822;
References: <> <>
>>>>> On Tue, 27 May 2003 11:17:40 +0200, Ralf Baechle <> 
>>>>> said:
ralf> Use the value returned by pci_alloc_consistent in *dma_handle
ralf> instead of trying to do any conversions with of
ralf> pci_alloc_consistent's return value.

How about virt_to_page()?

Currently, many sound drivers (including ALSA) pass a
pci_alloc_consistent's return value to virt_to_page.  While
virt_to_page is defined as below, we can not pass KSEG1 address
(returned by pci_alloc_consistent) to virt_to_page.

#define __pa(x)         ((unsigned long) (x) - PAGE_OFFSET)
#define virt_to_page(kaddr)     (mem_map + (__pa(kaddr) >> PAGE_SHIFT))

Following definition can handle this case properly,

#define virt_to_page(kaddr)     (mem_map + (PHYSADDR(kaddr) >> PAGE_SHIFT))

But as ralf said, PHYSADDR() may be is a bit slower then __pa().

Is it worth to change?  Or should we fix the driver using virt_to_page
with pci_alloc_consistent?

Atsushi Nemoto

<Prev in Thread] Current Thread [Next in Thread>