diff mbox series

[edk2,v3,3/3] MdeModulePkg/SerialDxe: Do not fail reset when SetAttributes is not supported

Message ID 20171129172823.2906-4-julien.grall@linaro.org
State New
Headers show
Series MdeModulePkg/SerialDxe: Do not fail reset when SetAttributes is not supported | expand

Commit Message

Julien Grall Nov. 29, 2017, 5:28 p.m. UTC
After commit 91cc526b15 "MdeModulePkg/SerialDxe: Fix not able to change
serial attributes", serial is initialized using the reset method that
will call SetAttributes.

However, SetAttributes may return EFI_INVALID_PARAMETER when a driver
does not support some parameters. This will be propagated by the reset
function and lead to UEFI failing to get the console setup.

For instance, this is the case when using the Xen console driver.

Fix it by introspecting the result and return EFI_SUCCESS when the
SetAttributes report an invalid parameter (i.e EFI_INVALID_PARAMETER).

Contributed-under: Tianocore Contribution Agreement 1.1
Signed-off-by: Julien Grall <julien.grall@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>


---
    Changes in v3:
        - Add Star reviewed-by
        - Fix typoes in the commit message
---
 MdeModulePkg/Universal/SerialDxe/SerialIo.c | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.11.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
index ee10ec7e05..e18cc7ed51 100644
--- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c
+++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
@@ -240,6 +240,15 @@  SerialReset (
                    (EFI_STOP_BITS_TYPE) This->Mode->StopBits
                    );
 
+  //
+  // The serial device may not support some of the attributes. To prevent
+  // later failure, always return EFI_SUCCESS when SetAttributes is returning
+  // EFI_INVALID_PARAMETER.
+  //
+  if (Status == EFI_INVALID_PARAMETER) {
+    return EFI_SUCCESS;
+  }
+
   return Status;
 }