From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759443AbaD3TQP (ORCPT ); Wed, 30 Apr 2014 15:16:15 -0400 Received: from mga09.intel.com ([134.134.136.24]:18211 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759344AbaD3TQO (ORCPT ); Wed, 30 Apr 2014 15:16:14 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,959,1389772800"; d="scan'208";a="532631932" Date: Thu, 1 May 2014 03:16:04 -0400 From: Zhuang Jin Can To: Felipe Balbi Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: dwc3: gadget: fix burst size corruption Message-ID: <20140501071604.GB30575@intel.com> Reply-To: jin.can.zhuang@intel.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org endpoint.maxburst may be 0 if a gadget doesn't call config_ep_by_speed() to update it from the companion descriptor. And endpoint.maxburst - 1 returns 11111b which wrongly sets bit 26 of endpoint parameter 0. This sets a wrong endpoint state and will cause "Get Endpoint State" command can't get the corret endpoint state and "Set Endpoint Config" command can't restore the correct endpoint state during hibernation resume flow. Thus, when endpoint.maxburst is 0, we should set burst as 0 directly. Signed-off-by: Zhuang Jin Can --- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 70715ee..44eca95 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -440,7 +440,8 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, /* Burst size is only needed in SuperSpeed mode */ if (dwc->gadget.speed == USB_SPEED_SUPER) { - u32 burst = dep->endpoint.maxburst - 1; + u32 burst = dep->endpoint.maxburst ? + dep->endpoint.maxburst - 1 : 0; params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst); } -- 1.7.9.5