From patchwork Fri Oct 11 14:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 834577 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp837335wrd; Fri, 11 Oct 2024 07:38:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXcDEopioCO0n0s9jW9ZLFjIqQN+Z3iaV4Y8Mwv9sb9FvB4JFyIAtrYQoeQ0GABJAEipv3RVw==@linaro.org X-Google-Smtp-Source: AGHT+IHkWGWSIxWLpbhFmIIyWb7cTmpZY3To1g0+ozN1ITPDuc39NI8AqnTRS2IIjMnVr7vRSi3a X-Received: by 2002:a05:6e02:20e9:b0:3a1:a2b4:6665 with SMTP id e9e14a558f8ab-3a3b58cac98mr15880885ab.12.1728657524285; Fri, 11 Oct 2024 07:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728657524; cv=none; d=google.com; s=arc-20240605; b=YwRw23/+SBUhwp0Iw1C30Q94xUcaeBXxQAtYJ+EdDoBhsfkSyLXj8vY92lkuaEKJym Bnwy+bOZFpiwU7+76R3tCwT1SSq4CBXc6u8ja/HZzM/CC8BERlW35TmaXzh+wi1rxP7C DevOU3263TimfK3GhXLWmtjT9jm37IarQALsmnPRRI/FYq1Sr32hKllCbuEtvNFEfdqt 7qdgJRxDCkDYy1Q8+CGOnoj3sZfBEeU3soXqZeGcb/I8SVxahBfq5Mpb62KaSYvNk7Es bDW684febJqULikTk/DW45rFYwCEtPb8dfJNdCDUazk6UvRIKZVatdYjI+CJ6J2O1c12 DR3Q== 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=is+Qmg++UbP3a7LbEEqkdEMgwsnrCh69hZqjp/yMHRk=; fh=dnxG3ymJw6XNDLxLA9isuuQaGQYB69OWJH4jK966/JA=; b=d/L1BCE89VP1l2IRDEfIMPPpw/u18Hbhhl6GMQOGz1ZycacmumkLt2MqCtMWLdyQds JtGwj2h6FwqkGQrmFz/y620ktUVrnTi2YsKKEdqe7BNvUOZe/PlT+W2KYDjpn/jtnpK7 Vx32nMWhOO1cWfBX1YDL4RHd3ogMpcCAS1J47t+ogtYQX9A7y8wv16mRFwVxah2LGVSI YxeKfO292yhvA01/mRHXzD3JYVIrqbvQzDYi2eU45+PN4WKE6uX1KOSiEHpLNdV1ct10 zD5FJt7XyK+5MJYnAdquf24rk6Ar70WAPGFrOdhus+a17JhfYNcs7zWva+o4Sl1Pbckt v8OQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJ0DubPE; 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-3a3afe137f4si15762625ab.182.2024.10.11.07.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:38:44 -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=XJ0DubPE; 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 365F989342; Fri, 11 Oct 2024 16:38:34 +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="XJ0DubPE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DAA1D89338; Fri, 11 Oct 2024 16:38:32 +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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 2A16889336 for ; Fri, 11 Oct 2024 16:38:29 +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-x32e.google.com with SMTP id 5b1f17b1804b1-43120f65540so3735905e9.0 for ; Fri, 11 Oct 2024 07:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728657508; x=1729262308; 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=is+Qmg++UbP3a7LbEEqkdEMgwsnrCh69hZqjp/yMHRk=; b=XJ0DubPE77LylDnaOmlUjMX2utg1vgcQNjXc8t6na4jP3uR0Zn/3a0XwmVbCGJy0no 99BYUdlimW3FHx1PB20g4AKsPqKw5isXwBZ2gIP36Ny0cUqcvhzHE8uKdSjBUjzOBF2N +fyiHfOUbaYtbWsnQEH6eLmkCeJb55Z0uO0Hf5XaiqAz3NFH8yfxt+CV5aN9+CK8bMrL UP1eB3bqJm98LcwyyrxpiS8V1r/7ARaZm6VRFbNJMLxSy8ZGOoXjtBu+T1Junzp9mFrL ctjMRGBnAnGHWLS4pegd0dnQ4o88DhVWjZlaFhh82Ne9pmSgqTB9WLMWNyCdYh8zwsyy stuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728657508; x=1729262308; 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=is+Qmg++UbP3a7LbEEqkdEMgwsnrCh69hZqjp/yMHRk=; b=EpqChY+1kk+FcvhRl1jcHc9OtLu5kJTa0w3c7cvdjZAXXhXED3X/aXB0pfnKCBXJqJ rcknUhNIGKL0I917o/0/2rX0zMoUkWJJfXD45zaKZNdh/zCc4gyupI0JC4H7AjvkkHVY LsDQSZvlq/LvpifuxIgu12DsOLVq/9d4DdfXXuxBhesMNkOb/YJX2K+qePdBBcEO9R79 hG7tRVy0oB3or3ezlPSFal0K0ZNz9WocE8mUuiTr7Tg7e7VUWTSxjOGxFxodnNOcIm4Y XULG9jT4WsGQYGaZiVom3+H6u0YbSbUreDC1UlfI0G4018JVaXCc0ayF22AzIgLtYy7a tz0A== X-Forwarded-Encrypted: i=1; AJvYcCWI3Dqj3s8rrQWMwT2Tl6zjyXXobJxnvP4guwWsiKYh+bWaX1UOLHiVMRXgqXEdtRn6ZKvzhjs=@lists.denx.de X-Gm-Message-State: AOJu0YyO6QMdu3tzT5lQAMMXbeFUWr6cdOo499aGT5802I1T9GTwWJwR e5YqpkzwueO62szrSy92YQX3xIr9zEgQJOLhW9+n9JQMAspiS5fbRK69z6uJJ4o= X-Received: by 2002:a05:600c:1c9e:b0:42f:8515:e479 with SMTP id 5b1f17b1804b1-4311dea4233mr17594055e9.4.1728657508645; Fri, 11 Oct 2024 07:38:28 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-430ccf5188dsm75991815e9.24.2024.10.11.07.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:38:28 -0700 (PDT) From: Neil Armstrong Date: Fri, 11 Oct 2024 16:38:24 +0200 Subject: [PATCH v4 1/3] usb: dwc3: allocate setup_buf with dma_alloc_coherent() MIME-Version: 1.0 Message-Id: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-1-5f3498d8035b@linaro.org> References: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-0-5f3498d8035b@linaro.org> In-Reply-To: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-0-5f3498d8035b@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=3288; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=/YQoIhV2IWohezd877+6D9uRlBPbgPaoZkRO0x/uh9Q=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnCThhzea0dODk0DPZKWz/z+vp46R/433sjtxpYJW8 +1dSg1+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZwk4YQAKCRB33NvayMhJ0dBUEA C5/7vGv3b57Xjn40/ftwDbJH92m1UOzeiTPjPmr51wiBYlVz8oQdcN5S/ldj4RXYQ9yYsWp2HgkVdd BmpqhMEbWfSA3NI+/296IkGpJTeip02LLdPX8aTsYtMW7OvVfnbdjVVx9u2K8lVyVDy2ym5ZuxTtWx 0hbHYGb6NI1a3zH3cTxosFhVjczL8Udf42QNPXvcuI0koH0e/T672uw07RR1FKC7UeTAvZslLoRgYL dZ7eCcHp9L+HYOXHVKi6u1hQ9dTDxa1Tl2BWWLloEwj/KlR1lGDtYyKdjZDdo5cY3U9Cz+VlQ/YaW4 uXhyhfAp3FFbf0YWLVz8F+teSslHeuPdVzvN+S7xG6PqYX//yCkKI1LxjwaVBFlewO6v88kfIpukKy 5Nvlq78/fnjMd6MgFBJwFyUJt3/nBXa+x++8JuiH3UEnC+pVnYGCU//GAwJ8bbxxnp7XvJFl3oDdTi bPoNO80WLUrnXC+TJIx10c2PGbbIvEq4QJlQIdl2LqjnTwJ441fPpMH9TU2SvASlnUIZKU6jdFyMYC 8Jgf89Yh0M6CGoIOYRpmaOruZHapGUUrH+CSwGYTGKfThsCWZDHAqSlYjIsvgu41empyu+rbQFwGVy YaZXbRlHMqua7P4y1Ly5A7pcVdjTmuZDbnelG90JOyKwyf+kPS5UOD9kr/gw== 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 Reviewed-by: Marek Vasut 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 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 Fri Oct 11 14:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 834576 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp837279wrd; Fri, 11 Oct 2024 07:38:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWiMkUncno2VVRxRUSwidUA9t1yVylFwvHX9IW8kREtbHvdP5Y1WwX4SefG9WWj6+seAjYGww==@linaro.org X-Google-Smtp-Source: AGHT+IHOZRlPWqyxFG1zKafaU5/mEKyugBzq4mYexdOsYBl3DR4v2RE0AOFauOHWn4mL+rp+GEyl X-Received: by 2002:a05:6602:2dc6:b0:82d:2a45:79f6 with SMTP id ca18e2360f4ac-83794684461mr322382839f.11.1728657515671; Fri, 11 Oct 2024 07:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728657515; cv=none; d=google.com; s=arc-20240605; b=e8yeCGF9/IR716QCsOjC87MBPXZ70H+iZ9n+BsNbeWusn+nT7Sta8qFMk96wRVsTk8 yX3bbvUB3PVmoHzdGMyFGt21i7gsMgHyPWCWSb+p9ICi2gGsyp/ZwHLeKkBHpLCGm31+ ceCnPJXSSeg0yDfsEffzjePcml4gw4dsxmy37Q16KQewVlKCfx5RS0TdE/m+3u6nxyRF de6i+rLKJnVrmHVzJazyi5DOywnvY0igy0MfhpwjsO8sRZVfIq9avFbT0n5So0TToYGj ZDbV71Uu0bTz1vTRCnAnlKiWjkb72xunLSyFG02+/hVA/0wNO6Sx7EHDqiUz8ZHWQMBG czFg== 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=6qOfvTiOFso3G7c2hqztL44MqGmtGHntNZfQRLW/OAg=; fh=XoeORWvOd/ILVN7vZLFqyCvZdR70UXF/29b1vyUAHJ0=; b=RjFqugd/TB5+NxYqyvnm7nSmveHJoQkOJF07YhZp3pY6X48JPjmEzVGrNPHmBrV9ZY /44glfpooyiPbY3DnWP3r+WVI96qjWWX/zsvOqB0HaHukIncScC6wIovyvbJ6Vv4yOjr Fi75o0PLjLjugPXOfPGDaSt0VEiM5kN1DXubSywV4aU+pAX9Fqjw/UXWOZ4BsFJB6+4t UUsEidJh2Ntps/HWVwEEF0VfY4qWH2R8KDEe/NrbWrJhxEzGns4t290CmqJgWC3+DHVS GmV3xknMLwa1rr9ttLN4NAbsFF5RC2imaCEPHJ4/5mvC1F0pcxdViaHMvbbQMVOPJpI4 8g6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IuWgWcQv; 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 ca18e2360f4ac-8354b952a5csi161164139f.51.2024.10.11.07.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:38:35 -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=IuWgWcQv; 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 BD5AD89335; Fri, 11 Oct 2024 16:38:33 +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="IuWgWcQv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C33208935A; Fri, 11 Oct 2024 16:38:32 +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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 078D489348 for ; Fri, 11 Oct 2024 16:38:30 +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-x329.google.com with SMTP id 5b1f17b1804b1-42f6bec84b5so19190295e9.1 for ; Fri, 11 Oct 2024 07:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728657509; x=1729262309; 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=6qOfvTiOFso3G7c2hqztL44MqGmtGHntNZfQRLW/OAg=; b=IuWgWcQvLhgX4ug2ETb3Cdq0m4qBW6Fc/cDML7VjopRPDRHlR4mZnWDhkegp1CYRMk DIeH1CQG4ZhPClESASFJQ4sEHNASMXNUh9pIfC698E9Owb31jfGxyuV3uep/Z8LmFZK4 Sv+fcIaUXYfPBzlZPsZau4U2iU1s/NPXnOQOVeSdHangco4f5lR9THNhWrGcCDmEWbUx ZsbSgFRW1F33JA5992oPKwKTU1cN2c+OlniAdbZSQ4Epu7J/tfmPa6te85raxR0OFEE4 OnjZes5HTMnQou3RRs0T+i7qNUpwpkLGsvz/gFtGkq/YZJhAGdQoE2ndUZwvuiLfXntb flOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728657509; x=1729262309; 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=6qOfvTiOFso3G7c2hqztL44MqGmtGHntNZfQRLW/OAg=; b=uagud2qvCv1gUv2IPO+/vzovaCkU0kcFPvH8jnakz5pNdqc0xPLwG++bG3NoI3bKYQ YrkB5bx2NJ6dXJ4MSKktOeUyqKDIjoe1AImtCwLIlQPbe24HYva1ZdSv6q9h0oOJzxV+ nLfn1u2dVSYPu5y9HfmQZ/Wz3Z8fMO7zgp4ibL7fLQUsMLR8GxHJuvhIS9iSzQJ72K7p t2o63ndWF2gatm2TPg99nv7wvexSxs86U2UHF8prCE3LWkgr/uTds+FMaIzLD1qCakbj wt+bwCU7o8uDC11l6NezrfWTTc7ZNPYve+0iL7MXkoD3PdH/Xu0JUqurDRE6ff6OLvDw 7PHA== X-Forwarded-Encrypted: i=1; AJvYcCVPQlJO8HMYTbuDnbQVmX0LJMYck5doucbilxQMwHu1Pf/Gf2AxU8lDYDgnAXE+O+CSGlVQM90=@lists.denx.de X-Gm-Message-State: AOJu0YxB46b0f97GjuK2vf1CnPzTxAXXG8lTRBdwCmRCDLDCIXvRsebE mRRetQOnCHosQS3FMIby40ljsa5geXRD56TvGDiQnyyVdRIZLEKNTPfU8TVUmgc= X-Received: by 2002:a05:600c:5024:b0:42c:bb41:a05a with SMTP id 5b1f17b1804b1-4311df55e0fmr22461095e9.34.1728657509438; Fri, 11 Oct 2024 07:38:29 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-430ccf5188dsm75991815e9.24.2024.10.11.07.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:38:29 -0700 (PDT) From: Neil Armstrong Date: Fri, 11 Oct 2024 16:38:25 +0200 Subject: [PATCH v4 2/3] usb: dwc3: fix dcache flush range calculation MIME-Version: 1.0 Message-Id: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-2-5f3498d8035b@linaro.org> References: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-0-5f3498d8035b@linaro.org> In-Reply-To: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-0-5f3498d8035b@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=1198; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=WkL4d/oa8d34YakzfvLf/4CbUT+vDaGFbb8LMUkM3jI=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnCThi0vfvCHEtS6Gjwjl8xdTIqFbvrejcM/MdhEED EWMjkQ6JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZwk4YgAKCRB33NvayMhJ0UcaD/ 9xoXjoqiL1MSRbexPpqp1EWMOQjIma1e20FtYPrhz5SjSbqreZASFd4euKGunE98+j6FEipIwcY6Na 2X7K5EpsJkXK216i74PqJTcfGX9+7PgWBHkPEAx/kWdJRjbHOvupQqDrFpT9We1ODsXQ5dHLZzg0GM aqF7dQ0Zm21Oy06Yo3hRYZzvsWMcmXHXLHD3PFD8GJ6o4ihdDxgkjDhcfvFIlr9HgNgcnrPrvaw/Dv mnJXmjGbCwzXMEtE2ml30a7CTPUzkHa40a+OOCtt7Y7TuA1fSGc4AD5BWUI2lrK8zrTR9fp3BPpE+W xUNUkujWUTfav7w4w+u3KalVsReCp37l9zfW1J6ovvtlvowYGBXjZwNjBzVvsJmhijzxITkGAzfiZz qWApgqWLAhj54Xsv7yDMQi/uFf4k8NA/x3y2G04egHbpqY3QNc4Bdz6ysxXaD9OZyQgxTVLjt7fj0V jv7+WDjJs1PJDgouLZE8gLHs0HGCenI5XhSC/9Uene31VMsI1PE7hLTzR3qrBx4WOJnWoV5n2pjNg+ EiVfv0OcPcvNfVELcECo4YtTK5CkrvmrR0SzFvXs2/2E6B0295cQrJJ7CknrN/ILn36MWXNTqa5KGs Vnt0R51xbqZMOHEY/e7dVVCDGItIusexMLyYP8TE7frTZKQGOMB4j4U4gOog== 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 CACHELINE_SIZE. 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 Reviewed-by: Marek Vasut --- 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..0ede323671b 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 & ~(CACHELINE_SIZE - 1); + uintptr_t end_addr = ALIGN((uintptr_t)addr + length, CACHELINE_SIZE); + + flush_dcache_range((unsigned long)start_addr, (unsigned long)end_addr); } #endif /* __DRIVERS_USB_DWC3_IO_H */ From patchwork Fri Oct 11 14:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 834579 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp837522wrd; Fri, 11 Oct 2024 07:39:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUxjl7mi075MZFuXBwFKpwIyrLgCtxDUED3IevUXoLquGKw42B0+Q4O89YQHuLYPsuvTzUiNA==@linaro.org X-Google-Smtp-Source: AGHT+IG/cbcyerswXAa5sEsfFeM1EJkbEWBYXzo+/aNW23p6rft+rFl8cXH2cFr9pBIjuzCreLF1 X-Received: by 2002:a05:6602:1589:b0:82c:ee6d:a7ee with SMTP id ca18e2360f4ac-837926ff2famr204072839f.2.1728657545284; Fri, 11 Oct 2024 07:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728657545; cv=none; d=google.com; s=arc-20240605; b=NeHeZ64mPvm3n/eb/XD+XenMgjUDSk4ljDzfrP3zRB1S+eEdRxv1i+gOeWe6bThTnr tDNnZLnj/rnwOYwylUvdG35dMJE3H3L+bBlujwsvFQU5O6PtNo9wTm4FpC8z1Z4qWbp2 x9OQjwD0dkPfuX4GtSKi8W5ld0G+CxgFGqE7X+0zP1JWUPvSm4Z93ntRjvP1r0AH2nB0 v7Kw7A+1AmQUky+lAh43iZLTrcg+GxGm81IvypGkh6E2zkWFN/zk1GWV1inxGsId5vtB UWPkd9FOT8wZeZ13L9YXlFKb2JQ6X8KDzFKy80607MycyEA8XlF678v7spbYHuG1yAy+ VHGg== 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=EGzVAs/C70qEnt8Ib5tkWIzYZG5avjdcSr0nGfnNmqE=; fh=5JCBynjyZmZf2aLcVuNOMM8M36GKW4JbVn0Tu15Q1jE=; b=aWUV4nxwxSf4dYuJmSg54I6kvEdlUWBqyGrN9bGaWo36VlEwoxQtCd6zSfyHMSMWxu ZXb06BDsZNPf4UHLs1/qnyb9CYkLajhszKXJyj9UMBj2MKUU7iaGD+3JblxkEisAbmJf Z3GBeK10dQizKsI1U32g+If/8CR8Zp5uzyKdWtaR8ZbhWJMLOVk5PmVsxv8TTxyKHdmh GFxvtOrI9ItvcRzhWZagbMXE0wa471Nr5hBbfeTAOJTGed21pUzp1O5YZCw/9m4PDLsJ dRrSl6p3jL5fO4cBG/OQ0F+oYF5parATBOtOcUJlkjjVnzd9IEoNQVERHS3FrZTjVC3X 9aOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtC3U8+D; 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 ca18e2360f4ac-8354b93b8c3si155808439f.31.2024.10.11.07.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:39:05 -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=AtC3U8+D; 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 1ACFD8931F; Fri, 11 Oct 2024 16:38:36 +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="AtC3U8+D"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CF48892F8; Fri, 11 Oct 2024 16:38:35 +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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 AC97689333 for ; Fri, 11 Oct 2024 16:38:31 +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-x32c.google.com with SMTP id 5b1f17b1804b1-42f6bec84b5so19190835e9.1 for ; Fri, 11 Oct 2024 07:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728657511; x=1729262311; 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=EGzVAs/C70qEnt8Ib5tkWIzYZG5avjdcSr0nGfnNmqE=; b=AtC3U8+D2kqe89bK0mb5BClsiE6wpdO+YveyIYwe6+7FKp9Kc2HQcZ9EsbFHM1UoiP v2Rd5VI09hlhV6VtenfrWIDla4w/mxjlgxHQZzJSyMKX8bh8mQoXLXCHZOepkKvZ4MNZ bd1cOXkX+lKQR82j05QHyabIPvmu6Izu+c5elEZW5olx5tVZ0IiEm22yevDxqVlrcuYh QjkHvPzfUKl/5xVReKClt8KpnB1+uu7wNz00zM6uUmu1ufizcL0XEZK147HFexjnjvD5 hvnQ4i99UYAeY9mvAiEHPforu9OoLyT1dNLU0Xboia7x+r5y9RO/lXyUS7QgvAeBKT/Q veIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728657511; x=1729262311; 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=EGzVAs/C70qEnt8Ib5tkWIzYZG5avjdcSr0nGfnNmqE=; b=IHrPvc4Gjy5Dzcj6E5Jm423WR4Jv7dmTRZR+5/4Sjfh6lqtJkQxemHOfR8/9EI/IrC hmHpK4Vidn/mxg5bEPXg9tBUN7hYqvqxgLKumnyM1Kh84zTm7PRHJYpPvw2mxD6UTiSF VC7Q3B9ePiSUjjSkLnwhFIsOQGkSFP5pnRREDf5KhhVzUxYs93VvS2Ptg9wgmIoSVfmn 1PD0Kdrm6c1HuxifOGnQXbn9tk5QE29BWWO7N5+ziXjRH7XNy9dAmLs8o8E8Y8yjX0bY xxstspBuVOGbn8rcvP4gaT6pett7dTY62zaQdubXuAqSlGdFduiq1GqzSJhZ+KuV5Oza B2uQ== X-Forwarded-Encrypted: i=1; AJvYcCV3Xfms4joZYtKlLW+f7f3CE3gdlp+Zb8OFgid0rgsrAHuNEUFW1GclWbnCxfmqAv7vgGVMvnI=@lists.denx.de X-Gm-Message-State: AOJu0Yxej+vrlLVHj7gL1wa9ZXYJSb7ZpV2qiJe/N1nRSR/aOKZbdOHx RHQNwqFqvzS2aocLpq5e7HGzHUKsCycqUOKFYw2CkBmOg606nII4RjaCSuDMcpY= X-Received: by 2002:a05:600c:4f07:b0:426:5fbc:f319 with SMTP id 5b1f17b1804b1-4311df55cffmr22536985e9.33.1728657511041; Fri, 11 Oct 2024 07:38:31 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-430ccf5188dsm75991815e9.24.2024.10.11.07.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:38:29 -0700 (PDT) From: Neil Armstrong Date: Fri, 11 Oct 2024 16:38:26 +0200 Subject: [PATCH v4 3/3] usb: dwc3: invalidate dcache on buffer used in interrupt handling MIME-Version: 1.0 Message-Id: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-3-5f3498d8035b@linaro.org> References: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-0-5f3498d8035b@linaro.org> In-Reply-To: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-0-5f3498d8035b@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=2487; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=iI21rtikGKorJ7BWBMqn9I5JapH4U68HHGHBK/ZyTJY=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnCThiYXV6wjBn5vHmvr0yi/EcIFu074jkYEOmQbZz hPXNoVeJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZwk4YgAKCRB33NvayMhJ0YjkD/ wPquam+MhFn4MGAnVBBvgVkqKwL5gZTXwozCrxscWQH1V4enhmJwS2ueC0UaeX7eCiD7YccHb1j4ha Sl2ujss1X3Iq0uqi14DdKdHboJbCfk3rHs5hzw2bbiWMAC/SkeEV2QbYxch32I1QOdgOWwu5mx9xvb yVu+9Ygzgr/uj+YjEKDhf0cJWX9DPQ6qZY301XSMnlw6/dLZjVglrm732DGVUkeSveuw/uDjhvLwYr 2M32uV4miVlOER7Azcj7VuaBcY0RmMsGq2hEzGiSTIDvJXmbGVVDWBsNsPUI1usSITfPT30asmHSry rLAWyFlmGmKpoBFKU+OPjL9XD6Y95kbAJhqhzhiueBy6EzuoVzjKWVviYkvQkszpxJvDgfRIG9/rl1 Q5YmfXnqdMOskZFIp9ksJ/20dvbLoFcvjX+wDkodNcjeWGJCHtd0Ggj/lltqsDzWrPFk3dGczORGjU 55oFaKYfush3w/1Y4Kmi6i8m5EyFE7HbYj/QChzwt5R4iJ70W9tdDgWvZ205gJ/kUSQ2rJ0KYm14y2 xJOhQe9aRlx+QG+dfLzSYsg8NDd1LkRR5lS/H/UsZDC/yNNOmhwCPQ9w2F5l+LSE6B7jQzRGaDI0Xb V1IBK2tobML9/RG9UEIi73vyF7Wm63sPBykj/rEN0jRaM3/dvGGrvWj5rRzg== 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 Reviewed-by: Marek Vasut --- 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 0ede323671b..c1ab0288142 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((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 & ~(CACHELINE_SIZE - 1); + uintptr_t end_addr = ALIGN((uintptr_t)addr + length, CACHELINE_SIZE); + + invalidate_dcache_range((unsigned long)start_addr, (unsigned long)end_addr); +} #endif /* __DRIVERS_USB_DWC3_IO_H */