From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 363B3740046 for ; Mon, 18 Sep 2023 15:17:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=XmX7tKGV2qdrbkoObuXLmV1g42UIOsiy6cIgYJgtdxU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695050273; v=1; b=B9ljrWnMvCZ3vDe4lwM5KC8Tt0p/2SfOsQBPhhf6FE6EXRM9gtsgxysUhopu+3U18DEJfInC HWJdrFReWbN7iDHyBm5oc5QSoN7yz0D33Tk+jiLr/BK4s3RVdLIm7ZWcZ7hlcZ5vweY/fbZxWgD r+YPx4fDwc0I6hqH8JqL+Ao0= X-Received: by 127.0.0.2 with SMTP id OJ0rYY7687511xf5napwXr2f; Mon, 18 Sep 2023 08:17:53 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.45974.1695020229635994250 for ; Sun, 17 Sep 2023 23:57:09 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="369909038" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="369909038" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 23:57:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="869454571" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="869454571" X-Received: from shclientbuild02.ccr.corp.intel.com ([10.239.133.21]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 23:57:02 -0700 From: "Xianglei Cai" To: devel@edk2.groups.io Cc: Xianglei Cai , Hao A Wu , Ray Ni , Jian J Wang , Liming Gao , More Shih Subject: [edk2-devel] [PATCH 1/1] MdeModulePkg\XhciDxe: Command Abort when times out Date: Mon, 18 Sep 2023 14:56:38 +0800 Message-ID: <91ce12999b52f08034b6cc58ad642dd526cf6c4b.1695020158.git.xianglei.cai@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,xianglei.cai@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 3488YZMn3Af8tFlWi0WCcMc4x7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=B9ljrWnM; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io https://bugzilla.tianocore.org/show_bug.cgi?id=4552 CC: Hao A Wu CC: Ray Ni CC: Jian J Wang CC: Liming Gao CC: More Shih Signed-off-by: Xianglei Cai --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c index 53421e64a850..5024d5e3acb9 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -2121,6 +2121,29 @@ RingIntTransferDoorBell ( return EFI_SUCCESS; } +/** + Set Command abort + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be disabled. + + @retval EFI_SUCCESS Successfully disable the device slot. + +**/ +VOID +XhcCmdRingCmdAbort ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId + ) +{ + // + // Some 3rd party XHCI external cards don't support single 64-bytes width register access, + // So divide it to two 32-bytes width register access. + // + DEBUG ((DEBUG_INFO, "Command Ring Control set Command Abort, SlotId: %d!\n", SlotId)); + XhcSetOpRegBit (Xhc, XHC_CRCR_OFFSET, XHC_CRCR_CA); +} + /** Assign and initialize the device slot for a new device. @@ -2331,6 +2354,12 @@ XhcInitializeDeviceSlot ( Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; } else { DEBUG ((DEBUG_ERROR, " Slot %d address not assigned successfully. Status = %r\n", SlotId, Status)); + // + // Software need abort the command if a command times out in xHCI spec 4.6. + // + if (Status == EFI_TIMEOUT) { + XhcCmdRingCmdAbort (Xhc, SlotId); + } XhcDisableSlotCmd (Xhc, SlotId); } @@ -2547,6 +2576,12 @@ XhcInitializeDeviceSlot64 ( Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; } else { DEBUG ((DEBUG_ERROR, " Slot %d address not assigned successfully. Status = %r\n", SlotId, Status)); + // + // Software need abort the command if a command times out in xHCI spec 4.6. + // + if (Status == EFI_TIMEOUT) { + XhcCmdRingCmdAbort (Xhc, SlotId); + } XhcDisableSlotCmd64 (Xhc, SlotId); } -- 2.42.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108793): https://edk2.groups.io/g/devel/message/108793 Mute This Topic: https://groups.io/mt/101435621/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-