[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20190220162053.abe9ffde0f6d347a281bbe49@suse.de>
Date: Wed, 20 Feb 2019 16:20:53 +0100
From: Thomas Bogendoerfer <tbogendoerfer@...e.de>
To: Christoph Hellwig <hch@...radead.org>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>,
James Hogan <jhogan@...nel.org>, linux-kernel@...r.kernel.org,
linux-mips@...r.kernel.org, linux-pci@...r.kernel.org,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Paul Burton <paul.burton@...s.com>,
Ralf Baechle <ralf@...ux-mips.org>
Subject: Re: [PATCH 6/7] MIPS: SGI-IP27: use generic PCI driver
On Wed, 20 Feb 2019 07:10:56 -0800
Christoph Hellwig <hch@...radead.org> wrote:
> On Mon, Feb 18, 2019 at 11:58:07AM +0100, Thomas Bogendoerfer wrote:
> > This of course will break SH7786. To fix both cases how about making dma_pfn_offset
> >
> > a signed long ?
>
> Yes, making it signed sounds like a good idea.
but at least my implementation looks a little bit ugly:
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index b7338702592a..b72b1cba8911 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -12,14 +12,20 @@ static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
{
dma_addr_t dev_addr = (dma_addr_t)paddr;
- return dev_addr - ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+ if (dev->dma_pfn_offset > 0)
+ return dev_addr + ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+
+ return dev_addr - ((dma_addr_t)-dev->dma_pfn_offset << PAGE_SHIFT);
}
static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
{
phys_addr_t paddr = (phys_addr_t)dev_addr;
- return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+ if (dev->dma_pfn_offset > 0)
+ return paddr - ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+
+ return paddr + ((phys_addr_t)-dev->dma_pfn_offset << PAGE_SHIFT);
}
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
For the v2 version of the IP27 rework I've used the mach-XXX include structure
of the MIPS tree to implement __phy_to_dma/__dma_to_phys for IP27. I'd prefer
it that way.
Thomas.
--
SUSE Linux GmbH
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Powered by blists - more mailing lists