Re: [PATCH 1/1] macb: fix gem_recv circular buffer handling

2013-03-14 Thread Jean-Christophe PLAGNIOL-VILLARD
On 20:13 Wed 13 Mar , Steffen Trumtrar wrote:
> On Wed, Mar 13, 2013 at 04:39:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
> wrote:
> > as we use a full buffer no need to check the SOF
> > and reset the rx_tail
> > 
> > fix at the same time the gem detection so we can have the rx_buffer
> > allocated correctly according to the IP
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
Sascah
> > ---
> >  drivers/net/macb.c |   32 
> >  1 file changed, 16 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> > index 0cfad05..2d4e373 100644
> > --- a/drivers/net/macb.c
> > +++ b/drivers/net/macb.c
> > @@ -172,7 +172,6 @@ static void reclaim_rx_buffers(struct macb_device *macb,
> >  static int gem_recv(struct eth_device *edev)
> >  {
> > struct macb_device *macb = edev->priv;
> > -   unsigned int rx_tail = macb->rx_tail;
> > void *buffer;
> > int length;
> > u32 status;
> > @@ -181,20 +180,20 @@ static int gem_recv(struct eth_device *edev)
> >  
> > for (;;) {
> > barrier();
> > -   if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED)))
> > +   if (!(macb->rx_ring[macb->rx_tail].addr & MACB_BIT(RX_USED)))
> > return -1;
> >  
> > barrier();
> > -   status = macb->rx_ring[rx_tail].ctrl;
> > +   status = macb->rx_ring[macb->rx_tail].ctrl;
> > length = MACB_BFEXT(RX_FRMLEN, status);
> > -   if (status & MACB_BIT(RX_SOF)) {
> > -   buffer = macb->rx_buffer + macb->rx_buffer_size * 
> > macb->rx_tail;
> > -   net_receive(buffer, length);
> > -   macb->rx_ring[rx_tail].ctrl &= ~MACB_BIT(RX_USED);
> > -   barrier();
> > -   }
> > -   rx_tail++;
> > +   buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
> > +   net_receive(buffer, length);
> > +   macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED);
> > +   barrier();
> > +
> > macb->rx_tail++;
> > +   if (macb->rx_tail >= macb->rx_ring_size)
> > +   macb->rx_tail = 0;
> > }
> >  
> > return 0;
> > @@ -619,11 +618,6 @@ static int macb_probe(struct device_d *dev)
> >  
> > macb->phy_flags = pdata->phy_flags;
> >  
> > -   macb_init_rx_buffer_size(macb, PKTSIZE);
> > -   macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * 
> > macb->rx_ring_size);
> > -   macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
> > -   macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
> > -
> > macb->regs = dev_request_mem_region(dev, 0);
> >  
> > /*
> > @@ -638,11 +632,17 @@ static int macb_probe(struct device_d *dev)
> >  
> > clk_enable(macb->pclk);
> >  
> > +   macb->is_gem = read_is_gem(macb);
> > +
> > if (macb_is_gem(macb))
> > edev->recv = gem_recv;
> > else
> > edev->recv = macb_recv;
> > -   macb->is_gem = read_is_gem(macb);
> > +
> > +   macb_init_rx_buffer_size(macb, PKTSIZE);
> > +   macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * 
> > macb->rx_ring_size);
> > +   macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
> > +   macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
> >  
> > macb_reset_hw(macb);
> > ncfgr = macb_mdc_clk_div(macb);
> 
> I know that the last part is not a very sophisticated patch, but you could at 
> least
> mention that I found the error and/or made part of this patch. Don't just
> pretend that you came up with this all alone.
sorry just did the diff between both tree and forget to add the Report-by
Sasha can you add it while applying?

Best Regards,
J.
> 
> Regards,
> Steffen
> 
> -- 
> 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- |

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


Re: [PATCH 1/1] macb: fix gem_recv circular buffer handling

2013-03-13 Thread Steffen Trumtrar
On Wed, Mar 13, 2013 at 04:39:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> as we use a full buffer no need to check the SOF
> and reset the rx_tail
> 
> fix at the same time the gem detection so we can have the rx_buffer
> allocated correctly according to the IP
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> ---
>  drivers/net/macb.c |   32 
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 0cfad05..2d4e373 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -172,7 +172,6 @@ static void reclaim_rx_buffers(struct macb_device *macb,
>  static int gem_recv(struct eth_device *edev)
>  {
>   struct macb_device *macb = edev->priv;
> - unsigned int rx_tail = macb->rx_tail;
>   void *buffer;
>   int length;
>   u32 status;
> @@ -181,20 +180,20 @@ static int gem_recv(struct eth_device *edev)
>  
>   for (;;) {
>   barrier();
> - if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED)))
> + if (!(macb->rx_ring[macb->rx_tail].addr & MACB_BIT(RX_USED)))
>   return -1;
>  
>   barrier();
> - status = macb->rx_ring[rx_tail].ctrl;
> + status = macb->rx_ring[macb->rx_tail].ctrl;
>   length = MACB_BFEXT(RX_FRMLEN, status);
> - if (status & MACB_BIT(RX_SOF)) {
> - buffer = macb->rx_buffer + macb->rx_buffer_size * 
> macb->rx_tail;
> - net_receive(buffer, length);
> - macb->rx_ring[rx_tail].ctrl &= ~MACB_BIT(RX_USED);
> - barrier();
> - }
> - rx_tail++;
> + buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
> + net_receive(buffer, length);
> + macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED);
> + barrier();
> +
>   macb->rx_tail++;
> + if (macb->rx_tail >= macb->rx_ring_size)
> + macb->rx_tail = 0;
>   }
>  
>   return 0;
> @@ -619,11 +618,6 @@ static int macb_probe(struct device_d *dev)
>  
>   macb->phy_flags = pdata->phy_flags;
>  
> - macb_init_rx_buffer_size(macb, PKTSIZE);
> - macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * 
> macb->rx_ring_size);
> - macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
> - macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
> -
>   macb->regs = dev_request_mem_region(dev, 0);
>  
>   /*
> @@ -638,11 +632,17 @@ static int macb_probe(struct device_d *dev)
>  
>   clk_enable(macb->pclk);
>  
> + macb->is_gem = read_is_gem(macb);
> +
>   if (macb_is_gem(macb))
>   edev->recv = gem_recv;
>   else
>   edev->recv = macb_recv;
> - macb->is_gem = read_is_gem(macb);
> +
> + macb_init_rx_buffer_size(macb, PKTSIZE);
> + macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * 
> macb->rx_ring_size);
> + macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
> + macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
>  
>   macb_reset_hw(macb);
>   ncfgr = macb_mdc_clk_div(macb);

I know that the last part is not a very sophisticated patch, but you could at 
least
mention that I found the error and/or made part of this patch. Don't just
pretend that you came up with this all alone.

Regards,
Steffen

-- 
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- |

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


[PATCH 1/1] macb: fix gem_recv circular buffer handling

2013-03-13 Thread Jean-Christophe PLAGNIOL-VILLARD
as we use a full buffer no need to check the SOF
and reset the rx_tail

fix at the same time the gem detection so we can have the rx_buffer
allocated correctly according to the IP

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 drivers/net/macb.c |   32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0cfad05..2d4e373 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -172,7 +172,6 @@ static void reclaim_rx_buffers(struct macb_device *macb,
 static int gem_recv(struct eth_device *edev)
 {
struct macb_device *macb = edev->priv;
-   unsigned int rx_tail = macb->rx_tail;
void *buffer;
int length;
u32 status;
@@ -181,20 +180,20 @@ static int gem_recv(struct eth_device *edev)
 
for (;;) {
barrier();
-   if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED)))
+   if (!(macb->rx_ring[macb->rx_tail].addr & MACB_BIT(RX_USED)))
return -1;
 
barrier();
-   status = macb->rx_ring[rx_tail].ctrl;
+   status = macb->rx_ring[macb->rx_tail].ctrl;
length = MACB_BFEXT(RX_FRMLEN, status);
-   if (status & MACB_BIT(RX_SOF)) {
-   buffer = macb->rx_buffer + macb->rx_buffer_size * 
macb->rx_tail;
-   net_receive(buffer, length);
-   macb->rx_ring[rx_tail].ctrl &= ~MACB_BIT(RX_USED);
-   barrier();
-   }
-   rx_tail++;
+   buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
+   net_receive(buffer, length);
+   macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED);
+   barrier();
+
macb->rx_tail++;
+   if (macb->rx_tail >= macb->rx_ring_size)
+   macb->rx_tail = 0;
}
 
return 0;
@@ -619,11 +618,6 @@ static int macb_probe(struct device_d *dev)
 
macb->phy_flags = pdata->phy_flags;
 
-   macb_init_rx_buffer_size(macb, PKTSIZE);
-   macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * 
macb->rx_ring_size);
-   macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
-   macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
-
macb->regs = dev_request_mem_region(dev, 0);
 
/*
@@ -638,11 +632,17 @@ static int macb_probe(struct device_d *dev)
 
clk_enable(macb->pclk);
 
+   macb->is_gem = read_is_gem(macb);
+
if (macb_is_gem(macb))
edev->recv = gem_recv;
else
edev->recv = macb_recv;
-   macb->is_gem = read_is_gem(macb);
+
+   macb_init_rx_buffer_size(macb, PKTSIZE);
+   macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * 
macb->rx_ring_size);
+   macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
+   macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
 
macb_reset_hw(macb);
ncfgr = macb_mdc_clk_div(macb);
-- 
1.7.10.4


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