mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] net: macb: no need for coherent memory for receive buffer
@ 2018-11-02  7:26 Sascha Hauer
  2018-11-02  7:26 ` [PATCH 2/4] net: macb: remove unused variable Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-11-02  7:26 UTC (permalink / raw)
  To: Barebox List

The receive buffers are properly synchronized with dma_sync_*, no need
to use coherent memory for them.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/macb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 7721bcb56a..8575c838a8 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -697,8 +697,7 @@ static int macb_probe(struct device_d *dev)
 		edev->recv = macb_recv;
 
 	macb_init_rx_buffer_size(macb, PKTSIZE);
-	macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size,
-					     DMA_ADDRESS_BROKEN);
+	macb->rx_buffer = dma_alloc(macb->rx_buffer_size * macb->rx_ring_size);
 	macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb), DMA_ADDRESS_BROKEN);
 	macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES, DMA_ADDRESS_BROKEN);
 
-- 
2.19.1


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] net: macb: remove unused variable
  2018-11-02  7:26 [PATCH 1/4] net: macb: no need for coherent memory for receive buffer Sascha Hauer
@ 2018-11-02  7:26 ` Sascha Hauer
  2018-11-02  7:26 ` [PATCH 3/4] net: macb: simplify private data allocation Sascha Hauer
  2018-11-02  7:26 ` [PATCH 4/4] net: macb: add remove callback Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-11-02  7:26 UTC (permalink / raw)
  To: Barebox List

tx_tail is unused. Remove it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/macb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 8575c838a8..28065e1e13 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -65,7 +65,6 @@ struct macb_device {
 
 	unsigned int		rx_tail;
 	unsigned int		tx_head;
-	unsigned int		tx_tail;
 
 	void			*rx_buffer;
 	void			*tx_buffer;
@@ -344,7 +343,7 @@ static void macb_init(struct macb_device *macb)
 	}
 	macb->tx_ring[TX_RING_SIZE - 1].addr |= MACB_BIT(TX_WRAP);
 
-	macb->rx_tail = macb->tx_head = macb->tx_tail = 0;
+	macb->rx_tail = macb->tx_head = 0;
 
 	macb_configure_dma(macb);
 
-- 
2.19.1


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] net: macb: simplify private data allocation
  2018-11-02  7:26 [PATCH 1/4] net: macb: no need for coherent memory for receive buffer Sascha Hauer
  2018-11-02  7:26 ` [PATCH 2/4] net: macb: remove unused variable Sascha Hauer
@ 2018-11-02  7:26 ` Sascha Hauer
  2018-11-02  7:26 ` [PATCH 4/4] net: macb: add remove callback Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-11-02  7:26 UTC (permalink / raw)
  To: Barebox List

Instead of allocating struct macb_device and a struct eth_device
separately just use the eth_device structure that is already embedded
in struct macb_device but currently unused.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/macb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 28065e1e13..fe192f9bf4 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -618,9 +618,10 @@ static int macb_probe(struct device_d *dev)
 	const char *pclk_name;
 	u32 ncfgr;
 
-	edev = xzalloc(sizeof(struct eth_device) + sizeof(struct macb_device));
-	edev->priv = (struct macb_device *)(edev + 1);
-	macb = edev->priv;
+	macb = xzalloc(sizeof(*macb));
+	edev = &macb->netdev;
+	edev->priv = macb;
+	dev->priv = macb;
 
 	macb->dev = dev;
 
-- 
2.19.1


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] net: macb: add remove callback
  2018-11-02  7:26 [PATCH 1/4] net: macb: no need for coherent memory for receive buffer Sascha Hauer
  2018-11-02  7:26 ` [PATCH 2/4] net: macb: remove unused variable Sascha Hauer
  2018-11-02  7:26 ` [PATCH 3/4] net: macb: simplify private data allocation Sascha Hauer
@ 2018-11-02  7:26 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-11-02  7:26 UTC (permalink / raw)
  To: Barebox List

The macb driver does DMA and thus should be quiesced on shutdown. Add
the remove callback.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/macb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index fe192f9bf4..b2957b7d29 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -719,6 +719,13 @@ static int macb_probe(struct device_d *dev)
 	return 0;
 }
 
+static void macb_remove(struct device_d *dev)
+{
+	struct macb_device *macb = dev->priv;
+
+	macb_halt(&macb->netdev);
+}
+
 static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,at91sam9260-macb",},
 	{ /* sentinel */ }
@@ -727,6 +734,7 @@ static const struct of_device_id macb_dt_ids[] = {
 static struct driver_d macb_driver = {
 	.name  = "macb",
 	.probe = macb_probe,
+	.remove = macb_remove,
 	.of_compatible = DRV_OF_COMPAT(macb_dt_ids),
 };
 device_platform_driver(macb_driver);
-- 
2.19.1


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-02  7:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02  7:26 [PATCH 1/4] net: macb: no need for coherent memory for receive buffer Sascha Hauer
2018-11-02  7:26 ` [PATCH 2/4] net: macb: remove unused variable Sascha Hauer
2018-11-02  7:26 ` [PATCH 3/4] net: macb: simplify private data allocation Sascha Hauer
2018-11-02  7:26 ` [PATCH 4/4] net: macb: add remove callback Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox