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 CDE959410FD for ; Thu, 21 Sep 2023 03:57:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=fUliboGH7ONkxf0v6YwhzVg2JaXbPEyJovNb/pkeANk=; 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=1695268677; v=1; b=Qfx5m08kTCleOIfuQeM3eUovjyKH8XfoRUYs+0CRuFnnZ5y/0NO/6LKkQRNGL1MR8oMv431Z q1xptFdokk1wltgmjI8lzezRUF2Dqums7mTnrZrfBfLL3sMgV2r9CrOK/mU3OmCgPBg/AruSvBn b62QYbB+08sJdkY9C0B3+FKk= X-Received: by 127.0.0.2 with SMTP id BFZmYY7687511xA59byJ61kU; Wed, 20 Sep 2023 20:57:57 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.8702.1695268676532796210 for ; Wed, 20 Sep 2023 20:57:56 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="359798608" X-IronPort-AV: E=Sophos;i="6.03,164,1694761200"; d="scan'208";a="359798608" X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 20:57:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="746927559" X-IronPort-AV: E=Sophos;i="6.03,164,1694761200"; d="scan'208";a="746927559" X-Received: from shclientbuild02.ccr.corp.intel.com ([10.239.133.21]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 20:57:53 -0700 From: "Xianglei Cai" To: devel@edk2.groups.io Cc: Xianglei Cai , Hao A Wu , Ray Ni , Jian J Wang , Liming Gao , More Shih , Jenny Huang Subject: [edk2-devel] [PATCH V2 1/1] MdeModulePkg/XhciDxe: Abort the Address Device cmd when time out Date: Thu, 21 Sep 2023 11:57:40 +0800 Message-ID: <5a1ea986c40109ea9860f0b6bd2be0fa249c9b3a.1695268645.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: jIRaVJT3sHDyXWXusUrFAKzsx7686176AA= 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=Qfx5m08k; 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 Following XHCI spec 4.6.1.2, software may abort the execution of Address Device Command when command failed due to timeout. Cc: Hao A Wu Cc: Ray Ni Cc: Jian J Wang Cc: Liming Gao Cc: More Shih Cc: Jenny Huang Signed-off-by: Xianglei Cai --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c index 53421e64a850..f6efcf80f376 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -2121,6 +2121,26 @@ RingIntTransferDoorBell ( return EFI_SUCCESS; } +/** + Set Command abort + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be disabled. + +**/ +VOID +XhcCmdRingCmdAbort ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId + ) +{ + // + // Set XHC_CRCR_CA bit in XHC_CRCR_OFFSET to abort command. + // + 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 +2351,14 @@ XhcInitializeDeviceSlot ( Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; } else { DEBUG ((DEBUG_ERROR, " Slot %d address not assigned successfully. Status = %r\n", SlotId, Status)); + // + // Software may abort the execution of Address Device Command when command failed + // due to timeout by following XHCI spec. 4.6.1.2. + // + if (Status == EFI_TIMEOUT) { + XhcCmdRingCmdAbort (Xhc, SlotId); + } + XhcDisableSlotCmd (Xhc, SlotId); } @@ -2547,6 +2575,14 @@ XhcInitializeDeviceSlot64 ( Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; } else { DEBUG ((DEBUG_ERROR, " Slot %d address not assigned successfully. Status = %r\n", SlotId, Status)); + // + // Software may abort the execution of Address Device Command when command failed + // due to timeout by following XHCI spec. 4.6.1.2. + // + 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 (#108933): https://edk2.groups.io/g/devel/message/108933 Mute This Topic: https://groups.io/mt/101493909/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-