Skip to contentSkip to conversation

mlxbf_gige: disable port during stop()

PATCH In review David Thompson 3 participants 5 messages Aug 16, 2024 – Aug 28, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxbf_gige: disable port during stop()

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")
---
 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +6 -0
index 385a56ac7348..12942a50e1bb 100644
@@ -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);
Signature · 1 line
2.30.1
#1 lore raw
Quoted 18 lines · David Thompson

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")
---
 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +0 -0
index 385a56ac7348..12942a50e1bb 100644
@@ -205,8 +205,14 @@ static int mlxbf_gige_open(struct net_device *netdev)
 static int mlxbf_gige_stop(struct net_device *netdev)

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c static int mlxbf_gige_open(struct net_device *netdev) · line 215

Quoted 10 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +6 -0
 {
 	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?

maintainer
#2 lore raw
Quoted 1 line · 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.

Signature · 1 line
pw-bot: cr
#3 lore raw
Quoted 11 lines

-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Monday, August 19, 2024 8:47 PM
To: David Thompson <[email protected]>
Cc: Benjamin Poirier <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Asmaa Mnebhi <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH net v1] mlxbf_gige: disable port during stop()

Quoted 8 lines
Quoted 1 line · 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

maintainer
#4 lore raw
Quoted 3 lines · 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..

Quoted 4 lines

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.