linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Miles Chen <miles.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Cc: wsd_upstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Subject: Re: [PATCH v3] dma-debug: fix incorrect pfn calculation
Date: Tue, 3 Oct 2017 09:07:52 +0200	[thread overview]
Message-ID: <20171003070752.GA18928@lst.de> (raw)
In-Reply-To: <1506940241.28397.36.camel@mtkswgap22>

On Mon, Oct 02, 2017 at 06:30:41PM +0800, Miles Chen wrote:
> ARCHs like metag and xtensa define their mappings (non-vmalloc and
> non-linear) for dma allocation.

metag basically is a reimplementation of the vmalloc map mechanism
that should be easy to consolidate into the common one :(  xtensa
has a weird remapping into a different segment, something that I
vaguely remember mips used to support as well.

> These mapping types are architecture-dependent and should not be used
> outside arch folders. So it is hard to check the mappings and convert
> a virtual address to a correct pfn in lib/dam-debug.c
> 
> How about recording only vmalloc (by is_vmalloc_addr()) and linear
> address (by virt_addr_valid()) in lib/dma-debug? Since current 
> implementation is not correct for those ARCHs.
> 
> if (!is_vmalloc_addr(addr) && !virt_addr_valid(addr))
>     return;
> 
> or

This looks like a good start, although I'm not sure I'd trust
virt_addr_valid on every little arch.  In the worse case we'll
have to exclude offenders from supporting dma debug, so let's go
with that version.

> > > > +	entry->pfn	 = is_vmalloc_addr(virt) ? vmalloc_to_pfn(virt) :
> > > > +						page_to_pfn(virt_to_page(virt));
> > 
> > Please use normal if/else conditionsals:
> 
> Is this for better readability? I'll send another patch for this.

Yes.

      reply	other threads:[~2017-10-03  7:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27  3:48 [PATCH v3] dma-debug: fix incorrect pfn calculation miles.chen
2017-09-27 10:23 ` Robin Murphy
2017-10-01  8:04   ` Christoph Hellwig
2017-10-02 10:30     ` Miles Chen
2017-10-03  7:07       ` Christoph Hellwig [this message]

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=20171003070752.GA18928@lst.de \
    --to=hch-jcswghmuv9g@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=miles.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
    --cc=wsd_upstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).