[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190218115807.1a683d2c6824acd4ea78eb11@suse.de>
Date: Mon, 18 Feb 2019 11:58:07 +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 Mon, 28 Jan 2019 05:32:15 -0800
Christoph Hellwig <hch@...radead.org> wrote:
> Note that we could probably fix these by just switching IP27 and
> other users of the bridge chip to use the dma_pfn_offset field
> in struct device and stop overriding these functions.
during my final round of tests for v2 of the patchset I found a problem with
the current implementation regarding dma_pfn_offset. Right now it asumes that
dma addresses are lower than physical addresses, which probably came from the
sh7786 usage (at least that's how I understand the SH7786 datasheet). But for
IP27 physical addresses starts at 0 and dma address is more at the end of the
64bit address space. So using following patch gets it right for IP27:
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index b7338702592a..19dfadc292f5 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -12,14 +12,14 @@ 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);
+ 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);
+ 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)
This of course will break SH7786. To fix both cases how about making dma_pfn_offset
a signed long ?
Thomas.
--
SUSE Linux GmbH
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Powered by blists - more mailing lists