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