From patchwork Fri Jul 19 13:56:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 813392 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp764660wro; Fri, 19 Jul 2024 06:57:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV0QKcuSkROsZaizikIbUZJsznwYsGtEC4CgkqHea2VN+GsxcvYn8TXNYjBfU0HVZZIPil6fxpxENBS6SkhnvxV X-Google-Smtp-Source: AGHT+IEdBOM9lehir2jSUivkQ3su5hgOuPBXEyhP+IXJvQKzl/wbEGmGXUbkqAY4f24mAYqPCnVD X-Received: by 2002:a05:6512:a8d:b0:52c:e192:5f5f with SMTP id 2adb3069b0e04-52ee53df0bfmr5864199e87.19.1721397432589; Fri, 19 Jul 2024 06:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721397432; cv=none; d=google.com; s=arc-20160816; b=yOhnSwhaaQW5waAyzy6VJFgCCpaMWS15vrg3hQ5RS3rCmgZLfW6BeGUBSDs4K/3l2j 21UerYjx/PKM6x/1Tc0EbFHbRbouuRDOtdfg/2ng+ZCuxyiDdMpru+5qhJYw01yjqWuw +imddtsa9DcRBbn3gY4uGrs22/drXKywkZLzVN4G8drmzDGfXIlHuA8APi+K++l7urIt wFmaYXw56Kl+4TM8o/3+cmZMXtCNJROTRjUL8Vxxl5jHcZMi1EwuN2BTmYz5KOwsWqMw lkcygNl4PENAFjXvxJZx/SggzFdKcC/5YSVmpLr+3RRoRTKFxPg4Fcm+P4eyKaKe+tjQ IyWw== 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=iC92PipK9xi9Jfw1OJglpEcx4IgdHfslzbOxexcXORc=; fh=cLkEPrWisjOe78FY6AxtUThgrBXSRv+18zlxjNyWVJE=; b=Nv8cgAohVl4wbf4cjg0usrVLq7Iz9neaMtbGZ3BJ4DSYSEnxxcl7wgPEhaZLKriX3r gQm5VKp+BeiSEbNj9Awemt/IbMQRFmeDtnBe/xkz1fbZh7Exrg8QvDl4FPRl2WJ6I6Fu 0Lhw9eTJv0boW5leBFw2NeS+x3VRJBHWnsHWZr7JLoQyXRe8qinTciVJFFADHLHuuaF1 +a++K9G+mzfeEXgc/tW6VM+VXKKCFL+8/B4NcB+XGnZfFO3nOYr458+klXVN+35LfGBI tNCP+eQsU4AZMBGd8A91N6CryHIsKCp1A/HvFxdaOuWVsG+lNtNXb6j8GBJdUO4MXcDi 8ZPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HS7dpAu+; 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 2adb3069b0e04-52ef54ffd62si412060e87.195.2024.07.19.06.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:57:12 -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=HS7dpAu+; 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 CEFED88BC2; Fri, 19 Jul 2024 15:57:02 +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="HS7dpAu+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D93E088B8D; Fri, 19 Jul 2024 15:57:00 +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-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 48CA688BC1 for ; Fri, 19 Jul 2024 15:56:56 +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-4279c924ca7so12850585e9.2 for ; Fri, 19 Jul 2024 06:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721397416; x=1722002216; 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=iC92PipK9xi9Jfw1OJglpEcx4IgdHfslzbOxexcXORc=; b=HS7dpAu+HbZVVkBSGaL5MuDpab9UV+ghUf6CXQR/JFEO7x/6dLeYaRdeoAuJFlO4D4 jKVt8E7/424mExPyPvUyd72PcgoJua7vKZdxyjPYzzz24ptJ0ctl7qYAHHC9SMYbGl+f JDkdystVjNENAvyYLHG+6ndTt0q2OXE3AozvZRac9jNxdPxzPMc/AxsEkJkNS6md1ZGv zAEQeMDYdUkgiAaAVlzULnVxowRWD+ooDTJzMNFUvrM1yzcFsOGGuKGYZ27pEcwd7oyN FoZycNLmGQMvEAMop3CFU+q9Yz9aN05DezCHZVIJsQq3y2j+0ucO1sETDX+L8nHyWsAU KybA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721397416; x=1722002216; 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=iC92PipK9xi9Jfw1OJglpEcx4IgdHfslzbOxexcXORc=; b=RAW9sJFQqRkNidEjdG1WXdMPgTukRpcsdrZ5T6Syne0taKPpee2kJ+ZVUg68WwWdmo xqUZqJWziHHGwUkFGm1kB/Zn59If0JHHWXL9h1JCNn5TePmwVzj22yCgVqN6BpdwuhfA uAADzFEOoCQ4l/dd788X+h4btzGS00R/uhPPdQ+puwWn53altUzPev3HycHmbndQICWn BxfyCAcxQMnlIO1YLST8qz+kbPAs1h4BhvKxTq0uabMT1MfHxj7v0tSTqTwJCKNEgkWj oEWJzrcoIwpGgr4mwcgCgYSqSvaJ/q8aukUj8tdJh1xUZAV1WUAcFqnB2QlRu8xkBhb1 fY/A== X-Forwarded-Encrypted: i=1; AJvYcCUZor3n+aQHfjsaJAmD+Ntix8AgggiFSs07o+nz7IVzJ6tNmzxs1v1c9sFDxB4A4TG++gi0sahy33dQfyBYvE9CjhOifQ== X-Gm-Message-State: AOJu0YxKff5rz9r63jUzbzcZiEqX9GRshKa7OSgXVZrbIfcOu+PyiAbH IoSoibxdA/eL8sog8eSlQRam6Imx7NZYrEYyjwLD3VRAoLhAguk/mQCP794d5NA= X-Received: by 2002:a05:6000:14e:b0:368:74e0:2068 with SMTP id ffacd0b85a97d-36874e02316mr1655270f8f.33.1721397415452; Fri, 19 Jul 2024 06:56:55 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bc21sm1694083f8f.39.2024.07.19.06.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:56:55 -0700 (PDT) From: Neil Armstrong Date: Fri, 19 Jul 2024 15:56:50 +0200 Subject: [PATCH 1/3] usb: dwc3: allocate setup_buf with dma_alloc_coherent() MIME-Version: 1.0 Message-Id: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-1-58a5f026ea8e@linaro.org> References: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-0-58a5f026ea8e@linaro.org> In-Reply-To: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-0-58a5f026ea8e@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=3047; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=oDzc1qoX0+WC9wBPLHsCPc0eCSw/oz1cIvgRcvtG0gc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmmnCkYL2ILTqu1DArHuc4X17tYShyqIreRATqLa5T 1bhjxJ6JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZppwpAAKCRB33NvayMhJ0QY5D/ 4uSpl6vnmUg19tsmsUVxUSBI2SzHrNWnqb6obfq7OPr9FafM3G7vWNEGlZlU1Ol2+2Ssh6FzzWY+JV 6P7MsAOfbIUx4H54yZIFd8ffJuCBeQ3uLQzNqBadhVwnTEuj92kFMTh8wp01+SopHBXwM4fQJD0qH6 TTOXjIJasNs5LRnYhr+FYJ6wGlMO7Q4NnvvEozMUQoFQeRViPJ+n2DSeZTeP1egsehPfpOYGL8wDnM N5XA6eqgym/HgK/mzgNGGOvsoIGHNY+d11P+LrloB7VvBkJVVcYrZUsYV1/U3F5CSMu9R61/ELGKP7 7DXv5LI4B3agPgTaNMvr5HAmRtOasW6F9wD0td2ieA0P1Pc3g62kzA2CNXe1er8BBJQp3Fm3tBmoXN Tf/hBvX2Zb4gdilhbya0Jw/WPZTQBkecXN9vDLlRL6W+8Ur8MxLwDWUB174Rkea0IwSWWSgcYO4QRb KjNtUps1BzugX7qHKxwBaidSVi+6RR5wHchvmlH3x0qtJdhejqMso4RHr2dSZshHFuR5hNTs9jUhZL T8EaDsSKXEMe2qXupGczri/D8MWsksxjJpRfH/ldLEr/LDFF6GT1nrkPkGcxAaIdXq7ckR/V5hlKXA R6OXQwnnnUcGbKxtkfbEfS35lf7Y6wbMgJh/kUs3b4nASOb4jaHkDWFQBM8w== 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 Also allocate the setup_buf with dma_alloc_coherent() since it's also consumed by the hardware DMA. Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek --- 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..ce35460c405 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 if 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 Fri Jul 19 13:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 813393 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp764716wro; Fri, 19 Jul 2024 06:57:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWF9dsLVewKcCalfZWInhwfP6uctHmu+BCUwWkhaiJ7ikTWp33hx+uiVA07fl7mT60YhDz/lB088AoP1NRyumY9 X-Google-Smtp-Source: AGHT+IFXDHr7XsAslw4Jtgf/si0B3cVaFAXKApVRe0ddglg6EAdPDRyX3YeklrjwncKkydRJEr38 X-Received: by 2002:a05:6512:128e:b0:52e:a60e:3a08 with SMTP id 2adb3069b0e04-52ee53c4950mr5616286e87.11.1721397442499; Fri, 19 Jul 2024 06:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721397442; cv=none; d=google.com; s=arc-20160816; b=yhIJKQuK+3MTUZEagpoNSxFIj2HMaiLw6oQvmp92u4MDnySIwWnDMnJADenOK2PD94 IidtGao5h6V1pbx3pPqHisM+u9A/m/vl5BFgJaYaS6qfh3rf1bxUMxg7xgdErqFGo2kQ pcKBfzIBgi9AfH7TNYqrQLAJN/m8alY+sxh3BQmYoTr60xlUeuJthkocE5xKzn+8ZP4C JgmMiD5/bolF6kXtmeQRX1tz0l0iT7BOT8OROAjU+pLm5VNFyNgBEg3Z6Jl0YP58K6v3 +t0LHH4vpjQLjPCzn7dz1VLKYiNWpYfMUtLXj6H47RK990ZkgJj+I3G28ia71eJ1OGkm +plQ== 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=i+jRIalvS5muc88dIbat7gIg4Q1A2Ra7DzoF/oDb6nU=; fh=IHdrh0w8Fl6sUu/FegR2WHcQ3FTGpY0o/mYarTjxDuA=; b=xZu6+0ZJ7bT9xLkQXkiJC9RGVwvpSTRDbVLQycuZvl+73k0XWXNsr3EbMCAZsUdW51 Iv6FJCbXYtc3Kncf4M9ENIryd+zdwk+0oFmhlgp+8hS1my05eZwXqg2QF/tqRtKD4njO pMqGjiEGUCAB+5AMXldNgOq5VhHooNBzq3uQ2SIfJ/7dKounHTs8wII/sLb8PkoVWSH2 ET7vjw7LgNG5bJJHvF3oREgCqFOjodYM6KBnPgQRPuTuAu3knd7eljgdRbQrocHPir7f jY4CuVTtymXIInW01DEV+TBVfZy734WgVuZ67rAxCdQEPrXmCZDkvFpkBb696hAY07mg hkGw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EkhyiP/n"; 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 2adb3069b0e04-52ef54ff440si423165e87.151.2024.07.19.06.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:57:22 -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="EkhyiP/n"; 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 4584288BCB; Fri, 19 Jul 2024 15:57:03 +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="EkhyiP/n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48B0F88B8D; Fri, 19 Jul 2024 15:57:01 +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-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 6584188BC7 for ; Fri, 19 Jul 2024 15:56:57 +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-x32f.google.com with SMTP id 5b1f17b1804b1-4279c924ca7so12850715e9.2 for ; Fri, 19 Jul 2024 06:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721397417; x=1722002217; 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=i+jRIalvS5muc88dIbat7gIg4Q1A2Ra7DzoF/oDb6nU=; b=EkhyiP/nMy6dhwlsfiZRmt4d4YhOKpp4gkxVL6HGYY37jdHd71381o5ROy9WR/qYA2 DwI7K6hIjfPzf3IAXkQonEMXh1PYvwusaruMGdj2UXbnEu760upy8X7DVeHkKehCunBu VfRZXSuEH4uDvo2eJkTpYvp7DGHSFuamvvlBcwZWIUKg2697evqcM6680JiwsB1m7QO7 qXs4xYhdNHA+Z1yxfObIzG7Zoqgy7lpe9azQ9VKvBtxJb6E9pLqscqn7zVFYYlwttTO1 8PTqIuoua6tbd2I+DZLdxnZrnEID9f1EzmStdUN08USTafz4XoAcykQBVXFcQg8gp609 MW6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721397417; x=1722002217; 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=i+jRIalvS5muc88dIbat7gIg4Q1A2Ra7DzoF/oDb6nU=; b=rVaGc8BSJH3VYpqi72TErgFkE9l5Ceez6sLOCd0/WgcdkyLFZqDxnmmTVjoctuIlyK 63lwp3MyuDKWwh4sN146btUEuxonrI+0KFpOaM9S5N2YhDAwMvmMblBR3W2x7PcEKWrG 6Q2ZRH/0agGdI8qcSFzAsrOwCbTUvlG5Jkthl005obCOFgZQbNzHVKft7pSWNsmCHcE7 H097OlhSKMI7ZHFEI6Kitt7xwpjA1GYxr4DXZ/bsZ/y76cJ/i7QLf/s+QFEInHkhWVnD 6p8tVVqd8x9iDSE3bIR6ODiwl7VwZjhTivMYSVUM5+NX9EojT1O6CpNVo57DLyqr60l/ Hy1A== X-Forwarded-Encrypted: i=1; AJvYcCUR4I4xEd5GDwpyeHLnGNcKLl69nodJU0FwjCYsp4xRZjODgkAYxGTfwPRGQ44TX4Iz8pWg4ANIBFItIQBW9VFkc7JplQ== X-Gm-Message-State: AOJu0Yz7/RwT3XN7Cca6Zl0RtM+JL6QUOH786/XtGg2PnOpC7gH/qTzV rN1gVvoHE+vAMBd4OCQ3bXgRQ2BVVgPqb8JXA2ei22zwfUQwwsIa0OoitGn3d50= X-Received: by 2002:a5d:4c8e:0:b0:368:31c7:19d3 with SMTP id ffacd0b85a97d-36831c72a22mr4681547f8f.9.1721397416289; Fri, 19 Jul 2024 06:56:56 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bc21sm1694083f8f.39.2024.07.19.06.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:56:55 -0700 (PDT) From: Neil Armstrong Date: Fri, 19 Jul 2024 15:56:51 +0200 Subject: [PATCH 2/3] usb: dwc3: fix dcache flush range calculation MIME-Version: 1.0 Message-Id: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-2-58a5f026ea8e@linaro.org> References: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-0-58a5f026ea8e@linaro.org> In-Reply-To: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-0-58a5f026ea8e@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=1110; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=kh4rtOL6KeUvZru5sLtHZtD07pAad6NFUjKXTJm+qDc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmmnClPPG/Fg9c6HqnGAbU3NOHqXuMzkT+XVYeFAfF bSfTPJGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZppwpQAKCRB33NvayMhJ0Y3sEA CVFcj2sDoJHJIuKiiCDOwm2HfJ/xEIjAqoiZ9UFFgegJjWBWvWHgvkLP2t9hf3oRIMeV9Ifq0CkXyx iAsGxXjqjSuyvzKC0s7JORHI11qqWvICHEIfvuqfVnkNsyX8dZZ42VZA/u01sKF1hR+dY9UWQylvgC FzyDUI1q7ZtyhL0qVHnRFsjHgS4BPaHsYXoDYku+rrbSEewXB0X/oDlYX5JBDSDwEk2aM/nSOjm8vz EgSCREGm/uX3OfdY8MpbqbSFF8rkLAsqsrzGxMVYA1izmevlztjxwbIFjFktyZ6secS+pDAbHKsKvl sKiaAJc9EGpowHdfS+YBBxcRpmQ//MoHts5zaxmM+oiJY1ds4s4UpGBQH6YoyfvgPka7H9xOGr0vvt n/YPk9jL1KKgcruDyyfshQTylnuDGUXpDYbxui6CQ3sRDedNFWMWir1PMBlWE9712SVc2YWkbQLIE2 lR56Ivp/A+z+k4Msrypy7ObTaKR4KZ+gMRE8LwNdZbSak8qhxFW8ciKrPwZ+BCz/oGECXpaT7M8zs8 VntXCS/LfYuWsl9R3wULTraYYcAPjb3eAmulIiju/8l/47y9hy01pPsxBVUktyAhS/cGtLtnoaLKKB 9zj9MFLlAVLHhgPpTbmJKOWcbORorS1k/4RIMXQsuFCFc2PQJFU/Q9nlcXUQ== 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. Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek --- 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 Fri Jul 19 13:56:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 813394 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp764799wro; Fri, 19 Jul 2024 06:57:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXH3chOJZcYuxzIwGSJF3ZWwHgZorS1Ag3p6GbDgSMea+GrbthO6yNNMsQIV2IDqjJP38/hF+AMSV5BZBwIAFYj X-Google-Smtp-Source: AGHT+IG8xW2DlGlilwvHHUac08mqDK4u8r2OzIKs9cY35RRgnfydnuICkqBAPMbvfadTTqUVMJ3W X-Received: by 2002:a05:6512:3b8b:b0:52e:9cc7:4461 with SMTP id 2adb3069b0e04-52ee53c3dffmr5741964e87.5.1721397453807; Fri, 19 Jul 2024 06:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721397453; cv=none; d=google.com; s=arc-20160816; b=mXNgUlmw1L1TNPYMvo7H8OmwfjyFb7UIpgQga7CvwmDipyU1fVd7KFq6/+GhrT8l1d J2gkN2Oc1bTvGA0xc2XkxDIJWNaOuJwYNKYgdZ2vN1Tytg4Y4gwZQAyxT98/YvisNmE5 YQIzT3SHfVKXEmbqOb2FfC7cqiObZYSF+KNsmJKz7jJ8s1DhP4YrivPgaKKqQnTFjaMr X1tiYJBVcgAw2lEkqWYnJ+3mI+/RLuq9x7COqlKJ+NWTHX5gSq4YjExWfI8bTwOq8InD gzeXal4vYxef/KTNMUCxHrPsD+9p+4ZkAKWw2/bi/rWP/l/P9EBlDg+k0DjXA3kLIoc2 XTRQ== 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=XC6Y1cpNpchY+zzcdh5bJH6Mn3r/EZmTDYKPR+8m8/Y=; fh=k3jB3sD2Qiog1uXeUFdI0kRkNVuuiIQIp6aZ4/HGsWM=; b=CXYffNRb+vwMNWWnsbhyJ1muhnQeB/34zdmCDeQTh1Tra1hAzCKYDgg9XF4XF/GxXJ YvFtoK4RIi3atR9GCYZj6D5kXof3j1lkzcjQ2w2kmfTPeBD5+93Aq6+Am/yRwpJbytUQ cd3y+Fkd/UMrVxEIkYOEHt5oink7nqKTCvLbFHtCWZPnA66oimIKKGyIU4EVS3KySMK+ DGd3kDY1vUgY2wPnspIk5C9Hq9G4pc/6W/ZVkyXgxnOXxQUUynzhph+5tRXCG0633lxZ pTGXDdu6f+uvNpUbbtnHmkcve/FWFsxzZkokDWbKKo+3IH8nuZtzCZxtQohRhVM2VJmG 9wsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hjA0LV7O; 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 2adb3069b0e04-52ef5543fd7si428353e87.447.2024.07.19.06.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:57:33 -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=hjA0LV7O; 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 C547288BE8; Fri, 19 Jul 2024 15:57:06 +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="hjA0LV7O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1C55988BCB; Fri, 19 Jul 2024 15:57:03 +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-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 D339388BA8 for ; Fri, 19 Jul 2024 15:56:57 +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-x42a.google.com with SMTP id ffacd0b85a97d-3685a564bafso642541f8f.3 for ; Fri, 19 Jul 2024 06:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721397417; x=1722002217; 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=XC6Y1cpNpchY+zzcdh5bJH6Mn3r/EZmTDYKPR+8m8/Y=; b=hjA0LV7O5LBPccrqikk5ipdtONuNqS7+VmssDy5cC5ZBRawSeE4kj+WY+TzDgJ+phF j+Xlsyc6bVShHImPGTHCR1HLVk9wWwMsCOPBiQGpxkuPJtJND6vbqUQ7uiXbM48N5VCH O+ns2rHjhgmTGx3yF+UwlAJUfcLP/PTvsdpbZKcY1bT+TL/Cw77PfUWSGJ0sfAMjoEou Rht25VvUS5gu6VU30QUNcoZ0bNa4g1d3JSNUJS9ECUhv/j5mEh8+mLSU/dPNuP/g/Ic4 iIMzfT9Yj5mG8HY3j2XaGIUDhB/Gr2ogdcPoZDh55IsAfH5EB8SrijtKRbF296o9h3wL IOuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721397417; x=1722002217; 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=XC6Y1cpNpchY+zzcdh5bJH6Mn3r/EZmTDYKPR+8m8/Y=; b=JBF3vfrWhWRzHGM7DklTWpLHhKlHZzjYdCa77x2ckKJ4rYemoV0idO1WpzwtzT06lV CmfQJNTMMs8vALEpCn6ocNv8w7SYpuFPPNRDMzgF3pL9FrKjTL+6BDUojNeYZ8kvGJ4Y k4ldrZrQuatKPuM2yMOEKEFq4XnWqz2Te+RkeOqdJcESo26c/KJWy7QRoRmb1CzqByJ0 L4N+jVbMFM4PijnOHnKHz2gRSZY8XYLWvaue1XyKC6abL/Mnf0GvCArtiCpz5chSQr1n YQzFiHqDUzKNXOLAuu3qOLunen9mBuBa6izV2tB9r5mZdGW142c15HLgrxS/0EQ88R6C f1sQ== X-Forwarded-Encrypted: i=1; AJvYcCVFJVy7JQmdRlQIKA481zvGF6lvb11VBmdOGUz504e5sFQYOhsfrHNcgV8qgxQCqrAHYv51neoex/btSNOYWMnn0fOX9Q== X-Gm-Message-State: AOJu0YzkdNV6qj4liOYBqR3UAIL+SHstGXF5R/QbTl4d0njE2AL3pMnt TCHsNPnNvGLqMGjNnHpCP7fDpZM1DKWocJMg2r7pR0B9suUABzuRCkp1ud1VTQQ= X-Received: by 2002:a5d:4576:0:b0:368:657a:6347 with SMTP id ffacd0b85a97d-368657a647bmr2726949f8f.34.1721397417069; Fri, 19 Jul 2024 06:56:57 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bc21sm1694083f8f.39.2024.07.19.06.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:56:56 -0700 (PDT) From: Neil Armstrong Date: Fri, 19 Jul 2024 15:56:52 +0200 Subject: [PATCH 3/3] usb: dwc3: invalidate dcache on buffer used in interrupt handling MIME-Version: 1.0 Message-Id: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-3-58a5f026ea8e@linaro.org> References: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-0-58a5f026ea8e@linaro.org> In-Reply-To: <20240719-u-boot-dwc3-gadget-dcache-fixup-v1-0-58a5f026ea8e@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=2360; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=O5J25UaIoFRsnO+v0VukJ5RdDmbk6MuGwxOpVDPF6vE=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmmnClazlJj0WqLRfFrc+7CRP65tPRd8p7CpfhZbjd xeha/J+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZppwpQAKCRB33NvayMhJ0UK0EA CodKdnPVSp6uLnVnqS2+F+5gLUR7NspBen5GdUogUMAnAhdJ1ye1HfrZu5hvnlirnE3Ba9L4EZp7XT z6iQXmUhMox5dL8AcsGOJF5vaHOailBehTO2ox483vcMODVznbp1TudsgLLCHWmPB1yaRnt5VWACb7 /U5MvOpYsqr8qcxukiFar2GMJhNeVWG9HZKYYPlcO2Ub7KTTmVO3iFP03g6PALFPP8t/HZ+x+vUta9 alCepAAuSe2Cq7JXCRw1ayQtUnVfP4ZAuAjmN3Wi95+as52mR2rwKS2UIjZroc0VSy/SFUPyirrQaI xIJ/xmTQYJKcRpfEP2gI8PCbpEMjniAGDzPBcSEno5+wYMi1OVfKlamn/37R647kJxaivfNyfeV10f XCHhYQIawp2MqxbsLfb7G3L9ewC9gecovnL/IdqNLRJ6OJ7iNH71ZvNP2+db7i5ysWvll1Dw19lMIV pNKrhgTqNwDvpciG1nRHUpURBweWcIGdFAIs6qOK58dnQ9sXfdGZzwePx0FRp+g3OJ23n6SeGDPtVp YMm3DMSnMP9otyuIlnn3hI6N6SkiSZG4CzjSTBW3XYMQ96oRZqPtasnkdzKGzpLS0F9y63zaiuUS3+ TWms86YHTym0Y6ZFCMGfVzNyFqHOhwq74U9u3BpKiPx6sy45NQOUeein9h1w== 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/ Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek --- 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 */