Fixes for running a big-endian kernel on Cubieboard2
Subsystems (8)
v2 cover Fixes for running a big-endian kernel on Cubieboard2
Hello,
the following patches fix up endianness problems with DMA descriptors in the sunxi-mmc and stmmac drivers preventing a big-endian kernel from working correctly on the Cubieboard2. The final patch enables the big-endian kernel configuration option for sunxi devices in order to be able to compile a big-endian kernel for the Cubieboard2. All of these have been tested successfull on a Cubieboard2 Dual-Card.
Changes since v1:
- fixed checkpatch niggles
- added respective Cc:s
Regards,
Michael
PATCH v2 1/3 mmc: sunxi-mmc: change idma descriptor to __le32
The sunxi-mmc driver does not take into account the processor may be big endian when writing the DMA descriptors. This causes cards not to be detected when running a big-endian kernel. Change the descriptors for IDMA to use __le32 and ensure they are suitably swapped before writing. Tested successfully on the Cubieboard2.
--- drivers/mmc/host/sunxi-mmc.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/mmc/host/sunxi-mmc.c +15 -12
@@ -223,10 +223,10 @@ struct sunxi_mmc_clk_delay { };struct sunxi_idma_des { -u32 config; -u32 buf_size; -u32 buf_addr_ptr1; -u32 buf_addr_ptr2; +__le32 config; +__le32 buf_size; +__le32 buf_addr_ptr1; +__le32 buf_addr_ptr2; };struct sunxi_mmc_host {
@@ -325,22 +325,25 @@ static void sunxi_mmc_init_idma_des(struct sunxi_mmc_host *host,int i, max_len = (1 << host->idma_des_size_bits);for (i =0 ; i < data->sg_len; i++) { - pdes[i].config =SDXC_IDMAC_DES0_CH |SDXC_IDMAC_DES0_OWN | -SDXC_IDMAC_DES0_DIC ; + pdes[i].config =cpu_to_le32 (SDXC_IDMAC_DES0_CH | +SDXC_IDMAC_DES0_OWN | +SDXC_IDMAC_DES0_DIC );if (data->sg[i].length == max_len) pdes[i].buf_size =0 ;/* 0 == max_len */ else - pdes[i].buf_size = data->sg[i].length; + pdes[i].buf_size =cpu_to_le32 (data->sg[i].length); next_desc +=sizeof (struct sunxi_idma_des ); - pdes[i].buf_addr_ptr1 =sg_dma_address (&data->sg[i]); - pdes[i].buf_addr_ptr2 = (u32 )next_desc; + pdes[i].buf_addr_ptr1 = +cpu_to_le32 (sg_dma_address (&data->sg[i])); + pdes[i].buf_addr_ptr2 =cpu_to_le32 ((u32 )next_desc); } - pdes[0 ].config |=SDXC_IDMAC_DES0_FD ; - pdes[i -1 ].config |=SDXC_IDMAC_DES0_LD |SDXC_IDMAC_DES0_ER ; - pdes[i -1 ].config &= ~SDXC_IDMAC_DES0_DIC ; + pdes[0 ].config |=cpu_to_le32 (SDXC_IDMAC_DES0_FD ); + pdes[i -1 ].config |=cpu_to_le32 (SDXC_IDMAC_DES0_LD | +SDXC_IDMAC_DES0_ER ); + pdes[i -1 ].config &=cpu_to_le32 (~SDXC_IDMAC_DES0_DIC ); pdes[i -1 ].buf_addr_ptr2 =0 ;/*
Signature · 1 line
2.9.0
PATCH 1/3 mmc: sunxi-mmc: change idma descriptor to __le32
Quoted 11 lines · Michael Weiser
The sunxi-mmc driver does not take into account the processor may be big endian when writing the DMA descriptors. This causes cards not to be detected when running a big-endian kernel. Change the descriptors for IDMA to use
__le32and ensure they are suitably swapped before writing. Tested successfully on the Cubieboard2.Signed-off-by Michael Weiser <[email protected]>Cc Ulf Hansson <[email protected]>Cc Maxime Ripard <[email protected]>Cc Chen-Yu Tsai <[email protected]>Cc linux-mmc at vger.kernel.org
Thanks,
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160722/f4b399ca/attachment.sig>
PATCH v2 2/3 stmmac: change dma descriptors to __le32
In reply to Michael WeiserThe stmmac driver does not take into account the processor may be big endian when writing the DMA descriptors. This causes the ethernet interface not to be initialised correctly when running a big-endian kernel. Change the descriptors for DMA to use __le32 and ensure they are suitably swapped before writing. Tested successfully on the Cubieboard2.
--- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 55 ++++++++++---------- drivers/net/ethernet/stmicro/stmmac/descs.h | 20 ++++---- drivers/net/ethernet/stmicro/stmmac/descs_com.h | 48 +++++++++-------- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 60 +++++++++++----------- drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 55 ++++++++++---------- drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 48 ++++++++--------- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 39 +++++++------- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 53 ++++++++++--------- 8 files changed, 196 insertions(+), 182 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +29 -26
@@ -34,7 +34,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)unsigned int entry = priv->cur_tx;struct dma_desc *desc = priv->dma_tx + entry;unsigned int nopaged_len =skb_headlen (skb); -unsigned int bmax; +unsigned int bmax, des2;unsigned int i =1 , len;if (priv->plat->enh_desc)
@@ -44,11 +44,12 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) len = nopaged_len - bmax; - desc->des2 =dma_map_single (priv->device, skb->data, - bmax,DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, desc->des2)) + des2 =dma_map_single (priv->device, skb->data, + bmax,DMA_TO_DEVICE ); + desc->des2 =cpu_to_le32 (des2); +if (dma_mapping_error (priv->device, des2))return -1 ; - priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].buf = des2; priv->tx_skbuff_dma[entry].len = bmax;/* do not close the descriptor and do not set own bit */ priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE,
@@ -60,12 +61,13 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc = priv->dma_tx + entry;if (len > bmax) { - desc->des2 =dma_map_single (priv->device, - (skb->data + bmax * i), - bmax,DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, desc->des2)) + des2 =dma_map_single (priv->device, + (skb->data + bmax * i), + bmax,DMA_TO_DEVICE ); + desc->des2 =cpu_to_le32 (des2); +if (dma_mapping_error (priv->device, des2))return -1 ; - priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].buf = des2; priv->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum, STMMAC_CHAIN_MODE, 1,
@@ -73,12 +75,13 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) len -= bmax; i++; }else { - desc->des2 =dma_map_single (priv->device, - (skb->data + bmax * i), len, -DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, desc->des2)) + des2 =dma_map_single (priv->device, + (skb->data + bmax * i), len, +DMA_TO_DEVICE ); + desc->des2 =cpu_to_le32 (des2); +if (dma_mapping_error (priv->device, des2))return -1 ; - priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].buf = des2; priv->tx_skbuff_dma[entry].len = len;/* last descriptor can be set now */ priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
@@ -119,19 +122,19 @@ static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr,struct dma_extended_desc *p = (struct dma_extended_desc *)des;for (i =0 ; i < (size -1 ); i++) { dma_phy +=sizeof (struct dma_extended_desc ); - p->basic.des3 = (unsigned int )dma_phy; + p->basic.des3 =cpu_to_le32 ((unsigned int )dma_phy); p++; } - p->basic.des3 = (unsigned int )phy_addr; + p->basic.des3 =cpu_to_le32 ((unsigned int )phy_addr); }else {struct dma_desc *p = (struct dma_desc *)des;for (i =0 ; i < (size -1 ); i++) { dma_phy +=sizeof (struct dma_desc ); - p->des3 = (unsigned int )dma_phy; + p->des3 =cpu_to_le32 ((unsigned int )dma_phy); p++; } - p->des3 = (unsigned int )phy_addr; + p->des3 =cpu_to_le32 ((unsigned int )phy_addr); } }
@@ -144,10 +147,10 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)* 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = (unsigned int )(priv->dma_rx_phy + - (((priv->dirty_rx) +1 ) % -DMA_RX_SIZE ) * -sizeof (struct dma_desc )); + p->des3 =cpu_to_le32 ((unsigned int )(priv->dma_rx_phy + + (((priv->dirty_rx) +1 ) % +DMA_RX_SIZE ) * +sizeof (struct dma_desc ))); }static void stmmac_clean_desc3 (void *priv_ptr,struct dma_desc *p)
@@ -161,9 +164,9 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)* 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = (unsigned int )((priv->dma_tx_phy + - ((priv->dirty_tx +1 ) %DMA_TX_SIZE )) - *sizeof (struct dma_desc )); + p->des3 =cpu_to_le32 ((unsigned int )((priv->dma_tx_phy + + ((priv->dirty_tx +1 ) %DMA_TX_SIZE )) + *sizeof (struct dma_desc ))); }const struct stmmac_mode_ops chain_mode_ops = {
drivers/net/ethernet/stmicro/stmmac/descs.h +10 -10
@@ -87,7 +87,7 @@#define TDES0_ERROR_SUMMARY BIT(15)#define TDES0_IP_HEADER_ERROR BIT(16)#define TDES0_TIME_STAMP_STATUS BIT(17) -#define TDES0_OWN BIT(31) +#define TDES0_OWN ((u32)BIT(31))/* silence sparse */ /* TDES1 */ #define TDES1_BUFFER1_SIZE_MASK GENMASK(10, 0)#define TDES1_BUFFER2_SIZE_MASK GENMASK(21, 11)
@@ -130,7 +130,7 @@#define ETDES0_FIRST_SEGMENT BIT(28)#define ETDES0_LAST_SEGMENT BIT(29)#define ETDES0_INTERRUPT BIT(30) -#define ETDES0_OWN BIT(31) +#define ETDES0_OWN ((u32)BIT(31))/* silence sparse */ /* TDES1 */ #define ETDES1_BUFFER1_SIZE_MASK GENMASK(12, 0)#define ETDES1_BUFFER2_SIZE_MASK GENMASK(28, 16)
@@ -166,19 +166,19 @@/* Basic descriptor structure for normal and alternate descriptors */ struct dma_desc { -unsigned int des0; -unsigned int des1; -unsigned int des2; -unsigned int des3; +__le32 des0; +__le32 des1; +__le32 des2; +__le32 des3; };/* Extended descriptor structure (e.g. >= databook 3.50a) */ struct dma_extended_desc {struct dma_desc basic;/* Basic descriptors */ -unsigned int des4;/* Extended Status */ -unsigned int des5;/* Reserved */ -unsigned int des6;/* Tx/Rx Timestamp Low */ -unsigned int des7;/* Tx/Rx Timestamp High */ +__le32 des4;/* Extended Status */ +__le32 des5;/* Reserved */ +__le32 des6;/* Tx/Rx Timestamp Low */ +__le32 des7;/* Tx/Rx Timestamp High */ };/* Transmit checksum insertion control */
drivers/net/ethernet/stmicro/stmmac/descs_com.h +26 -22
115 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +31 -29
174 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +28 -27
164 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/norm_desc.c +25 -23
155 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +21 -18
@@ -34,7 +34,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)unsigned int entry = priv->cur_tx;struct dma_desc *desc;unsigned int nopaged_len =skb_headlen (skb); -unsigned int bmax, len; +unsigned int bmax, len, des2;if (priv->extend_desc) desc = (struct dma_desc *)(priv->dma_etx + entry);
@@ -50,16 +50,17 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)if (nopaged_len > BUF_SIZE_8KiB) { - desc->des2 =dma_map_single (priv->device, skb->data, - bmax,DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, desc->des2)) + des2 =dma_map_single (priv->device, skb->data, bmax, +DMA_TO_DEVICE ); + desc->des2 =cpu_to_le32 (des2); +if (dma_mapping_error (priv->device, des2))return -1 ; - priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].buf = des2; priv->tx_skbuff_dma[entry].len = bmax; priv->tx_skbuff_dma[entry].is_jumbo = true; - desc->des3 = desc->des2 + BUF_SIZE_4KiB; + desc->des3 =cpu_to_le32 (des2 + BUF_SIZE_4KiB); priv->hw->desc->prepare_tx_desc (desc,1 , bmax, csum,STMMAC_RING_MODE ,0 , false); priv->tx_skbuff[entry] =NULL ;
@@ -70,26 +71,28 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)else desc = priv->dma_tx + entry; - desc->des2 =dma_map_single (priv->device, skb->data + bmax, - len,DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, desc->des2)) + des2 =dma_map_single (priv->device, skb->data + bmax, len, +DMA_TO_DEVICE ); + desc->des2 =cpu_to_le32 (des2); +if (dma_mapping_error (priv->device, des2))return -1 ; - priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].buf = des2; priv->tx_skbuff_dma[entry].len = len; priv->tx_skbuff_dma[entry].is_jumbo = true; - desc->des3 = desc->des2 + BUF_SIZE_4KiB; + desc->des3 =cpu_to_le32 (des2 + BUF_SIZE_4KiB); priv->hw->desc->prepare_tx_desc (desc,0 , len, csum,STMMAC_RING_MODE ,1 , true); }else { - desc->des2 =dma_map_single (priv->device, skb->data, - nopaged_len,DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, desc->des2)) + des2 =dma_map_single (priv->device, skb->data, + nopaged_len,DMA_TO_DEVICE ); + desc->des2 =cpu_to_le32 (des2); +if (dma_mapping_error (priv->device, des2))return -1 ; - priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].buf = des2; priv->tx_skbuff_dma[entry].len = nopaged_len; priv->tx_skbuff_dma[entry].is_jumbo = true; - desc->des3 = desc->des2 + BUF_SIZE_4KiB; + desc->des3 =cpu_to_le32 (des2 + BUF_SIZE_4KiB); priv->hw->desc->prepare_tx_desc (desc,1 , nopaged_len, csum,STMMAC_RING_MODE ,0 , true); }
@@ -115,13 +118,13 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)/* Fill DES3 in case of RING mode */ if (priv->dma_buf_sz >= BUF_SIZE_8KiB) - p->des3 = p->des2 + BUF_SIZE_8KiB; + p->des3 =cpu_to_le32 (le32_to_cpu (p->des2) + BUF_SIZE_8KiB); }/* In ring mode we need to fill the desc3 because it is used as buffer */ static void stmmac_init_desc3 (struct dma_desc *p) { - p->des3 = p->des2 + BUF_SIZE_8KiB; + p->des3 =cpu_to_le32 (le32_to_cpu (p->des2) + BUF_SIZE_8KiB); }static void stmmac_clean_desc3 (void *priv_ptr,struct dma_desc *p)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +26 -27
112 lines not on this page · raw message
Signature · 1 line
2.9.0
Re: [PATCH 2/3] stmmac: change dma descriptors to __le32
Quoted 6 lines · Michael Weiser
The stmmac driver does not take into account the processor may be big endian when writing the DMA descriptors. This causes the ethernet interface not to be initialised correctly when running a big-endian kernel. Change the descriptors for DMA to use
__le32and ensure they are suitably swapped before writing. Tested successfully on the Cubieboard2.
Thx for the effort on big endian platform.
Quoted 6 lines
Signed-off-by Michael Weiser <[email protected]>Cc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>Cc netdev at vger.kernel.org---
...
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void sysfs_display_ring(void *head, int size, int extend_desc, · line 2883
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5
-3@@ -2880,14 +2876,17 @@ static void sysfs_display_ring(void *head, int size, int extend_desc, x = *(u64 *) ep;seq_printf (seq,"%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n" , i, (unsigned int )virt_to_phys (ep), - ep->basic.des0, ep->basic.des1, - ep->basic.des2, ep->basic.des3); - ep++; +le32_to_cpu (ep->basic.des0), +le32_to_cpu (ep->basic.des1), +le32_to_cpu (ep->basic.des2), +le32_to_cpu (ep->basic.des3)); + ep++);
there is a build problem here.
Pls fix it.
Peppe
Re: [PATCH 2/3] stmmac: change dma descriptors to __le32
Hi Giuseppe,
Quoted 4 lines · Giuseppe CAVALLARO
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void sysfs_display_ring(void *head, int size, int extend_desc, · line 2883
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1- ep++; + ep++);there is a build problem here.
Pls fix it.
Thanks for your review. I've got it fixed locally. An updated patchset will be forthcoming as soon as I've sorted a problem with sun4i-emac which I've been asked to look into as well.
Signature · 2 lines
Thanks, Michael
Re: [PATCH 2/3] stmmac: change dma descriptors to __le32
Quoted 4 lines · Michael Weiser
Hi Giuseppe,
On Tue, Jul 26, 2016 at 02:13:45PM +0200, Giuseppe CAVALLARO wrote:
Quoted 9 lines
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void sysfs_display_ring(void *head, int size, int extend_desc, · line 2883
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1- ep++; + ep++);there is a build problem here.
Pls fix it.Thanks for your review. I've got it fixed locally. An updated patchset will be forthcoming as soon as I've sorted a problem with sun4i-emac which I've been asked to look into as well.
ok, as you send the new version I will do a run on ARM box based too
peppe
PATCH v2 3/3 ARM: sunxi: enable big-endian
In reply to Michael WeiserAt least the Cubieboard2 incarnation of sunxi works correctly in big-endian mode. Allow the selection of big-endian.
--- arch/arm/mach-sunxi/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-sunxi/Kconfig +1 -0
@@ -1,6 +1,7 @@ menuconfig ARCH_SUNXI bool "Allwinner SoCs" depends on ARCH_MULTI_V7 + select ARCH_SUPPORTS_BIG_ENDIAN select ARCH_REQUIRE_GPIOLIB select ARCH_HAS_RESET_CONTROLLER select CLKSRC_MMIO
Signature · 1 line
2.9.0
PATCH 3/3 ARM: sunxi: enable big-endian
Hi,
Quoted 7 lines · Michael Weiser
At least the Cubieboard2 incarnation of sunxi works correctly in big-endian mode. Allow the selection of big-endian.
Signed-off-by Michael Weiser <[email protected]>Cc Maxime Ripard <[email protected]>Cc Chen-Yu Tsai <[email protected]>Cc linux-arm-kernel at lists.infradead.org
With what devices has it been tested? The one doing DMA will probably be the one who fail, have you tested the DMA engine? EMAC? GMAC?
Thanks,
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160722/0e68325a/attachment.sig>
PATCH v2 3/3 ARM: sunxi: enable big-endian
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Quoted 2 lines
At least the Cubieboard2 incarnation of sunxi works correctly in big-endian mode. Allow the selection of big-endian.
With what devices has it been tested? The one doing DMA will probably be the one who fail, have you tested the DMA engine? EMAC? GMAC?
I've tested with a Cubieboard2 Two-Card (on-board EMMC replaced with a second slot). I ran into and fixed DMA problems with stmmac (that's GMAC) and sunxi-mmc. Patches are submitted as part of this patchset. Endianness fixes to stmmac went much farther than just GMAC but remain untested since the Cubieboard2 only uses GMAC.
I have also successfully used SATA, SPI, UART, security system (with cryptodev), the hwmon part of the touchscreen controller, pinctrl with a custom interrupt pin via fdt for ethernet via SPI (ENC28J60), watchdog as reset controller, onboard RTC and external battery-backed DS1307 RTC via I2C. I have not deliberately/synthetically tested the DMA engine. It's enabled in the my kernel config and seems happy but was not selected by any other driver so seems to be unused currently.
I was reluctant to enable big endian support this generically but found no better way. Since board specifics are in device tree now, I can't really do a && CONFIG_MACH_CUBIEBOARD2 or somesuch. Or can I?
Signature · 2 lines
Thanks, Michael
PATCH 3/3 ARM: sunxi: enable big-endian
Quoted 15 lines · Michael Weiser
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Quoted 2 lines
At least the Cubieboard2 incarnation of sunxi works correctly in big-endian mode. Allow the selection of big-endian.
With what devices has it been tested? The one doing DMA will probably be the one who fail, have you tested the DMA engine? EMAC? GMAC?
I've tested with a Cubieboard2 Two-Card (on-board EMMC replaced with a second slot). I ran into and fixed DMA problems with stmmac (that's GMAC) and sunxi-mmc. Patches are submitted as part of this patchset. Endianness fixes to stmmac went much farther than just GMAC but remain untested since the Cubieboard2 only uses GMAC.
Quoted 7 lines
I have also successfully used SATA, SPI, UART, security system (with cryptodev), the hwmon part of the touchscreen controller, pinctrl with a custom interrupt pin via fdt for ethernet via SPI (ENC28J60), watchdog as reset controller, onboard RTC and external battery-backed DS1307 RTC via I2C. I have not deliberately/synthetically tested the DMA engine. It's enabled in the my kernel config and seems happy but was not selected by any other driver so seems to be unused currently.
You can test the DMA using the audio components, either the codec, i2s or spdif. EMAC would be worth testing too.
Quoted 3 lines
I was reluctant to enable big endian support this generically but found no better way. Since board specifics are in device tree now, I can't really do a &&
CONFIG_MACH_CUBIEBOARD2or somesuch. Or can I?
Not really, but it doesn't really matter, since all those drivers are at the SoC level and should affect all boards equally. And you have MACH_SUN7I :)
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160725/5783092e/attachment.sig>
PATCH v2 3/3 ARM: sunxi: enable big-endian
Hi Maxime,
Quoted 5 lines · Maxime Ripard
Quoted 3 lines
via I2C. I have not deliberately/synthetically tested the DMA engine. It's enabled in the my kernel config and seems happy but was not selected by any other driver so seems to be unused currently.
You can test the DMA using the audio components, either the codec, i2s or spdif.
I've enabled the codec and it's currently playing some King Khan to me.
PATCH 3/3 ARM: sunxi: enable big-endian
Quoted 15 lines · Michael Weiser
Hi Maxime,
Quoted 5 lines · Maxime Ripard
Quoted 3 lines
via I2C. I have not deliberately/synthetically tested the DMA engine. It's enabled in the my kernel config and seems happy but was not selected by any other driver so seems to be unused currently.
You can test the DMA using the audio components, either the codec, i2s or spdif.
I've enabled the codec and it's currently playing some King Khan to me. From looking at
sun4i-dma.cit seems that all communication with the silicon is via registers, including transfer of the DMA descriptors, and all is done using {read,write}l{,_relaxed} already.
Quoted 4 lines
Quoted 1 line
EMAC would be worth testing too.
As far as I gather, the Cubieboard2 does not route the EMAC pins anywhere. So I can't connect a PHY to it for testing.
The EMAC pins are muxed with the GMAC pins. All you need to do is disable the GMAC, enable the EMAC, and use emac_pins_a for the pinctrl.
ChenYu
PATCH v2 3/3 ARM: sunxi: enable big-endian
Hi ChenYu,
Quoted 4 lines · Chen-Yu Tsai
Quoted 2 lines
As far as I gather, the Cubieboard2 does not route the EMAC pins anywhere. So I can't connect a PHY to it for testing.
The EMAC pins are muxed with the GMAC pins. All you need to do is disable the GMAC, enable the EMAC, and use
emac_pins_afor the pinctrl.
Okay, I've done that by copying the relevant dts sections from sun4i-a10-cubieboard.dts. It initialises and transmits packets fine. But it doesn't seem to accept incoming packets. I suspect that programming of its own MAC address (which the driver chooses randomly) suffers from an endianness issue. I'm somewhat stumped as to what is causing it since all accesses use {read,write}l. Interrupt handling is another possible culprit. I'm still digging.
Signature · 2 lines
Thanks, Michael
PATCH 3/3 ARM: sunxi: enable big-endian
Hi,
Quoted 8 lines · Michael Weiser
Hi ChenYu,
Quoted 4 lines · Chen-Yu Tsai
Quoted 2 lines
As far as I gather, the Cubieboard2 does not route the EMAC pins anywhere. So I can't connect a PHY to it for testing.
The EMAC pins are muxed with the GMAC pins. All you need to do is disable the GMAC, enable the EMAC, and use
emac_pins_afor the pinctrl.
Quoted 7 lines
Okay, I've done that by copying the relevant dts sections from
sun4i-a10-cubieboard.dts. It initialises and transmits packets fine. But it doesn't seem to accept incoming packets. I suspect that programming of its own MAC address (which the driver chooses randomly) suffers from an endianness issue. I'm somewhat stumped as to what is causing it since all accesses use {read,write}l. Interrupt handling is another possible culprit. I'm still digging.
Maybe a good way to confirm that would be to generate outgoing traffic, dump that and see what the mac address is? If it's not programmed properly, you should see it in the packets.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160729/ba256feb/attachment-0001.sig>
PATCH v2 3/3 ARM: sunxi: enable big-endian
Hi Maxime,
Quoted 6 lines · Maxime Ripard
Quoted 3 lines
it doesn't seem to accept incoming packets. I suspect that programming of its own MAC address (which the driver chooses randomly) suffers from an endianness issue. I'm somewhat stumped as to what is causing it since
Maybe a good way to confirm that would be to generate outgoing traffic, dump that and see what the mac address is? If it's not programmed properly, you should see it in the packets.
That's what I've done: When trying to ping another machine, with tcpdump I see ARP requests coming from the cubieboard with the right MAC and I see the target machine sending ARP responses to the right MAC. But I do not see them coming in with tcpdump on the cubieboard.
The same process works fine with a little-endian kernel (same .config and dtb) and userland, so I'm sure it's an endianess issue somewhere.
I'll do some more comparison of little- and big-endian kernel behaviour and dig a bit deeper into the code.
Signature · 2 lines
Thanks, Michael