diff mbox series

[v4,11/19] lpfc: vmid: cleanup vmid resources

Message ID 1604895845-2587-12-git-send-email-muneendra.kumar@broadcom.com
State New
Headers show
Series [v4,01/19] cgroup: Added cgroup_get_from_kernfs_id | expand

Commit Message

Muneendra Kumar Nov. 9, 2020, 4:23 a.m. UTC
From: Gaurav Srivastava <gaurav.srivastava@broadcom.com>

The patch cleans up the vmid resources and stops the timer.

Signed-off-by: Gaurav Srivastava  <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>

---
v4:
No change

v3:
No change

v2:
Ported the patch on top of 5.10/scsi-queue
---
 drivers/scsi/lpfc/lpfc_init.c |  4 ++++
 drivers/scsi/lpfc/lpfc_scsi.c | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Hannes Reinecke Nov. 16, 2020, 7:56 a.m. UTC | #1
On 11/9/20 5:23 AM, Muneendra wrote:
> From: Gaurav Srivastava <gaurav.srivastava@broadcom.com>

> 

> The patch cleans up the vmid resources and stops the timer.

> 

> Signed-off-by: Gaurav Srivastava  <gaurav.srivastava@broadcom.com>

> Signed-off-by: James Smart <jsmart2021@gmail.com>

> 

> ---

> v4:

> No change

> 

> v3:

> No change

> 

> v2:

> Ported the patch on top of 5.10/scsi-queue

> ---

>   drivers/scsi/lpfc/lpfc_init.c |  4 ++++

>   drivers/scsi/lpfc/lpfc_scsi.c | 21 +++++++++++++++++++++

>   2 files changed, 25 insertions(+)

> 

> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c

> index e32d69515586..88777875f4b8 100644

> --- a/drivers/scsi/lpfc/lpfc_init.c

> +++ b/drivers/scsi/lpfc/lpfc_init.c

> @@ -2843,6 +2843,10 @@ lpfc_cleanup(struct lpfc_vport *vport)

>   	if (phba->link_state > LPFC_LINK_DOWN)

>   		lpfc_port_link_failure(vport);

>   

> +	/* cleanup vmid resources */

> +	if (lpfc_is_vmid_enabled(phba))

> +		lpfc_vmid_vport_cleanup(vport);

> +

>   	list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {

>   		if (!NLP_CHK_NODE_ACT(ndlp)) {

>   			ndlp = lpfc_enable_node(vport, ndlp,

> diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c

> index 5e802c8b22a9..7bc1fd69b715 100644

> --- a/drivers/scsi/lpfc/lpfc_scsi.c

> +++ b/drivers/scsi/lpfc/lpfc_scsi.c

> @@ -4711,6 +4711,27 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)

>   	return 0;

>   }

>   

> +/*

> + * lpfc_vmid_vport_cleanup - cleans up the resources associated with a vports

> + * @vport: The virtual port for which this call is being executed.

> + */

> +void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport)

> +{

> +	/* delete the timer */

> +	if (vport->port_type == LPFC_PHYSICAL_PORT)

> +		del_timer_sync(&vport->phba->inactive_vmid_poll);

> +

> +	/* free the resources */

> +	kfree(vport->qfpa_res);

> +	kfree(vport->vmid_priority.vmid_range);

> +	kfree(vport->vmid);

> +

> +	/* reset variables */

> +	vport->qfpa_res = NULL;

> +	vport->vmid_priority.vmid_range = NULL;

> +	vport->vmid = NULL;

> +	vport->cur_vmid_cnt = 0;

> +}

>   

>   /**

>    * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point

> 

Please merge with the previous patch.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
diff mbox series

Patch

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index e32d69515586..88777875f4b8 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -2843,6 +2843,10 @@  lpfc_cleanup(struct lpfc_vport *vport)
 	if (phba->link_state > LPFC_LINK_DOWN)
 		lpfc_port_link_failure(vport);
 
+	/* cleanup vmid resources */
+	if (lpfc_is_vmid_enabled(phba))
+		lpfc_vmid_vport_cleanup(vport);
+
 	list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
 		if (!NLP_CHK_NODE_ACT(ndlp)) {
 			ndlp = lpfc_enable_node(vport, ndlp,
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 5e802c8b22a9..7bc1fd69b715 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -4711,6 +4711,27 @@  lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
 	return 0;
 }
 
+/*
+ * lpfc_vmid_vport_cleanup - cleans up the resources associated with a vports
+ * @vport: The virtual port for which this call is being executed.
+ */
+void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport)
+{
+	/* delete the timer */
+	if (vport->port_type == LPFC_PHYSICAL_PORT)
+		del_timer_sync(&vport->phba->inactive_vmid_poll);
+
+	/* free the resources */
+	kfree(vport->qfpa_res);
+	kfree(vport->vmid_priority.vmid_range);
+	kfree(vport->vmid);
+
+	/* reset variables */
+	vport->qfpa_res = NULL;
+	vport->vmid_priority.vmid_range = NULL;
+	vport->vmid = NULL;
+	vport->cur_vmid_cnt = 0;
+}
 
 /**
  * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point