From patchwork Wed Jul 24 15:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 814168 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2813660wro; Wed, 24 Jul 2024 08:48:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUa3Hoh2uEg1I+eWaVjV+qfwmbYK21hrodEjA6LeI5DeSiEWQ03K18Ogef1IMDsUhgvSxjDAyI1KaCR3ZBxGh4q X-Google-Smtp-Source: AGHT+IGN0JsfJKR234LFq/OptaCOSOaeMu4g0lS1vEBqfaTN5v1hb6f5C110i2ZtFpmjMD+9B2sK X-Received: by 2002:a05:600c:4591:b0:426:6edf:6597 with SMTP id 5b1f17b1804b1-427f7a32720mr21702585e9.19.1721836101536; Wed, 24 Jul 2024 08:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721836101; cv=none; d=google.com; s=arc-20160816; b=HXCPzI8cqaDRyIZdsCIAoqyeUVGFlVL5WPThR+ZveWOb5ni7xDVoCabM32i4iDijPM IQjVIifyEUHz9BUfZPXAihtdcEtUsw5hqEQNcjPD+jatOk6KHDCoaIPCWbEL6NCBuRFO BJVvtt1wa8KKypV3SWJtzEcOZkoy7Rkzc1Uk3xPLzwV+uLEX+5Tfx9ctuF+ZFOotCtqi AgIaO1RSkaeTIriGgybzxf199ZPgayAEAhe88rva4cwyiAYRmeGzrR780/q9AlbO9vze nmzEXIHNaKqRTX5MZlVEq7AKVMy22V5RJ9sWoKA8mwcMOQa3iFn0p1j4bJ6S/jeEQQE0 EYKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=QBd6NvMy/fWSFw4JFGKRaGpPxX2t0h4CS/mrUUn4lmk=; fh=j9wSnfhe58IFhK/NTbMxZkI5JXRxlOx1KCe7+BCpzIQ=; b=PArSwi9T8ozugjqgzdruB9xJIVJOBCU643J7d/fOPHTqoZ/AujOu6j91yEN/6TtOwb erdkx6HyHwIB8JGBOUH5NaEfN5AaSTDNzoc9zavUH8staW/t0e7cNwnLC2xsAMap4uBR s+g/WmxgXvqr+SjUTfB0rhsf60aogibxzhTVsT1OzFTVc6H5uzyfxo9mPqVv4lpWiNCs gGKHhUEjblwYNGIMwrtIbZovJppbj1SwnpiXFZipV0Qfv8tFOYZDcLxOrcLdxqvmzJx4 AKLVu+fkO9jvTS6SFld9KLUKcd7wiUKxY/EZ3BZ4Xm9Kb7tnAVkaKfcm0zonkiK5xfAy STiQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KKh6YKo9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ffacd0b85a97d-369e365dc99si1890497f8f.201.2024.07.24.08.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:48:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KKh6YKo9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F0828897F; Wed, 24 Jul 2024 17:48:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="KKh6YKo9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E282C889AA; Wed, 24 Jul 2024 17:48:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6A49588997 for ; Wed, 24 Jul 2024 17:48:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ef2d582e31so39189951fa.2 for ; Wed, 24 Jul 2024 08:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721836097; x=1722440897; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QBd6NvMy/fWSFw4JFGKRaGpPxX2t0h4CS/mrUUn4lmk=; b=KKh6YKo97vTIrEmTopOoG4tTpVBsUhCyx0Agzo3K9KwZm0IYex9P9zTE1tRg8j67k0 MKruXKVPfHrbFdw05jKkEzMtoKWQtE0qLaQ8xpbyCFGgLsUAi34w88CUkiFTGEBZqIHV Dt0kvuDcJ5l8tEu5MhElbCvcHxgG/huHBaJdJmsqxT6hl1M7VVqNFL22kGe/JswhfwHh 3bFhmVW/7RQ7+l/fHi11FYejk8lNBaorppTlOyyI33zEwLHBUMagDYsbmTy46d9tBxny m9vCo7SY6/6SMmRU5UwmfiF1hCk+lzeYDa9ls9mR0jJY7ATNR1Q9q/1LfwmKXZ6b85oz 1AfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836097; x=1722440897; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QBd6NvMy/fWSFw4JFGKRaGpPxX2t0h4CS/mrUUn4lmk=; b=QHcrJfCdjbM5MC14iZG7WnQuR9tuPhTFwhVgoPDUoSbg8N7gdEXclU0yS11pwk0Maz W0kQdZlQidPeboRq7YDgYku63JqIM/rDbVVxjMgM4TIvp0kRSM9xBTdYquG/Ycubf/VM +tQerADGpkSJnLP88291hf8xbdSt47BDGBvbbMvqH3LEYHY+syPruCNwAYgB2XOrtZkS +0RWpSmJrDbY/og6imBrrUeXvfcJ/a40ZmP3PXUkd+SDeg3E15yRn07BdYhVmfySA4gb SqdFNBG5ntwRbCCKiujAhsA8v0tzdpp7yuOLAEl3/UThtSN5eqabzivXRPKwoMAtcc+L HHDg== X-Forwarded-Encrypted: i=1; AJvYcCUW8WxNHAtVPenWtUnVty6VuLsymWIoXHSblvYo/edR2YkI+lpkF0eapYJAdxDViLJxAHmueQRmEWqk/BdKONBpBEk5Vw== X-Gm-Message-State: AOJu0Ywnu7PzrAnD7bKTKhSmsAAOcS4Sr3MIfv0XRrM/rkt5d7L3cCgj QkDD0yHVZK1VmopSTr5MixT49AN7Myug1KVBOoOy3yKG+FqbAlj3Ha2QhuKdMAk= X-Received: by 2002:a05:651c:155:b0:2ef:2d6e:58fe with SMTP id 38308e7fff4ca-2f039d8f959mr1640461fa.32.1721836096453; Wed, 24 Jul 2024 08:48:16 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f93aabdasm33633015e9.36.2024.07.24.08.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:48:16 -0700 (PDT) From: Neil Armstrong Date: Wed, 24 Jul 2024 17:48:09 +0200 Subject: [PATCH v2 1/3] usb: dwc3: allocate setup_buf with dma_alloc_coherent() MIME-Version: 1.0 Message-Id: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-1-65836d699a71@linaro.org> References: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-0-65836d699a71@linaro.org> In-Reply-To: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-0-65836d699a71@linaro.org> To: Marek Vasut , Tom Rini , Lukasz Majewski , Mattijs Korpershoek Cc: Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3246; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=has3gz/aM0afGUQH4DsnuFvgyVLWYivVIH5LE+Ha1CQ=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmoSI8MkKh3L4swJmpflbdl3MWyGtAOz/NRgQoa9av tmAmuCGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZqEiPAAKCRB33NvayMhJ0XeBEA DQc+Cod6NbnTf+qYDPFanw5uvYv6SDCKodcddonGDpE57Gx9wmgpCWHUtKZ26IYPDA/rtnsVlauP9N OuHbLErvVDTKdfEKI4uu7yfouaHMtguoQzescldKUKLjw4+Jzj2tPyo/ET8O1ySqDEErUzxCn4ngvn F7pkUV4QWTzq8RxO2RIbOH8RafF5rzJ4ed9/jOMCamN72yNWe5gZgKZD96DpQ19Qbn/9DFB5WO65ke Ce4MRY5buo6pMRB403VSEJecZCsaW0g4G1LYz+rYqPxWIAA8oET9E8/LkOmI8C88aoRzjJh+Z2XOc/ fJK8wW++eRRntr1qkUbK3H7WAz6AuKeiVXtnn3C6OTLDa+0jQUmYQYfgVmPdmzhh4M/oHspqp8RJ5n fpZYPFqvaqsQ3AJB4T/bwHzk3aYSLerBI55OXPpS4aXHT1huk4ZZq4NVm/CEQJdvQbhX2ckj4icz2Z lIyUEyI/k1elJWX8eLD7klyo6joZ/wf5KR8V4W5pPOqhuCO9x6ZHeGG0wdX95KS3itMJppoFM4/T8w QJNMDKPnjvIzyumyQ+EIElM+UHIFl1VEL4pYWNHec8b/6/5MFO4JeXIVYUQ9O/GyxCQkGhhYVVtGHT odwNXngDh7eEqf+wECX19Zxmbixm8gHQhKk8hL5f+6yERVVgz6CMpMr9pRbA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Since setup_buf is also consumed by hardware DMA, aligns it's allocation like other hardware buffers by introduce setup_buf_addr populated by dma_alloc_coherent(), and use it to pass the physical address of the buffer to the hardware. Reviewed-by: Mattijs Korpershoek Signed-off-by: Neil Armstrong --- drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/ep0.c | 4 ++-- drivers/usb/dwc3/gadget.c | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 7374ce950da..b572ea340c8 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -670,6 +670,7 @@ struct dwc3_scratchpad_array { * @ep0_trb: dma address of ep0_trb * @ep0_usb_req: dummy req used while handling STD USB requests * @ep0_bounce_addr: dma address of ep0_bounce + * @setup_buf_addr: dma address of setup_buf * @scratch_addr: dma address of scratchbuf * @lock: for synchronizing * @dev: pointer to our struct device @@ -757,6 +758,7 @@ struct dwc3 { dma_addr_t ep0_trb_addr; dma_addr_t ep0_bounce_addr; dma_addr_t scratch_addr; + dma_addr_t setup_buf_addr; struct dwc3_request ep0_usb_req; /* device lock */ diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 16b11ce3d9f..0c7e0123368 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -381,7 +381,7 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc, dep = dwc->eps[0]; dwc->ep0_usb_req.dep = dep; dwc->ep0_usb_req.request.length = sizeof(*response_pkt); - dwc->ep0_usb_req.request.buf = dwc->setup_buf; + dwc->ep0_usb_req.request.buf = (void *)dwc->setup_buf_addr; dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl; return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req); @@ -663,7 +663,7 @@ static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) dep = dwc->eps[0]; dwc->ep0_usb_req.dep = dep; dwc->ep0_usb_req.request.length = dep->endpoint.maxpacket; - dwc->ep0_usb_req.request.buf = dwc->setup_buf; + dwc->ep0_usb_req.request.buf = (void *)dwc->setup_buf_addr; dwc->ep0_usb_req.request.complete = dwc3_ep0_set_sel_cmpl; return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req); diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 7d6bcc2627f..d41b590afb8 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2622,8 +2622,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err1; } - dwc->setup_buf = memalign(CONFIG_SYS_CACHELINE_SIZE, - DWC3_EP0_BOUNCE_SIZE); + dwc->setup_buf = dma_alloc_coherent(DWC3_EP0_BOUNCE_SIZE, + (unsigned long *)&dwc->setup_buf_addr); if (!dwc->setup_buf) { ret = -ENOMEM; goto err2; @@ -2670,7 +2670,7 @@ err4: dma_free_coherent(dwc->ep0_bounce); err3: - kfree(dwc->setup_buf); + dma_free_coherent(dwc->setup_buf); err2: dma_free_coherent(dwc->ep0_trb); @@ -2692,7 +2692,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc) dma_free_coherent(dwc->ep0_bounce); - kfree(dwc->setup_buf); + dma_free_coherent(dwc->setup_buf); dma_free_coherent(dwc->ep0_trb); From patchwork Wed Jul 24 15:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 814170 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2813753wro; Wed, 24 Jul 2024 08:48:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVw4AE8yEdKXtE0wRxB12IDmKqYtJBAvAHTV038iN5K1uGOXm1XtEnKAGBhtlwohjJOec/mj7B0VTalvUATBmnH X-Google-Smtp-Source: AGHT+IGUIiqAP8QNCYFW+KsOCZZSWzPRjI+HQrqmHErnp7vMPWfl/wO+EJ9WSFlCGa8VXDZHanVn X-Received: by 2002:a05:6000:110b:b0:367:8f89:f7c9 with SMTP id ffacd0b85a97d-36b31baa3b3mr7476f8f.33.1721836121234; Wed, 24 Jul 2024 08:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721836121; cv=none; d=google.com; s=arc-20160816; b=zPKCTuIbbUbRtllH5WEITWXihRHc0+JpvBN9JGu780TDvHs/ehvnk2nkaW0lPl00I9 xzESCndNlGpLsD9I1Yp87D7AUC0XNEWCAAPoDHlw6Z+AFJNQJVh7+iVRbPyZJyLzKO09 O3DLMOVa2lJYQRuD/5e8GSnemtFAig/SLA7r8pf+WUHSWHUjHJDyumKHb/7WNNbfc2Vl wmRXA8M6KNOMTX7QbkzJEV6mk2SZjJ7EeanvQxBTi5wJGLkSlKxuVJh1o2WxxcFWi3rL iET9J1itpOSYnen12vsRB38FhYcmTISm1uT+mNCkwuqRptjKixoe/oWEuPM107dJcw+E W2Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=5GUX+/hleNqxcTaZXAgRavQAAtag56nexX+KTS2glto=; fh=+BJFgnxXI8A+nBgnRdXm2lRfDQ1R9FObSMQpU2rFBR8=; b=XSSDhhgL72dp5PFvnXCwh5VCg1Qm3CwQfjqozvhP0frb5qPkh3etSwRADOOiRVSOdO lxDdCoPJMcHC/q2S7RzjO6COCwRVCON9dGqi3yp0Ljvwxyha5FE4oa5mh9alaXmrWuxe XdbMGfNJv2WP1n4QrD6GFu71TOD8w2v2zMd0ZwCVUTLDfwsghEy4qXZCqk+sTH4J/y52 tstx1LM/zp/aX4awOk6TRIsL0OcPp+9lxW04eOWmK+e1Y8L6/Uw6xdqSkBLf7vq/cfRv pl0ews2/XndJyFcnaVHTzG3VjXz/75mGtwJE/oqUMk+4oYxV9eDY0FtIkR1JMHlGfSlG d3Ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LHdxdO1u; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ffacd0b85a97d-369e3818a0asi1812436f8f.517.2024.07.24.08.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LHdxdO1u; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1663088929; Wed, 24 Jul 2024 17:48:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LHdxdO1u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2E308818B; Wed, 24 Jul 2024 17:48:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1749088929 for ; Wed, 24 Jul 2024 17:48:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-368313809a4so684261f8f.0 for ; Wed, 24 Jul 2024 08:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721836097; x=1722440897; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5GUX+/hleNqxcTaZXAgRavQAAtag56nexX+KTS2glto=; b=LHdxdO1u5froPAdJ3KsDFx+8oJDvWladhvz+OXzj8lB4mN/DcmQqtcr2lFeb5Fm9BW 4LX70NJLvkMcd8Oj+0gECIXt4ggYlC/zmxiEs2ufAUkY4bHA/ny1iJvBtchFGEszBicr 8yJUyWck20opNlmskHQpnsHM2pRlzjZ6RyMwTbmSiEJZO7j012FzAX6GsIKvockIccB5 tPcq8u1fbIWUZAG0z6f2nCHXTfeqazc0IP/GZjnUr4xu/j1Bl7k7ZEHGKKvFpSan1uNh fjESpz5xklvmSeDmkxLyjDoFkNQgxAyTwIrcWVQY4UnxVxwAsANNx2WaAlRzFMfeBj3L wSXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836097; x=1722440897; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5GUX+/hleNqxcTaZXAgRavQAAtag56nexX+KTS2glto=; b=XzZNnA3IFjn007fPEs1mQixhelbDpm+arU08uCp6BudjUvmh3MQ9YFD63D0eKfVh1W N/1QS2rDYWr9PjuBvNyc/cR1m6y7V/FfBhCbxkJPsESZhQz0bGE9KLkCpmm9laOq0HZA Hv10EpCbMuCFyUHwvZnwGSpNVKJhTq9tTfNZ0WAlKEy6gtsjpacVlZVcGWdbhtusAF0K C1W9c9lCuQKA3SMh1jdeJ/pSSIbOU6WMHIlszGV+S2jjm6Jo1rIK39YENzIZ+78HQ8/y ZaCo+Q4/cKr1E+RzqmbJidl7awdo82yXliPPkDlZqloK6Xk3iGbYSR1fihx5FZ1nmTzD bFAg== X-Forwarded-Encrypted: i=1; AJvYcCVqSQ/RjBn1ZsPMctdGWhkSH02mUKfJfi+lZsx4wsZhDo1V38f9sOWrRoK572JorSu8jUI2YGyJB9C1pTKwQziKgW/HXQ== X-Gm-Message-State: AOJu0Yy1q0im30+8fO/+N+4LRscg+tifXrD55HHUhEj3CITEGwVsrRmT z3PvqHPd4nKui+/q3HhGVHlL5jZ98ZxWYU7VSbdodVKKQI5qHnIT4Ky1HDr1zqs= X-Received: by 2002:adf:f9c5:0:b0:366:df35:b64f with SMTP id ffacd0b85a97d-369f6667e81mr1923295f8f.4.1721836097389; Wed, 24 Jul 2024 08:48:17 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f93aabdasm33633015e9.36.2024.07.24.08.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:48:17 -0700 (PDT) From: Neil Armstrong Date: Wed, 24 Jul 2024 17:48:10 +0200 Subject: [PATCH v2 2/3] usb: dwc3: fix dcache flush range calculation MIME-Version: 1.0 Message-Id: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-2-65836d699a71@linaro.org> References: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-0-65836d699a71@linaro.org> In-Reply-To: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-0-65836d699a71@linaro.org> To: Marek Vasut , Tom Rini , Lukasz Majewski , Mattijs Korpershoek Cc: Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1172; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=srY3udycfvqYMAFtZZ11qUpBrqT3tgodDPaWL7DnMTs=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmoSI8fsFRKV70il9VEJqdZNr1wcJolgjcgpszJhKZ +OXeJhaJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZqEiPAAKCRB33NvayMhJ0Vt0D/ 0eq6hnxu9FDrX1Y1nlW0a0Z0k2e6o24IWb9IwzyNBoTQATaQGd6rIVn8oYQne7AndiTJP2qi3pmVyW 1a5hrwHXQ9tcS2vcw5xibG/NZEfNKtN/7pycBhMRgAPScpEdffDNcPN+AWaXZ10ose3gXy489HXN4m JDQK2K3c+Ku77XcbO3yjXaibxux0Qs/o0Kc3nwMAI43bFD9HT8uW84rgfrcVeFx/4mAc9trC1lcXk1 nHfooUQ0uZxF4//I9BccyK+V023LBwB5sXY2XXznjGS92Tm/wtGiCyLiwp/n5xER7nvHkLUJ72r833 4U4EuDRoanRkUDpQqxcBh9UCPod4rd2uSzteobjh9JdUl0S3vS86WPB9b0I4i1/Kijo5qezZlmOGKw memsoQcPaRFycidZaXp81uusNbiOV3IaepqGUbxBVI9pustDD3w5o+ec5qvJ0SRw1DsNBzyC96MQUQ OvMWK7xtL7JR6/Y1jvyhcREt6SF4X+5Ec7WCrxgJBwYnQnu28My3Qo5ppfgFKfqcyOokHnA17IfNB2 615gouZaRf0AhpQG12+Fjh2pWd0K8RZI/idx6xAocUu+9Fi0QozZCMvUNPQj+8AYxuL32cmi2epIKw VQs/iCoSxXvkZ4AR1Jo7LR7uF4L68XZRurkJyVi+mAMsDnylNsg/CpsqW9MA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The current flush operation will omit doing a flush/invalidate on the first and last bytes if the base address and size are not aligned with DMA_MINALIGN. This causes operation failures Qualcomm platforms. Take in account the alignment and size of the buffer and also flush the previous and last cacheline. Reviewed-by: Mattijs Korpershoek Signed-off-by: Neil Armstrong --- drivers/usb/dwc3/io.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index 04791d4c9be..1aaf5413c6d 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -50,6 +50,9 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) static inline void dwc3_flush_cache(uintptr_t addr, int length) { - flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE)); + uintptr_t start_addr = (uintptr_t)addr & ~(ARCH_DMA_MINALIGN - 1); + uintptr_t end_addr = ALIGN((uintptr_t)addr + length, ARCH_DMA_MINALIGN); + + flush_dcache_range(start_addr, end_addr); } #endif /* __DRIVERS_USB_DWC3_IO_H */ From patchwork Wed Jul 24 15:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 814171 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2813807wro; Wed, 24 Jul 2024 08:48:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWtQJGPIkN6xY3g2ngxEVRrQkAupCRkcXBJttKat7PemasodPmsECMUSal9TwjkGIIBC5qyPjL/KOr6HAU14m3h X-Google-Smtp-Source: AGHT+IEjPImLYTvEOOqmr6tkkfBZ5G2jzgS005rFQ1IppA1u+itZ+mb7Bj268HHLQOZ/Q8DNkKH7 X-Received: by 2002:a05:600c:1d14:b0:426:60bc:8f4e with SMTP id 5b1f17b1804b1-427f954225dmr19713905e9.5.1721836131890; Wed, 24 Jul 2024 08:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721836131; cv=none; d=google.com; s=arc-20160816; b=KO+qSw4bPWqCwF9qtRJxvEEXjgdwGCbQmqO45RXWr3/WZppeDH7S1Az8pByebBUb5I xHlUik97PWSZIfxrrRBalmTr5XIfvWkc0EJrMUcr/1hxwXFH0IGMJrntGm1ja1+dQ9Kq lmkDrt+D0Jm5pPpxiFrR8lLFYDCOix4om6pMZvFTJw9KzNYSv8A40iED2/KDZp3mc/RO gAvjt5lmaafPAT4cFgiZZuwEVi82nVQCNbTuIktS51n5OZieKU8ZVb6B+IkGSRMBeN+4 7jTpVYvFCDNxo52yeNeAkXkG98p1Ikoxtx9NJonmMfQBuPJE0EJkrouoeupHYZ9BjkRH /aQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Ad0hAj3rVLkU6OtNt+velqlccTC1YGRAtRCzw7xbhg0=; fh=kphrTi8lIFxkoONesYbwQuiLnGnE+Kg7/YVHth+K9Ek=; b=VFgiHQZ4T4B4OGRBQUf2JWU8P7Qk2OKnHq8fnkhAM+JD5q939SfOcXayIbLpP54AJD PeWX2q8jp0zSJ4jTia5Ld8l/NqBqWMqrkFQB78hfmjmw3WkKYIT+o4pISnGrglYx12Jd uefRUvQaVryXpRlCUCvDvWvOxiAoeHadiSEI8rngixeIOn8n5y0hoNY3rm422QVPnL4w wRse2wkrnBRdL7/2BTH/gHHzwkegcLi82E7v2xAKjDu+XdzZ+b71ofHSJia1JYbGgO90 8USSKOurRnoaJBnGoj4sRaJdSW98Rt6jRZlHxDAKVBB0Ky8af7GKFpab774amlVc0W9L auvA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ocD6TAR6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-369e384dd17si1845465f8f.1017.2024.07.24.08.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ocD6TAR6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7017888998; Wed, 24 Jul 2024 17:48:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ocD6TAR6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 172A688993; Wed, 24 Jul 2024 17:48:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CD185889A6 for ; Wed, 24 Jul 2024 17:48:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2eeb1051360so70593221fa.0 for ; Wed, 24 Jul 2024 08:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721836099; x=1722440899; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ad0hAj3rVLkU6OtNt+velqlccTC1YGRAtRCzw7xbhg0=; b=ocD6TAR6OfCv7EJkvpaM+/GMim1EsPKs+SVxZdZZ7hp9EYRb1p829/lJA4D3ZPYBpw Mya1q2jaHnr3rg9gKBGe/ka5Rj2BCUyO9KyKcr7/UWCHrQWjELCv/n+MZnRSDzfJPTA8 4pV5p4C363LWyJiZKytNEXp5/Qx3nIHZ0VEqOcZuWcxxFosKNCcyLIVf5PajTT+mFyh/ RFRpeE6Cq7fIH307s5/IOQW9IXk/kifQuF2hddLyVPJ0Z/pG8vv3PK4n2gX3i45DAYcb NH0R1DdaIZNPXRNkvrCjkRcgRHGWSNvarLU5TdU5yRUOc6UHqZzav0yoeGnuEAg+zmE6 8CJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836099; x=1722440899; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ad0hAj3rVLkU6OtNt+velqlccTC1YGRAtRCzw7xbhg0=; b=di8RGjljSPGEyPqalsQdQQVPzZxUMRbhdomBGkOjFMpqa3v9C81Bu6Q+Ss6v0r9Sy1 QZGVsI67J4KHGSheUjdUsCrRY3kDzKb+nRixt7TUGQy5q9JWyub3HvBsxB196y+1JpPW nsfnxl2j7nUiHbTSq0t27Hajy4vc9LfrjMCwFnicaSF6G7Vww59WQu8jfM9VVreBCZRr EU9vU5aIjtj+3ZwG5C4+DIGug9dlzPrCWRwi+tWt2C3/FLXHHyzeEvzeGBCIqmlDI3ts rrj9q98qHo8u97GoXNrzLiH1heSn+k3tXDQaYcwe916DJltStQev8WNz35MrR9YcYTPI x0tQ== X-Forwarded-Encrypted: i=1; AJvYcCU1XtkMaSBjI9dcSj+SjZRpj8P9Y5rxLZbAteyLsTIK9EIJj2yzsQ/GD2oIY5SqS93Hl8yeonwQZ1dtP3GecTWXX8UKZA== X-Gm-Message-State: AOJu0Yz82z7LRg+cDvVR05PhgoLYW2CUAEJArZxhby6/yJfaC1olACCF ldPZNFD3llxxxTLRic4UgxZjiBIlxbbZUTjrOuf3Ml7rVTXXt3DQ7hFleP+oMWs= X-Received: by 2002:a2e:87d3:0:b0:2ef:27ab:40e6 with SMTP id 38308e7fff4ca-2f039e14a53mr1527901fa.49.1721836098656; Wed, 24 Jul 2024 08:48:18 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f93aabdasm33633015e9.36.2024.07.24.08.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:48:17 -0700 (PDT) From: Neil Armstrong Date: Wed, 24 Jul 2024 17:48:11 +0200 Subject: [PATCH v2 3/3] usb: dwc3: invalidate dcache on buffer used in interrupt handling MIME-Version: 1.0 Message-Id: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-3-65836d699a71@linaro.org> References: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-0-65836d699a71@linaro.org> In-Reply-To: <20240724-u-boot-dwc3-gadget-dcache-fixup-v2-0-65836d699a71@linaro.org> To: Marek Vasut , Tom Rini , Lukasz Majewski , Mattijs Korpershoek Cc: Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2422; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=3gMDwcl9eQjahxC/asoDOOL8xiMqw5Kh1iWDspcId7I=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmoSI8eQRS30M5GikS3/OKz+h1cEWPN7muwjRV87Xz rvEHjM+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZqEiPAAKCRB33NvayMhJ0Q7/D/ 44oY8AqIaM5pzi1/BUjjgo6GCINpEloU6TViwVNF62L0P7Y5BFn3atd6ruf7vd6gaNBEyaB5T3bDye wGicv+MyX4SW1gh0VeEgd4Q0puflqWloDt7md/IchPntWqYc6+3kwpbDYujruSQE1sq0pbvASeqofZ f3zMAGc2NffQxLzfrNqGT95QQcQujsQ8/3p9v1p9C0zm4QGF+xx3pzcKgRR+Srj1S+QwK9A9ozTGrn LwqN0ZOheVAp+1U8rXbFwJQKGi4GGqk03cuXQDnI5TbmPDs5VT/IDhukJUxPYifarps+3iNsAVnG/i ErJcgI7LUMUPEoWCnsPm77diM6B4FpY9yqKT3YY4tTt9bxUo4vfDQw/GDFhtKxaMa0O1pMAGYiVBzW RMCI7xanOjDjsxdaw31dJKysw1BRqWd5KYPgimVTBTV/UaLysAFEXwaEjIcPI9C9kUGcHw/smzchPY 0AOVUh/ElgPctCZkKmu69wFJQ4vfAWGXKyIyZ5wdr1jSBbbywvgvic0x5RlJw7bX3jjE7lIcdEZXLW xE+9SUuqMdt9WaaMzJ2FnDEX+ovq4WGBsrJcZnOMna6Z3Herbpm/s6PRXzUvTklDn81xS9EQw8PH+1 KjKV08D+Wf77WTmidX+UznRMp5XlCWhvNNoSdMcXzsTh9jo1OpN0iiH2vYDg== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On Qualcomm systems, the setup buffer and even buffers are in a bad state at interrupt handling, so invalidate the dcache lines for the setup_buf and event buffer to make sure we read correct data written by the hardware. This fixes the following error: dwc3-generic-peripheral usb@a600000: UNKNOWN IRQ type -1 dwc3-generic-peripheral usb@a600000: UNKNOWN IRQ type 4673109 and invalid situation in dwc3_gadget_giveback() because setup_buf content is read at 0s and leads to fatal crash fixed by [1]. [1] https://lore.kernel.org/all/20240528-topic-sm8x50-dwc3-gadget-crash-fix-v1-1-58434ab4b3d3@linaro.org/ Reviewed-by: Mattijs Korpershoek Signed-off-by: Neil Armstrong --- drivers/usb/dwc3/ep0.c | 2 ++ drivers/usb/dwc3/gadget.c | 2 ++ drivers/usb/dwc3/io.h | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 0c7e0123368..fc1d5892106 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -743,6 +743,8 @@ static void dwc3_ep0_inspect_setup(struct dwc3 *dwc, if (!dwc->gadget_driver) goto out; + dwc3_invalidate_cache(ctrl, sizeof(*ctrl)); + len = le16_to_cpu(ctrl->wLength); if (!len) { dwc->three_stage_setup = false; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index d41b590afb8..0bc9aee4daa 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2503,6 +2503,8 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) while (left > 0) { union dwc3_event event; + dwc3_invalidate_cache((uintptr_t)evt->buf, evt->length); + event.raw = *(u32 *) (evt->buf + evt->lpos); dwc3_process_event_entry(dwc, &event); diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index 1aaf5413c6d..7cf05203b0d 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -55,4 +55,12 @@ static inline void dwc3_flush_cache(uintptr_t addr, int length) flush_dcache_range(start_addr, end_addr); } + +static inline void dwc3_invalidate_cache(uintptr_t addr, int length) +{ + uintptr_t start_addr = (uintptr_t)addr & ~(ARCH_DMA_MINALIGN - 1); + uintptr_t end_addr = ALIGN((uintptr_t)addr + length, ARCH_DMA_MINALIGN); + + invalidate_dcache_range(start_addr, end_addr); +} #endif /* __DRIVERS_USB_DWC3_IO_H */