public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: Dave Airlie <airlied@linux.ie>, Ben Skeggs <bskeggs@redhat.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
	gnurou@gmail.com
Subject: Re: [PATCH] instmem/gk20a: do not use non-portable dma_to_phys()
Date: Tue, 10 Nov 2015 14:41:44 -0800	[thread overview]
Message-ID: <20151110144144.39c2a4109c26e91f4f3fb47b@linux-foundation.org> (raw)
In-Reply-To: <1447132247-9767-1-git-send-email-acourbot@nvidia.com>

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?

  reply	other threads:[~2015-11-10 22:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151110144144.39c2a4109c26e91f4f3fb47b@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=gnurou@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox