Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp745012pxb; Mon, 16 Aug 2021 17:03:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy90mUuPDeYkNoAhHwmgcCrI8FGRuq9WB9d4mv2/YJWFH68Jb01iBNlhjS7V/RNqbYyUJxL X-Received: by 2002:a5d:8e11:: with SMTP id e17mr697960iod.138.1629158609636; Mon, 16 Aug 2021 17:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629158609; cv=none; d=google.com; s=arc-20160816; b=MaH0Eh3+nzUQujXr9ypY4N6NB68VFBp/Nqs8/xIKERJk5rgCtEJaLXugYzyCzRIirs Nm7dsstcP/VZjgl15LAkpTuyqbgBhjqmePHmTi/n4u06cHM+I/TrCwddvPc5mu/SxUZ4 jHbyc33oFhT4e2mm4FqQzTyisZWXFzsYBCtCV9zE4fWxK3daoytQSQYO2hujuAGUifU7 jO2FTpkWC88Z76Ip1aeUKEpZBJ1PAsXmrncCo7yH4PwUYqbyLBaPN6fO9wlN410lrKfU VEw0kpJGr6IQxHkstflr0TCrHLTkBoRMRi8QsXx3p7PxYi/fQ7dzVvmhWuHiTGhSA9wx CWRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=K5wMGZQ9prIRh71CsiF4fL+ypemm9zRUN8YLcm2qyP4=; b=GyzsqbA16lfazyMkzrdpGpvGmlYahu3+1u2cg4LlWS9U+NprH5WFyZSi6URlDpa99w 0PyiDY/GL/V2478nzEw5sLsJo2NPbnaOIHL3VZeAi701TF3Xx7QI6UfvXvE1cPBTeIrN n1UmVPz9UVIn+xm8COCl50PexgHL8rahJlLbU+oyz7n3dZj0RvUAnP3JxyaTABUDiyjT jvVQeIeu2B6JJgosJyrTh1sJFiPUzNBoqThQ14IXtWzIC0hqCc4Ppv07M4Ib0/75oLCt YjgS/iFhNzu2PQy09N1CMZl/2FTI8ViQtkDK4bJsH/nWeJg9Xm9kQeZRDuJrfyUI1w/E zjbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si620200jal.55.2021.08.16.17.03.17; Mon, 16 Aug 2021 17:03:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234981AbhHQACg (ORCPT + 99 others); Mon, 16 Aug 2021 20:02:36 -0400 Received: from mail-ej1-f42.google.com ([209.85.218.42]:34518 "EHLO mail-ej1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234958AbhHQACg (ORCPT ); Mon, 16 Aug 2021 20:02:36 -0400 Received: by mail-ej1-f42.google.com with SMTP id u3so35039826ejz.1; Mon, 16 Aug 2021 17:02:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=K5wMGZQ9prIRh71CsiF4fL+ypemm9zRUN8YLcm2qyP4=; b=qMvaRCWkcOXithaJVmLXpwuaKAr/0zJSb46S7r+49cY9fGNID9/n5F6XMCaLLZ3x3f ChcWxa8rQiDxsXPNmPV8Iq1QYG9xA7gMHvuKYciWCHYiAmjL2GaW1UKI47/ruJL+og/i tD4Ve7cNaZL70kOKuJER9LgQkAwfZez7N5g60xvmZofdaDGBwtmm4Y1vMXXaajniafHT ZuZfBRaWkZfsXHAkZwQWgDaiYLDqKB15aV88y/3+TVjjZ45HJUTplKK1L7uDwXhHgdIM vYutof6dvYiMQ5moX7xd7dbRKgK9k4oAgAEsb1pDUBPvwafK+ecvSatT7CJqQssKzWBh sCkA== X-Gm-Message-State: AOAM5326P889nssQIYFq58gB2nYoNAJFCFPGoN67VkhyKi414kvnx8V1 VJDCyKNfbq6IiGb6a+Ef/8o= X-Received: by 2002:a17:906:7095:: with SMTP id b21mr705327ejk.131.1629158522789; Mon, 16 Aug 2021 17:02:02 -0700 (PDT) Received: from localhost (host-87-16-116-124.retail.telecomitalia.it. [87.16.116.124]) by smtp.gmail.com with ESMTPSA id gh23sm83504ejb.27.2021.08.16.17.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 17:02:02 -0700 (PDT) Date: Tue, 17 Aug 2021 02:01:57 +0200 From: Matteo Croce To: Jakub Kicinski Cc: Marc Zyngier , Eric Dumazet , Thierry Reding , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Giuseppe Cavallaro , Alexandre Torgue , "David S. Miller" , Palmer Dabbelt , Paul Walmsley , Drew Fustini , Emil Renner Berthing , Jon Hunter , Will Deacon Subject: Re: [PATCH net-next] stmmac: align RX buffers Message-ID: <20210817020157.3b9d015e@linux.microsoft.com> In-Reply-To: <20210816081208.522ac47c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> References: <20210614022504.24458-1-mcroce@linux.microsoft.com> <871r71azjw.wl-maz@kernel.org> <202417ef-f8ae-895d-4d07-1f9f3d89b4a4@gmail.com> <87o8a49idp.wl-maz@kernel.org> <20210812121835.405d2e37@linux.microsoft.com> <874kbuapod.wl-maz@kernel.org> <20210816081208.522ac47c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Organization: Microsoft X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Aug 2021 08:12:08 -0700 Jakub Kicinski wrote: > On Thu, 12 Aug 2021 12:05:38 +0100 Marc Zyngier wrote: > > > A possible fix, which takes in account also the XDP headroom for > > > stmmac_rx_buf1_len() only could be (only compile tested, I don't > > > have the hardware now): > > > > However, this doesn't fix my issue. I still get all sort of > > corruption. Probably stmmac_rx_buf2_len() also need adjusting (it > > has a similar logic as its buf1 counterpart...) > > > > Unless you can fix it very quickly, and given that we're towards the > > end of the cycle, I'd be more comfortable if we reverted this patch. > > Any luck investigating this one? The rc6 announcement sounds like > there may not be that many more rc releases for 5.14. Hi Jackub. Unfortunately I have only a device with stmmac, and it works fine with the patch. It seems that not all hardware suffers from this issue. Also, using NET_IP_ALIGN on RX is a common pattern, I think that any ethernet device is doing the same to align the IPv4 header. Anyway, I asked for two tests on the affected device: 1. Change NET_IP_ALIGN with 8, to see if the DMA has problems in receiving to a non word aligned address 2. load a nop XDP program (I provided one), to see if the problem is already there when XDP is used I doubt that changing also stmmac_rx_buf2_len would help, but it's worth a try, here is a patch: diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 7b8404a21544..73d1f0ec66ff 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -93,7 +93,7 @@ static int tc = TC_DEFAULT; module_param(tc, int, 0644); MODULE_PARM_DESC(tc, "DMA threshold control value"); -#define DEFAULT_BUFSIZE 1536 +#define DEFAULT_BUFSIZE 1536 + XDP_PACKET_HEADROOM + NET_IP_ALIGN static int buf_sz = DEFAULT_BUFSIZE; module_param(buf_sz, int, 0644); MODULE_PARM_DESC(buf_sz, "DMA buffer size"); @@ -4508,12 +4508,12 @@ static unsigned int stmmac_rx_buf1_len(struct stmmac_priv *priv, /* First descriptor, not last descriptor and not split header */ if (status & rx_not_ls) - return priv->dma_buf_sz; + return priv->dma_buf_sz - stmmac_rx_offset(priv); plen = stmmac_get_rx_frame_len(priv, p, coe); /* First descriptor and last descriptor and not split header */ - return min_t(unsigned int, priv->dma_buf_sz, plen); + return min_t(unsigned int, priv->dma_buf_sz - stmmac_rx_offset(priv), plen); } static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, @@ -4529,12 +4529,12 @@ static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, /* Not last descriptor */ if (status & rx_not_ls) - return priv->dma_buf_sz; + return priv->dma_buf_sz - stmmac_rx_offset(priv); plen = stmmac_get_rx_frame_len(priv, p, coe); /* Last descriptor */ - return plen - len; + return plen - len - stmmac_rx_offset(priv); } static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue, Regards, -- per aspera ad upstream