Received: by 10.223.164.202 with SMTP id h10csp438912wrb; Thu, 30 Nov 2017 01:45:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMbu1eFKviHZgGLaAIrfTP7cDmJ7MlbsJmX5jKRS/x6f8BVleuficGSmJnYk+gjVznGb1PlE X-Received: by 10.159.255.75 with SMTP id u11mr1968337pls.79.1512035129869; Thu, 30 Nov 2017 01:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512035129; cv=none; d=google.com; s=arc-20160816; b=rOSsb7JedzhwJ89GK6PYNycaqE9mfwR2XWpwC+GvzQpbInw3Ydipowox+xLOl6gw3h +Jvcq4hwdvBOX32xmjq/VpZpt1WilEujVzyyhrLct52hYZebO8soK0v8M/NAeHXen1g6 8EgvuUwDyZNET9bkIe4YTr26ExP/0iJGfTnAC4RnuPISA4/rQ6zQ8Gotp1M+TMTpGegQ HKekbXYze/q4rVnwRj6HroZjZmqZDSZutcHpGW8GAiiucRpAnwxA3rq9tRhozZ1SL5YG 4s1OjcIs6Vu6iztManM9kPL52JfFuvmk3+E521GbNlG6lj9k8DbbUfgMouthkLy+de0w wsiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=pCV3iZMUKkpK/YVRdpG4vOM9VDs+YfblaxOve4l09aM=; b=RaZX5UuCNedp7vuOmGq60D1hB+YxErNbDguEd+TZUPycDuMTgXxhko6VFfAFrauJGb Nz+YtAbOyge6Qy22z2JF6b/qzzQz0Q6TjyjVeazCnuxHOByj2KyeeZi/pqxOb23uw0Td woEcntFazI8mY6uUdPQIqAbSLJNuLrUzjAvYpULsCGOg53TNHXzIjxDSiXjJrdZyXBJU rHsPyJj2vN2yj7cFgTDa1MZyMF9TJaKk+FZYEhjjQ0/KXlYElOoWcB+R+YX5fW65Hx/b e/HmmWc4bKsAvnqc8dEEP4IonMEQ3ahds6vBXBQ+AncM+km9yqmAbI7fsm/pCzOhBTHl K99Q== ARC-Authentication-Results: i=1; mx.google.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si2713168pgv.237.2017.11.30.01.45.16; Thu, 30 Nov 2017 01:45:29 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752221AbdK3Jnv convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Nov 2017 04:43:51 -0500 Received: from smtprelay.synopsys.com ([198.182.47.9]:36392 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751885AbdK3Jnt (ORCPT ); Thu, 30 Nov 2017 04:43:49 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 780EF24E0F44; Thu, 30 Nov 2017 01:43:49 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 5D5151C7; Thu, 30 Nov 2017 01:43:49 -0800 (PST) Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 493EF1C4; Thu, 30 Nov 2017 01:43:49 -0800 (PST) Received: from AM04WEHTCB.internal.synopsys.com (10.116.16.192) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 30 Nov 2017 01:43:04 -0800 Received: from AM04WEMBXA.internal.synopsys.com ([fe80::79c3:55f2:1f20:5bf4]) by am04wehtcb.internal.synopsys.com ([::1]) with mapi id 14.03.0266.001; Thu, 30 Nov 2017 13:43:01 +0400 From: Minas Harutyunyan To: Amelie Delaunay , John Youn , Felipe Balbi , Greg Kroah-Hartman CC: "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] usb: dwc2: gadget: fix dwc2_check_param_tx_fifo_sizes Thread-Topic: [PATCH] usb: dwc2: gadget: fix dwc2_check_param_tx_fifo_sizes Thread-Index: AQHTZ43iDJjL9wCywUSjeVEUwQztPw== Date: Thu, 30 Nov 2017 09:43:01 +0000 Message-ID: <410670D7E743164D87FA6160E7907A560113A451C0@am04wembxa.internal.synopsys.com> References: <1511793691-6325-1-git-send-email-amelie.delaunay@st.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.92] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Amelie, On 11/27/2017 6:42 PM, Amelie Delaunay wrote: > In case of OTG mode, with an OTG adapter plugged, the > dwc2_check_param_tx_fifo_sizes function reads DPTXFSIZN registers while > the controller is in Host mode, and, because DPTXFSIZN registers are > Device specific registers, the values read are 0. > Then, g_tx_fifo_size[fifo] values are considered invalid because in the > comparison test, they need to be greater than min and lower than dptxfszn > which is 0. > To fix this issue, force the controller in device mode if needed before > reading the DPTXFSIZN registers, and restore the previous mode if needed > after reading. > > Fixes: 3c6aea7344c3 ("usb: dwc2: gadget: Add checking for g-tx-fifo-size > parameter") > Signed-off-by: Amelie Delaunay > --- > drivers/usb/dwc2/params.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c > index ef73af6..302fefb 100644 > --- a/drivers/usb/dwc2/params.c > +++ b/drivers/usb/dwc2/params.c > @@ -469,6 +469,7 @@ static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) > int fifo; > int min; > u32 total = 0; > + bool forced; > u32 dptxfszn; > > fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); > @@ -483,6 +484,12 @@ static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) > dwc2_set_param_tx_fifo_sizes(hsotg); > } > > + /* > + * Reading DPTXFSIZN registers requires the controller to be in device > + * mode. The mode will be forced, if necessary, to read these values. > + */ > + forced = dwc2_force_mode_if_needed(hsotg, false); > + > for (fifo = 1; fifo <= fifo_count; fifo++) { > dptxfszn = (dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)) & > FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; > @@ -495,6 +502,9 @@ static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) > hsotg->params.g_tx_fifo_size[fifo] = dptxfszn; > } > } > + > + if (forced) > + dwc2_clear_force_mode(hsotg); > } > > #define CHECK_RANGE(_param, _min, _max, _def) do { \ > I'll recommend to use "[PATCH] usb: dwc2: Fix TxFIFOn sizes and total TxFIFO size issues" instead. Thanks, Minas From 1585230748973675917@xxx Mon Nov 27 14:44:10 +0000 2017 X-GM-THRID: 1585230748973675917 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread