From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x235.google.com (mail-pf0-x235.google.com [IPv6:2607:f8b0:400e:c00::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 96CEA21CB0319 for ; Tue, 18 Jul 2017 01:11:40 -0700 (PDT) Received: by mail-pf0-x235.google.com with SMTP id e26so7879117pfd.0 for ; Tue, 18 Jul 2017 01:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=25oxDtlv3s4f7s9qC2nQZpS0wrFD5no5hg4vw71UJ0k=; b=R1dNAXBf+AwC7xjnnceAO8Q4TS6AfIM2/QunR44HKKW3jPypGrDk5FMujBtJAxc2kV VxvjQUtbKWg8H2UqEW+t4hS1uMwYIBHNch82I8Ld5QoIJyyNYvNXyttM6DadzGrojRO3 GgKyiKOo/igyVBqhVR8wl3Z3won1tnpeKx7B0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=25oxDtlv3s4f7s9qC2nQZpS0wrFD5no5hg4vw71UJ0k=; b=jFmrv6CwBAamV6ktDfm0k/IeV+R4M/YtzU/mP2SAjcSi5TELvGcqW3voKo3/7pqjoB TX3oRnzxKq627p6NcR5EU5vAo6zFcTxUwC4u4Niw8jvX4G8pjihLT9OwEXsz2vEmJJDa kdVjiNJOmoxNfdAPxyMZHYGXuqNnqr3AnjBrgLYsBeYrnJMr6v4kf6aB8ePN/vvDwoPj 9O9/cRZnZW/HJDRYq+VVlceiI/O8UygrVBgvMqzRJlEcjOJhJNXQL4305pTs1NOnfqJg MJfhDR2ubIgoNHlEdRWpsOwefTgg+GdEV7dZGbQ7TrVeTdZFjcFK5tYY9jADpW2Rj6eL QqGQ== X-Gm-Message-State: AIVw1126PYoVDF9s1zPuseXL590nMjCpntNfp/Vc2y1dG/evJUIgx3Oj M27t1+GCKC+6IgGp2uut7w== X-Received: by 10.98.155.133 with SMTP id e5mr467251pfk.186.1500365613915; Tue, 18 Jul 2017 01:13:33 -0700 (PDT) Received: from [10.229.36.134] ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id y5sm2768661pge.38.2017.07.18.01.13.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 01:13:33 -0700 (PDT) To: "edk2-devel@lists.01.org" References: Cc: star.zeng@intel.com, eric.dong@intel.com From: Heyi Guo Message-ID: <2e9ddb6f-8014-0c59-a874-82844a185182@linaro.org> Date: Tue, 18 Jul 2017 16:13:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jul 2017 08:11:40 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit +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; > } >