From patchwork Fri Mar 4 18:34:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12769815 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 276F1C433EF for ; Fri, 4 Mar 2022 18:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241752AbiCDSiX (ORCPT ); Fri, 4 Mar 2022 13:38:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241797AbiCDSiG (ORCPT ); Fri, 4 Mar 2022 13:38:06 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58EEA1D67C5 for ; Fri, 4 Mar 2022 10:37:18 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id dr20so19203283ejc.6 for ; Fri, 04 Mar 2022 10:37:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=efc4guVCDN5LLszeccB5jtPV6jvB3vn6Khwu7Qxa6tM=; b=LZg6Jion2ZkKJ7hUMFyw4XZ+eubN222n4hmMpGu3OjwFYtLgKWGAMUUw85CQOYWYn0 5LhbauI/dlm+oMaeSgFZKxR0WwnXFRTZZVzWFYFePGHQyywidN0AY4AlffOyfR36/KRN AMP/yVWp0+s/SGQjKnjJxWRjstZSnQzQt/4mp22RoI5p6I1QOnGdjiME/F5egK5DubKb 7c4JH5/D1jtvjLTrORK5YUOYpVJmpw6j76/0M6WbgjfrdnWFY8JpTCaEeHjcXbhXuO+9 2sy6du1YCle+8eb2IixVEkdjfebJ7bpxwp5FN5WT3AjHLOTX+6f25n4P+Dc4tDXbLYkC f5PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=efc4guVCDN5LLszeccB5jtPV6jvB3vn6Khwu7Qxa6tM=; b=xDHSJtzapXsNyGFsNZkUMcE3m62luaQ5x8b+FSo1xJzZj/J0xMlQ/9KhnSSvtPBf5p Khu3OnxL1tjRWTbznXhN4NgQs8awcQkFmpqln8oH33+oU42RCF0NvlgDob0U5M6MzsQO QZHy5watw9y4CQNYaTH1BLj9Fwb8sFrZ0RI+LLt7wkT0LUfeV5GVXrzfEgbaBmlOo23X aw5W/6R++1kCVpAlg73n+lIUQkkr0TbtPRNuTnFrvQUocweD9Uhp+Mkew2xLj5ayuWsM ptHp3nuZ92ObGLn3AbqLt+RKmxu7ETl2i/hvmhev6m1EhidtNAQa7xqEY7Qkm2eFa4lW XVoQ== X-Gm-Message-State: AOAM531s5vqn+s1/lNAAJW4Pr0p/rNtawplJ1PdjCYS/4L54u3GDRBcM fb0fSuZpFQM0M09iQgQOXv8= X-Google-Smtp-Source: ABdhPJyvHiAA3DD5YgAzFHTnBnsK5rKnQbyYUO8i16bupKT9nZRDm1Ej7ZhF0RGK39BBKHO4rd0aDw== X-Received: by 2002:a17:906:8616:b0:6ce:36ab:a289 with SMTP id o22-20020a170906861600b006ce36aba289mr44145ejx.127.1646419036915; Fri, 04 Mar 2022 10:37:16 -0800 (PST) Received: from ?IPV6:2a01:c23:b9fb:2800:c56d:9b34:f61c:e318? (dynamic-2a01-0c23-b9fb-2800-c56d-9b34-f61c-e318.c23.pool.telefonica.de. [2a01:c23:b9fb:2800:c56d:9b34:f61c:e318]) by smtp.googlemail.com with ESMTPSA id s14-20020aa7cb0e000000b00410bf015567sm2344863edt.92.2022.03.04.10.37.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 10:37:16 -0800 (PST) Message-ID: Date: Fri, 4 Mar 2022 19:34:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 1/5] usb: host: xhci-plat: create shared hcd after having added main hcd Content-Language: en-US From: Heiner Kallweit To: Mathias Nyman , Greg Kroah-Hartman Cc: Linux USB Mailing List , "open list:ARM/Amlogic Meson..." , Alan Stern , Jack Pham , Tung Nguyen References: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> In-Reply-To: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch is in preparation of an extension where in case of a root hub with no ports no shared hcd will be created. Whether one of the root hubs has no ports we figure our in usb_add_hcd() for the primary hcd. Therefore create the shared hcd only after this call. Signed-off-by: Heiner Kallweit --- drivers/usb/host/xhci-plat.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 8094da348..484c7fe3e 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -294,12 +294,6 @@ static int xhci_plat_probe(struct platform_device *pdev) device_set_wakeup_capable(&pdev->dev, true); xhci->main_hcd = hcd; - xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, - dev_name(&pdev->dev), hcd); - if (!xhci->shared_hcd) { - ret = -ENOMEM; - goto disable_clk; - } /* imod_interval is the interrupt moderation value in nanoseconds. */ xhci->imod_interval = 40000; @@ -324,16 +318,15 @@ static int xhci_plat_probe(struct platform_device *pdev) if (IS_ERR(hcd->usb_phy)) { ret = PTR_ERR(hcd->usb_phy); if (ret == -EPROBE_DEFER) - goto put_usb3_hcd; + goto disable_clk; hcd->usb_phy = NULL; } else { ret = usb_phy_init(hcd->usb_phy); if (ret) - goto put_usb3_hcd; + goto disable_clk; } hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); - xhci->shared_hcd->tpl_support = hcd->tpl_support; if (priv) { ret = xhci_priv_plat_setup(hcd); @@ -351,12 +344,21 @@ static int xhci_plat_probe(struct platform_device *pdev) if (ret) goto disable_usb_phy; + xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, + dev_name(&pdev->dev), hcd); + if (!xhci->shared_hcd) { + ret = -ENOMEM; + goto dealloc_usb2_hcd; + } + + xhci->shared_hcd->tpl_support = hcd->tpl_support; + if (HCC_MAX_PSA(xhci->hcc_params) >= 4) xhci->shared_hcd->can_do_streams = 1; ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); if (ret) - goto dealloc_usb2_hcd; + goto put_usb3_hcd; device_enable_async_suspend(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); @@ -370,15 +372,15 @@ static int xhci_plat_probe(struct platform_device *pdev) return 0; +put_usb3_hcd: + usb_put_hcd(xhci->shared_hcd); + dealloc_usb2_hcd: usb_remove_hcd(hcd); disable_usb_phy: usb_phy_shutdown(hcd->usb_phy); -put_usb3_hcd: - usb_put_hcd(xhci->shared_hcd); - disable_clk: clk_disable_unprepare(xhci->clk); From patchwork Fri Mar 4 18:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12769817 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 ABB10C433F5 for ; Fri, 4 Mar 2022 18:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241497AbiCDSi0 (ORCPT ); Fri, 4 Mar 2022 13:38:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241800AbiCDSiI (ORCPT ); Fri, 4 Mar 2022 13:38:08 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 963911D67C6 for ; Fri, 4 Mar 2022 10:37:19 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id s1so11829134edd.13 for ; Fri, 04 Mar 2022 10:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=mGk3B+K5X2U3dvLx49arF2t8VsVYc/Id6UewkzTupAo=; b=e2qFauSTQG/Loa6Oix2tFUduzULhvcwiVp79xPGKWN6L/ilCJ9l+/eBUPaqQTcfysf O1SnQkIGxeTRPC8GCDd5LasU4WLq190RqZeESWliMvfkjtofDAHR3k6IagXREs/r18UW DqrUtZH3cl8mL5oCa5zHjN9FA6rF+nOlNbz1T9J4Z5wQWIpfI49zjxp/HIOdwNehx8bb EGuCoobOoAz1BFhMHKzMxE3qKdIo550uRMMjKQRsxFjWnO7sRP2RQAHtfLIhJWXEGR7y UJhYsEcZD24kEFIPMybPNRVKlxfRFmXq4Vn6W4AfOp1tiusHQN8EQeNyHCWS5iyFxvyv hwjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=mGk3B+K5X2U3dvLx49arF2t8VsVYc/Id6UewkzTupAo=; b=m8qN2KHdIM9XL+78ivk+uWY44DJsbOctoK7uPT9w0pAAINUCQ9mgu3jRMDCbT69vjI Eokycnvh8jxZcjfe4KL+SCEtYlaQk86BgRNXE4D8h/zyZS6OAKNxoOmPDY47ggR1u8wo cECQIcMtNG1VEccQagxM0yQ+ElMytEaFm7dEJ8q2NNWUkEU/e9ww6TDlYPGIurguDhtY cdJii/Y54UXwomiTHlY4d/wE/OdoVJE/omW2E4PUnjWogqOSeYmESM60uoSKJR3401Zu 2rohJr39oGFfmVOVPMe7C0S4Z032HcPEQx4mrZodmqewK5b1NcBsLKy8ut0dEb8tNid8 iT5Q== X-Gm-Message-State: AOAM532gmQtcMsjDcM4CRXWR2Xkz7BxDKFlWfMzAbXcvXjJEAtgBL1Sw J3jafN9HPJrxGU+InamoCRJhMGJ3D6s= X-Google-Smtp-Source: ABdhPJzYMYDDT5Ov/FZHvyxLPinCXEOOwQE5zvU6h91XO1oiBb6BS0hplIqImKaO9CUthAy2Ho5Fcw== X-Received: by 2002:a05:6402:270a:b0:410:63d:a66d with SMTP id y10-20020a056402270a00b00410063da66dmr40653526edd.48.1646419038088; Fri, 04 Mar 2022 10:37:18 -0800 (PST) Received: from ?IPV6:2a01:c23:b9fb:2800:c56d:9b34:f61c:e318? (dynamic-2a01-0c23-b9fb-2800-c56d-9b34-f61c-e318.c23.pool.telefonica.de. [2a01:c23:b9fb:2800:c56d:9b34:f61c:e318]) by smtp.googlemail.com with ESMTPSA id r11-20020aa7cfcb000000b00412c58c43ccsm2434601edy.37.2022.03.04.10.37.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 10:37:17 -0800 (PST) Message-ID: <816c881a-dca4-7730-54b5-85cc640ea88e@gmail.com> Date: Fri, 4 Mar 2022 19:35:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 2/5] xhci: factor out parts of xhci_gen_setup() Content-Language: en-US From: Heiner Kallweit To: Mathias Nyman , Greg Kroah-Hartman Cc: Linux USB Mailing List , "open list:ARM/Amlogic Meson..." , Alan Stern , Jack Pham , Tung Nguyen References: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> In-Reply-To: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Factoring out parts of xhci_gen_setup() has two motivations: - When adding functionaliy to omit shared hcd if not needed in a subsequent patch, we'll have to call xhci_hcd_init_usb3_data() from two places. - It reduces size of xhci_gen_setup() and makes it better readable. Signed-off-by: Heiner Kallweit --- drivers/usb/host/xhci.c | 104 +++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a1c781f70..824b833ae 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5195,6 +5195,57 @@ static int xhci_get_frame(struct usb_hcd *hcd) return readl(&xhci->run_regs->microframe_index) >> 3; } +static void xhci_hcd_init_usb2_data(struct xhci_hcd *xhci, struct usb_hcd *hcd) +{ + xhci->usb2_rhub.hcd = hcd; + hcd->speed = HCD_USB2; + hcd->self.root_hub->speed = USB_SPEED_HIGH; + /* + * USB 2.0 roothub under xHCI has an integrated TT, + * (rate matching hub) as opposed to having an OHCI/UHCI + * companion controller. + */ + hcd->has_tt = 1; +} + +static void xhci_hcd_init_usb3_data(struct xhci_hcd *xhci, struct usb_hcd *hcd) +{ + unsigned int minor_rev; + + /* + * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts + * should return 0x31 for sbrn, or that the minor revision + * is a two digit BCD containig minor and sub-minor numbers. + * This was later clarified in xHCI 1.2. + * + * Some USB 3.1 capable hosts therefore have sbrn 0x30, and + * minor revision set to 0x1 instead of 0x10. + */ + if (xhci->usb3_rhub.min_rev == 0x1) + minor_rev = 1; + else + minor_rev = xhci->usb3_rhub.min_rev / 0x10; + + switch (minor_rev) { + case 2: + hcd->speed = HCD_USB32; + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; + hcd->self.root_hub->rx_lanes = 2; + hcd->self.root_hub->tx_lanes = 2; + hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x2; + break; + case 1: + hcd->speed = HCD_USB31; + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; + hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x1; + break; + } + xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", + minor_rev, minor_rev ? "Enhanced " : ""); + + xhci->usb3_rhub.hcd = hcd; +} + int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) { struct xhci_hcd *xhci; @@ -5203,7 +5254,6 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) * quirks */ struct device *dev = hcd->self.sysdev; - unsigned int minor_rev; int retval; /* Accept arbitrarily long scatter-gather lists */ @@ -5218,60 +5268,14 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) xhci = hcd_to_xhci(hcd); if (usb_hcd_is_primary_hcd(hcd)) { - xhci->main_hcd = hcd; - xhci->usb2_rhub.hcd = hcd; - /* Mark the first roothub as being USB 2.0. - * The xHCI driver will register the USB 3.0 roothub. - */ - hcd->speed = HCD_USB2; - hcd->self.root_hub->speed = USB_SPEED_HIGH; - /* - * USB 2.0 roothub under xHCI has an integrated TT, - * (rate matching hub) as opposed to having an OHCI/UHCI - * companion controller. - */ - hcd->has_tt = 1; + xhci_hcd_init_usb2_data(xhci, hcd); } else { - /* - * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts - * should return 0x31 for sbrn, or that the minor revision - * is a two digit BCD containig minor and sub-minor numbers. - * This was later clarified in xHCI 1.2. - * - * Some USB 3.1 capable hosts therefore have sbrn 0x30, and - * minor revision set to 0x1 instead of 0x10. - */ - if (xhci->usb3_rhub.min_rev == 0x1) - minor_rev = 1; - else - minor_rev = xhci->usb3_rhub.min_rev / 0x10; - - switch (minor_rev) { - case 2: - hcd->speed = HCD_USB32; - hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; - hcd->self.root_hub->rx_lanes = 2; - hcd->self.root_hub->tx_lanes = 2; - hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x2; - break; - case 1: - hcd->speed = HCD_USB31; - hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; - hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x1; - break; - } - xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", - minor_rev, - minor_rev ? "Enhanced " : ""); - - xhci->usb3_rhub.hcd = hcd; - /* xHCI private pointer was set in xhci_pci_probe for the second - * registered roothub. - */ + xhci_hcd_init_usb3_data(xhci, hcd); return 0; } mutex_init(&xhci->mutex); + xhci->main_hcd = hcd; xhci->cap_regs = hcd->regs; xhci->op_regs = hcd->regs + HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)); From patchwork Fri Mar 4 18:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12769818 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 08389C433EF for ; Fri, 4 Mar 2022 18:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235180AbiCDSi2 (ORCPT ); Fri, 4 Mar 2022 13:38:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241810AbiCDSiL (ORCPT ); Fri, 4 Mar 2022 13:38:11 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 686401D5290 for ; Fri, 4 Mar 2022 10:37:22 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id qa43so19171527ejc.12 for ; Fri, 04 Mar 2022 10:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=SYFoL4D1TXW6vhl6Uq63PkI2yEgwRuD0c8R2wUDDQ0A=; b=clS+8kUmRSaQXoUk87EHXNmflU7Ep87W139tLGWGxm00HMS3obhmUorFqddEIt82S3 2kxYxJ74Rd8wzKYLcF9vlq0PuvV+RVV0S05/iS9YrO4Qlout+6RsPnvrlrlUM+zVjHbR FQMkjsG7sXV4XMcb6WFf1isPWt9jt8R86yUgZUqYXzg8FMo4qtzBkslExmrnPHWrh9vd mpEufS6njeO9/EQkQ1GSEkc8gqQLpUSK533F1NNaGhstLCmx5Nl1hojBm1RdAgcRF7cD lomManIYtn0boPCH1QEvMZSGHNOrNFjpwIihOffyvj/zVwakITTIFRw7Oo36WW53j1bk hUnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=SYFoL4D1TXW6vhl6Uq63PkI2yEgwRuD0c8R2wUDDQ0A=; b=ldTs758r2aKAG1ucy5a3nPsOUekXl0X8P1MxTvSYp4zWi57nUzsOsyilLWzPMyhW/r u8Krj6Ejn97kJ10HZdy7UzM46/z45LG931pdvNs2uvs+I36+kWrRtd5m5b3a32WWH6wn pRgK6N4BQAyM7wnJcc3XcQ37eL++NExU+kE5Fou9EQp4kofMvtx0pVeiTyxlPiNJZmbN CmVjXwSxbxXgU76nxTWkWlxY4nkVaGPMB1craPrge79CrYv2Znn27foJDo+DdUVa2ebg WFYK3c+FquiqFibofpTXZE6uL83fJsh14lphXB2oEw7u+kDhNezV+CIhbgqNHm/G4q+E hosQ== X-Gm-Message-State: AOAM531A+cY6/LVC9GoA3mhoKdQdsyJuB9nmc+g25oPIhxu4TFwQpsrW MUAcmj1u/nAfnb8VQXniDxE= X-Google-Smtp-Source: ABdhPJyMXawA4GkZPl4adIYw+UP7H/jKaZXiuP8FFuy7XKpuR8hmX0Rk/dFGyvp9GCaRO1iaVSEJKQ== X-Received: by 2002:a17:906:bc9b:b0:6da:9f90:a56a with SMTP id lv27-20020a170906bc9b00b006da9f90a56amr24469ejb.575.1646419040041; Fri, 04 Mar 2022 10:37:20 -0800 (PST) Received: from ?IPV6:2a01:c23:b9fb:2800:c56d:9b34:f61c:e318? (dynamic-2a01-0c23-b9fb-2800-c56d-9b34-f61c-e318.c23.pool.telefonica.de. [2a01:c23:b9fb:2800:c56d:9b34:f61c:e318]) by smtp.googlemail.com with ESMTPSA id lj2-20020a170906f9c200b006da6f29bc01sm2012594ejb.158.2022.03.04.10.37.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 10:37:19 -0800 (PST) Message-ID: <2a1c1f6c-bd3f-b0cb-f90d-fc3b8c37c580@gmail.com> Date: Fri, 4 Mar 2022 19:35:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 3/5] xhci: prepare for operation w/o shared hcd Content-Language: en-US From: Heiner Kallweit To: Mathias Nyman , Greg Kroah-Hartman Cc: Linux USB Mailing List , "open list:ARM/Amlogic Meson..." , Alan Stern , Jack Pham , Tung Nguyen References: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> In-Reply-To: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch prepares xhci for the following scenario: - If either of the root hubs has no ports, then omit shared hcd - Main hcd can be USB3 if there are no USB2 ports Signed-off-by: Heiner Kallweit --- drivers/usb/host/xhci-hub.c | 3 ++- drivers/usb/host/xhci-mem.c | 4 +++- drivers/usb/host/xhci.c | 44 +++++++++++++++++++++++-------------- drivers/usb/host/xhci.h | 20 +++++++++++++++++ 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index df3522dab..7931c7612 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -707,6 +707,7 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci, u16 test_mode, u16 wIndex, unsigned long *flags) __must_hold(&xhci->lock) { + struct usb_hcd *usb3_hcd = xhci_get_usb3_hcd(xhci); int i, retval; /* Disable all Device Slots */ @@ -727,7 +728,7 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci, xhci_dbg(xhci, "Disable all port (PP = 0)\n"); /* Power off USB3 ports*/ for (i = 0; i < xhci->usb3_rhub.num_ports; i++) - xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags); + xhci_set_port_power(xhci, usb3_hcd, i, false, flags); /* Power off USB2 ports*/ for (i = 0; i < xhci->usb2_rhub.num_ports; i++) xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags); diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index f8c2b6c79..a1a17713a 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1072,7 +1072,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, struct usb_hcd *hcd; if (udev->speed >= USB_SPEED_SUPER) - hcd = xhci->shared_hcd; + hcd = xhci_get_usb3_hcd(xhci); else hcd = xhci->main_hcd; @@ -2362,6 +2362,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) xhci->usb2_rhub.num_ports = USB_MAXCHILDREN; } + xhci->needs_shared_hcd = 1; + /* * Note we could have all USB 3.0 ports, or all USB 2.0 ports. * Not sure how the USB core will handle a hub with no ports... diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 824b833ae..83a54a566 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -485,6 +485,10 @@ static void compliance_mode_recovery(struct timer_list *t) xhci = from_timer(xhci, t, comp_mode_recovery_timer); rhub = &xhci->usb3_rhub; + hcd = rhub->hcd; + + if (!hcd) + return; for (i = 0; i < rhub->num_ports; i++) { temp = readl(rhub->ports[i]->addr); @@ -498,7 +502,6 @@ static void compliance_mode_recovery(struct timer_list *t) i + 1); xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, "Attempting compliance mode recovery"); - hcd = xhci->shared_hcd; if (hcd->state == HC_STATE_SUSPENDED) usb_hcd_resume_root_hub(hcd); @@ -611,14 +614,11 @@ static int xhci_run_finished(struct xhci_hcd *xhci) xhci_halt(xhci); return -ENODEV; } - xhci->shared_hcd->state = HC_STATE_RUNNING; xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; if (xhci->quirks & XHCI_NEC_HOST) xhci_ring_cmd_db(xhci); - xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "Finished xhci_run for USB3 roothub"); return 0; } @@ -693,12 +693,15 @@ int xhci_run(struct usb_hcd *hcd) xhci_free_command(xhci, command); } xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "Finished xhci_run for USB2 roothub"); + "Finished %s for main hcd", __func__); xhci_create_dbc_dev(xhci); xhci_debugfs_init(xhci); + if (!xhci->needs_shared_hcd) + return xhci_run_finished(xhci); + return 0; } EXPORT_SYMBOL_GPL(xhci_run); @@ -980,7 +983,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) return 0; if (hcd->state != HC_STATE_SUSPENDED || - xhci->shared_hcd->state != HC_STATE_SUSPENDED) + (xhci->shared_hcd && xhci->shared_hcd->state != HC_STATE_SUSPENDED)) return -EINVAL; /* Clear root port wake on bits if wakeup not allowed. */ @@ -997,15 +1000,18 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) __func__, hcd->self.busnum); clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); del_timer_sync(&hcd->rh_timer); - clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); - del_timer_sync(&xhci->shared_hcd->rh_timer); + if (xhci->shared_hcd) { + clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); + del_timer_sync(&xhci->shared_hcd->rh_timer); + } if (xhci->quirks & XHCI_SUSPEND_DELAY) usleep_range(1000, 1500); spin_lock_irq(&xhci->lock); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); + if (xhci->shared_hcd) + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); /* step 1: stop endpoint */ /* skipped assuming that port suspend has done */ @@ -1105,7 +1111,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) msleep(100); set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); + if (xhci->shared_hcd) + set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); spin_lock_irq(&xhci->lock); @@ -1165,7 +1172,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) /* Let the USB core know _both_ roothubs lost power. */ usb_root_hub_lost_power(xhci->main_hcd->self.root_hub); - usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub); + if (xhci->shared_hcd) + usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub); xhci_dbg(xhci, "Stop HCD\n"); xhci_halt(xhci); @@ -1205,12 +1213,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) xhci_dbg(xhci, "Start the primary HCD\n"); retval = xhci_run(hcd->primary_hcd); - if (!retval) { + if (!retval && secondary_hcd) { xhci_dbg(xhci, "Start the secondary HCD\n"); retval = xhci_run(secondary_hcd); } hcd->state = HC_STATE_SUSPENDED; - xhci->shared_hcd->state = HC_STATE_SUSPENDED; + if (xhci->shared_hcd) + xhci->shared_hcd->state = HC_STATE_SUSPENDED; goto done; } @@ -1248,7 +1257,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) } if (pending_portevent) { - usb_hcd_resume_root_hub(xhci->shared_hcd); + if (xhci->shared_hcd) + usb_hcd_resume_root_hub(xhci->shared_hcd); usb_hcd_resume_root_hub(hcd); } } @@ -1267,8 +1277,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) /* Re-enable port polling. */ xhci_dbg(xhci, "%s: starting usb%d port polling.\n", __func__, hcd->self.busnum); - set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); - usb_hcd_poll_rh_status(xhci->shared_hcd); + if (xhci->shared_hcd) { + set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); + usb_hcd_poll_rh_status(xhci->shared_hcd); + } set_bit(HCD_FLAG_POLL_RH, &hcd->flags); usb_hcd_poll_rh_status(hcd); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8a0026ee9..2edc910d9 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1908,6 +1908,8 @@ struct xhci_hcd { unsigned hw_lpm_support:1; /* Broken Suspend flag for SNPS Suspend resume issue */ unsigned broken_suspend:1; + /* Indicates that a shared hcd is needed */ + unsigned needs_shared_hcd:1; /* cached usb2 extened protocol capabilites */ u32 *ext_caps; unsigned int num_ext_caps; @@ -1963,6 +1965,24 @@ static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci) return xhci->main_hcd; } +static inline struct usb_hcd *xhci_get_usb3_hcd(struct xhci_hcd *xhci) +{ + if (xhci->shared_hcd) + return xhci->shared_hcd; + + if (!xhci->usb2_rhub.num_ports) + return xhci->main_hcd; + + return NULL; +} + +static inline bool xhci_hcd_is_usb3(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + + return hcd == xhci_get_usb3_hcd(xhci); +} + #define xhci_dbg(xhci, fmt, args...) \ dev_dbg(xhci_to_hcd(xhci)->self.controller , fmt , ## args) #define xhci_err(xhci, fmt, args...) \ From patchwork Fri Mar 4 18:36:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12769816 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 4A1C1C433FE for ; Fri, 4 Mar 2022 18:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237349AbiCDSiZ (ORCPT ); Fri, 4 Mar 2022 13:38:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241813AbiCDSiL (ORCPT ); Fri, 4 Mar 2022 13:38:11 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 609411D67C5 for ; Fri, 4 Mar 2022 10:37:23 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id gb39so19215408ejc.1 for ; Fri, 04 Mar 2022 10:37:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=09N1QN49YKxRhEIn1LjCDFBtShHoPdeuFT9UB97L/Cw=; b=Dq+QfdPMGLA6HE1ym+z7hDcxBF6iwrTk2XShYDu2DGXGBdaGhKmeZGOJ88ej7U92lP zRXDk1UGs1qTDhhf4Q65bCVp2YSu76UGjiCbcVpL9CJHjrLLp4LdqIQDYVfErtGUp7Dx 769BVNy/SzeTdpCaeRYdfxddWLc1WaNhwVAIffV6Zqrf0JUNWhP+75ug9YABSRPsVHWv sp2UKAhaKDOoJRfYzEHf9lTxOXDeFsj3FyLce0z/F/yj3LFCsHjpPpu4ycyNKfda/zl/ 5dD8h1ofH/q7fq5wxzyBrheSQPAMWeALb2unU3CowR4RcSb5UyhwLfL43MEv40B9ZlEL ocqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=09N1QN49YKxRhEIn1LjCDFBtShHoPdeuFT9UB97L/Cw=; b=g/98jsZnlJDdkX2qv1aVd7+0J1TCYADhsFvsqHEdeEQKCWN6oUboDg6XwTqGyZyJaj ZEREAQ92JKiNaW3aFeugYXr3soS8kOU2PntDDR/GVIhyk8wbbEXSgDDmoJndCgM7k5oR IwSpY/PiTG7TN2D5+WWzqoJm6kOa261m8muzkGnTwnxJxZ5BCessOWfx6KbqBwyqXdTu 2Gkewb+Es/tXbJ0+d7/JF9Xyda57JF6FXPnzKcSRuC/gdlN4uTKNTGAZXNHI1+c8nIVM W9Wt+wi6uCSzsr8FudNioxGMxMYLTqw7ShWBW3soYDXrgkbxLpNTStp67Xcwl4Ag6wue YGsg== X-Gm-Message-State: AOAM530A0yiRrjcAOe15Vvw50JcS5G1G41kfcFFuz8NKQ9R8duqp0XyL 2/OUMIuu969NEQRzo0WM54c= X-Google-Smtp-Source: ABdhPJzeJcGwu1DKue/A6+wQ2Hnx/O0WYJ3eZscuyHECzbbA79iTk3Y/ds1fUUSYaBfzJJAf6UzaKg== X-Received: by 2002:a17:906:aed4:b0:6da:aa56:c923 with SMTP id me20-20020a170906aed400b006daaa56c923mr80865ejb.148.1646419041874; Fri, 04 Mar 2022 10:37:21 -0800 (PST) Received: from ?IPV6:2a01:c23:b9fb:2800:c56d:9b34:f61c:e318? (dynamic-2a01-0c23-b9fb-2800-c56d-9b34-f61c-e318.c23.pool.telefonica.de. [2a01:c23:b9fb:2800:c56d:9b34:f61c:e318]) by smtp.googlemail.com with ESMTPSA id f6-20020a50fc86000000b0040f614e0906sm2383081edq.46.2022.03.04.10.37.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 10:37:21 -0800 (PST) Message-ID: <854f54a4-44bc-2a54-89e9-ae2486068d35@gmail.com> Date: Fri, 4 Mar 2022 19:36:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 4/5] usb: host: xhci-plat: prepare operation w/o shared hcd Content-Language: en-US From: Heiner Kallweit To: Mathias Nyman , Greg Kroah-Hartman Cc: Linux USB Mailing List , "open list:ARM/Amlogic Meson..." , Alan Stern , Jack Pham , Tung Nguyen References: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> In-Reply-To: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch prepares xhci-plat for the following scenario - If either of the root hubs has no ports, then omit shared hcd - Main hcd can be USB3 if there are no USB2 ports Signed-off-by: Heiner Kallweit --- drivers/usb/host/xhci-plat.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 484c7fe3e..0177d8564 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -191,7 +191,7 @@ static int xhci_plat_probe(struct platform_device *pdev) struct device *sysdev, *tmpdev; struct xhci_hcd *xhci; struct resource *res; - struct usb_hcd *hcd; + struct usb_hcd *hcd, *usb3_hcd; int ret; int irq; struct xhci_plat_priv *priv = NULL; @@ -344,21 +344,26 @@ static int xhci_plat_probe(struct platform_device *pdev) if (ret) goto disable_usb_phy; - xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, - dev_name(&pdev->dev), hcd); - if (!xhci->shared_hcd) { - ret = -ENOMEM; - goto dealloc_usb2_hcd; - } + if (xhci->needs_shared_hcd) { + xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, + dev_name(&pdev->dev), hcd); + if (!xhci->shared_hcd) { + ret = -ENOMEM; + goto dealloc_usb2_hcd; + } - xhci->shared_hcd->tpl_support = hcd->tpl_support; + xhci->shared_hcd->tpl_support = hcd->tpl_support; + } - if (HCC_MAX_PSA(xhci->hcc_params) >= 4) - xhci->shared_hcd->can_do_streams = 1; + usb3_hcd = xhci_get_usb3_hcd(xhci); + if (usb3_hcd && HCC_MAX_PSA(xhci->hcc_params) >= 4) + usb3_hcd->can_do_streams = 1; - ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); - if (ret) - goto put_usb3_hcd; + if (xhci->shared_hcd) { + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); + if (ret) + goto put_usb3_hcd; + } device_enable_async_suspend(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); From patchwork Fri Mar 4 18:37:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12769814 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 5B178C433FE for ; Fri, 4 Mar 2022 18:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241330AbiCDSiV (ORCPT ); Fri, 4 Mar 2022 13:38:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241817AbiCDSiN (ORCPT ); Fri, 4 Mar 2022 13:38:13 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 801F21D5290 for ; Fri, 4 Mar 2022 10:37:24 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id qt6so19201478ejb.11 for ; Fri, 04 Mar 2022 10:37:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=5cKpBLN6W/XTLPaS2O2YVfEK3xn2DNe6RJKVM5hTxZg=; b=crn697PXvGDcdsA8ZF/+tfvWfLcgTa2PQ3T6bOmCREqzBTXNwlyqbKXsvWmK835X0E FAnw96zAEqlgSvZSGVf950J9tMqAyNbmovm8JHu0aJu3lHgcMjFzMC7ruW3+M8InO9jG 8xu6aSVB5QvMk5m61TuDiNz1gtWVK8z9h4igPggWmLQl6iEEyhDRi0cEF0Us8FsYcUCb DrWLRWq2uB258ubJdNOIzoc0TSUTtTH8/Xk7I6JSdPH5CAHU9W4ZY3iTZTANLsbWhsTR UfGSXKmTiRdedoNn9Yij0mSMzl6XMN9V16NQqzAC7M/zQgHyWS7xvjy3Q3n0TMmFEZBi Wf0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=5cKpBLN6W/XTLPaS2O2YVfEK3xn2DNe6RJKVM5hTxZg=; b=1m43jU5uD0rQcpKdI3gq/hVjnH3pQjbZpUbSeeYpysOvuea2TyTBLlj9t71L65h9oT Icg5zwszWZdAaJ1GZk1eRs+i6FREtU72SU3wYjsxVyNZZjVS7xx7O7UI6fXJTYp9PVsH FPgFktmi6IZxDJ8GfpJivcg9rtH1zra++ragRf9rqUQC51lO/eA3L68sgetTdDlcZtqN HoqUFiiP4OJgnOk/uVopHp1ENqKeSpeYnZr/GUQzF/NZySXweueJQOAtHSADExxhpWx7 QCog6peItl+4hkVMhPWA8r7QCkpia3QTUqiea4mIxTTigDIkRoYsatD7SIl8QDQWRSS6 hO/g== X-Gm-Message-State: AOAM532qUz5EnyPrxwJk9tfgkrIBXLBfzRYNlWzmlRbypKRftYeQR2CT f6ZzdflGxKV0VNHCqTIsREr6l1Bj+9c= X-Google-Smtp-Source: ABdhPJyhy15uyUHHV4DHsA6OB66mWbELtC59alSCH1i8obW5MTpGlW2YCGdKgn25veJJgNTSPwaawA== X-Received: by 2002:a17:906:4c4b:b0:6da:a5d9:7af9 with SMTP id d11-20020a1709064c4b00b006daa5d97af9mr70026ejw.336.1646419043044; Fri, 04 Mar 2022 10:37:23 -0800 (PST) Received: from ?IPV6:2a01:c23:b9fb:2800:c56d:9b34:f61c:e318? (dynamic-2a01-0c23-b9fb-2800-c56d-9b34-f61c-e318.c23.pool.telefonica.de. [2a01:c23:b9fb:2800:c56d:9b34:f61c:e318]) by smtp.googlemail.com with ESMTPSA id vl11-20020a17090730cb00b006d8121d0fc4sm1989783ejb.138.2022.03.04.10.37.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 10:37:22 -0800 (PST) Message-ID: Date: Fri, 4 Mar 2022 19:37:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 5/5] xhci: support omitting shared hcd if either of the root hubs has no ports Content-Language: en-US From: Heiner Kallweit To: Mathias Nyman , Greg Kroah-Hartman Cc: Linux USB Mailing List , "open list:ARM/Amlogic Meson..." , Alan Stern , Jack Pham , Tung Nguyen References: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> In-Reply-To: <18a93669-7f7a-dad8-38f4-44819fc3b64a@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org If either of the root hubs has no ports, then we can get rid of overhead like the shared hcd. A major internal change is that now the main hcd can be USB2 or USB3. Signed-off-by: Heiner Kallweit --- drivers/usb/host/xhci-mem.c | 11 +++++------ drivers/usb/host/xhci.c | 9 ++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a1a17713a..ced139583 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2362,12 +2362,11 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) xhci->usb2_rhub.num_ports = USB_MAXCHILDREN; } - xhci->needs_shared_hcd = 1; - - /* - * Note we could have all USB 3.0 ports, or all USB 2.0 ports. - * Not sure how the USB core will handle a hub with no ports... - */ + if (xhci->usb2_rhub.num_ports && xhci->usb3_rhub.num_ports) + xhci->needs_shared_hcd = 1; + else + xhci_info(xhci, "USB%u root hub has no ports\n", + xhci->usb2_rhub.num_ports ? 3 : 2); xhci_create_rhub_port_array(xhci, &xhci->usb2_rhub, flags); xhci_create_rhub_port_array(xhci, &xhci->usb3_rhub, flags); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 83a54a566..623901890 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5279,9 +5279,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) xhci = hcd_to_xhci(hcd); - if (usb_hcd_is_primary_hcd(hcd)) { - xhci_hcd_init_usb2_data(xhci, hcd); - } else { + if (!usb_hcd_is_primary_hcd(hcd)) { xhci_hcd_init_usb3_data(xhci, hcd); return 0; } @@ -5363,6 +5361,11 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) return retval; xhci_dbg(xhci, "Called HCD init\n"); + if (xhci_hcd_is_usb3(hcd)) + xhci_hcd_init_usb3_data(xhci, hcd); + else + xhci_hcd_init_usb2_data(xhci, hcd); + xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%016llx\n", xhci->hcc_params, xhci->hci_version, xhci->quirks);