Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D25BC433EF for ; Tue, 14 Sep 2021 02:07:00 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4360160EFE for ; Tue, 14 Sep 2021 02:06:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4360160EFE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B4BE8340F; Tue, 14 Sep 2021 04:06:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="R2o7RFsL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 191938341B; Tue, 14 Sep 2021 04:06:53 +0200 (CEST) Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9CA678340D for ; Tue, 14 Sep 2021 04:06:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pj1-x1035.google.com with SMTP id mi6-20020a17090b4b4600b00199280a31cbso1122955pjb.0 for ; Mon, 13 Sep 2021 19:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=OJbc88TRawxqjytNiL5zIgd7kYCAVXDS8q/cRSpwSHA=; b=R2o7RFsLoWGMxh+G3JlYXbWPGJQYVbIeqq7m8KTj/RXtaRY3qPcmLcvOutqW+Pe3Gt kBhrEPWjDhK0q+/bVV7DTbzD80eWGLIbQ5i1yXsC1S9sELCHghM4m5s6vw3c2tCD0q2B bJ+0I1A2W6QBvMsTP0AqhWc1ZOatJwLBDK4ROvQZaDTJAvySabo1qmgZ9Ggk/2iIwBhn wc2zhYhpqQpZdtJJsXc83GNSHQhLvyFaVqLROphoeX+TbPvBo8VskG2BCLKVGAbTLXKs ggzz0XMFc4s1TjyV7vbKQWB8H46MlDecLTMoieeK3Wpr1ltbPjX1dz75oGb21h6Gd47/ TPyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=OJbc88TRawxqjytNiL5zIgd7kYCAVXDS8q/cRSpwSHA=; b=zL/g5E0lKhBXsObGjkYTv9nsxuCWmIkLh/32uHmVg+1D9zm0ENEfHOzK+PSGXHjyrx wgRj7RFwj1ihwZ8g6n+NRUwOV+g+8Z+T9uSAMHQUTjjQQcBDNpNzEbO1TehlTHHAoZAC 7MOZ9yTIU3DYigm6aV2ysBHaZBKt3PKhufF0exfEERpV2U0wFavJosD1KwU+IIGwbCqx nSc2crlon1zIPtJtlcmGVsHahQh0rIYxqkkR3kS+O1LaZs1636GVCk3cOMJBDVVrgJ+N JAMP0c85M4wQwSyuwkl6zigGpGjKYI22s1RuQLiP12F8+680efXQ8Yas+SpeTnlmBYEr PtDg== X-Gm-Message-State: AOAM533YqLw9pvxOPstucQJ/2gc0gRZ73aL1g+RalMDBksVInGcxGGqc J8BmoIJPegkDWMkhjO8gPewN7g== X-Google-Smtp-Source: ABdhPJyBK5fmeKV6e+suc2QUyylyDcWEeVmYZ+wCS39hvCDI7O5xAX5oP3G4vv3qOJNxUQTv3HbTiQ== X-Received: by 2002:a17:90a:b881:: with SMTP id o1mr2743923pjr.141.1631585207819; Mon, 13 Sep 2021 19:06:47 -0700 (PDT) Received: from localhost.localdomain (122x208x150x49.ap122.ftth.ucom.ne.jp. [122.208.150.49]) by smtp.gmail.com with ESMTPSA id u12sm9376903pgi.21.2021.09.13.19.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 19:06:47 -0700 (PDT) From: Masami Hiramatsu To: Heinrich Schuchardt Cc: Kazuhiko Sakamoto , Masami Hiramatsu , Jassi Brar , Ilias Apalodimas , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Set EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT again in efi_net_receive() Date: Tue, 14 Sep 2021 11:06:44 +0900 Message-Id: <163158520452.224107.7330406153367961192.stgit@localhost> X-Mailer: git-send-email 2.25.1 User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Kazuhiko Sakamoto Since 'this->int_status' is cleared by efi_net_get_status(), if user does wait_for_event(wait_for_packet) and efi_net_get_status() loop and there are several received packets on the buffer, the second efi_net_get_status() does not return EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT even if the 'wait_for_packet' is ready. This happens on "efiboot selftest" with noisy network. (The network device can receive both of other packets and dhcp discover packet in a short time.) Set EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT again when we found any packet still on the receive buffer. Signed-off-by: Kazuhiko Sakamoto Signed-off-by: Masami Hiramatsu --- lib/efi_loader/efi_net.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 69276b275d..9ca1e0c354 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -640,10 +640,19 @@ static efi_status_t EFIAPI efi_net_receive *buffer_size = receive_lengths[rx_packet_idx]; rx_packet_idx = (rx_packet_idx + 1) % ETH_PACKETS_BATCH_RECV; rx_packet_num--; - if (rx_packet_num) + if (rx_packet_num) { + /* + * Since 'this->int_status' is cleared by efi_net_get_status(), + * if user does wait_for_event(wait_for_packet) and + * efi_net_get_status() again, EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT + * is not set even if 'wait_for_packet' is ready. + * Set EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT again here. + */ + this->int_status |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; wait_for_packet->is_signaled = true; - else + } else { this->int_status &= ~EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; + } out: return EFI_EXIT(ret); }