]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: hisi_sas: fix SATA breakpoint memory size
authorXiang Chen <chenxiang66@hisilicon.com>
Tue, 24 Oct 2017 15:51:35 +0000 (23:51 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 25 Oct 2017 12:21:04 +0000 (08:21 -0400)
Currently the size of memory we allocate for SATA breakpoint buffer is
incorrect.

The breakpoint memory size should be as follows: 32 (NCQ tags) * 128 *
2048 (max #devs) = 8MB

Currently we only allocate 0.5MB, but get away with it as we never
have SATA device index > 128 typically.

To conserve precious DMA memory (8MB may not be even available), limit
the number of devices per HBA to 1024, which means 4MB of memory
required for SATA breakpoint.

The 1024 device limit applied to all HW versions. For v3 hw, we need
to configure this value.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
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_v3_hw.c

index 07f4a4cfbec1b3275280eb0193009fbf3e72b264..07538cf24d5c5b45c8b9c1d6bfa04ccf04f1d757 100644 (file)
@@ -29,7 +29,7 @@
 #define HISI_SAS_MAX_PHYS      9
 #define HISI_SAS_MAX_QUEUES    32
 #define HISI_SAS_QUEUE_SLOTS 512
-#define HISI_SAS_MAX_ITCT_ENTRIES 2048
+#define HISI_SAS_MAX_ITCT_ENTRIES 1024
 #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
 #define HISI_SAS_RESET_BIT     0
 #define HISI_SAS_REJECT_CMD_BIT        1
@@ -342,7 +342,11 @@ struct hisi_sas_initial_fis {
 };
 
 struct hisi_sas_breakpoint {
-       u8      data[128];      /*io128 byte*/
+       u8      data[128];
+};
+
+struct hisi_sas_sata_breakpoint {
+       struct hisi_sas_breakpoint tag[32];
 };
 
 struct hisi_sas_sge {
index 254af67d87e1051baf84a3f62ab48b9a781de0e2..f49a131c04e4f2c80bd08d8e2dd709eb9d480020 100644 (file)
@@ -1613,7 +1613,7 @@ void hisi_sas_init_mem(struct hisi_hba *hisi_hba)
        s = max_command_entries * sizeof(struct hisi_sas_breakpoint);
        memset(hisi_hba->breakpoint, 0, s);
 
-       s = max_command_entries * sizeof(struct hisi_sas_breakpoint) * 2;
+       s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_sata_breakpoint);
        memset(hisi_hba->sata_breakpoint, 0, s);
 }
 EXPORT_SYMBOL_GPL(hisi_sas_init_mem);
@@ -1706,7 +1706,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
        if (!hisi_hba->initial_fis)
                goto err_out;
 
-       s = max_command_entries * sizeof(struct hisi_sas_breakpoint) * 2;
+       s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_sata_breakpoint);
        hisi_hba->sata_breakpoint = dma_alloc_coherent(dev, s,
                                &hisi_hba->sata_breakpoint_dma, GFP_KERNEL);
        if (!hisi_hba->sata_breakpoint)
@@ -1771,7 +1771,7 @@ void hisi_sas_free(struct hisi_hba *hisi_hba)
                                  hisi_hba->initial_fis,
                                  hisi_hba->initial_fis_dma);
 
-       s = max_command_entries * sizeof(struct hisi_sas_breakpoint) * 2;
+       s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_sata_breakpoint);
        if (hisi_hba->sata_breakpoint)
                dma_free_coherent(dev, s,
                                  hisi_hba->sata_breakpoint,
index 38eeba9192cb5df4ab302983abba10ef1a62d671..ac499e9645a2c0e1f6366738d4a54e1b82aee959 100644 (file)
 #define DMA_RX_STATUS_BUSY_OFF         0
 #define DMA_RX_STATUS_BUSY_MSK         (0x1 << DMA_RX_STATUS_BUSY_OFF)
 
-#define MAX_ITCT_HW                    4096 /* max the hw can support */
 #define DEFAULT_ITCT_HW                2048 /* reset value, not reprogrammed */
 #if (HISI_SAS_MAX_DEVICES > DEFAULT_ITCT_HW)
 #error Max ITCT exceeded
@@ -377,6 +376,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
        /* Global registers init */
        hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE,
                         (u32)((1ULL << hisi_hba->queue_count) - 1));
+       hisi_sas_write32(hisi_hba, CFG_MAX_TAG, 0xfff0400);
        hisi_sas_write32(hisi_hba, HGC_SAS_TXFAIL_RETRY_CTRL, 0x108);
        hisi_sas_write32(hisi_hba, CFG_1US_TIMER_TRSH, 0xd);
        hisi_sas_write32(hisi_hba, INT_COAL_EN, 0x1);