]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
scsi: hisi_sas: Make max IPTT count equal for all hw revisions
authorJohn Garry <john.garry@huawei.com>
Mon, 5 Aug 2019 13:47:58 +0000 (21:47 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 8 Aug 2019 02:13:14 +0000 (22:13 -0400)
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>
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_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

index 42a02cc47a60b88245007e6623594a037a81b4cc..1fa3e53e857d2b3bed09b9a3074850898a4c569e 100644 (file)
 #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))
@@ -292,7 +295,6 @@ struct hisi_sas_hw {
                                          int delay_ms, int timeout_ms);
        void (*snapshot_prepare)(struct hisi_hba *hisi_hba);
        void (*snapshot_restore)(struct hisi_hba *hisi_hba);
-       int max_command_entries;
        int complete_hdr_size;
        struct scsi_host_template *sht;
 
index cb746cfc2fa89d37d3f6fb8e8bc1a2a2d3a7407d..94c7c2b48b17ee40c79ef6d42786a98aa50b9725 100644 (file)
@@ -180,8 +180,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);
@@ -211,8 +211,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;
@@ -2291,7 +2290,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = {
 
 void hisi_sas_init_mem(struct hisi_hba *hisi_hba)
 {
-       int i, s, j, max_command_entries = hisi_hba->hw->max_command_entries;
+       int i, s, j, max_command_entries = HISI_SAS_MAX_COMMANDS;
        struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint;
 
        for (i = 0; i < hisi_hba->queue_count; i++) {
@@ -2328,7 +2327,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;
 
@@ -2458,8 +2457,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba)
        hisi_sas_init_mem(hisi_hba);
 
        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) {
@@ -2672,13 +2670,11 @@ int hisi_sas_probe(struct platform_device *pdev,
        shost->max_channel = 1;
        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;
@@ -2794,7 +2790,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;
@@ -3008,7 +3004,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++) {
@@ -3177,7 +3173,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;
index 3912216e8a4f591c0d105bab9770bc6b466e0870..afdbaccbbc5eebe34849994c680a762f115ce492 100644 (file)
@@ -401,8 +401,6 @@ enum {
        TRANS_RX_SMP_RESP_TIMEOUT_ERR, /* 0x31a */
 };
 
-#define HISI_SAS_COMMAND_ENTRIES_V1_HW 8192
-
 #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)
@@ -1830,7 +1828,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,
 };
index e9b15d45f98f952b3540dd1a292e8e432d02a734..fc98bd9e5588ba0cf5cbd6bc25fbb9a61d9c80e5 100644 (file)
@@ -3616,7 +3616,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,
index 5f0f6df11adfa60152a4724d6ef8256e27a77fff..0171cdb4da81c89fb2a6baf9de3581087c341a49 100644 (file)
@@ -2935,7 +2935,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,
@@ -3076,10 +3075,8 @@ 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;
-       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;