Skip to contentSkip to conversation

Set Ether device's DMA masks on SH-Mobile boards

PATCH New Sergei Shtylyov 2 participants 7 messages Feb 15, 2014 – Feb 17, 2014 SuperH

lore
Share & tools
lore
#0 lore raw

cover Set Ether device's DMA masks on SH-Mobile boards

Hello.

Here's the set of 5 patches against Simon Horman's 'renesas.git' repo,
'renesas-devel-v3.14-rc2-20130213' tag. Here we add still missing DMA masks for the Ether platform devices (I was always wondering how the 'sh_eth' driver manages to work without them :-). This should be especially important for the Lager/Koelsch boards with their CPUs supporting LPAE and the boards having memory outside 4 GiB address range, so we'd have to eventually enable CONFIG_HIGHMEM for them; I also have plans to add support for NETIF_F_SG to the 'sh_eth' driver -- in which case the correct DMA masks would become important.

[1/5] ARM: shmobile: Armadillo 800 EVA: set proper DMA masks for Ether device [2/5] ARM: shmobile: BOCK-W: set proper DMA masks for Ether device [3/5] ARM: shmobile: Lager: set proper DMA masks for Ether device [4/5] ARM: shmobile: Koelsch: set proper DMA masks for Ether device [5/5] ARM: shmobile: Genmai: set proper DMA masks for Ether device

WBR, Sergei

#1 lore raw

PATCH 1/5 ARM: shmobile: Armadillo 800 EVA: set proper DMA masks for Ether device

Ether MAC is a DMA-capable device and so should have 'dev.dma_mask' and 'dev.coherent_dma_mask' fields set properly, to reflect 32-bit DMA addressing ability.

---
 arch/arm/mach-shmobile/board-armadillo800eva.c |    2 ++
 1 file changed, 2 insertions(+)

Index: renesas/arch/arm/mach-shmobile/board-armadillo800eva.c =================================--- renesas.orig/arch/arm/mach-shmobile/board-armadillo800eva.c +++ renesas/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -383,6 +383,8 @@ static struct platform_device sh_eth_dev
.id = -1,
.dev = {
.platform_data = &sh_eth_platdata,
+ .dma_mask = &sh_eth_device.dev.coherent_dma_mask,
+ .coherent_dma_mask = DMA_BIT_MASK(32),
},
.resource = sh_eth_resources,
.num_resources = ARRAY_SIZE(sh_eth_resources),

#2 lore raw

PATCH 2/5 ARM: shmobile: BOCK-W: set proper DMA masks for Ether device

In reply to Sergei Shtylyov

Ether MAC is a DMA-capable device and so should have 'dev.dma_mask' and 'dev.coherent_dma_mask' fields set properly, to reflect 32-bit DMA addressing ability.

---
 arch/arm/mach-shmobile/board-bockw.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

Index: renesas/arch/arm/mach-shmobile/board-bockw.c =================================--- renesas.orig/arch/arm/mach-shmobile/board-bockw.c +++ renesas/arch/arm/mach-shmobile/board-bockw.c
@@ -1,9 +1,9 @@
/*
* Bock-W board support
*
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
* Copyright (C) 2013 Kuninori Morimoto <[email protected]>
- * Copyright (C) 2013 Cogent Embedded, Inc.
+ * Copyright (C) 2013-2014 Cogent Embedded, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -235,6 +235,17 @@ static struct sh_eth_plat_data ether_pla
.no_ether_link = 1,
};

+static struct platform_device_info ether_info __initdata = {
+ .parent = &platform_bus,
+ .name = "r8a777x-ether",
+ .id = -1,
+ .res = ether_resources,
+ .num_res = ARRAY_SIZE(ether_resources),
+ .data = &ether_platform_data,
+ .size_data = sizeof(ether_platform_data),
+ .dma_mask = DMA_BIT_MASK(32),
+};
+
/* I2C */
static struct i2c_board_info i2c0_devices[] = {
{
@@ -592,11 +603,7 @@ static void __init bockw_init(void)
r8a7778_init_irq_extpin(1); r8a7778_add_standard_devices();

- platform_device_register_resndata(&platform_bus, "r8a777x-ether", -1,

-					  ether_resources,
-					  ARRAY_SIZE(ether_resources),
-					  &ether_platform_data,
-					  sizeof(ether_platform_data));

+ platform_device_register_full(&ether_info);

platform_device_register_full(&vin0_info); /* VIN1 has a pin conflict with Ether */

#3 lore raw

PATCH 3/5 ARM: shmobile: Lager: set proper DMA masks for Ether device

In reply to Sergei Shtylyov

Ether MAC is a DMA-capable device and so should have 'dev.dma_mask' and 'dev.coherent_dma_mask' fields set properly, to reflect 32-bit DMA addressing ability.

Currently, the code works without DMA masks but as we would have to enable CONFIG_HIGHMEM to access the full board memory in the future, when support for NETIF_F_SG would be added to the 'sh_eth' driver as well, the correct DMA masks should start to matter...

---
 arch/arm/mach-shmobile/board-lager.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Index: renesas/arch/arm/mach-shmobile/board-lager.c =================================--- renesas.orig/arch/arm/mach-shmobile/board-lager.c +++ renesas/arch/arm/mach-shmobile/board-lager.c
@@ -1,8 +1,9 @@
/*
* Lager board support
*
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
* Copyright (C) 2013 Magnus Damm
+ * Copyright (C) 2014 Cogent Embedded, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -275,6 +276,17 @@ static const struct resource ether_resou
DEFINE_RES_IRQ(gic_spi(162)),
};

+static const struct platform_device_info ether_info __initconst = {
+ .parent = &platform_bus,
+ .name = "r8a7790-ether",
+ .id = -1,
+ .res = ether_resources,
+ .num_res = ARRAY_SIZE(ether_resources),
+ .data = &ether_pdata,
+ .size_data = sizeof(ether_pdata),
+ .dma_mask = DMA_BIT_MASK(32),
+};
+
/* SPI Flash memory (Spansion S25FL512SAGMFIG11 64Mb) */
static struct mtd_partition spi_flash_part[] = {
/* Reserved for user loader program, read-only */
@@ -743,10 +755,7 @@ static void __init lager_add_standard_de
mmcif1_resources, ARRAY_SIZE(mmcif1_resources), &mmcif1_pdata, sizeof(mmcif1_pdata));

- platform_device_register_resndata(&platform_bus, "r8a7790-ether", -1,

-					  ether_resources,
-					  ARRAY_SIZE(ether_resources),
-					  &ether_pdata, sizeof(ether_pdata));

+ platform_device_register_full(&ether_info);

lager_add_du_device();

#4 lore raw

PATCH 4/5 ARM: shmobile: Koelsch: set proper DMA masks for Ether device

In reply to Sergei Shtylyov

Ether MAC is a DMA-capable device and so should have 'dev.dma_mask' and 'dev.coherent_dma_mask' fields set properly, to reflect 32-bit DMA addressing ability.

Currently, the code works without DMA masks but as we would have to enable CONFIG_HIGHMEM to access the full board memory in the future, when support for NETIF_F_SG would be added to the 'sh_eth' driver as well, the correct DMA masks should start to matter...

---
 arch/arm/mach-shmobile/board-koelsch.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Index: renesas/arch/arm/mach-shmobile/board-koelsch.c =================================--- renesas.orig/arch/arm/mach-shmobile/board-koelsch.c +++ renesas/arch/arm/mach-shmobile/board-koelsch.c
@@ -2,8 +2,9 @@
* Koelsch board support
*
* Copyright (C) 2013 Renesas Electronics Corporation
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
* Copyright (C) 2013 Magnus Damm
+ * Copyright (C) 2014 Cogent Embedded, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -116,6 +117,17 @@ static const struct resource ether_resou
DEFINE_RES_IRQ(gic_spi(162)),
};

+static const struct platform_device_info ether_info __initconst = {
+ .parent = &platform_bus,
+ .name = "r8a7791-ether",
+ .id = -1,
+ .res = ether_resources,
+ .num_res = ARRAY_SIZE(ether_resources),
+ .data = &ether_pdata,
+ .size_data = sizeof(ether_pdata),
+ .dma_mask = DMA_BIT_MASK(32),
+};
+
/* LEDS */
static struct gpio_led koelsch_leds[] = {
{
@@ -426,10 +438,7 @@ static void __init koelsch_add_standard_
ARRAY_SIZE(koelsch_pinctrl_map));
r8a7791_pinmux_init(); r8a7791_add_standard_devices();
- platform_device_register_resndata(&platform_bus, "r8a7791-ether", -1,

-					  ether_resources,
-					  ARRAY_SIZE(ether_resources),
-					  &ether_pdata, sizeof(ether_pdata));

+ platform_device_register_full(&ether_info);
platform_device_register_data(&platform_bus, "leds-gpio", -1,
&koelsch_leds_pdata, sizeof(koelsch_leds_pdata));

#5 lore raw

PATCH 5/5 ARM: shmobile: Genmai: set proper DMA masks for Ether device

In reply to Sergei Shtylyov

Ether MAC is a DMA-capable device and so should have 'dev.dma_mask' and 'dev.coherent_dma_mask' fields set properly, to reflect 32-bit DMA addressing ability.

---
 arch/arm/mach-shmobile/board-genmai.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Index: renesas/arch/arm/mach-shmobile/board-genmai.c =================================--- renesas.orig/arch/arm/mach-shmobile/board-genmai.c +++ renesas/arch/arm/mach-shmobile/board-genmai.c
@@ -1,8 +1,9 @@
/*
* Genmai board support
*
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
* Copyright (C) 2013 Magnus Damm
+ * Copyright (C) 2014 Cogent Embedded, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,6 +44,17 @@ static const struct resource ether_resou
DEFINE_RES_IRQ(gic_iid(359)),
};

+static const struct platform_device_info ether_info __initconst = {
+ .parent = &platform_bus,
+ .name = "r7s72100-ether",
+ .id = -1,
+ .res = ether_resources,
+ .num_res = ARRAY_SIZE(ether_resources),
+ .data = &ether_pdata,
+ .size_data = sizeof(ether_pdata),
+ .dma_mask = DMA_BIT_MASK(32),
+};
+
/* RSPI */
#define RSPI_RESOURCE(idx, baseaddr, irq) \
static const struct resource rspi##idx##_resources[] __initconst = { \
@@ -82,10 +94,7 @@ static void __init genmai_add_standard_d
r7s72100_clock_init();
r7s72100_add_dt_devices();

- platform_device_register_resndata(&platform_bus, "r7s72100-ether", -1,

-					  ether_resources,
-					  ARRAY_SIZE(ether_resources),
-					  &ether_pdata, sizeof(ether_pdata));

+ platform_device_register_full(&ether_info);

r7s72100_register_rspi(0);
r7s72100_register_rspi(1);

#6 lore raw

cover Set Ether device's DMA masks on SH-Mobile boards

In reply to Sergei Shtylyov
Quoted 11 lines · Sergei Shtylyov

Hello.

Here's the set of 5 patches against Simon Horman's 'renesas.git' repo,
'renesas-devel-v3.14-rc2-20130213' tag. Here we add still missing DMA masks for the Ether platform devices (I was always wondering how the 'sh_eth' driver manages to work without them :-). This should be especially important for the Lager/Koelsch boards with their CPUs supporting LPAE and the boards having memory outside 4 GiB address range, so we'd have to eventually enable CONFIG_HIGHMEM for them; I also have plans to add support for NETIF_F_SG to the 'sh_eth' driver -- in which case the correct DMA masks would become important.

Quoted 5 lines

[1/5] ARM: shmobile: Armadillo 800 EVA: set proper DMA masks for Ether device [2/5] ARM: shmobile: BOCK-W: set proper DMA masks for Ether device [3/5] ARM: shmobile: Lager: set proper DMA masks for Ether device [4/5] ARM: shmobile: Koelsch: set proper DMA masks for Ether device [5/5] ARM: shmobile: Genmai: set proper DMA masks for Ether device

Thanks, I have queued these up.