[U-Boot] [PATCH v3 1/2] net: designware: fix descriptor layout and warnings on 64-bit archs

Marek Vasut
2016-04-10T23:59:59Z

On 04/10/2016 05:30 PM, Beniamino Galvani wrote:
> All members of the DMA descriptor must be 32-bit, even on 64-bit
> architectures: change the type to u32 to ensure this. Also, fix
> other warnings.
>
> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> drivers/net/designware.c | 54 ++++++++++++++++++++++++------------------------
> drivers/net/designware.h | 4 ++--
> 2 files changed, 29 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/designware.c b/drivers/net/designware.c
> index ca58f34..78d6901 100644
> --- a/drivers/net/designware.c
> +++ b/drivers/net/designware.c
> @@ -98,8 +98,8 @@ static void tx_descs_init(struct dw_eth_dev *priv)
>
> for (idx = 0; idx < CONFIG_TX_DESCR_NUM; idx++) {
> desc_p = &desc_table_p[idx];
> - desc_p->dmamac_addr = &txbuffs[idx * CONFIG_ETH_BUFSIZE];
> - desc_p->dmamac_next = &desc_table_p[idx + 1];
> + desc_p->dmamac_addr = (ulong)&txbuffs[idx * CONFIG_ETH_BUFSIZE];
> + desc_p->dmamac_next = (ulong)&desc_table_p[idx + 1];

This looks more like silencing the warning by a forced cast.
The pointer should most likely be sanity-checked to make sure it's in
4GiB address space at least. I am worried such forced casts will bite
us in the long run.

> #if defined(CONFIG_DW_ALTDESCRIPTOR)
> desc_p->txrx_status &= ~(DESC_TXSTS_TXINT | DESC_TXSTS_TXLAST |
> @@ -117,11 +117,11 @@ static void tx_descs_init(struct dw_eth_dev *priv)
> }
>
> /* Correcting the last pointer of the chain */
> - desc_p->dmamac_next = &desc_table_p[0];
> + desc_p->dmamac_next = (ulong)&desc_table_p[0];
>
> /* Flush all Tx buffer descriptors at once */
> - flush_dcache_range((unsigned int)priv->tx_mac_descrtable,
> - (unsigned int)priv->tx_mac_descrtable +
> + flush_dcache_range((ulong)priv->tx_mac_descrtable,
> + (ulong)priv->tx_mac_descrtable +
> sizeof(priv->tx_mac_descrtable));
>
> writel((ulong)&desc_table_p[0], &dma_p->txdesclistaddr);
[...]

Best regards,
Marek Vasut