From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5230DC4338F for ; Tue, 17 Aug 2021 00:02:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1553860F22 for ; Tue, 17 Aug 2021 00:02:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1553860F22 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HCRhb4Vkxg0/7zPm/cXIUfiUr7N2zOv1cPbvvzEXjOA=; b=b0+O7T/vot5Yy2 62FHzJuoZEbeyv+xtHIERILqo8TFb2egGqXYME2edEQblJNMZlMXwHVvyv9TOdCEpoK5OBd0u9d8y AauLU1eMgsuy81qh8/nNBEBhUWwDycIH1dPJktkx/dqah913biPwAB7i+v0XTjF6O/OJH2AMFwGNW O7ELWPhsyZLZKMFZvNMYQtatilooX3yBGg4WNra7zggAELx6hvIAnTYo6DdZTvNLJ4X8CEs74seWB +yMQTvmkBe8r6YHLxF68uDRGlmYnLD6UsTuxpBQrBPRhw2Oo5Qfrd9GK5dFG7g2lpb2LPYISOgtgA q1IH6Th3k3M+zeoW4Rhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFmYX-000Xjr-Fg; Tue, 17 Aug 2021 00:02:13 +0000 Received: from mail-ej1-f51.google.com ([209.85.218.51]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFmYO-000XiJ-VM for linux-riscv@lists.infradead.org; Tue, 17 Aug 2021 00:02:06 +0000 Received: by mail-ej1-f51.google.com with SMTP id lo4so34875942ejb.7 for ; 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=DWMLOLxLZM+O3PB4hyur4GeH5qJgknSZmeJaPSl+D1V+lDp+VtE/koL1WP5/YpUhKz pJKvADZW1O+2T6pKnG/M1R3Wh88F7hOjuVRB7FhMAqyfoZEDkwy+IzV71YLhDAdcAOEW va1CrHL/tJsdCVJfutANtGlmK+od5IpJXdHkrrlDPZ4IJijVHRKUkezHz+x36BKopf2K 1HXFQKRU8XLFpo7Wnif+MoDq7fU6SL/L9FLxHwoM3w4F3cNei7jOFTEApXUPP4iRBHrZ xA5ZKeyJaqZxAlZakK962i8WoWpz31wJHSrdZB8ToS5SbJq3qvyWapSLO5RJMwqgbAFw gSbA== X-Gm-Message-State: AOAM5312LwW6cZD3dHoZ95RcimqZL4oJ3N6r5CyUkuyMMs0MY4rcQK/5 rYD07tu96b3zaItvky/nlrVG3cYrxyV95Q== X-Google-Smtp-Source: ABdhPJwbIAStQIsvY6nYd2xafGE+WztwQNp3Byq8JJLV82ISdOqBErzCmeSfzD0xXPsR/3+lGtA1aQ== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210816_170205_075490_F811871A X-CRM114-Status: GOOD ( 25.30 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv