mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org, Peter Mamonov <pmamonov@gmail.com>
Subject: Re: [RFC 4/5] net: rtl8169: make it work on big-endian system
Date: Fri, 28 Feb 2020 08:38:21 +0300	[thread overview]
Message-ID: <20200228083821.8c11f920b8f763e711088223@gmail.com> (raw)
In-Reply-To: <f6e8e0b8-4f7c-e4ae-7317-09cc1500343b@pengutronix.de>

On Tue, 4 Feb 2020 15:03:53 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:

> Hi Antony,
> 
> do you wont to resent this patches as not RFC?

It looks like some additional testing is necessary.

There is an alignment issue on MIPS.
We can't just pass cache line size unaligned address to dma_sync_single_for_device().
Some workaround is necessary, e.g.

--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -220,10 +220,10 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
 
        priv->tx_desc = dma_alloc_coherent(NUM_TX_DESC *
                                sizeof(struct bufdesc), &priv->tx_desc_phys);
-       priv->tx_buf = malloc(NUM_TX_DESC * PKT_BUF_SIZE);
+       priv->tx_buf = dma_alloc_coherent(NUM_TX_DESC * PKT_BUF_SIZE, DMA_ADDRESS_BROKEN);
        priv->rx_desc = dma_alloc_coherent(NUM_RX_DESC *
                                sizeof(struct bufdesc), &priv->rx_desc_phys);
-       priv->rx_buf = malloc(NUM_RX_DESC * PKT_BUF_SIZE);
+       priv->rx_buf = dma_alloc_coherent(NUM_RX_DESC * PKT_BUF_SIZE, DMA_ADDRESS_BROKEN);
        dma_sync_single_for_device((unsigned long)priv->rx_buf,
                                   NUM_RX_DESC * PKT_BUF_SIZE, DMA_FROM_DEVICE);

> 
> On 09.01.20 08:28, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> >   drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
> >   1 file changed, 17 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
> > index 80997dc89f..3762cb6354 100644
> > --- a/drivers/net/rtl8169.c
> > +++ b/drivers/net/rtl8169.c
> > @@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
> >   	for (i = 0; i < NUM_RX_DESC; i++) {
> >   		if (i == (NUM_RX_DESC - 1))
> >   			priv->rx_desc[i].status =
> > -				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
> > +				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
> >   		else
> >   			priv->rx_desc[i].status =
> > -				BD_STAT_OWN | PKT_BUF_SIZE;
> > +				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
> >   
> >   		priv->rx_desc[i].buf_addr =
> > -				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
> > +				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
> >   	}
> >   }
> >   
> > @@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
> >   
> >   	priv->tx_desc[entry].buf_Haddr = 0;
> >   	priv->tx_desc[entry].buf_addr =
> > -		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
> > +		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
> >   
> >   	if (entry != (NUM_TX_DESC - 1)) {
> >   		priv->tx_desc[entry].status =
> > -			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
> > -			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
> > +			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
> > +			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
> >   	} else {
> >   		priv->tx_desc[entry].status =
> > -			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
> > -			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
> > +			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
> > +			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
> >   	}
> >   
> >   	RTL_W8(priv, TxPoll, 0x40);
> >   
> > -	while (priv->tx_desc[entry].status & BD_STAT_OWN)
> > +	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
> >   		;
> >   
> >   	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
> > @@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
> >   
> >   	entry = priv->cur_rx % NUM_RX_DESC;
> >   
> > -	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
> > -		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
> > -			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
> > +	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
> > +		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
> > +			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
> >   
> >   			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
> >   						+ entry * PKT_BUF_SIZE,
> > @@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
> >   						   pkt_size, DMA_FROM_DEVICE);
> >   
> >   			if (entry == NUM_RX_DESC - 1)
> > -				priv->rx_desc[entry].status = BD_STAT_OWN |
> > -					BD_STAT_EOR | PKT_BUF_SIZE;
> > +				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
> > +					BD_STAT_EOR | PKT_BUF_SIZE);
> >   			else
> >   				priv->rx_desc[entry].status =
> > -					BD_STAT_OWN | PKT_BUF_SIZE;
> > +					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
> >   			priv->rx_desc[entry].buf_addr =
> > -				virt_to_phys(priv->rx_buf +
> > -				             entry * PKT_BUF_SIZE);
> > +				cpu_to_le32(virt_to_phys(priv->rx_buf +
> > +				             entry * PKT_BUF_SIZE));
> >   		} else {
> >   			dev_err(&edev->dev, "rx error\n");
> >   		}
> > 
> 
> Kind regards,
> Oleksij Rempel
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-02-28  5:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09  7:28 [RFC 0/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
2020-01-09  7:28 ` [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU Antony Pavlov
2020-01-13  6:48   ` Oleksij Rempel
2020-01-09  7:28 ` [RFC 2/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
2020-01-13  8:26   ` Oleksij Rempel
2020-01-14 21:03     ` Antony Pavlov
2020-01-09  7:28 ` [RFC 3/5] net: e1000: make it work on MIPS Antony Pavlov
2020-01-13  7:29   ` Oleksij Rempel
2020-01-13 19:06     ` Lucas Stach
2020-01-09  7:28 ` [RFC 4/5] net: rtl8169: make it work on big-endian system Antony Pavlov
2020-01-13  7:21   ` Oleksij Rempel
2020-02-04 14:03   ` Oleksij Rempel
2020-02-09  6:30     ` Antony Pavlov
2020-02-09  8:17       ` Oleksij Rempel
2020-02-28  5:38     ` Antony Pavlov [this message]
2020-01-09  7:28 ` [RFC 5/5] MIPS: qemu-malta_defconfig: enable e1000 network driver Antony Pavlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200228083821.8c11f920b8f763e711088223@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pmamonov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox