Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752041AbdCIU1S (ORCPT ); Thu, 9 Mar 2017 15:27:18 -0500 Received: from avon.wwwdotorg.org ([70.85.31.133]:53908 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751333AbdCIU1R (ORCPT ); Thu, 9 Mar 2017 15:27:17 -0500 X-Greylist: delayed 527 seconds by postgrey-1.27 at vger.kernel.org; Thu, 09 Mar 2017 15:27:17 EST Subject: Re: [PATCH 5/7] net: stmmac: Program RX queue size and flow control To: Thierry Reding , Mikko Perttunen References: <20170223172438.14770-1-thierry.reding@gmail.com> <20170223172438.14770-6-thierry.reding@gmail.com> <74ee5bff-8893-ebd4-bcf8-bb92c476f581@kapsi.fi> <20170309194231.GD5554@ulmo.ba.sec> Cc: "David S . Miller" , Giuseppe Cavallaro , Alexandre Torgue , Rob Herring , Mark Rutland , Joao Pinto , Alexandre Courbot , Jon Hunter , netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org From: Stephen Warren Message-ID: <83aaa3b1-a2d4-8ddd-d31a-2fd6c653e3d1@wwwdotorg.org> Date: Thu, 9 Mar 2017 13:18:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170309194231.GD5554@ulmo.ba.sec> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1891 Lines: 58 On 03/09/2017 12:42 PM, Thierry Reding wrote: > On Mon, Feb 27, 2017 at 12:09:02PM +0200, Mikko Perttunen wrote: >> On 23.02.2017 19:24, Thierry Reding wrote: >>> From: Thierry Reding >>> >>> Program the receive queue size based on the RX FIFO size and enable >>> hardware flow control for large FIFOs. >>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c >>> @@ -252,6 +253,44 @@ static void dwmac4_dma_chan_op_mode(void __iomem *ioaddr, int txmode, >>> mtl_rx_op |= MTL_OP_MODE_RTC_128; >>> } >>> >>> + mtl_rx_op &= ~MTL_OP_MODE_RQS_MASK; >>> + mtl_rx_op |= rqs << MTL_OP_MODE_RQS_SHIFT; >>> + >>> + /* enable flow control only if each channel gets 4 KiB or more FIFO */ >>> + if (rxfifosz >= 4096) { >>> + unsigned int rfd, rfa; >>> + >>> + mtl_rx_op |= MTL_OP_MODE_EHFC; >>> + >>> + switch (rxfifosz) { >>> + case 4096: >>> + rfd = 0x03; >>> + rfa = 0x01; >>> + break; >>> + >>> + case 8192: >>> + rfd = 0x06; >>> + rfa = 0x0a; >>> + break; >>> + >>> + case 16384: >>> + rfd = 0x06; >>> + rfa = 0x12; >>> + break; >>> + >>> + default: >>> + rfd = 0x06; >>> + rfa = 0x1e; >>> + break; >>> + } >> >> Are these values correct? In the 4096 case, rfd > rfa, in all other cases >> the other way around. In any case it would be useful to have a comment >> clarifying the thresholds in bytes. > > I'll investigate. To be honest I simply took this from Stephen's U-Boot > driver since that's already tested. I trust Stephen, so I didn't bother > double-checking. I don't recall for sure, but I think these values came directly from either the upstream kernel (the non-stmmac driver) or NV downstream kernel EQoS driver, and I re-used them without investigating. I'm not even sure if the outer if() expression is true; these numbers might not even end up being used?