public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: Allow for different DMA and CPU bus offsets
Date: Wed, 18 May 2016 12:52:28 +0200	[thread overview]
Message-ID: <12218676.p29ELivsix@wuerfel> (raw)
In-Reply-To: <1463563981-69722-1-git-send-email-agraf@suse.de>

On Wednesday 18 May 2016 11:33:01 Alexander Graf wrote:
> diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
> index ba437f0..67bf8e1 100644
> --- a/arch/arm64/include/asm/dma-mapping.h
> +++ b/arch/arm64/include/asm/dma-mapping.h
> @@ -66,12 +66,16 @@ static inline bool is_device_dma_coherent(struct device *dev)
>  
>  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
>  {
> -       return (dma_addr_t)paddr;
> +       dma_addr_t dev_addr = (dma_addr_t)paddr;
> +
> +       return dev_addr - (dma_addr_t)__pfn_to_phys(dev->dma_pfn_offset);
>  }
>  
>  static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
>  {
> -       return (phys_addr_t)dev_addr;
> +       phys_addr_t paddr = (phys_addr_t)dev_addr;
> +
> +       return paddr + __pfn_to_phys(dev->dma_pfn_offset);
>  }
>  

The patch looks ok overall, but I think it's better to use an open-coded
shift instead of __pfn_to_phys/__pfn_to_phys here: those helpers convert
between actual page frame numbers and addresses, which may not always
be a 1:1 relationship, e.g. if someone wants to work around the crazy
"Principles of ARM Memory Maps White Paper" layout.

	Arnd

  reply	other threads:[~2016-05-18 10:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18  9:33 [PATCH] arm64: Allow for different DMA and CPU bus offsets Alexander Graf
2016-05-18 10:52 ` Arnd Bergmann [this message]
2016-05-18 13:45   ` Catalin Marinas
2016-05-18 13:50     ` Arnd Bergmann

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=12218676.p29ELivsix@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.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