Skip to contentSkip to conversation

net: fec_mxc: add DM_FLAG_ACTIVE_DMA flag for FEC network driver

PATCH Superseded Meng Li 3 participants 3 messages Dec 20, 2024 – Dec 21, 2024 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Meng Li

author
#0 lore raw

PATCH 1/1 net: fec_mxc: add DM_FLAG_ACTIVE_DMA flag for FEC network driver

From: Meng Li <[email protected]>

When FEC network card works as the prime one in u-boot, and is in active status, kernel might crash during booting up stage, especially working with grub. Because the DMA of FEC is still in active status, and copy data into momey if there is network data received. In this case, if kernel allocated a part of memory that has overlay with the memory used by DMA, kernel memory may be destroyed and cause kernel crashes. Because before kernel boots up really, u-boot dm_remove_devices_flags() can call the remove callback of FEC driver with DM_FLAG_ACTIVE_DMA flag. In fecmxc_remove(), phy power is disabled, so there is no data received. In this way, it makes sure that there is no DMA action, so that avoid kernel crashing occurs.

---
 drivers/net/fec_mxc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/fec_mxc.c +1 -0
index 70eccfa8a4..07aff12b53 100644
@@ -1484,4 +1484,5 @@ U_BOOT_DRIVER(fecmxc_gem) = {
 	.ops	= &fecmxc_ops,
 	.priv_auto	= sizeof(struct fec_priv),
 	.plat_auto	= sizeof(struct eth_pdata),
+	.flags = DM_FLAG_ACTIVE_DMA,
 };
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines

Subject: [PATCH] net: fec_mxc: add DM_FLAG_ACTIVE_DMA flag for FEC network driver

From: Meng Li <[email protected]>

When FEC network card works as the prime one in u-boot, and is in active status, kernel might crash during booting up stage, especially working with grub. Because the DMA of FEC is still in active status, and copy data into momey if there is network data received. In this case, if kernel allocated a part of memory that has overlay with the memory used by DMA, kernel memory may be destroyed and cause kernel crashes.
Because before kernel boots up really, u-boot dm_remove_devices_flags() can call the remove callback of FEC driver with DM_FLAG_ACTIVE_DMA flag. In fecmxc_remove(), phy power is disabled, so there is no data received. In this way, it makes sure that there is no DMA action, so that avoid kernel crashing occurs.

Quoted 1 line

This looks good to me.

#2 lore raw
In reply to Meng Li
Quoted 7 lines · Meng Li

From: Meng Li <[email protected]>

When FEC network card works as the prime one in u-boot, and is in active status, kernel might crash during booting up stage, especially working with grub. Because the DMA of FEC is still in active status, and copy data into momey if there is network data received. In this case, if

There is a typo here at "momey".