STA2X11 fixes for next
cover 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(-)
Signature · 1 line
1.7.7.2
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.
--- arch/x86/pci/sta2x11-fixup.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/pci/sta2x11-fixup.c +7 -5
@@ -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,
Signature · 1 line
1.7.7.2
PATCH 2/3 x86: introduce CONFIG_X86_DEV_DMA_OPS
In reply to Alessandro Rubini32-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.
--- 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(-)
arch/x86/Kconfig +6 -0
@@ -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"
arch/x86/include/asm/device.h +2 -2
@@ -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 */
arch/x86/include/asm/dma-mapping.h +1 -1
@@ -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)
Signature · 1 line
1.7.7.2
PATCH 3/3 x86: introduce CONFIG_X86_DMA_REMAP
In reply to Alessandro RubiniThe 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.
--- arch/x86/Kconfig | 5 +++++ arch/x86/include/asm/dma-mapping.h | 7 +++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
arch/x86/Kconfig +5 -0
@@ -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"
arch/x86/include/asm/dma-mapping.h +7 -0
@@ -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,
Signature · 1 line
1.7.7.2