From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Sun, 17 Apr 2016 11:56:58 +0200 Subject: [U-Boot] [PATCH v4 1/3] net: designware: fix descriptor layout and warnings on 64-bit archs In-Reply-To: <1460879338-7671-2-git-send-email-b.galvani@gmail.com> References: <1460879338-7671-1-git-send-email-b.galvani@gmail.com> <1460879338-7671-2-git-send-email-b.galvani@gmail.com> Message-ID: <57135DEA.4000609@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 04/17/2016 09:48 AM, 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 > --- > drivers/net/designware.c | 59 ++++++++++++++++++++++++++---------------------- > drivers/net/designware.h | 4 ++-- > 2 files changed, 34 insertions(+), 29 deletions(-) > > diff --git a/drivers/net/designware.c b/drivers/net/designware.c > index ca58f34..2eda461 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]; Why don't you use u32 instead of ulong ? The u32 is well defined. DTTO all over the place. btw just curious, but what will happen if the descriptors get allocated in area above 4GiB ? Will the code silently corrupt memory by discarding the top bits in the descriptor pointer? [...] > diff --git a/drivers/net/designware.h b/drivers/net/designware.h > index ed6344c..d48df7b 100644 > --- a/drivers/net/designware.h > +++ b/drivers/net/designware.h > @@ -110,8 +110,8 @@ struct eth_dma_regs { > struct dmamacdescr { > u32 txrx_status; > u32 dmamac_cntl; > - void *dmamac_addr; > - struct dmamacdescr *dmamac_next; > + u32 dmamac_addr; > + u32 dmamac_next; > } __aligned(ARCH_DMA_MINALIGN); > > /* > -- Best regards, Marek Vasut