]> TLD Linux GIT Repositories - packages/grub2.git/blob - efi-net-fix.patch
- fix initrd-search patch
[packages/grub2.git] / efi-net-fix.patch
1 From 886d93184b894a29b0bef1f2467230a20c7a33ce Mon Sep 17 00:00:00 2001
2 From: Mark Salter <msalter@redhat.com>
3 Date: Tue, 8 Apr 2014 10:58:11 -0400
4 Subject: [PATCH] reopen SNP protocol for exclusive use by grub
5
6 While working with pxeboot of grub on an ARM platform, I noticed
7 very poor network performance while grub was loading a kernel
8 and initramfs. The performance during the loading of grub itself
9 seemed reasonable. Digging into the issue, I found that the UEFI
10 firmware was periodically polling for network packets while grub
11 was downloading files. This was causing timeouts and retries in
12 the grub network stack.
13
14 The solution I found was to reopen the SNP protocol for exclusive
15 use. This forces UEFI to shutdown its use of SNP so that grub is
16 not competing for incoming packets.
17
18 Signed-off-by: Mark Salter <msalter@redhat.com>
19 ---
20  grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++++
21  1 file changed, 16 insertions(+)
22
23 diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
24 index 2b344d6..a6e4c79 100644
25 --- a/grub-core/net/drivers/efi/efinet.c
26 +++ b/grub-core/net/drivers/efi/efinet.c
27 @@ -223,6 +223,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
28  {
29    struct grub_net_card *card;
30    grub_efi_device_path_t *dp;
31 +  grub_efi_simple_network_t *net;
32  
33    dp = grub_efi_get_device_path (hnd);
34    if (! dp)
35 @@ -250,6 +251,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
36                                     &pxe_mode->dhcp_ack,
37                                     sizeof (pxe_mode->dhcp_ack),
38                                     1, device, path);
39 +    net = grub_efi_open_protocol (card->efi_handle, &net_io_guid,
40 +                                 GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE);
41 +    if (net) {
42 +      if (net->mode->state == GRUB_EFI_NETWORK_STOPPED
43 +         && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS)
44 +       continue;
45 +
46 +      if (net->mode->state == GRUB_EFI_NETWORK_STOPPED)
47 +       continue;
48 +
49 +      if (net->mode->state == GRUB_EFI_NETWORK_STARTED
50 +         && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS)
51 +       continue;
52 +      card->efi_net = net;
53 +    }
54      return;
55    }
56  }
57 -- 
58 1.8.5.3
59