netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Jijie Shao <shaojijie@huawei.com>
Cc: yisen.zhuang@huawei.com, salil.mehta@huawei.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, jiri@resnulli.us, shenjian15@huawei.com,
	wangjie125@huawei.com, liuyonglong@huawei.com,
	chenhao418@huawei.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 net 4/7] net: hns3: use appropriate barrier function after setting a bit value
Date: Fri, 26 Apr 2024 15:25:53 +0100	[thread overview]
Message-ID: <20240426142553.GB513047@kernel.org> (raw)
In-Reply-To: <20240426100045.1631295-5-shaojijie@huawei.com>

On Fri, Apr 26, 2024 at 06:00:42PM +0800, Jijie Shao wrote:
> From: Peiyang Wang <wangpeiyang1@huawei.com>
> 
> There is a memory barrier in followed case. When set the port down,
> hclgevf_set_timmer will set DOWN in state. Meanwhile, the service task has
> different behaviour based on whether the state is DOWN. Thus, to make sure
> service task see DOWN, use smp_mb__after_atomic after calling set_bit().
> 
>           CPU0                        CPU1
> ========================== ===================================
> hclgevf_set_timer_task()    hclgevf_periodic_service_task()
>   set_bit(DOWN,state)         test_bit(DOWN,state)
> 
> pf also has this issue.
> 
> Fixes: ff200099d271 ("net: hns3: remove unnecessary work in hclgevf_main")
> Fixes: 1c6dfe6fc6f7 ("net: hns3: remove mailbox and reset work in hclge_main")

FWIIW, I think it is fine to fix both problems in one patch
because both the cited patches were included in the same release - v5.6.
(Actually, they seem to be consecutive patches in git history.)

> Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 3 +--
>  drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index a068cd745eb4..6eda73f1e6ad 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -7954,8 +7954,7 @@ static void hclge_set_timer_task(struct hnae3_handle *handle, bool enable)
>  		/* Set the DOWN flag here to disable link updating */
>  		set_bit(HCLGE_STATE_DOWN, &hdev->state);
>  
> -		/* flush memory to make sure DOWN is seen by service task */
> -		smp_mb__before_atomic();
> +		smp_mb__after_atomic(); /* flush memory to make sure DOWN is seen by service task */

If you need to post a v2 for some other reason, please consider reworking
this comment so lines are no longer than 80 columns wide. The previous form
where the comment was on it's own line looks good to me.

Likewise below.

In any case, this patch looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

>  		hclge_flush_link_update(hdev);
>  	}
>  }
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> index b57111252d07..08db8e84be4e 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> @@ -2181,8 +2181,7 @@ static void hclgevf_set_timer_task(struct hnae3_handle *handle, bool enable)
>  	} else {
>  		set_bit(HCLGEVF_STATE_DOWN, &hdev->state);
>  
> -		/* flush memory to make sure DOWN is seen by service task */
> -		smp_mb__before_atomic();
> +		smp_mb__after_atomic(); /* flush memory to make sure DOWN is seen by service task */
>  		hclgevf_flush_link_update(hdev);
>  	}
>  }
> -- 
> 2.30.0
> 
> 

  reply	other threads:[~2024-04-26 14:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 10:00 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2024-04-26 10:00 ` [PATCH V2 net 1/7] net: hns3: direct return when receive a unknown mailbox message Jijie Shao
2024-04-26 14:26   ` Simon Horman
2024-04-26 10:00 ` [PATCH V2 net 2/7] net: hns3: change type of numa_node_mask as nodemask_t Jijie Shao
2024-04-26 14:26   ` Simon Horman
2024-04-26 10:00 ` [PATCH V2 net 3/7] net: hns3: release PTP resources if pf initialization failed Jijie Shao
2024-04-26 11:21   ` Hariprasad Kelam
2024-04-26 10:00 ` [PATCH V2 net 4/7] net: hns3: use appropriate barrier function after setting a bit value Jijie Shao
2024-04-26 14:25   ` Simon Horman [this message]
2024-04-26 10:00 ` [PATCH V2 net 5/7] net: hns3: using user configure after hardware reset Jijie Shao
2024-04-26 14:25   ` Simon Horman
2024-04-28 14:14     ` Jijie Shao
2024-04-26 10:00 ` [PATCH V2 net 6/7] net: hns3: fix port vlan filter not disabled issue Jijie Shao
2024-04-26 18:15   ` Simon Horman
2024-04-26 10:00 ` [PATCH V2 net 7/7] net: hns3: fix kernel crash when devlink reload during initialization Jijie Shao

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=20240426142553.GB513047@kernel.org \
    --to=horms@kernel.org \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --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=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=wangjie125@huawei.com \
    --cc=yisen.zhuang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).