From patchwork Tue Aug 24 10:52:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 502111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BA6AC432BE for ; Tue, 24 Aug 2021 10:53:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0457E61371 for ; Tue, 24 Aug 2021 10:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236436AbhHXKx7 (ORCPT ); Tue, 24 Aug 2021 06:53:59 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:43912 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236365AbhHXKx6 (ORCPT ); Tue, 24 Aug 2021 06:53:58 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17OAr9sQ115506; Tue, 24 Aug 2021 05:53:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629802389; bh=/IGhgpyFa7J0glYv6JIPAv7S3dfbMKxisLlEe7ciQag=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=b5MhZ7g5Y9nvFYfzT/jyjuhTsZIp6VnGIIutz/ZQGw+TM+rQR1kgXcVigDqnXDh/W 84Zp5mOoHAuuP3mWnwYsysufr+8XBv/GO0FgymXqgowMvAespmlARLmQThhzgjIobH Bb/yE4JPvj7Qo7tDTilDn05PDmHU/w+ME2XALlUQ= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17OAr9xh046916 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Aug 2021 05:53:09 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 24 Aug 2021 05:53:09 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 24 Aug 2021 05:53:09 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17OAr3Dd129176; Tue, 24 Aug 2021 05:53:07 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern CC: , , Subject: [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Date: Tue, 24 Aug 2021 16:22:58 +0530 Message-ID: <20210824105302.25382-2-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824105302.25382-1-kishon@ti.com> References: <20210824105302.25382-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org No functional change. Since configuration to stop HCD is invoked from multiple places, group all of them in usb_stop_hcd(). Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/core/hcd.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 0f8b7c93310e..c036ba5311b3 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2760,6 +2760,29 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd) usb_put_dev(rhdev); } +/** + * usb_stop_hcd - Halt the HCD + * @hcd: the usb_hcd that has to be halted + * + * Stop the timer and invoke ->stop() callback on the HCD + */ +static void usb_stop_hcd(struct usb_hcd *hcd) +{ + if (!hcd) + return; + + hcd->rh_pollable = 0; + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); + del_timer_sync(&hcd->rh_timer); + + hcd->driver->stop(hcd); + hcd->state = HC_STATE_HALT; + + /* In case the HCD restarted the timer, stop it again. */ + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); + del_timer_sync(&hcd->rh_timer); +} + /** * usb_add_hcd - finish generic HCD structure initialization and register * @hcd: the usb_hcd structure to initialize @@ -2946,13 +2969,7 @@ int usb_add_hcd(struct usb_hcd *hcd, return retval; err_register_root_hub: - hcd->rh_pollable = 0; - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); - hcd->driver->stop(hcd); - hcd->state = HC_STATE_HALT; - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); + usb_stop_hcd(hcd); err_hcd_driver_start: if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) free_irq(irqnum, hcd); @@ -3022,16 +3039,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) * interrupt occurs), but usb_hcd_poll_rh_status() won't invoke * the hub_status_data() callback. */ - hcd->rh_pollable = 0; - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); - - hcd->driver->stop(hcd); - hcd->state = HC_STATE_HALT; - - /* In case the HCD restarted the timer, stop it again. */ - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); + usb_stop_hcd(hcd); if (usb_hcd_is_primary_hcd(hcd)) { if (hcd->irq > 0) From patchwork Tue Aug 24 10:52:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 502690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ABB8C432BE for ; Tue, 24 Aug 2021 10:53:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F01861163 for ; Tue, 24 Aug 2021 10:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236455AbhHXKyB (ORCPT ); Tue, 24 Aug 2021 06:54:01 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:43920 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236434AbhHXKyA (ORCPT ); Tue, 24 Aug 2021 06:54:00 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17OArCqn115512; Tue, 24 Aug 2021 05:53:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629802392; bh=tLtBHAGWvxZ3XAUy2MPek7fmn41zSHEmJFrc52bJeqc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hRqSxxUB9NeMqfQVvSwLC2hfUStQFJ0JCiQiNmbRdYJ5de3J02rnkneYHlSEuC2ez XwuTpkt8ZfMJvmQ89AsVU6sgE+KKg/t4KRGeNCPo6CCfaOB60oAYAk5ncea3/2sOIJ z4OkDOnIcUv18NCU8crZTcnZuYLrnQc5ztJpk9o0= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17OArC5D016236 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Aug 2021 05:53:12 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 24 Aug 2021 05:53:12 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 24 Aug 2021 05:53:12 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17OAr3De129176; Tue, 24 Aug 2021 05:53:09 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern CC: , , Subject: [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Date: Tue, 24 Aug 2021 16:22:59 +0530 Message-ID: <20210824105302.25382-3-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824105302.25382-1-kishon@ti.com> References: <20210824105302.25382-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org No functional change. Add __usb_add_hcd() which takes "register_hub" flag that indicates if roothub has to be registered or not. This is in preparation for allowing xhci to register roothub after the shared hcd is created. The interface for usb_add_hcd() is not modified to make sure there is no USB subsystem wide changes. Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/core/hcd.c | 20 +++++++++++--------- include/linux/usb/hcd.h | 8 ++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index c036ba5311b3..4d7a9f0e2caa 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2788,13 +2788,14 @@ static void usb_stop_hcd(struct usb_hcd *hcd) * @hcd: the usb_hcd structure to initialize * @irqnum: Interrupt line to allocate * @irqflags: Interrupt type flags + * @register_hub: Flag to indicate if roothub has to be registered. * * Finish the remaining parts of generic HCD initialization: allocate the * buffers of consistent memory, register the bus, request the IRQ line, * and call the driver's reset() and start() routines. */ -int usb_add_hcd(struct usb_hcd *hcd, - unsigned int irqnum, unsigned long irqflags) +int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags, + bool register_hub) { int retval; struct usb_device *rhdev; @@ -2959,12 +2960,13 @@ int usb_add_hcd(struct usb_hcd *hcd, } /* starting here, usbcore will pay attention to this root hub */ - retval = register_root_hub(hcd); - if (retval != 0) - goto err_register_root_hub; - - if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) - usb_hcd_poll_rh_status(hcd); + if (register_hub) { + retval = register_root_hub(hcd); + if (retval != 0) + goto err_register_root_hub; + if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) + usb_hcd_poll_rh_status(hcd); + } return retval; @@ -2988,7 +2990,7 @@ int usb_add_hcd(struct usb_hcd *hcd, return retval; } -EXPORT_SYMBOL_GPL(usb_add_hcd); +EXPORT_SYMBOL_GPL(__usb_add_hcd); /** * usb_remove_hcd - shutdown processing for generic HCDs diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 548a028f2dab..2c99cfe20531 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -468,8 +468,8 @@ extern struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd); extern void usb_put_hcd(struct usb_hcd *hcd); extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd); -extern int usb_add_hcd(struct usb_hcd *hcd, - unsigned int irqnum, unsigned long irqflags); +extern int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags, + bool register_hub); extern void usb_remove_hcd(struct usb_hcd *hcd); extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr, @@ -477,6 +477,10 @@ int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr, struct platform_device; extern void usb_hcd_platform_shutdown(struct platform_device *dev); + +#define usb_add_hcd(hcd, irqnum, irqflags) \ + __usb_add_hcd(hcd, irqnum, irqflags, true) + #ifdef CONFIG_USB_HCD_TEST_MODE extern int ehset_single_step_set_feature(struct usb_hcd *hcd, int port); #else From patchwork Tue Aug 24 10:53:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 502110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D83C6C4338F for ; Tue, 24 Aug 2021 10:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD8A961214 for ; Tue, 24 Aug 2021 10:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236575AbhHXKyG (ORCPT ); Tue, 24 Aug 2021 06:54:06 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:43928 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236484AbhHXKyC (ORCPT ); Tue, 24 Aug 2021 06:54:02 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17OArFNe115522; Tue, 24 Aug 2021 05:53:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629802395; bh=H1g1X9IA47qU7hRXNqLolqlyxE7PPZmGK5nBlX+YghY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Hqcns6OxLNjujzMUF3MABlzg86LQdamIxPf3b7VshUnvadFt6ANBRAzG/JM7mQbcE l+ZZFr6ihPvd5b90lPdceoBgRqf/n2qQMtgpMk9vNFQrtAI8NwYbfWbs/tuNJ0stq/ WgCG+ATghT2CpUqbLAsQ24+YF3zuhw+eo+TSHSgA= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17OArEec016279 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Aug 2021 05:53:15 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 24 Aug 2021 05:53:14 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 24 Aug 2021 05:53:14 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17OAr3Df129176; Tue, 24 Aug 2021 05:53:12 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern CC: , , Subject: [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD Date: Tue, 24 Aug 2021 16:23:00 +0530 Message-ID: <20210824105302.25382-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824105302.25382-1-kishon@ti.com> References: <20210824105302.25382-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add support for registering secondary roothub (RH) along with primary HCD. It has been observed with certain PCIe USB cards that as soon as the primary HCD is registered, port status change is handled leading to cold plug devices getting not detected. For such cases, registering both the root hubs along with the second HCD is useful. Signed-off-by: Kishon Vijay Abraham I Suggested-by: Alan Stern --- drivers/usb/core/hcd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 4d7a9f0e2caa..9c8df22a7d9a 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2799,6 +2799,7 @@ int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqfla { int retval; struct usb_device *rhdev; + struct usb_hcd *shared_hcd = NULL; if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) { hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); @@ -2961,6 +2962,15 @@ int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqfla /* starting here, usbcore will pay attention to this root hub */ if (register_hub) { + shared_hcd = hcd->shared_hcd; + if (shared_hcd) { + retval = register_root_hub(shared_hcd); + if (retval != 0) + goto err_register_shared_root_hub; + if (shared_hcd->uses_new_polling && HCD_POLL_RH(shared_hcd)) + usb_hcd_poll_rh_status(shared_hcd); + } + retval = register_root_hub(hcd); if (retval != 0) goto err_register_root_hub; @@ -2972,6 +2982,8 @@ int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqfla err_register_root_hub: usb_stop_hcd(hcd); +err_register_shared_root_hub: + usb_stop_hcd(shared_hcd); err_hcd_driver_start: if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) free_irq(irqnum, hcd); From patchwork Tue Aug 24 10:53:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 502689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DDEDC4338F for ; Tue, 24 Aug 2021 10:53:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFC5761214 for ; Tue, 24 Aug 2021 10:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236484AbhHXKyI (ORCPT ); Tue, 24 Aug 2021 06:54:08 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:59772 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236552AbhHXKyG (ORCPT ); Tue, 24 Aug 2021 06:54:06 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17OArIAI066452; Tue, 24 Aug 2021 05:53:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629802398; bh=3rJTEfJn/oAUbfpfHmC7ElWuOC9zGfOzG9ekrqMw+ac=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oHVgNdzPEHtl128Xqs6hsj3PAAVYXxdKqfvEUuAuGXSWTPtP9+rHQ+7bbkVRa5A5b vl4TLSsQkKTJDmcjkzDgAPY1O+C4cHQL0of2nJZRkUDGkYC9Uac74DUbnx8KcKZSUt x1jdO17xeYfgoJDeZNPgnNesPTvNvbUWao8qMSjE= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17OArH1f016349 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Aug 2021 05:53:17 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 24 Aug 2021 05:53:17 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 24 Aug 2021 05:53:17 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17OAr3Dg129176; Tue, 24 Aug 2021 05:53:15 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern CC: , , Subject: [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Date: Tue, 24 Aug 2021 16:23:01 +0530 Message-ID: <20210824105302.25382-5-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824105302.25382-1-kishon@ti.com> References: <20210824105302.25382-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org No functional change. Add __usb_hcd_pci_probe() which takes "register_hub" flag that indicates if roothub (RH) has to be registered or not. This is in preparation for allowing xhci-pci to register roothub after the shared hcd is created. The interface for usb_hcd_pci_probe() is not modified to make sure there are minimal code changes. Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/core/hcd-pci.c | 11 ++++++----- include/linux/usb/hcd.h | 8 +++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index d630cccd2e6e..65c1f9aee4d1 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -160,6 +160,7 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd, * @dev: USB Host Controller being probed * @id: pci hotplug id connecting controller to HCD framework * @driver: USB HC driver handle + * @register_hub: Flag to indicate of roothub has to be registered or not * * Context: task context, might sleep * @@ -171,8 +172,8 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd, * * Return: 0 if successful. */ -int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, - const struct hc_driver *driver) +int __usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, + const struct hc_driver *driver, bool register_hub) { struct usb_hcd *hcd; int retval; @@ -262,7 +263,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, down_write(&companions_rwsem); dev_set_drvdata(&dev->dev, hcd); for_each_companion(dev, hcd, ehci_pre_add); - retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED); + retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub); if (retval != 0) dev_set_drvdata(&dev->dev, NULL); for_each_companion(dev, hcd, ehci_post_add); @@ -270,7 +271,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, } else { down_read(&companions_rwsem); dev_set_drvdata(&dev->dev, hcd); - retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED); + retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub); if (retval != 0) dev_set_drvdata(&dev->dev, NULL); else @@ -296,7 +297,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); return retval; } -EXPORT_SYMBOL_GPL(usb_hcd_pci_probe); +EXPORT_SYMBOL_GPL(__usb_hcd_pci_probe); /* may be called without controller electrically present */ diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 2c99cfe20531..49c1a8d56b2c 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -493,14 +493,16 @@ static inline int ehset_single_step_set_feature(struct usb_hcd *hcd, int port) #ifdef CONFIG_USB_PCI struct pci_dev; struct pci_device_id; -extern int usb_hcd_pci_probe(struct pci_dev *dev, - const struct pci_device_id *id, - const struct hc_driver *driver); +extern int __usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, + const struct hc_driver *driver, bool register_hub); extern void usb_hcd_pci_remove(struct pci_dev *dev); extern void usb_hcd_pci_shutdown(struct pci_dev *dev); extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev); +#define usb_hcd_pci_probe(dev, id, driver) \ + __usb_hcd_pci_probe(dev, id, driver, true) + #ifdef CONFIG_PM extern const struct dev_pm_ops usb_hcd_pci_pm_ops; #endif From patchwork Tue Aug 24 10:53:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 502109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB86EC4338F for ; Tue, 24 Aug 2021 10:53:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93BC9613B1 for ; Tue, 24 Aug 2021 10:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236586AbhHXKyL (ORCPT ); Tue, 24 Aug 2021 06:54:11 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:59784 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236595AbhHXKyI (ORCPT ); Tue, 24 Aug 2021 06:54:08 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17OArK2d066459; Tue, 24 Aug 2021 05:53:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629802400; bh=JyBRZzPMPceCiPja5vAcH+yb/sDFtlnhdvvXkZdKMEo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=akzbfYVRe3KX5A8KI5FYRh0Rre9pHTUHmjm1Th71MmzbCVJ0Hy2N+fU0kTqYmIKe8 QY7jUIGtZ4IvCBou4O+HOsjZb4nauRR9uCbyICtY+0jv9v2l5gYMfwEZjcthfcCfKb GUW9jOa+APNbj+DygCtr1rUaGiBIbWhL+yGmq8zY= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17OArK8Z072615 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Aug 2021 05:53:20 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 24 Aug 2021 05:53:20 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 24 Aug 2021 05:53:20 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17OAr3Dh129176; Tue, 24 Aug 2021 05:53:18 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern CC: , , Subject: [RFC PATCH 5/5] xhci-pci: Use flag to not register roothub while adding primary HCD Date: Tue, 24 Aug 2021 16:23:02 +0530 Message-ID: <20210824105302.25382-6-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824105302.25382-1-kishon@ti.com> References: <20210824105302.25382-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Invoke __usb_hcd_pci_probe() without setting "register_hub" so that primary roothub is not registered here. Instead it will be registered along with secondary roothub. This is required for cold plugged USB devices to be detected in certain PCIe USB cards (like Inateck USB card). Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/host/xhci-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 1c9a7957c45c..7734ff13aea9 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -397,7 +397,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) * to say USB 2.0, but I'm not sure what the implications would be in * the other parts of the HCD code. */ - retval = usb_hcd_pci_probe(dev, id, &xhci_pci_hc_driver); + retval = __usb_hcd_pci_probe(dev, id, &xhci_pci_hc_driver, 0); if (retval) goto put_runtime_pm;