From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.3315.1598986527104587080 for ; Tue, 01 Sep 2020 11:55:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=nPjlqc+g; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0513205a6d=patrick.henz@hpe.com) Received: from pps.filterd (m0134422.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 081Iqio7011151; Tue, 1 Sep 2020 18:55:26 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=FsT/MUoFDTJJDTAdX1OHpgAPR0OLXBJqeVXL2R5yED4=; b=nPjlqc+gaJ/ghnrqiWDh1j8LHx/z+Snom+K38qLk1UcKsEiTz7VijvrEnl8Z6utcVTEo pCnxwM5qjt2LSjZ1oqD3a4uiJpmKcHDHvYFQbw6ztIAq3v2ZR61OmB1Hxf26ZKcGKNsV sKO1zrigfxC4/cgnfsvgFxA4c6CYcNwPEtASGomclnW7BApaJMXRogJ29N6oAoKRA1I0 oAlJHBMhyAjg8pTcMpA2VAthSEc+avvF5KJy0CUb3rw+rdTtY2wDr4Q9zO/RvSVzoA9/ NF+vMrR3yb8mzJmetS0FE42N2yj5tsGuHmohrJwT+BQpDDMeUjE5XfQedr73X+rmP1+O kQ== Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0b-002e3701.pphosted.com with ESMTP id 338dqpgyxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Sep 2020 18:55:26 +0000 Received: from G9W8456.americas.hpqcorp.net (exchangepmrr1.us.hpecorp.net [16.216.161.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3425.houston.hpe.com (Postfix) with ESMTPS id 873F3AF; Tue, 1 Sep 2020 18:55:25 +0000 (UTC) Received: from G4W9119.americas.hpqcorp.net (2002:10d2:14d6::10d2:14d6) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 1 Sep 2020 18:55:25 +0000 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (15.241.52.13) by G4W9119.americas.hpqcorp.net (16.210.20.214) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 1 Sep 2020 18:55:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QlrtsCVHh0pMkmVC4KOMTqWLt4FPDrY+4ADiUDXL/ZOdfTUOdBJpFCg42Rw+M8goeA+uj6EshqTw9CXxSLTLSsjTK2R9aNqRafucAtwfC/ny3ElmQOumIpsyEfimRwIeNTnTG9dEk0EUJYo5sCY+96Hk5hGaI5mwawLWhjpRsrqs+8O198JiLxU0t8VohKw9bLVIDz/hID4DGhPCGK0KUf6lMObEmximUZuiVpvDlFhxfj4KP3KfFAW2MQ/W/Xr+mFFt7Uv+gdig2y1/aK+DKlhA05Gdnj5uMfPujQLdW+SFit7wf5fxHUGrOJ2gwqYNmWr+rcKZ1fY8UAJNxd/Zzw== 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=FsT/MUoFDTJJDTAdX1OHpgAPR0OLXBJqeVXL2R5yED4=; b=LMIrNzgQjKXhyy+h0KZJ75A//zb1u3bQdqqFfFpW53YebsSCUERXN5wxgLNqD0ftRn6tHK3bK9zYsB724QFTwcruZf1RFzyLpzsw8BtSfAgtTHJU+x4XGMb/hu2E6EieA3QiAxH+CX0vgtYiYB/rv6JxtaIkRb54U6P52+G1V7jz6hCJIA7gItdVozSqJdqRVyjJX6lT+f0RSERpCmASXXtTm4rRIqsrpvUNQv453Iuy7nayYIkAqj0PhCHNB02bRUQdPW4FpoHTlnRBJ628NY0OIviEK9Y7uvz/W49UyJ2QxH3ck6RSWW9jGFPs6aeltNc/n0KrLxb+dFU0AtEQpQ== 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 TU4PR8401MB0591.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:770c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 18:55:24 +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.3326.025; Tue, 1 Sep 2020 18:55:24 +0000 From: patrick.henz@hpe.com To: CC: henz , Jian J Wang , Hao A Wu , Ray Ni Subject: [PATCH 0/1] Fix XhciDxe Timeouts Date: Tue, 1 Sep 2020 13:55:05 -0500 Message-ID: X-Mailer: git-send-email 2.28.0 X-ClientProxiedBy: CH2PR12CA0015.namprd12.prod.outlook.com (2603:10b6:610:57::25) 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 CH2PR12CA0015.namprd12.prod.outlook.com (2603:10b6:610:57::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 18:55:23 +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: 58def82a-9910-4334-1b9e-08d84ea89526 X-MS-TrafficTypeDiagnostic: TU4PR8401MB0591: 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: 9h38ggxPvwpxUL46w7n5wNuUjLkMUXgU+f1VMeggIyUw5djrAE99LYQYTLkqj6yD1pzOnNd1RqlT2XcQtTc6rAI2+tbUBtpbWo6kRN1J/HilAsDtzq5QweAWYduSmAQNL6tVQqc7kX9Vz8sa/NCj6KP9YcNdI/+LHByJWlCbBStLWITONrWlybjGf3+bieC5C9+zSvsXMyCHxM/mu9xd15sBJhpqyddXoeHAJYZqR86LOKwL7K6Z2C7xETQYs/8yA4Xa6ZLvHBS0f3F15lSzvz9jRhOJCHJ8yQyAqSw2y2SyIvhgYExH4RFMI12yLIGVIHZy8yd9YikwECnxmQCdhA== 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:(39860400002)(366004)(136003)(376002)(346002)(396003)(66476007)(86362001)(54906003)(2906002)(66946007)(6916009)(9686003)(6486002)(66556008)(2616005)(956004)(316002)(16576012)(5660300002)(8936002)(8676002)(186003)(6666004)(4326008)(478600001)(36756003)(52116002)(83380400001)(26005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1OrUsthjzmT9XavPUGFyhTMNWPhQQQuWgFijPA/Cdfb1d1iUWdDI6RRXyWZOr+lylR6PBUyUBO/GzsspzK587P53cwzPE/AYD8ZkNV8L6dt3B37nPpXR6ji2J63yFhVBN8oIdNSLyTun8CGyvaYgDnRysqFUMP7em67VWSt8wcEM3IBF/jj9u+Y7fERkitVZMCFf07xACxXRBDjzpDtMryssNrQY/uin/7+rFbY//9kXaNqZZkfNgLta9648vH4KIHWrfCeUGrOBZKEhYLIrgt7cUYzsoc915iJ3NrlPS5QSXqptw5HcCmYoZHO+uSMsYF+8wOE5f3NiMF/NXFA/xUuCXeobQ1pX3lWcbwhKkiyb2Ld7fyXZp8tX2Zak+eEEZb4WyWGlqAYaqOVDExQ0vk2U9XBe5asCBsB7xzh8aMBYWrBsEAz2Q1c+xFRNQWwhirbmjzdTk5/9dR8ILXSsOU4E4j8ktYogK83Rvtj+HBq3dZK4aHHYLdjQiNwfcWeVO8z+B3aQd4bUgOedYCG2+SJ+9LVkFdGLt/r8AOytQj4MkQCHpSCMywKvqJ5NdmSRZpjFWzKaf3impAKMf1p8hxEzG7ID8Asx2yZjTSKJVey+hD2EfF9xWHTDuED8EcOG+POmY+cFzO5Dq8drbO/dXg== X-MS-Exchange-CrossTenant-Network-Message-Id: 58def82a-9910-4334-1b9e-08d84ea89526 X-MS-Exchange-CrossTenant-AuthSource: TU4PR8401MB0478.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 18:55:24.0298 (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: vGtHn3G95uUmRMQD1tG3M8QCQEulbUunc//3uUkrv6LEqCd9U+6Ds3fgVfmYY4Z9iA9+RhyzpyaJ6W4nObwMfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR8401MB0591 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-01_10:2020-09-01,2020-09-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 clxscore=1011 suspectscore=4 spamscore=0 mlxlogscore=856 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009010159 Content-Transfer-Encoding: 8bit Content-Type: text/plain From: 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(TimerStatus) && 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 | 28 ++++++++++++++++--- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 34 +++++++++++++++++------- 2 files changed, 49 insertions(+), 13 deletions(-) -- 2.27.0