diff mbox

[v2,03/14] qla2xxx: Allow vref count to timeout on vport delete.

Message ID 1486161655-2307-4-git-send-email-himanshu.madhani@cavium.com (mailing list archive)
State Deferred
Headers show

Commit Message

Madhani, Himanshu Feb. 3, 2017, 10:40 p.m. UTC
From: Joe Carnuccio <joe.carnuccio@cavium.com>

Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
---
 drivers/scsi/qla2xxx/qla_attr.c |  4 +---
 drivers/scsi/qla2xxx/qla_mid.c  | 12 +++++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Christoph Hellwig Feb. 8, 2017, 1:03 p.m. UTC | #1
On Fri, Feb 03, 2017 at 02:40:44PM -0800, Himanshu Madhani wrote:
> -	spin_lock_irqsave(&ha->vport_slock, flags);
> -	while (atomic_read(&vha->vref_count)) {
> -		spin_unlock_irqrestore(&ha->vport_slock, flags);
> -
> +	while (count-- && atomic_read(&vha->vref_count))
>  		msleep(500);

Please add a wait queue to skeep on while waiting for vref_count to
drop to zero.  
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Madhani, Himanshu Feb. 8, 2017, 6:25 p.m. UTC | #2
On 2/8/17, 5:03 AM, "Christoph Hellwig" <hch@infradead.org> wrote:

>On Fri, Feb 03, 2017 at 02:40:44PM -0800, Himanshu Madhani wrote:

>> -	spin_lock_irqsave(&ha->vport_slock, flags);

>> -	while (atomic_read(&vha->vref_count)) {

>> -		spin_unlock_irqrestore(&ha->vport_slock, flags);

>> -

>> +	while (count-- && atomic_read(&vha->vref_count))

>>  		msleep(500);

>

>Please add a wait queue to skeep on while waiting for vref_count to

>drop to zero.  


Thanks for the review. Will update patch and resend series.
diff mbox

Patch

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index f610103..435ff7f 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -2154,8 +2154,6 @@  struct device_attribute *qla2x00_host_attrs[] = {
 		    "Timer for the VP[%d] has stopped\n", vha->vp_idx);
 	}
 
-	BUG_ON(atomic_read(&vha->vref_count));
-
 	qla2x00_free_fcports(vha);
 
 	mutex_lock(&ha->vport_lock);
@@ -2166,7 +2164,7 @@  struct device_attribute *qla2x00_host_attrs[] = {
 	dma_free_coherent(&ha->pdev->dev, vha->gnl.size, vha->gnl.l,
 	    vha->gnl.ldma);
 
-	if (vha->qpair->vp_idx == vha->vp_idx) {
+	if (vha->qpair && vha->qpair->vp_idx == vha->vp_idx) {
 		if (qla2xxx_delete_qpair(vha, vha->qpair) != QLA_SUCCESS)
 			ql_log(ql_log_warn, vha, 0x7087,
 			    "Queue Pair delete failed.\n");
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index c6d6f0d..bf8e1e2 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -65,6 +65,7 @@ 
 	uint16_t vp_id;
 	struct qla_hw_data *ha = vha->hw;
 	unsigned long flags = 0;
+	unsigned int count = 10;
 
 	mutex_lock(&ha->vport_lock);
 	/*
@@ -74,13 +75,14 @@ 
 	 * ensures no active vp_list traversal while the vport is removed
 	 * from the queue)
 	 */
-	spin_lock_irqsave(&ha->vport_slock, flags);
-	while (atomic_read(&vha->vref_count)) {
-		spin_unlock_irqrestore(&ha->vport_slock, flags);
-
+	while (count-- && atomic_read(&vha->vref_count))
 		msleep(500);
 
-		spin_lock_irqsave(&ha->vport_slock, flags);
+	spin_lock_irqsave(&ha->vport_slock, flags);
+	if (atomic_read(&vha->vref_count)) {
+		ql_dbg(ql_dbg_vport, vha, 0xfffa,
+		    "vha->vref_count=%u timeout\n", vha->vref_count.counter);
+		vha->vref_count = (atomic_t)ATOMIC_INIT(0);
 	}
 	list_del(&vha->list);
 	qlt_update_vp_map(vha, RESET_VP_IDX);