diff mbox series

net: Only access network devices after init

Message ID 20180315140709.10346-1-agraf@suse.de
State Accepted
Commit a532e2f2e52277635fac79cdbe4e6b5b51166de4
Headers show
Series net: Only access network devices after init | expand

Commit Message

Alexander Graf March 15, 2018, 2:07 p.m. UTC
In the efi_loader main loop we call eth_rx() occasionally. This rx function
might end up calling into devices that haven't been initialized yet,
potentially resulting in a lot of transfer timeouts.

Instead, let's make sure the ethernet device is actually initialized before
reading from or writing to it.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 net/eth-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joe Hershberger March 15, 2018, 6:57 p.m. UTC | #1
On Thu, Mar 15, 2018 at 9:07 AM, Alexander Graf <agraf@suse.de> wrote:
> In the efi_loader main loop we call eth_rx() occasionally. This rx function
> might end up calling into devices that haven't been initialized yet,
> potentially resulting in a lot of transfer timeouts.
>
> Instead, let's make sure the ethernet device is actually initialized before
> reading from or writing to it.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger March 26, 2018, 7:26 p.m. UTC | #2
Hi Alexander,

https://patchwork.ozlabs.org/patch/886255/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index d30b04ba86..240b596534 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -336,7 +336,7 @@  int eth_send(void *packet, int length)
 	if (!current)
 		return -ENODEV;
 
-	if (!device_active(current))
+	if (!eth_is_active(current))
 		return -EINVAL;
 
 	ret = eth_get_ops(current)->send(current, packet, length);
@@ -359,7 +359,7 @@  int eth_rx(void)
 	if (!current)
 		return -ENODEV;
 
-	if (!device_active(current))
+	if (!eth_is_active(current))
 		return -EINVAL;
 
 	/* Process up to 32 packets at one time */