nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0158-efinet-Check-for-immediate-completition.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Martin Wilck <martin.wilck@ts.fujitsu.com>
4fe85b
Date: Fri, 27 Mar 2015 14:27:56 +0100
4fe85b
Subject: [PATCH] efinet: Check for immediate completition.
4fe85b
4fe85b
This both speeds GRUB up and workarounds unexpected EFI behaviour.
4fe85b
---
4fe85b
 grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++--
4fe85b
 1 file changed, 14 insertions(+), 2 deletions(-)
4fe85b
4fe85b
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
4fe85b
index a6e4c7992f7..78df215be12 100644
4fe85b
--- a/grub-core/net/drivers/efi/efinet.c
4fe85b
+++ b/grub-core/net/drivers/efi/efinet.c
4fe85b
@@ -37,11 +37,12 @@ send_card_buffer (struct grub_net_card *dev,
4fe85b
   grub_efi_status_t st;
4fe85b
   grub_efi_simple_network_t *net = dev->efi_net;
4fe85b
   grub_uint64_t limit_time = grub_get_time_ms () + 4000;
4fe85b
+  void *txbuf;
4fe85b
 
4fe85b
   if (dev->txbusy)
4fe85b
     while (1)
4fe85b
       {
4fe85b
-	void *txbuf = NULL;
4fe85b
+	txbuf = NULL;
4fe85b
 	st = efi_call_3 (net->get_status, net, 0, &txbuf);
4fe85b
 	if (st != GRUB_EFI_SUCCESS)
4fe85b
 	  return grub_error (GRUB_ERR_IO,
4fe85b
@@ -74,7 +75,18 @@ send_card_buffer (struct grub_net_card *dev,
4fe85b
 		   dev->txbuf, NULL, NULL, NULL);
4fe85b
   if (st != GRUB_EFI_SUCCESS)
4fe85b
     return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
4fe85b
-  dev->txbusy = 1;
4fe85b
+
4fe85b
+  /*
4fe85b
+     The card may have sent out the packet immediately - set txbusy
4fe85b
+     to 0 in this case.
4fe85b
+     Cases were observed where checking txbuf at the next call
4fe85b
+     of send_card_buffer() is too late: 0 is returned in txbuf and
4fe85b
+     we run in the GRUB_ERR_TIMEOUT case above.
4fe85b
+     Perhaps a timeout in the FW has discarded the recycle buffer.
4fe85b
+   */
4fe85b
+  st = efi_call_3 (net->get_status, net, 0, &txbuf);
4fe85b
+  dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf == dev->txbuf);
4fe85b
+
4fe85b
   return GRUB_ERR_NONE;
4fe85b
 }
4fe85b