Skip to contentSkip to conversation

bcma: inform drivers about translation bits needed for the board

PATCH In review Rafał Miłecki 2 participants 6 messages Jul 19, 2011

Subsystems (2)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/2 bcma: inform drivers about translation bits needed for the board

When using DMA, drivers need to pass special translation info to the hardware.

---
 drivers/bcma/main.c       |   12 ++++++++++++
 include/linux/bcma/bcma.h |    2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)
drivers/bcma/main.c +12 -0
index 873e2e4..660288c 100644
@@ -164,6 +164,18 @@ int bcma_bus_register(struct bcma_bus *bus)
 	return 0;
 }
 
+u32 bcma_dma_translation(struct bcma_bus *bus)
+{
+	switch (bus->hosttype) {
+	case BCMA_HOSTTYPE_PCI:
+		return 0x40000000;
+	default:
+		pr_err("DMA translation unknown for host %d\n", bus->hosttype);
+	}
+	return 0;
+}
+EXPORT_SYMBOL(bcma_dma_translation);
+
 void bcma_bus_unregister(struct bcma_bus *bus)
 {
 	bcma_unregister_cores(bus);
include/linux/bcma/bcma.h +2 -0
index cc1582d..921671b 100644
@@ -255,6 +255,8 @@ void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
 #define bcma_maskset32(cc, offset, mask, set) \
 	bcma_write32(cc, offset, (bcma_read32(cc, offset) & (mask)) | (set))
 
+extern u32 bcma_dma_translation(struct bcma_bus *bus);
+
 extern bool bcma_core_is_enabled(struct bcma_device *core);
 extern void bcma_core_disable(struct bcma_device *core, u32 flags);
 extern int bcma_core_enable(struct bcma_device *core, u32 flags);
Signature · 1 line
1.7.3.4
author maintainer
#1 lore raw

PATCH 2/2 b43: bcma: get DMA translation bits

Add some missing defines by the way.

---
 drivers/net/wireless/b43/dma.c |    5 +++++
 drivers/net/wireless/b43/dma.h |    4 ++++
 2 files changed, 9 insertions(+), 0 deletions(-)
drivers/net/wireless/b43/dma.c +5 -0
index ce572ae..0bedc30 100644
@@ -1057,6 +1057,11 @@ int b43_dma_init(struct b43_wldev *dev)
 		return err;
 
 	switch (dev->dev->bus_type) {
+#ifdef CONFIG_B43_BCMA
+	case B43_BUS_BCMA:
+		dma->translation = bcma_dma_translation(dev->dev->bdev->bus);
+		break;
+#endif
 #ifdef CONFIG_B43_SSB
 	case B43_BUS_SSB:
 		dma->translation = ssb_dma_translation(dev->dev->sdev);
drivers/net/wireless/b43/dma.h +4 -0
index e8a80a1..cdf8709 100644
@@ -20,6 +20,7 @@
 #define		B43_DMA32_TXSUSPEND			0x00000002
 #define		B43_DMA32_TXLOOPBACK		0x00000004
 #define		B43_DMA32_TXFLUSH			0x00000010
+#define		B43_DMA32_TXPARITYDISABLE		0x00000800
 #define		B43_DMA32_TXADDREXT_MASK		0x00030000
 #define		B43_DMA32_TXADDREXT_SHIFT		16
 #define B43_DMA32_TXRING				0x04
@@ -44,6 +45,7 @@
 #define		B43_DMA32_RXFROFF_MASK		0x000000FE
 #define		B43_DMA32_RXFROFF_SHIFT		1
 #define		B43_DMA32_RXDIRECTFIFO		0x00000100
+#define		B43_DMA32_RXPARITYDISABLE		0x00000800
 #define		B43_DMA32_RXADDREXT_MASK		0x00030000
 #define		B43_DMA32_RXADDREXT_SHIFT		16
 #define B43_DMA32_RXRING				0x14
@@ -84,6 +86,7 @@ struct b43_dmadesc32 {
 #define		B43_DMA64_TXSUSPEND			0x00000002
 #define		B43_DMA64_TXLOOPBACK		0x00000004
 #define		B43_DMA64_TXFLUSH			0x00000010
+#define		B43_DMA64_TXPARITYDISABLE		0x00000800
 #define		B43_DMA64_TXADDREXT_MASK		0x00030000
 #define		B43_DMA64_TXADDREXT_SHIFT		16
 #define B43_DMA64_TXINDEX				0x04
@@ -111,6 +114,7 @@ struct b43_dmadesc32 {
 #define		B43_DMA64_RXFROFF_MASK		0x000000FE
 #define		B43_DMA64_RXFROFF_SHIFT		1
 #define		B43_DMA64_RXDIRECTFIFO		0x00000100
+#define		B43_DMA64_RXPARITYDISABLE		0x00000800
 #define		B43_DMA64_RXADDREXT_MASK		0x00030000
 #define		B43_DMA64_RXADDREXT_SHIFT		16
 #define B43_DMA64_RXINDEX				0x24
Signature · 1 line
1.7.3.4
#4 lore raw
In reply to Rafał Miłecki
Quoted 4 lines · Rafał Miłecki

When using DMA, drivers need to pass special translation info to the hardware.

I'm not sure why you are copying it to me.

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 171

Quoted 3 lines
drivers/bcma/main.c +3 -0
+	switch (bus->hosttype) {
+	case BCMA_HOSTTYPE_PCI:
+		return 0x40000000;

This is already implemented in ssb_dma_translation(), and the constant is called SSB_PCI_DMA. I think we need a named constant here as well, either SSB_PCI_DMA or a new constant BCMA_PCI_DMA.

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw

Re: [PATCH 2/2] b43: bcma: get DMA translation bits

In reply to Rafał Miłecki

drivers/net/wireless/b43/dma.c int b43_dma_init(struct b43_wldev *dev) · line 1064

Quoted 5 lines · Rafał Miłecki
drivers/net/wireless/b43/dma.c +5 -0
+#ifdef CONFIG_B43_BCMA
+	case B43_BUS_BCMA:
+		dma->translation = bcma_dma_translation(dev->dev->bdev->bus);
+		break;
+#endif

How about we set dma->translation to 0x40000000 for 32-bit DMA and to 0x80000000 for 64-bit DMA and remove shifting translation by 1 in the 64-bit DMA code? There should be a warning for non-PCI devices here. No ifdefs, no separate treatment of different buses.

I think we are adding too much complexity here.

Signature · 2 lines
Regards,
Pavel Roskin
author maintainer
#5 lore raw

PATCH 1/2 bcma: inform drivers about translation bits needed for the board

In reply to Pavel Roskin

W dniu 19 lipca 2011 16:38 u?ytkownik Pavel Roskin <[email protected]> napisa?:

Quoted 8 lines · Rafa? Mi?ecki
Quoted 5 lines

When using DMA, drivers need to pass special translation info to the hardware.

I'm not sure why you are copying it to me.

Upd, I've used bash history and the last send-email was with --cc to you.

Quoted 7 lines
Quoted 3 lines

+ ? ? ? switch (bus->hosttype) {
+ ? ? ? case BCMA_HOSTTYPE_PCI:
+ ? ? ? ? ? ? ? return 0x40000000;

This is already implemented in ssb_dma_translation(), and the constant is called SSB_PCI_DMA. ?I think we need a named constant here as well, either SSB_PCI_DMA or a new constant BCMA_PCI_DMA.

Signature · 1 line
Rafa?
author maintainer
#3 lore raw

PATCH 2/2 b43: bcma: get DMA translation bits

In reply to Pavel Roskin

W dniu 19 lipca 2011 16:52 u?ytkownik Pavel Roskin <[email protected]> napisa?:

Quoted 14 lines · Rafa? Mi?ecki
Quoted 7 lines

+#ifdef CONFIG_B43_BCMA
+ ? ? ? case B43_BUS_BCMA:
+ ? ? ? ? ? ? ? dma->translation =
bcma_dma_translation(dev->dev->bdev->bus);
+ ? ? ? ? ? ? ? break;
+#endif

How about we set dma->translation to 0x40000000 for 32-bit DMA and to 0x80000000 for 64-bit DMA and remove shifting translation by 1 in the 64-bit DMA code? ?There should be a warning for non-PCI devices here. No ifdefs, no separate treatment of different buses.

Quoted 1 line

I think we are adding too much complexity here.

Warning is generated on bcma_dma_translation side. We could make that function return s32 and return negative values of error, but not sure if it's worth it. We will get warning anyway.

After checking specs (http://bcm-v4.sipsolutions.net/802.11/DMA) I've to agree that our shifting looks crazy. Probably ssb function was implemented and someone added 64-bit DMA support without modifying ssb.

There is no reason to shift value by 1. Routing mask is always 0xC0000000. It's just about different values:
DMA32: 0x1 == Client Mode Translation (1GB)
DMA64: 0x2 == Client Mode Translation (2 Zettabytes)

Well, I've to say it was really worth to CC you :)

Signature · 1 line
Rafa?