From patchwork Fri Dec 6 07:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 848079 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 665AB197548; Fri, 6 Dec 2024 07:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733471310; cv=fail; b=ApZC6PoGA3uHtQ3pu7s7NDOM8ho8ws6CRAr+/y4rkOfzJvPC6uWJ+/8g1QeYu1vdx7jSwsYC/7EpdYN5AEviYp3M2J4F5hWF3NZTn4Tmss7brnr8GcPCXBo5+p2VDEovcULk+CzfC/1d573NlIm1miJwsxzEg8KoGhe+xkvTkao= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733471310; c=relaxed/simple; bh=gWvp08Y9778s1h3INGSYHKaJkE9ciK8/79pA6Qs3w0I=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=CQlLeveSCOdBiEWKtsp9k1WPDVHA0WZr20wB7cXkwjP8NBad0Q9P4kQQ6+aelBLPIBPabvp/DPK1/c29+rD5BdaLJ76v6DBWNoh9ILnijJ0HZ2+3dJrMtTw0nk/HLl8cJZN3xuNNl5Lc804vFxKgPbw+6YdBjSsFJkgsOiDy2AA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=MLFNV0Oz; arc=fail smtp.client-ip=40.107.94.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="MLFNV0Oz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qIjVKDa7KVn3Ty6b5TpTOuAwIKgptZmjM2lDMiygLw4djbY0SltORCUL+DtfA0V0iiGWsy5vz4xFQ7IRdCpyZbNz+MdEYBeuXnhtvKTAVUh4Jhvi2xHQEB45szYKXNfgMUHcKSg0Zkxc9jT2ov6ptfsEo9Ea5itzY9/2LMzG5kWJfkrkHJP/DPZ7qW4d7Y7M6ZQ9t45jkTF2ti+9mOIMXzBkqC3Z/6FITilcELHmyCG0YsUnGUTTVanzf/nuxQDl+Icl8I5s9dc7IYvHewYCaLzpyd3XNZaC0L1Dh3u3ERDPTEL7DOEXiuy+1lioq/1cDVDtH1t0ttys/PL8Ptwf6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JiStLYrfzUClt5UzCYLKUQxARFAQcX7Seai28oU6NjY=; b=Bz3q4fo7ghQU7Xy8+36YdpcToZKWH+tIKvvVloBF9oFK0DpG1rCN25XDFXQIlfDP/7OMUN+80g7LEYVGWA13WJLQ/3fsmVu9uo9H7YPhedbDO3lYfeP9JWzbU1Znf9KzSo1ml7NhMyp4/P3tqH2p3ZORh51xIrkg8HOaag4oZbg23hv+cSR9gPAxnL8dYEctgsrzncIfIFl+tJ7S4IiM0gcXqk6UkADxI2hkLjOLqbEklXGrysYblGqeYJeD+cklEbnq/YtFg9Tg5PvxjIDUjFCeiu6fpcMldlGf1UgbfrDfIZxr0VsukzgjDoIPeh+rNdJ8BAUnH4HjV1BLnePH2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JiStLYrfzUClt5UzCYLKUQxARFAQcX7Seai28oU6NjY=; b=MLFNV0OzfeQItTcRfzGeDpgsIRG0A3oRkwBVJVzZILKVjUEd7dkqyaPwdd3S7YYb6gRgEty7QKBJQAXc9pDXn1iiLaA/W51LEbwYxaZ0i3NSZMC2k2S7/CmTgaQUWqLof29g84TAhhuwbNMTqF0Dx+Q5gbDJOEyfPEIRz4ITAqahQZ9HVdt3fWaIYcc+/ktpmQOp0pSU0LvkIpZ83HT7cYqU01ocX/8PFvMzFqoCnkqNrdVSCftcjB+PV95MRk7JV5EecOQ0ghi+nQoEcLq5uAU8iLRzhEMoDBmpBB/k54IA3KMEuM08dQ4aDDKkq3RDygyxUVm38Ngi3/lBmdEC0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from PH7PR12MB7914.namprd12.prod.outlook.com (2603:10b6:510:27d::13) by IA0PR12MB8085.namprd12.prod.outlook.com (2603:10b6:208:400::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 07:48:24 +0000 Received: from PH7PR12MB7914.namprd12.prod.outlook.com ([fe80::8998:fe5c:833c:f378]) by PH7PR12MB7914.namprd12.prod.outlook.com ([fe80::8998:fe5c:833c:f378%6]) with mapi id 15.20.8207.017; Fri, 6 Dec 2024 07:48:24 +0000 From: Kai-Heng Feng To: gregkh@linuxfoundation.org Cc: stern@rowland.harvard.edu, mathias.nyman@linux.intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kai-Heng Feng , Wayne Chang , stable@vger.kernel.org Subject: [PATCH v3] USB: core: Disable LPM only for non-suspended ports Date: Fri, 6 Dec 2024 15:48:17 +0800 Message-Id: <20241206074817.89189-1-kaihengf@nvidia.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) X-ClientProxiedBy: TYWPR01CA0043.jpnprd01.prod.outlook.com (2603:1096:400:17f::17) To PH7PR12MB7914.namprd12.prod.outlook.com (2603:10b6:510:27d::13) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB7914:EE_|IA0PR12MB8085:EE_ X-MS-Office365-Filtering-Correlation-Id: 26db9f51-f642-45a5-b3fa-08dd15ca5d01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: ggiARTe2d7c+wrN/vxXyq/gP6vyXNrq7afiusa/6/dvjrEKCLout3sStcGyOrEZwP03mQK6vKiPZADEMC7EWAHBSPQmthClTJ3uxgjFQCLn5zkyq6TvzP7GIFR34gbd95obb9qffiIKDwelaTxuxZOU7w6bjBlkUDutGHrjK4lNva6GZ7OydRRTCv8XSNruUMVSDt/DQ6itnHr+SDACe2FBPmR4GXn2wKuVjkhcTL3bqg7MnWiA45DKEdJOottMIPadnNAUmWkyP5XuUbTPCzDiu06tqecTegfDaASu1glu0p4qmiY1gdP6ijF70v2wfjZG4/GA89cKhSKKPmCVrXhabMer6+LMPUTE5Ab/bY+wURus6g8kH7nL3slqrRguQhtfIVqiVFcE++e1/Y4GvxjTBRnNdnt9pALmy5/OFxqAveYlWLp7bnW4/BeszQJ6SfFGYNk09lu1EvdKdutQDLQY2Cq5bqSX8p7Gw5K+ZsfaorLScLmt0/8gusWgzIDaWVXNHH9rq103KnakXFhi+U+OvQ17ByxQCSsnNo+Mg3c12g/DpL1LxoJdff2QVThNGAiHPU5ZaNGlCNk5T/sj1fNBOBI0YTJI5z+CWvv+KvUmafZAVNtz1g2Y5Ev26ujAA1TxiL/0ZtpWkV3fXuNo4TcmSwveeDR2qLP0xw7zDbAjOBUsu4xr28lY8EoLILCSMvc+BQhaa0rmIzdavk7C7psqrFMrFfbjLGwCAajtAN4pGZw12ZGaiAnE3PVBi3xP7vmv0zUC0hpIMswWxe/zKV55yzmmlFjQyS3CxLS9M1JfPXzVAip84cYuGiRLI6wmo6sEpaNNXxjnm3zLZa8SAYEVdh/zfGkVhqC+O/Rz+HK1ge27BohR+Kaf2PoMv9MIOTKjHPefj1txs6g7sHjia11odHfCV7zKtY/19s8ETnO47xL/4XpkYwjN9Yynxtt8PfjkQ35NdfLqNqGAsringJAssXYXCYVmTBnFb2XdIBChNCEKydc9ytcGFAOtCaMqQEjDR44oIUYbAYAryU2O5qwqVCcY1fkb8hV4GSETsMmBUEVe557bIaKct08Tzq5uOcv1QVc5eg/U/5fCugtiWiulUtIRTXz6WQaTVpf8SBGzb/xjPQhTr3UBNvCyGnKLrcMe1ovcCtdXQFpx500otcr4fTSZH4bn4qY99DA/tUVg2/xAfTfM/aZ2TacRsJr3p1VffRlxTnOjA3sH0+AZc3kt6TdHJVYNpuxvcbHWKxG/l1IERph5s5CnHtCUFj70pfbNxVI5a7arFcbRPgq9AqpWqfX2A56H6htPIiy2yP3sSmEWEd4byydNFOqIxJ156ykmtbz/SzPQeGxMoKulBMg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR12MB7914.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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QKza9NbV4timxQpJGqJ3SszsFwrbgu63KVcNhA800KeDHJbC2t9/sZpfu6oPJxnTDWSg6FBWStmiBQEy25qmjahqS5H6TX/gn2XnjJk0tRvT3kWdnx3IxeNFRbrwuI7kH8P9kj+ktCfC0F8Tj/7i04EjAQGMgxbfOYPu0AOdcPF/V9E8Hiiap140ByLLX17KWO5Qgl4CoSO68YZjytdzEJ0cmy1XvW/0OLcu/p9llZobWRxCDuO2i/eZpbKtdxHl8onU+n2uhI9+9KG1oagjccYAOeY+5m1Y4i7dwfnwsICD856LB6+afihTP7vrRdxEbGh4y3AYlmzE5zoQi5oBuB3OC/cZ2g/nuvDNIMyDkdKRjC9e+2T41ese9xNyG+qL5vk9tx/tZ1TmQl5xW1fVwKC/6SNXFDLCulWSm41LDLptot/BAwtWM4P40InZ2K9PbsJIOjVxw7tKL8It/DFp+rJBlnO/3KK6xQclcACMtYDvZFM+SAQ/V3Yi5TAQRK81lxxSEaufmc9Ghu6D8k7lp8EXLKryyp X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26db9f51-f642-45a5-b3fa-08dd15ca5d01 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB7914.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 07:48:24.6652 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WLVUC3JuIrSQwlQhzFy/JFnQRWC16JH06bCEMpo2EWw62+Ru0LpFFjKTfSEcLdlUCPxKZPl9mptEEjZ9vYYScA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8085 There's USB error when tegra board is shutting down: [ 180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113 [ 180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113 [ 180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113 [ 186.157172] tegra-xusb 3610000.usb: xHCI host controller not responding, assume dead [ 186.157858] tegra-xusb 3610000.usb: HC died; cleaning up [ 186.317280] tegra-xusb 3610000.usb: Timeout while waiting for evaluate context command The issue is caused by disabling LPM on already suspended ports. For USB2 LPM, the LPM is already disabled during port suspend. For USB3 LPM, port won't transit to U1/U2 when it's already suspended in U3, hence disabling LPM is only needed for ports that are not suspended. Cc: Wayne Chang Cc: stable@vger.kernel.org Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown") Signed-off-by: Kai-Heng Feng Acked-by: Alan Stern --- v3: Use udev->port_is_suspended which reflects upstream port status v2: Add "Cc: stable@vger.kernel.org" drivers/usb/core/port.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index e7da2fca11a4..c92fb648a1c4 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -452,10 +452,11 @@ static int usb_port_runtime_suspend(struct device *dev) static void usb_port_shutdown(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); + struct usb_device *udev = port_dev->child; - if (port_dev->child) { - usb_disable_usb2_hardware_lpm(port_dev->child); - usb_unlocked_disable_lpm(port_dev->child); + if (udev && !udev->port_is_suspended) { + usb_disable_usb2_hardware_lpm(udev); + usb_unlocked_disable_lpm(udev); } }