Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1403009
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] arm64: Allow for different DMA and CPU bus offsets |
| Date | 2016-05-18 16:00 +0200 |
| Message-ID | <rAab0-2Rm-35@gated-at.bofh.it> (permalink) |
| References | <rA67n-eQ-9@gated-at.bofh.it> <rA7mO-10d-19@gated-at.bofh.it> <rAa1l-2O5-47@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wednesday 18 May 2016 14:45:55 Catalin Marinas wrote:
> On Wed, May 18, 2016 at 12:52:28PM +0200, Arnd Bergmann wrote:
> > 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.
>
> Nitpick: Even better to use the PFN_PHYS() macro as it matches the
> PFN_DOWN() in of_dma_configure(). I can fix it up when applying.
>
>
I'd probably avoid that for the same reason as avoiding __pfn_to_phys.
In practice all three methods do the same thing for now, and if someone
wanted to change one, they'd also have to audit all the existing users.
Arnd
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] arm64: Allow for different DMA and CPU bus offsets Alexander Graf <agraf@suse.de> - 2016-05-18 11:40 +0200
Re: [PATCH] arm64: Allow for different DMA and CPU bus offsets Arnd Bergmann <arnd@arndb.de> - 2016-05-18 13:00 +0200
Re: [PATCH] arm64: Allow for different DMA and CPU bus offsets Catalin Marinas <catalin.marinas@arm.com> - 2016-05-18 15:50 +0200
Re: [PATCH] arm64: Allow for different DMA and CPU bus offsets Arnd Bergmann <arnd@arndb.de> - 2016-05-18 16:00 +0200
csiph-web