Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8190902rwi; Tue, 25 Oct 2022 03:46:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM789U5v1PPgQFvJtZfhwu+mMvVZPMj/qjxIMD+Rlus1cwdR5RlBlKuFOp++EoLGB5J4jWA/ X-Received: by 2002:a17:907:75c8:b0:78d:b646:e768 with SMTP id jl8-20020a17090775c800b0078db646e768mr31513267ejc.432.1666694800023; Tue, 25 Oct 2022 03:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666694800; cv=none; d=google.com; s=arc-20160816; b=XGKBxuWqu5B0548UjP0ZRC272I0Kt3Z9QmkUXhbkY63LWiIe3ctr7S6yjikpPJQ5xx SSPCgIqIW5PVTZ4/SkolsNHUrg/cUaQIUhx+2F/Ns/Pith8yEsnIamLE563jIPP4sXRX ZQzRGqL3+Kjc6amgSez09j9FyDZvAmL2rcYczB1KpEO+/1uuJIi4+cgQoazCrpirJd4+ aEss8HwEI3/jTm72p7Qk3TK6yBzXHFpVc/aKspJx2kUp8766BiTLLpolMk9kaC4wEAIy V9rv3GplMTxguLn++wW8fxuuj53itrKL9R2BLkJiZrDA3jWdDoEOdSDy4GbTGv1eKUWn kC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Jobd9fu8BfYRKqEbhCCelRVF4f9nqOaUDRRYDEKDYD0=; b=QCYKDljiqixW1InQwCItsdMTNUPCppiUyAhSlsQmBRLK1rz3NkAchfIR4fXNTjDXHe XAeQHwpYNrzA0PMs8P12Y+2XpspuqSmP0d/Bor7yPSOrXKi+RadSJzoDMpINZ4t8/o57 bOjuDopqRtKyzoak/Z5aokbxVJy/7vfVwO73m//zZmE0ALgq74ofjT/TMybUatPsHWKw RbP4/70WNmzEuyKJk//QM+gMY8VwMgTBU0mON7Koj4s7XL5Ws3/KDKDCP/jTZt3YGW8b Gg8yf6knsAYeePZqd6wRGXLUagPXdlvm8pK2rU9lkb47v1MNt804B247U3SbWjKyZgM7 idiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa23-20020a1709076d1700b0078d9c0e8971si2582120ejc.752.2022.10.25.03.46.12; Tue, 25 Oct 2022 03:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232360AbiJYKML (ORCPT + 99 others); Tue, 25 Oct 2022 06:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232171AbiJYKKt (ORCPT ); Tue, 25 Oct 2022 06:10:49 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8806013669F; Tue, 25 Oct 2022 03:03:42 -0700 (PDT) Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxS9Q390vz67brF; Tue, 25 Oct 2022 18:00:10 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 12:03:40 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 11:03:37 +0100 From: John Garry To: , , , , , , , CC: , , , , , , , John Garry Subject: [PATCH RFC v3 7/7] scsi: hisi_sas: Remove internal tag handling for reserved commands Date: Tue, 25 Oct 2022 18:32:56 +0800 Message-ID: <1666693976-181094-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693976-181094-1-git-send-email-john.garry@huawei.com> References: <1666693976-181094-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that any sas_task which we're sent has a request associated, we can use the request tag for slot IPTT. However, since v2 HW has its own slot IPTT allocation scheme due to badly broken HW, continue to use it. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 3 - drivers/scsi/hisi_sas/hisi_sas_main.c | 82 +++++--------------------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 9 +-- 3 files changed, 17 insertions(+), 77 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 6f8a52a1b808..8cd238f75066 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -39,9 +39,6 @@ #define HISI_SAS_PM_BIT 2 #define HISI_SAS_HW_FAULT_BIT 3 #define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) -#define HISI_SAS_RESERVED_IPTT 96 -#define HISI_SAS_UNRESERVED_IPTT \ - (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) #define HISI_SAS_IOST_ITCT_CACHE_NUM 64 #define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 65475775c844..7f784cdacf9f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -161,49 +161,13 @@ static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx) static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx) { - if (hisi_hba->hw->slot_index_alloc || - slot_idx >= HISI_SAS_UNRESERVED_IPTT) { + if (hisi_hba->hw->slot_index_alloc) { spin_lock(&hisi_hba->lock); hisi_sas_slot_index_clear(hisi_hba, slot_idx); spin_unlock(&hisi_hba->lock); } } -static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) -{ - void *bitmap = hisi_hba->slot_index_tags; - - __set_bit(slot_idx, bitmap); -} - -static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, - struct request *rq) -{ - int index; - void *bitmap = hisi_hba->slot_index_tags; - - if (rq) - return rq->tag + HISI_SAS_RESERVED_IPTT; - - spin_lock(&hisi_hba->lock); - index = find_next_zero_bit(bitmap, HISI_SAS_RESERVED_IPTT, - hisi_hba->last_slot_index + 1); - if (index >= HISI_SAS_RESERVED_IPTT) { - index = find_next_zero_bit(bitmap, - HISI_SAS_RESERVED_IPTT, - 0); - if (index >= HISI_SAS_RESERVED_IPTT) { - spin_unlock(&hisi_hba->lock); - return -SAS_QUEUE_FULL; - } - } - hisi_sas_slot_index_set(hisi_hba, index); - hisi_hba->last_slot_index = index; - spin_unlock(&hisi_hba->lock); - - return index; -} - void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, struct hisi_sas_slot *slot) { @@ -465,8 +429,10 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) struct hisi_sas_port *port; struct hisi_hba *hisi_hba; struct hisi_sas_slot *slot; + unsigned int dq_index; struct request *rq; struct device *dev; + u32 blk_tag; int rc; if (!sas_port) { @@ -486,20 +452,9 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) hisi_hba = dev_to_hisi_hba(device); dev = hisi_hba->dev; rq = sas_task_find_rq(task); - if (rq) { - unsigned int dq_index; - u32 blk_tag; - - blk_tag = blk_mq_unique_tag(rq); - dq_index = blk_mq_unique_tag_to_hwq(blk_tag); - dq = &hisi_hba->dq[dq_index]; - } else { - struct Scsi_Host *shost = hisi_hba->shost; - struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; - int queue = qmap->mq_map[raw_smp_processor_id()]; - - dq = &hisi_hba->dq[queue]; - } + blk_tag = blk_mq_unique_tag(rq); + dq_index = blk_mq_unique_tag_to_hwq(blk_tag); + dq = &hisi_hba->dq[dq_index]; switch (task->task_proto) { case SAS_PROTOCOL_SSP: @@ -563,13 +518,13 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) goto err_out_dma_unmap; } - if (!internal_abort && hisi_hba->hw->slot_index_alloc) + if (hisi_hba->hw->slot_index_alloc) { rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device); - else - rc = hisi_sas_slot_index_alloc(hisi_hba, rq); - - if (rc < 0) - goto err_out_dif_dma_unmap; + if (rc < 0) + goto err_out_dif_dma_unmap; + } else { + rc = rq->tag; + } slot = &hisi_hba->slot_info[rc]; slot->n_elem = n_elem; @@ -2434,17 +2389,8 @@ int hisi_sas_probe(struct platform_device *pdev, shost->max_lun = ~0; shost->max_channel = 1; shost->max_cmd_len = 16; - if (hisi_hba->hw->slot_index_alloc) { - shost->can_queue = HISI_SAS_MAX_COMMANDS; - shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS; - } else { - /* - * Intentionally use HISI_SAS_UNRESERVED_IPTT for .can_queue until - * every sas_task we're sent has a request associated. - */ - shost->can_queue = HISI_SAS_UNRESERVED_IPTT; - shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; - } + shost->can_queue = HISI_SAS_MAX_COMMANDS; + shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS; sha->sas_ha_name = DRV_NAME; sha->dev = hisi_hba->dev; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 4caf07306b24..c7963ae8ad50 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -4862,12 +4862,9 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_lun = ~0; shost->max_channel = 1; shost->max_cmd_len = 16; - /* - * Intentionally use HISI_SAS_UNRESERVED_IPTT for .can_queue until - * every sas_task we're sent has a request associated. - */ - shost->can_queue = HISI_SAS_UNRESERVED_IPTT; - shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; + + shost->can_queue = HISI_SAS_MAX_COMMANDS; + shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS; sha->sas_ha_name = DRV_NAME; sha->dev = dev; -- 2.35.3