Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90114d65 authored by Thierry Reding's avatar Thierry Reding Committed by Marek Szyprowski
Browse files

s390: Implement dma_{alloc,free}_attrs()



The S390 architecture advertises support for HAVE_DMA_ATTRS when PCI is
enabled. Patches to unify some of the DMA API would like to rely on the
dma_alloc_attrs() and dma_free_attrs() functions to be provided when an
architecture supports DMA attributes.

Rename dma_alloc_coherent() and dma_free_coherent() to dma_alloc_attrs()
and dma_free_attrs() since they are functionally equivalent and alias
the former to the latter for compatibility.

For consistency with other architectures, also reuse the existing symbol
HAVE_DMA_ATTRS defined in arch/Kconfig instead of providing a duplicate.
Select it when PCI is enabled.

While at it, drop a redundant 'default n' from the PCI Kconfig symbol.

Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Acked-By: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
parent 7d1311b9
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -498,8 +498,8 @@ config QDIO


menuconfig PCI
menuconfig PCI
	bool "PCI support"
	bool "PCI support"
	default n
	depends on 64BIT
	depends on 64BIT
	select HAVE_DMA_ATTRS
	select PCI_MSI
	select PCI_MSI
	help
	help
	  Enable PCI support.
	  Enable PCI support.
@@ -546,9 +546,6 @@ config HAS_DMA
config NEED_SG_DMA_LENGTH
config NEED_SG_DMA_LENGTH
	def_bool PCI
	def_bool PCI


config HAVE_DMA_ATTRS
	def_bool PCI

config NEED_DMA_MAP_STATE
config NEED_DMA_MAP_STATE
	def_bool PCI
	def_bool PCI


+21 −10
Original line number Original line Diff line number Diff line
@@ -56,24 +56,35 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
	return dma_addr == DMA_ERROR_CODE;
	return dma_addr == DMA_ERROR_CODE;
}
}


static inline void *dma_alloc_coherent(struct device *dev, size_t size,
#define dma_alloc_coherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
				       dma_addr_t *dma_handle, gfp_t flag)

static inline void *dma_alloc_attrs(struct device *dev, size_t size,
				    dma_addr_t *dma_handle, gfp_t flags,
				    struct dma_attrs *attrs)
{
{
	struct dma_map_ops *ops = get_dma_ops(dev);
	struct dma_map_ops *ops = get_dma_ops(dev);
	void *ret;
	void *cpu_addr;

	BUG_ON(!ops);


	ret = ops->alloc(dev, size, dma_handle, flag, NULL);
	cpu_addr = ops->alloc(dev, size, dma_handle, flags, attrs);
	debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
	debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
	return ret;

	return cpu_addr;
}
}


static inline void dma_free_coherent(struct device *dev, size_t size,
#define dma_free_coherent(d, s, c, h) dma_free_attrs(d, s, c, h, NULL)
				     void *cpu_addr, dma_addr_t dma_handle)

static inline void dma_free_attrs(struct device *dev, size_t size,
				  void *cpu_addr, dma_addr_t dma_handle,
				  struct dma_attrs *attrs)
{
{
	struct dma_map_ops *dma_ops = get_dma_ops(dev);
	struct dma_map_ops *ops = get_dma_ops(dev);

	BUG_ON(!ops);


	debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
	debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
	dma_ops->free(dev, size, cpu_addr, dma_handle, NULL);
	ops->free(dev, size, cpu_addr, dma_handle, attrs);
}
}


#endif /* _ASM_S390_DMA_MAPPING_H */
#endif /* _ASM_S390_DMA_MAPPING_H */