From patchwork Wed Oct 2 14:39:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 832219 Delivered-To: patch@linaro.org Received: by 2002:a5d:43d2:0:b0:367:895a:4699 with SMTP id v18csp799252wrr; Wed, 2 Oct 2024 07:40:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUQG1SV90g8QUjLA1b6gBxYmhn49sPe02zG8HFNB9tLW/LyEoj96mguDKiK74hOCeEgk3BR0g==@linaro.org X-Google-Smtp-Source: AGHT+IEQd5JZRYXjDVTOeuJ3md68uJpRO63bJrUiE92xZEWZ/AEzdPMKiZxyReYiuOXtw68rWKKT X-Received: by 2002:a05:6e02:4aa:b0:3a0:a0a1:650c with SMTP id e9e14a558f8ab-3a365953623mr25730885ab.22.1727880003021; Wed, 02 Oct 2024 07:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727880003; cv=none; d=google.com; s=arc-20240605; b=a4UZW+m4X/grvl7H2oo3i1ACd1wuqqdbdNnPyGtlDJ2a9Uny1RkPxkkxXPca5mjmLV th73tKw0OSTE2OH8WA2PqaMgIMcU/iBdEEpMxEIfVLb7lmz4AQL7uOvo8Fms37oBYJfc PsNzRqjG6gLaO2URo+bH1ugbuQzg4luIXCBKa4Crvc1u2drEAz7eGHopAfnHsbeuzxJV vXGhZstsGH07WfiBANrhVx1xx9prI6+WTQthzADbTkZJpvNJJG9ZDXHXzqqh3PDQnlmf yQIxFGjfUx1a9dSMfdh5dM6OFd1Yeh8ylmXM943GaaSLeQmWw+Nek6PQ2qFHWDmWJ5AH BvJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=XbaWVpPZ0AENYL/jANVAHR/JFi93NTFANsG7ICTg4Ck=; fh=vCjtuMMb4aauC6lvV1Mwl4KM6dUuulRWNuIR3XESpcQ=; b=kH5iTsJ/GZRtxrRwCKGBhBvCldfXVvBSY3tIlUs128OSWiGKjggEF85Pym9Wujrb/b cCZC2LhFZ/WGEqv8/cP+6BZLofB7VBCo8uqvDiJ8MTzRzUMAJFx/qu1xlo3IDyVtoXNH kJnI21j2U29mPNq7tHOUQCZM+Rx179DbMQALCzKnDfxaq5N600G11IwfC3WzwteytaZH B7Cy6skwgJr+RAl7ZTQXqlNZJ4btu2R8PXXSnUMjeTDS1SreI4ojLrS17i77pBtnPtnn lOTVXlW4TOluDhQNU11fzxb2bF6Tl/US1jZ1gcaRhs81H9i2/mdLLqAZ2U6z+eELa3FG Utsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yZhOz94h; 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 e9e14a558f8ab-3a35eabebf4si21773465ab.172.2024.10.02.07.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 07:40:02 -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=yZhOz94h; 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 122DF890CE; Wed, 2 Oct 2024 16:39:43 +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="yZhOz94h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8711B890CE; Wed, 2 Oct 2024 16:39:41 +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-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 0532D890B7 for ; Wed, 2 Oct 2024 16:39:38 +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-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cde6b5094so61107235e9.3 for ; Wed, 02 Oct 2024 07:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727879977; x=1728484777; 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=XbaWVpPZ0AENYL/jANVAHR/JFi93NTFANsG7ICTg4Ck=; b=yZhOz94hDVulakdphKEbPgiqPI5b0VSuxpX0g24u1KrvYxHvL+mRsPP2TgIaoVNN2X n3IyQ8IqcSkL5drtbeoUOskPUAQVbxFRfALdEQmWKE6xxEPClQfkFw9K6Aw5v/nyFPy0 bReF7zLxnXeZ6HZ4+fXS38EVaCqq8djsFowS2MWjFNLv3vJsoK9qXT7g8FjXfXdo4B4z FevOuWP2pAPfTIdFJYFBlcTEWuffuCWfVAjZsJPDXeKl5/KtxoayMRCq3oAgcW9Gyi1j miPqYCw44stRF6LRBETeFv/77O4XnX38a8gUKXioKidOSs1VJpBx3eKSu9jplxMml4N4 fVkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727879977; x=1728484777; 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=XbaWVpPZ0AENYL/jANVAHR/JFi93NTFANsG7ICTg4Ck=; b=De03viTK2gcshzDyI4cQFR/hZ5iV8/oOqm8Qytzdqfy/mHmS0qfIVTlw25Y967RZYj SnIM5bYJUnfoS6+ixYXZxFJvIbh4JuU3RIGrt0nGDklAW+UopsWD1h1lTKbVl1lrR90b 6pCT1Iajc+vDYOHunAdrnt8ZeZvndB0942WR1KQ4NaZ2RZ8YPUE7PacCKb8spoez4Q2b wcaa69VMp2+wpD7LnLJ1rB4yi4tspdYlRIukjEjbKlDuuv263cPOsN3ZPDviwxjr9X1s tW8mjTtUPWLBBo9/EckA4gPHcU00kdOPRXiEsypytGwqiRE3OMoG4qJXibZRnCHsFa6O Z7wA== X-Forwarded-Encrypted: i=1; AJvYcCXxhgXdtyRz+bA25jWq1pMz4EINWDWKV9XEkRnlnDjpse4GJwsKTmR/gwK3snXoR4VfHZFcfJ0=@lists.denx.de X-Gm-Message-State: AOJu0YwWhGpir032b8oVtP0DKBJK5fougiIot6TSKOcj/lFM2Bgwdl8b 4U9MSUPZgUBoCcLLJShB7FYTVc6QZvm4V7aansFWQE9ZOvcGfFJ0jTSogISo41s= X-Received: by 2002:a05:600c:230c:b0:42c:bdb0:c61e with SMTP id 5b1f17b1804b1-42f7a12bb01mr19673815e9.13.1727879977397; Wed, 02 Oct 2024 07:39:37 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e65c3sm14056083f8f.60.2024.10.02.07.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 07:39:37 -0700 (PDT) From: Neil Armstrong Date: Wed, 02 Oct 2024 16:39:32 +0200 Subject: [PATCH v3 1/3] usb: dwc3: allocate setup_buf with dma_alloc_coherent() MIME-Version: 1.0 Message-Id: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-1-5398088ef93c@linaro.org> References: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-0-5398088ef93c@linaro.org> In-Reply-To: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-0-5398088ef93c@linaro.org> To: Marek Vasut , Tom Rini , Lukasz Majewski , Mattijs Korpershoek , Bin Meng Cc: Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3246; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=7pM47L/QmRm9ChxWkiFFuxDhel4FJ1Ku0kJr5Fv5KHY=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm/VsmIEV//DLEZz7b/K39kxJw68uPbJ8t21e0Tg70 +wkNZHKJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZv1bJgAKCRB33NvayMhJ0e+wEA CHn2XDc0OWWLvEQ5O4CYmT8/HKJ0n/r5uVsp01piH+539J5NtxlglVBRo2+pUVDEE+AiKNFDVu2nlp SoV+iRomjaRUwNTzVW6jWrFVkuYYgV/Tw7Pm6zp/4SqA7K+9FT3JWOikQKr4Wlh0O9iBol/PwN1+Q2 5DrteMwlDAhFRC/UMsAU52pgF5cIk8vFEV9Jk+C+hmfodC/IWRWn47uTnkxjLFQW6/BZmpcgOwnmds WsKsWXvao/k5yPWc1kBvklDJit7zt3jh938mOe5FTGwgZ1NvEGPgb/L9WmN9H0YJS3TtABie7FFDuC pXKYse1I5PRPO/80kWgYntEwBFW7UlpSnjYUkiuE5BK1ea45kUupLwio0MCDkIaw8EKXhxQ8sI/54o RzYGSivNz7Nl6HTNIANnGfHOYerjkko8fVJdtAhdu95oVMbKvlqh3CJpcXH5usNt+mmG1Rk4AssoVQ ba935NN1kb67b0aH60ls+qYQHIrJRWsS9atFx+/C69U0m0dl8yIeE9nyZrickzMziOEGAyk47vhCfk EePW5sX/LQ0LPiC3tJKXPvmmEFLexz5KosXhngb0NAhBNiTX23NE8gPl3gH/aAxdkAnZ/mhNVUlj8t nJ5V3HzuNRRqEgr1yAnxRdfpqOdhWp4Ur81fPQ8H3ZiCtSFEdNGYaq8MKvCg== 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 Reviewed-by: Marek Vasut --- 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 24f516a131b..8ba5fcd5312 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -380,7 +380,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); @@ -662,7 +662,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 fe33e307d3e..19c3a5f5e58 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2653,8 +2653,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; @@ -2701,7 +2701,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); @@ -2723,7 +2723,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 Oct 2 14:39:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 832218 Delivered-To: patch@linaro.org Received: by 2002:a5d:43d2:0:b0:367:895a:4699 with SMTP id v18csp799196wrr; Wed, 2 Oct 2024 07:39:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWcG0LX9VHTQ9g9QNxZuyLjiAfBXu3IbKfLDQs0KNz7OkjH8hJKsE5MRwbh4dnsOk2K4DfNng==@linaro.org X-Google-Smtp-Source: AGHT+IGVlJnSrXoP6FAM0SdLfepscFMyWNcPT19Lu6BGRU7ACvghl6TWVcVzVrMEtQlkYiXiLftM X-Received: by 2002:a05:6602:15c2:b0:82c:d794:4695 with SMTP id ca18e2360f4ac-834d84252c1mr283208439f.7.1727879992737; Wed, 02 Oct 2024 07:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727879992; cv=none; d=google.com; s=arc-20240605; b=hJw7o3cVKANDpNQwmKdGxcoLrAvWSQHo2bKXzcwtdc9e6LpqBGyuZ/rPWO2QRNiogz vKAUnAgwHoAsYDQ9UbemohqHnxY32Av2fo16MoO9XIDEm8qPy/cV0ryf8EZSq5p892F2 BQBNTBsNXa15351kAXDIj9rQ6yTcEPqYnGCCVYRt0SloAQn+Ds1GkvRJ3Pnlon6WavnN CvyY7qU1pBk6PsIL4m/fVtZN3yJcJ33WXWd861lumZRL8f/0OVORP6lbHSACzr397B3o gzvNr5fUCt7N//t5AqAne1yQAPT9F/abwT9pIcBDoCUMGhI3Azm/8E+C3CkkEYG2QPZL NBjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Kw110bgQIB++mEZ/IhsEoAMkwIQOj/pRBnQftJzGOqk=; fh=+VVL4aPRpJuOqbAQ2kK9nn4yDT9HZZY+CGpnNy/sszk=; b=D0ExrcRwxySn53Yyjebe1NB8SqsvID20E3TXkA0TxGfZl6xxy7OmpewNsnLK9kQmUa EOGUAIl9kml81PV0UxK4sVlPJsCQXch+G7/51D1Od7JqkTVIAgmjaeVVyNn+HJ5BT3n4 wq5LikSj6dN2pS6JBqltUqJLlGo6ZfDAgt3OB18omtrklAThTi/gEPkBkakaXI9jmX2U d4DSPNH8QAMkX9DC0EtIB4yQkEHMbq9JFMZF6cx2vyZhJv3w27L5o9qYgBVcFE//0a1Q z98NknKZH5LAbf3+qt6Nq8/cBfpApNqkKZynzUCrmarpnZOEa40Dozqtz7dlUnCyfcHS 8mfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WesUoDMY; 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 8926c6da1cb9f-4d8888fed5esi5335700173.178.2024.10.02.07.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 07:39:52 -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=WesUoDMY; 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 BC27989034; Wed, 2 Oct 2024 16:39:42 +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="WesUoDMY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 805C8890F3; Wed, 2 Oct 2024 16:39:41 +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-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 C1E7E890CE for ; Wed, 2 Oct 2024 16:39:38 +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-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42cd46f3a26so55310675e9.2 for ; Wed, 02 Oct 2024 07:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727879978; x=1728484778; 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=Kw110bgQIB++mEZ/IhsEoAMkwIQOj/pRBnQftJzGOqk=; b=WesUoDMY3K30sWUQGG+OvFNWSpuKn5mhUvN7h2da81QaA3T2JBgHPF5LhXsLuvRwKR ZiEgozRIQk2rWn2Qidkv1eNvced1U86Nt2Jz+jWyKqGIr1ca/9cr8UDqhOmf8Rf+dM51 WABrDtfg28kaSi6QKRZDZbdYo1jMS+mATQkrcmPPIU4n9pAbMQt2Gi70sJ1qUY4zfZIf 1JJYM2bf6ybUlUg8Q89tQoJx+m7O0p0W5TR0DTsDQVRodlSq5afvME22GPwO98wlM8at YVf17tIe3qRN5SSJfc/IgWDH+4f/AYXGIcZGdoXb8pzEMxtdAtFwfAg1KrtA9r/mvHQj 8wdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727879978; x=1728484778; 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=Kw110bgQIB++mEZ/IhsEoAMkwIQOj/pRBnQftJzGOqk=; b=wzjHa3FuwaVzRA7B5AhWwhNa668GtDXBkWKXPxlQls2cFLFHHndYnodtHWnLwdqMy/ PfhmtRdRqVcQ23994Z4pXeGf0CMaCJZQZKx7INRTgq52FDb7J++MGabXLVqu0Nht7vmL iz0KUNquQi8ZMrtOJXvzyrePctpKYtwNNISFb8GujXGBxh2Qf9WJivvss9gk58vyYJO4 zTH31JqcqSmyQnmMm9IbhCSVBDpnDJKjgt1Si/zslRmVs2oU7trWzIW0lLPxdu0KNKz+ sVTwLjSgripLjOSlelcDGy8avY8J1CG+uWm78qTITKzfZa3eTczg136zbnTQ/Xz69r1f Fjag== X-Forwarded-Encrypted: i=1; AJvYcCWAXMNMgRtMowzV6m4rI9I1mTxHLYmuYSZb/1N8+5dZJ4ji2gpDNz+X42LBVG7qwYTMm7toVgc=@lists.denx.de X-Gm-Message-State: AOJu0YzdE9q0tNit5vcqU/9FSf5OULIlL6h/Mp+ueR7xtv/MwCSmpD3+ F4Vih4smtxrqNtEzCdVfdjb20s4rVQFNpFlAp9acJQdO3qCypJJFtAdLZMIJelU= X-Received: by 2002:a05:600c:4454:b0:42f:68e8:d874 with SMTP id 5b1f17b1804b1-42f778fa3c7mr23965155e9.31.1727879978166; Wed, 02 Oct 2024 07:39:38 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e65c3sm14056083f8f.60.2024.10.02.07.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 07:39:37 -0700 (PDT) From: Neil Armstrong Date: Wed, 02 Oct 2024 16:39:33 +0200 Subject: [PATCH v3 2/3] usb: dwc3: fix dcache flush range calculation MIME-Version: 1.0 Message-Id: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-2-5398088ef93c@linaro.org> References: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-0-5398088ef93c@linaro.org> In-Reply-To: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-0-5398088ef93c@linaro.org> To: Marek Vasut , Tom Rini , Lukasz Majewski , Mattijs Korpershoek , Bin Meng Cc: Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1510; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=y5L/ah81b52wg2BmUIBDjC9IK51neBebBKPXX2bS1kY=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm/VsncgLj8ZE6ED+Md4TtA91Kn2hdkE1XO7lhZWvK WjJbWUqJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZv1bJwAKCRB33NvayMhJ0XQOD/ 4zFItGtjvmgfMrc4tdNBqGcrgt3ca2zr57HvavxIadd8tHujqtoqxaWHHqCjIO0gvg+9fAC8lDmns2 6vCEmMsGJlLEtjztYRJGYQvRdcvqetzdwPAUGLdRWvM4TM22+m8DEFdP7fhAHbFVJFufvr+pAFQySc 2Kky04jHSJry+UhYSyTbQHPUTtXpCW7JGxlk7ScS8w0O5Y0bwRgdjk60eOICT66y3cRoZSoDErfIjb yLh3mzOZPYznEEyjfQSeq1Y7dSvedjuatxdXZtTf+LpHp/tBU/XMhtlO2d/fFL8RxDromOF3l25z0a 5pEQ93lGtnzeNZEpACPJ+W13n+YBlkIB3IljXCldt8+YN78fw1nWo0/lSt6JS+6GnmwsKKJPC1/lmM HOyRyVy4yilAf0iwkNEOoV6zwGale+3HXuOmBIJl9Ao++xFx1szK1jWTjoQAhMN5hdndptsG0SlgNU dgsDuXYK5UNRQC9G7buIjRRMcDyc/rqfnchmnei3w3R/06TbBYuXUXvTklNlUij+kEuILjv9c/e0VW 4lZE6c1Zll6TioiQQTBNCwaDTHHFfCQDlMvYkDTO+YFeA4BoauucBJgN1qMpwEI80/wZoPn+J0RE8m POM5wPmbnoT3pX4oGklZwqarSJTuI1e0xhnILhc3pzQrFSUrngHtLzdzcKnQ== 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. Remove CACHELINE_SIZE which was the same as DMA_MINALIGN. Reviewed-by: Mattijs Korpershoek Signed-off-by: Neil Armstrong --- drivers/usb/dwc3/io.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index 04791d4c9be..a6c2bb0f47d 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -20,7 +20,6 @@ #include #include -#define CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE static inline u32 dwc3_readl(void __iomem *base, u32 offset) { unsigned long offs = offset - DWC3_GLOBALS_REGS_START; @@ -50,6 +49,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((unsigned long)start_addr, (unsigned long)end_addr); } #endif /* __DRIVERS_USB_DWC3_IO_H */ From patchwork Wed Oct 2 14:39:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 832220 Delivered-To: patch@linaro.org Received: by 2002:a5d:43d2:0:b0:367:895a:4699 with SMTP id v18csp799346wrr; Wed, 2 Oct 2024 07:40:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVO+kU7i6AQieNp6aA6ioLkK7m4ZlcZtyyUUPeQPVemWVrIWc87vygjtOYsU3LHLaVZkPTpmw==@linaro.org X-Google-Smtp-Source: AGHT+IFc/B4l7aM2v/fEy4WbUiTo7YcgFXoua3Feb1RxWHIJ3+0uUIHXgvv3zzVBRtWfAJ+sW6GZ X-Received: by 2002:a05:6e02:1c85:b0:395:e85e:f2fa with SMTP id e9e14a558f8ab-3a3655ffb0dmr26131785ab.1.1727880014284; Wed, 02 Oct 2024 07:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727880014; cv=none; d=google.com; s=arc-20240605; b=fGbUfMyz9yJyba4el47UAF3VXQfwfFdYAeN1Th2N34F8bRWXtShErVCxTJgCnv+9tb B4GZjEhKpkONvw6VxicVNlX61Rh5zsyAWaL6rbit/7gmCf67QtwCrr8YZVkDgKAceulO bGyIRnSAGNswJ9LWV3jILqc6B20VuhMzBh1Ivj1ozfqTn40AiU+aMs5LKkHpr6pgGotm SohPF0mq7xSFG2qzrFfuN2QKWzynZTKlYIRWgyiyJzsbK4UqlslTdgC+/J1CZfz3QvVj xIpV2feF04XaEdulFEYU1w8CT3IsTQ/LUwToZGUwZNnTtDWomBL+zCMvEY7yVDxS/3F3 R2YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=HXGHuBI7DESo+MXQROKR49q8aImAvCPU6dR7n5FZxQs=; fh=3YgbWI9XBwXViM6+JtqmIZxoW7De/iMKHyAQZHKDAys=; b=dAddhLQzWw7HAx+0iP4YlNZelVy4CdVGfhR636Vz0YfJ0UMro6wZWPlhFXJVLD/tF2 6z/05OyE32GIeP9EAtjTGfHysP0ziu0TiWb19VfNWSkzqLBWoTzPIhaDUxfcBxezZPgI McRx/nFwycXef8hyX5TJclvMM0zb8J7zbVX6wdNTTxTLsNq0CZPFv+93G1PeH3iN5Pfj eqiU0NZqtAlcR/XYXDovwuJ0fYVxzjpafHRx5Iu1o87a/DE1RMH5+bJqn5Y8iXYFXxSj xY2B48jwjmTJukTjLswOWDxXARFRCVzFqAT10CP64YcspNeM48SKZiRt+srBgP+/hR/R zYZA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GnqFawC8; 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 e9e14a558f8ab-3a344d653b3si60451545ab.27.2024.10.02.07.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 07:40:14 -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=GnqFawC8; 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 60EEC89001; Wed, 2 Oct 2024 16:39:45 +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="GnqFawC8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD3D288DD4; Wed, 2 Oct 2024 16:39:44 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 8DA67890DF for ; Wed, 2 Oct 2024 16:39:39 +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-x431.google.com with SMTP id ffacd0b85a97d-37cdb6ebc1cso2808280f8f.1 for ; Wed, 02 Oct 2024 07:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727879979; x=1728484779; 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=HXGHuBI7DESo+MXQROKR49q8aImAvCPU6dR7n5FZxQs=; b=GnqFawC8L5Hqm/oohzb7qb7wC9EXpF1rbKkE+yHFYyccS3E/sgh6nHcz8u9TaGZPYF JlaSRF+qWALD6uX+xCc2DN/XzvDhxlLNjqVD/N+2JowY5HzV4rEJoPruwCTaupcuTyKQ gzz3/AKeWNOivfbGJ0xkXw3aJBGlGLt3HLsxO1fGuo1Jv+o6wrD2qcTHAGQSJQQJQC0Z 49ywofNcE1hHhkc9YaM7zZ0efEDTEGwKA3OuRMWiVb+u2mdgia0tsPjfCKzfVGV9X/Yw hYPUXE95Uavr4VeBMhpls+cf/Y+1ASmU5cHlmQ4gHVsRoz2zj8xSDblkVNti5y8ldAAH KgPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727879979; x=1728484779; 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=HXGHuBI7DESo+MXQROKR49q8aImAvCPU6dR7n5FZxQs=; b=vfUfrwJAZ+a8peAJzevSkA/U9IrwyFRkogQff0++jy/g+kbT14aMeDdmoIb5mKrm9s +xjEoAdVPV/KtodC5FKq3Q06KFsJ0ez6zyReYLMysgtB2eb2iZQHgHsz5T/152KOUU3Y RWKk8leIbCtai/G/RJ+WGm2evNo452G8sQ6kW7pcqhYzukZblz02Qu9K8XrGt88SjlMq IA+bn1/5Vsb/wMd871lmo+njJ/77fJIHSEv/VYk/aieC49eOGGvhzyYdIDh68PpOq9O1 NEJ+5/1QSiew8SkHxb4aAaRV2YM3q/nfQuYCE4q4qtsiW/w/UqUz2Vokw37SI9ITYhsB +kFA== X-Forwarded-Encrypted: i=1; AJvYcCU/XbL5jbuxG6ObAjQBupw25lckS/LJWKtTUyC2X5B5taenrOxvckH8udx2hXeoDtmv2uNGmvk=@lists.denx.de X-Gm-Message-State: AOJu0Yyghmj+fj9F9EEMs7eGmjNi+SfJklwTwuf0ClYTrdmQqATNRi7H qP9QbNiiURncgvj+b17TODmPxaGvWxiV1M+DLIBqzI6FzomXLE6ShF3k+lTuMuI= X-Received: by 2002:a5d:540e:0:b0:37c:cdcd:689e with SMTP id ffacd0b85a97d-37cfb9d4541mr1868481f8f.31.1727879978946; Wed, 02 Oct 2024 07:39:38 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e65c3sm14056083f8f.60.2024.10.02.07.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 07:39:38 -0700 (PDT) From: Neil Armstrong Date: Wed, 02 Oct 2024 16:39:34 +0200 Subject: [PATCH v3 3/3] usb: dwc3: invalidate dcache on buffer used in interrupt handling MIME-Version: 1.0 Message-Id: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-3-5398088ef93c@linaro.org> References: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-0-5398088ef93c@linaro.org> In-Reply-To: <20241002-u-boot-dwc3-gadget-dcache-fixup-v3-0-5398088ef93c@linaro.org> To: Marek Vasut , Tom Rini , Lukasz Majewski , Mattijs Korpershoek , Bin Meng Cc: Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2493; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=a5B8p3C7xIZv9mgyWkU0YkXLsCnCIPXjs/MTJ6LPpa0=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm/VsnPRxaGopPKsFMdfeqrjFH1wyDJ7rDBeYGGQCE 2sRf7kiJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZv1bJwAKCRB33NvayMhJ0d6JEA C09w7wvW04GbO4Ick0NQdlB8QQptBIGnqvDVfv5fzmfwGf78A9Evl9W3URJWGmXBDCiiA+CDVdpKw8 5Z+41HYRJDttWJ7mB9SBqJOTkC912jgLrgKkZDKlXS1DWwOhw3ev5NSrX/0ASHN8wjkKjJzPy1iSXE oLQdOh1LOCB2nO0aJxL3EuMOjCp2+u5vBGON2fe2dxNCnWJrvwt/0n2EEEVPhlM2c4t8pfPTsYiFYn zvdfnS+/VwZmUGOqyrDVk6zxQnbtPzt2TbLFC7tPwncLdi/5aaoGNYBD+VRXOFyNpu+xO1pnjE0Mlu wnzKFFXstKhhXc5BRElkVH1hf68IbMmU0zgLBqJ5vLfEXnug5d6UWNSy+tOxHI0bvJljbghXPcfU6x ukJk4oC/wskr9HYnvXuANqqqRBlPv5CnwaFISICkF295dtYqmkyOmCnPZWfFAdGFZ8rL5huwzLcXpu BtHDgRbhZVlsWR8hhaqbuzz9/c1JSsWyEsxMAJxceXRahS4ztxTcho90iCLBy6XExukMVbgQbJpNJU s11dYvAHqXx0wvzpBqGba9RyikNpKI5O+widNJybs/Rx+aPka1+uoINMYkstTBtHRNMzhseEuyk1Qe ooCOEPaMa3e3NS03kwZQrnl9EFxGbd9gKgX1mHvLtpImOdcwKuavs3Vgl23g== 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 8ba5fcd5312..531f0b522af 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -742,6 +742,8 @@ static void dwc3_ep0_inspect_setup(struct dwc3 *dwc, if (!dwc->gadget_driver) goto out; + dwc3_invalidate_cache((uintptr_t)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 19c3a5f5e58..e5a383407a2 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2534,6 +2534,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 a6c2bb0f47d..b347a7f1fc1 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -54,4 +54,12 @@ static inline void dwc3_flush_cache(uintptr_t addr, int length) flush_dcache_range((unsigned long)start_addr, (unsigned long)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((unsigned long)start_addr, (unsigned long)end_addr); +} #endif /* __DRIVERS_USB_DWC3_IO_H */