* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices @ 2010-08-19 8:51 FUJITA Tomonori 2010-08-28 17:58 ` Krzysztof Halasa 0 siblings, 1 reply; 11+ messages in thread From: FUJITA Tomonori @ 2010-08-19 8:51 UTC (permalink / raw) To: linux-arm-kernel This fixes the regression of the 6fee48cd330c68332f9712bc968d934a1a84a32a commit. After the above commit, pci_set_consistent_dma_mask doesn't work for dmabounce devices. It converts ARM to use the generic implementation of pci_set_consistent_dma_mask. The root cause that ARM's CONFIG_DMABOUNCE uses dev->coherent_dma_mask for the dma mask of a device _AND_ a bus. dev->coherent_dma_mask is supposed to represent the dma mask of a device. The proper solution is that device and bus has the own dma mask respectively (POWERPC does the similar). But the fix must go to stable trees so this simple (and hacky a bit) patch works better for now. For further information: http://lkml.org/lkml/2010/8/10/272 Reported-by: Krzysztof Halasa <khc@pm.waw.pl> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Krzysztof Halasa <khc@pm.waw.pl> Cc: stable at kernel.org --- arch/arm/mm/dma-mapping.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c704eed..2a3fc2e 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -77,6 +77,11 @@ static struct page *__dma_alloc_buffer(struct device *dev, size_t size, gfp_t gf if (mask < 0xffffffffULL) gfp |= GFP_DMA; +#ifdef CONFIG_DMABOUNCE + if (dev->archdata.dmabounce) + gfp |= GFP_DMA; +#endif + page = alloc_pages(gfp, order); if (!page) return NULL; -- 1.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-08-19 8:51 [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices FUJITA Tomonori @ 2010-08-28 17:58 ` Krzysztof Halasa 2010-09-01 8:57 ` Russell King - ARM Linux 0 siblings, 1 reply; 11+ messages in thread From: Krzysztof Halasa @ 2010-08-28 17:58 UTC (permalink / raw) To: linux-arm-kernel What's the outcome of the following? Russell, are you going to apply it as is, or is a better (short-term) fix being made? FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> writes: > This fixes the regression of the > 6fee48cd330c68332f9712bc968d934a1a84a32a commit. > > After the above commit, pci_set_consistent_dma_mask doesn't work for > dmabounce devices. It converts ARM to use the generic implementation > of pci_set_consistent_dma_mask. > > The root cause that ARM's CONFIG_DMABOUNCE uses dev->coherent_dma_mask > for the dma mask of a device _AND_ a bus. dev->coherent_dma_mask is > supposed to represent the dma mask of a device. > > The proper solution is that device and bus has the own dma mask > respectively (POWERPC does the similar). But the fix must go to stable > trees so this simple (and hacky a bit) patch works better for now. > > For further information: http://lkml.org/lkml/2010/8/10/272 > > Reported-by: Krzysztof Halasa <khc@pm.waw.pl> > Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> > Tested-by: Krzysztof Halasa <khc@pm.waw.pl> > Cc: stable at kernel.org > --- > arch/arm/mm/dma-mapping.c | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c > index c704eed..2a3fc2e 100644 > --- a/arch/arm/mm/dma-mapping.c > +++ b/arch/arm/mm/dma-mapping.c > @@ -77,6 +77,11 @@ static struct page *__dma_alloc_buffer(struct device *dev, size_t size, gfp_t gf > if (mask < 0xffffffffULL) > gfp |= GFP_DMA; > > +#ifdef CONFIG_DMABOUNCE > + if (dev->archdata.dmabounce) > + gfp |= GFP_DMA; > +#endif > + > page = alloc_pages(gfp, order); > if (!page) > return NULL; -- Krzysztof Halasa ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-08-28 17:58 ` Krzysztof Halasa @ 2010-09-01 8:57 ` Russell King - ARM Linux 2010-09-02 2:50 ` FUJITA Tomonori 0 siblings, 1 reply; 11+ messages in thread From: Russell King - ARM Linux @ 2010-09-01 8:57 UTC (permalink / raw) To: linux-arm-kernel On Sat, Aug 28, 2010 at 07:58:11PM +0200, Krzysztof Halasa wrote: > What's the outcome of the following? > > Russell, are you going to apply it as is, or is a better (short-term) > fix being made? I want to see a better solution to this first - without which we'll apply this hack and then quietly forget about the problem. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-01 8:57 ` Russell King - ARM Linux @ 2010-09-02 2:50 ` FUJITA Tomonori 2010-09-02 5:59 ` Richard Cochran 2010-09-05 11:25 ` Russell King - ARM Linux 0 siblings, 2 replies; 11+ messages in thread From: FUJITA Tomonori @ 2010-09-02 2:50 UTC (permalink / raw) To: linux-arm-kernel On Wed, 1 Sep 2010 09:57:38 +0100 Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > On Sat, Aug 28, 2010 at 07:58:11PM +0200, Krzysztof Halasa wrote: > > What's the outcome of the following? > > > > Russell, are you going to apply it as is, or is a better (short-term) > > fix being made? > > I want to see a better solution to this first - without which we'll > apply this hack and then quietly forget about the problem. This restores the trick that had worked. btw, I can't compile ARCH_IXP4XX without the following patch: http://www.spinics.net/lists/arm-kernel/msg95933.html = From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Subject: [PATCH] arm: fix arm: fix pci_set_consistent_dma_mask for dmabounce devices This fixes the regression caused by the commit 6fee48cd330c68332f9712bc968d934a1a84a32a. ARM needs to clip the dma coherent mask for dmabounce devices. This restores the old trick. Note that strictly speaking, the DMA API doesn't allow architectures to do such but I'm not sure it's worth adding the new API to set the dma mask that allows architectures to clip it. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> --- arch/arm/common/it8152.c | 8 ++++++++ arch/arm/mach-ixp4xx/common-pci.c | 8 ++++++++ arch/arm/mach-ixp4xx/include/mach/hardware.h | 2 ++ arch/arm/mach-pxa/include/mach/hardware.h | 2 +- arch/arm/mach-pxa/include/mach/io.h | 2 ++ include/linux/dma-mapping.h | 4 ++++ 6 files changed, 25 insertions(+), 1 deletions(-) diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c index 6c09135..f89dc5d 100644 --- a/arch/arm/common/it8152.c +++ b/arch/arm/common/it8152.c @@ -263,6 +263,14 @@ static int it8152_pci_platform_notify_remove(struct device *dev) return 0; } +int dma_set_coherent_mask(struct device *dev, u64 mask) +{ + if (mask >= PHYS_OFFSET + SZ_64M - 1) + return 0; + + return -EIO; +} + int __init it8152_pci_setup(int nr, struct pci_sys_data *sys) { it8152_io.start = IT8152_IO_BASE + 0x12000; diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c index 61cd4d6..06941a0 100644 --- a/arch/arm/mach-ixp4xx/common-pci.c +++ b/arch/arm/mach-ixp4xx/common-pci.c @@ -503,6 +503,14 @@ struct pci_bus * __devinit ixp4xx_scan_bus(int nr, struct pci_sys_data *sys) return pci_scan_bus(sys->busnr, &ixp4xx_ops, sys); } +int dma_set_coherent_mask(struct device *dev, u64 mask) +{ + if (mask >= SZ_64M - 1 ) + return 0; + + return -EIO; +} + EXPORT_SYMBOL(ixp4xx_pci_read); EXPORT_SYMBOL(ixp4xx_pci_write); diff --git a/arch/arm/mach-ixp4xx/include/mach/hardware.h b/arch/arm/mach-ixp4xx/include/mach/hardware.h index f91ca6d..8138371 100644 --- a/arch/arm/mach-ixp4xx/include/mach/hardware.h +++ b/arch/arm/mach-ixp4xx/include/mach/hardware.h @@ -26,6 +26,8 @@ #define PCIBIOS_MAX_MEM 0x4BFFFFFF #endif +#define ARCH_HAS_DMA_SET_COHERENT_MASK + #define pcibios_assign_all_busses() 1 /* Register locations and bits */ diff --git a/arch/arm/mach-pxa/include/mach/hardware.h b/arch/arm/mach-pxa/include/mach/hardware.h index 7f64d24..428cc7b 100644 --- a/arch/arm/mach-pxa/include/mach/hardware.h +++ b/arch/arm/mach-pxa/include/mach/hardware.h @@ -309,7 +309,7 @@ extern unsigned long get_clock_tick_rate(void); #define PCIBIOS_MIN_IO 0 #define PCIBIOS_MIN_MEM 0 #define pcibios_assign_all_busses() 1 +#define ARCH_HAS_DMA_SET_COHERENT_MASK #endif - #endif /* _ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/mach-pxa/include/mach/io.h b/arch/arm/mach-pxa/include/mach/io.h index 262691f..fdca3be 100644 --- a/arch/arm/mach-pxa/include/mach/io.h +++ b/arch/arm/mach-pxa/include/mach/io.h @@ -6,6 +6,8 @@ #ifndef __ASM_ARM_ARCH_IO_H #define __ASM_ARM_ARCH_IO_H +#include <mach/hardware.h> + #define IO_SPACE_LIMIT 0xffffffff /* diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index ce29b81..ba8319a 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -102,6 +102,9 @@ static inline u64 dma_get_mask(struct device *dev) return DMA_BIT_MASK(32); } +#ifdef ARCH_HAS_DMA_SET_COHERENT_MASK +int dma_set_coherent_mask(struct device *dev, u64 mask); +#else static inline int dma_set_coherent_mask(struct device *dev, u64 mask) { if (!dma_supported(dev, mask)) @@ -109,6 +112,7 @@ static inline int dma_set_coherent_mask(struct device *dev, u64 mask) dev->coherent_dma_mask = mask; return 0; } +#endif extern u64 dma_get_required_mask(struct device *dev); -- 1.7.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-02 2:50 ` FUJITA Tomonori @ 2010-09-02 5:59 ` Richard Cochran 2010-09-05 10:50 ` Eric Miao 2010-09-05 11:25 ` Russell King - ARM Linux 1 sibling, 1 reply; 11+ messages in thread From: Richard Cochran @ 2010-09-02 5:59 UTC (permalink / raw) To: linux-arm-kernel On Thu, Sep 02, 2010 at 11:50:33AM +0900, FUJITA Tomonori wrote: > btw, I can't compile ARCH_IXP4XX without the following patch: > > http://www.spinics.net/lists/arm-kernel/msg95933.html I have the same problem. Compilation of IXP4xx was broken by commit 4fa5518c65df7a2c4b6c58061ac53d0b01228042 Author: Eric Miao <eric.y.miao@gmail.com> Date: Sat Jun 5 15:16:17 2010 +0800 [ARM] pxa: remove now unnecessary dma_needs_bounce() What is the correct way to do fix this? Is the above patch the solution, or is dma_needs_bounce() perhaps also unnecessary for ixp? Thanks, Richard ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-02 5:59 ` Richard Cochran @ 2010-09-05 10:50 ` Eric Miao 2010-09-05 11:21 ` Russell King - ARM Linux 0 siblings, 1 reply; 11+ messages in thread From: Eric Miao @ 2010-09-05 10:50 UTC (permalink / raw) To: linux-arm-kernel On Thu, Sep 2, 2010 at 1:59 PM, Richard Cochran <richardcochran@gmail.com> wrote: > On Thu, Sep 02, 2010 at 11:50:33AM +0900, FUJITA Tomonori wrote: >> btw, I can't compile ARCH_IXP4XX without the following patch: >> >> http://www.spinics.net/lists/arm-kernel/msg95933.html > > I have the same problem. Compilation of IXP4xx was broken by > > ? ?commit 4fa5518c65df7a2c4b6c58061ac53d0b01228042 > ? ?Author: Eric Miao <eric.y.miao@gmail.com> > ? ?Date: ? Sat Jun 5 15:16:17 2010 +0800 > > ? ?[ARM] pxa: remove now unnecessary dma_needs_bounce() > > What is the correct way to do fix this? Is the above patch the > solution, or is dma_needs_bounce() perhaps also unnecessary for ixp? > My bad to break this. If there is no quick proper fix, I'd prefer this being reverted first. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-05 10:50 ` Eric Miao @ 2010-09-05 11:21 ` Russell King - ARM Linux 2010-09-05 11:58 ` Eric Miao 0 siblings, 1 reply; 11+ messages in thread From: Russell King - ARM Linux @ 2010-09-05 11:21 UTC (permalink / raw) To: linux-arm-kernel On Sun, Sep 05, 2010 at 06:50:17PM +0800, Eric Miao wrote: > On Thu, Sep 2, 2010 at 1:59 PM, Richard Cochran > <richardcochran@gmail.com> wrote: > > On Thu, Sep 02, 2010 at 11:50:33AM +0900, FUJITA Tomonori wrote: > >> btw, I can't compile ARCH_IXP4XX without the following patch: > >> > >> http://www.spinics.net/lists/arm-kernel/msg95933.html > > > > I have the same problem. Compilation of IXP4xx was broken by > > > > ? ?commit 4fa5518c65df7a2c4b6c58061ac53d0b01228042 > > ? ?Author: Eric Miao <eric.y.miao@gmail.com> > > ? ?Date: ? Sat Jun 5 15:16:17 2010 +0800 > > > > ? ?[ARM] pxa: remove now unnecessary dma_needs_bounce() > > > > What is the correct way to do fix this? Is the above patch the > > solution, or is dma_needs_bounce() perhaps also unnecessary for ixp? > > > > My bad to break this. If there is no quick proper fix, I'd prefer this > being reverted first. Reverted. Can I assume that I can commit this with: Reported-by: Richard Cochran <richardcochran@gmail.com> Acked-by: Eric Miao <eric.y.miao@gmail.com> ? ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-05 11:21 ` Russell King - ARM Linux @ 2010-09-05 11:58 ` Eric Miao 0 siblings, 0 replies; 11+ messages in thread From: Eric Miao @ 2010-09-05 11:58 UTC (permalink / raw) To: linux-arm-kernel On Sun, Sep 5, 2010 at 7:21 PM, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > On Sun, Sep 05, 2010 at 06:50:17PM +0800, Eric Miao wrote: >> On Thu, Sep 2, 2010 at 1:59 PM, Richard Cochran >> <richardcochran@gmail.com> wrote: >> > On Thu, Sep 02, 2010 at 11:50:33AM +0900, FUJITA Tomonori wrote: >> >> btw, I can't compile ARCH_IXP4XX without the following patch: >> >> >> >> http://www.spinics.net/lists/arm-kernel/msg95933.html >> > >> > I have the same problem. Compilation of IXP4xx was broken by >> > >> > ? ?commit 4fa5518c65df7a2c4b6c58061ac53d0b01228042 >> > ? ?Author: Eric Miao <eric.y.miao@gmail.com> >> > ? ?Date: ? Sat Jun 5 15:16:17 2010 +0800 >> > >> > ? ?[ARM] pxa: remove now unnecessary dma_needs_bounce() >> > >> > What is the correct way to do fix this? Is the above patch the >> > solution, or is dma_needs_bounce() perhaps also unnecessary for ixp? >> > >> >> My bad to break this. If there is no quick proper fix, I'd prefer this >> being reverted first. > > Reverted. > > Can I assume that I can commit this with: > > Reported-by: Richard Cochran <richardcochran@gmail.com> > Acked-by: Eric Miao <eric.y.miao@gmail.com> > Yes please. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-02 2:50 ` FUJITA Tomonori 2010-09-02 5:59 ` Richard Cochran @ 2010-09-05 11:25 ` Russell King - ARM Linux 2010-09-05 23:32 ` FUJITA Tomonori 1 sibling, 1 reply; 11+ messages in thread From: Russell King - ARM Linux @ 2010-09-05 11:25 UTC (permalink / raw) To: linux-arm-kernel On Thu, Sep 02, 2010 at 11:50:33AM +0900, FUJITA Tomonori wrote: > On Wed, 1 Sep 2010 09:57:38 +0100 > Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > > > On Sat, Aug 28, 2010 at 07:58:11PM +0200, Krzysztof Halasa wrote: > > > What's the outcome of the following? > > > > > > Russell, are you going to apply it as is, or is a better (short-term) > > > fix being made? > > > > I want to see a better solution to this first - without which we'll > > apply this hack and then quietly forget about the problem. > > This restores the trick that had worked. > > btw, I can't compile ARCH_IXP4XX without the following patch: > > http://www.spinics.net/lists/arm-kernel/msg95933.html > > = > From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> > Subject: [PATCH] arm: fix arm: fix pci_set_consistent_dma_mask for dmabounce devices > > This fixes the regression caused by the commit > 6fee48cd330c68332f9712bc968d934a1a84a32a. > > ARM needs to clip the dma coherent mask for dmabounce devices. This > restores the old trick. > > Note that strictly speaking, the DMA API doesn't allow architectures > to do such but I'm not sure it's worth adding the new API to set the > dma mask that allows architectures to clip it. > > Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Thanks. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-05 11:25 ` Russell King - ARM Linux @ 2010-09-05 23:32 ` FUJITA Tomonori 2010-09-14 21:23 ` Krzysztof Halasa 0 siblings, 1 reply; 11+ messages in thread From: FUJITA Tomonori @ 2010-09-05 23:32 UTC (permalink / raw) To: linux-arm-kernel On Sun, 5 Sep 2010 12:25:13 +0100 Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > > This restores the trick that had worked. > > > > btw, I can't compile ARCH_IXP4XX without the following patch: > > > > http://www.spinics.net/lists/arm-kernel/msg95933.html > > > > = > > From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> > > Subject: [PATCH] arm: fix arm: fix pci_set_consistent_dma_mask for dmabounce devices > > > > This fixes the regression caused by the commit > > 6fee48cd330c68332f9712bc968d934a1a84a32a. > > > > ARM needs to clip the dma coherent mask for dmabounce devices. This > > restores the old trick. > > > > Note that strictly speaking, the DMA API doesn't allow architectures > > to do such but I'm not sure it's worth adding the new API to set the > > dma mask that allows architectures to clip it. > > > > Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> > > Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Should I send this to Linus? Or Can I assume that someone in ARM camp will do? ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices 2010-09-05 23:32 ` FUJITA Tomonori @ 2010-09-14 21:23 ` Krzysztof Halasa 0 siblings, 0 replies; 11+ messages in thread From: Krzysztof Halasa @ 2010-09-14 21:23 UTC (permalink / raw) To: linux-arm-kernel FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> writes: >> > From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> >> > Subject: [PATCH] arm: fix arm: fix pci_set_consistent_dma_mask for dmabounce devices >> > >> > This fixes the regression caused by the commit >> > 6fee48cd330c68332f9712bc968d934a1a84a32a. >> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> > > Should I send this to Linus? Or Can I assume that someone in ARM camp > will do? It would be nice if you do. TIA. -- Krzysztof Halasa ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-09-14 21:23 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-08-19 8:51 [PATCH] arm: fix pci_set_consistent_dma_mask for dmabounce devices FUJITA Tomonori 2010-08-28 17:58 ` Krzysztof Halasa 2010-09-01 8:57 ` Russell King - ARM Linux 2010-09-02 2:50 ` FUJITA Tomonori 2010-09-02 5:59 ` Richard Cochran 2010-09-05 10:50 ` Eric Miao 2010-09-05 11:21 ` Russell King - ARM Linux 2010-09-05 11:58 ` Eric Miao 2010-09-05 11:25 ` Russell King - ARM Linux 2010-09-05 23:32 ` FUJITA Tomonori 2010-09-14 21:23 ` Krzysztof Halasa
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).