Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1266830

Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys()

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys()
Date 2015-11-10 23:50 +0100
Message-ID <qtpTH-2Jl-3@gated-at.bofh.it> (permalink)
References <qt9vz-JX-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 10 Nov 2015 14:10:47 +0900 Alexandre Courbot <acourbot@nvidia.com> wrote:

> 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.

mainline i386 allmodconfig is now busted.

> --- 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);

This looks ugly.

What's actually going on here?  Why is this driver doing something which
no other driver appears to need to do?

Is it the driver which is broken, or are the core kernel APIs inadequate?

If the latter, what can we do to fix them up?

IOW, how do we fix this properly?
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Alexandre Courbot <acourbot@nvidia.com> - 2015-11-10 06:20 +0100
  Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Andrew Morton <akpm@linux-foundation.org> - 2015-11-10 23:50 +0100
    Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Dave Airlie <airlied@gmail.com> - 2015-11-11 03:30 +0100
    Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Alexandre Courbot <gnurou@gmail.com> - 2015-11-11 07:30 +0100
      Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Guenter Roeck <linux@roeck-us.net> - 2015-11-11 08:00 +0100
        Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys() Alexandre Courbot <gnurou@gmail.com> - 2015-11-11 08:20 +0100

csiph-web