Received: by 10.223.185.116 with SMTP id b49csp5735550wrg; Wed, 7 Mar 2018 17:36:50 -0800 (PST) X-Google-Smtp-Source: AG47ELvSy/B3nt7gWlD5Z6hNLi9vA85Z1p0u5RzCg1Vjax3gEI2F0UncnzJB5a6El+oACVBi6nt6 X-Received: by 2002:a17:902:8ec6:: with SMTP id x6-v6mr22648258plo.402.1520473010595; Wed, 07 Mar 2018 17:36:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520473010; cv=none; d=google.com; s=arc-20160816; b=w2zFBXZ0/I45HRWARShZZWXNK68fcBAuo8wSSo2Y209s/HeamosGrCJ6lJ8DlYAdC+ bNXQ+Yz54ec31E14p0SttYxqvq3YnYhgtVJFd4YFO3wBUGMtqfnRlQ4uAD1C7qozitMH OA96sxbNccdHZBli+jldq7zlDIijAaEuFh+7jbLIMwKCrMkK1W6X0RUKzh4Ov7Gcyzz+ CR066zrn6KhMKavQ5o02swxPxm7GUwnHuwBnwxenQH9oaflCKYtYJoQmetdHku9PIv7h CPIaR+LSIGg35d0Hnywb7JR8BzNjkxj2p7PcbmZAtwAQNO2Tb6Pz8WKx7g48YsCwKLyX SziA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=TuB8M9lfGJNiICZOtpp5wYbzXP/w3Anrhqiy3PJPjmQ=; b=V3za1q+wK17A9Wm5YH3UCpHPXdd1HdL4zHW6qUEmsydr5z28fTq44vP639Bs+BSZqS IHj+92xfsrDctFBvOqy0Uf5tXCV8T3EUozBnQ3M6lSNrGAkjDDN7EbXBneqUf/yMj1/d n+iM15kjxOcStpRtW4BnjWE7CwQtrkPHxH+i1K1nyjXUtj2Sk7N/R/ex0yQVAakyB8RT H/JGEtC3tMsMogJukFbhLQkcXv5e9b1VIePcZ6TPeyfe3jDRvp/y2aJ2/wQBiVX6Ye5Q WgRQbfjXsS0p0QcmtwC1m2zOcJgMS/hQsd9ILF1vlGcTj2C6S0PWCWtZOjHSB/thrvm8 t69g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si14898864pfg.246.2018.03.07.17.36.35; Wed, 07 Mar 2018 17:36:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934639AbeCHBfK (ORCPT + 99 others); Wed, 7 Mar 2018 20:35:10 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:38130 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933554AbeCHBfI (ORCPT ); Wed, 7 Mar 2018 20:35:08 -0500 Received: by mail-oi0-f66.google.com with SMTP id h23so3219551oib.5; Wed, 07 Mar 2018 17:35:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TuB8M9lfGJNiICZOtpp5wYbzXP/w3Anrhqiy3PJPjmQ=; b=q/noNKq3YkI0MZ6NEpCiFWipV7/hsnVJw6Myf0WrOF/nnJwC5zTje4XxXPuyA50r7x uaYa0+IBm527A71APiImCa/DHU8fC/CgMPzCmkIP9L3sGQi1rUJSRpNzQhDxHK3VrrY3 GhnOHNFugIqwUBUabnc0couUa2x9CVrCnAcqhKiSajDViiRkCmRlWvd73Nh1RR6D2cCK 0EfupGvgW4vXRlxqcvGpWXMnHFpC+rQGrUJbdoDLAkf6TFGKqmQvsUlL+HlvLYKTUxlZ 8AsQy4binXRzZzr184l7XuniQKDPE0ZCON4AKpFCfXbeY5BJuf3ZtrPxH90dT/+UCdsr mtbw== X-Gm-Message-State: AElRT7FcwQb+FCN5+/0Qy0OKb0ltg0Nq+12hbPMRPiVTHVN5jVYERUOt Lzm+lbOYE/K9S/1Y/Hv7cExwHz0hng== X-Received: by 10.202.237.212 with SMTP id l203mr301831oih.109.1520472907444; Wed, 07 Mar 2018 17:35:07 -0800 (PST) Received: from localhost (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.gmail.com with ESMTPSA id 70sm9522707oti.1.2018.03.07.17.35.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Mar 2018 17:35:06 -0800 (PST) Date: Wed, 7 Mar 2018 19:35:05 -0600 From: Rob Herring To: Ran Wang Cc: Felipe Balbi , Shawn Guo , Greg Kroah-Hartman , Mark Rutland , Russell King , Catalin Marinas , Will Deacon , Li Yang , devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 3/3] USB3/DWC3: Enable undefined length INCR burst type Message-ID: <20180308013505.lyrmkdz54iyghbsf@rob-hp-laptop> References: <20180306085911.5930-1-ran.wang_1@nxp.com> <20180306085911.5930-3-ran.wang_1@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180306085911.5930-3-ran.wang_1@nxp.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 06, 2018 at 04:59:11PM +0800, Ran Wang wrote: > Enable the undefined length INCR burst type and set INCRx. > Different platform may has the different burst size type. > In order to get best performance, we need to tune the burst size to > one special value, instead of the default value. > > Signed-off-by: Changming Huang > Signed-off-by: Rajesh Bhagat > Signed-off-by: Ran Wang > --- > Changes in v5: > - no change > Changes in v4: > - Modify the codes according to the definition of this property. > Changes in v3: > - add new property for INCR burst in usb node to reset GSBUSCFG0. > Changes in v2: > - split patch > - create one new function to handle soc bus configuration register. > > drivers/usb/dwc3/core.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ > drivers/usb/dwc3/core.h | 7 ++++ > 2 files changed, 90 insertions(+), 0 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index f1d838a..8ea2bc8 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -741,6 +741,87 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc) > static int dwc3_core_get_phy(struct dwc3 *dwc); > static int dwc3_core_ulpi_init(struct dwc3 *dwc); > > +/* set global soc bus configuration registers */ > +static void dwc3_set_soc_bus_cfg(struct dwc3 *dwc) > +{ > + struct device *dev = dwc->dev; > + u32 *vals; > + u32 cfg; > + int ntype; > + int ret; > + int i; > + > + cfg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0); > + > + /* > + * Handle property "snps,incr-burst-type-adjustment". > + * Get the number of value from this property: > + * result <= 0, means this property is not supported. > + * result = 1, means INCRx burst mode supported. > + * result > 1, means undefined length burst mode supported. > + */ > + ntype = device_property_read_u32_array(dev, > + "snps,incr-burst-type-adjustment", NULL, 0); Can't you just do: if (ntype <= 0) return; > + if (ntype > 0) { And then save a level of indentation. > + vals = kcalloc(ntype, sizeof(u32), GFP_KERNEL); > + if (!vals) { > + dev_err(dev, "Error to get memory\n"); > + return; > + } > + /* Get INCR burst type, and parse it */ > + ret = device_property_read_u32_array(dev, > + "snps,incr-burst-type-adjustment", vals, ntype); > + if (ret) { > + dev_err(dev, "Error to get property\n"); > + return; > + } > + *(dwc->incrx_type + 1) = vals[0]; > + if (ntype > 1) { > + *dwc->incrx_type = 1; > + for (i = 1; i < ntype; i++) { > + if (vals[i] > *(dwc->incrx_type + 1)) > + *(dwc->incrx_type + 1) = vals[i]; > + } > + } else > + *dwc->incrx_type = 0; This code is hard to follow. Why do you have an array to store a boolean (INCR burst enable) and the burst size. 2 elements with more descriptive names would be better. > + > + /* Enable Undefined Length INCR Burst and Enable INCRx Burst */ > + cfg &= ~DWC3_GSBUSCFG0_INCRBRST_MASK; > + if (*dwc->incrx_type) > + cfg |= DWC3_GSBUSCFG0_INCRBRSTENA; > + switch (*(dwc->incrx_type + 1)) { > + case 256: > + cfg |= DWC3_GSBUSCFG0_INCR256BRSTENA; > + break; > + case 128: > + cfg |= DWC3_GSBUSCFG0_INCR128BRSTENA; > + break; > + case 64: > + cfg |= DWC3_GSBUSCFG0_INCR64BRSTENA; > + break; > + case 32: > + cfg |= DWC3_GSBUSCFG0_INCR32BRSTENA; > + break; > + case 16: > + cfg |= DWC3_GSBUSCFG0_INCR16BRSTENA; > + break; > + case 8: > + cfg |= DWC3_GSBUSCFG0_INCR8BRSTENA; > + break; > + case 4: > + cfg |= DWC3_GSBUSCFG0_INCR4BRSTENA; > + break; > + case 1: > + break; > + default: > + dev_err(dev, "Invalid property\n"); > + break; > + } > + } > + > + dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg); > +} > + > /** > * dwc3_core_init - Low-level initialization of DWC3 Core > * @dwc: Pointer to our controller context structure > @@ -803,6 +884,8 @@ static int dwc3_core_init(struct dwc3 *dwc) > /* Adjust Frame Length */ > dwc3_frame_length_adjustment(dwc); > > + dwc3_set_soc_bus_cfg(dwc); > + > usb_phy_set_suspend(dwc->usb2_phy, 0); > usb_phy_set_suspend(dwc->usb3_phy, 0); > ret = phy_power_on(dwc->usb2_generic_phy); > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > index 8f97f61..565d7ec 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -806,6 +806,7 @@ struct dwc3_scratchpad_array { > * @regs: base address for our registers > * @regs_size: address space size > * @fladj: frame length adjustment > + * @incrx_type: INCR burst type adjustment > * @irq_gadget: peripheral controller's IRQ number > * @nr_scratch: number of scratch buffers > * @u1u2: only used on revisions <1.83a for workaround > @@ -939,6 +940,12 @@ struct dwc3 { > enum usb_phy_interface hsphy_mode; > > u32 fladj; > + /* > + * For INCR burst type. > + * First field: for undefined length INCR burst type enable. > + * Second field: for INCRx burst type enable > + */ > + u32 incrx_type[2]; > u32 irq_gadget; > u32 nr_scratch; > u32 u1u2; > -- > 1.7.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel