223 lines
9.0 KiB
Diff
223 lines
9.0 KiB
Diff
From 41a669b572098e569f76c4bffcabee63413f31a0 Mon Sep 17 00:00:00 2001
|
|
From: John Garry <john.garry@huawei.com>
|
|
Date: Mon, 5 Aug 2019 21:47:58 +0800
|
|
Subject: [PATCH 006/108] scsi: hisi_sas: Make max IPTT count equal for all hw
|
|
revisions
|
|
|
|
mainline inclusion
|
|
from mainline-v5.4-rc1
|
|
commit 93352abc81a90314bf032038200ce96989a32c62
|
|
category: feature
|
|
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EKNE
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=93352abc81a90314bf032038200ce96989a32c62
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
There is a small optimisation to be had by making the max IPTT the same for
|
|
all hw revisions, that being we can drop the check for read and write
|
|
pointer being the same in the get free slot function.
|
|
|
|
Change v1 hw to have max IPTT of 4096 - same as v2 and v3 hw - and
|
|
drop hisi_sas_hw.max_command_entries.
|
|
|
|
Signed-off-by: John Garry <john.garry@huawei.com>
|
|
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
Signed-off-by: YunYi Yang <yangyunyi2@huawei.com>
|
|
|
|
Conflicts:
|
|
drivers/scsi/hisi_sas/hisi_sas.h
|
|
drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
|
|
---
|
|
drivers/scsi/hisi_sas/hisi_sas.h | 6 ++++--
|
|
drivers/scsi/hisi_sas/hisi_sas_main.c | 30 +++++++++++---------------
|
|
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 ---
|
|
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 -
|
|
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 ++----
|
|
5 files changed, 19 insertions(+), 28 deletions(-)
|
|
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
|
|
index 06a8bf9f0f73..94aeb3bb6329 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas.h
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
|
|
@@ -37,7 +37,10 @@
|
|
#define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
|
|
#define HISI_SAS_RESET_BIT 0
|
|
#define HISI_SAS_REJECT_CMD_BIT 1
|
|
-#define HISI_SAS_RESERVED_IPTT_CNT 96
|
|
+#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_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer))
|
|
#define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table))
|
|
@@ -337,7 +340,6 @@ struct hisi_sas_hw {
|
|
const struct cpumask *(*get_managed_irq_aff)(struct hisi_hba
|
|
*hisi_hba, int queue);
|
|
void (*debugfs_work_handler)(struct work_struct *work);
|
|
- int max_command_entries;
|
|
int complete_hdr_size;
|
|
struct scsi_host_template *sht;
|
|
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
index b280cc109efb..7784b6c1b1d8 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
@@ -174,8 +174,8 @@ static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx)
|
|
{
|
|
unsigned long flags;
|
|
|
|
- if (hisi_hba->hw->slot_index_alloc || (slot_idx >=
|
|
- hisi_hba->hw->max_command_entries - HISI_SAS_RESERVED_IPTT_CNT)) {
|
|
+ if (hisi_hba->hw->slot_index_alloc ||
|
|
+ slot_idx >= HISI_SAS_UNRESERVED_IPTT) {
|
|
spin_lock_irqsave(&hisi_hba->lock, flags);
|
|
hisi_sas_slot_index_clear(hisi_hba, slot_idx);
|
|
spin_unlock_irqrestore(&hisi_hba->lock, flags);
|
|
@@ -206,8 +206,7 @@ static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba,
|
|
if (index >= hisi_hba->slot_index_count) {
|
|
index = find_next_zero_bit(bitmap,
|
|
hisi_hba->slot_index_count,
|
|
- hisi_hba->hw->max_command_entries -
|
|
- HISI_SAS_RESERVED_IPTT_CNT);
|
|
+ HISI_SAS_UNRESERVED_IPTT);
|
|
if (index >= hisi_hba->slot_index_count) {
|
|
spin_unlock_irqrestore(&hisi_hba->lock, flags);
|
|
return -SAS_QUEUE_FULL;
|
|
@@ -2356,7 +2355,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = {
|
|
|
|
void hisi_sas_init_mem(struct hisi_hba *hisi_hba)
|
|
{
|
|
- int i, s, max_command_entries = hisi_hba->hw->max_command_entries;
|
|
+ int i, s, max_command_entries = HISI_SAS_MAX_COMMANDS;
|
|
|
|
for (i = 0; i < hisi_hba->queue_count; i++) {
|
|
struct hisi_sas_cq *cq = &hisi_hba->cq[i];
|
|
@@ -2388,7 +2387,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_init_mem);
|
|
int hisi_sas_alloc(struct hisi_hba *hisi_hba)
|
|
{
|
|
struct device *dev = hisi_hba->dev;
|
|
- int i, j, s, max_command_entries = hisi_hba->hw->max_command_entries;
|
|
+ int i, j, s, max_command_entries = HISI_SAS_MAX_COMMANDS;
|
|
int max_command_entries_ru, sz_slot_buf_ru;
|
|
int blk_cnt, slots_per_blk;
|
|
|
|
@@ -2523,8 +2522,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba)
|
|
goto err_out;
|
|
|
|
hisi_sas_slot_index_init(hisi_hba);
|
|
- hisi_hba->last_slot_index = hisi_hba->hw->max_command_entries -
|
|
- HISI_SAS_RESERVED_IPTT_CNT;
|
|
+ hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT;
|
|
|
|
hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
|
|
if (!hisi_hba->wq) {
|
|
@@ -2738,13 +2736,11 @@ int hisi_sas_probe(struct platform_device *pdev,
|
|
/* shost support 16 bytes cmd len base on hw */
|
|
shost->max_cmd_len = 16;
|
|
if (hisi_hba->hw->slot_index_alloc) {
|
|
- shost->can_queue = hisi_hba->hw->max_command_entries;
|
|
- shost->cmd_per_lun = hisi_hba->hw->max_command_entries;
|
|
+ shost->can_queue = HISI_SAS_MAX_COMMANDS;
|
|
+ shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS;
|
|
} else {
|
|
- shost->can_queue = hisi_hba->hw->max_command_entries -
|
|
- HISI_SAS_RESERVED_IPTT_CNT;
|
|
- shost->cmd_per_lun = hisi_hba->hw->max_command_entries -
|
|
- HISI_SAS_RESERVED_IPTT_CNT;
|
|
+ shost->can_queue = HISI_SAS_UNRESERVED_IPTT;
|
|
+ shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT;
|
|
}
|
|
|
|
sha->sas_ha_name = DRV_NAME;
|
|
@@ -2853,7 +2849,7 @@ static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba)
|
|
|
|
static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba)
|
|
{
|
|
- int max_command_entries = hisi_hba->hw->max_command_entries;
|
|
+ int max_command_entries = HISI_SAS_MAX_COMMANDS;
|
|
void *databuf = hisi_hba->debugfs_iost;
|
|
struct hisi_sas_iost *iost;
|
|
int i;
|
|
@@ -3452,7 +3448,7 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p)
|
|
{
|
|
struct hisi_hba *hisi_hba = s->private;
|
|
struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost;
|
|
- int i, ret, max_command_entries = hisi_hba->hw->max_command_entries;
|
|
+ int i, ret, max_command_entries = HISI_SAS_MAX_COMMANDS;
|
|
__le64 *iost = &debugfs_iost->qw0;
|
|
|
|
for (i = 0; i < max_command_entries; i++, debugfs_iost++) {
|
|
@@ -3633,7 +3629,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler);
|
|
|
|
void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba)
|
|
{
|
|
- int max_command_entries = hisi_hba->hw->max_command_entries;
|
|
+ int max_command_entries = HISI_SAS_MAX_COMMANDS;
|
|
struct device *dev = hisi_hba->dev;
|
|
int p, i, c, d;
|
|
size_t sz;
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
|
|
index 1c51cbd94925..1e03e673ceb5 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
|
|
@@ -406,8 +406,6 @@ enum {
|
|
TRANS_RX_SMP_RESP_TIMEOUT_ERR, /* 0x31a */
|
|
};
|
|
|
|
-#define HISI_SAS_COMMAND_ENTRIES_V1_HW 4096
|
|
-
|
|
#define HISI_SAS_PHY_MAX_INT_NR (HISI_SAS_PHY_INT_NR * HISI_SAS_MAX_PHYS)
|
|
#define HISI_SAS_CQ_MAX_INT_NR (HISI_SAS_MAX_QUEUES)
|
|
#define HISI_SAS_FATAL_INT_NR (2)
|
|
@@ -1806,7 +1804,6 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = {
|
|
.phy_set_linkrate = phy_set_linkrate_v1_hw,
|
|
.phy_get_max_linkrate = phy_get_max_linkrate_v1_hw,
|
|
.get_wideport_bitmap = get_wideport_bitmap_v1_hw,
|
|
- .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V1_HW,
|
|
.complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr),
|
|
.sht = &sht_v1_hw,
|
|
};
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
|
|
index 72fb4fa69668..ff197bc06453 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
|
|
@@ -3617,7 +3617,6 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = {
|
|
.get_events = phy_get_events_v2_hw,
|
|
.phy_set_linkrate = phy_set_linkrate_v2_hw,
|
|
.phy_get_max_linkrate = phy_get_max_linkrate_v2_hw,
|
|
- .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V2_HW,
|
|
.complete_hdr_size = sizeof(struct hisi_sas_complete_v2_hdr),
|
|
.soft_reset = soft_reset_v2_hw,
|
|
.get_phys_state = get_phys_state_v2_hw,
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
|
|
index 1285d61b29b4..12fc3b370265 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
|
|
@@ -3434,7 +3434,6 @@ static struct scsi_host_template sht_v3_hw = {
|
|
static const struct hisi_sas_hw hisi_sas_v3_hw = {
|
|
.hw_init = hisi_sas_v3_init,
|
|
.setup_itct = setup_itct_v3_hw,
|
|
- .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V3_HW,
|
|
.get_wideport_bitmap = get_wideport_bitmap_v3_hw,
|
|
.complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr),
|
|
.clear_itct = clear_itct_v3_hw,
|
|
@@ -3581,10 +3580,8 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
shost->max_channel = 1;
|
|
/* shost support 16 bytes cmd len base on hw */
|
|
shost->max_cmd_len = 16;
|
|
- shost->can_queue = hisi_hba->hw->max_command_entries -
|
|
- HISI_SAS_RESERVED_IPTT_CNT;
|
|
- shost->cmd_per_lun = hisi_hba->hw->max_command_entries -
|
|
- HISI_SAS_RESERVED_IPTT_CNT;
|
|
+ shost->can_queue = HISI_SAS_UNRESERVED_IPTT;
|
|
+ shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT;
|
|
|
|
sha->sas_ha_name = DRV_NAME;
|
|
sha->dev = dev;
|
|
--
|
|
2.27.0
|
|
|