From: John Garry <john.garry@huawei.com>
To: <damien.lemoal@opensource.wdc.com>, <jejb@linux.ibm.com>,
<martin.petersen@oracle.com>, <hare@suse.de>,
<bvanassche@acm.org>, <hch@lst.de>, <ming.lei@redhat.com>,
<niklas.cassel@wdc.com>
Cc: <axboe@kernel.dk>, <jinpu.wang@cloud.ionos.com>,
<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-ide@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<linuxarm@huawei.com>, John Garry <john.garry@huawei.com>
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 [thread overview]
Message-ID: <1666693976-181094-8-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1666693976-181094-1-git-send-email-john.garry@huawei.com>
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 <john.garry@huawei.com>
---
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
prev parent reply other threads:[~2022-10-25 10:12 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 10:32 [PATCH RFC v3 0/7] blk-mq/libata/scsi: SCSI driver tagging improvements Part II John Garry
2022-10-25 10:32 ` [PATCH RFC v3 1/7] ata: libata-scsi: Add ata_scsi_queue_internal() John Garry
2022-10-27 1:42 ` Damien Le Moal
2022-10-27 10:45 ` John Garry
2022-10-27 22:24 ` Damien Le Moal
2022-10-25 10:32 ` [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand() John Garry
2022-10-27 1:45 ` Damien Le Moal
2022-10-27 9:56 ` John Garry
2022-10-27 13:02 ` Hannes Reinecke
2022-10-27 17:23 ` John Garry
2022-10-27 22:35 ` Damien Le Moal
2022-10-28 8:14 ` John Garry
2022-10-28 8:26 ` Damien Le Moal
2022-10-27 22:25 ` Damien Le Moal
2022-10-28 8:01 ` John Garry
2022-10-28 8:07 ` Damien Le Moal
2022-10-28 8:33 ` John Garry
2022-10-31 5:59 ` Damien Le Moal
2022-11-02 9:52 ` John Garry
2022-11-02 10:07 ` Damien Le Moal
2022-11-02 11:12 ` Hannes Reinecke
2022-11-02 11:25 ` Damien Le Moal
2022-11-07 10:12 ` Hannes Reinecke
2022-11-07 13:29 ` Damien Le Moal
2022-11-07 14:34 ` Hannes Reinecke
2022-10-25 10:32 ` [PATCH RFC v3 3/7] ata: libata: Make space for ATA queue command in scmd payload John Garry
2022-10-25 10:32 ` [PATCH RFC v3 4/7] ata: libata: Add ata_internal_timeout() John Garry
2022-10-25 10:32 ` [PATCH RFC v3 5/7] ata: libata: Queue ATA internal commands as requests John Garry
2022-10-25 10:32 ` [PATCH RFC v3 6/7] scsi: mvsas: Remove internal tag handling John Garry
2022-10-25 10:32 ` John Garry [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1666693976-181094-8-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=niklas.cassel@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox