[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <546A09A2.9090704@citrix.com>
Date: Mon, 17 Nov 2014 14:43:46 +0000
From: David Vrabel <david.vrabel@...rix.com>
To: Stefano Stabellini <stefano.stabellini@...citrix.com>,
<gregkh@...uxfoundation.org>
CC: <linux-mips@...ux-mips.org>, <airlied@...ux.ie>,
<dri-devel@...ts.freedesktop.org>, <xen-devel@...ts.xensource.com>,
<linux@....linux.org.uk>, <vinod.koul@...el.com>, <deller@....de>,
<jejb@...isc-linux.org>, Ian Campbell <Ian.Campbell@...rix.com>,
<alexander.deucher@....com>, <bhelgaas@...gle.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-parisc@...r.kernel.org>, <dwmw2@...radead.org>,
<linux-kernel@...r.kernel.org>, <ralf@...ux-mips.org>,
<iommu@...ts.linux-foundation.org>,
David Vrabel <david.vrabel@...rix.com>,
<dmaengine@...r.kernel.org>, <torvalds@...ux-foundation.org>,
<christian.koenig@....com>
Subject: Re: [Xen-devel] [RFC] add a struct page* parameter to dma_map_ops.unmap_page
On 17/11/14 14:11, Stefano Stabellini wrote:
> Hi all,
> I am writing this email to ask for your advice.
>
> On architectures where dma addresses are different from physical
> addresses, it can be difficult to retrieve the physical address of a
> page from its dma address.
>
> Specifically this is the case for Xen on arm and arm64 but I think that
> other architectures might have the same issue.
>
> Knowing the physical address is necessary to be able to issue any
> required cache maintenance operations when unmap_page,
> sync_single_for_cpu and sync_single_for_device are called.
>
> Adding a struct page* parameter to unmap_page, sync_single_for_cpu and
> sync_single_for_device would make Linux dma handling on Xen on arm and
> arm64 much easier and quicker.
Using an opaque handle instead of struct page * would be more beneficial
for the Intel IOMMU driver. e.g.,
typedef dma_addr_t dma_handle_t;
dma_handle_t dma_map_single(struct device *dev,
void *va, size_t size,
enum dma_data_direction dir);
void dma_unmap_single(struct device *dev,
dma_handle_t handle, size_t size,
enum dma_data_direction dir);
etc.
Drivers would then use:
dma_addr_t dma_addr(dma_handle_t handle);
To obtain the bus address from the handle.
> I think that other drivers have similar problems, such as the Intel
> IOMMU driver having to call find_iova and walking down an rbtree to get
> the physical address in its implementation of unmap_page.
>
> Callers have the struct page* in their hands already from the previous
> map_page call so it shouldn't be an issue for them. A problem does
> exist however: there are about 280 callers of dma_unmap_page and
> pci_unmap_page. We have even more callers of the dma_sync_single_for_*
> functions.
You will also need to fix dma_unmap_single() and pci_unmap_single()
(another 1000+ callers).
You may need to consider a parallel set of map/unmap API calls that
return/accept a handle, and then converting drivers one-by-one as
required, instead of trying to convert every single driver at once.
David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists