Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp705679pxb; Thu, 25 Feb 2021 12:57:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTPnr8YdHR1qneSXxEnuPuTvNIN06LZjNXhcqYRJSCmBh0RqJgOm/tF/unu8rDVafP/EKs X-Received: by 2002:a05:6402:4d5:: with SMTP id n21mr4911690edw.201.1614286671355; Thu, 25 Feb 2021 12:57:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614286671; cv=none; d=google.com; s=arc-20160816; b=0vjz6O3QhvWU4MdE2A8abGvouRLT/rzYcOP8rD14V/PQVBHmr8V9F3iPA5hwzS6ti7 H61egIXcziuLICvCnzirxxU9Vu+LDZ42OnbzJ9VM7eaJh49gv9A3w6tY3r/tb/tycBGS lUtkVIOLcfVL13XaelBg4bh47lE7ExzMObrdJybQ0HqLI38WnBxMCOB88QwzKkLcktV8 Q5EzOfq5p7mTEQ2QA9RmEa4y8qTOsGqHGQY+fgdBFU7TwGyfii9QwNVCvG3PAP9XabJk 3pGtJthYMXMRPvaIfnKhgEsXrp9w/e0CNDaADG/+X5GZxTASdloK/Xu9hG7ES3OlQkHM QQ/Q== 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=3UJhECTJ8Lq8CSwy7ZDDyqgl8A+F7dNbRsh0MA5G864=; b=L/89MYodwyh0YK08MnW9XUUNHwThzl+4K6HqjutmxnjgfA6+zTZPkmNNn+PWO8eQJd A8J/Ul8gQvqnt84NzGclzuakmPJhPjhRZ2AxexpXK03Wgh87oI9Fe0HGe6xzJxKEta6l 1qkKMcphyzlnSax/Y//6ykN3yAuBvD4sK5YqmOzNfOq9Pj1N3c+zkJK+IHx6mz+y8/rn txLp+HfQpqYw29CsRc4OOWBXbd7xLfkWJh+S72ATawBLZvrMFbGXnF23VTcI4eel5KG1 xVfJ07zdPutlqy+DdiH88ttGMIpXebf+pi2nNLPWJSKzQqfexoe5aEEaPmLdur5IK4sJ uMvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=foK5ii+U; 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 oy5si4174025ejb.312.2021.02.25.12.57.28; Thu, 25 Feb 2021 12:57:51 -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=foK5ii+U; 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 S235031AbhBYUzN (ORCPT + 99 others); Thu, 25 Feb 2021 15:55:13 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41472 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233659AbhBYUtq (ORCPT ); Thu, 25 Feb 2021 15:49:46 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11PKYFjh035701; Thu, 25 Feb 2021 15:48:30 -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=3UJhECTJ8Lq8CSwy7ZDDyqgl8A+F7dNbRsh0MA5G864=; b=foK5ii+UoGT3FGd0ade+IAAaMxXHWL10cF7nuwGfHqKBG1jm9m11Bsl9Spoq7PaNhb+G ep1wTAJFLHUrkaqyF4FRPGGfPWin1MQgMYLCXkdSwJIhcaW6gkpKVYAERBfG+Q82vfo1 VJxPtaPbur/Te6I/EbPnGEfANuQbmg5F10EBLC9z0RM3Z2VVh/67hID5FvSeq5ZBuTge eMmx7gEvIkSq/pM6yL3tPSN21Gar/f7MDP/Qg6Aiy1+izKiM8WD/n/FIWDDGMkbEeVXM B4nHxc5CD0zO2vZZtT9vpSlTB2URlenoLEMHevdeZQVoD6o1UiB1yVUcYAkBpZ8SCBxD sQ== Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 36xe10bav1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Feb 2021 15:48:30 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11PKluga003411; Thu, 25 Feb 2021 20:48:29 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma03dal.us.ibm.com with ESMTP id 36v5y9mcct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Feb 2021 20:48:29 +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 11PKmRvI28311874 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Feb 2021 20:48:27 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 945B96E05D; Thu, 25 Feb 2021 20:48:27 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 478296E04E; Thu, 25 Feb 2021 20:48:27 +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 20:48:27 +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 v2 2/5] ibmvfc: fix invalid sub-CRQ handles after hard reset Date: Thu, 25 Feb 2021 14:48:21 -0600 Message-Id: <20210225204824.14570-3-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210225204824.14570-1-tyreld@linux.ibm.com> References: <20210225204824.14570-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_11:2021-02-24,2021-02-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102250158 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 Reviewed-by: Brian King --- 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..3dd20f383453 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,6 +959,9 @@ 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); + + ibmvfc_init_sub_crqs(vhost); + spin_unlock(vhost->crq.q_lock); spin_unlock_irqrestore(vhost->host->host_lock, flags); @@ -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