From: David Laight <david.laight.linux@gmail.com>
To: Simon Horman <horms@kernel.org>
Cc: Jijie Shao <shaojijie@huawei.com>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch, shenjian15@huawei.com,
liuyonglong@huawei.com, chenhao418@huawei.com,
jonathan.cameron@huawei.com,
shameerali.kolothum.thodi@huawei.com, salil.mehta@huawei.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/4] net: hns3: fixed vf get max channels bug
Date: Sat, 5 Jul 2025 08:24:03 +0100 [thread overview]
Message-ID: <20250705082403.0ba474f4@pumpkin> (raw)
In-Reply-To: <20250704160537.GH41770@horms.kernel.org>
On Fri, 4 Jul 2025 17:05:37 +0100
Simon Horman <horms@kernel.org> wrote:
> + David Laight
>
> On Wed, Jul 02, 2025 at 09:09:00PM +0800, Jijie Shao wrote:
> > From: Hao Lan <lanhao@huawei.com>
> >
> > Currently, the queried maximum of vf channels is the maximum of channels
> > supported by each TC. However, the actual maximum of channels is
> > the maximum of channels supported by the device.
> >
> > Fixes: 849e46077689 ("net: hns3: add ethtool_ops.get_channels support for VF")
> > Signed-off-by: Jian Shen <shenjian15@huawei.com>
> > Signed-off-by: Hao Lan <lanhao@huawei.com>
> > Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>
> Reviewed-by: Simon Horman <horms@kernel.org>
>
> > ---
> > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +-----
> > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> > index 33136a1e02cf..626f5419fd7d 100644
> > --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> > @@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
> >
> > static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev)
> > {
> > - struct hnae3_handle *nic = &hdev->nic;
> > - struct hnae3_knic_private_info *kinfo = &nic->kinfo;
> > -
> > - return min_t(u32, hdev->rss_size_max,
> > - hdev->num_tqps / kinfo->tc_info.num_tc);
> > + return min_t(u32, hdev->rss_size_max, hdev->num_tqps);
>
> min_t() wasn't needed before and it certainly doesn't seem to be needed
> now, as both .rss_size_max, and .num_tqps are u16.
It (well something) would have been needed before the min_t() changes.
The u16 values get promoted to 'signed int' prior to the division.
>
> As a follow-up, once this change hits net-next, please update to use min()
> instead. Likely elsewhere too.
Especially any min_t(u16, ...) or u8 ones.
They are just so wrong and have caused bugs.
David
next prev parent reply other threads:[~2025-07-05 7:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 13:08 [PATCH net 0/4] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2025-07-02 13:08 ` [PATCH net 1/4] net: hns3: fix concurrent setting vlan filter issue Jijie Shao
2025-07-04 15:52 ` Simon Horman
2025-07-08 9:30 ` Jijie Shao
2025-07-02 13:08 ` [PATCH net 2/4] net: hns3: disable interrupt when ptp init failed Jijie Shao
2025-07-04 15:55 ` Simon Horman
2025-07-02 13:09 ` [PATCH net 3/4] net: hns3: fixed vf get max channels bug Jijie Shao
2025-07-04 16:05 ` Simon Horman
2025-07-05 7:24 ` David Laight [this message]
2025-07-08 9:37 ` Jijie Shao
2025-07-08 16:35 ` Simon Horman
2025-07-02 13:09 ` [PATCH net 4/4] net: hns3: default enable tx bounce buffer when smmu enabled Jijie Shao
2025-07-04 16:31 ` Simon Horman
2025-07-08 9:41 ` Jijie Shao
2025-07-08 16:35 ` Simon Horman
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=20250705082403.0ba474f4@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=chenhao418@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.