From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Guenter Roeck <linux@roeck-us.net>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Yanteng Si <si.yanteng@linux.dev>, Furong Xu <0x1207@gmail.com>,
Joao Pinto <Joao.Pinto@synopsys.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v4 3/3] net: stmmac: Specify hardware capability value when FIFO size isn't specified
Date: Mon, 3 Feb 2025 20:32:53 +0900 [thread overview]
Message-ID: <e1654cc9-a696-454c-a9c7-80a8e1a148ff@socionext.com> (raw)
In-Reply-To: <Z6CLDJJ21MMml3cD@shell.armlinux.org.uk>
Hi,
On 2025/02/03 18:23, Russell King (Oracle) wrote:
> On Mon, Feb 03, 2025 at 11:45:05AM +0900, Kunihiko Hayashi wrote:
>> Hi all,
>>
>> On 2025/02/02 5:35, Russell King (Oracle) wrote:
>>> On Sat, Feb 01, 2025 at 11:14:41AM -0800, Guenter Roeck wrote:
>>>> Hi,
>>>>
>>>> On Mon, Jan 27, 2025 at 10:38:20AM +0900, Kunihiko Hayashi wrote:
>>>>> When Tx/Rx FIFO size is not specified in advance, the driver
> checks if
>>>>> the value is zero and sets the hardware capability value in
> functions
>>>>> where that value is used.
>>>>>
>>>>> Consolidate the check and settings into function stmmac_hw_init()
> and
>>>>> remove redundant other statements.
>>>>>
>>>>> If FIFO size is zero and the hardware capability also doesn't have
>>> upper
>>>>> limit values, return with an error message.
>>>>>
>>>>> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
>>>>
>>>> This patch breaks qemu's stmmac emulation, for example for
>>>> npcm750-evb. The error message is:
>>>> stmmaceth f0804000.eth: Can't specify Rx FIFO size
>>
>> Sorry for inconvenience.
>>
>>> Interesting. I looked at QEMU to see whether anything in the Debian
>>> stable version of QEMU might possibly have STMMAC emulation, but
>>> drew a blank... Even trying to find where in QEMU it emulates the
>>> STMMAC. I do see that it does include this, so maybe I can use that
>>> to test some of my stmmac changes. Thanks!
>>>
>>>> The setup function called for the emulated hardware is
>>> dwmac1000_setup().
>>>> That function does not set the DMA rx or tx fifo size.
>>>>
>>>> At the same time, the rx and tx fifo size is not provided in the
>>>> devicetree file (nuvoton-npcm750.dtsi), so the failure is obvious.
>>>>
>>>> I understand that the real hardware may be based on a more recent
>>>> version of the DWMAC IP which provides the DMA tx/rx fifo size, but
>>>> I do wonder: Are the benefits of this patch so substantial that it
>>>> warrants breaking the qemu emulation of this network interface >
>>> Please see my message sent a while back on an earlier revision of this
>>> patch series. I reviewed the stmmac driver for the fifo sizes and
>>> documented what I found.
>>>
>>> https://lore.kernel.org/r/Z4_ZilVFKacuAUE8@shell.armlinux.org.uk
>>>
>>> To save clicking on the link, I'll reproduce the relevant part below.
>>> It appears that dwmac1000 has no way to specify the FIFO size, and
>>> thus would have priv->dma_cap.rx_fifo_size and
>>> priv->dma_cap.tx_fifo_size set to zero.
>>>
>>> Given the responses, I'm now of the opinion that the patch series is
>>> wrong, and probably should be reverted - I never really understood
>>> the motivation why the series was necessary. It seemed to me to be a
>>> "wouldn't it be nice if" series rather than something that is
>>> functionally necessary.
>>>
>>>
>>> Here's the extract from my previous email:
>>>
>>> Now looking at the defintions:
>>>
>>> drivers/net/ethernet/stmicro/stmmac/dwmac4.h:#define
> GMAC_HW_RXFIFOSIZE
>>> GENMASK(4, 0)
>>> drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h:#define
>>> XGMAC_HWFEAT_RXFIFOSIZE GENMASK(4, 0)
>>>
>>> So there's a 5-bit bitfield that describes the receive FIFO size for
>>> these two MACs. Then we have:
>>>
>>> drivers/net/ethernet/stmicro/stmmac/common.h:#define
>>> DMA_HW_FEAT_RXFIFOSIZE 0x00080000 /* Rx FIFO > 2048 Bytes */
>>>
>>> which is used here:
>>>
>>> drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c:
>>> dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
>>>
>>> which is only used to print a Y/N value in a debugfs file, otherwise
>>> having no bearing on driver behaviour.
>>>
>>> So, I suspect MACs other than xgmac2 or dwmac4 do not have the ability
>>> to describe the hardware FIFO sizes in hardware, thus why there's the
>>> override and no checking of what the platform provided - and doing so
>>> would break the driver. This is my interpretation from the code alone.
>>>
>>
>> The {tx,rx}_queus_to_use are referenced in stmmac_ethtool.c,
> stmmac_tc.c,
>> and stmmac_selftests.c as the number of queues, so I've thought that
>> these variables should not be non-zero.
>
> Huh? We're talking about {tx,rx}_fifo_size, not _queues_to_use.
Sorry, this topic is just about {tx,rx}_fifo_size.
Above comments are not needed here.
These value are only referenced in stmmac_main.c and stmmac_selftest.c.
As far as I can see, there is no usage that requires the values to be non-zero.
>> However, currently the variables are allowed to be zero, so I understand
>> this patch 3/3 breaks on the chips that hasn't hardware capabilities.
>>
>> In hwif.c, stmmac_hw[] defines four patterns of hardwares:
>>
>> "dwmac100" .gmac=false, .gmac4=false, .xgmac=false, .get_hw_feature =
> NULL
>> "dwmac1000" .gmac=true, .gmac4=false, .xgmac=false, .get_hw_feature =
> dwmac1000_get_hw_feature()
>> "dwmac4" .gmac=false, .gmac4=true, .xgmac=false, .get_hw_feature =
> dwmac4_get_hw_feature()
>> "dwxgmac2" .gmac=false, .gmac4=false, .xgmac=true , .get_hw_feature =
> dwxgmac2_get_hw_feature()
>>
>> As Russell said, the dwmac100 can't get the number of queues from the
> hardware
>> capability. And some environments (at least QEMU device that Guenter
> said)
>> seems the capability values are zero in spite of dwmac1000.
>
> Huh? I mentioned dwmac1000, not dwmac100.
My above comment is missing the point.
dwmac1000 doesn't have the field of the fifo size in the hardware capability
even if dwmac1000 has get_hw_feature function as you said.
Steven's diff is reasonable to check the feature.
>
>> Since I can't test all of the device patterns, so I appreciate checking
> each
>> hardware and finding the issue.
>>
>> The patch 3/3 includes some cleanup and code reduction, though, I think
>> it would be better to revert it once.
>
> I'm not sure you're discussing the same issue as the rest of us.
> You seem to be talking about a different pair of structure members
> (queues_to_use) whereas your patches and the problem at hand is with
> the changes made to {tx,rx}_fifo_size.
Sorry for confusion. The patch 3/3 treats FIFO size as per the subject.
Thank you,
---
Best Regards
Kunihiko Hayashi
next prev parent reply other threads:[~2025-02-03 11:32 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 1:38 [PATCH net v4 0/3] Limit devicetree parameters to hardware capability Kunihiko Hayashi
2025-01-27 1:38 ` [PATCH net v4 1/3] net: stmmac: Limit the number of MTL queues " Kunihiko Hayashi
2025-01-27 18:07 ` Yanteng Si
2025-01-27 1:38 ` [PATCH net v4 2/3] net: stmmac: Limit FIFO size by " Kunihiko Hayashi
2025-01-27 18:11 ` Yanteng Si
2025-01-27 1:38 ` [PATCH net v4 3/3] net: stmmac: Specify hardware capability value when FIFO size isn't specified Kunihiko Hayashi
2025-01-27 18:24 ` Yanteng Si
2025-01-31 9:46 ` Steven Price
2025-01-31 14:15 ` Andrew Lunn
2025-01-31 14:33 ` Steven Price
2025-01-31 14:47 ` Andrew Lunn
2025-01-31 15:03 ` Steven Price
2025-01-31 15:29 ` Andrew Lunn
2025-01-31 15:54 ` Steven Price
2025-01-31 16:07 ` Andrew Lunn
2025-02-01 12:10 ` Xi Ruoyao
2025-02-01 21:03 ` Andrew Lunn
2025-02-01 19:14 ` Guenter Roeck
2025-02-01 19:21 ` Andrew Lunn
2025-02-01 20:25 ` Guenter Roeck
2025-02-01 20:35 ` Russell King (Oracle)
2025-02-01 22:02 ` Guenter Roeck
2025-02-03 2:45 ` Kunihiko Hayashi
2025-02-03 9:23 ` Russell King (Oracle)
2025-02-03 11:32 ` Kunihiko Hayashi [this message]
2025-02-03 11:55 ` Kunihiko Hayashi
2025-01-28 12:20 ` [PATCH net v4 0/3] Limit devicetree parameters to hardware capability patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1654cc9-a696-454c-a9c7-80a8e1a148ff@socionext.com \
--to=hayashi.kunihiko@socionext.com \
--cc=0x1207@gmail.com \
--cc=Joao.Pinto@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@roeck-us.net \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=si.yanteng@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®