From patchwork Tue Apr 4 12:55:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 96725 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp179049qgd; Tue, 4 Apr 2017 05:53:45 -0700 (PDT) X-Received: by 10.98.194.88 with SMTP id l85mr22998272pfg.55.1491310425120; Tue, 04 Apr 2017 05:53:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s36si17457046pld.3.2017.04.04.05.53.44; Tue, 04 Apr 2017 05:53:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754199AbdDDMxk (ORCPT + 4 others); Tue, 4 Apr 2017 08:53:40 -0400 Received: from mga09.intel.com ([134.134.136.24]:25913 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754151AbdDDMxj (ORCPT ); Tue, 4 Apr 2017 08:53:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491310418; x=1522846418; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=+JChSnm8Fxd96pBUXrnCiyWCpLbZYfHGHLd8l7Woz7M=; b=HYr3O9uir5iNll6Wz6adF18Ww7XhX/wJmubmXvdA4fBZThAATvUYsUGW gvNbz7PhkIyFbZI9V1vJ88SCaM6AMQ==; Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2017 05:53:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,275,1486454400"; d="scan'208";a="841627735" Received: from mattu-haswell.fi.intel.com ([10.237.72.164]) by FMSMGA003.fm.intel.com with ESMTP; 04 Apr 2017 05:53:32 -0700 From: Mathias Nyman To: Cc: , Joel Stanley , Mathias Nyman Subject: [PATCH 12/24] xhci: Do not halt the host until both HCD have disconnected their devices. Date: Tue, 4 Apr 2017 15:55:04 +0300 Message-Id: <1491310516-6176-13-git-send-email-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491310516-6176-1-git-send-email-mathias.nyman@linux.intel.com> References: <1491310516-6176-1-git-send-email-mathias.nyman@linux.intel.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Joel Stanley We can't halt the host controller immediately when first HCD is removed as it will cause problems if we have devices attached to the second (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. [minor adjustments, code comments and remove HALT check -Mathias] Signed-off-by: Joel Stanley Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index e523dbd..5ecba7c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -692,21 +692,21 @@ void xhci_stop(struct usb_hcd *hcd) mutex_lock(&xhci->mutex); - if (!(xhci->xhc_state & XHCI_STATE_HALTED)) { - spin_lock_irq(&xhci->lock); - - xhci->xhc_state |= XHCI_STATE_HALTED; - xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; - xhci_halt(xhci); - xhci_reset(xhci); - spin_unlock_irq(&xhci->lock); - } - + /* Only halt host and free memory after both hcds are removed */ if (!usb_hcd_is_primary_hcd(hcd)) { + /* usb core will free this hcd shortly, unset pointer */ + xhci->shared_hcd = NULL; mutex_unlock(&xhci->mutex); return; } + spin_lock_irq(&xhci->lock); + xhci->xhc_state |= XHCI_STATE_HALTED; + xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; + xhci_halt(xhci); + xhci_reset(xhci); + spin_unlock_irq(&xhci->lock); + xhci_cleanup_msix(xhci); /* Deleting Compliance Mode Recovery Timer */