APPLIED[D/E]: [PATCH 2/4][D/E] net: hns3: revert to old channel when setting new channel num fail
Kleber Souza
kleber.souza at canonical.com
Tue Jan 7 11:34:03 UTC 2020
On 2020-01-01 17:09, Ike Panhc wrote:
> From: Peng Li <lipeng321 at huawei.com>
>
> BugLink: https://launchpad.net/bugs/1853983
>
> After setting new channel num, it needs free old ring memory and
> allocate new ring memory. If there is no enough memory and allocate
> new ring memory fail, the ring may initialize fail. To make sure
> the network interface can work normally, driver should revert the
> channel to the old configuration.
>
> Signed-off-by: Peng Li <lipeng321 at huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong at huawei.com>
> Signed-off-by: David S. Miller <davem at davemloft.net>
> (cherry picked from commit 3a5a5f06d4d2ddb257cb71e9c52106f50abad8fc)
> Signed-off-by: Ike Panhc <ike.pan at canonical.com>
> ---
> .../net/ethernet/hisilicon/hns3/hns3_enet.c | 51 ++++++++++++++-----
> 1 file changed, 37 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 551c5a9709ee..0dbb78b727ee 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -4377,6 +4377,30 @@ static int hns3_reset_notify(struct hnae3_handle *handle,
> return ret;
> }
>
> +static int hns3_change_channels(struct hnae3_handle *handle, u32 new_tqp_num,
> + bool rxfh_configured)
> +{
> + int ret;
> +
> + ret = handle->ae_algo->ops->set_channels(handle, new_tqp_num,
> + rxfh_configured);
> + if (ret) {
> + dev_err(&handle->pdev->dev,
> + "Change tqp num(%u) fail.\n", new_tqp_num);
> + return ret;
> + }
> +
> + ret = hns3_reset_notify(handle, HNAE3_INIT_CLIENT);
> + if (ret)
> + return ret;
> +
> + ret = hns3_reset_notify(handle, HNAE3_UP_CLIENT);
> + if (ret)
> + hns3_reset_notify(handle, HNAE3_UNINIT_CLIENT);
> +
> + return ret;
> +}
> +
> int hns3_set_channels(struct net_device *netdev,
> struct ethtool_channels *ch)
> {
> @@ -4410,24 +4434,23 @@ int hns3_set_channels(struct net_device *netdev,
> return ret;
>
> org_tqp_num = h->kinfo.num_tqps;
> - ret = h->ae_algo->ops->set_channels(h, new_tqp_num, rxfh_configured);
> + ret = hns3_change_channels(h, new_tqp_num, rxfh_configured);
> if (ret) {
> - ret = h->ae_algo->ops->set_channels(h, org_tqp_num,
> - rxfh_configured);
> - if (ret) {
> - /* If revert to old tqp failed, fatal error occurred */
> - dev_err(&netdev->dev,
> - "Revert to old tqp num fail, ret=%d", ret);
> - return ret;
> + int ret1;
> +
> + netdev_warn(netdev,
> + "Change channels fail, revert to old value\n");
> + ret1 = hns3_change_channels(h, org_tqp_num, rxfh_configured);
> + if (ret1) {
> + netdev_err(netdev,
> + "revert to old channel fail\n");
> + return ret1;
> }
> - dev_info(&netdev->dev,
> - "Change tqp num fail, Revert to old tqp num");
> - }
> - ret = hns3_reset_notify(h, HNAE3_INIT_CLIENT);
> - if (ret)
> +
> return ret;
> + }
>
> - return hns3_reset_notify(h, HNAE3_UP_CLIENT);
> + return 0;
> }
>
> static const struct hnae3_client_ops client_ops = {
>
Applied to disco/linux and eoan/linux.
Thanks,
Kleber
More information about the kernel-team
mailing list