From patchwork Fri Apr 26 08:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 1928019 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=gpeeLhGO; dkim=fail reason="key not found in DNS" header.d=ew.tq-group.com header.i=@ew.tq-group.com header.a=rsa-sha256 header.s=dkim header.b=ilnlbrDn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VQlbn2Lvbz1yb7 for ; Fri, 26 Apr 2024 18:03:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BB0F8914A; Fri, 26 Apr 2024 10:03:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com 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=tq-group.com header.i=@tq-group.com header.b="gpeeLhGO"; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="ilnlbrDn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 235F88915B; Fri, 26 Apr 2024 10:03:08 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2B59D88EF8 for ; Fri, 26 Apr 2024 10:03:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matthias.schiffer@ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1714118583; x=1745654583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/JV6d2ir3FmMS2C8p9V/8pX87bdwS5QoIkkHOu736IM=; b=gpeeLhGOWCBgu1mViy8fLnpOvStH3R9lhGYq7zxxyY/o/Fw6Vhklb3i7 5gIAwZB8LJLZTSvZTvN4b+JSpEf6CHEKitG4Ka4GI+Fc32oYohuYFHkBw iF4lSKmorsMqD/XYBN1ba9qBNqHL1ugPzRGUme89mHBcHrYQWerttOJ3K 6ul8t6b9iW597PVfN7zmfTFmth8f01vCz7NlkIg3N0RM1yaU4VAfpajSp APNinEaZKVXWNTsBMz6rSpqgwWWFR2IaICLKL13qFYuUOOwu/jXsuLDME RtQaWSUaIvTCKgBhEYfPMhtsgGL/EQmZJZklUfaeU4WdDbIE4v1HO6egr A==; X-IronPort-AV: E=Sophos;i="6.07,231,1708383600"; d="scan'208";a="36629249" Received: from vmailcow01.tq-net.de ([10.150.86.48]) by mx1.tq-group.com with ESMTP; 26 Apr 2024 10:03:03 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5A92916FC9C; Fri, 26 Apr 2024 10:02:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ew.tq-group.com; s=dkim; t=1714118579; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/JV6d2ir3FmMS2C8p9V/8pX87bdwS5QoIkkHOu736IM=; b=ilnlbrDnf3gjylseeTnVgkuEfOhcu4WCYLp4cbYuih8kDcoI5HDNE7B/GjWKK8yLHTRBem ftAuDOJhUH3oSHpKBRn1pPQZOueH25yB59srpRZLlFR+fdnguzHWdF08cLglp8xcER2BWv Q1n8OqIgmoUkKAm2yB7OZeOAgdvbytlfPuml1k/jIoswHhihdk9FeV8S6Xs71HweH1shwV p0wbyBZFHasdbUeJUt8Ryb6qkDGaYZ4aZs8QDnddLZpnsf+pGBIvWUGYQK3nW4eBDqS1CV Iipag6bqM/4xsszJDGSoyRuBxOSGU5slGXNrm39WR6zwhT5igLkT2+QvT4yzcQ== From: Matthias Schiffer To: Tom Rini , Joe Hershberger , Ramon Fried , MD Danish Anwar , Jai Luthra , Siddharth Vadapalli , Nishanth Menon , Udit Kumar , Suman Anna Cc: u-boot@lists.denx.de, u-boot@ew.tq-group.com, Matthias Schiffer Subject: [PATCH 5/5] dma: ti: k3-udma: invalidate prepared buffers before pushing to recv ring Date: Fri, 26 Apr 2024 10:02:28 +0200 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 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 Buffers must not have an unclean cache before being used for DMA - a pending write-back may corrupt the next dev-to-mem transfer otherwise. This was consistently noticeable during long TFTP transfers, when an ARP request is answered by U-Boot in the middle of the transfer: As U-Boot's arp_receive() reuses the receive buffer to prepare its reply packet, the beginning of one of the next incoming TFTP packets is overwritten by the ARP reply. The corrupted packet is ignored, but the TFTP transfer stalls for a few seconds until a timeout is detected and a retransmit is triggered. Signed-off-by: Matthias Schiffer Tested-by: Alexander Sverdlin --- drivers/dma/ti/k3-udma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 4e6f7f570c5..8f6d396653e 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -2678,6 +2678,9 @@ int udma_prepare_rcv_buf(struct dma *dma, void *dst, size_t size) cppi5_hdesc_set_pktlen(desc_rx, size); cppi5_hdesc_attach_buf(desc_rx, dma_dst, size, dma_dst, size); + invalidate_dcache_range((unsigned long)dma_dst, + (unsigned long)(dma_dst + size)); + flush_dcache_range((unsigned long)desc_rx, ALIGN((unsigned long)desc_rx + uc->config.hdesc_size, ARCH_DMA_MINALIGN));