All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices
@ 2019-01-28 13:32 Alexander Fomichev
  2019-01-30 12:58 ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Fomichev @ 2019-01-28 13:32 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux

get_dma_ops() falls into arch-dependant get_arch_dma_ops(), which
historically returns NULL on PowerPC. Therefore dma_set_mask() fails.
This affects Switchtec (and probably other) NTB devices, that they fail
to initialize.
The proposed patch should fix the issue.

---
 arch/powerpc/include/asm/dma-mapping.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index ebf6680..cb6ac96 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -70,14 +70,11 @@ extern struct dma_map_ops dma_iommu_ops;
 #endif
 extern const struct dma_map_ops dma_nommu_ops;
 
+extern const struct dma_map_ops *get_pci_dma_ops(void);
+
 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
-	/* We don't handle the NULL dev case for ISA for now. We could
-	 * do it via an out of line call but it is not needed for now. The
-	 * only ISA DMA device we support is the floppy and we have a hack
-	 * in the floppy driver directly to get a device for us.
-	 */
-	return NULL;
+	return get_pci_dma_ops();
 }
 
 /*
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices
  2019-01-28 13:32 [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices Alexander Fomichev
@ 2019-01-30 12:58 ` Michael Ellerman
  2019-02-04  8:17   ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2019-01-30 12:58 UTC (permalink / raw)
  To: Alexander Fomichev, linuxppc-dev; +Cc: Christoph Hellwig, linux

Alexander Fomichev <fomichev.ru@gmail.com> writes:

> get_dma_ops() falls into arch-dependant get_arch_dma_ops(), which
> historically returns NULL on PowerPC. Therefore dma_set_mask() fails.
> This affects Switchtec (and probably other) NTB devices, that they fail
> to initialize.

What's an NTB device?

drivers/ntb I assume?

So it's a PCI device of some sort, but presumably the device you're
calling dma_set_mask() on is an NTB device not a PCI device?

But then it works if you tell it to use the PCI DMA ops?

At the very least the code should be checking for the NTB bus type and
only returning the PCI ops in that specific case, not for all devices.

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices
  2019-01-30 12:58 ` Michael Ellerman
@ 2019-02-04  8:17   ` Christoph Hellwig
  2019-02-05 11:20     ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2019-02-04  8:17 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Christoph Hellwig, Alexander Fomichev, linux

On Wed, Jan 30, 2019 at 11:58:40PM +1100, Michael Ellerman wrote:
> Alexander Fomichev <fomichev.ru@gmail.com> writes:
> 
> > get_dma_ops() falls into arch-dependant get_arch_dma_ops(), which
> > historically returns NULL on PowerPC. Therefore dma_set_mask() fails.
> > This affects Switchtec (and probably other) NTB devices, that they fail
> > to initialize.
> 
> What's an NTB device?
> 
> drivers/ntb I assume?
> 
> So it's a PCI device of some sort, but presumably the device you're
> calling dma_set_mask() on is an NTB device not a PCI device?
> 
> But then it works if you tell it to use the PCI DMA ops?
> 
> At the very least the code should be checking for the NTB bus type and
> only returning the PCI ops in that specific case, not for all devices.

Can you provide the context?  E.g. the patch and the rest of the commit
log.  This all looks rather odd to me.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices
  2019-02-04  8:17   ` Christoph Hellwig
@ 2019-02-05 11:20     ` Michael Ellerman
  2019-02-05 16:13       ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2019-02-05 11:20 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linuxppc-dev, Christoph Hellwig, Alexander Fomichev, linux

Christoph Hellwig <hch@lst.de> writes:
> On Wed, Jan 30, 2019 at 11:58:40PM +1100, Michael Ellerman wrote:
>> Alexander Fomichev <fomichev.ru@gmail.com> writes:
>> 
>> > get_dma_ops() falls into arch-dependant get_arch_dma_ops(), which
>> > historically returns NULL on PowerPC. Therefore dma_set_mask() fails.
>> > This affects Switchtec (and probably other) NTB devices, that they fail
>> > to initialize.
>> 
>> What's an NTB device?
>> 
>> drivers/ntb I assume?
>> 
>> So it's a PCI device of some sort, but presumably the device you're
>> calling dma_set_mask() on is an NTB device not a PCI device?
>> 
>> But then it works if you tell it to use the PCI DMA ops?
>> 
>> At the very least the code should be checking for the NTB bus type and
>> only returning the PCI ops in that specific case, not for all devices.
>
> Can you provide the context?  E.g. the patch and the rest of the commit
> log.  This all looks rather odd to me.

Sorry, here it is.

Or on lore: https://lore.kernel.org/linuxppc-dev/20190128133203.mon4a3nkrzijn43g@alfbook-pro.local/

Subject: [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices

get_dma_ops() falls into arch-dependant get_arch_dma_ops(), which
historically returns NULL on PowerPC. Therefore dma_set_mask() fails.
This affects Switchtec (and probably other) NTB devices, that they fail
to initialize.
The proposed patch should fix the issue.

---
 arch/powerpc/include/asm/dma-mapping.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index ebf6680..cb6ac96 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -70,14 +70,11 @@ extern struct dma_map_ops dma_iommu_ops;
 #endif
 extern const struct dma_map_ops dma_nommu_ops;

+extern const struct dma_map_ops *get_pci_dma_ops(void);
+
 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
-	/* We don't handle the NULL dev case for ISA for now. We could
-	 * do it via an out of line call but it is not needed for now. The
-	 * only ISA DMA device we support is the floppy and we have a hack
-	 * in the floppy driver directly to get a device for us.
-	 */
-	return NULL;
+	return get_pci_dma_ops();
 }

 /*

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices
  2019-02-05 11:20     ` Michael Ellerman
@ 2019-02-05 16:13       ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2019-02-05 16:13 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Christoph Hellwig, Alexander Fomichev, linux

On Tue, Feb 05, 2019 at 10:20:32PM +1100, Michael Ellerman wrote:
> get_dma_ops() falls into arch-dependant get_arch_dma_ops(), which
> historically returns NULL on PowerPC. Therefore dma_set_mask() fails.
> This affects Switchtec (and probably other) NTB devices, that they fail
> to initialize.
> The proposed patch should fix the issue.

I'm not a fan of this.  powerpc, just like arm64 for example has
required that we set a specific per-device dma ops, which keeps
the assignments clear.  Where do the NTB devices come from?

Might be worth adding the NTB maintainers to the CC list and maybe
linux-iommu.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-05 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 13:32 [RFC PATCH] powerpc: fix get_arch_dma_ops() for NTB devices Alexander Fomichev
2019-01-30 12:58 ` Michael Ellerman
2019-02-04  8:17   ` Christoph Hellwig
2019-02-05 11:20     ` Michael Ellerman
2019-02-05 16:13       ` Christoph Hellwig

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.