All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders Roxell <anders.roxell@linaro.org>
To: u-boot@lists.denx.de, marex@denx.de
Cc: mkorpershoek@kernel.org, ilias.apalodimas@linaro.org,
	trini@konsulko.com, michal.simek@amd.com, alchark@flipper.net,
	jerome.forissier@arm.com,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Simon Glass <sjg@chromium.org>,
	Anders Roxell <anders.roxell@linaro.org>,
	Marek Vasut <marek.vasut+usb@mailbox.org>,
	Lukasz Majewski <lukma@denx.de>,
	u-boot@lists.u-boot-project.org
Subject: [PATCH v6 24/87] usb: dwc3: import from kernel v4.20
Date: Fri, 21 Aug 2026 10:47:00 +0200	[thread overview]
Message-ID: <20260821084829.2070426-25-anders.roxell@linaro.org> (raw)
In-Reply-To: <20260821084829.2070426-1-anders.roxell@linaro.org>

From: Jens Wiklander <jens.wiklander@linaro.org>

Sync Linux kernel dwc3 changes from v4.19 to v4.20.

The following files are preserved across the import:
Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c
dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c
dwc3-layerscape.c ti_usb_phy.c

Skipping unused files:
debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c
dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c
dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c

Note that this is a raw import and doesn't build.
A fixup commit at the end of the series fixes that.

List of commits: git log --oneline v4.19..v4.20
Commits imported:
38317f5c0f2f Revert "usb: dwc3: gadget: skip Set/Clear Halt when invalid"
2fc6d4be35fb usb: dwc3: gadget: fix ISOC TRB type on unaligned transfers
ba3a51ac32eb usb: dwc3: gadget: Properly check last unaligned/zero chain TRB
08fd9a82fda8 usb: dwc3: core: Clean up ULPI device
6af19fd10595 usb: dwc3: Fix spelling of 'optimizations'
87dd96111b0b usb: dwc3: gadget: Check ENBLSLPM before sending ep command

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
 drivers/usb/dwc3/core.c   |  3 ++-
 drivers/usb/dwc3/gadget.c | 42 +++++++++++++++++++++------------------
 2 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 88c80fcc39f5..2f2048aa5fde 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -756,7 +756,7 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 
 	/* check if current dwc3 is on simulation board */
 	if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
-		dev_info(dwc->dev, "Running with FPGA optmizations\n");
+		dev_info(dwc->dev, "Running with FPGA optimizations\n");
 		dwc->is_fpga = true;
 	}
 
@@ -1499,6 +1499,7 @@ static int dwc3_probe(struct platform_device *pdev)
 
 err5:
 	dwc3_event_buffers_cleanup(dwc);
+	dwc3_ulpi_exit(dwc);
 
 err4:
 	dwc3_free_scratch_buffers(dwc);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 2b53194081ba..9f92ee03dde7 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -270,27 +270,36 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 	const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
 	struct dwc3		*dwc = dep->dwc;
 	u32			timeout = 1000;
+	u32			saved_config = 0;
 	u32			reg;
 
 	int			cmd_status = 0;
-	int			susphy = false;
 	int			ret = -EINVAL;
 
 	/*
-	 * Synopsys Databook 2.60a states, on section 6.3.2.5.[1-8], that if
-	 * we're issuing an endpoint command, we must check if
-	 * GUSB2PHYCFG.SUSPHY bit is set. If it is, then we need to clear it.
+	 * When operating in USB 2.0 speeds (HS/FS), if GUSB2PHYCFG.ENBLSLPM or
+	 * GUSB2PHYCFG.SUSPHY is set, it must be cleared before issuing an
+	 * endpoint command.
 	 *
-	 * We will also set SUSPHY bit to what it was before returning as stated
-	 * by the same section on Synopsys databook.
+	 * Save and clear both GUSB2PHYCFG.ENBLSLPM and GUSB2PHYCFG.SUSPHY
+	 * settings. Restore them after the command is completed.
+	 *
+	 * DWC_usb3 3.30a and DWC_usb31 1.90a programming guide section 3.2.2
 	 */
 	if (dwc->gadget.speed <= USB_SPEED_HIGH) {
 		reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
 		if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) {
-			susphy = true;
+			saved_config |= DWC3_GUSB2PHYCFG_SUSPHY;
 			reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
-			dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
 		}
+
+		if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) {
+			saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
+			reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
+		}
+
+		if (saved_config)
+			dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
 	}
 
 	if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
@@ -389,9 +398,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 		}
 	}
 
-	if (unlikely(susphy)) {
+	if (saved_config) {
 		reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
-		reg |= DWC3_GUSB2PHYCFG_SUSPHY;
+		reg |= saved_config;
 		dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
 	}
 
@@ -1072,7 +1081,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
 			/* Now prepare one extra TRB to align transfer size */
 			trb = &dep->trb_pool[dep->trb_enqueue];
 			__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr,
-					maxp - rem, false, 0,
+					maxp - rem, false, 1,
 					req->request.stream_id,
 					req->request.short_not_ok,
 					req->request.no_interrupt);
@@ -1116,7 +1125,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
 		/* Now prepare one extra TRB to align transfer size */
 		trb = &dep->trb_pool[dep->trb_enqueue];
 		__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem,
-				false, 0, req->request.stream_id,
+				false, 1, req->request.stream_id,
 				req->request.short_not_ok,
 				req->request.no_interrupt);
 	} else if (req->request.zero && req->request.length &&
@@ -1132,7 +1141,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
 		/* Now prepare one extra TRB to handle ZLP */
 		trb = &dep->trb_pool[dep->trb_enqueue];
 		__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
-				false, 0, req->request.stream_id,
+				false, 1, req->request.stream_id,
 				req->request.short_not_ok,
 				req->request.no_interrupt);
 	} else {
@@ -1461,9 +1470,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
 		unsigned transfer_in_flight;
 		unsigned started;
 
-		if (dep->flags & DWC3_EP_STALL)
-			return 0;
-
 		if (dep->number > 1)
 			trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
 		else
@@ -1485,8 +1491,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
 		else
 			dep->flags |= DWC3_EP_STALL;
 	} else {
-		if (!(dep->flags & DWC3_EP_STALL))
-			return 0;
 
 		ret = dwc3_send_clear_stall_ep_cmd(dep);
 		if (ret)
@@ -2250,7 +2254,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
 	 * with one TRB pending in the ring. We need to manually clear HWO bit
 	 * from that TRB.
 	 */
-	if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) {
+	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
 		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 		return 1;
 	}
-- 
2.53.0


  parent reply	other threads:[~2026-08-21 13:14 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260821084829.2070426-1-anders.roxell@linaro.org>
2026-08-21  8:46 ` [PATCH v6 01/87] usb: host: re-import xhci-ext-caps.h from kernel v6.16 Anders Roxell
2026-08-21 19:44   ` Tom Rini
2026-08-22  4:22     ` Marek Vasut
2026-08-23 18:44       ` Anders Roxell
2026-08-23 18:59         ` Tom Rini
2026-08-23 19:08           ` Anders Roxell
2026-08-23 20:57             ` Tom Rini
2026-08-21  8:46 ` [PATCH v6 02/87] usb: dwc3: restore to original v3.19-rc1 kernel import Anders Roxell
2026-08-21  8:46 ` [PATCH v6 03/87] usb: dwc3: import from kernel v3.19 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 04/87] usb: dwc3: import from kernel v4.0 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 05/87] usb: dwc3: import from kernel v4.1 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 06/87] usb: dwc3: import from kernel v4.2 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 07/87] usb: dwc3: import from kernel v4.3 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 08/87] usb: dwc3: import from kernel v4.4 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 09/87] usb: dwc3: import from kernel v4.5 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 10/87] usb: dwc3: import from kernel v4.6 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 11/87] usb: dwc3: import from kernel v4.7 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 12/87] usb: dwc3: import from kernel v4.8 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 13/87] usb: dwc3: import from kernel v4.9 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 14/87] usb: dwc3: import from kernel v4.10 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 15/87] usb: dwc3: import from kernel v4.11 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 16/87] usb: dwc3: import from kernel v4.12 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 17/87] usb: dwc3: import from kernel v4.13 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 18/87] usb: dwc3: import from kernel v4.14 Anders Roxell
2026-08-24  8:54   ` Mattijs Korpershoek
2026-08-21  8:46 ` [PATCH v6 19/87] usb: dwc3: import from kernel v4.15 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 20/87] usb: dwc3: import from kernel v4.16 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 21/87] usb: dwc3: import from kernel v4.17 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 22/87] usb: dwc3: import from kernel v4.18 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 23/87] usb: dwc3: import from kernel v4.19 Anders Roxell
2026-08-21  8:47 ` Anders Roxell [this message]
2026-08-21  8:47 ` [PATCH v6 25/87] usb: dwc3: import from kernel v5.0 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 26/87] usb: dwc3: import from kernel v5.1 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 27/87] usb: dwc3: import from kernel v5.2 Anders Roxell
2026-08-24  8:57   ` Mattijs Korpershoek
2026-08-21  8:47 ` [PATCH v6 28/87] usb: dwc3: import from kernel v5.3 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 29/87] usb: dwc3: import from kernel v5.4 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 30/87] usb: dwc3: import from kernel v5.5 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 31/87] usb: dwc3: import from kernel v5.6 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 32/87] usb: dwc3: import from kernel v5.7 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 33/87] usb: dwc3: import from kernel v5.8 Anders Roxell
2026-08-24  8:59   ` Mattijs Korpershoek
2026-08-21  8:47 ` [PATCH v6 34/87] usb: dwc3: import from kernel v5.9 Anders Roxell
2026-08-24  9:00   ` Mattijs Korpershoek
2026-08-21  8:47 ` [PATCH v6 35/87] usb: dwc3: import from kernel v5.10 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 36/87] usb: dwc3: import from kernel v5.11 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 37/87] usb: dwc3: import from kernel v5.12 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 38/87] usb: dwc3: import from kernel v5.13 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 39/87] usb: dwc3: import from kernel v5.14 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 40/87] usb: dwc3: import from kernel v5.15 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 41/87] usb: dwc3: import from kernel v5.16 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 42/87] usb: dwc3: import from kernel v5.17 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 43/87] usb: dwc3: import from kernel v5.18 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 44/87] usb: dwc3: import from kernel v5.19 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 45/87] usb: dwc3: import from kernel v6.0 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 46/87] usb: dwc3: import from kernel v6.1 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 47/87] usb: dwc3: import from kernel v6.2 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 48/87] usb: dwc3: import from kernel v6.3 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 49/87] usb: dwc3: import from kernel v6.4 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 50/87] usb: dwc3: import from kernel v6.5 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 51/87] usb: dwc3: import from kernel v6.6 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 52/87] usb: dwc3: import from kernel v6.7 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 53/87] usb: dwc3: import from kernel v6.8 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 54/87] usb: dwc3: import from kernel v6.9 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 55/87] usb: dwc3: import from kernel v6.10 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 56/87] usb: dwc3: import from kernel v6.11 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 57/87] usb: dwc3: import from kernel v6.12 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 58/87] usb: dwc3: import from kernel v6.13 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 59/87] usb: dwc3: import from kernel v6.14 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 60/87] usb: dwc3: import from kernel v6.15 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 61/87] usb: dwc3: import from kernel v6.16 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 62/87] usb: gadget: re-import epautoconf.c " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 63/87] usb: udc: re-import udc-core.c " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 64/87] dm: add helpers needed by the resynced DWC3 code Anders Roxell
2026-08-21  8:47 ` [PATCH v6 65/87] usb: phy: add the usb_phy " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 66/87] usb: gadget: adapt the gadget API after the resync Anders Roxell
2026-08-21  8:47 ` [PATCH v6 67/87] usb: gadget: udc: make udc-core build in u-boot Anders Roxell
2026-08-21  8:47 ` [PATCH v6 68/87] usb: dwc3: make the core driver " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 69/87] usb: dwc3: bring back the samsung usb phy driver Anders Roxell
2026-08-21  8:47 ` [PATCH v6 70/87] usb: dwc3: make gadget and ep0 build in u-boot Anders Roxell
2026-08-21  8:47 ` [PATCH v6 71/87] usb: gadget: udc: enable async callbacks on bind Anders Roxell
2026-08-21  8:47 ` [PATCH v6 72/87] usb: dwc3: ep0: flush and invalidate cache around ep0 transfers Anders Roxell
2026-08-21  8:47 ` [PATCH v6 73/87] usb: dwc3: make the am62 glue build in u-boot Anders Roxell
2026-08-21  8:47 ` [PATCH v6 74/87] usb: gadget: ci_udc: move to the udc-core registration Anders Roxell
2026-08-21  8:47 ` [PATCH v6 75/87] usb: gadget: ci_udc: set endpoint capabilities Anders Roxell
2026-08-21  8:47 ` [PATCH v6 76/87] usb: gadget: dwc2_udc_otg: fix up after the resync Anders Roxell
2026-08-21  8:47 ` [PATCH v6 77/87] usb: gadget: fix up the function drivers " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 78/87] usb: gadget: fix up the last UDC " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 79/87] usb: gadget: atmel_usba_udc: set endpoint capabilities Anders Roxell
2026-08-21  8:47 ` [PATCH v6 80/87] usb: gadget: at91_udc: register with udc-core Anders Roxell
2026-08-21  8:47 ` [PATCH v6 81/87] usb: gadget: at91_udc: set endpoint capabilities Anders Roxell
2026-08-21  8:47 ` [PATCH v6 82/87] usb: musb-new: fix up after the resync Anders Roxell
2026-08-21  8:47 ` [PATCH v6 83/87] usb: musb-new: set endpoint capabilities Anders Roxell
2026-08-21  8:48 ` [PATCH v6 84/87] usb: mtu3: fix up after the resync Anders Roxell

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=20260821084829.2070426-25-anders.roxell@linaro.org \
    --to=anders.roxell@linaro.org \
    --cc=alchark@flipper.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jens.wiklander@linaro.org \
    --cc=jerome.forissier@arm.com \
    --cc=lukma@denx.de \
    --cc=marek.vasut+usb@mailbox.org \
    --cc=marex@denx.de \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=u-boot@lists.u-boot-project.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.