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

Commit bfbf7d61 authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Marek Szyprowski
Browse files

PowerPC: adapt for dma_map_ops changes



Adapt core PowerPC architecture code for dma_map_ops changes: replace
alloc/free_coherent with generic alloc/free methods.

Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
[added missing changes to arch/powerpc/kernel/vio.c]
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
parent e8d51e54
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -22,9 +22,11 @@

/* Some dma direct funcs must be visible for use in other dma_ops */
extern void *dma_direct_alloc_coherent(struct device *dev, size_t size,
				       dma_addr_t *dma_handle, gfp_t flag);
				       dma_addr_t *dma_handle, gfp_t flag,
				       struct dma_attrs *attrs);
extern void dma_direct_free_coherent(struct device *dev, size_t size,
				     void *vaddr, dma_addr_t dma_handle);
				     void *vaddr, dma_addr_t dma_handle,
				     struct dma_attrs *attrs);


#ifdef CONFIG_NOT_COHERENT_CACHE
@@ -130,23 +132,29 @@ static inline int dma_supported(struct device *dev, u64 mask)

extern int dma_set_mask(struct device *dev, u64 dma_mask);

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

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

	BUG_ON(!dma_ops);

	cpu_addr = dma_ops->alloc_coherent(dev, size, dma_handle, flag);
	cpu_addr = dma_ops->alloc(dev, size, dma_handle, flag, attrs);

	debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);

	return cpu_addr;
}

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

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);

@@ -154,7 +162,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

	debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);

	dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
	dma_ops->free(dev, size, cpu_addr, dma_handle, attrs);
}

static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+6 −4
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@
 * to the dma address (mapping) of the first page.
 */
static void *dma_iommu_alloc_coherent(struct device *dev, size_t size,
				      dma_addr_t *dma_handle, gfp_t flag)
				      dma_addr_t *dma_handle, gfp_t flag,
				      struct dma_attrs *attrs)
{
	return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size,
				    dma_handle, dev->coherent_dma_mask, flag,
@@ -25,7 +26,8 @@ static void *dma_iommu_alloc_coherent(struct device *dev, size_t size,
}

static void dma_iommu_free_coherent(struct device *dev, size_t size,
				    void *vaddr, dma_addr_t dma_handle)
				    void *vaddr, dma_addr_t dma_handle,
				    struct dma_attrs *attrs)
{
	iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle);
}
@@ -105,8 +107,8 @@ static u64 dma_iommu_get_required_mask(struct device *dev)
}

struct dma_map_ops dma_iommu_ops = {
	.alloc_coherent		= dma_iommu_alloc_coherent,
	.free_coherent		= dma_iommu_free_coherent,
	.alloc			= dma_iommu_alloc_coherent,
	.free			= dma_iommu_free_coherent,
	.map_sg			= dma_iommu_map_sg,
	.unmap_sg		= dma_iommu_unmap_sg,
	.dma_supported		= dma_iommu_dma_supported,
+2 −2
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ static u64 swiotlb_powerpc_get_required(struct device *dev)
 * for everything else.
 */
struct dma_map_ops swiotlb_dma_ops = {
	.alloc_coherent = dma_direct_alloc_coherent,
	.free_coherent = dma_direct_free_coherent,
	.alloc = dma_direct_alloc_coherent,
	.free = dma_direct_free_coherent,
	.map_sg = swiotlb_map_sg_attrs,
	.unmap_sg = swiotlb_unmap_sg_attrs,
	.dma_supported = swiotlb_dma_supported,
+6 −4
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@


void *dma_direct_alloc_coherent(struct device *dev, size_t size,
				dma_addr_t *dma_handle, gfp_t flag)
				dma_addr_t *dma_handle, gfp_t flag,
				struct dma_attrs *attrs)
{
	void *ret;
#ifdef CONFIG_NOT_COHERENT_CACHE
@@ -54,7 +55,8 @@ void *dma_direct_alloc_coherent(struct device *dev, size_t size,
}

void dma_direct_free_coherent(struct device *dev, size_t size,
			      void *vaddr, dma_addr_t dma_handle)
			      void *vaddr, dma_addr_t dma_handle,
			      struct dma_attrs *attrs)
{
#ifdef CONFIG_NOT_COHERENT_CACHE
	__dma_free_coherent(size, vaddr);
@@ -150,8 +152,8 @@ static inline void dma_direct_sync_single(struct device *dev,
#endif

struct dma_map_ops dma_direct_ops = {
	.alloc_coherent			= dma_direct_alloc_coherent,
	.free_coherent			= dma_direct_free_coherent,
	.alloc				= dma_direct_alloc_coherent,
	.free				= dma_direct_free_coherent,
	.map_sg				= dma_direct_map_sg,
	.unmap_sg			= dma_direct_unmap_sg,
	.dma_supported			= dma_direct_dma_supported,
+6 −4
Original line number Diff line number Diff line
@@ -65,7 +65,8 @@ static struct of_device_id __initdata ibmebus_matches[] = {
static void *ibmebus_alloc_coherent(struct device *dev,
				    size_t size,
				    dma_addr_t *dma_handle,
				    gfp_t flag)
				    gfp_t flag,
				    struct dma_attrs *attrs)
{
	void *mem;

@@ -77,7 +78,8 @@ static void *ibmebus_alloc_coherent(struct device *dev,

static void ibmebus_free_coherent(struct device *dev,
				  size_t size, void *vaddr,
				  dma_addr_t dma_handle)
				  dma_addr_t dma_handle,
				  struct dma_attrs *attrs)
{
	kfree(vaddr);
}
@@ -136,8 +138,8 @@ static u64 ibmebus_dma_get_required_mask(struct device *dev)
}

static struct dma_map_ops ibmebus_dma_ops = {
	.alloc_coherent     = ibmebus_alloc_coherent,
	.free_coherent      = ibmebus_free_coherent,
	.alloc              = ibmebus_alloc_coherent,
	.free               = ibmebus_free_coherent,
	.map_sg             = ibmebus_map_sg,
	.unmap_sg           = ibmebus_unmap_sg,
	.dma_supported      = ibmebus_dma_supported,
Loading