All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	linux-usb@vger.kernel.org
Cc: John Youn <John.Youn@synopsys.com>
Subject: [RFC PATCH 14/14] usb: dwc3: gadget: Implement disabling of mult TRB fetch
Date: Wed, 11 Dec 2019 18:50:25 -0800	[thread overview]
Message-ID: <13d33d2a4f4425f85aae6aad545fdd3c06ec3a69.1576118671.git.thinhn@synopsys.com> (raw)
In-Reply-To: <cover.1576118671.git.thinhn@synopsys.com>

DWC_usb32 controller allows the HW to send multiple TRB fetch requests.
If the second fetch to the same TRB complete before the previous
request, then the result of the second fetch is taken and the first to
drop. This feature improve the performance when the number of cache TRB
is greater than 2. DWC_usb32 also has the option to issue only single
TRB fetch, which this patch implements the "snps,dis-mult-trb-fetch"
property.

For optimal performance, the programming guide recommend to do only
single TRB fetch if num_trb_prefetch is 2 or lower.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/core.c   |  2 ++
 drivers/usb/dwc3/core.h   |  5 +++++
 drivers/usb/dwc3/gadget.c | 12 ++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8de2928f47ac..713b5fdce38b 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1346,6 +1346,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 				"snps,dis-del-phy-power-chg-quirk");
 	dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev,
 				"snps,dis-tx-ipgap-linecheck-quirk");
+	dwc->dis_mult_trb_fetch = device_property_read_bool(dev,
+				"snps,dis-mult-trb-fetch");
 
 	dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
 				"snps,tx_de_emphasis_quirk");
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6315c0fa28b5..49692d88f15b 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -146,6 +146,7 @@
 #define DWC3_DSTS		0xc70c
 #define DWC3_DGCMDPAR		0xc710
 #define DWC3_DGCMD		0xc714
+#define DWC32_DCTL1		0xc718 /* DWC_usb32 only */
 #define DWC3_DALEPENA		0xc720
 
 #define DWC3_DEP_BASE(n)	(0xc800 + ((n) * 0x10))
@@ -441,6 +442,8 @@
 #define DWC3_DCTL_ULSTCHNG_COMPLIANCE	(DWC3_DCTL_ULSTCHNGREQ(10))
 #define DWC3_DCTL_ULSTCHNG_LOOPBACK	(DWC3_DCTL_ULSTCHNGREQ(11))
 
+#define DWC32_DCTL1_SINGLE_TRB_FETCH	BIT(0)
+
 /* Device Event Enable Register */
 #define DWC3_DEVTEN_VNDRDEVTSTRCVEDEN	BIT(12)
 #define DWC3_DEVTEN_EVNTOVERFLOWEN	BIT(11)
@@ -1040,6 +1043,7 @@ struct dwc3_scratchpad_array {
  *			change quirk.
  * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate
  *			check during HS transmit.
+ * @dis_mult_trb_fetch: set to disable multiple TRB cache
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
  * @tx_de_emphasis: Tx de-emphasis value
  * 	0	- -6dB de-emphasis
@@ -1229,6 +1233,7 @@ struct dwc3 {
 	unsigned		dis_u2_freeclk_exists_quirk:1;
 	unsigned		dis_del_phy_power_chg_quirk:1;
 	unsigned		dis_tx_ipgap_linecheck_quirk:1;
+	unsigned		dis_mult_trb_fetch:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
 	unsigned		tx_de_emphasis:2;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index cd478de6c008..60bed79f0681 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3506,6 +3506,18 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 		goto err4;
 	}
 
+	if (dwc3_is_usb32(dwc) && dwc->dis_mult_trb_fetch) {
+		u32 reg;
+
+		/*
+		 * For optimal performance, set DCTL1.SINGLE_TRB_FETCH_EN
+		 * if the number of trb prefetch is 2 or less.
+		 */
+		reg = dwc3_readl(dwc->regs, DWC32_DCTL1);
+		reg |= DWC32_DCTL1_SINGLE_TRB_FETCH;
+		dwc3_writel(dwc->regs, DWC32_DCTL1, reg);
+	}
+
 	if (dwc3_is_usb32(dwc) && dwc->maximum_lsm)
 		dwc3_gadget_set_sublink_attr(&dwc->gadget,
 					     dwc->maximum_lanes,
-- 
2.11.0


      parent reply	other threads:[~2019-12-12  2:50 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12  2:48 [RFC PATCH 00/14] usb: dwc3: Introduce DWC_usb32 Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 01/14] usb: gadget: Add lane count and lsm Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 02/14] usb: gadget: Add callback to set lane and transfer rate Thinh Nguyen
2019-12-12  7:58   ` Felipe Balbi
2019-12-12 15:49     ` Alan Stern
2019-12-12 22:33       ` Thinh Nguyen
2019-12-12 22:10     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 03/14] usb: composite: Properly report lsm Thinh Nguyen
2019-12-12  7:59   ` Felipe Balbi
2019-12-12 22:10     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 04/14] usb: dwc3: Implement new id check for DWC_usb32 Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 05/14] usb: dwc3: Update IP checks to support DWC_usb32 Thinh Nguyen
2019-12-12  8:05   ` Felipe Balbi
2019-12-12 22:12     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 06/14] usb: devicetree: dwc3: Add max lane and lsm Thinh Nguyen
2019-12-12  8:06   ` Felipe Balbi
2019-12-19 22:09   ` Rob Herring
2019-12-19 22:49     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 07/14] usb: dwc3: gadget: Set lane count " Thinh Nguyen
2019-12-12  8:14   ` Felipe Balbi
2019-12-12 22:15     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 08/14] usb: dwc3: gadget: Track connected lane count and speed Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 09/14] usb: dwc3: gadget: Limit the setting of speed Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 10/14] usb: dwc3: Update HWPARAMS0.MDWIDTH for DWC_usb32 Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 11/14] usb: devicetree: dwc3: Add TRB prefetch count Thinh Nguyen
2019-12-12  8:18   ` Felipe Balbi
2019-12-12 22:16     ` Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 12/14] usb: dwc3: gadget: Set number of TRB prefetch Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 13/14] usb: devicetree: dwc3: Add property to disable mult TRB fetch Thinh Nguyen
2019-12-12  8:19   ` Felipe Balbi
2019-12-12 22:28     ` Thinh Nguyen
2019-12-13  7:04       ` Felipe Balbi
2019-12-13 20:10         ` Thinh Nguyen
2019-12-19 22:17         ` Rob Herring
2019-12-19 22:51           ` Thinh Nguyen
2019-12-20 22:11             ` Rob Herring
2019-12-20 23:52               ` Thinh Nguyen
2019-12-12  2:50 ` Thinh Nguyen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13d33d2a4f4425f85aae6aad545fdd3c06ec3a69.1576118671.git.thinhn@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=John.Youn@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.