* [PATCH] dma-mapping: tidy up dma_parms default handling @ 2015-01-09 16:56 ` Robin Murphy 0 siblings, 0 replies; 17+ messages in thread From: Robin Murphy @ 2014-12-19 17:39 UTC (permalink / raw) To: vinod.koul, dmaengine, linux-kernel Cc: linux-arm-kernel, dan.j.williams, lars, liviu.dudau, andrew.jackson Many DMA controllers and other devices set max_segment_size to indicate their scatter-gather capability, but have no interest in segment_boundary_mask. However, the existence of a dma_parms structure precludes the use of any default value, leaving them as zeros (assuming a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) then tries to respect this by ensuring a mapped segment does not cross a zero-byte boundary, hilarity ensues. Since zero is a nonsensical value for either parameter, treat it as an indicator for "default", as might be expected. In the process, clean up a bit by replacing the bare constants with slightly more meaningful macros and removing the superfluous "else" statements. Signed-off-by: Robin Murphy <robin.murphy@arm.com> --- Hi Vinod, dmaengine folks, This isn't strictly a dmaengine patch, but get_maintainer.pl pointed at you, and there do happen to be more dmaengine drivers potentially affected by this than anything else - the current PL330 driver blows up arm64's SWIOTLB when running dmatest on the Juno platform, which is what brought the underlying problem to light. include/linux/dma-mapping.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index c3007cb..99ba736 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } static inline unsigned int dma_get_max_seg_size(struct device *dev) { - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; + if (dev->dma_parms && dev->dma_parms->max_segment_size) + return dev->dma_parms->max_segment_size; + return SZ_64K; } static inline unsigned int dma_set_max_seg_size(struct device *dev, @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, if (dev->dma_parms) { dev->dma_parms->max_segment_size = size; return 0; - } else - return -EIO; + } + return -EIO; } static inline unsigned long dma_get_seg_boundary(struct device *dev) { - return dev->dma_parms ? - dev->dma_parms->segment_boundary_mask : 0xffffffff; + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) + return dev->dma_parms->segment_boundary_mask; + return DMA_BIT_MASK(32); } static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) if (dev->dma_parms) { dev->dma_parms->segment_boundary_mask = mask; return 0; - } else - return -EIO; + } + return -EIO; } #ifndef dma_max_pfn -- 1.9.1 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-09 16:56 ` Robin Murphy 0 siblings, 0 replies; 17+ messages in thread From: Robin Murphy @ 2015-01-09 16:56 UTC (permalink / raw) To: linux-arm-kernel Many DMA controllers and other devices set max_segment_size to indicate their scatter-gather capability, but have no interest in segment_boundary_mask. However, the existence of a dma_parms structure precludes the use of any default value, leaving them as zeros (assuming a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) then tries to respect this by ensuring a mapped segment does not cross a zero-byte boundary, hilarity ensues. Since zero is a nonsensical value for either parameter, treat it as an indicator for "default", as might be expected. In the process, clean up a bit by replacing the bare constants with slightly more meaningful macros and removing the superfluous "else" statements. Signed-off-by: Robin Murphy <robin.murphy@arm.com> --- Hi, various maintainers from Git logs ;) This one's a bit tricky to find a home for - I think technically it's probably an IOMMU patch, but then the long-underlying problem doesn't seem to have blown up anything until arm64, and my motivation is to make bits of Juno work, which seems to nudge it towards arm64/arm-soc territory. Could anyone suggest which tree is most appropriate? Thanks, Robin. include/linux/dma-mapping.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index c3007cb..99ba736 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } static inline unsigned int dma_get_max_seg_size(struct device *dev) { - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; + if (dev->dma_parms && dev->dma_parms->max_segment_size) + return dev->dma_parms->max_segment_size; + return SZ_64K; } static inline unsigned int dma_set_max_seg_size(struct device *dev, @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, if (dev->dma_parms) { dev->dma_parms->max_segment_size = size; return 0; - } else - return -EIO; + } + return -EIO; } static inline unsigned long dma_get_seg_boundary(struct device *dev) { - return dev->dma_parms ? - dev->dma_parms->segment_boundary_mask : 0xffffffff; + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) + return dev->dma_parms->segment_boundary_mask; + return DMA_BIT_MASK(32); } static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) if (dev->dma_parms) { dev->dma_parms->segment_boundary_mask = mask; return 0; - } else - return -EIO; + } + return -EIO; } #ifndef dma_max_pfn -- 1.9.1 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH] dma-mapping: tidy up dma_parms default handling 2015-01-09 16:56 ` [PATCH RESEND] " Robin Murphy @ 2014-12-22 15:25 ` Vinod Koul -1 siblings, 0 replies; 17+ messages in thread From: Vinod Koul @ 2014-12-22 15:25 UTC (permalink / raw) To: linux-arm-kernel On Fri, Dec 19, 2014 at 05:39:09PM +0000, Robin Murphy wrote: > Many DMA controllers and other devices set max_segment_size to > indicate their scatter-gather capability, but have no interest in > segment_boundary_mask. However, the existence of a dma_parms structure > precludes the use of any default value, leaving them as zeros (assuming > a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) > then tries to respect this by ensuring a mapped segment does not cross > a zero-byte boundary, hilarity ensues. > > Since zero is a nonsensical value for either parameter, treat it as an > indicator for "default", as might be expected. In the process, clean up > a bit by replacing the bare constants with slightly more meaningful > macros and removing the superfluous "else" statements. > > Signed-off-by: Robin Murphy <robin.murphy@arm.com> > --- > > Hi Vinod, dmaengine folks, > > This isn't strictly a dmaengine patch, but get_maintainer.pl pointed at you, > and there do happen to be more dmaengine drivers potentially affected by this > than anything else - the current PL330 driver blows up arm64's SWIOTLB when > running dmatest on the Juno platform, which is what brought the underlying > problem to light. That's due to include/linux/dma*, I will fix that up. I think arm folks should be able to help review this... Last few commit point to Will Decon carrying these -- ~Vinod > > include/linux/dma-mapping.h | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index c3007cb..99ba736 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } > > static inline unsigned int dma_get_max_seg_size(struct device *dev) > { > - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; > + if (dev->dma_parms && dev->dma_parms->max_segment_size) > + return dev->dma_parms->max_segment_size; > + return SZ_64K; > } > > static inline unsigned int dma_set_max_seg_size(struct device *dev, > @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, > if (dev->dma_parms) { > dev->dma_parms->max_segment_size = size; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > static inline unsigned long dma_get_seg_boundary(struct device *dev) > { > - return dev->dma_parms ? > - dev->dma_parms->segment_boundary_mask : 0xffffffff; > + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) > + return dev->dma_parms->segment_boundary_mask; > + return DMA_BIT_MASK(32); > } > > static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > if (dev->dma_parms) { > dev->dma_parms->segment_boundary_mask = mask; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > #ifndef dma_max_pfn > -- > 1.9.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe dmaengine" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] dma-mapping: tidy up dma_parms default handling @ 2014-12-22 15:25 ` Vinod Koul 0 siblings, 0 replies; 17+ messages in thread From: Vinod Koul @ 2014-12-22 15:25 UTC (permalink / raw) To: Robin Murphy, Will Deacon Cc: dmaengine, linux-kernel, linux-arm-kernel, dan.j.williams, lars, liviu.dudau, andrew.jackson On Fri, Dec 19, 2014 at 05:39:09PM +0000, Robin Murphy wrote: > Many DMA controllers and other devices set max_segment_size to > indicate their scatter-gather capability, but have no interest in > segment_boundary_mask. However, the existence of a dma_parms structure > precludes the use of any default value, leaving them as zeros (assuming > a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) > then tries to respect this by ensuring a mapped segment does not cross > a zero-byte boundary, hilarity ensues. > > Since zero is a nonsensical value for either parameter, treat it as an > indicator for "default", as might be expected. In the process, clean up > a bit by replacing the bare constants with slightly more meaningful > macros and removing the superfluous "else" statements. > > Signed-off-by: Robin Murphy <robin.murphy@arm.com> > --- > > Hi Vinod, dmaengine folks, > > This isn't strictly a dmaengine patch, but get_maintainer.pl pointed at you, > and there do happen to be more dmaengine drivers potentially affected by this > than anything else - the current PL330 driver blows up arm64's SWIOTLB when > running dmatest on the Juno platform, which is what brought the underlying > problem to light. That's due to include/linux/dma*, I will fix that up. I think arm folks should be able to help review this... Last few commit point to Will Decon carrying these -- ~Vinod > > include/linux/dma-mapping.h | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index c3007cb..99ba736 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } > > static inline unsigned int dma_get_max_seg_size(struct device *dev) > { > - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; > + if (dev->dma_parms && dev->dma_parms->max_segment_size) > + return dev->dma_parms->max_segment_size; > + return SZ_64K; > } > > static inline unsigned int dma_set_max_seg_size(struct device *dev, > @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, > if (dev->dma_parms) { > dev->dma_parms->max_segment_size = size; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > static inline unsigned long dma_get_seg_boundary(struct device *dev) > { > - return dev->dma_parms ? > - dev->dma_parms->segment_boundary_mask : 0xffffffff; > + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) > + return dev->dma_parms->segment_boundary_mask; > + return DMA_BIT_MASK(32); > } > > static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > if (dev->dma_parms) { > dev->dma_parms->segment_boundary_mask = mask; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > #ifndef dma_max_pfn > -- > 1.9.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe dmaengine" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling 2015-01-09 16:56 ` [PATCH RESEND] " Robin Murphy @ 2015-01-09 19:45 ` Arnd Bergmann -1 siblings, 0 replies; 17+ messages in thread From: Arnd Bergmann @ 2015-01-09 19:45 UTC (permalink / raw) To: Robin Murphy Cc: will.deacon, m.szyprowski, bhelgaas, joro, gregkh, iommu, linux-kernel, linux-arm-kernel On Friday 09 January 2015 16:56:03 Robin Murphy wrote: > > This one's a bit tricky to find a home for - I think technically it's > probably an IOMMU patch, but then the long-underlying problem doesn't > seem to have blown up anything until arm64, and my motivation is to > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > territory. Could anyone suggest which tree is most appropriate? I have a set of patches touching various dma-mapping.h related bits across architectures and in ARM in particular. Your patch fits into that series, and I guess we could either have it in my asm-generic tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical reasons, although it really doesn't belong in there. Arnd ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-09 19:45 ` Arnd Bergmann 0 siblings, 0 replies; 17+ messages in thread From: Arnd Bergmann @ 2015-01-09 19:45 UTC (permalink / raw) To: linux-arm-kernel On Friday 09 January 2015 16:56:03 Robin Murphy wrote: > > This one's a bit tricky to find a home for - I think technically it's > probably an IOMMU patch, but then the long-underlying problem doesn't > seem to have blown up anything until arm64, and my motivation is to > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > territory. Could anyone suggest which tree is most appropriate? I have a set of patches touching various dma-mapping.h related bits across architectures and in ARM in particular. Your patch fits into that series, and I guess we could either have it in my asm-generic tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical reasons, although it really doesn't belong in there. Arnd ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling 2015-01-09 19:45 ` Arnd Bergmann (?) @ 2015-01-12 13:00 ` Will Deacon -1 siblings, 0 replies; 17+ messages in thread From: Will Deacon @ 2015-01-12 13:00 UTC (permalink / raw) To: Arnd Bergmann Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, Robin Murphy, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org On Fri, Jan 09, 2015 at 07:45:49PM +0000, Arnd Bergmann wrote: > On Friday 09 January 2015 16:56:03 Robin Murphy wrote: > > > > This one's a bit tricky to find a home for - I think technically it's > > probably an IOMMU patch, but then the long-underlying problem doesn't > > seem to have blown up anything until arm64, and my motivation is to > > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > > territory. Could anyone suggest which tree is most appropriate? > > I have a set of patches touching various dma-mapping.h related bits > across architectures and in ARM in particular. Your patch fits into > that series, and I guess we could either have it in my asm-generic > tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical > reasons, although it really doesn't belong in there. I also have a couple of fixes for issues found by Laurent for tearing down the IOMMU dma ops, so you could include those too. I'll send them out this afternoon. Will ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-12 13:00 ` Will Deacon 0 siblings, 0 replies; 17+ messages in thread From: Will Deacon @ 2015-01-12 13:00 UTC (permalink / raw) To: Arnd Bergmann Cc: Robin Murphy, m.szyprowski@samsung.com, bhelgaas@google.com, joro@8bytes.org, gregkh@linuxfoundation.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org On Fri, Jan 09, 2015 at 07:45:49PM +0000, Arnd Bergmann wrote: > On Friday 09 January 2015 16:56:03 Robin Murphy wrote: > > > > This one's a bit tricky to find a home for - I think technically it's > > probably an IOMMU patch, but then the long-underlying problem doesn't > > seem to have blown up anything until arm64, and my motivation is to > > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > > territory. Could anyone suggest which tree is most appropriate? > > I have a set of patches touching various dma-mapping.h related bits > across architectures and in ARM in particular. Your patch fits into > that series, and I guess we could either have it in my asm-generic > tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical > reasons, although it really doesn't belong in there. I also have a couple of fixes for issues found by Laurent for tearing down the IOMMU dma ops, so you could include those too. I'll send them out this afternoon. Will ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-12 13:00 ` Will Deacon 0 siblings, 0 replies; 17+ messages in thread From: Will Deacon @ 2015-01-12 13:00 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jan 09, 2015 at 07:45:49PM +0000, Arnd Bergmann wrote: > On Friday 09 January 2015 16:56:03 Robin Murphy wrote: > > > > This one's a bit tricky to find a home for - I think technically it's > > probably an IOMMU patch, but then the long-underlying problem doesn't > > seem to have blown up anything until arm64, and my motivation is to > > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > > territory. Could anyone suggest which tree is most appropriate? > > I have a set of patches touching various dma-mapping.h related bits > across architectures and in ARM in particular. Your patch fits into > that series, and I guess we could either have it in my asm-generic > tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical > reasons, although it really doesn't belong in there. I also have a couple of fixes for issues found by Laurent for tearing down the IOMMU dma ops, so you could include those too. I'll send them out this afternoon. Will ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling 2015-01-09 19:45 ` Arnd Bergmann (?) @ 2015-01-12 13:07 ` Robin Murphy -1 siblings, 0 replies; 17+ messages in thread From: Robin Murphy @ 2015-01-12 13:07 UTC (permalink / raw) To: Arnd Bergmann Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, Will Deacon, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org On 09/01/15 19:45, Arnd Bergmann wrote: > On Friday 09 January 2015 16:56:03 Robin Murphy wrote: >> >> This one's a bit tricky to find a home for - I think technically it's >> probably an IOMMU patch, but then the long-underlying problem doesn't >> seem to have blown up anything until arm64, and my motivation is to >> make bits of Juno work, which seems to nudge it towards arm64/arm-soc >> territory. Could anyone suggest which tree is most appropriate? > > I have a set of patches touching various dma-mapping.h related bits > across architectures and in ARM in particular. Your patch fits into > that series, and I guess we could either have it in my asm-generic > tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical > reasons, although it really doesn't belong in there. > Thanks Arnd, I'd agree asm-generic or mm sound the most sensible - If you're happy to carry this patch with your series that'd be really helpful. Robin. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-12 13:07 ` Robin Murphy 0 siblings, 0 replies; 17+ messages in thread From: Robin Murphy @ 2015-01-12 13:07 UTC (permalink / raw) To: Arnd Bergmann Cc: Will Deacon, m.szyprowski@samsung.com, bhelgaas@google.com, joro@8bytes.org, gregkh@linuxfoundation.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org On 09/01/15 19:45, Arnd Bergmann wrote: > On Friday 09 January 2015 16:56:03 Robin Murphy wrote: >> >> This one's a bit tricky to find a home for - I think technically it's >> probably an IOMMU patch, but then the long-underlying problem doesn't >> seem to have blown up anything until arm64, and my motivation is to >> make bits of Juno work, which seems to nudge it towards arm64/arm-soc >> territory. Could anyone suggest which tree is most appropriate? > > I have a set of patches touching various dma-mapping.h related bits > across architectures and in ARM in particular. Your patch fits into > that series, and I guess we could either have it in my asm-generic > tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical > reasons, although it really doesn't belong in there. > Thanks Arnd, I'd agree asm-generic or mm sound the most sensible - If you're happy to carry this patch with your series that'd be really helpful. Robin. ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-12 13:07 ` Robin Murphy 0 siblings, 0 replies; 17+ messages in thread From: Robin Murphy @ 2015-01-12 13:07 UTC (permalink / raw) To: linux-arm-kernel On 09/01/15 19:45, Arnd Bergmann wrote: > On Friday 09 January 2015 16:56:03 Robin Murphy wrote: >> >> This one's a bit tricky to find a home for - I think technically it's >> probably an IOMMU patch, but then the long-underlying problem doesn't >> seem to have blown up anything until arm64, and my motivation is to >> make bits of Juno work, which seems to nudge it towards arm64/arm-soc >> territory. Could anyone suggest which tree is most appropriate? > > I have a set of patches touching various dma-mapping.h related bits > across architectures and in ARM in particular. Your patch fits into > that series, and I guess we could either have it in my asm-generic > tree or in Andrew Morton's mm tree. Possibly also arm-soc for practical > reasons, although it really doesn't belong in there. > Thanks Arnd, I'd agree asm-generic or mm sound the most sensible - If you're happy to carry this patch with your series that'd be really helpful. Robin. ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <ffdc5455d698d2525f2d126d0adabf9418fd76b1.1418990609.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>]
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling 2015-01-09 16:56 ` [PATCH RESEND] " Robin Murphy (?) @ 2015-01-13 11:19 ` Marek Szyprowski -1 siblings, 0 replies; 17+ messages in thread From: Marek Szyprowski @ 2015-01-13 11:19 UTC (permalink / raw) To: Robin Murphy, will.deacon-5wv7dgnIgG8, arnd-r2nGTMty4D4, bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, joro-zLv9SwRftAIdnm+yROfE0A, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Hello, On 2015-01-09 17:56, Robin Murphy wrote: > Many DMA controllers and other devices set max_segment_size to > indicate their scatter-gather capability, but have no interest in > segment_boundary_mask. However, the existence of a dma_parms structure > precludes the use of any default value, leaving them as zeros (assuming > a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) > then tries to respect this by ensuring a mapped segment does not cross > a zero-byte boundary, hilarity ensues. > > Since zero is a nonsensical value for either parameter, treat it as an > indicator for "default", as might be expected. In the process, clean up > a bit by replacing the bare constants with slightly more meaningful > macros and removing the superfluous "else" statements. > > Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> Acked-by: Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> > --- > > Hi, various maintainers from Git logs ;) > > This one's a bit tricky to find a home for - I think technically it's > probably an IOMMU patch, but then the long-underlying problem doesn't > seem to have blown up anything until arm64, and my motivation is to > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > territory. Could anyone suggest which tree is most appropriate? > > Thanks, > Robin. > > include/linux/dma-mapping.h | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index c3007cb..99ba736 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } > > static inline unsigned int dma_get_max_seg_size(struct device *dev) > { > - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; > + if (dev->dma_parms && dev->dma_parms->max_segment_size) > + return dev->dma_parms->max_segment_size; > + return SZ_64K; > } > > static inline unsigned int dma_set_max_seg_size(struct device *dev, > @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, > if (dev->dma_parms) { > dev->dma_parms->max_segment_size = size; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > static inline unsigned long dma_get_seg_boundary(struct device *dev) > { > - return dev->dma_parms ? > - dev->dma_parms->segment_boundary_mask : 0xffffffff; > + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) > + return dev->dma_parms->segment_boundary_mask; > + return DMA_BIT_MASK(32); > } > > static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > if (dev->dma_parms) { > dev->dma_parms->segment_boundary_mask = mask; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > #ifndef dma_max_pfn Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-13 11:19 ` Marek Szyprowski 0 siblings, 0 replies; 17+ messages in thread From: Marek Szyprowski @ 2015-01-13 11:19 UTC (permalink / raw) To: Robin Murphy, will.deacon, arnd, bhelgaas, joro, gregkh Cc: iommu, linux-kernel, linux-arm-kernel Hello, On 2015-01-09 17:56, Robin Murphy wrote: > Many DMA controllers and other devices set max_segment_size to > indicate their scatter-gather capability, but have no interest in > segment_boundary_mask. However, the existence of a dma_parms structure > precludes the use of any default value, leaving them as zeros (assuming > a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) > then tries to respect this by ensuring a mapped segment does not cross > a zero-byte boundary, hilarity ensues. > > Since zero is a nonsensical value for either parameter, treat it as an > indicator for "default", as might be expected. In the process, clean up > a bit by replacing the bare constants with slightly more meaningful > macros and removing the superfluous "else" statements. > > Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > > Hi, various maintainers from Git logs ;) > > This one's a bit tricky to find a home for - I think technically it's > probably an IOMMU patch, but then the long-underlying problem doesn't > seem to have blown up anything until arm64, and my motivation is to > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > territory. Could anyone suggest which tree is most appropriate? > > Thanks, > Robin. > > include/linux/dma-mapping.h | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index c3007cb..99ba736 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } > > static inline unsigned int dma_get_max_seg_size(struct device *dev) > { > - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; > + if (dev->dma_parms && dev->dma_parms->max_segment_size) > + return dev->dma_parms->max_segment_size; > + return SZ_64K; > } > > static inline unsigned int dma_set_max_seg_size(struct device *dev, > @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, > if (dev->dma_parms) { > dev->dma_parms->max_segment_size = size; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > static inline unsigned long dma_get_seg_boundary(struct device *dev) > { > - return dev->dma_parms ? > - dev->dma_parms->segment_boundary_mask : 0xffffffff; > + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) > + return dev->dma_parms->segment_boundary_mask; > + return DMA_BIT_MASK(32); > } > > static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > if (dev->dma_parms) { > dev->dma_parms->segment_boundary_mask = mask; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > #ifndef dma_max_pfn Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-13 11:19 ` Marek Szyprowski 0 siblings, 0 replies; 17+ messages in thread From: Marek Szyprowski @ 2015-01-13 11:19 UTC (permalink / raw) To: linux-arm-kernel Hello, On 2015-01-09 17:56, Robin Murphy wrote: > Many DMA controllers and other devices set max_segment_size to > indicate their scatter-gather capability, but have no interest in > segment_boundary_mask. However, the existence of a dma_parms structure > precludes the use of any default value, leaving them as zeros (assuming > a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) > then tries to respect this by ensuring a mapped segment does not cross > a zero-byte boundary, hilarity ensues. > > Since zero is a nonsensical value for either parameter, treat it as an > indicator for "default", as might be expected. In the process, clean up > a bit by replacing the bare constants with slightly more meaningful > macros and removing the superfluous "else" statements. > > Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > > Hi, various maintainers from Git logs ;) > > This one's a bit tricky to find a home for - I think technically it's > probably an IOMMU patch, but then the long-underlying problem doesn't > seem to have blown up anything until arm64, and my motivation is to > make bits of Juno work, which seems to nudge it towards arm64/arm-soc > territory. Could anyone suggest which tree is most appropriate? > > Thanks, > Robin. > > include/linux/dma-mapping.h | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index c3007cb..99ba736 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device *dev) { } > > static inline unsigned int dma_get_max_seg_size(struct device *dev) > { > - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; > + if (dev->dma_parms && dev->dma_parms->max_segment_size) > + return dev->dma_parms->max_segment_size; > + return SZ_64K; > } > > static inline unsigned int dma_set_max_seg_size(struct device *dev, > @@ -150,14 +152,15 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, > if (dev->dma_parms) { > dev->dma_parms->max_segment_size = size; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > static inline unsigned long dma_get_seg_boundary(struct device *dev) > { > - return dev->dma_parms ? > - dev->dma_parms->segment_boundary_mask : 0xffffffff; > + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) > + return dev->dma_parms->segment_boundary_mask; > + return DMA_BIT_MASK(32); > } > > static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) > if (dev->dma_parms) { > dev->dma_parms->segment_boundary_mask = mask; > return 0; > - } else > - return -EIO; > + } > + return -EIO; > } > > #ifndef dma_max_pfn Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND] dma-mapping: tidy up dma_parms default handling 2015-01-13 11:19 ` Marek Szyprowski @ 2015-01-22 3:45 ` Sumit Semwal -1 siblings, 0 replies; 17+ messages in thread From: Sumit Semwal @ 2015-01-22 3:45 UTC (permalink / raw) To: Marek Szyprowski Cc: Robin Murphy, Will Deacon, Arnd Bergmann, Bjorn Helgaas, joro, Greg Kroah-Hartman, iommu, LKML, linux-arm-kernel Hi Robin, On 13 January 2015 at 16:49, Marek Szyprowski <m.szyprowski@samsung.com> wrote: > Hello, > > On 2015-01-09 17:56, Robin Murphy wrote: >> >> Many DMA controllers and other devices set max_segment_size to >> indicate their scatter-gather capability, but have no interest in >> segment_boundary_mask. However, the existence of a dma_parms structure >> precludes the use of any default value, leaving them as zeros (assuming >> a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) >> then tries to respect this by ensuring a mapped segment does not cross >> a zero-byte boundary, hilarity ensues. >> >> Since zero is a nonsensical value for either parameter, treat it as an >> indicator for "default", as might be expected. In the process, clean up >> a bit by replacing the bare constants with slightly more meaningful >> macros and removing the superfluous "else" statements. >> >> Signed-off-by: Robin Murphy <robin.murphy@arm.com> > > > Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Please feel free to add my Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org> > >> --- >> >> Hi, various maintainers from Git logs ;) >> >> This one's a bit tricky to find a home for - I think technically it's >> probably an IOMMU patch, but then the long-underlying problem doesn't >> seem to have blown up anything until arm64, and my motivation is to >> make bits of Juno work, which seems to nudge it towards arm64/arm-soc >> territory. Could anyone suggest which tree is most appropriate? >> >> Thanks, >> Robin. >> >> >> include/linux/dma-mapping.h | 17 ++++++++++------- >> 1 file changed, 10 insertions(+), 7 deletions(-) >> >> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h >> index c3007cb..99ba736 100644 >> --- a/include/linux/dma-mapping.h >> +++ b/include/linux/dma-mapping.h >> @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device >> *dev) { } >> static inline unsigned int dma_get_max_seg_size(struct device *dev) >> { >> - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; >> + if (dev->dma_parms && dev->dma_parms->max_segment_size) >> + return dev->dma_parms->max_segment_size; >> + return SZ_64K; >> } >> static inline unsigned int dma_set_max_seg_size(struct device *dev, >> @@ -150,14 +152,15 @@ static inline unsigned int >> dma_set_max_seg_size(struct device *dev, >> if (dev->dma_parms) { >> dev->dma_parms->max_segment_size = size; >> return 0; >> - } else >> - return -EIO; >> + } >> + return -EIO; >> } >> static inline unsigned long dma_get_seg_boundary(struct device *dev) >> { >> - return dev->dma_parms ? >> - dev->dma_parms->segment_boundary_mask : 0xffffffff; >> + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) >> + return dev->dma_parms->segment_boundary_mask; >> + return DMA_BIT_MASK(32); >> } >> static inline int dma_set_seg_boundary(struct device *dev, unsigned >> long mask) >> @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device >> *dev, unsigned long mask) >> if (dev->dma_parms) { >> dev->dma_parms->segment_boundary_mask = mask; >> return 0; >> - } else >> - return -EIO; >> + } >> + return -EIO; >> } >> #ifndef dma_max_pfn > > > Best regards > -- > Marek Szyprowski, PhD > Samsung R&D Institute Poland > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Thanks and regards, Sumit Semwal Kernel Team Lead - Linaro Mobile Group Linaro.org │ Open source software for ARM SoCs ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND] dma-mapping: tidy up dma_parms default handling @ 2015-01-22 3:45 ` Sumit Semwal 0 siblings, 0 replies; 17+ messages in thread From: Sumit Semwal @ 2015-01-22 3:45 UTC (permalink / raw) To: linux-arm-kernel Hi Robin, On 13 January 2015 at 16:49, Marek Szyprowski <m.szyprowski@samsung.com> wrote: > Hello, > > On 2015-01-09 17:56, Robin Murphy wrote: >> >> Many DMA controllers and other devices set max_segment_size to >> indicate their scatter-gather capability, but have no interest in >> segment_boundary_mask. However, the existence of a dma_parms structure >> precludes the use of any default value, leaving them as zeros (assuming >> a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) >> then tries to respect this by ensuring a mapped segment does not cross >> a zero-byte boundary, hilarity ensues. >> >> Since zero is a nonsensical value for either parameter, treat it as an >> indicator for "default", as might be expected. In the process, clean up >> a bit by replacing the bare constants with slightly more meaningful >> macros and removing the superfluous "else" statements. >> >> Signed-off-by: Robin Murphy <robin.murphy@arm.com> > > > Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Please feel free to add my Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org> > >> --- >> >> Hi, various maintainers from Git logs ;) >> >> This one's a bit tricky to find a home for - I think technically it's >> probably an IOMMU patch, but then the long-underlying problem doesn't >> seem to have blown up anything until arm64, and my motivation is to >> make bits of Juno work, which seems to nudge it towards arm64/arm-soc >> territory. Could anyone suggest which tree is most appropriate? >> >> Thanks, >> Robin. >> >> >> include/linux/dma-mapping.h | 17 ++++++++++------- >> 1 file changed, 10 insertions(+), 7 deletions(-) >> >> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h >> index c3007cb..99ba736 100644 >> --- a/include/linux/dma-mapping.h >> +++ b/include/linux/dma-mapping.h >> @@ -141,7 +141,9 @@ static inline void arch_teardown_dma_ops(struct device >> *dev) { } >> static inline unsigned int dma_get_max_seg_size(struct device *dev) >> { >> - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; >> + if (dev->dma_parms && dev->dma_parms->max_segment_size) >> + return dev->dma_parms->max_segment_size; >> + return SZ_64K; >> } >> static inline unsigned int dma_set_max_seg_size(struct device *dev, >> @@ -150,14 +152,15 @@ static inline unsigned int >> dma_set_max_seg_size(struct device *dev, >> if (dev->dma_parms) { >> dev->dma_parms->max_segment_size = size; >> return 0; >> - } else >> - return -EIO; >> + } >> + return -EIO; >> } >> static inline unsigned long dma_get_seg_boundary(struct device *dev) >> { >> - return dev->dma_parms ? >> - dev->dma_parms->segment_boundary_mask : 0xffffffff; >> + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) >> + return dev->dma_parms->segment_boundary_mask; >> + return DMA_BIT_MASK(32); >> } >> static inline int dma_set_seg_boundary(struct device *dev, unsigned >> long mask) >> @@ -165,8 +168,8 @@ static inline int dma_set_seg_boundary(struct device >> *dev, unsigned long mask) >> if (dev->dma_parms) { >> dev->dma_parms->segment_boundary_mask = mask; >> return 0; >> - } else >> - return -EIO; >> + } >> + return -EIO; >> } >> #ifndef dma_max_pfn > > > Best regards > -- > Marek Szyprowski, PhD > Samsung R&D Institute Poland > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Thanks and regards, Sumit Semwal Kernel Team Lead - Linaro Mobile Group Linaro.org ? Open source software for ARM SoCs ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2015-01-22 3:45 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-19 17:39 [PATCH] dma-mapping: tidy up dma_parms default handling Robin Murphy
2015-01-09 16:56 ` [PATCH RESEND] " Robin Murphy
2014-12-22 15:25 ` [PATCH] " Vinod Koul
2014-12-22 15:25 ` Vinod Koul
2015-01-09 19:45 ` [PATCH RESEND] " Arnd Bergmann
2015-01-09 19:45 ` Arnd Bergmann
2015-01-12 13:00 ` Will Deacon
2015-01-12 13:00 ` Will Deacon
2015-01-12 13:00 ` Will Deacon
2015-01-12 13:07 ` Robin Murphy
2015-01-12 13:07 ` Robin Murphy
2015-01-12 13:07 ` Robin Murphy
[not found] ` <ffdc5455d698d2525f2d126d0adabf9418fd76b1.1418990609.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-01-13 11:19 ` Marek Szyprowski
2015-01-13 11:19 ` Marek Szyprowski
2015-01-13 11:19 ` Marek Szyprowski
2015-01-22 3:45 ` Sumit Semwal
2015-01-22 3:45 ` Sumit Semwal
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.