Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp737762pxb; Thu, 25 Feb 2021 13:54:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNVeYpWC0b/FnJ78lNNUMB5cEukW/Fc+tJHlB2fc5h9ZYMNC+9pdITXJciyaONmvidxFCm X-Received: by 2002:a17:906:c08a:: with SMTP id f10mr4815001ejz.52.1614290078947; Thu, 25 Feb 2021 13:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614290078; cv=none; d=google.com; s=arc-20160816; b=jocWIcq2f8u+jpeuJYYpjlTZLakeIQNEzvRTNXTd16L1lJ4XXYdgmEgiNk5ve2GiuT ZTk/5iV5f0xBgkweMxbDHgHGNLH3MvU3+wo8k5hPUp3il0FY1Xe4fLqX4EWnhju9H5a5 avwv1c3aFQXtMXldFIgAf2EoIaDgiXrDZ/4rcg/J1XIXbnjzJiePd4+TNQ/6wbf+x+1/ KdgUK7pB5YB1F3O+zYUTDkN3oibgV7lbri74OOlebdr+zNMbfOXuZBZ1I5ix0SnKknfq 5RTyuRcqETUR+4Towtztn3GqjkoKIpxvU0u7glkVQB840rgAwYnKZUSKef6WbFNCYrMj vq+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vsu/9LvA8vu2SG4EBzcOmhCz/Tz5x97vI0SkMtBQdIw=; b=nM4eq/kFfr3mz6cmLKjjCUXO8z79/pZKh9fpY9Xi31CV6Nlm9PcojpMUG5FHg9EABV g7z/vX/7Gks7iruDaE2vf8B+G13wXuWz1amifJyjijVETPluqAjMAhnjD6g+MaxkPaQy tSd+yHoPiMWTXMiTWcblJWf8Zs0LiN+cB9oe+zFjFBSC6dndO0UYs9WVH7/8JReP285G /4PpcIrcqgReNKEr7rIw0GKF1ueFYc3aany+iN/yGVO0CONAcqrbY7RrEi8KEYeatT0e tV72lm8TsXA2waaQZKE1iLzKtK2BCYQfsJQlix+qGsOuoFuFt2KD0mV49cz59fAv/4M9 Hg4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Bq02OW1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp35si4846897ejc.477.2021.02.25.13.54.16; Thu, 25 Feb 2021 13:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Bq02OW1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232113AbhBYVwS (ORCPT + 99 others); Thu, 25 Feb 2021 16:52:18 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:16468 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232770AbhBYVvt (ORCPT ); Thu, 25 Feb 2021 16:51:49 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11PLWqZu090842; Thu, 25 Feb 2021 16:51:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=vsu/9LvA8vu2SG4EBzcOmhCz/Tz5x97vI0SkMtBQdIw=; b=Bq02OW1B3TyQAmpw0puWNgnXKPUOixMJj14lfsBarVNv1lYPvdtyRqgy5JC9RYLZ12y3 5wIdtdj0gZc6aStcmAXqmpa6GIwxCgBvmhptz4Zui+mkYJDpaJAqHULk0tVw5l78OQiA IedJcwe/S8DrBbpGTvg/P+U1gEALV3SktiW6N/KGJ2HJIA+pIudgZMIDIvLdYdrjNCqQ TGT6aOz8T4Rcwf4Ty17Lb9nNqWOVUcmenJSxx8dO9T/gs68I/f1ZB00gaPYH87a/k82p iuJeOFz5UTEpBLCGdSYk04BGoz2IKi/jYx5LCIuBQvges0OJuxQHj9NXsDVuPrpHlS2n vg== Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 36xf2v0pc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Feb 2021 16:51:02 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11PLmRHA000860; Thu, 25 Feb 2021 21:51:01 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04dal.us.ibm.com with ESMTP id 36tt2b494f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Feb 2021 21:51:01 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11PLoxEC24641834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Feb 2021 21:50:59 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76AF96E04C; Thu, 25 Feb 2021 21:50:59 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E3B76E052; Thu, 25 Feb 2021 21:50:59 +0000 (GMT) Received: from vios4361.aus.stglabs.ibm.com (unknown [9.3.43.61]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Feb 2021 21:50:59 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v4 2/5] ibmvfc: fix invalid sub-CRQ handles after hard reset Date: Thu, 25 Feb 2021 15:50:54 -0600 Message-Id: <20210225215057.23020-3-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210225215057.23020-1-tyreld@linux.ibm.com> References: <20210225215057.23020-1-tyreld@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-25_14:2021-02-24,2021-02-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102250163 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A hard reset results in a complete transport disconnect such that the CRQ connection with the partner VIOS is broken. This has the side effect of also invalidating the associated sub-CRQs. The current code assumes that the sub-CRQs are perserved resulting in a protocol violation after trying to reconnect them with the VIOS. This introduces an infinite loop such that the VIOS forces a disconnect after each subsequent attempt to re-register with invalid handles. Avoid the aforementioned issue by releasing the sub-CRQs prior to CRQ disconnect, and driving a reinitialization of the sub-CRQs once a new CRQ is registered with the hypervisor. fixes: faacf8c5f1d5 ("ibmvfc: add alloc/dealloc routines for SCSI Sub-CRQ Channels") Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 384960036f8b..d34e1a4f74d9 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -158,6 +158,9 @@ static void ibmvfc_npiv_logout(struct ibmvfc_host *); static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *); static void ibmvfc_tgt_move_login(struct ibmvfc_target *); +static void ibmvfc_release_sub_crqs(struct ibmvfc_host *); +static void ibmvfc_init_sub_crqs(struct ibmvfc_host *); + static const char *unknown_error = "unknown error"; static long h_reg_sub_crq(unsigned long unit_address, unsigned long ioba, @@ -926,8 +929,8 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost) unsigned long flags; struct vio_dev *vdev = to_vio_dev(vhost->dev); struct ibmvfc_queue *crq = &vhost->crq; - struct ibmvfc_queue *scrq; - int i; + + ibmvfc_release_sub_crqs(vhost); /* Close the CRQ */ do { @@ -947,16 +950,6 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost) memset(crq->msgs.crq, 0, PAGE_SIZE); crq->cur = 0; - if (vhost->scsi_scrqs.scrqs) { - for (i = 0; i < nr_scsi_hw_queues; i++) { - scrq = &vhost->scsi_scrqs.scrqs[i]; - spin_lock(scrq->q_lock); - memset(scrq->msgs.scrq, 0, PAGE_SIZE); - scrq->cur = 0; - spin_unlock(scrq->q_lock); - } - } - /* And re-open it again */ rc = plpar_hcall_norets(H_REG_CRQ, vdev->unit_address, crq->msg_token, PAGE_SIZE); @@ -966,9 +959,12 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost) dev_warn(vhost->dev, "Partner adapter not ready\n"); else if (rc != 0) dev_warn(vhost->dev, "Couldn't register crq (rc=%d)\n", rc); + spin_unlock(vhost->crq.q_lock); spin_unlock_irqrestore(vhost->host->host_lock, flags); + ibmvfc_init_sub_crqs(vhost); + return rc; } @@ -5692,6 +5688,7 @@ static void ibmvfc_deregister_scsi_channel(struct ibmvfc_host *vhost, int index) free_irq(scrq->irq, scrq); irq_dispose_mapping(scrq->irq); + scrq->irq = 0; do { rc = plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, -- 2.27.0