Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3425850yba; Tue, 7 May 2019 00:39:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEBVFR81AlTpjyCXXs3AyLxG6Q0z0CGKazxq8fRQSgAxbVZTlNdpTcN9oVBTvpAsP/7Oy/ X-Received: by 2002:a63:560d:: with SMTP id k13mr37716642pgb.124.1557214745789; Tue, 07 May 2019 00:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557214745; cv=none; d=google.com; s=arc-20160816; b=My0lwTvf+plElY+xjdxjFm9heJdoQI7dRlBxHh9ChPZnfhLAIbTc7qtVCOXYvyJXZD skySQG772uGSn9Grcvf/mDZjRu8nPdBEEAdjHrvKg9XFfviZQDa7HnIzYlba6LWVFkLM C5+n6oqIHYEaRaH1Tiiub+PDVHfHXrq5ORxKcgmAJ3J3FiBLdQmBOZ1uRr9BP61pGk7r Wdlk5m5jNVwTft+edzDPZIVPduBcg22Rg/pYyZ3inGTD2czRWB3aA3Uh+NEeplPuuAde cJxT39gn2oNVJ4iaMWUufngI/B+ZcDGqCeNEHKqRl+R3t9BvED8vAV40b9L+VFp0Tw41 IYSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=2RlyeqIx7xcM1BXUudT+zjMTph2qpZXItm8MptNkx30=; b=zFXUKUtteML71JjiGp9ewv4kK59rXmwzTpI/A6xp+P6b25FScGtTj/yX/E7dJaiUcZ X2kvY4iLXV3lhUS2eTsnL4MOHvrROrXQCmioFtOwJ+4/9ct22pcE18Iv18RauLitFnqd 5WYo5zc104BsxQgk1p4BVxQ7iowaD/z4rQoOAhZ6XTkleh5iD4v/26eF+n9ELJ4wTAmG H/uj/dpS73I4W3dY8W48O+FPGTunqEw0zd2OHgZ1etWIIU7S5sJgKH5/uop9WUVxH7ce HoQdoPBVLSVWKrNndgVCoS65f5h5dREM0xBqu6V8RheSAgurWJfK/JuX8aSqvsxtSnzE 8Rvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si17702648pgs.17.2019.05.07.00.38.49; Tue, 07 May 2019 00:39:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbfEGHhh (ORCPT + 99 others); Tue, 7 May 2019 03:37:37 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:18790 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726175AbfEGHhh (ORCPT ); Tue, 7 May 2019 03:37:37 -0400 X-UUID: 30d28f96dd634158bdf39ddcf422b952-20190507 X-UUID: 30d28f96dd634158bdf39ddcf422b952-20190507 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1598305782; Tue, 07 May 2019 15:37:29 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS32DR.mediatek.inc (172.27.6.104) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 7 May 2019 15:37:25 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 7 May 2019 15:37:24 +0800 Message-ID: <1557214644.10179.266.camel@mhfsdcap03> Subject: Re: [PATCH 2/2] usb: xhci-mtk: Do not create shared_hcd if no USB 3.0 port available From: Chunfeng Yun To: Nicolas Boichat CC: Greg Kroah-Hartman , Mathias Nyman , Matthias Brugger , , , , , Khuong Dinh , Hoan Tran Date: Tue, 7 May 2019 15:37:24 +0800 In-Reply-To: <20190502045631.229386-2-drinkcat@chromium.org> References: <20190502045631.229386-1-drinkcat@chromium.org> <20190502045631.229386-2-drinkcat@chromium.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-TM-SNTS-SMTP: F29A5653419344021C7CCE1ECFF7F5112A40D61367D92EF03386E42FBB22C6DA2000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nicolas, On Thu, 2019-05-02 at 12:56 +0800, Nicolas Boichat wrote: > When the controller only supports USB 2.0, do not even create the > USB 3.0 hcd/root hub. > > Signed-off-by: Nicolas Boichat > --- > drivers/usb/host/xhci-mtk.c | 44 +++++++++++++++++++++++-------------- > 1 file changed, 28 insertions(+), 16 deletions(-) > > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c > index 026fe18972d3e5b..189f5dc614e6e05 100644 > --- a/drivers/usb/host/xhci-mtk.c > +++ b/drivers/usb/host/xhci-mtk.c > @@ -527,23 +527,28 @@ static int xhci_mtk_probe(struct platform_device *pdev) > xhci->imod_interval = 5000; > device_property_read_u32(dev, "imod-interval-ns", &xhci->imod_interval); > > - xhci->shared_hcd = usb_create_shared_hcd(driver, dev, > + /* Only create shared_hcd when USB3.0 port is available. */ > + if (xhci->usb3_rhub.num_ports > 0) { xhci->usb3_rhub.num_ports is not set until usb_add_hcd() is called. > + xhci->shared_hcd = usb_create_shared_hcd(driver, dev, > dev_name(dev), hcd); > - if (!xhci->shared_hcd) { > - ret = -ENOMEM; > - goto disable_device_wakeup; > + if (!xhci->shared_hcd) { > + ret = -ENOMEM; > + goto disable_device_wakeup; > + } > } > > ret = usb_add_hcd(hcd, irq, IRQF_SHARED); > if (ret) > goto put_usb3_hcd; > > - if (HCC_MAX_PSA(xhci->hcc_params) >= 4) > - xhci->shared_hcd->can_do_streams = 1; > + if (xhci->usb3_rhub.num_ports > 0) { > + 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; > + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); > + if (ret) > + goto dealloc_usb2_hcd; > + } > > return 0; > > @@ -552,7 +557,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) > > put_usb3_hcd: > xhci_mtk_sch_exit(mtk); > - usb_put_hcd(xhci->shared_hcd); > + if (xhci->shared_hcd) > + usb_put_hcd(xhci->shared_hcd); > > disable_device_wakeup: > device_init_wakeup(dev, false); > @@ -579,12 +585,14 @@ static int xhci_mtk_remove(struct platform_device *dev) > struct xhci_hcd *xhci = hcd_to_xhci(hcd); > struct usb_hcd *shared_hcd = xhci->shared_hcd; > > - usb_remove_hcd(shared_hcd); > + if (shared_hcd) > + usb_remove_hcd(shared_hcd); > xhci->shared_hcd = NULL; > device_init_wakeup(&dev->dev, false); > > usb_remove_hcd(hcd); > - usb_put_hcd(shared_hcd); > + if (shared_hcd) > + usb_put_hcd(shared_hcd); > usb_put_hcd(hcd); > xhci_mtk_sch_exit(mtk); > xhci_mtk_clks_disable(mtk); > @@ -611,8 +619,10 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev) > xhci_dbg(xhci, "%s: stop port polling\n", __func__); > 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); > + } > > xhci_mtk_host_disable(mtk); > xhci_mtk_clks_disable(mtk); > @@ -631,8 +641,10 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) > xhci_mtk_host_enable(mtk); > > xhci_dbg(xhci, "%s: restart port polling\n", __func__); > - 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); > return 0;