From patchwork Wed Jun 10 17:29:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 187766 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688449ilo; Wed, 10 Jun 2020 10:33:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi2JpfuBG1WJQ2S6q9g/tOz2UTXyuz3Sii6eV1oSaULX+aylYE0H44yeKAQNSr76Cxqq3h X-Received: by 2002:a17:906:2c10:: with SMTP id e16mr4257106ejh.189.1591810421968; Wed, 10 Jun 2020 10:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591810421; cv=none; d=google.com; s=arc-20160816; b=Rhpl4yoashjjGf5rJQUQnTrgdHbwI24AI/KwPvccErRSksnvKzijdbeSlBbJLrfd6a 1CMjRwZpMy5NCKbjtRaI40NO6/eEjJfcHJq2obwTI2wQT1ec7jvehVo2nZjhyRltTmnL AmeIx1gNpr/TTn+usl2N6oi/eCBjstnBgBFqUpUQLx2NhOvSMh6o+mJnPDEbn9knaT5t 14OEB0q+gsTKluYJuJnvrKDS/sR+5jPyqKTRf90DdpuR2imALLgP9+xndthJbTrbnrSj xpJd/5zPoO2Tv3wVCr1NyhLHsgXLCe2M8Lgf8mTNgnqn2nhJ7yk3ywwArDkO4HAPMtkP FDzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=sLSV1rRAaupRpnzMnNsJEpLmD34xmM0JkEbESogPNm0=; b=QHvszcmMhaIgC2Cmgt2AaXqbjVtwZMgClAp+PFoW6P1hZbJzdxoQVsAf9LzeKGczh4 fMzHFpxYZBtNHc0TfAhgAbth+hAfB5ValqA3DhBv/NNDf8H+teiN+xVyEpI1n8UDi6yN rUUyK0ETJXwQ4fVAVGLKWJ9rX5+KgH10DQJ9qzoGmCQMI31higgrR39PhBArMOOzEjYc N2UYfBgTQ1Xw3zQxZYH/Unc84v9u6AC+W5lhFlTpm2CGKr6Smiazh6hAg1e+Zip5uTz6 V78jVASkUKRHX3xFTk6chhFWfRCYvjUTxHFbqwEmKV1Kl/vELIHqyXrL9/ZkpSpRky+D OT2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz26si430501ejb.252.2020.06.10.10.33.41 for ; Wed, 10 Jun 2020 10:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgFJRdf (ORCPT ); Wed, 10 Jun 2020 13:33:35 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5808 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726332AbgFJRde (ORCPT ); Wed, 10 Jun 2020 13:33:34 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0BBDD1831338785E6BCC; Thu, 11 Jun 2020 01:33:27 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Thu, 11 Jun 2020 01:33:21 +0800 From: John Garry To: , , , , , , , , , , CC: , , , , , Hannes Reinecke Subject: [PATCH RFC v7 11/12] smartpqi: enable host tagset Date: Thu, 11 Jun 2020 01:29:18 +0800 Message-ID: <1591810159-240929-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1591810159-240929-1-git-send-email-john.garry@huawei.com> References: <1591810159-240929-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke Enable host tagset for smartpqi; with this we can use the request tag to look command from the pool avoiding the list iteration in the hot path. Signed-off-by: Hannes Reinecke --- drivers/scsi/smartpqi/smartpqi_init.c | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) -- 2.26.2 diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index cd157f11eb22..1f4de4c2d876 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -575,17 +575,29 @@ static inline void pqi_reinit_io_request(struct pqi_io_request *io_request) } static struct pqi_io_request *pqi_alloc_io_request( - struct pqi_ctrl_info *ctrl_info) + struct pqi_ctrl_info *ctrl_info, struct scsi_cmnd *scmd) { struct pqi_io_request *io_request; + unsigned int limit = PQI_RESERVED_IO_SLOTS; u16 i = ctrl_info->next_io_request_slot; /* benignly racy */ - while (1) { + if (scmd) { + u32 blk_tag = blk_mq_unique_tag(scmd->request); + + i = blk_mq_unique_tag_to_tag(blk_tag) + limit; io_request = &ctrl_info->io_request_pool[i]; - if (atomic_inc_return(&io_request->refcount) == 1) - break; - atomic_dec(&io_request->refcount); - i = (i + 1) % ctrl_info->max_io_slots; + if (WARN_ON(atomic_inc_return(&io_request->refcount) > 1)) { + atomic_dec(&io_request->refcount); + return NULL; + } + } else { + while (1) { + io_request = &ctrl_info->io_request_pool[i]; + if (atomic_inc_return(&io_request->refcount) == 1) + break; + atomic_dec(&io_request->refcount); + i = (i + 1) % limit; + } } /* benignly racy */ @@ -4075,7 +4087,7 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, atomic_inc(&ctrl_info->sync_cmds_outstanding); - io_request = pqi_alloc_io_request(ctrl_info); + io_request = pqi_alloc_io_request(ctrl_info, NULL); put_unaligned_le16(io_request->index, &(((struct pqi_raid_path_request *)request)->request_id)); @@ -5032,7 +5044,9 @@ static inline int pqi_raid_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info, { struct pqi_io_request *io_request; - io_request = pqi_alloc_io_request(ctrl_info); + io_request = pqi_alloc_io_request(ctrl_info, scmd); + if (!io_request) + return SCSI_MLQUEUE_HOST_BUSY; return pqi_raid_submit_scsi_cmd_with_io_request(ctrl_info, io_request, device, scmd, queue_group); @@ -5230,7 +5244,10 @@ static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info, struct pqi_io_request *io_request; struct pqi_aio_path_request *request; - io_request = pqi_alloc_io_request(ctrl_info); + io_request = pqi_alloc_io_request(ctrl_info, scmd); + if (!io_request) + return SCSI_MLQUEUE_HOST_BUSY; + io_request->io_complete_callback = pqi_aio_io_complete; io_request->scmd = scmd; io_request->raid_bypass = raid_bypass; @@ -5657,7 +5674,7 @@ static int pqi_lun_reset(struct pqi_ctrl_info *ctrl_info, DECLARE_COMPLETION_ONSTACK(wait); struct pqi_task_management_request *request; - io_request = pqi_alloc_io_request(ctrl_info); + io_request = pqi_alloc_io_request(ctrl_info, NULL); io_request->io_complete_callback = pqi_lun_reset_complete; io_request->context = &wait; @@ -6504,6 +6521,7 @@ static struct scsi_host_template pqi_driver_template = { .map_queues = pqi_map_queues, .sdev_attrs = pqi_sdev_attrs, .shost_attrs = pqi_shost_attrs, + .host_tagset = 1, }; static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info)