Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp159123pxu; Wed, 2 Dec 2020 18:12:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm7z1Dzif8UiAZbO3sD6uEdfKP7x6dnQj6nN9Ulb5qOTSbXQw1BQyeWRcOQ4bK9wSScHfg X-Received: by 2002:a17:906:6c94:: with SMTP id s20mr659488ejr.0.1606961546814; Wed, 02 Dec 2020 18:12:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606961546; cv=none; d=google.com; s=arc-20160816; b=t3iJ0W5jq/joH55mQjICtgeKqYIHRppWQIe74g948jZfgvGbhF0ldtV/yMxKgnRQQ+ arigrh5U50+3IJFAG+b2u7cBO6Apiv/5v6yQG9asXpDoYz4B2jy5+kHi5Oog60oxPvbS u+qoQSQEbkVw487vbzMvGD4HPAoD5Hma0LDjc9fFCJbsXZd+kYcDqtZAmL/Vi1pOLTmm dF86snNI9lsaQcg/eXankC87GJwV8CQ4IuCZRv/uZ17VpPabYEc3X6GZ2ypwXKGa4AeW luQXSjUM6rQEHlD8BseKsSMT4nw99c3iRD9LQ0VoMXxMM/uuzI2p1M4a3Vyh+OyIWG2b j0kA== 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=1RKZ2SdB/Y/n99fWxar2L0vt9zLjUEVpvzulfL68jLk=; b=KmEVl5T/wuVyh+NqFlW4PLKRIXIVrCpxo12Xqu9NJpUEoRxKUpasJiP4+lkxnON3aT 8nbWmp//E8XfQtavVmcg5RNwhzu8beJ4lLnad/QM6fHIBWviVhyJyEpPPR6ALIvwgPKg i5NO6lv06PXhGMNn71d5MkjqwS2meoDZTCq3eWtH6j0NSXk+kfk9t6yuRfk9xuHc7sin xwV4rpLsQYyxk4T0jxHY8EMdrs7S5Y5GzYB8QFB2voUkbTaPj4v4g1kLZDGgGvcqpm/L VPlZT8c71vnIo5qHd9ibXjyKV6O3fcs6vzYc9wQaCeCCmWGBfjrYn+YZnVP58R4iL0D3 951g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=X8eBvpAM; 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 hp31si288938ejc.313.2020.12.02.18.12.04; Wed, 02 Dec 2020 18:12:26 -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=X8eBvpAM; 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 S1729339AbgLCCJA (ORCPT + 99 others); Wed, 2 Dec 2020 21:09:00 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44658 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbgLCCJA (ORCPT ); Wed, 2 Dec 2020 21:09:00 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B322lUd096065; Wed, 2 Dec 2020 21:08:16 -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=1RKZ2SdB/Y/n99fWxar2L0vt9zLjUEVpvzulfL68jLk=; b=X8eBvpAMBlm7CO9WCuVmUDgROjQwUUUgsRmPPL1WdxmHBlwJ1VqBgrfAUayXDjA663KJ cC0MlfNlAW33VsnNG7+pk3M599PxUcoI/oVZzwqhEWAS2Fy02Y03y0GMH1N3DEV7HFAR G96lM0y5zyesH1Wn7w7WSc/1Eniq4MYdH7KSLTk1i1Tuo+JadX5Lf3ZY+kBIuhvIAhdP TsTkC9aIK97W7J2gSDFQeox2kkVSlmpaXrGb8WQ5jNKizluALqW1P+KpfuetW19cAOPe TtjBl9EiYdMqxHwQWwZCKnZ+gEyk1Z6fSQ7zpCM21GGep0PggbSfsmkxLottBQMu/phg iQ== Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 356jfcxxdj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2020 21:08:16 -0500 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B327SU9013205; Thu, 3 Dec 2020 02:08:14 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma03wdc.us.ibm.com with ESMTP id 353e69df1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Dec 2020 02:08:14 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B328Dv820447530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Dec 2020 02:08:13 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 654C07805E; Thu, 3 Dec 2020 02:08:13 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E35CE78068; Thu, 3 Dec 2020 02:08:12 +0000 (GMT) Received: from vios4361.aus.stglabs.ibm.com (unknown [9.3.43.61]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 3 Dec 2020 02:08:12 +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 v3 06/18] ibmvfc: add handlers to drain and complete Sub-CRQ responses Date: Wed, 2 Dec 2020 20:07:54 -0600 Message-Id: <20201203020806.14747-7-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201203020806.14747-1-tyreld@linux.ibm.com> References: <20201203020806.14747-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.312,18.0.737 definitions=2020-12-02_14:2020-11-30,2020-12-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=3 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012030009 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The logic for iterating over the Sub-CRQ responses is similiar to that of the primary CRQ. Add the necessary handlers for processing those responses. Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index e082935f56cf..b61ae1df21e5 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -3381,6 +3381,86 @@ static int ibmvfc_toggle_scrq_irq(struct ibmvfc_sub_queue *scrq, int enable) return rc; } +static void ibmvfc_handle_scrq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost) +{ + struct ibmvfc_event *evt = (struct ibmvfc_event *)be64_to_cpu(crq->ioba); + unsigned long flags; + + switch (crq->valid) { + case IBMVFC_CRQ_CMD_RSP: + break; + case IBMVFC_CRQ_XPORT_EVENT: + return; + default: + dev_err(vhost->dev, "Got and invalid message type 0x%02x\n", crq->valid); + return; + } + + /* The only kind of payload CRQs we should get are responses to + * things we send. Make sure this response is to something we + * actually sent + */ + if (unlikely(!ibmvfc_valid_event(&vhost->pool, evt))) { + dev_err(vhost->dev, "Returned correlation_token 0x%08llx is invalid!\n", + crq->ioba); + return; + } + + if (unlikely(atomic_read(&evt->free))) { + dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n", + crq->ioba); + return; + } + + del_timer(&evt->timer); + list_del(&evt->queue); + ibmvfc_trc_end(evt); + spin_unlock_irqrestore(vhost->host->host_lock, flags); + evt->done(evt); + spin_lock_irqsave(vhost->host->host_lock, flags); +} + +static struct ibmvfc_crq *ibmvfc_next_scrq(struct ibmvfc_sub_queue *scrq) +{ + struct ibmvfc_crq *crq; + + crq = &scrq->msgs[scrq->cur].crq; + if (crq->valid & 0x80) { + if (++scrq->cur == scrq->size) + scrq->cur = 0; + rmb(); + } else + crq = NULL; + + return crq; +} + +static void ibmvfc_drain_sub_crq(struct ibmvfc_sub_queue *scrq) +{ + struct ibmvfc_crq *crq; + unsigned long flags; + int done = 0; + + spin_lock_irqsave(scrq->vhost->host->host_lock, flags); + while (!done) { + while ((crq = ibmvfc_next_scrq(scrq)) != NULL) { + ibmvfc_handle_scrq(crq, scrq->vhost); + crq->valid = 0; + wmb(); + } + + ibmvfc_toggle_scrq_irq(scrq, 1); + if ((crq = ibmvfc_next_scrq(scrq)) != NULL) { + ibmvfc_toggle_scrq_irq(scrq, 0); + ibmvfc_handle_scrq(crq, scrq->vhost); + crq->valid = 0; + wmb(); + } else + done = 1; + } + spin_unlock_irqrestore(scrq->vhost->host->host_lock, flags); +} + /** * ibmvfc_init_tgt - Set the next init job step for the target * @tgt: ibmvfc target struct -- 2.27.0