2012-02-16 10:40:20

by Alessandro Rubini

[permalink] [raw]
Subject: [PATCH 0/3] STA2X11 fixes for next

My patch to add sta2x11 initial support has been merged by Ingo Molnar
as commit 60dda96f, with signed-off by Jesse Barnes. However, it
depended on two config symbols (the patch was 3/3, actually) and
I'm to get the blame for not noting it when Jesse told me he would
merge the 3/3.

Additionally, commit aa04651 by Andrzej Pietrasiewicz changed some
prototypes we use, so stuff is not compiling any more if
CONFIG_STA2X11 is on.

I Cc: all involved parties in all patches. The commit
messages for the original patches have been reworded to match the fact
that they are going in after sta2x11-fixup.c . At this point, they
are all bugfix patches.

Alessandro Rubini (3):
x86/PCI: change sta2x11-fixup to account for commit aa04651
x86: introduce CONFIG_X86_DEV_DMA_OPS
x86: introduce CONFIG_X86_DMA_REMAP

arch/x86/Kconfig | 11 +++++++++++
arch/x86/include/asm/device.h | 4 ++--
arch/x86/include/asm/dma-mapping.h | 9 ++++++++-
arch/x86/pci/sta2x11-fixup.c | 12 +++++++-----
4 files changed, 28 insertions(+), 8 deletions(-)

--
1.7.7.2


2012-02-16 10:40:29

by Alessandro Rubini

[permalink] [raw]
Subject: [PATCH 1/3] x86/PCI: change sta2x11-fixup to account for commit aa04651

Commit aa04651 changed the prototypes for swiotlb methods, so
the sta2x11 fixup file won't compile any more. This fixes our own
prototypes.

Signed-off-by: Alessandro Rubini <[email protected]>
Acked-by: Giancarlo Asnaghi <[email protected]>
Cc: Andrzej Pietrasiewicz <[email protected]>
---
arch/x86/pci/sta2x11-fixup.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/x86/pci/sta2x11-fixup.c b/arch/x86/pci/sta2x11-fixup.c
index f61ce8b..5aaa434 100644
--- a/arch/x86/pci/sta2x11-fixup.c
+++ b/arch/x86/pci/sta2x11-fixup.c
@@ -168,21 +168,23 @@ static dma_addr_t a2p(dma_addr_t a, struct pci_dev *pdev)
static void *sta2x11_swiotlb_alloc_coherent(struct device *dev,
size_t size,
dma_addr_t *dma_handle,
- gfp_t flags)
+ gfp_t flags,
+ struct dma_attrs *attrs)
{
void *vaddr;

- vaddr = dma_generic_alloc_coherent(dev, size, dma_handle, flags);
+ vaddr = dma_generic_alloc_coherent(dev, size, dma_handle, flags, attrs);
if (!vaddr)
- vaddr = swiotlb_alloc_coherent(dev, size, dma_handle, flags);
+ vaddr = swiotlb_alloc_coherent(dev, size, dma_handle, flags,
+ attrs);
*dma_handle = p2a(*dma_handle, to_pci_dev(dev));
return vaddr;
}

/* We have our own dma_ops: the same as swiotlb but from alloc (above) */
static struct dma_map_ops sta2x11_dma_ops = {
- .alloc_coherent = sta2x11_swiotlb_alloc_coherent,
- .free_coherent = swiotlb_free_coherent,
+ .alloc = sta2x11_swiotlb_alloc_coherent,
+ .free = swiotlb_free_coherent,
.map_page = swiotlb_map_page,
.unmap_page = swiotlb_unmap_page,
.map_sg = swiotlb_map_sg_attrs,
--
1.7.7.2

2012-02-16 10:40:42

by Alessandro Rubini

[permalink] [raw]
Subject: [PATCH 2/3] x86: introduce CONFIG_X86_DEV_DMA_OPS

32-bit x86 systems may need their own DMA operations, so add
a new config option, which is turned on for 64-bit systems and sta2x11.
Core sta2x11 support has already been accepted, but it won't compile
without this option.

Signed-off-by: Alessandro Rubini <[email protected]>
Acked-by: Giancarlo Asnaghi <[email protected]>
Cc: Alan Cox <[email protected]>
---
arch/x86/Kconfig | 6 ++++++
arch/x86/include/asm/device.h | 4 ++--
arch/x86/include/asm/dma-mapping.h | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index dd18c2b..5bb23c3 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -12,6 +12,7 @@ config X86_32

config X86_64
def_bool 64BIT
+ select X86_DEV_DMA_OPS

### Arch settings
config X86
@@ -510,6 +511,7 @@ config STA2X11
bool "STA2X11 Companion Chip Support"
depends on X86_32_NON_STANDARD && PCI
select SWIOTLB
+ select X86_DEV_DMA_OPS
select MFD_STA2X11
select ARCH_REQUIRE_GPIOLIB
default n
@@ -2249,6 +2251,10 @@ config HAVE_TEXT_POKE_SMP
bool
select STOP_MACHINE if SMP

+config X86_DEV_DMA_OPS
+ bool
+ depends on X86_64 || STA2X11
+
source "net/Kconfig"

source "drivers/Kconfig"
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
index 63a2a03..93e1c55 100644
--- a/arch/x86/include/asm/device.h
+++ b/arch/x86/include/asm/device.h
@@ -5,8 +5,8 @@ struct dev_archdata {
#ifdef CONFIG_ACPI
void *acpi_handle;
#endif
-#ifdef CONFIG_X86_64
-struct dma_map_ops *dma_ops;
+#ifdef CONFIG_X86_DEV_DMA_OPS
+ struct dma_map_ops *dma_ops;
#endif
#if defined(CONFIG_INTEL_IOMMU) || defined(CONFIG_AMD_IOMMU)
void *iommu; /* hook for IOMMU specific extension */
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 4b4331d..09aa473 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -30,7 +30,7 @@ extern struct dma_map_ops *dma_ops;

static inline struct dma_map_ops *get_dma_ops(struct device *dev)
{
-#ifdef CONFIG_X86_32
+#ifndef CONFIG_X86_DEV_DMA_OPS
return dma_ops;
#else
if (unlikely(!dev) || !dev->archdata.dma_ops)
--
1.7.7.2

2012-02-16 10:40:48

by Alessandro Rubini

[permalink] [raw]
Subject: [PATCH 3/3] x86: introduce CONFIG_X86_DMA_REMAP

The default functions phys_to_dma, dma_to_phys implement identity
mapping as fast inline functions. Some systems, however, need a
custom function to implement its own mapping between CPU addresses and
device addresses. This option is needed to support the sta2x11 I/O Hub,
whose support has been accepted but won't compile without this patch.

Signed-off-by: Alessandro Rubini <[email protected]>
Acked-by: Giancarlo Asnaghi <[email protected]>
Cc: Alan Cox <[email protected]>
---
arch/x86/Kconfig | 5 +++++
arch/x86/include/asm/dma-mapping.h | 7 +++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5bb23c3..5426833 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -512,6 +512,7 @@ config STA2X11
depends on X86_32_NON_STANDARD && PCI
select SWIOTLB
select X86_DEV_DMA_OPS
+ select X86_DMA_REMAP
select MFD_STA2X11
select ARCH_REQUIRE_GPIOLIB
default n
@@ -2255,6 +2256,10 @@ config X86_DEV_DMA_OPS
bool
depends on X86_64 || STA2X11

+config X86_DMA_REMAP
+ bool
+ depends on STA2X11
+
source "net/Kconfig"

source "drivers/Kconfig"
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 09aa473..61c0bd2 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -62,6 +62,12 @@ extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_addr, gfp_t flag,
struct dma_attrs *attrs);

+#ifdef CONFIG_X86_DMA_REMAP /* Platform code defines bridge-specific code */
+extern bool dma_capable(struct device *dev, dma_addr_t addr, size_t size);
+extern dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
+extern phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr);
+#else
+
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
{
if (!dev->dma_mask)
@@ -79,6 +85,7 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
{
return daddr;
}
+#endif /* CONFIG_X86_DMA_REMAP */

static inline void
dma_cache_sync(struct device *dev, void *vaddr, size_t size,
--
1.7.7.2