diff mbox series

[net,v1] mlxbf_gige: disable port during stop()

Message ID 20240816204808.30359-1-davthompson@nvidia.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net,v1] mlxbf_gige: disable port during stop() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 7 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch warning WARNING: memory barrier without comment
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-17--00-00 (tests: 710)

Commit Message

David Thompson Aug. 16, 2024, 8:48 p.m. UTC
The mlxbf_gige_open() routine initializes and enables the
Gigabit Ethernet port from a hardware point of view. The
mlxbf_gige_stop() routine must disable the port hardware
to fully quiesce it.

Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver")
Reviewed-by: Asmaa Mnebhi <asmaa@nvidia.com>
Signed-off-by: David Thompson <davthompson@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Benjamin Poirier Aug. 19, 2024, 6:55 p.m. UTC | #1
On 2024-08-16 16:48 -0400, David Thompson wrote:
> The mlxbf_gige_open() routine initializes and enables the
> Gigabit Ethernet port from a hardware point of view. The
> mlxbf_gige_stop() routine must disable the port hardware
> to fully quiesce it.
> 
> Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver")
> Reviewed-by: Asmaa Mnebhi <asmaa@nvidia.com>
> Signed-off-by: David Thompson <davthompson@nvidia.com>
> ---
>  drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
> index 385a56ac7348..12942a50e1bb 100644
> --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
> +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
> @@ -205,8 +205,14 @@ static int mlxbf_gige_open(struct net_device *netdev)
>  static int mlxbf_gige_stop(struct net_device *netdev)
>  {
>  	struct mlxbf_gige *priv = netdev_priv(netdev);
> +	u64 control;
> +
> +	control = readq(priv->base + MLXBF_GIGE_CONTROL);
> +	control &= ~MLXBF_GIGE_CONTROL_PORT_EN;
> +	writeq(control, priv->base + MLXBF_GIGE_CONTROL);
>  
>  	writeq(0, priv->base + MLXBF_GIGE_INT_EN);
> +	mb();

checkpatch says:
WARNING: memory barrier without comment
#37: FILE: drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c:215:
+       mb();

Is this memory barrier paired with another one?
Jakub Kicinski Aug. 20, 2024, 12:47 a.m. UTC | #2
On Mon, 19 Aug 2024 14:55:12 -0400 Benjamin Poirier wrote:
> Is this memory barrier paired with another one?

+1 
You probably want synchronize_irq() here?
You should explain in the cover letter, the mb() seems to not be
mentioned.
David Thompson Aug. 28, 2024, 9:37 p.m. UTC | #3
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Monday, August 19, 2024 8:47 PM
> To: David Thompson <davthompson@nvidia.com>
> Cc: Benjamin Poirier <benjamin.poirier@gmail.com>; davem@davemloft.net;
> edumazet@google.com; pabeni@redhat.com;
> andriy.shevchenko@linux.intel.com; u.kleine-koenig@pengutronix.de; Asmaa
> Mnebhi <asmaa@nvidia.com>; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH net v1] mlxbf_gige: disable port during stop()
> 
> On Mon, 19 Aug 2024 14:55:12 -0400 Benjamin Poirier wrote:
> > Is this memory barrier paired with another one?
> 
> +1
> You probably want synchronize_irq() here?
> You should explain in the cover letter, the mb() seems to not be mentioned.
> --
> pw-bot: cr

Hello Jakub and Benjamin, thanks for your input.

I will post a v2 adding information about the "mb()" call.

Regarding the "synchronize_irq()" call, I did some research and noticed that
some already merged driver patches (see list below for a sample) state that 
"synchronize_irq()" is unnecessary before "free_irq()":

3e0fcb782a9f i40e: Remove unnecessary synchronize_irq() before free_irq()
845517ed04ae RDMA/qedr: Remove unnecessary synchronize_irq() before free_irq()
d1e7f009bfff net: qede: Remove unnecessary synchronize_irq() before free_irq()
bd81bfb5a1d1 net: vxge: Remove unnecessary synchronize_irq() before free_irq()
29fd3ca1779f qed: Remove unnecessary synchronize_irq() before free_irq()
411dccf9d271 dmaengine: idxd: Remove unnecessary synchronize_irq() before free_irq()
d887ae3247e0 octeontx2-pf: Remove unnecessary synchronize_irq() before free_irq()

Given the above information, does my mlxbf_gige driver patch still need to
invoke "synchronize_irq()" in the stop() method?  The "mlxbf_gige_free_irq()"
call within the stop() method invokes "free_irq()" for each of the driver's IRQs, so
sounds like this "synchronize_irq()" is implicitly being invoked?

Regards, Dave
Jakub Kicinski Aug. 28, 2024, 10:55 p.m. UTC | #4
On Wed, 28 Aug 2024 21:37:06 +0000 David Thompson wrote:
> Hello Jakub and Benjamin, thanks for your input.
> 
> I will post a v2 adding information about the "mb()" call.

Perhaps this information you're adding will shed more light..

> Given the above information, does my mlxbf_gige driver patch still need to
> invoke "synchronize_irq()" in the stop() method?  The "mlxbf_gige_free_irq()"
> call within the stop() method invokes "free_irq()" for each of the driver's IRQs, so
> sounds like this "synchronize_irq()" is implicitly being invoked?

I was talking about the point in which you add the mb().
IDK what you're trying to protect from but it's after what looks like
disabling IRQ, and there's not free_irq() in that spot.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
index 385a56ac7348..12942a50e1bb 100644
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
@@ -205,8 +205,14 @@  static int mlxbf_gige_open(struct net_device *netdev)
 static int mlxbf_gige_stop(struct net_device *netdev)
 {
 	struct mlxbf_gige *priv = netdev_priv(netdev);
+	u64 control;
+
+	control = readq(priv->base + MLXBF_GIGE_CONTROL);
+	control &= ~MLXBF_GIGE_CONTROL_PORT_EN;
+	writeq(control, priv->base + MLXBF_GIGE_CONTROL);
 
 	writeq(0, priv->base + MLXBF_GIGE_INT_EN);
+	mb();
 	netif_stop_queue(netdev);
 	napi_disable(&priv->napi);
 	netif_napi_del(&priv->napi);