megaraid_sas: reduce memory footprints in kdump mode
[deliverable/linux.git] / drivers / scsi / megaraid / megaraid_sas_base.c
index 5c08568ccfbf3fe177fde645801dafaaae9c05ef..858820255dcb92217117eee9e3aefb07e9726798 100644 (file)
@@ -1838,7 +1838,7 @@ static int megasas_slave_configure(struct scsi_device *sdev)
        struct megasas_instance *instance;
 
        instance = megasas_lookup_instance(sdev->host->host_no);
-       if (instance->allow_fw_scan) {
+       if (instance->pd_list_not_supported) {
                if (sdev->channel < MEGASAS_MAX_PD_CHANNELS &&
                        sdev->type == TYPE_DISK) {
                        pd_index = (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
@@ -1874,7 +1874,8 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
                pd_index =
                        (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
                        sdev->id;
-               if ((instance->allow_fw_scan || instance->pd_list[pd_index].driveState ==
+               if ((instance->pd_list_not_supported ||
+                       instance->pd_list[pd_index].driveState ==
                        MR_PD_STATE_SYSTEM)) {
                        goto scan_target;
                }
@@ -4087,7 +4088,13 @@ megasas_get_pd_list(struct megasas_instance *instance)
 
        switch (ret) {
        case DCMD_FAILED:
-               megaraid_sas_kill_hba(instance);
+               dev_info(&instance->pdev->dev, "MR_DCMD_PD_LIST_QUERY "
+                       "failed/not supported by firmware\n");
+
+               if (instance->ctrl_context)
+                       megaraid_sas_kill_hba(instance);
+               else
+                       instance->pd_list_not_supported = 1;
                break;
        case DCMD_TIMEOUT:
 
@@ -5034,7 +5041,6 @@ static int megasas_init_fw(struct megasas_instance *instance)
        case PCI_DEVICE_ID_DELL_PERC5:
        default:
                instance->instancet = &megasas_instance_template_xscale;
-               instance->allow_fw_scan = 1;
                break;
        }
 
@@ -5755,13 +5761,6 @@ static int megasas_probe_one(struct pci_dev *pdev,
                break;
        }
 
-       instance->system_info_buf = pci_zalloc_consistent(pdev,
-                                       sizeof(struct MR_DRV_SYSTEM_INFO),
-                                       &instance->system_info_h);
-
-       if (!instance->system_info_buf)
-               dev_info(&instance->pdev->dev, "Can't allocate system info buffer\n");
-
        /* Crash dump feature related initialisation*/
        instance->drv_buf_index = 0;
        instance->drv_buf_alloc = 0;
@@ -5771,14 +5770,6 @@ static int megasas_probe_one(struct pci_dev *pdev,
        spin_lock_init(&instance->crashdump_lock);
        instance->crash_dump_buf = NULL;
 
-       if (!reset_devices)
-               instance->crash_dump_buf = pci_alloc_consistent(pdev,
-                                               CRASH_DMA_BUF_SIZE,
-                                               &instance->crash_dump_h);
-       if (!instance->crash_dump_buf)
-               dev_err(&pdev->dev, "Can't allocate Firmware "
-                       "crash dump DMA buffer\n");
-
        megasas_poll_wait_aen = 0;
        instance->flag_ieee = 0;
        instance->ev = NULL;
@@ -5797,11 +5788,26 @@ static int megasas_probe_one(struct pci_dev *pdev,
                goto fail_alloc_dma_buf;
        }
 
-       instance->pd_info = pci_alloc_consistent(pdev,
-               sizeof(struct MR_PD_INFO), &instance->pd_info_h);
+       if (!reset_devices) {
+               instance->system_info_buf = pci_zalloc_consistent(pdev,
+                                       sizeof(struct MR_DRV_SYSTEM_INFO),
+                                       &instance->system_info_h);
+               if (!instance->system_info_buf)
+                       dev_info(&instance->pdev->dev, "Can't allocate system info buffer\n");
+
+               instance->pd_info = pci_alloc_consistent(pdev,
+                       sizeof(struct MR_PD_INFO), &instance->pd_info_h);
 
-       if (!instance->pd_info)
-               dev_err(&instance->pdev->dev, "Failed to alloc mem for pd_info\n");
+               if (!instance->pd_info)
+                       dev_err(&instance->pdev->dev, "Failed to alloc mem for pd_info\n");
+
+               instance->crash_dump_buf = pci_alloc_consistent(pdev,
+                                               CRASH_DMA_BUF_SIZE,
+                                               &instance->crash_dump_h);
+               if (!instance->crash_dump_buf)
+                       dev_err(&pdev->dev, "Can't allocate Firmware "
+                               "crash dump DMA buffer\n");
+       }
 
        /*
         * Initialize locks and queues
@@ -6650,12 +6656,13 @@ out:
        }
 
        for (i = 0; i < ioc->sge_count; i++) {
-               if (kbuff_arr[i])
+               if (kbuff_arr[i]) {
                        dma_free_coherent(&instance->pdev->dev,
                                          le32_to_cpu(kern_sge32[i].length),
                                          kbuff_arr[i],
                                          le32_to_cpu(kern_sge32[i].phys_addr));
                        kbuff_arr[i] = NULL;
+               }
        }
 
        megasas_return_cmd(instance, cmd);
@@ -7166,6 +7173,16 @@ static int __init megasas_init(void)
 {
        int rval;
 
+       /*
+        * Booted in kdump kernel, minimize memory footprints by
+        * disabling few features
+        */
+       if (reset_devices) {
+               msix_vectors = 1;
+               rdpq_enable = 0;
+               dual_qdepth_disable = 1;
+       }
+
        /*
         * Announce driver version and other information
         */
This page took 0.027108 seconds and 5 git commands to generate.