Merge remote-tracking branch 'iommu/next'
[deliverable/linux.git] / drivers / net / ethernet / intel / i40e / i40e_client.c
index 618f18436618945b807c5e08f499dc1a4cd689cf..250db0b244b7677107ca1c56df23c23789e80fee 100644 (file)
@@ -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,
@@ -306,6 +316,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);
                }
@@ -336,6 +351,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);
                }
@@ -370,6 +390,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);
@@ -559,6 +584,7 @@ void i40e_client_subtask(struct i40e_pf *pf)
                                 pf->hw.bus.device, pf->hw.bus.func);
                }
 
+               mutex_lock(&i40e_client_instance_mutex);
                /* Send an Open request to the client */
                atomic_inc(&cdev->ref_cnt);
                if (client->ops && client->ops->open)
@@ -568,10 +594,12 @@ void i40e_client_subtask(struct i40e_pf *pf)
                        set_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
                } else {
                        /* remove client instance */
+                       mutex_unlock(&i40e_client_instance_mutex);
                        i40e_client_del_instance(pf, client);
                        atomic_dec(&client->ref_cnt);
                        continue;
                }
+               mutex_unlock(&i40e_client_instance_mutex);
        }
        mutex_unlock(&i40e_client_mutex);
 }
@@ -654,7 +682,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);
@@ -664,12 +692,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);
@@ -681,8 +709,7 @@ static int i40e_client_release(struct i40e_client *client)
                                 client->name, pf->hw.pf_id);
                }
                /* delete the client instance from the list */
-               list_del(&cdev->list);
-               list_add(&cdev->list, &cdevs_tmp);
+               list_move(&cdev->list, &cdevs_tmp);
                atomic_dec(&client->ref_cnt);
                dev_info(&pf->pdev->dev, "Deleted client instance of Client %s\n",
                         client->name);
@@ -811,7 +838,8 @@ static int i40e_client_setup_qvlist(struct i40e_info *ldev,
                        wr32(hw, I40E_PFINT_AEQCTL, reg);
                }
        }
-
+       /* Mitigate sync problems with iwarp VF driver */
+       i40e_flush(hw);
        return 0;
 err:
        kfree(ldev->qvlist_info);
@@ -1009,7 +1037,6 @@ int i40e_unregister_client(struct i40e_client *client)
        if (!i40e_client_is_registered(client)) {
                pr_info("i40e: Client %s has not been registered\n",
                        client->name);
-               mutex_unlock(&i40e_client_mutex);
                ret = -ENODEV;
                goto out;
        }
This page took 0.047939 seconds and 5 git commands to generate.