Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4417029yba; Tue, 7 May 2019 18:20:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCkUB7i4PeEAUuOQrf8/y573TXNXkCaTp7FdqsVIqD2stoCshRBM8AkfQvdAXoa6q+1qpZ X-Received: by 2002:a17:902:22f:: with SMTP id 44mr43233032plc.175.1557278454792; Tue, 07 May 2019 18:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557278454; cv=none; d=google.com; s=arc-20160816; b=WCNY8CVFyxj5WA1SBd9FiXjiUel2YHOPOBUNdbZpXHsWjPzKeesUVUZwuO8Qv+xxUu mCRf9S/NsZYew1BSZXTgXa8isQiDwc/ZiZ89YglkWlwAAA2n5cjxZFFltu769DULbHGu q1hu2ypkOxUkSr6TP+CQJXjaulZah+STY4ROpa38XOKyoe3qRY5ebeDqmP3pAt1Agv8N 5gtxOzXOr97x/e5PdQZath3Y8+qpnowA4Nud8+wOJaCGXywxoeKSSPGexRjyOnzyHhaL ChL/Ch05d7r0y/dkJQ3DZ6ZnTR8006tSOwWTuCf/skLEqJ9zFeFk7rufOix2Tzb5l9yV WPtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=O+01/fhDqtai1N/X2yLycMXv1SIs+oDpJCrUUWcrjMA=; b=d6vzzRtrNOMfXv3OgXOGe+47uKT8/daX/yR5G4nWaNTbAEB1W8L0wcUb2Q8QYYzZNL kFkw0FHaSVyzNBxo+PcTTqVOdEh2qa9kTIspPYQPQ+e7xlt/irR+E2dzUNfehVD7zVnS JVZzXYSEqa1M4ClWZ1ncpoRFtmfW+1DPL+KUNgsaOhLenbr8q67mH3fpox3NTaS+W8Xu pUsq/xJOvBMQzebHTcycZIyE4TzPze/R1fYjS5nqsoQANH6CuumDpbPAr8ZWSIylDzL5 v218LrxkxzdyFxYPj+RBowEwmLnJhlrAjeof+Q/m3sHn1N76EaI4d06BhP9SzlPpkkjP adGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FjutGs8U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b129si12340310pfa.254.2019.05.07.18.20.38; Tue, 07 May 2019 18:20:54 -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; dkim=pass header.i=@chromium.org header.s=google header.b=FjutGs8U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726511AbfEHBSB (ORCPT + 99 others); Tue, 7 May 2019 21:18:01 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:37399 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbfEHBSA (ORCPT ); Tue, 7 May 2019 21:18:00 -0400 Received: by mail-qk1-f196.google.com with SMTP id c1so2145976qkk.4 for ; Tue, 07 May 2019 18:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O+01/fhDqtai1N/X2yLycMXv1SIs+oDpJCrUUWcrjMA=; b=FjutGs8Upc4X6Ku/pI/PhsHhXsb8sSJIphZ2Bg6gKbUsba2yYhZiL0CQ1dmLmyiNMY 1DoyzoBrbX/9wIuVbbJxqDoh6T5/SjSLneERnFf2MvvZ4dEnh5JkyfUIml41Djky5/16 mUowZUTgIE3HBR+V4Tj+h5zLTs801GBy08Ld8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O+01/fhDqtai1N/X2yLycMXv1SIs+oDpJCrUUWcrjMA=; b=BdJ6iVoBzZRCK4GcjXOaUTnRrgq+8TcTEPEi/wE3O8f4y7VL+2vU7E8d96BKUcMfii IMaEI8S8FXrS8U9sxEaGyvi52Vfy1aZfXiiiYCN0pTZeZ8VNwuE6nHliYO7vwD00LxeT ZJcr0Uq0LdjId41QGjVimLeQpvr1qDWqaVt+2dnsOvEA4IAHXaN9Vy3/i+DisEKklSYy xTixx2qGbwnP0PpzTYABDWUiuSyEhDTrcKrQFTBjZYPrjLRX86+UCoHxWzOuIlnXE/gm kC0WkjkEnP9P6ztWf92ZFAnM1cbhs+qDEbfoTiAv0+SNXXs6HQZkiIltLJ3y4RPGj5Ae mWiA== X-Gm-Message-State: APjAAAVd6q1OqaAVA09AnsJoQZGE05OhHHnaUeiZKM1TGdVC5wkSeuhk y6XR8mw0WmecrdEvx2OcN1T5Q2map1ButUvggWcaQQ== X-Received: by 2002:a37:2e05:: with SMTP id u5mr6103515qkh.124.1557278279873; Tue, 07 May 2019 18:17:59 -0700 (PDT) MIME-Version: 1.0 References: <20190502045631.229386-1-drinkcat@chromium.org> <6844539f-3d5e-e3ff-b498-390cdc731880@linux.intel.com> In-Reply-To: <6844539f-3d5e-e3ff-b498-390cdc731880@linux.intel.com> From: Nicolas Boichat Date: Wed, 8 May 2019 10:17:48 +0900 Message-ID: Subject: Re: [PATCH 1/2] usb: xhci: Make it possible to not have a secondary HCD (3.0) To: Mathias Nyman Cc: Greg Kroah-Hartman , Mathias Nyman , Matthias Brugger , linux-usb@vger.kernel.org, lkml , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Khuong Dinh , Hoan Tran , chunfeng.yun@mediatek.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 6, 2019 at 10:19 PM Mathias Nyman wrote: > > On 2.5.2019 7.56, Nicolas Boichat wrote: > > Some XHCI controllers may not have any USB 3.0 port, in this case, it > > is not useful to create add hcd->shared_hcd, which has 2 main > > downsides: > > - A useless USB 3.0 root hub is created. > > - A warning is thrown on boot: > > hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19) > > > > The change is mostly about checking if hcd->shared_hcd is NULL before > > accessing it. The one special case is in xhci_run, where we need to > > call xhci_run_finished immediately, if there is no secondary hcd. > > To me it looks like this creates an controller starting issue for > xHC hardware that have both usb2 and usb3 ports. > > When we have usb3 ports xhci->shared_hcd is not set yet when xhci_run is called > the first time. We will end up starting the xHC before properly setting up the secondary hcd. > > See further down for details Thanks Mathias and Chunfeng, I need to test this on platforms that actually support USB 3.0 (both PCI and MTK), as you both highlighted, there might be issues. I'll do that a spin a v2. It might take a while though (this is not a very critical issue). > > > > Signed-off-by: Nicolas Boichat > > --- > > > > This is a respin of https://lore.kernel.org/patchwork/patch/863993/, > > hopefully addressing the comments there. Note that I dropped the change > > in xhci-plat.c, as I do not have a device to test it, but made a > > similar change in xhci-mtk.c, in the next patch. > > > > (the @apm.com addresses seem to bounce, so I added some > > @amperecomputing.com instead, if somebody there can track back the > > original issue, I'm happy to provide a patch for xhci-plat.c as well) > > > > drivers/usb/host/xhci-hub.c | 7 ++++-- > > drivers/usb/host/xhci.c | 45 +++++++++++++++++++++++++++---------- > > 2 files changed, 38 insertions(+), 14 deletions(-) > > > > ... > > > @@ -698,6 +703,10 @@ int xhci_run(struct usb_hcd *hcd) > > > > xhci_debugfs_init(xhci); > > > > + /* There is no secondary HCD, start the host controller immediately. */ > > + if (!xhci->shared_hcd) > > + return xhci_run_finished(xhci); > > + > > PCI xHC controllers with both usb2 and usb3 ports will be started before usb3 parts are properly set up. > > xhci_pci_probe() > usb_hcd_pci_probe() > usb_add_hcd() > hcd->driver->start(hcd) // .start = xhci_run > xhci_run() > if (!xhci->shared_hcd) // TRUE as xhci->shared_hcd is not yet set, > return xhci_run_finished(xhci) // starting controller too early here > xhci->shared_hcd = usb_create_shared_hcd() // now xhci->shared_hcd is set. > > -Mathias