From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.4316.1600889784939829119 for ; Wed, 23 Sep 2020 12:36:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=SbSwS0oA; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0535649adb=patrick.henz@hpe.com) Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08NJXMWM027624; Wed, 23 Sep 2020 19:36:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=pps0720; bh=ieFsXJz9LQZTt6h7xxKAzBK5ICE4h1PMEjOUAZW9xlA=; b=SbSwS0oA28LLlCRO6a7JYkGYT1QqEQdEKevLvo4pl1V77pv151wsq167LJpLCY4TaX6Q 0CLtOZDiiK97oXnmLDPqNuwtjqZEmK/M8L5B3oxUyyEM93RgdHYfBHFgoQ4C4A4fdz2C G1MMIYWrtvzqgdN1fr3Q1sVhXWgrRwiYTgHCpP591tlf7XW90WmBg0fxDek5KCf1M++y ZbZ6ss87klKOXei8XjQY8bsOfA+XnlefmFufGxi5hnkwbMVt10v4WxHqDFB3jOrOKcMz yMhXyeDKN+8uqJP5szVu09X7/i9wR1vu0s3G5ItriG6aT9sWag+uN40L/jhkb/FfbrBQ Yg== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 33r2nxprw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Sep 2020 19:36:23 +0000 Received: from G2W6310.americas.hpqcorp.net (g2w6310.austin.hp.com [16.197.64.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id BCD52B5; Wed, 23 Sep 2020 19:36:22 +0000 (UTC) Received: from G4W9121.americas.hpqcorp.net (2002:10d2:1510::10d2:1510) by G2W6310.americas.hpqcorp.net (2002:10c5:4034::10c5:4034) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Sep 2020 19:36:22 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (15.241.52.13) by G4W9121.americas.hpqcorp.net (16.210.21.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Wed, 23 Sep 2020 19:36:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hlv53GKTKlbglR60AwGaZac+BQQo/erBkknrUqnU/tsuJtsT+99IV5B3ldrrh6r52k4JMVqrHE+YQGrUIMgS9aupowynubmWkTpdnCAsS9JgC9Ywc3MQ1XJPWOzYbx294hONxWWcPD0MHl2oBdthZyAWRaQcw3fjYkYEOooJavWLTLO44J/JyYKwIv6y4g1mfMduV4/rHJsX85rMg0WV77NS4qGHddQxaDmL2yEUh/Y+faEixsgCevK5F7kftoRZEPSKnKvXjAliXVRgt0soPD7MywMpbsWq0kaWWsKle6K2Eo3+q/2n6XqS3jFYeOCXim3hIm04oXO4NJYDCjXteQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ieFsXJz9LQZTt6h7xxKAzBK5ICE4h1PMEjOUAZW9xlA=; b=lTZOp0G/MIenamjnA34CepX8Vb+dB6kGH8c1swSwC0UZxK47BhGJgiMPiqzyOmvG8AkAdaa9OKtLb2D4QFVOLrZ68EKQGdeT7Uc2oQuPgNaRs5BYO20s8l01jNnUUGj0NN/yrju9BeNFni7UkEnbUWAANPYGkla0lymigB2U7cfH8NF9ULJTqxMygeoMkY8YtOHlyriNBwq7MwngJSABQLDAB9r8GSHd2P3wrhTX0KjmO9wPahDlzPCPucbNdGv+I5kZUThZMbQhwm39Tz4KF+EjA6fuNMxP7x9xgMn1qmbIc+caHsOCyS+Dd2jcR7zoQbMAgcpSrF5n4dhjOnsdYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; Received: from TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7709::19) by TU4PR8401MB0399.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:770c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Wed, 23 Sep 2020 19:36:21 +0000 Received: from TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM ([fe80::4968:3a88:e4a6:5cea]) by TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM ([fe80::4968:3a88:e4a6:5cea%8]) with mapi id 15.20.3412.020; Wed, 23 Sep 2020 19:36:21 +0000 From: "Henz, Patrick" To: CC: Patrick Henz , Jian J Wang , Hao A Wu , Ray Ni Subject: [PATCH v3 0/1] MdeModulePkg/XhciDxe: Fix Broken Timeouts Date: Wed, 23 Sep 2020 14:36:02 -0500 Message-ID: X-Mailer: git-send-email 2.28.0 X-Originating-IP: [76.17.188.158] X-ClientProxiedBy: SN4PR0501CA0110.namprd05.prod.outlook.com (2603:10b6:803:42::27) To TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7709::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (76.17.188.158) by SN4PR0501CA0110.namprd05.prod.outlook.com (2603:10b6:803:42::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.16 via Frontend Transport; Wed, 23 Sep 2020 19:36:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 97b04f3f-f361-4fec-eb5b-08d85ff7f2da X-MS-TrafficTypeDiagnostic: TU4PR8401MB0399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VZjNyO0yDwQcYRySriIbOIAvJDX48Kdgy/xdvENvyY/l/Ap7qNTg4yPVVHuiQa90eSurBBAw/hJWDifV9NvC45wLR993pFGbjrcUlah45VEwSRooA9ppezwWq5PbTUGapXwXJPx6P/pmIvsv4fEI2WlMAgsHtuTFKOwxENkY73R3bUIdDSGB56X3FJvHVjR0QbEQrrKvySfi4xXJJb0SboxsTQwLM7CJNXU8ppMPWbS5ZYaLESKWTdAZHURRFxLQPZFpgU7LPIzeI89tPo4BMfEKKh5mC537BOauBgsmXLBBgy+jyUp7iOqgl+AZ2JbGYjH//HMgtKbimDEeZc3Vo0y8AR26M/M+jRR+/Ouujn3wKC5o7WoY+Fe0+zAdAT/s X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(376002)(346002)(39860400002)(396003)(366004)(136003)(8936002)(6666004)(9686003)(66946007)(66556008)(16526019)(66476007)(26005)(54906003)(6512007)(4326008)(186003)(36756003)(69590400008)(6506007)(316002)(86362001)(956004)(2616005)(478600001)(83380400001)(8676002)(52116002)(5660300002)(2906002)(6486002)(6916009);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: wFyCwmLyiV5eeOyGQC5f4Frzx63GgIgCh3qJi+Y9xZorWj7kZB0+qcRz6bazKjnVa2xjNlqXa9Q+Qqvgtl/z1jPLNktsS90WgsxHZHtDuA8y2AK7wzKMgYolb3plbmRFLr4mX1vul/v/rUhA2cmBtH4yqf1jLUwqk45Q1/t8PghtMYZmkYJak7SXY7m4dSl+fH1LhjOWevGEkbSJpbHFcL+ZGFvPmY9kMANlPsHYcuqOQPiNq0AJ7N/44KXl/YUJ0hGtxltwZrJ9DMXbI6ratvjeXkAQHcF/0eICQVG+FL69zNFzS90/htn58+5aIy5jUwwufB5evUBrdfMY5MzJvL1zW8T2P+SNtq5suVTghZNfYpqCQjRc9T5RUUbcLQlPBS34qiGV3VcvKyB5ySJzuzK9yX5tJYIohf1swDJDOQnI29yfC+QzgcBgIE5x8nQqj2djSxxyhre2nQFQHDvwikiu64o2D/6kD6WTOD3kzQV5MEbllIf+sKDZpvB3yhICSwetzMRTdG/UCKEb0wAuhx3iHr5mrVlFHfUhgTWUBbZXUy5jptDwu2jD09VJshpy1BIjTmdSHJBZNR+clHR2F0aanu7CV9iPwvWD9nrWqwS5hx0AKyhEsztilRZPHp+b4QP8nt5z6zgJEp9Wwv2EAA== X-MS-Exchange-CrossTenant-Network-Message-Id: 97b04f3f-f361-4fec-eb5b-08d85ff7f2da X-MS-Exchange-CrossTenant-AuthSource: TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2020 19:36:21.0728 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wrqbZiYxKppLI16oT4JrmhN7c+CvE/6b0N/D5S5Ir1MnoisbA0fUMVvp3tXyZ3DppAIyb4C8LOLh3Gn6UyWKxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR8401MB0399 X-OriginatorOrg: hpe.com X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-23_16:2020-09-23,2020-09-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 phishscore=0 mlxlogscore=883 adultscore=0 malwarescore=0 suspectscore=4 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009230145 Content-Transfer-Encoding: 8bit Content-Type: text/plain From: Patrick Henz Timeouts in the XhciDxe driver are taking longer than expected due to the timeout loops not accounting for code execution time. As en example, 5 second timeouts have been observed to take around 36 seconds to complete. Use SetTimer and Create/CheckEvent from Boot Services to determine when timeout occurred. This patch was tested using forced timeouts and print statements with QEmu as well as phycial hardware. The forced timeouts were implemented in code via static variables that guaranteed a timeout the first time the function with the broken timeout was called. Example: XhcExecTransfer ( . . ) { . . static int do_once = 1; // test line . . do { Finished = XhcCheckUrbResult (Xhc, Urb); if (do_once) Finished = 0; // test line if (Finished) { break; } gBS->Stall (XHC_1_MICROSECOND); } while (EFI_ERROR(gBS->CheckEvent (TimeoutEvent))); do_once = 0; // test line Using this forced timeout approach the correct timeouts were observed on both hardware and in QEmu. Similar broken timeout loops have been found in the Uhci and Ehci drivers. This patch does not fix those issues. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Patrick Henz Patrick Henz (1): MdeModulePkg/XhciDxe: Fix Broken Timeouts MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c | 59 +++++++++++++++++----- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 63 ++++++++++++++++++------ 2 files changed, 94 insertions(+), 28 deletions(-) -- 2.28.0