* Swiotlb breaks pseries
@ 2009-06-23 9:13 Michael Ellerman
2009-06-23 9:32 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2009-06-23 9:13 UTC (permalink / raw)
To: linuxppc-dev
Hi all,
Turning on SWIOTLB selects or enables PPC_NEED_DMA_SYNC_OPS, which means
we get the non empty versions of dma_sync_* in asm/dma-mapping.h
On my pseries machine the dma_ops have no such routines and we die with
a null pointer - this patch gets it booting, is there a more elegant way
to do it?
cheers
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 3d9e887..b44aaab 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -309,7 +309,9 @@ static inline void dma_sync_single_for_cpu(struct device *dev,
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
BUG_ON(!dma_ops);
- dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
+
+ if (dma_ops->sync_single_range_for_cpu)
+ dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
size, direction);
}
@@ -320,7 +322,9 @@ static inline void dma_sync_single_for_device(struct device *dev,
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
BUG_ON(!dma_ops);
- dma_ops->sync_single_range_for_device(dev, dma_handle,
+
+ if (dma_ops->sync_single_range_for_device)
+ dma_ops->sync_single_range_for_device(dev, dma_handle,
0, size, direction);
}
@@ -331,7 +335,9 @@ static inline void dma_sync_sg_for_cpu(struct device *dev,
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
BUG_ON(!dma_ops);
- dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
+
+ if (dma_ops->sync_sg_for_cpu)
+ dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
}
static inline void dma_sync_sg_for_device(struct device *dev,
@@ -341,7 +347,9 @@ static inline void dma_sync_sg_for_device(struct device *dev,
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
BUG_ON(!dma_ops);
- dma_ops->sync_sg_for_device(dev, sgl, nents, direction);
+
+ if (dma_ops->sync_sg_for_device)
+ dma_ops->sync_sg_for_device(dev, sgl, nents, direction);
}
static inline void dma_sync_single_range_for_cpu(struct device *dev,
@@ -351,7 +359,9 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
BUG_ON(!dma_ops);
- dma_ops->sync_single_range_for_cpu(dev, dma_handle,
+
+ if (dma_ops->sync_single_range_for_cpu)
+ dma_ops->sync_single_range_for_cpu(dev, dma_handle,
offset, size, direction);
}
@@ -362,7 +372,9 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
BUG_ON(!dma_ops);
- dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
+
+ if (dma_ops->sync_single_range_for_device)
+ dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
size, direction);
}
#else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */
--
1.6.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Swiotlb breaks pseries
2009-06-23 9:13 Swiotlb breaks pseries Michael Ellerman
@ 2009-06-23 9:32 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2009-06-23 9:32 UTC (permalink / raw)
To: michael; +Cc: linuxppc-dev
On Tue, 2009-06-23 at 19:13 +1000, Michael Ellerman wrote:
> Hi all,
>
> Turning on SWIOTLB selects or enables PPC_NEED_DMA_SYNC_OPS, which means
> we get the non empty versions of dma_sync_* in asm/dma-mapping.h
>
> On my pseries machine the dma_ops have no such routines and we die with
> a null pointer - this patch gets it booting, is there a more elegant way
> to do it?
No that's the best way (checking for NULL in the inlines), avoids
calling through a function pointer when not needed, since this can
be a fairly hot path, especially with networking.
Cheers,
Ben.
> cheers
>
> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
> index 3d9e887..b44aaab 100644
> --- a/arch/powerpc/include/asm/dma-mapping.h
> +++ b/arch/powerpc/include/asm/dma-mapping.h
> @@ -309,7 +309,9 @@ static inline void dma_sync_single_for_cpu(struct device *dev,
> struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> - dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
> +
> + if (dma_ops->sync_single_range_for_cpu)
> + dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
> size, direction);
> }
>
> @@ -320,7 +322,9 @@ static inline void dma_sync_single_for_device(struct device *dev,
> struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> - dma_ops->sync_single_range_for_device(dev, dma_handle,
> +
> + if (dma_ops->sync_single_range_for_device)
> + dma_ops->sync_single_range_for_device(dev, dma_handle,
> 0, size, direction);
> }
>
> @@ -331,7 +335,9 @@ static inline void dma_sync_sg_for_cpu(struct device *dev,
> struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> - dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
> +
> + if (dma_ops->sync_sg_for_cpu)
> + dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
> }
>
> static inline void dma_sync_sg_for_device(struct device *dev,
> @@ -341,7 +347,9 @@ static inline void dma_sync_sg_for_device(struct device *dev,
> struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> - dma_ops->sync_sg_for_device(dev, sgl, nents, direction);
> +
> + if (dma_ops->sync_sg_for_device)
> + dma_ops->sync_sg_for_device(dev, sgl, nents, direction);
> }
>
> static inline void dma_sync_single_range_for_cpu(struct device *dev,
> @@ -351,7 +359,9 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
> struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> - dma_ops->sync_single_range_for_cpu(dev, dma_handle,
> +
> + if (dma_ops->sync_single_range_for_cpu)
> + dma_ops->sync_single_range_for_cpu(dev, dma_handle,
> offset, size, direction);
> }
>
> @@ -362,7 +372,9 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
> struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> - dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
> +
> + if (dma_ops->sync_single_range_for_device)
> + dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
> size, direction);
> }
> #else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-23 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-23 9:13 Swiotlb breaks pseries Michael Ellerman
2009-06-23 9:32 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).