From patchwork Mon Sep 19 06:35:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 76508 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp807795qgf; Sun, 18 Sep 2016 23:36:24 -0700 (PDT) X-Received: by 10.66.100.225 with SMTP id fb1mr44476482pab.4.1474266984575; Sun, 18 Sep 2016 23:36:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d199si16247372pfd.10.2016.09.18.23.36.24; Sun, 18 Sep 2016 23:36:24 -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=fail header.i=@gmail.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 S1759608AbcISGgV (ORCPT + 27 others); Mon, 19 Sep 2016 02:36:21 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:32862 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753067AbcISGgM (ORCPT ); Mon, 19 Sep 2016 02:36:12 -0400 Received: by mail-pf0-f196.google.com with SMTP id q2so4115066pfj.0; Sun, 18 Sep 2016 23:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=ytvNmA85FWaYsUGWChVZFcp2BPOOyB3VVqXXLmJN8uw=; b=e5WdrDyT2SChpF1vdNSG4l0WlGfSY4kTq4kCbKr/uR1D1xXduL+RoO+GRt1aD0zJRb saZKTmBm12LKLZNRl3aTamOO0WnombpOSQfcKq/Duh2h31gUQsNRToRukq1fGCUBfo2N lRu7GHLMDlHQI3N3WfyPNmGVCjS1Ovi5J1qoE+leQEmIgJ7btf/akhV7wWWMqFBk564T ddNHH5ceB0hAHBaKaeA6G4s52HfrdDZgpiuZBZx6OovaXcjiGT7X39SzYWYVoI23lk9c rhlI9GoHnL3k59soJIBtxkw/e8sZhNse9bzzocMAIloWErkC1vBktN7bgSFacFaab6sU 9ATg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=ytvNmA85FWaYsUGWChVZFcp2BPOOyB3VVqXXLmJN8uw=; b=Xo580+rSGvpRBiKJr+9teOIrY6LpL2AUDEDPeDBGx0yTO27iWl5zLae23b1CqWTprw iOPGzXRjU40bCMmGm0dPQ18cILMDoFapMSYi3BwunD9MYS4TACgyJMLKAAQn0PoStmPO pxGVe4q4eCpR7ZGkvLj975uzgbUT3gI9/5q1JxJYB1MkqVn3VPq2RRp3kMwSsunjEy9E Y32ii3xk+OYR6NN8LWMxlBEv3kxNvHt91iOqqDODo9jgiYU3WCiXAuS7bcwiRCA0guOF zcRvPLHtClugY3CxNRB9BbfuqmpnUgbzJ5NR3f+7msVrFTqClXx7nHR8dMUDoebfGefi c+4w== X-Gm-Message-State: AE9vXwNossBpddU68WME7LDJ4ReXZAcsRGV4i4bXE4Q/YE4eiGIhNJ19cnMoiyZokouHVg== X-Received: by 10.98.56.148 with SMTP id f142mr4869604pfa.83.1474266971120; Sun, 18 Sep 2016 23:36:11 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id a137sm8622869pfa.72.2016.09.18.23.36.06 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 18 Sep 2016 23:36:09 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 19 Sep 2016 16:06:03 +0930 From: Joel Stanley To: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [RFC PATCH] xhci: do not halt the secondary HCD Date: Mon, 19 Sep 2016 16:05:45 +0930 Message-Id: <20160919063545.2055-1-joel@jms.id.au> X-Mailer: git-send-email 2.9.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can't halt the secondary HCD, because it's also the primary HCD, which will cause problems if we have devices attached to the primary HCD, like a keyboard. We've been carrying this in our Linux-as-a-bootloader environment for a little while now. The machines all have the same TI TUSB73x0 part, and when we kexec the devices don't come back until a system power cycle. I'd like some advice on an acceptable way to upstream the fix, so that the xhci device survives kexec. Signed-off-by: Joel Stanley --- drivers/usb/host/xhci.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.9.3 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index adc169d2fd76..ec92a843325b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -682,6 +682,21 @@ void xhci_stop(struct usb_hcd *hcd) mutex_lock(&xhci->mutex); + /* + * We can't halt the secondary HCD, because it's also the primary + * HCD, which will cause problems if we have devices attached to the + * primary HCD, like a keyboard. + */ + if (!usb_hcd_is_primary_hcd(hcd)) { + /* The shared_hcd is going to be deallocated shortly (the USB + * core only calls this function when allocation fails in + * usb_add_hcd(), or usb_remove_hcd() is called). So we need + * to unset xHCI's pointer. */ + xhci->shared_hcd = NULL; + mutex_unlock(&xhci->mutex); + return; + } + if (!(xhci->xhc_state & XHCI_STATE_HALTED)) { spin_lock_irq(&xhci->lock); @@ -693,11 +708,6 @@ void xhci_stop(struct usb_hcd *hcd) spin_unlock_irq(&xhci->lock); } - if (!usb_hcd_is_primary_hcd(hcd)) { - mutex_unlock(&xhci->mutex); - return; - } - xhci_cleanup_msix(xhci); /* Deleting Compliance Mode Recovery Timer */