From: Bjorn Helgaas <bhelgaas@google.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-doc@vger.kernel.org, linux-sh@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Joerg Roedel <joro@8bytes.org>,
Randy Dunlap <rdunlap@infradead.org>,
Liviu Dudau <Liviu.Dudau@arm.com>,
linux-kernel@vger.kernel.org,
James Bottomley <jbottomley@parallels.com>,
Magnus Damm <damm@opensource.se>,
linux-pci@vger.kernel.org, David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH v3 3/4] sh/PCI: Pass GAPSPCI_DMA_BASE CPU & bus address to dma_declare_coherent_memory()
Date: Thu, 08 May 2014 14:49:07 -0600 [thread overview]
Message-ID: <20140508204907.17877.4848.stgit@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20140508204257.17877.4639.stgit@bhelgaas-glaptop.roam.corp.google.com>
dma_declare_coherent_memory() needs both the CPU physical address and the
bus address of the device memory. They are the same on this platform, but
in general we should use pcibios_resource_to_bus() to account for any
address translation done by the PCI host bridge.
This makes no difference on Dreamcast, but is safer if the usage is copied
to future drivers.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
CC: Magnus Damm <damm@opensource.se>
CC: linux-sh@vger.kernel.org
---
arch/sh/drivers/pci/fixups-dreamcast.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c
index d6cde700e316..f22127f966ce 100644
--- a/arch/sh/drivers/pci/fixups-dreamcast.c
+++ b/arch/sh/drivers/pci/fixups-dreamcast.c
@@ -31,6 +31,8 @@
static void gapspci_fixup_resources(struct pci_dev *dev)
{
struct pci_channel *p = dev->sysdata;
+ struct resource res;
+ struct pci_bus_region region;
printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));
@@ -50,11 +52,21 @@ static void gapspci_fixup_resources(struct pci_dev *dev)
/*
* Redirect dma memory allocations to special memory window.
+ *
+ * If this GAPSPCI region were mapped by a BAR, the CPU
+ * phys_addr_t would be pci_resource_start(), and the bus
+ * address would be pci_bus_address(pci_resource_start()).
+ * But apparently there's no BAR mapping it, so we just
+ * "know" its CPU address is GAPSPCI_DMA_BASE.
*/
+ res.start = GAPSPCI_DMA_BASE;
+ res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
+ res.flags = IORESOURCE_MEM;
+ pcibios_resource_to_bus(dev, ®ion, &resource);
BUG_ON(!dma_declare_coherent_memory(&dev->dev,
- GAPSPCI_DMA_BASE,
- GAPSPCI_DMA_BASE,
- GAPSPCI_DMA_SIZE,
+ res.start,
+ region.start,
+ resource_size(&res),
DMA_MEMORY_MAP |
DMA_MEMORY_EXCLUSIVE));
break;
next prev parent reply other threads:[~2014-05-08 20:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 20:48 [PATCH v3 0/4] Clean up DMA API docs and dma_addr_t usage Bjorn Helgaas
2014-05-08 20:48 ` [PATCH v3 1/4] DMA-API: Clarify physical/bus address distinction Bjorn Helgaas
2014-05-09 2:49 ` Greg Kroah-Hartman
2014-05-09 6:12 ` Arnd Bergmann
2014-05-09 14:09 ` James Bottomley
2014-05-08 20:49 ` [PATCH v3 2/4] DMA-API: Change dma_declare_coherent_memory() CPU address to phys_addr_t Bjorn Helgaas
2014-05-09 2:50 ` Greg Kroah-Hartman
2014-05-08 20:49 ` Bjorn Helgaas [this message]
2014-05-26 14:46 ` [PATCH v3 3/4] sh/PCI: Pass GAPSPCI_DMA_BASE CPU & bus address to dma_declare_coherent_memory() Geert Uytterhoeven
2014-05-26 23:33 ` Bjorn Helgaas
2014-05-08 20:49 ` [PATCH v3 4/4] iommu/exynos: Remove unnecessary "&" from function pointers Bjorn Helgaas
2014-05-14 10:23 ` [PATCH v3 0/4] Clean up DMA API docs and dma_addr_t usage Joerg Roedel
2014-05-14 15:50 ` Randy Dunlap
2014-05-14 15:56 ` Joerg Roedel
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=20140508204907.17877.4848.stgit@bhelgaas-glaptop.roam.corp.google.com \
--to=bhelgaas@google.com \
--cc=Liviu.Dudau@arm.com \
--cc=arnd@arndb.de \
--cc=damm@opensource.se \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=jbottomley@parallels.com \
--cc=joro@8bytes.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=rdunlap@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
all inboxes | Powered by JetHome®