Skip to contentSkip to conversation

i40e: Check client is open before calling client ops

PATCH New Bimmy Pujari 2 participants 4 messages Aug 15, 2016 – Aug 19, 2016

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

PATCH 1/2 i40e: Check client is open before calling client ops

From: Catherine Sullivan <[email protected]>

We were having a race between the completion of the client open and calls to the client ops so don't call a client op unless we are sure the client is open.

Testing Hints: Load IWARP driver and make sure it works as expected.

Change-Id I741f4f2aa4fcbfdad3e40dabbbb1b005856c396b
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_client.c +25 -0
index 677dae5..1035f88 100644
@@ -148,6 +148,11 @@ i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)
 					"Cannot locate client instance virtual channel receive routine\n");
 				continue;
 			}
+			if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+				      &cdev->state)) {
+				dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort virtchnl_receive\n");
+				continue;
+			}
 			cdev->client->ops->virtchnl_receive(&cdev->lan_info,
 							    cdev->client,
 							    vf_id, msg, len);
@@ -181,6 +186,11 @@ void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
 					"Cannot locate client instance l2_param_change routine\n");
 				continue;
 			}
+			if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+				      &cdev->state)) {
+				dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n");
+				continue;
+			}
 			cdev->lan_info.params = params;
 			cdev->client->ops->l2_param_change(&cdev->lan_info,
 							   cdev->client,
@@ -298,6 +308,11 @@ void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id)
 					"Cannot locate client instance VF reset routine\n");
 				continue;
 			}
+			if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+				      &cdev->state)) {
+				dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-reset\n");
+				continue;
+			}
 			cdev->client->ops->vf_reset(&cdev->lan_info,
 						    cdev->client, vf_id);
 		}
@@ -328,6 +343,11 @@ void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs)
 					"Cannot locate client instance VF enable routine\n");
 				continue;
 			}
+			if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+				      &cdev->state)) {
+				dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-enable\n");
+				continue;
+			}
 			cdev->client->ops->vf_enable(&cdev->lan_info,
 						     cdev->client, num_vfs);
 		}
@@ -362,6 +382,11 @@ int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id,
 					"Cannot locate client instance VF capability routine\n");
 				continue;
 			}
+			if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
+				      &cdev->state)) {
+				dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-capable\n");
+				continue;
+			}
 			capable = cdev->client->ops->vf_capable(&cdev->lan_info,
 								cdev->client,
 								vf_id);
Signature · 1 line
2.4.11
#1 lore raw

PATCH 2/2 i40e: Initialize pointer in client_release function

From: Harshitha Ramamurthy <[email protected]>

The function i40e_client_release has a print statement that uses an adapter pointer which is not initialized if a previous if statement is not true. Hence, intialize it in the right place.

Testing Hints: Compile check

Change-ID I1afdaa2c46771ac42be56edcc41bb56b455b06c8
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_client.c +2 -2
index 1035f88..09a37cf 100644
@@ -662,7 +662,7 @@ int i40e_lan_del_device(struct i40e_pf *pf)
 static int i40e_client_release(struct i40e_client *client)
 {
 	struct i40e_client_instance *cdev, *tmp;
-	struct i40e_pf *pf = NULL;
+	struct i40e_pf *pf;
 	int ret = 0;
 
 	LIST_HEAD(cdevs_tmp);
@@ -672,12 +672,12 @@ static int i40e_client_release(struct i40e_client *client)
 		if (strncmp(cdev->client->name, client->name,
 			    I40E_CLIENT_STR_LENGTH))
 			continue;
+		pf = (struct i40e_pf *)cdev->lan_info.pf;
 		if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
 			if (atomic_read(&cdev->ref_cnt) > 0) {
 				ret = I40E_ERR_NOT_READY;
 				goto out;
 			}
-			pf = (struct i40e_pf *)cdev->lan_info.pf;
 			if (client->ops && client->ops->close)
 				client->ops->close(&cdev->lan_info, client,
 						   false);
Signature · 1 line
2.4.11
#2 lore raw

PATCH 2/2 i40e: Initialize pointer in client_release function

Quoted 14 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Monday, August 15, 2016 2:17 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S42-V2 2/2] i40e: Initialize pointer in client_release function

From: Harshitha Ramamurthy <[email protected]>

The function i40e_client_release has a print statement that uses an adapter pointer which is not initialized if a previous if statement is not true. Hence, intialize it in the right place.

Quoted 7 lines

Testing Hints: Compile check

Change-ID I1afdaa2c46771ac42be56edcc41bb56b455b06c8
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Base driver functions normally, code changes applied properly

#3 lore raw

PATCH 1/2 i40e: Check client is open before calling client ops

In reply to Bimmy Pujari
Quoted 14 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Monday, August 15, 2016 2:17 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Catherine Sullivan <[email protected]>
Subject: [Intel-wired-lan] [next PATCH S42-V2 1/2] i40e: Check client is open before calling client ops

From: Catherine Sullivan <[email protected]>

We were having a race between the completion of the client open and calls to the client ops so don't call a client op unless we are sure the client is open.

Quoted 8 lines

Testing Hints: Load IWARP driver and make sure it works as expected.

Change-Id I741f4f2aa4fcbfdad3e40dabbbb1b005856c396b
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 25
+++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Base driver functions normally, code changes applied properly