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 */ From patchwork Tue Apr 4 12:55:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 96726 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp179331qgd; Tue, 4 Apr 2017 05:54:37 -0700 (PDT) X-Received: by 10.99.213.81 with SMTP id v17mr24039342pgi.130.1491310477592; Tue, 04 Apr 2017 05:54:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x21si17407838pgf.396.2017.04.04.05.54.37; Tue, 04 Apr 2017 05:54:37 -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 S1754269AbdDDMyM (ORCPT + 4 others); Tue, 4 Apr 2017 08:54:12 -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 S1754262AbdDDMyK (ORCPT ); Tue, 4 Apr 2017 08:54:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491310450; x=1522846450; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QHPQgLVBkjs/YmtR+qFuv9zVlLGJNhZSwk6dNd2LZ0A=; b=RfBy36q9voCV1NPFRx0JSCY1oDtf+7Vr4KyRphijP6tyjaFyeiszFazJ JrhriVRttTW14svEJmUmAY1p4W5xdA==; 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:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,275,1486454400"; d="scan'208";a="841627821" Received: from mattu-haswell.fi.intel.com ([10.237.72.164]) by FMSMGA003.fm.intel.com with ESMTP; 04 Apr 2017 05:53:56 -0700 From: Mathias Nyman To: Cc: , Roger Quadros , Mathias Nyman Subject: [PATCH 24/24] usb: xhci: bInterval quirk for TI TUSB73x0 Date: Tue, 4 Apr 2017 15:55:16 +0300 Message-Id: <1491310516-6176-25-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: Roger Quadros As per [1] issue #4, "The periodic EP scheduler always tries to schedule the EPs that have large intervals (interval equal to or greater than 128 microframes) into different microframes. So it maintains an internal counter and increments for each large interval EP added. When the counter is greater than 128, the scheduler rejects the new EP. So when the hub re-enumerated 128 times, it triggers this condition." This results in Bandwidth error when devices with periodic endpoints (ISO/INT) having bInterval > 7 are plugged and unplugged several times on a TUSB73x0 XHCI host. Workaround this issue by limiting the bInterval to 7 (i.e. interval to 6) for High-speed or faster periodic endpoints. [1] - http://www.ti.com/lit/er/sllz076/sllz076.pdf Signed-off-by: Roger Quadros Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 11 +++++++++++ drivers/usb/host/xhci-pci.c | 3 +++ drivers/usb/host/xhci.h | 1 + 3 files changed, 15 insertions(+) -- 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-mem.c b/drivers/usb/host/xhci-mem.c index b88ec9a..2954b90 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1503,6 +1503,17 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, */ max_esit_payload = xhci_get_max_esit_payload(udev, ep); interval = xhci_get_endpoint_interval(udev, ep); + + /* Periodic endpoint bInterval limit quirk */ + if (usb_endpoint_xfer_int(&ep->desc) || + usb_endpoint_xfer_isoc(&ep->desc)) { + if ((xhci->quirks & XHCI_LIMIT_ENDPOINT_INTERVAL_7) && + udev->speed >= USB_SPEED_HIGH && + interval >= 7) { + interval = 6; + } + } + mult = xhci_get_endpoint_mult(udev, ep); max_packet = usb_endpoint_maxp(&ep->desc); max_burst = xhci_get_endpoint_max_burst(udev, ep); diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index fc99f51..7b86508 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -199,6 +199,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == 0x1042) xhci->quirks |= XHCI_BROKEN_STREAMS; + if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241) + xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7; + if (xhci->quirks & XHCI_RESET_ON_RESUME) xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, "QUIRK: Resetting on resume"); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index dbe8ba9..914968c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1820,6 +1820,7 @@ struct xhci_hcd { #define XHCI_MISSING_CAS (1 << 24) /* For controller with a broken Port Disable implementation */ #define XHCI_BROKEN_PORT_PED (1 << 25) +#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) unsigned int num_active_eps; unsigned int limit_active_eps;