public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] instmem/gk20a: do not use non-portable dma_to_phys()
@ 2015-11-10  5:10 Alexandre Courbot
  2015-11-10 22:41 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Courbot @ 2015-11-10  5:10 UTC (permalink / raw)
  To: Dave Airlie, Ben Skeggs
  Cc: Guenter Roeck, Stephen Rothwell, linux-next, linux-kernel, gnurou,
	Alexandre Courbot

dma_to_phys() is not guaranteed to be available on all platforms and
should not be used outside of arch/. Replace it with what it is expected
to do in our case: simply cast the DMA handle to a physical address.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
index fc419bb8eab7..49451645a049 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
@@ -134,13 +134,17 @@ static void __iomem *
 gk20a_instobj_cpu_map_dma(struct nvkm_memory *memory)
 {
 	struct gk20a_instobj_dma *node = gk20a_instobj_dma(memory);
-	struct device *dev = node->base.imem->base.subdev.device->dev;
 	int npages = nvkm_memory_size(memory) >> 12;
 	struct page *pages[npages];
 	int i;
 
-	/* phys_to_page does not exist on all platforms... */
-	pages[0] = pfn_to_page(dma_to_phys(dev, node->handle) >> PAGE_SHIFT);
+	/*
+	 * Ideally we would have a function to translate a handle to a physical
+	 * address, but there is no portable way of doing this. However since we
+	 * always use the DMA API without an IOMMU, we can assume that handles
+	 * are actual physical addresses.
+	 */
+	pages[0] = pfn_to_page(((phys_addr_t)node->handle) >> PAGE_SHIFT);
 	for (i = 1; i < npages; i++)
 		pages[i] = pages[0] + i;
 
-- 
2.6.2

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

end of thread, other threads:[~2015-11-11  7:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-10  5:10 [PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Alexandre Courbot
2015-11-10 22:41 ` Andrew Morton
2015-11-11  2:29   ` Dave Airlie
2015-11-11  6:27   ` Alexandre Courbot
2015-11-11  6:52     ` Guenter Roeck
2015-11-11  7:18       ` Alexandre Courbot

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