* MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead @ 2017-07-17 4:23 Heyi Guo 2017-07-18 8:13 ` Heyi Guo 2017-07-18 8:39 ` Zeng, Star 0 siblings, 2 replies; 8+ messages in thread From: Heyi Guo @ 2017-07-17 4:23 UTC (permalink / raw) To: edk2-devel@lists.01.org Hi Folks, In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, it seems the timeout processing in SerialRead is not consistent. Since SerialPortPoll only checks the status of serial port and returns immediately, and SerialPortRead does not really implement a time out mechanism and will always wait for enough input, it will cause below results: 1. If there is no serial input at all, this interface will return timeout immediately without any waiting; 2. If there is A characters in serial port FIFO, and caller requires A+1 characters, it will wait until a new input is coming and timeout will not really occur. As SerialPortLib is a simple library implementation, I think it is better to improve SerialIoDxe driver instead of SerialPortLib. Please let me know your comments about this. Thanks and regards, Gary (Heyi Guo) EFI_STATUS EFIAPI SerialRead ( IN EFI_SERIAL_IO_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer ) { UINTN Count; Count = 0; if (SerialPortPoll ()) { Count = SerialPortRead (Buffer, *BufferSize); } if (Count != *BufferSize) { *BufferSize = Count; return EFI_TIMEOUT; } return EFI_SUCCESS; } ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-07-17 4:23 MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead Heyi Guo @ 2017-07-18 8:13 ` Heyi Guo 2017-07-18 8:39 ` Zeng, Star 1 sibling, 0 replies; 8+ messages in thread From: Heyi Guo @ 2017-07-18 8:13 UTC (permalink / raw) To: edk2-devel@lists.01.org; +Cc: star.zeng, eric.dong +cc maintainers :) 在 7/17/2017 12:23 PM, Heyi Guo 写道: > Hi Folks, > > In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, > it seems the timeout processing in SerialRead is not consistent. > > Since SerialPortPoll only checks the status of serial port and returns > immediately, and SerialPortRead does not really implement a time out > mechanism and will always wait for enough input, it will cause below > results: > > 1. If there is no serial input at all, this interface will return > timeout immediately without any waiting; > > 2. If there is A characters in serial port FIFO, and caller requires > A+1 characters, it will wait until a new input is coming and timeout > will not really occur. > > As SerialPortLib is a simple library implementation, I think it is > better to improve SerialIoDxe driver instead of SerialPortLib. > > Please let me know your comments about this. > > Thanks and regards, > > Gary (Heyi Guo) > > EFI_STATUS > EFIAPI > SerialRead ( > IN EFI_SERIAL_IO_PROTOCOL *This, > IN OUT UINTN *BufferSize, > OUT VOID *Buffer > ) > { > UINTN Count; > > Count = 0; > > if (SerialPortPoll ()) { > Count = SerialPortRead (Buffer, *BufferSize); > } > > if (Count != *BufferSize) { > *BufferSize = Count; > return EFI_TIMEOUT; > } > > return EFI_SUCCESS; > } > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-07-17 4:23 MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead Heyi Guo 2017-07-18 8:13 ` Heyi Guo @ 2017-07-18 8:39 ` Zeng, Star 2017-07-18 8:58 ` Ni, Ruiyu 2017-07-18 10:59 ` Heyi Guo 1 sibling, 2 replies; 8+ messages in thread From: Zeng, Star @ 2017-07-18 8:39 UTC (permalink / raw) To: Heyi Guo, edk2-devel@lists.01.org, Ni, Ruiyu, Laszlo Ersek (lersek@redhat.com) Cc: Zeng, Star Gary, SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. If let SerialDxe to handle the TimeOut, seemingly it can only check SerialPortPoll() and read data by SerialPortRead() one byte by one byte, for example like below. Do you have any proposed patch? Ray and Laszlo, Do you have any comments? ==================== debf0d1b85e7a30defd29838abb20a44dd9ec69b MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Universal/SerialDxe/SerialIo.c index d2383e56dd8f..b05603d7f3b5 100644 --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c @@ -465,11 +465,25 @@ SerialRead ( ) { UINTN Count; + UINTN TimeOut; Count = 0; - if (SerialPortPoll ()) { - Count = SerialPortRead (Buffer, *BufferSize); + while (Count < *BufferSize) { + TimeOut = 0; + while (TimeOut < mSerialIoMode.TimeOut) { + if (SerialPortPoll ()) { + break; + } + gBS->Stall (10); + TimeOut += 10; + } + if (TimeOut >= mSerialIoMode.TimeOut) { + break; + } + SerialPortRead (Buffer, 1); + Count++; + Buffer = (VOID *) ((UINT8 *) Buffer + 1); } if (Count != *BufferSize) { ==================== Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Heyi Guo Sent: Monday, July 17, 2017 12:23 PM To: edk2-devel@lists.01.org Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead Hi Folks, In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, it seems the timeout processing in SerialRead is not consistent. Since SerialPortPoll only checks the status of serial port and returns immediately, and SerialPortRead does not really implement a time out mechanism and will always wait for enough input, it will cause below results: 1. If there is no serial input at all, this interface will return timeout immediately without any waiting; 2. If there is A characters in serial port FIFO, and caller requires A+1 characters, it will wait until a new input is coming and timeout will not really occur. As SerialPortLib is a simple library implementation, I think it is better to improve SerialIoDxe driver instead of SerialPortLib. Please let me know your comments about this. Thanks and regards, Gary (Heyi Guo) EFI_STATUS EFIAPI SerialRead ( IN EFI_SERIAL_IO_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer ) { UINTN Count; Count = 0; if (SerialPortPoll ()) { Count = SerialPortRead (Buffer, *BufferSize); } if (Count != *BufferSize) { *BufferSize = Count; return EFI_TIMEOUT; } return EFI_SUCCESS; } _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-07-18 8:39 ` Zeng, Star @ 2017-07-18 8:58 ` Ni, Ruiyu 2017-07-18 10:59 ` Heyi Guo 1 sibling, 0 replies; 8+ messages in thread From: Ni, Ruiyu @ 2017-07-18 8:58 UTC (permalink / raw) To: Zeng, Star, Heyi Guo, edk2-devel@lists.01.org, Laszlo Ersek (lersek@redhat.com) Star, Your change looks good. Thanks/Ray > -----Original Message----- > From: Zeng, Star > Sent: Tuesday, July 18, 2017 4:39 PM > To: Heyi Guo <heyi.guo@linaro.org>; edk2-devel@lists.01.org; Ni, Ruiyu > <ruiyu.ni@intel.com>; Laszlo Ersek (lersek@redhat.com) > <lersek@redhat.com> > Cc: Zeng, Star <star.zeng@intel.com> > Subject: RE: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout > processing in SerialRead > > Gary, > SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. > If let SerialDxe to handle the TimeOut, seemingly it can only check > SerialPortPoll() and read data by SerialPortRead() one byte by one byte, for > example like below. > Do you have any proposed patch? > > Ray and Laszlo, > Do you have any comments? > > > ==================== > debf0d1b85e7a30defd29838abb20a44dd9ec69b > MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c > b/MdeModulePkg/Universal/SerialDxe/SerialIo.c > index d2383e56dd8f..b05603d7f3b5 100644 > --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c > +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c > @@ -465,11 +465,25 @@ SerialRead ( > ) > { > UINTN Count; > + UINTN TimeOut; > > Count = 0; > > - if (SerialPortPoll ()) { > - Count = SerialPortRead (Buffer, *BufferSize); > + while (Count < *BufferSize) { > + TimeOut = 0; > + while (TimeOut < mSerialIoMode.TimeOut) { > + if (SerialPortPoll ()) { > + break; > + } > + gBS->Stall (10); > + TimeOut += 10; > + } > + if (TimeOut >= mSerialIoMode.TimeOut) { > + break; > + } > + SerialPortRead (Buffer, 1); > + Count++; > + Buffer = (VOID *) ((UINT8 *) Buffer + 1); > } > > if (Count != *BufferSize) { > ==================== > > > Thanks, > Star > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Heyi Guo > Sent: Monday, July 17, 2017 12:23 PM > To: edk2-devel@lists.01.org > Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout processing > in SerialRead > > Hi Folks, > > In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, > it seems the timeout processing in SerialRead is not consistent. > > Since SerialPortPoll only checks the status of serial port and returns > immediately, and SerialPortRead does not really implement a time out > mechanism and will always wait for enough input, it will cause below > results: > > 1. If there is no serial input at all, this interface will return timeout > immediately without any waiting; > > 2. If there is A characters in serial port FIFO, and caller requires A+1 > characters, it will wait until a new input is coming and timeout will not really > occur. > > As SerialPortLib is a simple library implementation, I think it is better to > improve SerialIoDxe driver instead of SerialPortLib. > > Please let me know your comments about this. > > Thanks and regards, > > Gary (Heyi Guo) > > EFI_STATUS > EFIAPI > SerialRead ( > IN EFI_SERIAL_IO_PROTOCOL *This, > IN OUT UINTN *BufferSize, > OUT VOID *Buffer > ) > { > UINTN Count; > > Count = 0; > > if (SerialPortPoll ()) { > Count = SerialPortRead (Buffer, *BufferSize); > } > > if (Count != *BufferSize) { > *BufferSize = Count; > return EFI_TIMEOUT; > } > > return EFI_SUCCESS; > } > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-07-18 8:39 ` Zeng, Star 2017-07-18 8:58 ` Ni, Ruiyu @ 2017-07-18 10:59 ` Heyi Guo 2017-08-04 8:02 ` Heyi Guo 1 sibling, 1 reply; 8+ messages in thread From: Heyi Guo @ 2017-07-18 10:59 UTC (permalink / raw) To: Zeng, Star, edk2-devel@lists.01.org, Ni, Ruiyu, Laszlo Ersek (lersek@redhat.com) Hi Star, I think your proposed patch is fine. Thanks. Gary (Heyi Guo) 在 7/18/2017 4:39 PM, Zeng, Star 写道: > Gary, > SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. > If let SerialDxe to handle the TimeOut, seemingly it can only check SerialPortPoll() and read data by SerialPortRead() one byte by one byte, for example like below. > Do you have any proposed patch? > > Ray and Laszlo, > Do you have any comments? > > > ==================== > debf0d1b85e7a30defd29838abb20a44dd9ec69b > MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Universal/SerialDxe/SerialIo.c > index d2383e56dd8f..b05603d7f3b5 100644 > --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c > +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c > @@ -465,11 +465,25 @@ SerialRead ( > ) > { > UINTN Count; > + UINTN TimeOut; > > Count = 0; > > - if (SerialPortPoll ()) { > - Count = SerialPortRead (Buffer, *BufferSize); > + while (Count < *BufferSize) { > + TimeOut = 0; > + while (TimeOut < mSerialIoMode.TimeOut) { > + if (SerialPortPoll ()) { > + break; > + } > + gBS->Stall (10); > + TimeOut += 10; > + } > + if (TimeOut >= mSerialIoMode.TimeOut) { > + break; > + } > + SerialPortRead (Buffer, 1); > + Count++; > + Buffer = (VOID *) ((UINT8 *) Buffer + 1); > } > > if (Count != *BufferSize) { > ==================== > > > Thanks, > Star > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Heyi Guo > Sent: Monday, July 17, 2017 12:23 PM > To: edk2-devel@lists.01.org > Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead > > Hi Folks, > > In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, > it seems the timeout processing in SerialRead is not consistent. > > Since SerialPortPoll only checks the status of serial port and returns immediately, and SerialPortRead does not really implement a time out mechanism and will always wait for enough input, it will cause below > results: > > 1. If there is no serial input at all, this interface will return timeout immediately without any waiting; > > 2. If there is A characters in serial port FIFO, and caller requires A+1 characters, it will wait until a new input is coming and timeout will not really occur. > > As SerialPortLib is a simple library implementation, I think it is better to improve SerialIoDxe driver instead of SerialPortLib. > > Please let me know your comments about this. > > Thanks and regards, > > Gary (Heyi Guo) > > EFI_STATUS > EFIAPI > SerialRead ( > IN EFI_SERIAL_IO_PROTOCOL *This, > IN OUT UINTN *BufferSize, > OUT VOID *Buffer > ) > { > UINTN Count; > > Count = 0; > > if (SerialPortPoll ()) { > Count = SerialPortRead (Buffer, *BufferSize); > } > > if (Count != *BufferSize) { > *BufferSize = Count; > return EFI_TIMEOUT; > } > > return EFI_SUCCESS; > } > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-07-18 10:59 ` Heyi Guo @ 2017-08-04 8:02 ` Heyi Guo 2017-08-04 8:05 ` Zeng, Star 0 siblings, 1 reply; 8+ messages in thread From: Heyi Guo @ 2017-08-04 8:02 UTC (permalink / raw) To: Zeng, Star, edk2-devel@lists.01.org, Ni, Ruiyu, Laszlo Ersek (lersek@redhat.com) Hi Star, The patch works well on our platform. Would you merge it to EDK2 main stream or do you like me to post it to the mailing-list? Thanks and regards, Gary (Heyi Guo) 在 7/18/2017 6:59 PM, Heyi Guo 写道: > Hi Star, > > I think your proposed patch is fine. > > Thanks. > > Gary (Heyi Guo) > > > 在 7/18/2017 4:39 PM, Zeng, Star 写道: >> Gary, >> SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. >> If let SerialDxe to handle the TimeOut, seemingly it can only check >> SerialPortPoll() and read data by SerialPortRead() one byte by one >> byte, for example like below. >> Do you have any proposed patch? >> >> Ray and Laszlo, >> Do you have any comments? >> >> >> ==================== >> debf0d1b85e7a30defd29838abb20a44dd9ec69b >> MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- >> 1 file changed, 16 insertions(+), 2 deletions(-) >> >> diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> index d2383e56dd8f..b05603d7f3b5 100644 >> --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> @@ -465,11 +465,25 @@ SerialRead ( >> ) >> { >> UINTN Count; >> + UINTN TimeOut; >> Count = 0; >> - if (SerialPortPoll ()) { >> - Count = SerialPortRead (Buffer, *BufferSize); >> + while (Count < *BufferSize) { >> + TimeOut = 0; >> + while (TimeOut < mSerialIoMode.TimeOut) { >> + if (SerialPortPoll ()) { >> + break; >> + } >> + gBS->Stall (10); >> + TimeOut += 10; >> + } >> + if (TimeOut >= mSerialIoMode.TimeOut) { >> + break; >> + } >> + SerialPortRead (Buffer, 1); >> + Count++; >> + Buffer = (VOID *) ((UINT8 *) Buffer + 1); >> } >> if (Count != *BufferSize) { >> ==================== >> >> >> Thanks, >> Star >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf >> Of Heyi Guo >> Sent: Monday, July 17, 2017 12:23 PM >> To: edk2-devel@lists.01.org >> Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout >> processing in SerialRead >> >> Hi Folks, >> >> In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, >> it seems the timeout processing in SerialRead is not consistent. >> >> Since SerialPortPoll only checks the status of serial port and >> returns immediately, and SerialPortRead does not really implement a >> time out mechanism and will always wait for enough input, it will >> cause below >> results: >> >> 1. If there is no serial input at all, this interface will return >> timeout immediately without any waiting; >> >> 2. If there is A characters in serial port FIFO, and caller requires >> A+1 characters, it will wait until a new input is coming and timeout >> will not really occur. >> >> As SerialPortLib is a simple library implementation, I think it is >> better to improve SerialIoDxe driver instead of SerialPortLib. >> >> Please let me know your comments about this. >> >> Thanks and regards, >> >> Gary (Heyi Guo) >> >> EFI_STATUS >> EFIAPI >> SerialRead ( >> IN EFI_SERIAL_IO_PROTOCOL *This, >> IN OUT UINTN *BufferSize, >> OUT VOID *Buffer >> ) >> { >> UINTN Count; >> >> Count = 0; >> >> if (SerialPortPoll ()) { >> Count = SerialPortRead (Buffer, *BufferSize); >> } >> >> if (Count != *BufferSize) { >> *BufferSize = Count; >> return EFI_TIMEOUT; >> } >> >> return EFI_SUCCESS; >> } >> >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-08-04 8:02 ` Heyi Guo @ 2017-08-04 8:05 ` Zeng, Star 2017-08-04 8:08 ` Heyi Guo 0 siblings, 1 reply; 8+ messages in thread From: Zeng, Star @ 2017-08-04 8:05 UTC (permalink / raw) To: Heyi Guo, edk2-devel@lists.01.org, Ni, Ruiyu, Laszlo Ersek (lersek@redhat.com) Cc: Zeng, Star Oh, sorry, I forgot it because of busying on other things. I will post it soon. Thanks for your reminder. Star -----Original Message----- From: Heyi Guo [mailto:heyi.guo@linaro.org] Sent: Friday, August 4, 2017 4:03 PM To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org; Ni, Ruiyu <ruiyu.ni@intel.com>; Laszlo Ersek (lersek@redhat.com) <lersek@redhat.com> Subject: Re: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead Hi Star, The patch works well on our platform. Would you merge it to EDK2 main stream or do you like me to post it to the mailing-list? Thanks and regards, Gary (Heyi Guo) 在 7/18/2017 6:59 PM, Heyi Guo 写道: > Hi Star, > > I think your proposed patch is fine. > > Thanks. > > Gary (Heyi Guo) > > > 在 7/18/2017 4:39 PM, Zeng, Star 写道: >> Gary, >> SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. >> If let SerialDxe to handle the TimeOut, seemingly it can only check >> SerialPortPoll() and read data by SerialPortRead() one byte by one >> byte, for example like below. >> Do you have any proposed patch? >> >> Ray and Laszlo, >> Do you have any comments? >> >> >> ==================== >> debf0d1b85e7a30defd29838abb20a44dd9ec69b >> MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- >> 1 file changed, 16 insertions(+), 2 deletions(-) >> >> diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> index d2383e56dd8f..b05603d7f3b5 100644 >> --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >> @@ -465,11 +465,25 @@ SerialRead ( >> ) >> { >> UINTN Count; >> + UINTN TimeOut; >> Count = 0; >> - if (SerialPortPoll ()) { >> - Count = SerialPortRead (Buffer, *BufferSize); >> + while (Count < *BufferSize) { >> + TimeOut = 0; >> + while (TimeOut < mSerialIoMode.TimeOut) { >> + if (SerialPortPoll ()) { >> + break; >> + } >> + gBS->Stall (10); >> + TimeOut += 10; >> + } >> + if (TimeOut >= mSerialIoMode.TimeOut) { >> + break; >> + } >> + SerialPortRead (Buffer, 1); >> + Count++; >> + Buffer = (VOID *) ((UINT8 *) Buffer + 1); >> } >> if (Count != *BufferSize) { >> ==================== >> >> >> Thanks, >> Star >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf >> Of Heyi Guo >> Sent: Monday, July 17, 2017 12:23 PM >> To: edk2-devel@lists.01.org >> Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout >> processing in SerialRead >> >> Hi Folks, >> >> In SerialRead function in >> MdeModulePkg/Universal/SerialDxe/SerialIo.c, >> it seems the timeout processing in SerialRead is not consistent. >> >> Since SerialPortPoll only checks the status of serial port and >> returns immediately, and SerialPortRead does not really implement a >> time out mechanism and will always wait for enough input, it will >> cause below >> results: >> >> 1. If there is no serial input at all, this interface will return >> timeout immediately without any waiting; >> >> 2. If there is A characters in serial port FIFO, and caller requires >> A+1 characters, it will wait until a new input is coming and timeout >> will not really occur. >> >> As SerialPortLib is a simple library implementation, I think it is >> better to improve SerialIoDxe driver instead of SerialPortLib. >> >> Please let me know your comments about this. >> >> Thanks and regards, >> >> Gary (Heyi Guo) >> >> EFI_STATUS >> EFIAPI >> SerialRead ( >> IN EFI_SERIAL_IO_PROTOCOL *This, >> IN OUT UINTN *BufferSize, >> OUT VOID *Buffer >> ) >> { >> UINTN Count; >> >> Count = 0; >> >> if (SerialPortPoll ()) { >> Count = SerialPortRead (Buffer, *BufferSize); >> } >> >> if (Count != *BufferSize) { >> *BufferSize = Count; >> return EFI_TIMEOUT; >> } >> >> return EFI_SUCCESS; >> } >> >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 2017-08-04 8:05 ` Zeng, Star @ 2017-08-04 8:08 ` Heyi Guo 0 siblings, 0 replies; 8+ messages in thread From: Heyi Guo @ 2017-08-04 8:08 UTC (permalink / raw) To: Zeng, Star, edk2-devel@lists.01.org, Ni, Ruiyu, Laszlo Ersek (lersek@redhat.com) No problem at all and thanks a lot for fixing the issue :) Gary (Heyi Guo) 在 8/4/2017 4:05 PM, Zeng, Star 写道: > Oh, sorry, I forgot it because of busying on other things. I will post it soon. > Thanks for your reminder. > > Star > -----Original Message----- > From: Heyi Guo [mailto:heyi.guo@linaro.org] > Sent: Friday, August 4, 2017 4:03 PM > To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org; Ni, Ruiyu <ruiyu.ni@intel.com>; Laszlo Ersek (lersek@redhat.com) <lersek@redhat.com> > Subject: Re: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead > > Hi Star, > > The patch works well on our platform. Would you merge it to EDK2 main stream or do you like me to post it to the mailing-list? > > Thanks and regards, > > Gary (Heyi Guo) > > > 在 7/18/2017 6:59 PM, Heyi Guo 写道: >> Hi Star, >> >> I think your proposed patch is fine. >> >> Thanks. >> >> Gary (Heyi Guo) >> >> >> 在 7/18/2017 4:39 PM, Zeng, Star 写道: >>> Gary, >>> SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. >>> If let SerialDxe to handle the TimeOut, seemingly it can only check >>> SerialPortPoll() and read data by SerialPortRead() one byte by one >>> byte, for example like below. >>> Do you have any proposed patch? >>> >>> Ray and Laszlo, >>> Do you have any comments? >>> >>> >>> ==================== >>> debf0d1b85e7a30defd29838abb20a44dd9ec69b >>> MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- >>> 1 file changed, 16 insertions(+), 2 deletions(-) >>> >>> diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> index d2383e56dd8f..b05603d7f3b5 100644 >>> --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> @@ -465,11 +465,25 @@ SerialRead ( >>> ) >>> { >>> UINTN Count; >>> + UINTN TimeOut; >>> Count = 0; >>> - if (SerialPortPoll ()) { >>> - Count = SerialPortRead (Buffer, *BufferSize); >>> + while (Count < *BufferSize) { >>> + TimeOut = 0; >>> + while (TimeOut < mSerialIoMode.TimeOut) { >>> + if (SerialPortPoll ()) { >>> + break; >>> + } >>> + gBS->Stall (10); >>> + TimeOut += 10; >>> + } >>> + if (TimeOut >= mSerialIoMode.TimeOut) { >>> + break; >>> + } >>> + SerialPortRead (Buffer, 1); >>> + Count++; >>> + Buffer = (VOID *) ((UINT8 *) Buffer + 1); >>> } >>> if (Count != *BufferSize) { >>> ==================== >>> >>> >>> Thanks, >>> Star >>> -----Original Message----- >>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf >>> Of Heyi Guo >>> Sent: Monday, July 17, 2017 12:23 PM >>> To: edk2-devel@lists.01.org >>> Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout >>> processing in SerialRead >>> >>> Hi Folks, >>> >>> In SerialRead function in >>> MdeModulePkg/Universal/SerialDxe/SerialIo.c, >>> it seems the timeout processing in SerialRead is not consistent. >>> >>> Since SerialPortPoll only checks the status of serial port and >>> returns immediately, and SerialPortRead does not really implement a >>> time out mechanism and will always wait for enough input, it will >>> cause below >>> results: >>> >>> 1. If there is no serial input at all, this interface will return >>> timeout immediately without any waiting; >>> >>> 2. If there is A characters in serial port FIFO, and caller requires >>> A+1 characters, it will wait until a new input is coming and timeout >>> will not really occur. >>> >>> As SerialPortLib is a simple library implementation, I think it is >>> better to improve SerialIoDxe driver instead of SerialPortLib. >>> >>> Please let me know your comments about this. >>> >>> Thanks and regards, >>> >>> Gary (Heyi Guo) >>> >>> EFI_STATUS >>> EFIAPI >>> SerialRead ( >>> IN EFI_SERIAL_IO_PROTOCOL *This, >>> IN OUT UINTN *BufferSize, >>> OUT VOID *Buffer >>> ) >>> { >>> UINTN Count; >>> >>> Count = 0; >>> >>> if (SerialPortPoll ()) { >>> Count = SerialPortRead (Buffer, *BufferSize); >>> } >>> >>> if (Count != *BufferSize) { >>> *BufferSize = Count; >>> return EFI_TIMEOUT; >>> } >>> >>> return EFI_SUCCESS; >>> } >>> >>> _______________________________________________ >>> edk2-devel mailing list >>> edk2-devel@lists.01.org >>> https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-08-04 8:06 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-17 4:23 MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead Heyi Guo 2017-07-18 8:13 ` Heyi Guo 2017-07-18 8:39 ` Zeng, Star 2017-07-18 8:58 ` Ni, Ruiyu 2017-07-18 10:59 ` Heyi Guo 2017-08-04 8:02 ` Heyi Guo 2017-08-04 8:05 ` Zeng, Star 2017-08-04 8:08 ` Heyi Guo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox