grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: grub-devel@gnu.org, arvidjaar@gmail.com, phcoder@gmail.com
Cc: Josef Bacik <jbacik@fb.com>
Subject: [PATCH V2] efinet: handle get_status() on buggy firmware properly
Date: Thu,  6 Aug 2015 10:49:46 -0700	[thread overview]
Message-ID: <1438883386-3043513-1-git-send-email-jbacik@fb.com> (raw)
In-Reply-To: <1438799799-32097-1-git-send-email-jbacik@fb.com>

The EFI spec indicates that get_status() should return the address of the buffer
we passed into transmit to indicate the the buffer was transmitted.  However we
have boxes where the firmware returns some arbitrary address instead, which
makes grub think that we've not sent anything.  So since we have the SNP stuff
opened in exclusive mode just assume any non-NULL txbuf means that our transmit
occurred properly.  This makes grub able to do its networking stuff properly on
our broken firmware.  Thanks,

cc: Peter Jones <pjones@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
V1->V2:
-updated the changelog to be more clear about what we are fixing.
-added a comment to the code to indicate why it is safe to only check for
 non-NULL txbufs and why we need to do it.

 grub-core/net/drivers/efi/efinet.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index f27a117..692d5ad 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -47,19 +47,19 @@ send_card_buffer (struct grub_net_card *dev,
 	if (st != GRUB_EFI_SUCCESS)
 	  return grub_error (GRUB_ERR_IO,
 			     N_("couldn't send network packet"));
-	if (txbuf == dev->txbuf)
+	/*
+	   Some buggy firmware could return an arbitrary address instead of the
+	   txbuf address we trasmitted, so just check that txbuf is non NULL
+	   for success.  This is ok because we open the SNP protocol in
+	   exclusive mode so we know we're the only ones transmitting on this
+	   box and since we only transmit one packet at a time we know our
+	   transmit was successfull.
+	 */
+	if (txbuf)
 	  {
 	    dev->txbusy = 0;
 	    break;
 	  }
-	if (txbuf)
-	  {
-	    st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size,
-			     dev->txbuf, NULL, NULL, NULL);
-	    if (st != GRUB_EFI_SUCCESS)
-	      return grub_error (GRUB_ERR_IO,
-				 N_("couldn't send network packet"));
-	  }
 	if (limit_time < grub_get_time_ms ())
 	  return grub_error (GRUB_ERR_TIMEOUT,
 			     N_("couldn't send network packet"));
@@ -84,8 +84,9 @@ send_card_buffer (struct grub_net_card *dev,
      we run in the GRUB_ERR_TIMEOUT case above.
      Perhaps a timeout in the FW has discarded the recycle buffer.
    */
+  txbuf = NULL;
   st = efi_call_3 (net->get_status, net, 0, &txbuf);
-  dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf == dev->txbuf);
+  dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf);
 
   return GRUB_ERR_NONE;
 }
-- 
1.8.1



  parent reply	other threads:[~2015-08-06 17:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05 18:36 [PATCH 1/3] efinet: handle get_status() properly Josef Bacik
2015-08-05 18:36 ` [PATCH 2/3] net: add local route when creating link local ipv6 interface Josef Bacik
2015-08-07  8:38   ` Andrei Borzenkov
2015-08-05 18:36 ` [PATCH 3/3] net: fix ipv6 routing Josef Bacik
2015-08-09 14:58   ` Andrei Borzenkov
2015-08-10 14:00     ` Josef Bacik
2015-08-10 14:07       ` Andrei Borzenkov
2015-08-05 20:04 ` [PATCH 1/3] efinet: handle get_status() properly Andrei Borzenkov
2015-08-05 20:26   ` Josef Bacik
2015-08-05 20:32     ` Vladimir 'phcoder' Serbinenko
2015-08-05 20:39       ` Josef Bacik
2015-08-05 20:50         ` Josef Bacik
2015-08-05 20:52           ` Vladimir 'phcoder' Serbinenko
2015-08-06  3:42       ` Andrei Borzenkov
2015-08-06 14:26         ` Josef Bacik
2015-08-05 20:57     ` Seth Goldberg
2015-08-06 17:49 ` Josef Bacik [this message]
2015-08-09 13:48   ` [PATCH V2] efinet: handle get_status() on buggy firmware properly Andrei Borzenkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438883386-3043513-1-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.com \
    --cc=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).