From patchwork Tue Oct 31 13:01:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 117619 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3884109qgn; Tue, 31 Oct 2017 06:02:29 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TvlpKvvfH3TS+GCb5CaXtuwPT0HCIIbs0V6Y7oDQFJTnAumCI8f5BoN8iqFl2t+bEy8Xl7 X-Received: by 10.99.189.18 with SMTP id a18mr1735690pgf.168.1509454949560; Tue, 31 Oct 2017 06:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509454949; cv=none; d=google.com; s=arc-20160816; b=jgsWCtmq/V9H1gJPhlqMe554m5hpiZPwSiHvzViSOoF5n/c79s+cD2IPUbc2Xq4vkH sUt51HCCQvKm2lJo4PbbRaguivkHeKxSkz5WkBbW36tW6MpKQ9ZZmIMK+HSK/AHCnZmd HA/P3kQIE4e9f2GsTPt6rhhTZMhEKxNSEXYCk5UUTTGjZVzlyPLALMWFblacLnYzDZjc HK1Mg7JFM0Jh4xcOZPj5RbOoPhQCGBFZUc7C0o4+OIosUd8gdQnr0gu3Gs1dILBp+sFX 7EtrVS7q3M0uWSVWG7PT4mGh9FTbK8jlr3fdndRcMn0MNccTV1YDPPGJSm1CeCcAlg8O cjfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=H9217UFzdFJwK1gq00vvqPEuD0N07GQtap8RKoRanPY=; b=jl1bvHH2wz4BW1Zdjc0Bajef9cUBS2CSb42QMb7MBI162s0i6N15whp3LcaNVW/sau /qPMptRP8QCjnhWOZlrE/iFuWKYTkAp0JDvlcvok7GB1t7BHazxBoqQ0oDGr5UTihDh3 xQPvQlMLwnspeJKYCnsU/d7VJO05hB4ML2ROupspfIz565D33pp5UKFZ8GISguQn348V EvxgCRHBbaUcQDFqiYlFY25OU34DiDwRIQBn/Nc9HCcKrK7ZbOQX4Skl6Vs0dzGPpJGE Y6cvvqBs/SyAIh8NCeXdVG8urZWzbbOWIsA3AY2EISbwlikkiMTuQtg6BOPmZ3RUuIjq 5Ljw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=XK/k83KN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7si1676697pfj.22.2017.10.31.06.02.28; Tue, 31 Oct 2017 06:02:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@ti.com header.s=ti-com-17Q1 header.b=XK/k83KN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751539AbdJaNC1 (ORCPT + 9 others); Tue, 31 Oct 2017 09:02:27 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:57629 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbdJaNC0 (ORCPT ); Tue, 31 Oct 2017 09:02:26 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9VD1sFL000612; Tue, 31 Oct 2017 08:01:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1509454914; bh=K5wmq8phZMgi8MSZDRHDisFmkH2tT0nFQCHlQ5AjHb4=; h=From:To:CC:Subject:Date; b=XK/k83KNvxXOE/5n12X2a+bqVk77fur/QHitVAsi/1bK3b0T3SId7AO7qvEvSPrYj ZmSicZ1PC9N/KjfqNYLlmgH6CmYhIcTPzhRqtnlBYaBVR+3RO066zihQzUxtwkqY1t HLxS82XUkJt3sPkHrbbOuTxpEvO8IJXMrJEIVoY8= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9VD1nfk028655; Tue, 31 Oct 2017 08:01:49 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 31 Oct 2017 08:01:48 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 31 Oct 2017 08:01:48 -0500 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9VD1mtN021738; Tue, 31 Oct 2017 08:01:48 -0500 Received: from lta0400828d.ti.com (vboxa0400828d.emea.dhcp.ti.com [172.22.234.209]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9VD1k3q014945; Tue, 31 Oct 2017 08:01:47 -0500 From: Roger Quadros To: CC: , , , Roger Quadros , "# v4 . 13+" Subject: [PATCH] usb: dwc3: gadget: Fix .udc_set_speed() Date: Tue, 31 Oct 2017 15:01:44 +0200 Message-ID: <1509454904-4966-1-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org UDC core calls .udc_set_speed() with the speed parameter containing the maximum speed supported by the gadget function driver. This might very well be more or less than that supported by the dwc3 controller driver. Select the lesser of the 2 speeds so both are operating within limits. This fixes PHY Erratic errors and 2 second enumeration delay on TI's AM437x platforms. Fixes: 7d8d0639565f ("usb: dwc3: gadget: implement ->udc_set_speed()") Cc: # v4.13+ Reported-by: Dylan Howey Signed-off-by: Roger Quadros --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f064f15..9f27ec0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2008,6 +2008,8 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g, unsigned long flags; u32 reg; + speed = min(g->max_speed, speed); + spin_lock_irqsave(&dwc->lock, flags); reg = dwc3_readl(dwc->regs, DWC3_DCFG); reg &= ~(DWC3_DCFG_SPEED_MASK);