From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-x22f.google.com (mail-pg0-x22f.google.com [IPv6:2607:f8b0:400e:c05::22f]) (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 A76C421B06E90 for ; Sun, 16 Jul 2017 21:21:40 -0700 (PDT) Received: by mail-pg0-x22f.google.com with SMTP id t186so72961980pgb.1 for ; Sun, 16 Jul 2017 21:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=sUX/VRwIknBOgVmh2p4jzoVPGUdzc82W0YNYbLmTteY=; b=PpsuIDtkDiNNI0Xj8FdJ0K/zI4YsYrXTK2Sjf1Bteuu7NCiaKEiQnDqawkjocJl/6s J7b+6rAnrGCz4q4lfO+r932guKq7csX1560EU9ZQTByuaL3A3tos7gxVhsNaqjeyGJz3 Re8vdH6mjcqWgUfU1rxaYFt8TPnl80baGWHYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=sUX/VRwIknBOgVmh2p4jzoVPGUdzc82W0YNYbLmTteY=; b=V3mCC4Mkb5OioI5aVEBqC+yyBo0IKL/5XLQ42C9YHOYjO7cBY68djWcvX7B1WbwMNZ 3d4rrwPXvvbsEER+/yBrY2eFWkuwsF6tV6gCPDVNSh5V5OPAaw3M0287tXnlSx4DTnZz rGXYCf3JalF8rhtzEkxtGzHZ7vJ0CRuH5QGhfWtUZhaMQebHMtC+S+ujXuYYlPHVxR55 ywffJh3fEu1Rh10FHGbdHPivff6FBLTpDbmGA31laRh9Jtl6e/gENwNyMYB85ECcTcfz 4L3aNSiQhGLG7irr6jJSspkdj9UhSjzp1PFTrcvstAPeqxllobZ2M5i2CbCISbwq/ZCh L2hA== X-Gm-Message-State: AIVw112JE9nK8pg8Zl/FlnR7yLeony/bDAwRET/+e2eX6qpvLli47BW4 YV6Dh4zzyZXO/jEQ/OQbgA== X-Received: by 10.99.125.68 with SMTP id m4mr3905260pgn.259.1500265412545; Sun, 16 Jul 2017 21:23:32 -0700 (PDT) Received: from [10.229.36.134] ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id n80sm2697927pfj.118.2017.07.16.21.23.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Jul 2017 21:23:31 -0700 (PDT) To: "edk2-devel@lists.01.org" From: Heyi Guo Message-ID: Date: Mon, 17 Jul 2017 12:23: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 Subject: 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: Mon, 17 Jul 2017 04:21:40 -0000 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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; }