From patchwork Mon Mar 13 22:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A8A05C6FD19 for ; Mon, 13 Mar 2023 22:47:04 +0000 (UTC) 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:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Nw1xXt+yYabiZN3w/7NaDu8g6B/mzSNm/ZntGcg4GAM=; b=EM8+CoBlinTuoT l+m5CIcc3y+9oXH9lA4ozC1g5fJBmtWyuEDDbzplgvRPvnsmjrYsJziwXEvSJVdJLsnq0UQw9aBPA olrty5P4xOpFOJs6+lgKj0OLseKsGipC9je7P1fhEBi3NNtiMUEV7X0tOqh5Pwob6ldQ0k41jsswk 1gz/uxZGpbkWc1nYpOGTnW+Ck24FMut7YGp9taKLqQdqscwvwRjGS/N+CtO9gLeIfV8BTaBZEhA5M y5WK4rbcMDFwtyPEQ3sngJakwLlqUl+/0xpkkiIxAEw5q2tDYYr3Sk5McoxYn7+AK/8T5Qa5p1cgS c38LKTMOOXLhGfTv609w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqva-0087xf-2H; Mon, 13 Mar 2023 22:46:02 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsd-0086HV-2j for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:02 +0000 Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id B5247E0EBD; Tue, 14 Mar 2023 01:42:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=nZ9yG0elRT6uL0+4AaOond5kO+hwjv7M4hDEo8ZCYAM=; b=FeqczvuB9KUR dQSzwn7YirRM436fADUn0EEbl2wqkSOPnkZO+RMPuVfw7ODFrNVdRJrhEx7hAVbo 4NX7UTUgW9C8KihED2TGQ28IZ7h0CQBS44vkj/fYABFnNClzQ9TmafRPiV0sUiOK dQM3MytNNuGvZmP8Fk5ntjAQ/UPUK5E= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 985A4E0EBB; Tue, 14 Mar 2023 01:42:54 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:53 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 10/13] net: stmmac: Make buf_sz module parameter useful Date: Tue, 14 Mar 2023 01:42:34 +0300 Message-ID: <20230313224237.28757-11-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154259_363966_5A65931B X-CRM114-Status: GOOD ( 17.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the first day of the driver been added to the kernel the Rx DMA-buffer size module parameter hasn't been utilized for something more-or-less useful. The STMMAC main code used to initialize the actual Rx DMA-buffer size (priv->dma_buf_sz) with it by default, but then overwrote it anyway in accordance with Network device MTU or with default DMA_BUFFER_SIZE/DEFAULT_BUFSIZE macro. Moreover in the both older and modern versions of the STMMAC driver the buf_sz module parameter was overwritten on each Net-dev open procedure with a value calculated in accordance with MTU and allowed maximum buffer size. Needless to say that even though it doesn't affect the driver functionality much, setting the generic parameter with a value specific to a private device is wrong, seeing each DW MAC may have different maximum buffer size on the same platform. In order to finally make the buf_sz (Rx DMA buffer size) parameter really useful let's stop setting it up with a value specific to a particular controller and use it to calculate the Rx DMA-buffer size instead of MTU if one is greater than the later. Thus we'll be able to tune the buffer size up when it's necessary. Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e5cb4edc4e23..12de84b7e90d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -100,10 +100,10 @@ static int tc = TC_DEFAULT; module_param(tc, int, 0644); MODULE_PARM_DESC(tc, "DMA threshold control value"); -#define DEFAULT_BUFSIZE 1536 -static int buf_sz = DEFAULT_BUFSIZE; -module_param(buf_sz, int, 0644); -MODULE_PARM_DESC(buf_sz, "DMA buffer size"); +#define DEFAULT_BUFSIZE 1536U +static unsigned int buf_sz = DEFAULT_BUFSIZE; +module_param(buf_sz, uint, 0644); +MODULE_PARM_DESC(buf_sz, "Rx DMA buffer size"); #define STMMAC_RX_COPYBREAK 256 @@ -3730,7 +3730,7 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) bfsize = 0; if (bfsize < BUF_SIZE_16KiB) - bfsize = stmmac_set_bfsize(mtu, 0); + bfsize = stmmac_set_bfsize(max(buf_sz, mtu), 0); dma_conf->dma_buf_sz = bfsize; /* Chose the tx/rx size from the already defined one in the @@ -3817,7 +3817,6 @@ static int __stmmac_open(struct net_device *dev, priv->rx_copybreak = STMMAC_RX_COPYBREAK; - buf_sz = dma_conf->dma_buf_sz; memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf)); stmmac_reset_queues_param(priv);