From patchwork Wed Aug 19 15:20:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 247986 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp561927ils; Wed, 19 Aug 2020 08:27:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5wDJ8CLFn85XI4w18JUBhRLghsRhkKn/UPnswQzb/tS/NAPkcsf1O+dtJMMGCBHLqJ9F0 X-Received: by 2002:a05:6402:a4c:: with SMTP id bt12mr24383280edb.360.1597850856760; Wed, 19 Aug 2020 08:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597850856; cv=none; d=google.com; s=arc-20160816; b=I6uIBBh1nTeOPvTFfN2tDR1loWw0IEl9EwrSnzzljBFao1Q+OU1XDk9E99+5C75toB WFlonxWi9CB3ClJAORWAzVP57P+m+dredrG4KZnIvihVNNTHgEW9glCfSk5Zh6VILIGg W7TmDe8U023kppmwPJgZlUKwl1x7x7vrBHpMOzJVcIA3FAHXFMsdclm+P5dEKEjhgplA Xv2bD0CN2W/Ih82UBZTNTn0w06A96DQV0Z2FhTxBxNMi/i9Nape+7qDgF2GVD+/JCzsu o7kYrxbT3w4NZx9fS2OAKBygmxDitgDp0+qP1qWl1/NHZrIQjhEcWe0CV/GUEQjn59iY SVzw== 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=f09s3QJhBb+8BZ0+lrjvD06ihWnK0HX2MIMJrzD3eQM=; b=xIaPyUlzVF8mnm50A4tC61h2/3OBXLN9c1uOekrrpw1BLZKUyFWUBI6jJkipXe2zGj UAEcyK74/4TpRkpuoWDH/k7NyAHEeTcN+sncp+RQs7PZwzPK7j3soJJ7/AeUxEH7zFKx ITM0W7IaB7/YwQzlQ1VZlshZWv2On47yQnOGY9YwqVKyOQg6CDHhzXQS5AucybvmuxEJ W8icixzSu15NoK8XSzTpj+BQYKt85U0QsOOrTx9C9A6MpBkDHL2PiwJ2RBK308kyCk6Y nVE0a1ZAjIVAIWnyqa3JKBrSsCL0Q2bfhksPH/fkMFPB6czPHFQvRFo5TPEJ5BbaJuIQ nhog== 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 cq22si14934581edb.609.2020.08.19.08.27.36 for ; Wed, 19 Aug 2020 08:27:36 -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 S1728479AbgHSPZH (ORCPT ); Wed, 19 Aug 2020 11:25:07 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9781 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726894AbgHSPZG (ORCPT ); Wed, 19 Aug 2020 11:25:06 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6DC731556ACDD80C64D7; 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:52 +0800 From: John Garry To: , , , , , , , , , , CC: , , , , , , , , John Garry Subject: [PATCH v8 15/18] scsi: scsi_debug: Support host tagset Date: Wed, 19 Aug 2020 23:20:33 +0800 Message-ID: <1597850436-116171-16-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 When host_max_queue is set (> 0), set the Scsi_Host.host_tagset such that blk-mq will use a hostwide tagset over all SCSI host submission queues. This means that we may expose all submission queues and always use the hwq chosen by blk-mq. And since if sdebug_host_max_queue is set, sdebug_max_queue is fixed to the same value, we can simplify how sdebug_driver_template.can_queue is set. Signed-off-by: John Garry --- drivers/scsi/scsi_debug.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) -- 2.26.2 diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 064ed680c053..4238baa2b34b 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4698,19 +4698,14 @@ static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd) { u16 hwq; + u32 tag = blk_mq_unique_tag(cmnd->request); - if (sdebug_host_max_queue) { - /* Provide a simple method to choose the hwq */ - hwq = smp_processor_id() % submit_queues; - } else { - u32 tag = blk_mq_unique_tag(cmnd->request); + hwq = blk_mq_unique_tag_to_hwq(tag); - hwq = blk_mq_unique_tag_to_hwq(tag); + pr_debug("tag=%#x, hwq=%d\n", tag, hwq); + if (WARN_ON_ONCE(hwq >= submit_queues)) + hwq = 0; - pr_debug("tag=%#x, hwq=%d\n", tag, hwq); - if (WARN_ON_ONCE(hwq >= submit_queues)) - hwq = 0; - } return sdebug_q_arr + hwq; } @@ -7347,10 +7342,7 @@ static int sdebug_driver_probe(struct device *dev) sdbg_host = to_sdebug_host(dev); - if (sdebug_host_max_queue) - sdebug_driver_template.can_queue = sdebug_host_max_queue; - else - sdebug_driver_template.can_queue = sdebug_max_queue; + sdebug_driver_template.can_queue = sdebug_max_queue; if (!sdebug_clustering) sdebug_driver_template.dma_boundary = PAGE_SIZE - 1; @@ -7367,11 +7359,11 @@ static int sdebug_driver_probe(struct device *dev) } /* * Decide whether to tell scsi subsystem that we want mq. The - * following should give the same answer for each host. If the host - * has a limit of hostwide max commands, then do not set. + * following should give the same answer for each host. */ - if (!sdebug_host_max_queue) - hpnt->nr_hw_queues = submit_queues; + hpnt->nr_hw_queues = submit_queues; + if (sdebug_host_max_queue) + hpnt->host_tagset = 1; sdbg_host->shost = hpnt; *((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host;