All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv
@ 2018-03-10  1:19 Peng Fan
  2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Peng Fan @ 2018-03-10  1:19 UTC (permalink / raw)
  To: u-boot

From: Ye Li <ye.li@nxp.com>

When using ethernet DM driver, the recv interface has a
change with non-DM interface, that driver needs to set
the packet pointer and provide it to upper layer to process.

In fec driver, the fecmxc_recv functions does not handle the
packet pointer parameter. This may cause crash in upper layer
processing because the packet pointer is not set.

This patch allocates a buffer for the packet pointer and free it
through free_pkt interface.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/net/fec_mxc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index ff7ad91116..7c396d8d95 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -806,7 +806,16 @@ static int fec_recv(struct eth_device *dev)
 	uint16_t bd_status;
 	ulong addr, size, end;
 	int i;
+
+#ifdef CONFIG_DM_ETH
+	*packetp = memalign(ARCH_DMA_MINALIGN, FEC_MAX_PKT_SIZE);
+	if (*packetp == 0) {
+		printf("%s: error allocating packetp\n", __func__);
+		return -ENOMEM;
+	}
+#else
 	ALLOC_CACHE_ALIGN_BUFFER(uchar, buff, FEC_MAX_PKT_SIZE);
+#endif
 
 	/* Check if any critical events have happened */
 	ievent = readl(&fec->eth->ievent);
@@ -882,8 +891,13 @@ static int fec_recv(struct eth_device *dev)
 #ifdef CONFIG_FEC_MXC_SWAP_PACKET
 			swap_packet((uint32_t *)addr, frame_length);
 #endif
+
+#ifdef CONFIG_DM_ETH
+			memcpy(*packetp, (char *)addr, frame_length);
+#else
 			memcpy(buff, (char *)addr, frame_length);
 			net_process_received_packet(buff, frame_length);
+#endif
 			len = frame_length;
 		} else {
 			if (bd_status & FEC_RBD_ERR)
@@ -917,6 +931,16 @@ static int fec_recv(struct eth_device *dev)
 	return len;
 }
 
+static int fecmxc_free_pkt(struct udevice *dev, uchar *packet, int length)
+{
+#ifdef CONFIG_DM_ETH
+	if (packet)
+		free(packet);
+#endif
+
+	return 0;
+}
+
 static void fec_set_dev_name(char *dest, int dev_id)
 {
 	sprintf(dest, (dev_id == -1) ? "FEC" : "FEC%i", dev_id);
@@ -1205,6 +1229,7 @@ static const struct eth_ops fecmxc_ops = {
 	.start			= fecmxc_init,
 	.send			= fecmxc_send,
 	.recv			= fecmxc_recv,
+	.free_pkt		= fecmxc_free_pkt,
 	.stop			= fecmxc_halt,
 	.write_hwaddr		= fecmxc_set_hwaddr,
 	.read_rom_hwaddr	= fecmxc_read_rom_hwaddr,
-- 
2.14.1

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

end of thread, other threads:[~2018-03-21 19:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
2018-03-19 21:18   ` Joe Hershberger
2018-03-20  8:49   ` Lothar Waßmann
2018-03-20  9:29     ` Peng Fan
2018-03-21 19:13       ` Joe Hershberger
2018-03-21 19:20         ` Joe Hershberger
2018-03-10  1:19 ` [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id Peng Fan
2018-03-19 21:19   ` Joe Hershberger
2018-03-10  1:19 ` [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers Peng Fan
2018-03-19 21:21   ` Joe Hershberger
2018-03-20  8:51   ` Lothar Waßmann
2018-03-21  1:59     ` Peng Fan
2018-03-10  1:19 ` [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible Peng Fan
2018-03-19 21:21   ` Joe Hershberger
2018-03-19 21:17 ` [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Joe Hershberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.