2011-07-19 07:26:24

by Rafał Miłecki

[permalink] [raw]
Subject: [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.

Signed-off-by: Rafał Miłecki <[email protected]>
---
drivers/bcma/main.c | 12 ++++++++++++
include/linux/bcma/bcma.h | 2 ++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 873e2e4..660288c 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -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);
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index cc1582d..921671b 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -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);
--
1.7.3.4



2011-07-19 14:52:13

by Pavel Roskin

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

On 07/19/2011 04:05 AM, Rafał Miłecki wrote:

> +#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.

--
Regards,
Pavel Roskin

2011-07-19 14:38:54

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH 1/2] bcma: inform drivers about translation bits needed for the board

On 07/19/2011 04:05 AM, Rafał Miłecki wrote:
> When using DMA, drivers need to pass special translation info to the
> hardware.
>
> Signed-off-by: Rafał Miłecki<[email protected]>

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

> + 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.

--
Regards,
Pavel Roskin

2011-07-19 18:46:35

by Rafał Miłecki

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

W dniu 19 lipca 2011 16:52 użytkownik Pavel Roskin <[email protected]> napisał:
> On 07/19/2011 04:05 AM, Rafał Miłecki wrote:
>
>> +#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.

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 :)

--
Rafał

2011-07-19 17:14:03

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [PATCH 1/2] bcma: inform drivers about translation bits needed for the board

W dniu 19 lipca 2011 16:38 użytkownik Pavel Roskin <[email protected]> napisał:
> On 07/19/2011 04:05 AM, Rafał Miłecki wrote:
>>
>> When using DMA, drivers need to pass special translation info to the
>> hardware.
>>
>> Signed-off-by: Rafał Miłecki<[email protected]>
>
> 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.


>> +       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.


--
Rafał

2011-07-19 07:26:29

by Rafał Miłecki

[permalink] [raw]
Subject: [PATCH 2/2] b43: bcma: get DMA translation bits

Add some missing defines by the way.

Signed-off-by: Rafał Miłecki <[email protected]>
---
drivers/net/wireless/b43/dma.c | 5 +++++
drivers/net/wireless/b43/dma.h | 4 ++++
2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index ce572ae..0bedc30 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -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);
diff --git a/drivers/net/wireless/b43/dma.h b/drivers/net/wireless/b43/dma.h
index e8a80a1..cdf8709 100644
--- a/drivers/net/wireless/b43/dma.h
+++ b/drivers/net/wireless/b43/dma.h
@@ -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
--
1.7.3.4