From patchwork Fri Nov 11 10:18:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Lin X-Patchwork-Id: 624189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51924C433FE for ; Fri, 11 Nov 2022 10:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233600AbiKKKVw (ORCPT ); Fri, 11 Nov 2022 05:21:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233644AbiKKKVc (ORCPT ); Fri, 11 Nov 2022 05:21:32 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2077.outbound.protection.outlook.com [40.107.101.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 321DD13E3D; Fri, 11 Nov 2022 02:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eud8nPScSclxDOJcZS8tI6mH7XJQZFmaKlC5FP9TRu/XedHRefgcwiBF1XKicZEXse6A/OmHiMOmjTuG8i0GUXxwG4Isitrt0KlH9FfcEH2twcDjFO6Z4oOo1iLaOBeuMWWHV4d3cv0AhZfrKnjFnAblGxyzY02b9K60Fx6awK7L26AUlgx68rkpwXL0TIxhUlBl/obGYkgOTuGBo/SPm1efcZ+Em0eJ4mmm3mKMHvzx5EriLaVmSEGNoMXCJElK/e4JEI4XysHL1k8/RndPCFD1tZjdETn2PRJhjG8AkFBpgO5N7NEcpQpkkwSaohfyCHrf03adqb+MuAlKTVItNA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e16U+KjxKRs0sqGQHj2L0rsHXv4IZExtK3Ryb24EgeY=; b=NkST4LGaeP9pf5ctYMeVhqgyXe9SWrUf4Q8Ufcy5HbckcPHB3SjPVQLPcPFenuAXEEwQNPSiqHnGakYTyHUlBTDeFpxTScLYItKWAxAzjamVHcPsvvnPRumBuzHk1ZHsLS1cw1N1X9yolOkcM2rn6sqvOikuKWSE0Jrew4e27a4KNr9W0/XRmc1P/QziVMKE6bDjQFNGi2j+CMn7hs221CBHyw3SI1zwxWpEQ5s6gGgIdfpjkD9XockyIYXBJObaHGLzIUOHwdnmxDktOM289QR8MBhEwaAgTt8x626wVxVq3YV7IPLLmUnvgeJhRVTNCk6c20Cq6vJv7lJMgErecA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=e16U+KjxKRs0sqGQHj2L0rsHXv4IZExtK3Ryb24EgeY=; b=hc3YuF31C9bTpQ6kuvKLYrtvseOROZ12qTNMxAiiUOne13mnOSAZtIrXbhDYipOOjccQFLSFO63tmLT7FYu3vd5IOJtA0EkYgM8vL11wmQ9DbrQmnYzyyAkY8hRVr2JShyy0Mhhx89ilkHFqR86sWBtevYAfLWF8Y8/d1MJP+LYK/hgJmbTq+GczFokao+JsYdewy4sf2L8a1Rc+J1ebcpQRSiNskXpVciwB+6lKpuyDcyo97X8jLmQHSD0rOuL2uUmnsJzpCXxWWOnQAdh9IyzqtOzRg56rYYY8pp2fPa2lS3c/m9RobBB0bNPjZjTyWij09omcBjD45BQWQN2fgQ== Received: from MW3PR05CA0028.namprd05.prod.outlook.com (2603:10b6:303:2b::33) by PH7PR12MB7453.namprd12.prod.outlook.com (2603:10b6:510:20a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 11 Nov 2022 10:20:36 +0000 Received: from CO1NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::3d) by MW3PR05CA0028.outlook.office365.com (2603:10b6:303:2b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.9 via Frontend Transport; Fri, 11 Nov 2022 10:20:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT091.mail.protection.outlook.com (10.13.175.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Fri, 11 Nov 2022 10:20:36 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 11 Nov 2022 02:20:24 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 11 Nov 2022 02:20:24 -0800 Received: from jilin-desktop.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Fri, 11 Nov 2022 02:20:22 -0800 From: Jim Lin To: , , CC: , , , , Jim Lin Subject: [PATCH v7 1/3] xhci: Add hub_control to xhci_driver_overrides Date: Fri, 11 Nov 2022 18:18:11 +0800 Message-ID: <20221111101813.32482-2-jilin@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221111101813.32482-1-jilin@nvidia.com> References: <20221111101813.32482-1-jilin@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT091:EE_|PH7PR12MB7453:EE_ X-MS-Office365-Filtering-Correlation-Id: a8db617d-4ee3-4129-b0bf-08dac3ce5fd8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ijwyOiIerL7vx6CH5wxN309C1m4EGkZ4+NQqCb9P70PPIpIdtCD+V1uyTGsivpvnVdIlsVvHyxPVBF66keUsM7QZG9ind5evldPv8pEckymDAa3cfzuJIzEkjvw9/ECxtdPH/Z0ZIa7GLSTw7FvDMe8hLAlduTTyq3sWIno1nCG85Gc+cARl8JEiWHK6u8oK+3DUKPzySujg0RbBDco2tm/RdzTCIXpO8X6dMTHfzpDFFuWmEqptmDKbii2ibaUPpI/f4PGiSyk3txIakV1vR72b6EnGgBE0cU+RpdobN66FYQv3wDxv5SkfwfkBRVESy/3bOEmiVq5CNg8yurXfYw7O5g4Ra/af2xBiQn2UA6U6nx/rNuc2TeF8c1EA2UNTPrxXERE9gvEb4hOUHGbB7uTr8aI9YAzz2D0zFoTf/idfoDs6z8Zkso6cHPY4xPtmxNnOuUyc+gSn994DGFErsU5raCiZjMKDT9HOpTolM2aBE/CiN7hDwMd4a9cdsmFXhmFI64Sx4D4cml+66yf9uIyT7hGJnVVP+oM2SzDtO6FIRfguwF5AY9Tmy3Hh/+dSIy0u6EcPTFK2NVx9H8j6MDKNOCtdDpOmvxblJoxr0k87Wlbst0RSKu9dh+VR2hwZKGMzrX6yx8nd+tmibA+1JnrlnPQ1JojZc172ckjJywCSWRV2K/OFkqHjOaxxzW1ft0TnAo3VNnufk5+RofYecE8fQts/XZhbAW2h8Q0tVqzh72hJuVWViU1THl12BVu2wGlo6SyKouS4aMbXfiIRBw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(36860700001)(83380400001)(426003)(2906002)(47076005)(40460700003)(8676002)(70586007)(70206006)(4326008)(41300700001)(26005)(36756003)(86362001)(82310400005)(40480700001)(82740400003)(6636002)(316002)(54906003)(7636003)(356005)(110136005)(186003)(2616005)(336012)(6666004)(5660300002)(1076003)(8936002)(107886003)(7696005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 10:20:36.4124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8db617d-4ee3-4129-b0bf-08dac3ce5fd8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7453 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add a hub_control() callback to the xhci_driver_overrides structure to allow host drivers to override the default hub_control function. This is required for Tegra which requires device specific actions for power management to be executed during USB state transitions. Signed-off-by: Jim Lin Reviewed-by: Jon Hunter Tested-by: Jon Hunter Acked-by: Thierry Reding --- v5: new change v6: adjust parameter alignment (xhci.h hub_control) v7: change commit message drivers/usb/host/xhci.c | 2 ++ drivers/usb/host/xhci.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 902f410874e8..3c7bf0a0e0b4 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5461,6 +5461,8 @@ void xhci_init_driver(struct hc_driver *drv, drv->check_bandwidth = over->check_bandwidth; if (over->reset_bandwidth) drv->reset_bandwidth = over->reset_bandwidth; + if (over->hub_control) + drv->hub_control = over->hub_control; } } EXPORT_SYMBOL_GPL(xhci_init_driver); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 5a75fe563123..f51b674fc10c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1943,6 +1943,8 @@ struct xhci_driver_overrides { struct usb_host_endpoint *ep); int (*check_bandwidth)(struct usb_hcd *, struct usb_device *); void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *); + int (*hub_control)(struct usb_hcd *hcd, u16 typeReq, u16 wValue, + u16 wIndex, char *buf, u16 wLength); }; #define XHCI_CFC_DELAY 10 From patchwork Fri Nov 11 10:18:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Lin X-Patchwork-Id: 624427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C9B0C43217 for ; Fri, 11 Nov 2022 10:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233305AbiKKKWK (ORCPT ); Fri, 11 Nov 2022 05:22:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233217AbiKKKVd (ORCPT ); Fri, 11 Nov 2022 05:21:33 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9859E13F8F; Fri, 11 Nov 2022 02:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UpMjcnylY1RME1I7aaL35g2/WEnxBrvq3Ru+LiPZKckyvPfyBZEnThsXk0xB522UTTEtoeMVhVFDt2kwyUxyr+gErI27o3aIah+W/pleSIaoyUD6y4mNVHtwwRquPldXOPI6jiOPT/f8RO4wOaJBZ82hTr0f34LGOFJPQUvvzAmOFmlzVvlsxZW19TiTpLFXZ0EI9N/2DDYEXwGCo25lYhTXt4rjYaPfLpivC5EBN3HUQ3o6dSZyayaySvHR30JRB2gPVO5vmTZFYJ+huCkkTTRa0EzMsOGa8FEvKHdtGva304YcmyQusOWcXMcG8782A3omZL6ZSAIIn6lDjOQ91Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3pAtFPgvHnO2SjScGb+WcStiNW+rvjoDKiE7Cz2zFPs=; b=ZFmDYcwFaiiD/HUUwJ4ZHsp6minugVZnaLL+/q1vbXIiSZ+dHcVwtk/8EhmEMX7lovj8rPtvo5YoVtDJ+y5rpXmTHpFpv8WOF0w5tF29v9M8rfRvgaHDkvT9cIpwtz5CE8E4XgWAZIb5+290UMlJ9TAaSx9L1c5gqABAEHfYK7o4lgd8sOo8gNnemxZfEMC74VjKb4mUG1Rv2dvhbs0Vyi+JvlRDIlIRErP6Gsl/XgccAkkKsDeeCo/mX2C8JRIVdixJZlsDPdPv5JUvZ8r2e847avJPVWM06RRaq3PvIS1ERuLOxjBM1Wk8DjeTpjtix4XSMnp1SuXM8+H2d0U0ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=3pAtFPgvHnO2SjScGb+WcStiNW+rvjoDKiE7Cz2zFPs=; b=Mk7Z37IlvZzPS60nXJnaCVLMhnnS3H/jb/uB87YYkqwwWZeHyGm2V7mJt+WbDpFcLZVvMKXzF7n3PuXeyUkHbz6pYBTxReBbNaToqKJ/ZJBa8add2sJoP7WIFqXLOnU9CSoz8C1F7s7FAkxuM4c64T9JUkFSrm5F/83MF8RzW5V2gm++hySZUmcz8In4gVDnGll8Nxkr1Zm8mOR50pWF2cOQ+1JbC9vfaWR97wLMq9jLmnv9pwXaRl2o39e8qyUvoLjwaUhOAouiudhc8hLbM9STkSOJrBy0U6CwTfUayCyP8nLoeCU5py+4+/w0dMqjYEeErD1MwgqIiCj6M1gi4A== Received: from BN9PR03CA0071.namprd03.prod.outlook.com (2603:10b6:408:fc::16) by DM8PR12MB5429.namprd12.prod.outlook.com (2603:10b6:8:29::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 11 Nov 2022 10:20:41 +0000 Received: from BN8NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fc:cafe::2d) by BN9PR03CA0071.outlook.office365.com (2603:10b6:408:fc::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.14 via Frontend Transport; Fri, 11 Nov 2022 10:20:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT062.mail.protection.outlook.com (10.13.177.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Fri, 11 Nov 2022 10:20:41 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 11 Nov 2022 02:20:26 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 11 Nov 2022 02:20:26 -0800 Received: from jilin-desktop.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Fri, 11 Nov 2022 02:20:24 -0800 From: Jim Lin To: , , CC: , , , , Jim Lin Subject: [PATCH v7 2/3] xhci: hub: export symbol on xhci_hub_control Date: Fri, 11 Nov 2022 18:18:12 +0800 Message-ID: <20221111101813.32482-3-jilin@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221111101813.32482-1-jilin@nvidia.com> References: <20221111101813.32482-1-jilin@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT062:EE_|DM8PR12MB5429:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b2f8fe4-bb29-4969-4ccc-08dac3ce62e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WCwrU3hckzTwNeZGx9wGcuuTYE1FdEzF9cNQFXAzZUlZVhteNw+8l4MgQkp102uS4q4tfVXB/LLTL3v/Z59f7dJsAxRVsbh/V8gzAxwe7eUE/BjWcwjJ0cRXr9r0PRpuAg5TW7TzNB57CvvSmQ8v5GUBtJz8wRuSYF/AHkd558IMyI/NBD8vlAbn/MVpS3e8Tt9YFjT21tFhtdlazcjVuln8ZetF27Pz7vGhbSCKrYVKFw6yiw04HgiTfJE8euCNQT7fGfPJyI6s7g4rff88QchbvjL5hSqvs4NX7zqAOgd+2YngOp+ZjmO9w2e4EOwwHt75kOSZb9vTX/eeSc2f9dJ5ZIbgRwNUW1U3Xdgkm4lyZEEJJRcpH4ivvNmgpssnuB56NYex2ygDnMDyPXP/QAUxy6coPa4G8RdU6cglRVQcptdvLS8T2keLHf0aiVFFhrDspSGCG+KP8d+9Zr9q9tcOHbVJcelfF94TnCz1CWNfkdLwSB87Ln+SOrCVPLkMpKkNoOeqdUXthExQKyjQLoDqEaE7i+TuZMA9t1ZC1KPRWjWAAIUSf9Z2jRHieAxx8hZwMVPhgv3FQaHdEO+1MYw+dyzrrFQtfA+vGLSx+6+iRzPcsVMsWF9XT7nd+HMkw7pu82Y1gZeh4U8wBb8lYl88BByzXjgT1sPvIbwcVrz1b0GCEoX6svB0EmDBE/Wnqy0RIAGDwxxixDfItnIS1p9/X55oyNtPYdYMkGzJEr+QymSI9jtsLLpLexgZzT2blNvw6FStw2FW9gZay0EbSA== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(316002)(47076005)(6636002)(1076003)(2616005)(426003)(336012)(186003)(70206006)(70586007)(26005)(7696005)(6666004)(107886003)(478600001)(2906002)(86362001)(8676002)(40460700003)(4326008)(4744005)(41300700001)(36860700001)(82310400005)(36756003)(5660300002)(82740400003)(8936002)(83380400001)(54906003)(40480700001)(110136005)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 10:20:41.4164 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b2f8fe4-bb29-4969-4ccc-08dac3ce62e7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5429 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org XHCI host drivers may override the default xhci_hub_control() with their own device specific function. To allow these host drivers to call the xhci_hub_control() function from within their own hub_control() callback and be built as a module, export the symbol for xhci_hub_control. Signed-off-by: Jim Lin --- v5: new change v6: modify commit message v7: change commit message drivers/usb/host/xhci-hub.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index af946c42b6f0..4f20cdae2a89 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1604,6 +1604,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, spin_unlock_irqrestore(&xhci->lock, flags); return retval; } +EXPORT_SYMBOL_GPL(xhci_hub_control); /* * Returns 0 if the status hasn't changed, or the number of bytes in buf. From patchwork Fri Nov 11 10:18:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Lin X-Patchwork-Id: 624188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 100BCC43219 for ; Fri, 11 Nov 2022 10:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232963AbiKKKWH (ORCPT ); Fri, 11 Nov 2022 05:22:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233650AbiKKKVc (ORCPT ); Fri, 11 Nov 2022 05:21:32 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4043713D40; Fri, 11 Nov 2022 02:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h83g+PR56DuiphD8Kybf14ovNAEbyeIj+EuP/L/eyK4yS0EjG/gF5aENXmZbagz3vDd82Wgg7tMHiYwlWmzof9SDaopYJ647H7u1phEjiucvs5aH93MgZ6PyjFAD9lPDxljPL2Ctnjdx5tnazAY8ANx5yWDX1MPJTaXTUhLEP+XXpklx3Jaa3yA0RnI9hWJz5creHvT3MrCLRtscM4h3GtvbDJPA3a7RrM3J8GCoH13hQ98K/fcKygK35LSZbXwuzWIcuKMiV5Ylb7HWw3I45zI47tIyG0RxK9XSN8OErxt1OWRRR8f+APDWXJmXp2y2yZ1+HrGoMMorjM6hn9BZ2g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pzoRqvLZptzlUJGIvYAXwvy2O9WYPVPpeVtkFgp892g=; b=A6k29G7XuAXQQK7gAAw/S45haKnvHW4UtGZZzb+aAWGAZ2I/dvwNuV9HyVRsUOZUwE+hW+3FS9VJ9zk1LjSmRSczyjUzbloeGf6jpFq3KrVjzY6Cjbq83UZ1jX2r4YOt4uxMtbDfG/xngWVLucoJt3tvzJmQiMzER48q/JEy7iN+2HSLeXBlrIr5c1NIrGSfs4pcjsTilgcjpKg6iVbxmVcXyUR8BmK3nc+BIVFwj4wHvgp22iy1w3xQZG92/mApPjFOSLLI0MA+o8dEUD951XxXfYTlg8bmxSwIF4cFnda5MpXEyr83IgYvFVjMu9dKr6mUXRMRthaZ0NqQj11thg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=pzoRqvLZptzlUJGIvYAXwvy2O9WYPVPpeVtkFgp892g=; b=jlzj0FG6UPRmNayqqvFeKOdjX2o4F3VKn6H5fZ7i8iUxDAiDfUnWwj9dcMB2QBVy383326XCqo6dySawUv6JxmhEySChTpGGJDN2qmpVUD7fFpQ0/OeeWu3pSMiXWUDPlWVlNnlczt9sGfqcVGQXqyb2PTMvMhNzHNcoidvfMrKys2YmBYyVh66o0a/0qwNJjbQVJciAqpI25aDltGgWK1tViVfAu4ePROp2UiWs53dTPPQ3NzsffJx0ojxkFrRt+QhE4tLPbSMpXNrDVVPrNYEWGQnq7KZjjHdvbhyXJFrU3qIL3ZUTaPJ/AFo0zK7n1QN90TIZWjboz3Erk+0ThA== Received: from MW3PR05CA0025.namprd05.prod.outlook.com (2603:10b6:303:2b::30) by DM4PR12MB6254.namprd12.prod.outlook.com (2603:10b6:8:a5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 11 Nov 2022 10:20:40 +0000 Received: from CO1NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::4b) by MW3PR05CA0025.outlook.office365.com (2603:10b6:303:2b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.8 via Frontend Transport; Fri, 11 Nov 2022 10:20:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT091.mail.protection.outlook.com (10.13.175.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Fri, 11 Nov 2022 10:20:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 11 Nov 2022 02:20:29 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 11 Nov 2022 02:20:28 -0800 Received: from jilin-desktop.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Fri, 11 Nov 2022 02:20:26 -0800 From: Jim Lin To: , , CC: , , , , "Petlozu Pravareshwar" , Jim Lin Subject: [PATCH v7 3/3] xhci: tegra: USB2 pad power controls Date: Fri, 11 Nov 2022 18:18:13 +0800 Message-ID: <20221111101813.32482-4-jilin@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221111101813.32482-1-jilin@nvidia.com> References: <20221111101813.32482-1-jilin@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT091:EE_|DM4PR12MB6254:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ed96838-49a2-4627-ebbb-08dac3ce6227 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p0kvDG3wM/a5ufjF3dNiz7haWpmJBoaszSpQTuCRISNBT4RnVr5SXiO6gpjk1RjSlEeDbbfIQAqnSXTGBYOO9EvQgt8NxP8t2xwkWXqcW5HJluJy0ZHfe+dAPo4gVL7kQQWSjjLRIHhwVagxfQR3t2mD5iWa2K/G0v2aeDKqfixKJba6eOZeZ8TA95CCKqoM+bCEnWqWcdDC9Etx3sqXqJmQCOYmnoYzxHzmRA2BtSE68yo42FR1cTb0Ju9NF0/Gd4WXj575MTr4+aLdsulr6vUEBkgpZNv28s2PZ2eGAQj4Oz+KjJBoqQrSjOQlW6I7SJFUyffJIt2hLAQ0NO7+PPxR4XjBL0GkbeBlUCoCOUphxC9E7jh9UcnwsimQx8QPhIbVYro366OvTPvpL0EDQmtaym52EkVri9SDdy2nL6v1fe3kw3BfHnUBXm3iJnyXodUE00UdFHgsEleqhOjpBe8OJVjiZcr5R7+fiNWLc2oKJ4JAcXHz9yRrEY/yg2PcYW793nsPh1tOrmEwIos0neJx7kfRuQl7Dy2UsdBjoiVmz7J3fTJwq8Wem1JlQ7ajdneCkNiW7rlThdCaJdPF78u+OtoxaUd2wg7vZbJ/VEu6GmDeaCqzODncSs6Q++p2AtSvYjn4Ihh4CU0qeIiiJTcEneyO34gm40ZjIRWjx1eP8tTtoVXrZJk9wcIbdEZvVtwZWt2rcT1/b46kv1ttQKLhqZf4ZatPom7E5pQp6OwPGDbjnox1yhDzqXA+6b3V+eL+Rg0bhkMWIf/7PKLVKQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199015)(46966006)(36840700001)(40470700004)(478600001)(7636003)(356005)(82310400005)(36860700001)(86362001)(1076003)(70586007)(5660300002)(41300700001)(8676002)(186003)(40460700003)(70206006)(36756003)(26005)(4326008)(2616005)(110136005)(54906003)(107886003)(6666004)(7696005)(336012)(8936002)(82740400003)(83380400001)(6636002)(2906002)(316002)(47076005)(426003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 10:20:40.2871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ed96838-49a2-4627-ebbb-08dac3ce6227 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6254 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Petlozu Pravareshwar Program USB2 pad PD controls during port connect/disconnect, port suspend/resume, and test mode, to reduce power consumption on disconnect or suspend. Signed-off-by: Petlozu Pravareshwar Co-developed-by: Jim Lin Signed-off-by: Jim Lin Reviewed-by: Jon Hunter Tested-by: Jon Hunter Acked-by: Thierry Reding --- v2: Fix issue that wrong tegra->phys[] may be accessed on tegra124 v3: No change on copyright v4: Remove hcd_to_tegra_xusb() function which is used only once. v5: Update .hub_control in tegra_xhci_overrides (xhci-tegra.c) Invoke xhci_hub_control() directly (xhci-tegra.c) v6: Change author to Petlozu Changed from u32 to u8 for variable enable_utmi_pad_after_lp0_exit Modified tegra_xhci_disable_phy_wake(), tegra_xhci_program_utmi_power_lp0_exit(), tegra_xhci_hub_control() v7: no change drivers/usb/host/xhci-tegra.c | 125 ++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index c8af2cd2216d..b5ed06ddbbac 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -274,6 +274,7 @@ struct tegra_xusb { bool suspended; struct tegra_xusb_context context; + u8 lp0_utmi_pad_mask; }; static struct hc_driver __read_mostly tegra_xhci_hc_driver; @@ -1951,10 +1952,24 @@ static void tegra_xhci_disable_phy_wake(struct tegra_xusb *tegra) struct tegra_xusb_padctl *padctl = tegra->padctl; unsigned int i; + for (i = 0; i < tegra->num_usb_phys; i++) { + struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i); + + if (!phy) + continue; + + if (tegra_xusb_padctl_remote_wake_detected(padctl, phy)) + tegra_phy_xusb_utmi_pad_power_on(phy); + } + for (i = 0; i < tegra->num_phys; i++) { if (!tegra->phys[i]) continue; + if (tegra_xusb_padctl_remote_wake_detected(padctl, tegra->phys[i])) + dev_dbg(tegra->dev, "%pOF remote wake detected\n", + tegra->phys[i]->dev.of_node); + tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); } } @@ -1972,6 +1987,28 @@ static void tegra_xhci_disable_phy_sleepwalk(struct tegra_xusb *tegra) } } +static void tegra_xhci_program_utmi_power_lp0_exit(struct tegra_xusb *tegra) +{ + unsigned int i, index_to_usb2; + struct phy *phy; + + for (i = 0; i < tegra->soc->num_types; i++) { + if (strcmp(tegra->soc->phy_types[i].name, "usb2") == 0) + index_to_usb2 = i; + } + + for (i = 0; i < tegra->num_usb_phys; i++) { + if (!is_host_mode_phy(tegra, index_to_usb2, i)) + continue; + + phy = tegra_xusb_get_phy(tegra, "usb2", i); + if (tegra->lp0_utmi_pad_mask & BIT(i)) + tegra_phy_xusb_utmi_pad_power_on(phy); + else + tegra_phy_xusb_utmi_pad_power_down(phy); + } +} + static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime) { struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); @@ -1980,6 +2017,7 @@ static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime) unsigned int i; int err; u32 usbcmd; + u32 portsc; dev_dbg(dev, "entering ELPG\n"); @@ -1993,6 +2031,15 @@ static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime) goto out; } + for (i = 0; i < tegra->num_usb_phys; i++) { + if (!xhci->usb2_rhub.ports[i]) + continue; + portsc = readl(xhci->usb2_rhub.ports[i]->addr); + tegra->lp0_utmi_pad_mask &= ~BIT(i); + if (((portsc & PORT_PLS_MASK) == XDEV_U3) || ((portsc & DEV_SPEED_MASK) == XDEV_FS)) + tegra->lp0_utmi_pad_mask |= BIT(i); + } + err = xhci_suspend(xhci, wakeup); if (err < 0) { dev_err(tegra->dev, "failed to suspend XHCI: %d\n", err); @@ -2066,6 +2113,8 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool runtime) phy_power_on(tegra->phys[i]); } + if (tegra->suspended) + tegra_xhci_program_utmi_power_lp0_exit(tegra); tegra_xusb_config(tegra); tegra_xusb_restore_context(tegra); @@ -2437,8 +2486,84 @@ static int tegra_xhci_setup(struct usb_hcd *hcd) return xhci_gen_setup(hcd, tegra_xhci_quirks); } +static int tegra_xhci_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index, + char *buf, u16 length) +{ + struct tegra_xusb *tegra = dev_get_drvdata(hcd->self.controller); + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + struct xhci_hub *rhub; + struct xhci_bus_state *bus_state; + int port = (index & 0xff) - 1; + unsigned int i; + struct xhci_port **ports; + u32 portsc; + int ret; + struct phy *phy; + + rhub = &xhci->usb2_rhub; + bus_state = &rhub->bus_state; + if (bus_state->resuming_ports && hcd->speed == HCD_USB2) { + ports = rhub->ports; + i = rhub->num_ports; + while (i--) { + if (!test_bit(i, &bus_state->resuming_ports)) + continue; + portsc = readl(ports[i]->addr); + if ((portsc & PORT_PLS_MASK) == XDEV_RESUME) + tegra_phy_xusb_utmi_pad_power_on( + tegra_xusb_get_phy(tegra, "usb2", (int) i)); + } + } + + if (hcd->speed == HCD_USB2) { + phy = tegra_xusb_get_phy(tegra, "usb2", port); + if ((type_req == ClearPortFeature) && (value == USB_PORT_FEAT_SUSPEND)) { + if (!index || index > rhub->num_ports) + return -EPIPE; + tegra_phy_xusb_utmi_pad_power_on(phy); + } + if ((type_req == SetPortFeature) && (value == USB_PORT_FEAT_RESET)) { + if (!index || index > rhub->num_ports) + return -EPIPE; + ports = rhub->ports; + portsc = readl(ports[port]->addr); + if (portsc & PORT_CONNECT) + tegra_phy_xusb_utmi_pad_power_on(phy); + } + } + + ret = xhci_hub_control(hcd, type_req, value, index, buf, length); + if (ret < 0) + return ret; + + if (hcd->speed == HCD_USB2) { + /* Use phy where we set previously */ + if ((type_req == SetPortFeature) && (value == USB_PORT_FEAT_SUSPEND)) + /* We don't suspend the PAD while HNP role swap happens on the OTG port */ + if (!((hcd->self.otg_port == (port + 1)) && hcd->self.b_hnp_enable)) + tegra_phy_xusb_utmi_pad_power_down(phy); + + if ((type_req == ClearPortFeature) && (value == USB_PORT_FEAT_C_CONNECTION)) { + ports = rhub->ports; + portsc = readl(ports[port]->addr); + if (!(portsc & PORT_CONNECT)) { + /* We don't suspend the PAD while HNP role swap happens on the OTG + * port + */ + if (!((hcd->self.otg_port == (port + 1)) && hcd->self.b_hnp_enable)) + tegra_phy_xusb_utmi_pad_power_down(phy); + } + } + if ((type_req == SetPortFeature) && (value == USB_PORT_FEAT_TEST)) + tegra_phy_xusb_utmi_pad_power_on(phy); + } + + return ret; +} + static const struct xhci_driver_overrides tegra_xhci_overrides __initconst = { .reset = tegra_xhci_setup, + .hub_control = tegra_xhci_hub_control, }; static int __init tegra_xusb_init(void)