From patchwork Wed Aug 19 15:20:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 247983 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp561547ils; Wed, 19 Aug 2020 08:27:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6S5N5DjsYoXNAQqiktJxJ11R1RPfEi4HTY9yUtn/qudQRV1gWofb6TxY5C6yzb1t0kq45 X-Received: by 2002:a05:6402:1d32:: with SMTP id dh18mr25092153edb.14.1597850826934; Wed, 19 Aug 2020 08:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597850826; cv=none; d=google.com; s=arc-20160816; b=S3waWyK2Dzm8vMCyTN/wvSZ4+X51tj0mpwEOQfze/qKzslaKyDpE1c+PvFAIPpkxvs ZPrRsDXIzD+kuu+xrmZLr+RnU8z8EUp9MG/KLhUKpFn8IlJbS8G73Uyo+fWD1oVzfvTB pd9YGHVJ4SxsCc7dT8DCa4LlEzSrsKd5p8du5lkbsAaBrR1ONO0rXZL0fXi9A0Q/9Sg7 4bZrWzegmrcwYDG/rLrL6HEFsZod4k9Uy2H0yRyA9GbUplGtZnMetuejLRvopwmeHWwa 2f8TYIMbm/xz7QCqIKJz5BoItdaXCx1YeLWbvQy89PYt4oKJB7Ip6HspKnDxB0VrkOSt Ilwg== 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=0z+lcPQXmhccQPkZPR4Ezw59pIL5bwHUOwZ92Qmi0bo=; b=ExL5fYeq+nEHqX0hGYbqq35/FDCtwM//sq7PYcWuaHwl2qdYigpkl3SeN74PRLHhPF YAQ8WUAVD98eTFFwuOGLSHIgfQ7fMfM0t6BUu1vNR+aY1kcPkDwIIUtTGi6r46syC/kJ hHCGno7si3bcsYvm7iiQnvEhVNeEKo0PRFRvf09BgMnN4so6KyF+b/ipUTx+3Xs9ZuzC roW9vUvPoS3onLBCzlmzHNmh7PXlLagWtBLqzHkshWxWN2Ut9DA/H5gN2Eez+oxE6L5O tEpP8lsxOtku3YBFUk8Nbbv44DE+ickuH7mvkwkFp9DCNtSjDHWJ8OeE2MdRhkC7IyaT Ioyw== 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 a3si15576462ejc.80.2020.08.19.08.27.06 for ; Wed, 19 Aug 2020 08:27:06 -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 S1728906AbgHSP1A (ORCPT ); Wed, 19 Aug 2020 11:27:00 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9851 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726894AbgHSPZQ (ORCPT ); Wed, 19 Aug 2020 11:25:16 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 97823174EF24E6297F9B; Wed, 19 Aug 2020 23:25:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 19 Aug 2020 23:24:54 +0800 From: John Garry To: , , , , , , , , , , CC: , , , , , , , , John Garry Subject: [PATCH v8 18/18] smartpqi: enable host tagset Date: Wed, 19 Aug 2020 23:20:36 +0800 Message-ID: <1597850436-116171-19-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1597850436-116171-1-git-send-email-john.garry@huawei.com> References: <1597850436-116171-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 [jpg: Mod ctrl_info->next_io_request_slot calc] Signed-off-by: John Garry --- drivers/scsi/smartpqi/smartpqi_init.c | 45 ++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) -- 2.26.2 diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index bd38c8cea56e..870ed1400a9e 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -575,22 +575,33 @@ 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; - u16 i = ctrl_info->next_io_request_slot; /* benignly racy */ + unsigned int limit = PQI_RESERVED_IO_SLOTS; + u16 i; - 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 { + i = ctrl_info->next_io_request_slot; /* benignly racy */ + 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; + } + ctrl_info->next_io_request_slot = (i + 1) % limit; } - /* benignly racy */ - ctrl_info->next_io_request_slot = (i + 1) % ctrl_info->max_io_slots; - pqi_reinit_io_request(io_request); return io_request; @@ -4075,7 +4086,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 +5043,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 +5243,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 +5673,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 +6520,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)