From patchwork Thu Mar 15 14:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 131794 Delivered-To: patch@linaro.org Received: by 10.80.210.197 with SMTP id q5csp1522280edg; Thu, 15 Mar 2018 07:07:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELvAcVl+iOiyCEm9g/XmxRaEbA2xnDc7pKsfSz+Of0iRBbLmyAfml+n5cKPIeoqecHv7e2nB X-Received: by 10.80.216.2 with SMTP id o2mr9203432edj.208.1521122842286; Thu, 15 Mar 2018 07:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521122842; cv=none; d=google.com; s=arc-20160816; b=CLN2EPztmBEfckoj5coAFI5vNPOwQYTbaXuqYqkDUrTks84BWRfXR9W1aI6pqTBrRB +pOfBH5RyJA8EB+vZw/7C6tzEW5gMLDgdF6QLPaz9fkPx1qYBXqY8e8HbkvynoHbZrxq XyUF6phJMlddjUdQpoTHomKz6dCp96KDsnUNs26cmq00VIFvtXXRyS/PoqSVOhxx5Oeg AX9taCzwBmdgm6giLZDBCwtE55Lc9vDQERWTj/OwNDjiNQySFU56is8ed60vsd+dyP5w kuFuEloKss/pQgufWETkjPtzJXwqaPy3zT3QC2UeFcne3mvE2n2GAFXMtZMELlWgBDPD HF1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :arc-authentication-results; bh=usl5fmlU6nqukAp3e1ME9pGHYxbRwRLJB3fXvV1Fu1Q=; b=GN8Kql3vXPoZT5Ye6E5ZiluDHcol9F1Xw50qE+Az5F7U8ja37MPP2ql+KZTjZOCYjK vx98lLXwP6ggbi0V30674Rtfs4STEwzu6sIjpdkUrVUk3rFskcLRg59ZoMEc6O0PauML 27NxA5c4+li2TsgCnCUTpZFbfU7oQL4w0ughds+37aoAovIvF6EkLKfbkqiKHRR3zI/h hSkzrSiku9jgtrZvvZPumV4Y+zTMt29Juujrc9KBNFwOjcYVdSipEbxRmGgSE4Yqcreh dy/y9XzoNT1/UNC3jY1A7+BnUqrmTp5bCPmI5IFCenSQ/9HFeLpJj5wHlhKTmsuzviaq bq8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id y17si647276edc.117.2018.03.15.07.07.17; Thu, 15 Mar 2018 07:07:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 8F326C21DED; Thu, 15 Mar 2018 14:07:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C344BC21C2F; Thu, 15 Mar 2018 14:07:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 58B8BC21C2F; Thu, 15 Mar 2018 14:07:11 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 0AAFBC21C29 for ; Thu, 15 Mar 2018 14:07:11 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7BB76AFFF; Thu, 15 Mar 2018 14:07:10 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Thu, 15 Mar 2018 15:07:09 +0100 Message-Id: <20180315140709.10346-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Joe Hershberger Subject: [U-Boot] [PATCH] net: Only access network devices after init X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Acked-by: Joe Hershberger --- net/eth-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 */