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.12906.1599066299830222348 for ; Wed, 02 Sep 2020 10:05:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=AZqwKy9l; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=051440aaa7=patrick.henz@hpe.com) Received: from pps.filterd (m0134425.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 082H4AZf028549; Wed, 2 Sep 2020 17:04:58 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=A6mdPcV3Hme6N7djzl/HOf9W2HPXr34n/oTmwJrcbc0=; b=AZqwKy9ln/cR8g6EMsLuxu9k4ZwNt+QTvoe4XcM5jgoGrdgDs3vIbKNQQaRupBe/T9uP qj/YlfZJL0in3QANu/7ZBYkNQv9Q1O/XDnVg7h4EfBzjtG/FUmBJqkcZC5qv4QVKGc6i 6pUYIP5EEQkrGRDyNWUsQkpr8diaFvcb2xKyjbXcE5qQIz81GhJUvHbpBbR95Us+EVJC 8CPIgBbfTRrzdqsj+V2NAv2EmEOXJeWBICodhHQbVCY4LLbu/rkVkhEOGHsJ/rWBl0Jq oJUXsPd1ujZ/eBbyaLm7oKoEXWYHlBWbx//8nvn1d7YqfynXHG5XUvbqaYCWNRFmxPmR tg== Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by mx0b-002e3701.pphosted.com with ESMTP id 339v6c9465-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 17:04:58 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5009.houston.hpe.com (Postfix) with ESMTPS id 16C115B; Wed, 2 Sep 2020 17:04:58 +0000 (UTC) Received: from G4W9325.americas.hpqcorp.net (16.208.32.94) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 2 Sep 2020 17:04:58 +0000 Received: from G9W9210.americas.hpqcorp.net (2002:10dc:429b::10dc:429b) by G4W9325.americas.hpqcorp.net (2002:10d0:205e::10d0:205e) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 2 Sep 2020 17:04:57 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (15.241.52.13) by G9W9210.americas.hpqcorp.net (16.220.66.155) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Wed, 2 Sep 2020 17:04:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1yqEMfIeyCPh6uhy4W6OXcBcDZRfLPdxo0aYvNdwRUBbAnn8AUbnZsjv0o0Ts4nYHrjHt1MOD9s81b07+/FaR9D/SyuIvYHskS4/BVOMgIOdfXPklOZczrhexoU1b17O3wCiN905CkXqlC/LP0wkG8wNNpuKMPwbL3NTsgqXanRAxO/0UFv+9oZoxHcrGUcMMeidxlRA2BeacN/7Tfoo+kEw2SdxVLUZNtTmZBC9zTj7IvFf7VlAKGqJUUdDVW9z468hvYcV4GsCbA26XdcqiEjbys3iSJwzqSv0Mo7Z3LBlItmrPUYJuTiE+DfFUBt8qLaATuz/pBwPJBexWEvbw== 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=A6mdPcV3Hme6N7djzl/HOf9W2HPXr34n/oTmwJrcbc0=; b=QccLZ/AC4j00gX000DEDDyQISpnOyCmrT9u9YWuXCBzjCIi5qhN5cbfXhrH7jBLCko640/r8WoXIRsh7tp+WeWedkmkdZ1OaGcXICaZ9weFbnH5fi0sny9GPX6PDr/Cb5nmodMLzk/g7I/zRxX3/b6rBl/yvvfBtM4usvScxw34zbJMmrlfw98z/uKArzEOoSQJRkv7f/fqM6h04ZID2gVYFOHSdaeOZtjWBXlE8X8TAXr8I7A5KMP09n9PCSND+HSe0uRv+cwq+FBBA5ZrI2M3TV2bFlsk0iMzNPktnCrIM5tSGoch3lS2VTU4K/HyciektM5TUFF5zzjd4uZBAaw== 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 TU4PR8401MB0400.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:770a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.22; Wed, 2 Sep 2020 17:04:56 +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.3348.015; Wed, 2 Sep 2020 17:04:56 +0000 From: patrick.henz@hpe.com To: CC: Patrick Henz , Jian J Wang , Hao A Wu , Ray Ni Subject: [PATCH v2 0/1] Fix XhciDxe Timeouts Date: Wed, 2 Sep 2020 12:04:39 -0500 Message-ID: X-Mailer: git-send-email 2.28.0 X-ClientProxiedBy: SN4PR0501CA0025.namprd05.prod.outlook.com (2603:10b6:803:40::38) To TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7709::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0501CA0025.namprd05.prod.outlook.com (2603:10b6:803:40::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.7 via Frontend Transport; Wed, 2 Sep 2020 17:04:55 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [76.17.188.158] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 63df91fc-3c7e-4d6c-d46c-08d84f625136 X-MS-TrafficTypeDiagnostic: TU4PR8401MB0400: 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: FqoZorsLLw7rmGppFwTU+TPaNqclzNEVTDXSnTy4rK7Z50cT3d5MLPCy9MJjjxFr01HCQpfhES5cB1mWrVr9Wo+opLfRyCJNwDAwyR/x5gBWzCjI5hng/rNYx9RthZfOXotv8jE2WZrHqD90MHtkWiZ7fBYrcL9FGGLfJBvdMDs17uWopMDdJ1OLW+xMDbMBX+lE4fpZ/nfWWx/80uCVONqYO8en2GllSokpIKLQiWs8G1Et6ZbIxi/qJCi4Smqg8mfiLgG8yjUH5+l0PdJYgox4MfiDs6uNy8u1JQiEzS7bzfAb4K3v1EcEYCTXzKgQ/D3Bq4XMP0hNQBpD3X1EEQ== 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:(366004)(376002)(136003)(39860400002)(346002)(396003)(9686003)(186003)(66946007)(66476007)(2616005)(956004)(52116002)(36756003)(66556008)(6916009)(5660300002)(26005)(316002)(16576012)(8676002)(6486002)(86362001)(54906003)(83380400001)(4326008)(2906002)(8936002)(6666004)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cn0uyBIN6/Le+x53w2cMQgGjK71Fv3SdnuGtBgCxZP/S89eQxUHLE+/aWH+MSu/oRcD95UQPupQ6t3dfjSMv0OjJuT5Lu+4s6VEKg5t85lJSY9AyjtuKvH9y6qdxGPLz0Daj0rCfS7z1gChsHfVAHSklWlfcH8uLKRxLBW39NZtCMgY9+SYDt09RmWoolLcZNFuyrk6lxrrKwNWXVYDC63YUuDshyTcJ0/pCPrlIiMYNIFopsbOKiH32sgKQqbE022i60EUGH8fIeO9beaBt71JhN/yRH8mQGiqlQiUrhU8HbKdy6dmCTAZEMkiyz/Rpb+aftVUpwPZzVnMdKlmOaDYORdAI05HFxK1N6qZxy0QZytUR4vpwymJe8JMg4xJEf0DjABpAQeieDa+WCj7ILG1r1WTcWsM/UEhcm3vu3Ea9CxDO7pNBwIFVtPHEy8PiIn0mllpSW5OJgIcbRCf58CWHtYUk2J1UidTRipS0mKSFxY+2opxOiExIMvKrAu3fxOfpKrerFfu8GVNsaGkuBuOxK5cqaI8EOoqXBmUoanfDtekB50pGimYtNXV+C6dWugm+NfyXRaDMydNwV3y137I7NQNnLVIY52KVvUkjGNSmH9E7SDRsuvYDOkGqjyPa5MfQiOwjoObmGWI66QBgrA== X-MS-Exchange-CrossTenant-Network-Message-Id: 63df91fc-3c7e-4d6c-d46c-08d84f625136 X-MS-Exchange-CrossTenant-AuthSource: TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2020 17:04:56.4420 (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: 9ItQrIomO0G2yR1Bx2+c8+AA0Iah691SP5tZFdEDhW/qJX+bzDPFXbw9kW9tFiRII887s8an4z9mZ7Wv17NIkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR8401MB0400 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-02_11:2020-09-02,2020-09-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=895 spamscore=0 suspectscore=4 clxscore=1015 bulkscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020163 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 | 35 ++++++++++++++++--- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 43 +++++++++++++++++++----- 2 files changed, 65 insertions(+), 13 deletions(-) -- 2.28.0