From d3557fc8be11d25f316884581f487684f8e7dad3 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:30:09 +0530 Subject: megaraid_sas : Add separate function for setting up IRQs This patch will create separate functions for- 1) setting up IRQs for MSI-x interrupts 2) setting up IRQs for legacy interrupts 3) freeing up IRQs. and enable interrupts after adapter's initialization. The reason behind initialising adapter earlier is: by that time firmware is operational and can send interrupts, so better to use interrupt based interface to send internal DCMD to firmware instead of using polling method, since MFI frames' pool size is reduced and polling method does not free up MFI frame for fusion adapters, so sending more DCMDs with polled method may cause MFI frames's pool go out of frames and end up failing DCMD. Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 281 ++++++++++++++---------------- 1 file changed, 135 insertions(+), 146 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 890637fdd61e..5be9ce45bde8 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4414,6 +4414,107 @@ fail_alloc_cmds: return 1; } +/* + * megasas_setup_irqs_msix - register legacy interrupts. + * @instance: Adapter soft state + * + * Do not enable interrupt, only setup ISRs. + * + * Return 0 on success. + */ +static int +megasas_setup_irqs_ioapic(struct megasas_instance *instance) +{ + struct pci_dev *pdev; + + pdev = instance->pdev; + instance->irq_context[0].instance = instance; + instance->irq_context[0].MSIxIndex = 0; + if (request_irq(pdev->irq, instance->instancet->service_isr, + IRQF_SHARED, "megasas", &instance->irq_context[0])) { + dev_err(&instance->pdev->dev, + "Failed to register IRQ from %s %d\n", + __func__, __LINE__); + return -1; + } + return 0; +} + +/** + * megasas_setup_irqs_msix - register MSI-x interrupts. + * @instance: Adapter soft state + * @is_probe: Driver probe check + * + * Do not enable interrupt, only setup ISRs. + * + * Return 0 on success. + */ +static int +megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe) +{ + int i, j, cpu; + struct pci_dev *pdev; + + pdev = instance->pdev; + + /* Try MSI-x */ + cpu = cpumask_first(cpu_online_mask); + for (i = 0; i < instance->msix_vectors; i++) { + instance->irq_context[i].instance = instance; + instance->irq_context[i].MSIxIndex = i; + if (request_irq(instance->msixentry[i].vector, + instance->instancet->service_isr, 0, "megasas", + &instance->irq_context[i])) { + dev_err(&instance->pdev->dev, + "Failed to register IRQ for vector %d.\n", i); + for (j = 0; j < i; j++) { + if (smp_affinity_enable) + irq_set_affinity_hint( + instance->msixentry[j].vector, NULL); + free_irq(instance->msixentry[j].vector, + &instance->irq_context[j]); + } + /* Retry irq register for IO_APIC*/ + instance->msix_vectors = 0; + if (is_probe) + return megasas_setup_irqs_ioapic(instance); + else + return -1; + } + if (smp_affinity_enable) { + if (irq_set_affinity_hint(instance->msixentry[i].vector, + get_cpu_mask(cpu))) + dev_err(&instance->pdev->dev, + "Failed to set affinity hint" + " for cpu %d\n", cpu); + cpu = cpumask_next(cpu, cpu_online_mask); + } + } + return 0; +} + +/* + * megasas_destroy_irqs- unregister interrupts. + * @instance: Adapter soft state + * return: void + */ +static void +megasas_destroy_irqs(struct megasas_instance *instance) { + + int i; + + if (instance->msix_vectors) + for (i = 0; i < instance->msix_vectors; i++) { + if (smp_affinity_enable) + irq_set_affinity_hint( + instance->msixentry[i].vector, NULL); + free_irq(instance->msixentry[i].vector, + &instance->irq_context[i]); + } + else + free_irq(instance->pdev->irq, &instance->irq_context[0]); +} + /** * megasas_init_fw - Initializes the FW * @instance: Adapter soft state @@ -4552,11 +4653,16 @@ static int megasas_init_fw(struct megasas_instance *instance) else instance->msix_vectors = 0; - dev_info(&instance->pdev->dev, "[scsi%d]: FW supports" - "<%d> MSIX vector,Online CPUs: <%d>," - "Current MSIX <%d>\n", instance->host->host_no, - fw_msix_count, (unsigned int)num_online_cpus(), - instance->msix_vectors); + dev_info(&instance->pdev->dev, + "firmware supports msix\t: (%d)", fw_msix_count); + dev_info(&instance->pdev->dev, + "current msix/online cpus\t: (%d/%d)\n", + instance->msix_vectors, (unsigned int)num_online_cpus()); + + if (instance->msix_vectors ? + megasas_setup_irqs_msix(instance, 1) : + megasas_setup_irqs_ioapic(instance)) + goto fail_setup_irqs; } instance->ctrl_info = kzalloc(sizeof(struct megasas_ctrl_info), @@ -4573,6 +4679,7 @@ static int megasas_init_fw(struct megasas_instance *instance) /* Get operational params, sge flags, send init cmd to controller */ if (instance->instancet->init_adapter(instance)) goto fail_init_adapter; + instance->instancet->enable_intr(instance); printk(KERN_ERR "megasas: INIT adapter done\n"); @@ -4584,7 +4691,7 @@ static int megasas_init_fw(struct megasas_instance *instance) (MEGASAS_MAX_PD * sizeof(struct megasas_pd_list))); if (megasas_get_pd_list(instance) < 0) { printk(KERN_ERR "megasas: failed to get PD list\n"); - goto fail_init_adapter; + goto fail_get_pd_list; } memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); @@ -4733,7 +4840,14 @@ static int megasas_init_fw(struct megasas_instance *instance) return 0; +fail_get_pd_list: + instance->instancet->disable_intr(instance); fail_init_adapter: + megasas_destroy_irqs(instance); +fail_setup_irqs: + if (instance->msix_vectors) + pci_disable_msix(instance->pdev); + instance->msix_vectors = 0; fail_ready_state: kfree(instance->ctrl_info); instance->ctrl_info = NULL; @@ -5106,7 +5220,7 @@ fail_set_dma_mask: static int megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) { - int rval, pos, i, j, cpu; + int rval, pos; struct Scsi_Host *host; struct megasas_instance *instance; u16 control = 0; @@ -5315,55 +5429,6 @@ static int megasas_probe_one(struct pci_dev *pdev, } } -retry_irq_register: - /* - * Register IRQ - */ - if (instance->msix_vectors) { - cpu = cpumask_first(cpu_online_mask); - for (i = 0; i < instance->msix_vectors; i++) { - instance->irq_context[i].instance = instance; - instance->irq_context[i].MSIxIndex = i; - if (request_irq(instance->msixentry[i].vector, - instance->instancet->service_isr, 0, - "megasas", - &instance->irq_context[i])) { - printk(KERN_DEBUG "megasas: Failed to " - "register IRQ for vector %d.\n", i); - for (j = 0; j < i; j++) { - if (smp_affinity_enable) - irq_set_affinity_hint( - instance->msixentry[j].vector, NULL); - free_irq( - instance->msixentry[j].vector, - &instance->irq_context[j]); - } - /* Retry irq register for IO_APIC */ - instance->msix_vectors = 0; - goto retry_irq_register; - } - if (smp_affinity_enable) { - if (irq_set_affinity_hint(instance->msixentry[i].vector, - get_cpu_mask(cpu))) - dev_err(&instance->pdev->dev, - "Error setting affinity hint " - "for cpu %d\n", cpu); - cpu = cpumask_next(cpu, cpu_online_mask); - } - } - } else { - instance->irq_context[0].instance = instance; - instance->irq_context[0].MSIxIndex = 0; - if (request_irq(pdev->irq, instance->instancet->service_isr, - IRQF_SHARED, "megasas", - &instance->irq_context[0])) { - printk(KERN_DEBUG "megasas: Failed to register IRQ\n"); - goto fail_irq; - } - } - - instance->instancet->enable_intr(instance); - /* * Store instance in PCI softstate */ @@ -5410,17 +5475,8 @@ retry_irq_register: megasas_mgmt_info.max_index--; instance->instancet->disable_intr(instance); - if (instance->msix_vectors) - for (i = 0; i < instance->msix_vectors; i++) { - if (smp_affinity_enable) - irq_set_affinity_hint( - instance->msixentry[i].vector, NULL); - free_irq(instance->msixentry[i].vector, - &instance->irq_context[i]); - } - else - free_irq(instance->pdev->irq, &instance->irq_context[0]); -fail_irq: + megasas_destroy_irqs(instance); + if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) || (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || @@ -5428,9 +5484,9 @@ fail_irq: megasas_release_fusion(instance); else megasas_release_mfi(instance); - fail_init_mfi: if (instance->msix_vectors) pci_disable_msix(instance->pdev); +fail_init_mfi: fail_alloc_dma_buf: if (instance->evt_detail) pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), @@ -5558,7 +5614,6 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) { struct Scsi_Host *host; struct megasas_instance *instance; - int i; instance = pci_get_drvdata(pdev); host = instance->host; @@ -5583,16 +5638,8 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) pci_set_drvdata(instance->pdev, instance); instance->instancet->disable_intr(instance); - if (instance->msix_vectors) - for (i = 0; i < instance->msix_vectors; i++) { - if (smp_affinity_enable) - irq_set_affinity_hint( - instance->msixentry[i].vector, NULL); - free_irq(instance->msixentry[i].vector, - &instance->irq_context[i]); - } - else - free_irq(instance->pdev->irq, &instance->irq_context[0]); + megasas_destroy_irqs(instance); + if (instance->msix_vectors) pci_disable_msix(instance->pdev); @@ -5611,7 +5658,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) static int megasas_resume(struct pci_dev *pdev) { - int rval, i, j, cpu; + int rval; struct Scsi_Host *host; struct megasas_instance *instance; @@ -5681,50 +5728,10 @@ megasas_resume(struct pci_dev *pdev) tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, (unsigned long)instance); - /* - * Register IRQ - */ - if (instance->msix_vectors) { - cpu = cpumask_first(cpu_online_mask); - for (i = 0 ; i < instance->msix_vectors; i++) { - instance->irq_context[i].instance = instance; - instance->irq_context[i].MSIxIndex = i; - if (request_irq(instance->msixentry[i].vector, - instance->instancet->service_isr, 0, - "megasas", - &instance->irq_context[i])) { - printk(KERN_DEBUG "megasas: Failed to " - "register IRQ for vector %d.\n", i); - for (j = 0; j < i; j++) { - if (smp_affinity_enable) - irq_set_affinity_hint( - instance->msixentry[j].vector, NULL); - free_irq( - instance->msixentry[j].vector, - &instance->irq_context[j]); - } - goto fail_irq; - } - - if (smp_affinity_enable) { - if (irq_set_affinity_hint(instance->msixentry[i].vector, - get_cpu_mask(cpu))) - dev_err(&instance->pdev->dev, "Error " - "setting affinity hint for cpu " - "%d\n", cpu); - cpu = cpumask_next(cpu, cpu_online_mask); - } - } - } else { - instance->irq_context[0].instance = instance; - instance->irq_context[0].MSIxIndex = 0; - if (request_irq(pdev->irq, instance->instancet->service_isr, - IRQF_SHARED, "megasas", - &instance->irq_context[0])) { - printk(KERN_DEBUG "megasas: Failed to register IRQ\n"); - goto fail_irq; - } - } + if (instance->msix_vectors ? + megasas_setup_irqs_msix(instance, 0) : + megasas_setup_irqs_ioapic(instance)) + goto fail_init_mfi; /* Re-launch SR-IOV heartbeat timer */ if (instance->requestorId) { @@ -5748,7 +5755,6 @@ megasas_resume(struct pci_dev *pdev) return 0; -fail_irq: fail_init_mfi: if (instance->evt_detail) pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), @@ -5829,16 +5835,8 @@ static void megasas_detach_one(struct pci_dev *pdev) instance->instancet->disable_intr(instance); - if (instance->msix_vectors) - for (i = 0; i < instance->msix_vectors; i++) { - if (smp_affinity_enable) - irq_set_affinity_hint( - instance->msixentry[i].vector, NULL); - free_irq(instance->msixentry[i].vector, - &instance->irq_context[i]); - } - else - free_irq(instance->pdev->irq, &instance->irq_context[0]); + megasas_destroy_irqs(instance); + if (instance->msix_vectors) pci_disable_msix(instance->pdev); @@ -5912,23 +5910,14 @@ static void megasas_detach_one(struct pci_dev *pdev) */ static void megasas_shutdown(struct pci_dev *pdev) { - int i; struct megasas_instance *instance = pci_get_drvdata(pdev); instance->unload = 1; megasas_flush_cache(instance); megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); instance->instancet->disable_intr(instance); - if (instance->msix_vectors) - for (i = 0; i < instance->msix_vectors; i++) { - if (smp_affinity_enable) - irq_set_affinity_hint( - instance->msixentry[i].vector, NULL); - free_irq(instance->msixentry[i].vector, - &instance->irq_context[i]); - } - else - free_irq(instance->pdev->irq, &instance->irq_context[0]); + megasas_destroy_irqs(instance); + if (instance->msix_vectors) pci_disable_msix(instance->pdev); } -- cgit v1.2.3-59-g8ed1b From 9b828182866d30f4a27f355d5e9bee95cf35ca46 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:30:24 +0530 Subject: megaraid_sas : Add separate function for refiring MFI commands This patch will add separate function for refiring MFI commands in Fusion adapters's OCR code. Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 80 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 41 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 5a0800d19970..58b96f9e3bce 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -2511,6 +2511,43 @@ void megasas_reset_reply_desc(struct megasas_instance *instance) reply_desc->Words = ULLONG_MAX; } +/* + * megasas_refire_mgmt_cmd : Re-fire management commands + * @instance: Controller's soft instance +*/ +void megasas_refire_mgmt_cmd(struct megasas_instance *instance) +{ + int j; + struct megasas_cmd_fusion *cmd_fusion; + struct fusion_context *fusion; + struct megasas_cmd *cmd_mfi; + union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc; + u16 smid; + + fusion = instance->ctrl_context; + + /* Re-fire management commands. + * Do not traverse complet MPT frame pool. Start from max_scsi_cmds. + */ + for (j = instance->max_scsi_cmds ; j < instance->max_fw_cmds; j++) { + cmd_fusion = fusion->cmd_list[j]; + cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; + smid = le16_to_cpu(cmd_mfi->context.smid); + + if (!smid) + continue; + req_desc = megasas_get_request_descriptor + (instance, smid - 1); + if (req_desc && (cmd_mfi->frame->dcmd.opcode != + cpu_to_le32(MR_DCMD_LD_MAP_GET_INFO))) { + instance->instancet->fire_cmd(instance, + req_desc->u.low, req_desc->u.high, + instance->reg_set); + } else + megasas_return_cmd(instance, cmd_mfi); + } +} + /* Check for a second path that is currently UP */ int megasas_check_mpio_paths(struct megasas_instance *instance, struct scsi_cmnd *scmd) @@ -2538,12 +2575,10 @@ out: /* Core fusion reset function */ int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout) { - int retval = SUCCESS, i, j, retry = 0, convert = 0; + int retval = SUCCESS, i, retry = 0, convert = 0; struct megasas_instance *instance; struct megasas_cmd_fusion *cmd_fusion; struct fusion_context *fusion; - struct megasas_cmd *cmd_mfi; - union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc; u32 host_diag, abs_state, status_reg, reset_adapter; u32 io_timeout_in_crash_mode = 0; @@ -2790,44 +2825,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout) continue; } - /* Re-fire management commands */ - for (j = 0 ; j < instance->max_fw_cmds; j++) { - cmd_fusion = fusion->cmd_list[j]; - if (cmd_fusion->sync_cmd_idx != - (u32)ULONG_MAX) { - cmd_mfi = - instance-> - cmd_list[cmd_fusion->sync_cmd_idx]; - if (cmd_mfi->frame->dcmd.opcode == - cpu_to_le32(MR_DCMD_LD_MAP_GET_INFO)) { - megasas_return_mfi_mpt_pthr(instance, cmd_mfi, cmd_fusion); - } else { - req_desc = - megasas_get_request_descriptor( - instance, - cmd_mfi->context.smid - -1); - if (!req_desc) { - printk(KERN_WARNING - "req_desc NULL" - " for scsi%d\n", - instance->host->host_no); - /* Return leaked MPT - frame */ - megasas_return_cmd_fusion(instance, cmd_fusion); - } else { - instance->instancet-> - fire_cmd(instance, - req_desc-> - u.low, - req_desc-> - u.high, - instance-> - reg_set); - } - } - } - } + megasas_refire_mgmt_cmd(instance); if (megasas_get_ctrl_info(instance)) { dev_info(&instance->pdev->dev, -- cgit v1.2.3-59-g8ed1b From 4a5c814d933911bcbeb33e238e1e427baf0802b2 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:30:39 +0530 Subject: megaraid_sas : Add separate functions for building sysPD IOs and non RW LDIOs Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Tomas Henzl Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 10 +- drivers/scsi/megaraid/megaraid_sas_base.c | 4 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 230 ++++++++++++++++------------ 3 files changed, 138 insertions(+), 106 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 14e5c7cea929..bdcf2b69778d 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1864,9 +1864,13 @@ struct megasas_instance_template { #define MEGASAS_IS_LOGICAL(scp) \ (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1 -#define MEGASAS_DEV_INDEX(inst, scp) \ - ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \ - scp->device->id +#define MEGASAS_DEV_INDEX(scp) \ + (((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \ + scp->device->id) + +#define MEGASAS_PD_INDEX(scp) \ + ((scp->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) + \ + scp->device->id) struct megasas_cmd { diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 5be9ce45bde8..1bd32721131d 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1196,7 +1196,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, struct megasas_pthru_frame *pthru; is_logical = MEGASAS_IS_LOGICAL(scp); - device_id = MEGASAS_DEV_INDEX(instance, scp); + device_id = MEGASAS_DEV_INDEX(scp); pthru = (struct megasas_pthru_frame *)cmd->frame; if (scp->sc_data_direction == PCI_DMA_TODEVICE) @@ -1294,7 +1294,7 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, u16 flags = 0; struct megasas_io_frame *ldio; - device_id = MEGASAS_DEV_INDEX(instance, scp); + device_id = MEGASAS_DEV_INDEX(scp); ldio = (struct megasas_io_frame *)cmd->frame; if (scp->sc_data_direction == PCI_DMA_TODEVICE) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 58b96f9e3bce..d38f85e6f26e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -1497,7 +1497,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, struct MR_DRV_RAID_MAP_ALL *local_map_ptr; u8 *raidLUN; - device_id = MEGASAS_DEV_INDEX(instance, scp); + device_id = MEGASAS_DEV_INDEX(scp); fusion = instance->ctrl_context; @@ -1650,23 +1650,19 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, } /** - * megasas_build_dcdb_fusion - Prepares IOs to devices + * megasas_build_ld_nonrw_fusion - prepares non rw ios for virtual disk * @instance: Adapter soft state * @scp: SCSI command * @cmd: Command to be prepared * - * Prepares the io_request frame for non-io cmds + * Prepares the io_request frame for non-rw io cmds for vd. */ -static void -megasas_build_dcdb_fusion(struct megasas_instance *instance, - struct scsi_cmnd *scmd, - struct megasas_cmd_fusion *cmd) +static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance, + struct scsi_cmnd *scmd, struct megasas_cmd_fusion *cmd) { u32 device_id; struct MPI2_RAID_SCSI_IO_REQUEST *io_request; u16 pd_index = 0; - u16 os_timeout_value; - u16 timeout_limit; struct MR_DRV_RAID_MAP_ALL *local_map_ptr; struct fusion_context *fusion = instance->ctrl_context; u8 span, physArm; @@ -1674,97 +1670,48 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, u32 ld, arRef, pd; struct MR_LD_RAID *raid; struct RAID_CONTEXT *pRAID_Context; + u8 fp_possible = 1; io_request = cmd->io_request; - device_id = MEGASAS_DEV_INDEX(instance, scmd); - pd_index = (scmd->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) - +scmd->device->id; + device_id = MEGASAS_DEV_INDEX(scmd); + pd_index = MEGASAS_PD_INDEX(scmd); local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; - io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); + /* get RAID_Context pointer */ + pRAID_Context = &io_request->RaidContext; + /* Check with FW team */ + pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id); + pRAID_Context->regLockRowLBA = 0; + pRAID_Context->regLockLength = 0; - if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS && - instance->pd_list[pd_index].driveState == MR_PD_STATE_SYSTEM) { - if (fusion->fast_path_io) - io_request->DevHandle = - local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl; - io_request->RaidContext.RAIDFlags = - MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD - << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT; - cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle; - cmd->request_desc->SCSIIO.MSIxIndex = - instance->msix_vectors ? - raw_smp_processor_id() % - instance->msix_vectors : - 0; - os_timeout_value = scmd->request->timeout / HZ; - - if (instance->secure_jbod_support && - (megasas_cmd_type(scmd) == NON_READ_WRITE_SYSPDIO)) { - /* system pd firmware path */ - io_request->Function = - MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST; - cmd->request_desc->SCSIIO.RequestFlags = - (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); - io_request->RaidContext.timeoutValue = - cpu_to_le16(os_timeout_value); - } else { - /* system pd Fast Path */ - io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; - io_request->RaidContext.regLockFlags = 0; - io_request->RaidContext.regLockRowLBA = 0; - io_request->RaidContext.regLockLength = 0; - timeout_limit = (scmd->device->type == TYPE_DISK) ? - 255 : 0xFFFF; - io_request->RaidContext.timeoutValue = - cpu_to_le16((os_timeout_value > timeout_limit) ? - timeout_limit : os_timeout_value); - if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) - io_request->IoFlags |= - cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH); - - cmd->request_desc->SCSIIO.RequestFlags = - (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); - } - } else { - if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS) - goto NonFastPath; - - /* - * For older firmware, Driver should not access ldTgtIdToLd - * beyond index 127 and for Extended VD firmware, ldTgtIdToLd - * should not go beyond 255. - */ - - if ((!fusion->fast_path_io) || - (device_id >= instance->fw_supported_vd_count)) - goto NonFastPath; + if (fusion->fast_path_io && ( + device_id < instance->fw_supported_vd_count)) { ld = MR_TargetIdToLdGet(device_id, local_map_ptr); - if (ld >= instance->fw_supported_vd_count) - goto NonFastPath; + fp_possible = 0; raid = MR_LdRaidGet(ld, local_map_ptr); - - /* check if this LD is FP capable */ if (!(raid->capability.fpNonRWCapable)) - /* not FP capable, send as non-FP */ - goto NonFastPath; + fp_possible = 0; + } else + fp_possible = 0; - /* get RAID_Context pointer */ - pRAID_Context = &io_request->RaidContext; + if (!fp_possible) { + io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST; + io_request->DevHandle = cpu_to_le16(device_id); + io_request->LUN[1] = scmd->device->lun; + pRAID_Context->timeoutValue = + cpu_to_le16 (scmd->request->timeout / HZ); + cmd->request_desc->SCSIIO.RequestFlags = + (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + } else { /* set RAID context values */ - pRAID_Context->regLockFlags = REGION_TYPE_SHARED_READ; - pRAID_Context->timeoutValue = cpu_to_le16(raid->fpIoTimeoutForLd); - pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id); - pRAID_Context->regLockRowLBA = 0; - pRAID_Context->regLockLength = 0; - pRAID_Context->configSeqNum = raid->seqNum; + pRAID_Context->configSeqNum = raid->seqNum; + pRAID_Context->regLockFlags = REGION_TYPE_SHARED_READ; + pRAID_Context->timeoutValue = cpu_to_le16(raid->fpIoTimeoutForLd); /* get the DevHandle for the PD (since this is fpNonRWCapable, this is a single disk RAID0) */ @@ -1776,7 +1723,7 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, /* build request descriptor */ cmd->request_desc->SCSIIO.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); cmd->request_desc->SCSIIO.DevHandle = devHandle; /* populate the LUN field */ @@ -1785,18 +1732,87 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, /* build the raidScsiIO structure */ io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; io_request->DevHandle = devHandle; + } +} - return; +/** + * megasas_build_syspd_fusion - prepares rw/non-rw ios for syspd + * @instance: Adapter soft state + * @scp: SCSI command + * @cmd: Command to be prepared + * @fp_possible: parameter to detect fast path or firmware path io. + * + * Prepares the io_request frame for rw/non-rw io cmds for syspds + */ +static void +megasas_build_syspd_fusion(struct megasas_instance *instance, + struct scsi_cmnd *scmd, struct megasas_cmd_fusion *cmd, u8 fp_possible) +{ + u32 device_id; + struct MPI2_RAID_SCSI_IO_REQUEST *io_request; + u16 pd_index = 0; + u16 os_timeout_value; + u16 timeout_limit; + struct MR_DRV_RAID_MAP_ALL *local_map_ptr; + struct RAID_CONTEXT *pRAID_Context; + struct fusion_context *fusion = instance->ctrl_context; + + device_id = MEGASAS_DEV_INDEX(scmd); + pd_index = MEGASAS_PD_INDEX(scmd); + os_timeout_value = scmd->request->timeout / HZ; -NonFastPath: + io_request = cmd->io_request; + /* get RAID_Context pointer */ + pRAID_Context = &io_request->RaidContext; + io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); + io_request->LUN[1] = scmd->device->lun; + pRAID_Context->RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD + << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT; + + pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id); + pRAID_Context->configSeqNum = 0; + local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; + io_request->DevHandle = + local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl; + + cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle; + cmd->request_desc->SCSIIO.MSIxIndex = + instance->msix_vectors ? + (raw_smp_processor_id() % instance->msix_vectors) : 0; + + + if (!fp_possible) { + /* system pd firmware path */ io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST; - io_request->DevHandle = cpu_to_le16(device_id); cmd->request_desc->SCSIIO.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + pRAID_Context->timeoutValue = cpu_to_le16(os_timeout_value); + } else { + /* system pd Fast Path */ + io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; + pRAID_Context->regLockFlags = 0; + pRAID_Context->regLockRowLBA = 0; + pRAID_Context->regLockLength = 0; + timeout_limit = (scmd->device->type == TYPE_DISK) ? + 255 : 0xFFFF; + pRAID_Context->timeoutValue = + cpu_to_le16((os_timeout_value > timeout_limit) ? + timeout_limit : os_timeout_value); + if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || + (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { + cmd->request_desc->SCSIIO.RequestFlags |= + (MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK << + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + pRAID_Context->Type = MPI2_TYPE_CUDA; + pRAID_Context->nseg = 0x1; + io_request->IoFlags |= + cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH); + } + cmd->request_desc->SCSIIO.RequestFlags = + (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY << + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); } - io_request->RaidContext.VirtualDiskTgtId = cpu_to_le16(device_id); - int_to_scsilun(scmd->device->lun, (struct scsi_lun *)io_request->LUN); } /** @@ -1813,11 +1829,10 @@ megasas_build_io_fusion(struct megasas_instance *instance, struct scsi_cmnd *scp, struct megasas_cmd_fusion *cmd) { - u32 device_id, sge_count; + u32 sge_count; + u8 cmd_type; struct MPI2_RAID_SCSI_IO_REQUEST *io_request = cmd->io_request; - device_id = MEGASAS_DEV_INDEX(instance, scp); - /* Zero out some fields so they don't get reused */ memset(io_request->LUN, 0x0, 8); io_request->CDB.EEDP32.PrimaryReferenceTag = 0; @@ -1837,10 +1852,24 @@ megasas_build_io_fusion(struct megasas_instance *instance, */ io_request->IoFlags = cpu_to_le16(scp->cmd_len); - if (megasas_cmd_type(scp) == READ_WRITE_LDIO) + switch (cmd_type = megasas_cmd_type(scp)) { + case READ_WRITE_LDIO: megasas_build_ldio_fusion(instance, scp, cmd); - else - megasas_build_dcdb_fusion(instance, scp, cmd); + break; + case NON_READ_WRITE_LDIO: + megasas_build_ld_nonrw_fusion(instance, scp, cmd); + break; + case READ_WRITE_SYSPDIO: + case NON_READ_WRITE_SYSPDIO: + if (instance->secure_jbod_support && + (cmd_type == NON_READ_WRITE_SYSPDIO)) + megasas_build_syspd_fusion(instance, scp, cmd, 0); + else + megasas_build_syspd_fusion(instance, scp, cmd, 1); + break; + default: + break; + } /* * Construct SGL @@ -2016,8 +2045,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) switch (scsi_io_req->Function) { case MPI2_FUNCTION_SCSI_IO_REQUEST: /*Fast Path IO.*/ /* Update load balancing info */ - device_id = MEGASAS_DEV_INDEX(instance, - cmd_fusion->scmd); + device_id = MEGASAS_DEV_INDEX(cmd_fusion->scmd); lbinfo = &fusion->load_balance_info[device_id]; if (cmd_fusion->scmd->SCp.Status & MEGASAS_LOAD_BALANCE_FLAG) { -- cgit v1.2.3-59-g8ed1b From f26ac3a1a5108df2bd1e30ee1c8bb6f7664929b5 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:30:54 +0530 Subject: megaraid_sas : Move controller's queue depth calculation in adapter specific function Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 1 + drivers/scsi/megaraid/megaraid_sas_base.c | 39 +++++++++++------------------ drivers/scsi/megaraid/megaraid_sas_fusion.c | 9 +++++++ 3 files changed, 25 insertions(+), 24 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index bdcf2b69778d..762de8ada155 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1084,6 +1084,7 @@ enum MR_SCSI_CMD_TYPE { #define MEGASAS_SKINNY_INT_CMDS 5 #define MEGASAS_FUSION_INTERNAL_CMDS 5 #define MEGASAS_FUSION_IOCTL_CMDS 3 +#define MEGASAS_MFI_IOCTL_CMDS 27 #define MEGASAS_MAX_MSIX_QUEUES 128 /* diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 1bd32721131d..dee61e8348fb 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4353,6 +4353,21 @@ megasas_init_adapter_mfi(struct megasas_instance *instance) instance->max_mfi_cmds = instance->max_fw_cmds; instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >> 0x10; + /* + * For MFI skinny adapters, MEGASAS_SKINNY_INT_CMDS commands + * are reserved for IOCTL + driver's internal DCMDs. + */ + if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || + (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) { + instance->max_scsi_cmds = (instance->max_fw_cmds - + MEGASAS_SKINNY_INT_CMDS); + sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS); + } else { + instance->max_scsi_cmds = (instance->max_fw_cmds - + MEGASAS_INT_CMDS); + sema_init(&instance->ioctl_sem, (MEGASAS_MFI_IOCTL_CMDS)); + } + /* * Create a pool of commands */ @@ -4788,30 +4803,6 @@ static int megasas_init_fw(struct megasas_instance *instance) if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) instance->max_sectors_per_req = tmp_sectors; - /* - * 1. For fusion adapters, 3 commands for IOCTL and 5 commands - * for driver's internal DCMDs. - * 2. For MFI skinny adapters, 5 commands for IOCTL + driver's - * internal DCMDs. - * 3. For rest of MFI adapters, 27 commands reserved for IOCTLs - * and 5 commands for drivers's internal DCMD. - */ - if (instance->ctrl_context) { - instance->max_scsi_cmds = instance->max_fw_cmds - - (MEGASAS_FUSION_INTERNAL_CMDS + - MEGASAS_FUSION_IOCTL_CMDS); - sema_init(&instance->ioctl_sem, MEGASAS_FUSION_IOCTL_CMDS); - } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) { - instance->max_scsi_cmds = instance->max_fw_cmds - - MEGASAS_SKINNY_INT_CMDS; - sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS); - } else { - instance->max_scsi_cmds = instance->max_fw_cmds - - MEGASAS_INT_CMDS; - sema_init(&instance->ioctl_sem, (MEGASAS_INT_CMDS - 5)); - } - /* Check for valid throttlequeuedepth module parameter */ if (throttlequeuedepth && throttlequeuedepth <= instance->max_scsi_cmds) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index d38f85e6f26e..3e9dd6a7d7d5 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -1060,6 +1060,15 @@ megasas_init_adapter_fusion(struct megasas_instance *instance) for (i = 0 ; i < count; i++) fusion->last_reply_idx[i] = 0; + /* + * For fusion adapters, 3 commands for IOCTL and 5 commands + * for driver's internal DCMDs. + */ + instance->max_scsi_cmds = instance->max_fw_cmds - + (MEGASAS_FUSION_INTERNAL_CMDS + + MEGASAS_FUSION_IOCTL_CMDS); + sema_init(&instance->ioctl_sem, MEGASAS_FUSION_IOCTL_CMDS); + /* * Allocate memory for descriptors * Create a pool of commands -- cgit v1.2.3-59-g8ed1b From d88da09a538d3a4b56fd1cc080983ae69cc2cee2 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:31:09 +0530 Subject: megaraid_sas : Enhanced few prints Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 49 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index dee61e8348fb..3e8b8b398288 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4091,12 +4091,11 @@ static void megasas_update_ext_vd_details(struct megasas_instance *instance) instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; } - dev_info(&instance->pdev->dev, "Firmware supports %d VD %d PD\n", - instance->fw_supported_vd_count, - instance->fw_supported_pd_count); - dev_info(&instance->pdev->dev, "Driver supports %d VD %d PD\n", - instance->drv_supported_vd_count, - instance->drv_supported_pd_count); + + dev_info(&instance->pdev->dev, + "firmware type\t: %s\n", + instance->supportmax256vd ? "Extended VD(240 VD)firmware" : + "Legacy(64 VD) firmware"); old_map_sz = sizeof(struct MR_FW_RAID_MAP) + (sizeof(struct MR_LD_SPAN_MAP) * @@ -4750,9 +4749,6 @@ static int megasas_init_fw(struct megasas_instance *instance) ctrl_info->adapterOperations2.supportUnevenSpans; if (instance->UnevenSpanSupport) { struct fusion_context *fusion = instance->ctrl_context; - - dev_info(&instance->pdev->dev, "FW supports: " - "UnevenSpanSupport=%x\n", instance->UnevenSpanSupport); if (MR_ValidateMapInfo(instance)) fusion->fast_path_io = 1; else @@ -4779,13 +4775,11 @@ static int megasas_init_fw(struct megasas_instance *instance) instance->crash_dump_drv_support = (instance->crash_dump_fw_support && instance->crash_dump_buf); - if (instance->crash_dump_drv_support) { - dev_info(&instance->pdev->dev, "Firmware Crash dump " - "feature is supported\n"); + if (instance->crash_dump_drv_support) megasas_set_crash_dump_params(instance, MR_CRASH_BUF_TURN_OFF); - } else { + else { if (instance->crash_dump_buf) pci_free_consistent(instance->pdev, CRASH_DMA_BUF_SIZE, @@ -4796,8 +4790,23 @@ static int megasas_init_fw(struct megasas_instance *instance) instance->secure_jbod_support = ctrl_info->adapterOperations3.supportSecurityonJBOD; - if (instance->secure_jbod_support) - dev_info(&instance->pdev->dev, "Firmware supports Secure JBOD\n"); + + dev_info(&instance->pdev->dev, + "pci id\t\t: (0x%04x)/(0x%04x)/(0x%04x)/(0x%04x)\n", + le16_to_cpu(ctrl_info->pci.vendor_id), + le16_to_cpu(ctrl_info->pci.device_id), + le16_to_cpu(ctrl_info->pci.sub_vendor_id), + le16_to_cpu(ctrl_info->pci.sub_device_id)); + dev_info(&instance->pdev->dev, "unevenspan support : %s\n", + instance->UnevenSpanSupport ? "yes" : "no"); + dev_info(&instance->pdev->dev, "disable ocr : %s\n", + instance->disableOnlineCtrlReset ? "yes" : "no"); + dev_info(&instance->pdev->dev, "firmware crash dump : %s\n", + instance->crash_dump_drv_support ? "yes" : "no"); + dev_info(&instance->pdev->dev, "secure jbod : %s\n", + instance->secure_jbod_support ? "yes" : "no"); + + instance->max_sectors_per_req = instance->max_num_sge * PAGE_SIZE / 512; if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) @@ -5233,16 +5242,6 @@ static int megasas_probe_one(struct pci_dev *pdev, } } - /* - * Announce PCI information - */ - printk(KERN_INFO "megasas: %#4.04x:%#4.04x:%#4.04x:%#4.04x: ", - pdev->vendor, pdev->device, pdev->subsystem_vendor, - pdev->subsystem_device); - - printk("bus %d:slot %d:func %d\n", - pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); - /* * PCI prepping: enable device set bus mastering and dma mask */ -- cgit v1.2.3-59-g8ed1b From 4026e9aac3ff108fd1885a7f05dd4b5a374b0bf8 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:31:24 +0530 Subject: megaraid_sas : Use Block layer tag support for internal command indexing megaraid_sas driver will use block layer provided tag for indexing internal MPT frames to get any unique MPT frame tied with tag. Each IO request submitted from SCSI mid layer will get associated MPT frame from MPT framepool (retrieved and return back using spinlock inside megaraid_sas driver's submission/completion call back). Getting MPT frame from MPT Frame pool is very expensive operation because of associated spin lock operation (spinlock overhead increase on multi NUMA node). This type of locking in driver is very expensive call considering each IO request need - Acquire and Release of the same lock. With this support, in IO path driver will directly provide the unique command index(which is based on block layer tag) and will get the MPT frame tied to the tag and this way driver can get rid off lock, which synchronizes the access to MPT frame pool while fetching and returning MPT frame from the pool. This support in driver provides siginificant performance improvement(on multi NUMA node system)on latest upstream with SCSI.MQ as well as on existing linux distributions. Here is the data for test executed at Avago- - IO Tool- FIO - 4 Socket SMC server. (4 NUMA node server) - 12 SSDs in JBOD mode . - 4K Rand READ, QD=32 - SCSI MQ x86_64 (Latest Upstream kernel) - upto 300% Performance Improvement. If IOs are running on single Node, perfromance gain is less, but as soon as increase number of nodes, performance improvement is significant. IOs running on all 4 NUMA nodes, with this patch applied IOPs observed was 1170K vs 344K IOPs seen without this patch. Logically, there are two parts of this patch- 1) Block layer tag support 2) changes in calling convention of return_cmd. part 2 will revert the changes done by patch- 90dc9d9 megaraid_sas : MFI MPT linked list corruption fix because changes done in part 1 has fixed the problem of MFI MPT linked list corruption. part 2 is very much dependent on part 1, so we decided to have single patch for these two logical changes. [jejb: remove chatty printk pointed out by hch] Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 13 +-- drivers/scsi/megaraid/megaraid_sas_base.c | 172 +++++++++------------------- drivers/scsi/megaraid/megaraid_sas_fusion.c | 151 ++++++------------------ drivers/scsi/megaraid/megaraid_sas_fusion.h | 5 - 4 files changed, 99 insertions(+), 242 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 762de8ada155..3751e58c7fae 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -153,6 +153,9 @@ #define MFI_FRAME_DIR_BOTH 0x0018 #define MFI_FRAME_IEEE 0x0020 +/* Driver internal */ +#define DRV_DCMD_POLLED_MODE 0x1 + /* * Definition for cmd_status */ @@ -1042,11 +1045,6 @@ struct megasas_ctrl_info { #define VD_EXT_DEBUG 0 -enum MR_MFI_MPT_PTHR_FLAGS { - MFI_MPT_DETACHED = 0, - MFI_LIST_ADDED = 1, - MFI_MPT_ATTACHED = 2, -}; enum MR_SCSI_CMD_TYPE { READ_WRITE_LDIO = 0, @@ -1889,10 +1887,7 @@ struct megasas_cmd { struct list_head list; struct scsi_cmnd *scmd; - - void *mpt_pthr_cmd_blocked; - atomic_t mfi_mpt_pthr; - u8 is_wait_event; + u8 flags; struct megasas_instance *instance; union { diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 3e8b8b398288..270e8f7131de 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -215,7 +215,6 @@ struct megasas_cmd *megasas_get_cmd(struct megasas_instance cmd = list_entry((&instance->cmd_pool)->next, struct megasas_cmd, list); list_del_init(&cmd->list); - atomic_set(&cmd->mfi_mpt_pthr, MFI_MPT_DETACHED); } else { printk(KERN_ERR "megasas: Command pool empty!\n"); } @@ -225,52 +224,41 @@ struct megasas_cmd *megasas_get_cmd(struct megasas_instance } /** - * __megasas_return_cmd - Return a cmd to free command pool + * megasas_return_cmd - Return a cmd to free command pool * @instance: Adapter soft state * @cmd: Command packet to be returned to free command pool */ inline void -__megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) +megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) { - /* - * Don't go ahead and free the MFI frame, if corresponding - * MPT frame is not freed(valid for only fusion adapters). - * In case of MFI adapters, anyways for any allocated MFI - * frame will have cmd->mfi_mpt_mpthr set to MFI_MPT_DETACHED + unsigned long flags; + u32 blk_tags; + struct megasas_cmd_fusion *cmd_fusion; + struct fusion_context *fusion = instance->ctrl_context; + + /* This flag is used only for fusion adapter. + * Wait for Interrupt for Polled mode DCMD */ - if (atomic_read(&cmd->mfi_mpt_pthr) != MFI_MPT_DETACHED) + if (cmd->flags & DRV_DCMD_POLLED_MODE) return; + spin_lock_irqsave(&instance->mfi_pool_lock, flags); + + if (fusion) { + blk_tags = instance->max_scsi_cmds + cmd->index; + cmd_fusion = fusion->cmd_list[blk_tags]; + megasas_return_cmd_fusion(instance, cmd_fusion); + } cmd->scmd = NULL; cmd->frame_count = 0; - cmd->is_wait_event = 0; - cmd->mpt_pthr_cmd_blocked = NULL; - - if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) && - (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) && - (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) && - (reset_devices)) + cmd->flags = 0; + if (!fusion && reset_devices) cmd->frame->hdr.cmd = MFI_CMD_INVALID; - - atomic_set(&cmd->mfi_mpt_pthr, MFI_LIST_ADDED); list_add(&cmd->list, (&instance->cmd_pool)->next); -} -/** - * megasas_return_cmd - Return a cmd to free command pool - * @instance: Adapter soft state - * @cmd: Command packet to be returned to free command pool - */ -inline void -megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) -{ - unsigned long flags; - - spin_lock_irqsave(&instance->mfi_pool_lock, flags); - __megasas_return_cmd(instance, cmd); spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); -} +} /** * The following functions are defined for xscale @@ -954,7 +942,6 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance, int ret = 0; cmd->cmd_status = ENODATA; - cmd->is_wait_event = 1; instance->instancet->issue_dcmd(instance, cmd); if (timeout) { ret = wait_event_timeout(instance->int_cmd_wait_q, @@ -1976,11 +1963,7 @@ out: new_affiliation_111_h); } - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return retval; } @@ -2147,11 +2130,7 @@ out: (MAX_LOGICAL_DRIVES + 1) * sizeof(struct MR_LD_VF_AFFILIATION), new_affiliation, new_affiliation_h); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return retval; } @@ -2219,9 +2198,13 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance, printk(KERN_WARNING "megasas: SR-IOV: Starting heartbeat for scsi%d\n", instance->host->host_no); - if (!megasas_issue_polled(instance, cmd)) { - retval = 0; - } else { + if (instance->ctrl_context && !instance->mask_interrupts) + retval = megasas_issue_blocked_cmd(instance, cmd, + MEGASAS_ROUTINE_WAIT_TIME_VF); + else + retval = megasas_issue_polled(instance, cmd); + + if (retval) { printk(KERN_WARNING "megasas: SR-IOV: MR_DCMD_CTRL_SHARED_HOST" "_MEM_ALLOC DCMD timed out for scsi%d\n", instance->host->host_no); @@ -2612,11 +2595,7 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd) instance->aen_cmd = NULL; - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); if ((instance->unload == 0) && ((instance->issuepend_done == 1))) { @@ -2978,8 +2957,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, "failed, status = 0x%x.\n", cmd->frame->hdr.cmd_status); else { - megasas_return_mfi_mpt_pthr(instance, - cmd, cmd->mpt_pthr_cmd_blocked); + megasas_return_cmd(instance, cmd); spin_unlock_irqrestore( instance->host->host_lock, flags); @@ -2987,8 +2965,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, } } else instance->map_id++; - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); + megasas_return_cmd(instance, cmd); /* * Set fast path IO to ZERO. @@ -3766,7 +3743,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance) cmd = instance->cmd_list[i]; memset(cmd, 0, sizeof(struct megasas_cmd)); cmd->index = i; - atomic_set(&cmd->mfi_mpt_pthr, MFI_LIST_ADDED); cmd->scmd = NULL; cmd->instance = instance; @@ -3874,11 +3850,7 @@ megasas_get_pd_list(struct megasas_instance *instance) MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST), ci, ci_h); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return ret; } @@ -3965,11 +3937,7 @@ megasas_get_ld_list(struct megasas_instance *instance) ci, ci_h); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return ret; } @@ -4050,11 +4018,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type) pci_free_consistent(instance->pdev, sizeof(struct MR_LD_TARGETID_LIST), ci, ci_h); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return ret; } @@ -4180,16 +4144,17 @@ megasas_get_ctrl_info(struct megasas_instance *instance) le32_to_cpus((u32 *)&ctrl_info->adapterOperations2); le32_to_cpus((u32 *)&ctrl_info->adapterOperations3); megasas_update_ext_vd_details(instance); + instance->is_imr = (ctrl_info->memory_size ? 0 : 1); + dev_info(&instance->pdev->dev, + "controller type\t: %s(%dMB)\n", + instance->is_imr ? "iMR" : "MR", + le16_to_cpu(ctrl_info->memory_size)); } pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info), ci, ci_h); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return ret; } @@ -4244,11 +4209,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance, else ret = megasas_issue_polled(instance, cmd); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return ret; } @@ -4731,17 +4692,6 @@ static int megasas_init_fw(struct megasas_instance *instance) tmp_sectors = min_t(u32, max_sectors_1 , max_sectors_2); - /*Check whether controller is iMR or MR */ - if (ctrl_info->memory_size) { - instance->is_imr = 0; - dev_info(&instance->pdev->dev, "Controller type: MR," - "Memory size is: %dMB\n", - le16_to_cpu(ctrl_info->memory_size)); - } else { - instance->is_imr = 1; - dev_info(&instance->pdev->dev, - "Controller type: iMR\n"); - } instance->disableOnlineCtrlReset = ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset; instance->mpio = ctrl_info->adapterOperations2.mpio; @@ -4946,11 +4896,7 @@ megasas_get_seq_num(struct megasas_instance *instance, pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info), el_info, el_info_h); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return 0; } @@ -5115,6 +5061,7 @@ static int megasas_start_aen(struct megasas_instance *instance) static int megasas_io_attach(struct megasas_instance *instance) { struct Scsi_Host *host = instance->host; + u32 error; /* * Export parameters required by SCSI mid-layer @@ -5164,12 +5111,21 @@ static int megasas_io_attach(struct megasas_instance *instance) host->hostt->eh_device_reset_handler = NULL; host->hostt->eh_bus_reset_handler = NULL; } + error = scsi_init_shared_tag_map(host, host->can_queue); + if (error) { + dev_err(&instance->pdev->dev, + "Failed to shared tag from %s %d\n", + __func__, __LINE__); + return -ENODEV; + } /* * Notify the mid-layer about the new controller */ if (scsi_add_host(host, &instance->pdev->dev)) { - printk(KERN_DEBUG "megasas: scsi_add_host failed\n"); + dev_err(&instance->pdev->dev, + "Failed to add host from %s %d\n", + __func__, __LINE__); return -ENODEV; } @@ -5287,8 +5243,6 @@ static int megasas_probe_one(struct pci_dev *pdev, fusion = instance->ctrl_context; memset(fusion, 0, ((1 << PAGE_SHIFT) << instance->ctrl_context_pages)); - INIT_LIST_HEAD(&fusion->cmd_pool); - spin_lock_init(&fusion->mpt_pool_lock); } break; default: /* For all other supported controllers */ @@ -5533,11 +5487,7 @@ static void megasas_flush_cache(struct megasas_instance *instance) dev_err(&instance->pdev->dev, "Command timedout" " from %s\n", __func__); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return; } @@ -5584,11 +5534,7 @@ static void megasas_shutdown_controller(struct megasas_instance *instance, dev_err(&instance->pdev->dev, "Command timedout" "from %s\n", __func__); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return; } @@ -6190,11 +6136,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, kbuff_arr[i] = NULL; } - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return error; } diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 3e9dd6a7d7d5..6f07f9119066 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -57,6 +57,7 @@ #include "megaraid_sas_fusion.h" #include "megaraid_sas.h" + extern void megasas_free_cmds(struct megasas_instance *instance); extern struct megasas_cmd *megasas_get_cmd(struct megasas_instance *instance); @@ -156,28 +157,15 @@ megasas_clear_intr_fusion(struct megasas_register_set __iomem *regs) * megasas_get_cmd_fusion - Get a command from the free pool * @instance: Adapter soft state * - * Returns a free command from the pool + * Returns a blk_tag indexed mpt frame */ -struct megasas_cmd_fusion *megasas_get_cmd_fusion(struct megasas_instance - *instance) +inline struct megasas_cmd_fusion *megasas_get_cmd_fusion(struct megasas_instance + *instance, u32 blk_tag) { - unsigned long flags; - struct fusion_context *fusion = - (struct fusion_context *)instance->ctrl_context; - struct megasas_cmd_fusion *cmd = NULL; - - spin_lock_irqsave(&fusion->mpt_pool_lock, flags); - - if (!list_empty(&fusion->cmd_pool)) { - cmd = list_entry((&fusion->cmd_pool)->next, - struct megasas_cmd_fusion, list); - list_del_init(&cmd->list); - } else { - printk(KERN_ERR "megasas: Command pool (fusion) empty!\n"); - } + struct fusion_context *fusion; - spin_unlock_irqrestore(&fusion->mpt_pool_lock, flags); - return cmd; + fusion = instance->ctrl_context; + return fusion->cmd_list[blk_tag]; } /** @@ -188,45 +176,8 @@ struct megasas_cmd_fusion *megasas_get_cmd_fusion(struct megasas_instance inline void megasas_return_cmd_fusion(struct megasas_instance *instance, struct megasas_cmd_fusion *cmd) { - unsigned long flags; - struct fusion_context *fusion = - (struct fusion_context *)instance->ctrl_context; - - spin_lock_irqsave(&fusion->mpt_pool_lock, flags); - cmd->scmd = NULL; - cmd->sync_cmd_idx = (u32)ULONG_MAX; memset(cmd->io_request, 0, sizeof(struct MPI2_RAID_SCSI_IO_REQUEST)); - list_add(&cmd->list, (&fusion->cmd_pool)->next); - - spin_unlock_irqrestore(&fusion->mpt_pool_lock, flags); -} - -/** - * megasas_return_mfi_mpt_pthr - Return a mfi and mpt to free command pool - * @instance: Adapter soft state - * @cmd_mfi: MFI Command packet to be returned to free command pool - * @cmd_mpt: MPT Command packet to be returned to free command pool - */ -inline void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance, - struct megasas_cmd *cmd_mfi, - struct megasas_cmd_fusion *cmd_fusion) -{ - unsigned long flags; - - /* - * TO DO: optimize this code and use only one lock instead of two - * locks being used currently- mpt_pool_lock is acquired - * inside mfi_pool_lock - */ - spin_lock_irqsave(&instance->mfi_pool_lock, flags); - megasas_return_cmd_fusion(instance, cmd_fusion); - if (atomic_read(&cmd_mfi->mfi_mpt_pthr) != MFI_MPT_ATTACHED) - dev_err(&instance->pdev->dev, "Possible bug from %s %d\n", - __func__, __LINE__); - atomic_set(&cmd_mfi->mfi_mpt_pthr, MFI_MPT_DETACHED); - __megasas_return_cmd(instance, cmd_mfi); - spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); } /** @@ -326,7 +277,6 @@ megasas_free_cmds_fusion(struct megasas_instance *instance) kfree(fusion->cmd_list); fusion->cmd_list = NULL; - INIT_LIST_HEAD(&fusion->cmd_pool); } /** @@ -535,7 +485,9 @@ megasas_alloc_cmds_fusion(struct megasas_instance *instance) memset(cmd, 0, sizeof(struct megasas_cmd_fusion)); cmd->index = i + 1; cmd->scmd = NULL; - cmd->sync_cmd_idx = (u32)ULONG_MAX; /* Set to Invalid */ + cmd->sync_cmd_idx = (i >= instance->max_scsi_cmds) ? + (i - instance->max_scsi_cmds) : + (u32)ULONG_MAX; /* Set to Invalid */ cmd->instance = instance; cmd->io_request = (struct MPI2_RAID_SCSI_IO_REQUEST *) @@ -543,8 +495,6 @@ megasas_alloc_cmds_fusion(struct megasas_instance *instance) memset(cmd->io_request, 0, sizeof(struct MPI2_RAID_SCSI_IO_REQUEST)); cmd->io_request_phys_addr = io_req_base_phys + offset; - - list_add_tail(&cmd->list, &fusion->cmd_pool); } /* @@ -605,12 +555,8 @@ wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, msleep(20); } - if (frame_hdr->cmd_status == 0xff) { - if (fusion) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); + if (frame_hdr->cmd_status == 0xff) return -ETIME; - } return 0; } @@ -820,11 +766,7 @@ megasas_get_ld_map_info(struct megasas_instance *instance) else ret = megasas_issue_polled(instance, cmd); - if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) - megasas_return_mfi_mpt_pthr(instance, cmd, - cmd->mpt_pthr_cmd_blocked); - else - megasas_return_cmd(instance, cmd); + megasas_return_cmd(instance, cmd); return ret; } @@ -1953,9 +1895,7 @@ megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance, fusion = instance->ctrl_context; - cmd = megasas_get_cmd_fusion(instance); - if (!cmd) - return SCSI_MLQUEUE_HOST_BUSY; + cmd = megasas_get_cmd_fusion(instance, scmd->request->tag); index = cmd->index; @@ -2013,6 +1953,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) union desc_value d_val; struct LD_LOAD_BALANCE_INFO *lbinfo; int threshold_reply_count = 0; + struct scsi_cmnd *scmd_local = NULL; fusion = instance->ctrl_context; @@ -2048,13 +1989,14 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) if (cmd_fusion->scmd) cmd_fusion->scmd->SCp.ptr = NULL; + scmd_local = cmd_fusion->scmd; status = scsi_io_req->RaidContext.status; extStatus = scsi_io_req->RaidContext.exStatus; switch (scsi_io_req->Function) { case MPI2_FUNCTION_SCSI_IO_REQUEST: /*Fast Path IO.*/ /* Update load balancing info */ - device_id = MEGASAS_DEV_INDEX(cmd_fusion->scmd); + device_id = MEGASAS_DEV_INDEX(scmd_local); lbinfo = &fusion->load_balance_info[device_id]; if (cmd_fusion->scmd->SCp.Status & MEGASAS_LOAD_BALANCE_FLAG) { @@ -2072,29 +2014,25 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) case MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST: /* LD-IO Path */ /* Map the FW Cmd Status */ map_cmd_status(cmd_fusion, status, extStatus); - scsi_dma_unmap(cmd_fusion->scmd); - cmd_fusion->scmd->scsi_done(cmd_fusion->scmd); scsi_io_req->RaidContext.status = 0; scsi_io_req->RaidContext.exStatus = 0; megasas_return_cmd_fusion(instance, cmd_fusion); + scsi_dma_unmap(scmd_local); + scmd_local->scsi_done(scmd_local); atomic_dec(&instance->fw_outstanding); break; case MEGASAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST: /*MFI command */ cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; - if (!cmd_mfi->mpt_pthr_cmd_blocked) { - if (megasas_dbg_lvl == 5) - dev_info(&instance->pdev->dev, - "freeing mfi/mpt pass-through " - "from %s %d\n", - __func__, __LINE__); - megasas_return_mfi_mpt_pthr(instance, cmd_mfi, - cmd_fusion); - } - - megasas_complete_cmd(instance, cmd_mfi, DID_OK); - cmd_fusion->flags = 0; + /* Poll mode. Dummy free. + * In case of Interrupt mode, caller has reverse check. + */ + if (cmd_mfi->flags & DRV_DCMD_POLLED_MODE) { + cmd_mfi->flags &= ~DRV_DCMD_POLLED_MODE; + megasas_return_cmd(instance, cmd_mfi); + } else + megasas_complete_cmd(instance, cmd_mfi, DID_OK); break; } @@ -2254,27 +2192,14 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance, struct megasas_cmd_fusion *cmd; struct fusion_context *fusion; struct megasas_header *frame_hdr = &mfi_cmd->frame->hdr; - u32 opcode; - cmd = megasas_get_cmd_fusion(instance); - if (!cmd) - return 1; + fusion = instance->ctrl_context; + + cmd = megasas_get_cmd_fusion(instance, + instance->max_scsi_cmds + mfi_cmd->index); /* Save the smid. To be used for returning the cmd */ mfi_cmd->context.smid = cmd->index; - cmd->sync_cmd_idx = mfi_cmd->index; - - /* Set this only for Blocked commands */ - opcode = le32_to_cpu(mfi_cmd->frame->dcmd.opcode); - if ((opcode == MR_DCMD_LD_MAP_GET_INFO) - && (mfi_cmd->frame->dcmd.mbox.b[1] == 1)) - mfi_cmd->is_wait_event = 1; - - if (opcode == MR_DCMD_CTRL_EVENT_WAIT) - mfi_cmd->is_wait_event = 1; - - if (mfi_cmd->is_wait_event) - mfi_cmd->mpt_pthr_cmd_blocked = cmd; /* * For cmds where the flag is set, store the flag and check @@ -2283,9 +2208,8 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance, */ if (frame_hdr->flags & cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE)) - cmd->flags = MFI_FRAME_DONT_POST_IN_REPLY_QUEUE; + mfi_cmd->flags |= DRV_DCMD_POLLED_MODE; - fusion = instance->ctrl_context; io_req = cmd->io_request; if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || @@ -2364,7 +2288,6 @@ megasas_issue_dcmd_fusion(struct megasas_instance *instance, printk(KERN_ERR "Couldn't issue MFI pass thru cmd\n"); return; } - atomic_set(&cmd->mfi_mpt_pthr, MFI_MPT_ATTACHED); instance->instancet->fire_cmd(instance, req_desc->u.low, req_desc->u.high, instance->reg_set); } @@ -2618,6 +2541,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout) struct fusion_context *fusion; u32 host_diag, abs_state, status_reg, reset_adapter; u32 io_timeout_in_crash_mode = 0; + struct scsi_cmnd *scmd_local = NULL; instance = (struct megasas_instance *)shost->hostdata; fusion = instance->ctrl_context; @@ -2685,15 +2609,16 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout) iotimeout = 0; /* Now return commands back to the OS */ - for (i = 0 ; i < instance->max_fw_cmds; i++) { + for (i = 0 ; i < instance->max_scsi_cmds; i++) { cmd_fusion = fusion->cmd_list[i]; + scmd_local = cmd_fusion->scmd; if (cmd_fusion->scmd) { - scsi_dma_unmap(cmd_fusion->scmd); - cmd_fusion->scmd->result = + scmd_local->result = megasas_check_mpio_paths(instance, - cmd_fusion->scmd); - cmd_fusion->scmd->scsi_done(cmd_fusion->scmd); + scmd_local); megasas_return_cmd_fusion(instance, cmd_fusion); + scsi_dma_unmap(scmd_local); + scmd_local->scsi_done(scmd_local); atomic_dec(&instance->fw_outstanding); } } diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h index 56e6db2d5874..c66194ebd118 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h @@ -679,7 +679,6 @@ struct megasas_cmd_fusion { */ u32 sync_cmd_idx; u32 index; - u8 flags; u8 pd_r1_lb; }; @@ -792,10 +791,6 @@ struct MR_FW_RAID_MAP_EXT { struct fusion_context { struct megasas_cmd_fusion **cmd_list; - struct list_head cmd_pool; - - spinlock_t mpt_pool_lock; - dma_addr_t req_frames_desc_phys; u8 *req_frames_desc; -- cgit v1.2.3-59-g8ed1b From 43cd7fe4957f29cb21d8feb60744f60cbbea030b Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:31:39 +0530 Subject: megaraid_sas : Modify driver's meta data to reflect Avago Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 270e8f7131de..6a9879b4277c 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -94,8 +94,8 @@ MODULE_PARM_DESC(smp_affinity_enable, "SMP affinity feature enable/disbale Defau MODULE_LICENSE("GPL"); MODULE_VERSION(MEGASAS_VERSION); -MODULE_AUTHOR("megaraidlinux@lsi.com"); -MODULE_DESCRIPTION("LSI MegaRAID SAS Driver"); +MODULE_AUTHOR("megaraidlinux.pdl@avagotech.com"); +MODULE_DESCRIPTION("Avago MegaRAID SAS Driver"); int megasas_transition_to_ready(struct megasas_instance *instance, int ocr); static int megasas_get_pd_list(struct megasas_instance *instance); @@ -2765,7 +2765,7 @@ struct device_attribute *megaraid_host_attrs[] = { static struct scsi_host_template megasas_template = { .module = THIS_MODULE, - .name = "LSI SAS based MegaRAID driver", + .name = "Avago SAS based MegaRAID driver", .proc_name = "megaraid_sas", .slave_configure = megasas_slave_configure, .slave_alloc = megasas_slave_alloc, -- cgit v1.2.3-59-g8ed1b From 09fced191739963ff7ca8e61b67f80bd55c205f0 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:31:54 +0530 Subject: megaraid_sas : Add release date and update driver version This patch will upgrade the driver version and add back the release date and sysfs hook for the same. Some internal applications uses sysfs parameter for release date, so they were broken because of removal of release date from sysfs. Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 3 ++- drivers/scsi/megaraid/megaraid_sas_base.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 3751e58c7fae..1c8cb856a95b 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -35,7 +35,8 @@ /* * MegaRAID SAS Driver meta data */ -#define MEGASAS_VERSION "06.806.08.00-rc1" +#define MEGASAS_VERSION "06.807.10.00-rc1" +#define MEGASAS_RELDATE "March 6, 2015" /* * Device IDs diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6a9879b4277c..ec14ec817f68 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -6422,6 +6422,15 @@ static ssize_t megasas_sysfs_show_version(struct device_driver *dd, char *buf) static DRIVER_ATTR(version, S_IRUGO, megasas_sysfs_show_version, NULL); +static ssize_t +megasas_sysfs_show_release_date(struct device_driver *dd, char *buf) +{ + return snprintf(buf, strlen(MEGASAS_RELDATE) + 2, "%s\n", + MEGASAS_RELDATE); +} + +static DRIVER_ATTR(release_date, S_IRUGO, megasas_sysfs_show_release_date, NULL); + static ssize_t megasas_sysfs_show_support_poll_for_event(struct device_driver *dd, char *buf) { @@ -6761,6 +6770,11 @@ static int __init megasas_init(void) if (rval) goto err_dcf_attr_ver; + rval = driver_create_file(&megasas_pci_driver.driver, + &driver_attr_release_date); + if (rval) + goto err_dcf_rel_date; + rval = driver_create_file(&megasas_pci_driver.driver, &driver_attr_support_poll_for_event); if (rval) @@ -6784,6 +6798,9 @@ err_dcf_dbg_lvl: driver_remove_file(&megasas_pci_driver.driver, &driver_attr_support_poll_for_event); err_dcf_support_poll_for_event: + driver_remove_file(&megasas_pci_driver.driver, + &driver_attr_release_date); +err_dcf_rel_date: driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version); err_dcf_attr_ver: pci_unregister_driver(&megasas_pci_driver); @@ -6803,6 +6820,8 @@ static void __exit megasas_exit(void) &driver_attr_support_poll_for_event); driver_remove_file(&megasas_pci_driver.driver, &driver_attr_support_device_change); + driver_remove_file(&megasas_pci_driver.driver, + &driver_attr_release_date); driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version); pci_unregister_driver(&megasas_pci_driver); -- cgit v1.2.3-59-g8ed1b From 5765c5b8b38ad8a5e2c5716ea9af29ff3f1d2a62 Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Thu, 23 Apr 2015 16:32:09 +0530 Subject: megaraid_sas : Support for Avago's Single server High Availability product This patch will add support for Single Server High Availability(SSHA) cluster support. Here is the short decsription of changes done to add support for SSHA- 1) Host will send system's Unique ID based on DMI_PRODUCT_UUID to firmware. 2) Toggle the devhandle in LDIO path for Remote LDs. Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Reviewed-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 17 +++++++++++++++-- drivers/scsi/megaraid/megaraid_sas_base.c | 15 ++++++++++++++- drivers/scsi/megaraid/megaraid_sas_fusion.c | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 1c8cb856a95b..ab488e09ff21 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1271,8 +1271,10 @@ struct megasas_init_frame { u32 queue_info_new_phys_addr_hi; /*1Ch */ u32 queue_info_old_phys_addr_lo; /*20h */ u32 queue_info_old_phys_addr_hi; /*24h */ - - u32 reserved_4[6]; /*28h */ + u32 reserved_4[2]; /*28h */ + u32 system_info_lo; /*30h */ + u32 system_info_hi; /*34h */ + u32 reserved_5[2]; /*38h */ } __attribute__ ((packed)); @@ -1649,12 +1651,22 @@ struct megasas_irq_context { u32 MSIxIndex; }; +struct MR_DRV_SYSTEM_INFO { + u8 infoVersion; + u8 systemIdLength; + u16 reserved0; + u8 systemId[64]; + u8 reserved[1980]; +}; + struct megasas_instance { u32 *producer; dma_addr_t producer_h; u32 *consumer; dma_addr_t consumer_h; + struct MR_DRV_SYSTEM_INFO *system_info_buf; + dma_addr_t system_info_h; struct MR_LD_VF_AFFILIATION *vf_affiliation; dma_addr_t vf_affiliation_h; struct MR_LD_VF_AFFILIATION_111 *vf_affiliation_111; @@ -1769,6 +1781,7 @@ struct megasas_instance { u16 throttlequeuedepth; u8 mask_interrupts; u8 is_imr; + bool dev_handle; }; struct MR_LD_VF_MAP { u32 size; diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index ec14ec817f68..3d311cad8daf 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -5265,6 +5265,13 @@ 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; @@ -5676,8 +5683,10 @@ megasas_resume(struct pci_dev *pdev) &instance->sriov_heartbeat_timer, megasas_sriov_heartbeat_handler, MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF); - else + else { instance->skip_heartbeat_timer_del = 1; + goto fail_init_mfi; + } } instance->instancet->enable_intr(instance); @@ -5833,6 +5842,10 @@ static void megasas_detach_one(struct pci_dev *pdev) pci_free_consistent(pdev, CRASH_DMA_BUF_SIZE, instance->crash_dump_buf, instance->crash_dump_h); + if (instance->system_info_buf) + pci_free_consistent(pdev, sizeof(struct MR_DRV_SYSTEM_INFO), + instance->system_info_buf, instance->system_info_h); + scsi_host_put(host); pci_disable_device(pdev); diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 6f07f9119066..ad1238fc47d3 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "megaraid_sas_fusion.h" #include "megaraid_sas.h" @@ -579,6 +580,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance) union MEGASAS_REQUEST_DESCRIPTOR_UNION req_desc; int i; struct megasas_header *frame_hdr; + const char *sys_info; fusion = instance->ctrl_context; @@ -641,6 +643,16 @@ megasas_ioc_init_fusion(struct megasas_instance *instance) /* Convert capability to LE32 */ cpu_to_le32s((u32 *)&init_frame->driver_operations.mfi_capabilities); + sys_info = dmi_get_system_info(DMI_PRODUCT_UUID); + if (instance->system_info_buf && sys_info) { + memcpy(instance->system_info_buf->systemId, sys_info, + strlen(sys_info) > 64 ? 64 : strlen(sys_info)); + instance->system_info_buf->systemIdLength = + strlen(sys_info) > 64 ? 64 : strlen(sys_info); + init_frame->system_info_lo = instance->system_info_h; + init_frame->system_info_hi = 0; + } + init_frame->queue_info_new_phys_addr_hi = cpu_to_le32(upper_32_bits(ioc_init_handle)); init_frame->queue_info_new_phys_addr_lo = @@ -1572,6 +1584,14 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, cmd->pd_r1_lb = io_info.pd_after_lb; } else scp->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG; + + if ((raidLUN[0] == 1) && + (local_map_ptr->raidMap.devHndlInfo[io_info.pd_after_lb].validHandles > 2)) { + instance->dev_handle = !(instance->dev_handle); + io_info.devHandle = + local_map_ptr->raidMap.devHndlInfo[io_info.pd_after_lb].devHandle[instance->dev_handle]; + } + cmd->request_desc->SCSIIO.DevHandle = io_info.devHandle; io_request->DevHandle = io_info.devHandle; /* populate the LUN field */ -- cgit v1.2.3-59-g8ed1b From 6a6981fea3b8a6e6ab6a533991e474270602b9e1 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Thu, 23 Apr 2015 16:33:23 +0530 Subject: megaraid_sas : megasas_complete_outstanding_ioctls() can be static drivers/scsi/megaraid/megaraid_sas_base.c:1701:6: sparse: symbol 'megasas_complete_outstanding_ioctls' was not declared. Should it be static? From: Christoph Hellwig Signed-off-by: Fengguang Wu Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 3d311cad8daf..67ca6d31f3f5 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1685,7 +1685,7 @@ static int megasas_slave_alloc(struct scsi_device *sdev) * @instance: Adapter soft state * */ -void megasas_complete_outstanding_ioctls(struct megasas_instance *instance) +static void megasas_complete_outstanding_ioctls(struct megasas_instance *instance) { int i; struct megasas_cmd *cmd_mfi; -- cgit v1.2.3-59-g8ed1b From 8a232bb39917bf94c6e4224ae9ef3178c90fe352 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:32:39 +0530 Subject: megaraid_sas : add missing __iomem annotations Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index ab488e09ff21..fc9ab5bbbd03 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1693,7 +1693,7 @@ struct megasas_instance { spinlock_t crashdump_lock; struct megasas_register_set __iomem *reg_set; - u32 *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY]; + u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY]; struct megasas_pd_list pd_list[MEGASAS_MAX_PD]; struct megasas_pd_list local_pd_list[MEGASAS_MAX_PD]; u8 ld_ids[MEGASAS_MAX_LD_IDS]; diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 67ca6d31f3f5..72e8b29b4ae8 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -802,8 +802,8 @@ megasas_adp_reset_gen2(struct megasas_instance *instance, { u32 retry = 0 ; u32 HostDiag; - u32 *seq_offset = ®_set->seq_offset; - u32 *hostdiag_offset = ®_set->host_diag; + u32 __iomem *seq_offset = ®_set->seq_offset; + u32 __iomem *hostdiag_offset = ®_set->host_diag; if (instance->instancet == &megasas_instance_template_skinny) { seq_offset = ®_set->fusion_seq_offset; @@ -4575,7 +4575,7 @@ static int megasas_init_fw(struct megasas_instance *instance) * It is used for all MPT based Adapters. */ instance->reply_post_host_index_addr[0] = - (u32 *)((u8 *)instance->reg_set + + (u32 __iomem *)((u8 __iomem *)instance->reg_set + MPI2_REPLY_POST_HOST_INDEX_OFFSET); /* Check if MSI-X is supported while in ready state */ @@ -4607,7 +4607,8 @@ static int megasas_init_fw(struct megasas_instance *instance) */ for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) { instance->reply_post_host_index_addr[loop] = - (u32 *)((u8 *)instance->reg_set + + (u32 __iomem *) + ((u8 __iomem *)instance->reg_set + MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET + (loop * 0x10)); } -- cgit v1.2.3-59-g8ed1b From 9ab9ed38f6186ca79ff151419e243440a1a002de Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:32:54 +0530 Subject: megaraid_sas : add endianness annotations This adds endianness annotations to all data structures, and a few variables directly referencing them. Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 302 ++++++++++++++-------------- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/megaraid/megaraid_sas_fp.c | 10 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +- drivers/scsi/megaraid/megaraid_sas_fusion.h | 276 ++++++++++++------------- 5 files changed, 296 insertions(+), 296 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index fc9ab5bbbd03..53a3c3f64621 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -412,7 +412,7 @@ enum MR_PD_STATE { * defines the physical drive address structure */ struct MR_PD_ADDRESS { - u16 deviceId; + __le16 deviceId; u16 enclDeviceId; union { @@ -437,8 +437,8 @@ struct MR_PD_ADDRESS { * defines the physical drive list structure */ struct MR_PD_LIST { - u32 size; - u32 count; + __le32 size; + __le32 count; struct MR_PD_ADDRESS addr[1]; } __packed; @@ -455,28 +455,28 @@ union MR_LD_REF { struct { u8 targetId; u8 reserved; - u16 seqNum; + __le16 seqNum; }; - u32 ref; + __le32 ref; } __packed; /* * defines the logical drive list structure */ struct MR_LD_LIST { - u32 ldCount; - u32 reserved; + __le32 ldCount; + __le32 reserved; struct { union MR_LD_REF ref; u8 state; u8 reserved[3]; - u64 size; + __le64 size; } ldList[MAX_LOGICAL_DRIVES_EXT]; } __packed; struct MR_LD_TARGETID_LIST { - u32 size; - u32 count; + __le32 size; + __le32 count; u8 pad[3]; u8 targetId[MAX_LOGICAL_DRIVES_EXT]; }; @@ -557,7 +557,7 @@ struct megasas_ctrl_prop { } OnOffProperties; u8 autoSnapVDSpace; u8 viewSpace; - u16 spinDownTime; + __le16 spinDownTime; u8 reserved[24]; } __packed; @@ -571,10 +571,10 @@ struct megasas_ctrl_info { */ struct { - u16 vendor_id; - u16 device_id; - u16 sub_vendor_id; - u16 sub_device_id; + __le16 vendor_id; + __le16 device_id; + __le16 sub_vendor_id; + __le16 sub_device_id; u8 reserved[24]; } __attribute__ ((packed)) pci; @@ -615,8 +615,8 @@ struct megasas_ctrl_info { /* * List of components residing in flash. All str are null terminated */ - u32 image_check_word; - u32 image_component_count; + __le32 image_check_word; + __le32 image_component_count; struct { @@ -633,7 +633,7 @@ struct megasas_ctrl_info { * empty if a flash operation has not occurred. All stings are null * terminated */ - u32 pending_image_component_count; + __le32 pending_image_component_count; struct { @@ -666,39 +666,39 @@ struct megasas_ctrl_info { } __attribute__ ((packed)) hw_present; - u32 current_fw_time; + __le32 current_fw_time; /* * Maximum data transfer sizes */ - u16 max_concurrent_cmds; - u16 max_sge_count; - u32 max_request_size; + __le16 max_concurrent_cmds; + __le16 max_sge_count; + __le32 max_request_size; /* * Logical and physical device counts */ - u16 ld_present_count; - u16 ld_degraded_count; - u16 ld_offline_count; + __le16 ld_present_count; + __le16 ld_degraded_count; + __le16 ld_offline_count; - u16 pd_present_count; - u16 pd_disk_present_count; - u16 pd_disk_pred_failure_count; - u16 pd_disk_failed_count; + __le16 pd_present_count; + __le16 pd_disk_present_count; + __le16 pd_disk_pred_failure_count; + __le16 pd_disk_failed_count; /* * Memory size information */ - u16 nvram_size; - u16 memory_size; - u16 flash_size; + __le16 nvram_size; + __le16 memory_size; + __le16 flash_size; /* * Error counters */ - u16 mem_correctable_error_count; - u16 mem_uncorrectable_error_count; + __le16 mem_correctable_error_count; + __le16 mem_uncorrectable_error_count; /* * Cluster information @@ -709,7 +709,7 @@ struct megasas_ctrl_info { /* * Additional max data transfer sizes */ - u16 max_strips_per_io; + __le16 max_strips_per_io; /* * Controller capabilities structures @@ -809,7 +809,7 @@ struct megasas_ctrl_info { * deviceInterface.portAddr, and the rest shall be * populated in deviceInterfacePortAddr2. */ - u64 deviceInterfacePortAddr2[8]; /*6a0h */ + __le64 deviceInterfacePortAddr2[8]; /*6a0h */ u8 reserved3[128]; /*6e0h */ struct { /*760h */ @@ -846,26 +846,26 @@ struct megasas_ctrl_info { u16 reserved[6]; } pdsForRaidLevels; - u16 maxPds; /*780h */ - u16 maxDedHSPs; /*782h */ - u16 maxGlobalHSPs; /*784h */ - u16 ddfSize; /*786h */ + __le16 maxPds; /*780h */ + __le16 maxDedHSPs; /*782h */ + __le16 maxGlobalHSP; /*784h */ + __le16 ddfSize; /*786h */ u8 maxLdsPerArray; /*788h */ u8 partitionsInDDF; /*789h */ u8 lockKeyBinding; /*78ah */ u8 maxPITsPerLd; /*78bh */ u8 maxViewsPerLd; /*78ch */ u8 maxTargetId; /*78dh */ - u16 maxBvlVdSize; /*78eh */ + __le16 maxBvlVdSize; /*78eh */ - u16 maxConfigurableSSCSize; /*790h */ - u16 currentSSCsize; /*792h */ + __le16 maxConfigurableSSCSize; /*790h */ + __le16 currentSSCsize; /*792h */ char expanderFwVersion[12]; /*794h */ - u16 PFKTrialTimeRemaining; /*7A0h */ + __le16 PFKTrialTimeRemaining; /*7A0h */ - u16 cacheMemorySize; /*7A2h */ + __le16 cacheMemorySize; /*7A2h */ struct { /*7A4h */ #if defined(__BIG_ENDIAN_BITFIELD) @@ -935,7 +935,7 @@ struct megasas_ctrl_info { u8 temperatureROC; /*7C9h */ u8 temperatureCtrl; /*7CAh */ u8 reserved4; /*7CBh */ - u16 maxConfigurablePds; /*7CCh */ + __le16 maxConfigurablePds; /*7CCh */ u8 reserved5[2]; /*0x7CDh */ @@ -1172,22 +1172,22 @@ struct megasas_register_set { struct megasas_sge32 { - u32 phys_addr; - u32 length; + __le32 phys_addr; + __le32 length; } __attribute__ ((packed)); struct megasas_sge64 { - u64 phys_addr; - u32 length; + __le64 phys_addr; + __le32 length; } __attribute__ ((packed)); struct megasas_sge_skinny { - u64 phys_addr; - u32 length; - u32 flag; + __le64 phys_addr; + __le32 length; + __le32 flag; } __packed; union megasas_sgl { @@ -1210,12 +1210,12 @@ struct megasas_header { u8 cdb_len; /*06h */ u8 sge_count; /*07h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 timeout; /*12h */ - u32 data_xferlen; /*14h */ + __le16 flags; /*10h */ + __le16 timeout; /*12h */ + __le32 data_xferlen; /*14h */ } __attribute__ ((packed)); @@ -1248,7 +1248,7 @@ typedef union _MFI_CAPABILITIES { u32 reserved:25; #endif } mfi_capabilities; - u32 reg; + __le32 reg; } MFI_CAPABILITIES; struct megasas_init_frame { @@ -1260,35 +1260,35 @@ struct megasas_init_frame { u8 reserved_1; /*03h */ MFI_CAPABILITIES driver_operations; /*04h*/ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 reserved_3; /*12h */ - u32 data_xfer_len; /*14h */ + __le16 flags; /*10h */ + __le16 reserved_3; /*12h */ + __le32 data_xfer_len; /*14h */ - u32 queue_info_new_phys_addr_lo; /*18h */ - u32 queue_info_new_phys_addr_hi; /*1Ch */ - u32 queue_info_old_phys_addr_lo; /*20h */ - u32 queue_info_old_phys_addr_hi; /*24h */ - u32 reserved_4[2]; /*28h */ - u32 system_info_lo; /*30h */ - u32 system_info_hi; /*34h */ - u32 reserved_5[2]; /*38h */ + __le32 queue_info_new_phys_addr_lo; /*18h */ + __le32 queue_info_new_phys_addr_hi; /*1Ch */ + __le32 queue_info_old_phys_addr_lo; /*20h */ + __le32 queue_info_old_phys_addr_hi; /*24h */ + __le32 reserved_4[2]; /*28h */ + __le32 system_info_lo; /*30h */ + __le32 system_info_hi; /*34h */ + __le32 reserved_5[2]; /*38h */ } __attribute__ ((packed)); struct megasas_init_queue_info { - u32 init_flags; /*00h */ - u32 reply_queue_entries; /*04h */ + __le32 init_flags; /*00h */ + __le32 reply_queue_entries; /*04h */ - u32 reply_queue_start_phys_addr_lo; /*08h */ - u32 reply_queue_start_phys_addr_hi; /*0Ch */ - u32 producer_index_phys_addr_lo; /*10h */ - u32 producer_index_phys_addr_hi; /*14h */ - u32 consumer_index_phys_addr_lo; /*18h */ - u32 consumer_index_phys_addr_hi; /*1Ch */ + __le32 reply_queue_start_phys_addr_lo; /*08h */ + __le32 reply_queue_start_phys_addr_hi; /*0Ch */ + __le32 producer_index_phys_addr_lo; /*10h */ + __le32 producer_index_phys_addr_hi; /*14h */ + __le32 consumer_index_phys_addr_lo; /*18h */ + __le32 consumer_index_phys_addr_hi; /*1Ch */ } __attribute__ ((packed)); @@ -1304,18 +1304,18 @@ struct megasas_io_frame { u8 reserved_0; /*06h */ u8 sge_count; /*07h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 timeout; /*12h */ - u32 lba_count; /*14h */ + __le16 flags; /*10h */ + __le16 timeout; /*12h */ + __le32 lba_count; /*14h */ - u32 sense_buf_phys_addr_lo; /*18h */ - u32 sense_buf_phys_addr_hi; /*1Ch */ + __le32 sense_buf_phys_addr_lo; /*18h */ + __le32 sense_buf_phys_addr_hi; /*1Ch */ - u32 start_lba_lo; /*20h */ - u32 start_lba_hi; /*24h */ + __le32 start_lba_lo; /*20h */ + __le32 start_lba_hi; /*24h */ union megasas_sgl sgl; /*28h */ @@ -1333,15 +1333,15 @@ struct megasas_pthru_frame { u8 cdb_len; /*06h */ u8 sge_count; /*07h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 timeout; /*12h */ - u32 data_xfer_len; /*14h */ + __le16 flags; /*10h */ + __le16 timeout; /*12h */ + __le32 data_xfer_len; /*14h */ - u32 sense_buf_phys_addr_lo; /*18h */ - u32 sense_buf_phys_addr_hi; /*1Ch */ + __le32 sense_buf_phys_addr_lo; /*18h */ + __le32 sense_buf_phys_addr_hi; /*1Ch */ u8 cdb[16]; /*20h */ union megasas_sgl sgl; /*30h */ @@ -1356,19 +1356,19 @@ struct megasas_dcmd_frame { u8 reserved_1[4]; /*03h */ u8 sge_count; /*07h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 timeout; /*12h */ + __le16 flags; /*10h */ + __le16 timeout; /*12h */ - u32 data_xfer_len; /*14h */ - u32 opcode; /*18h */ + __le32 data_xfer_len; /*14h */ + __le32 opcode; /*18h */ union { /*1Ch */ u8 b[12]; - u16 s[6]; - u32 w[3]; + __le16 s[6]; + __le32 w[3]; } mbox; union megasas_sgl sgl; /*28h */ @@ -1382,22 +1382,22 @@ struct megasas_abort_frame { u8 cmd_status; /*02h */ u8 reserved_1; /*03h */ - u32 reserved_2; /*04h */ + __le32 reserved_2; /*04h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 reserved_3; /*12h */ - u32 reserved_4; /*14h */ + __le16 flags; /*10h */ + __le16 reserved_3; /*12h */ + __le32 reserved_4; /*14h */ - u32 abort_context; /*18h */ - u32 pad_1; /*1Ch */ + __le32 abort_context; /*18h */ + __le32 pad_1; /*1Ch */ - u32 abort_mfi_phys_addr_lo; /*20h */ - u32 abort_mfi_phys_addr_hi; /*24h */ + __le32 abort_mfi_phys_addr_lo; /*20h */ + __le32 abort_mfi_phys_addr_hi; /*24h */ - u32 reserved_5[6]; /*28h */ + __le32 reserved_5[6]; /*28h */ } __attribute__ ((packed)); @@ -1411,14 +1411,14 @@ struct megasas_smp_frame { u8 reserved_2[3]; /*04h */ u8 sge_count; /*07h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 timeout; /*12h */ + __le16 flags; /*10h */ + __le16 timeout; /*12h */ - u32 data_xfer_len; /*14h */ - u64 sas_addr; /*18h */ + __le32 data_xfer_len; /*14h */ + __le64 sas_addr; /*18h */ union { struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */ @@ -1438,16 +1438,16 @@ struct megasas_stp_frame { u8 reserved_3[2]; /*05h */ u8 sge_count; /*07h */ - u32 context; /*08h */ - u32 pad_0; /*0Ch */ + __le32 context; /*08h */ + __le32 pad_0; /*0Ch */ - u16 flags; /*10h */ - u16 timeout; /*12h */ + __le16 flags; /*10h */ + __le16 timeout; /*12h */ - u32 data_xfer_len; /*14h */ + __le32 data_xfer_len; /*14h */ - u16 fis[10]; /*18h */ - u32 stp_flags; + __le16 fis[10]; /*18h */ + __le32 stp_flags; union { struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */ @@ -1491,18 +1491,18 @@ union megasas_evt_class_locale { } __attribute__ ((packed)); struct megasas_evt_log_info { - u32 newest_seq_num; - u32 oldest_seq_num; - u32 clear_seq_num; - u32 shutdown_seq_num; - u32 boot_seq_num; + __le32 newest_seq_num; + __le32 oldest_seq_num; + __le32 clear_seq_num; + __le32 shutdown_seq_num; + __le32 boot_seq_num; } __attribute__ ((packed)); struct megasas_progress { - u16 progress; - u16 elapsed_seconds; + __le16 progress; + __le16 elapsed_seconds; } __attribute__ ((packed)); @@ -1523,9 +1523,9 @@ struct megasas_evtarg_pd { struct megasas_evt_detail { - u32 seq_num; - u32 time_stamp; - u32 code; + __le32 seq_num; + __le32 time_stamp; + __le32 code; union megasas_evt_class_locale cl; u8 arg_type; u8 reserved1[15]; @@ -1544,18 +1544,18 @@ struct megasas_evt_detail { struct { struct megasas_evtarg_ld ld; - u64 count; + __le64 count; } __attribute__ ((packed)) ld_count; struct { - u64 lba; + __le64 lba; struct megasas_evtarg_ld ld; } __attribute__ ((packed)) ld_lba; struct { struct megasas_evtarg_ld ld; - u32 prevOwner; - u32 newOwner; + __le32 prevOwner; + __le32 newOwner; } __attribute__ ((packed)) ld_owner; struct { @@ -1612,7 +1612,7 @@ struct megasas_evt_detail { struct { u16 vendorId; - u16 deviceId; + __le16 deviceId; u16 subVendorId; u16 subDeviceId; } __attribute__ ((packed)) pci; @@ -1632,9 +1632,9 @@ struct megasas_evt_detail { } __attribute__ ((packed)) ecc; u8 b[96]; - u16 s[48]; - u32 w[24]; - u64 d[12]; + __le16 s[48]; + __le32 w[24]; + __le64 d[12]; } args; char description[128]; @@ -1661,9 +1661,9 @@ struct MR_DRV_SYSTEM_INFO { struct megasas_instance { - u32 *producer; + __le32 *producer; dma_addr_t producer_h; - u32 *consumer; + __le32 *consumer; dma_addr_t consumer_h; struct MR_DRV_SYSTEM_INFO *system_info_buf; dma_addr_t system_info_h; @@ -1674,7 +1674,7 @@ struct megasas_instance { struct MR_CTRL_HB_HOST_MEM *hb_host_mem; dma_addr_t hb_host_mem_h; - u32 *reply_queue; + __le32 *reply_queue; dma_addr_t reply_queue_h; u32 *crash_dump_buf; @@ -1977,10 +1977,10 @@ u8 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map); struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map); u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map); u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map); -u16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map); +__le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map); u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map); -u16 get_updated_dev_handle(struct megasas_instance *instance, +__le16 get_updated_dev_handle(struct megasas_instance *instance, struct LD_LOAD_BALANCE_INFO *lbInfo, struct IO_REQUEST_INFO *in_info); void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map, struct LD_LOAD_BALANCE_INFO *lbInfo); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 72e8b29b4ae8..fcf1512d76ba 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4222,7 +4222,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance, static int megasas_issue_init_mfi(struct megasas_instance *instance) { - u32 context; + __le32 context; struct megasas_cmd *cmd; diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c index 4f72287860ee..e9138a23be7e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fp.c +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c @@ -142,7 +142,7 @@ u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map) return le16_to_cpu(map->raidMap.ldSpanMap[ld].spanBlock[span].span.arrayRef); } -u16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map) +__le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map) { return map->raidMap.devHndlInfo[pd].curDevHdl; } @@ -735,7 +735,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld, u8 retval = TRUE; u8 do_invader = 0; u64 *pdBlock = &io_info->pdBlock; - u16 *pDevHandle = &io_info->devHandle; + __le16 *pDevHandle = &io_info->devHandle; u32 logArm, rowMod, armQ, arm; if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER || @@ -817,7 +817,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow, u8 retval = TRUE; u8 do_invader = 0; u64 *pdBlock = &io_info->pdBlock; - u16 *pDevHandle = &io_info->devHandle; + __le16 *pDevHandle = &io_info->devHandle; if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER || instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) @@ -1341,11 +1341,11 @@ u8 megasas_get_best_arm_pd(struct megasas_instance *instance, return io_info->pd_after_lb; } -u16 get_updated_dev_handle(struct megasas_instance *instance, +__le16 get_updated_dev_handle(struct megasas_instance *instance, struct LD_LOAD_BALANCE_INFO *lbInfo, struct IO_REQUEST_INFO *io_info) { u8 arm_pd; - u16 devHandle; + __le16 devHandle; struct fusion_context *fusion; struct MR_DRV_RAID_MAP_ALL *drv_map; diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index ad1238fc47d3..18873a783ae3 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -1637,7 +1637,7 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance, struct MR_DRV_RAID_MAP_ALL *local_map_ptr; struct fusion_context *fusion = instance->ctrl_context; u8 span, physArm; - u16 devHandle; + __le16 devHandle; u32 ld, arRef, pd; struct MR_LD_RAID *raid; struct RAID_CONTEXT *pRAID_Context; diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h index c66194ebd118..ced6dc0cf8e8 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h @@ -104,18 +104,18 @@ struct RAID_CONTEXT { u8 nseg:4; #endif u8 resvd0; - u16 timeoutValue; + __le16 timeoutValue; u8 regLockFlags; u8 resvd1; - u16 VirtualDiskTgtId; - u64 regLockRowLBA; - u32 regLockLength; - u16 nextLMId; + __le16 VirtualDiskTgtId; + __le64 regLockRowLBA; + __le32 regLockLength; + __le16 nextLMId; u8 exStatus; u8 status; u8 RAIDFlags; u8 numSGE; - u16 configSeqNum; + __le16 configSeqNum; u8 spanArm; u8 resvd2[3]; }; @@ -182,61 +182,61 @@ enum REGION_TYPE { #define MPI2_WRSEQ_6TH_KEY_VALUE (0xD) struct MPI25_IEEE_SGE_CHAIN64 { - u64 Address; - u32 Length; - u16 Reserved1; + __le64 Address; + __le32 Length; + __le16 Reserved1; u8 NextChainOffset; u8 Flags; }; struct MPI2_SGE_SIMPLE_UNION { - u32 FlagsLength; + __le32 FlagsLength; union { - u32 Address32; - u64 Address64; + __le32 Address32; + __le64 Address64; } u; }; struct MPI2_SCSI_IO_CDB_EEDP32 { u8 CDB[20]; /* 0x00 */ - u32 PrimaryReferenceTag; /* 0x14 */ - u16 PrimaryApplicationTag; /* 0x18 */ - u16 PrimaryApplicationTagMask; /* 0x1A */ - u32 TransferLength; /* 0x1C */ + __be32 PrimaryReferenceTag; /* 0x14 */ + __be16 PrimaryApplicationTag; /* 0x18 */ + __be16 PrimaryApplicationTagMask; /* 0x1A */ + __le32 TransferLength; /* 0x1C */ }; struct MPI2_SGE_CHAIN_UNION { - u16 Length; + __le16 Length; u8 NextChainOffset; u8 Flags; union { - u32 Address32; - u64 Address64; + __le32 Address32; + __le64 Address64; } u; }; struct MPI2_IEEE_SGE_SIMPLE32 { - u32 Address; - u32 FlagsLength; + __le32 Address; + __le32 FlagsLength; }; struct MPI2_IEEE_SGE_CHAIN32 { - u32 Address; - u32 FlagsLength; + __le32 Address; + __le32 FlagsLength; }; struct MPI2_IEEE_SGE_SIMPLE64 { - u64 Address; - u32 Length; - u16 Reserved1; + __le64 Address; + __le32 Length; + __le16 Reserved1; u8 Reserved2; u8 Flags; }; struct MPI2_IEEE_SGE_CHAIN64 { - u64 Address; - u32 Length; - u16 Reserved1; + __le64 Address; + __le32 Length; + __le16 Reserved1; u8 Reserved2; u8 Flags; }; @@ -269,34 +269,34 @@ union MPI2_SCSI_IO_CDB_UNION { * Total SGE count will be one less than _MPI2_SCSI_IO_REQUEST */ struct MPI2_RAID_SCSI_IO_REQUEST { - u16 DevHandle; /* 0x00 */ + __le16 DevHandle; /* 0x00 */ u8 ChainOffset; /* 0x02 */ u8 Function; /* 0x03 */ - u16 Reserved1; /* 0x04 */ + __le16 Reserved1; /* 0x04 */ u8 Reserved2; /* 0x06 */ u8 MsgFlags; /* 0x07 */ u8 VP_ID; /* 0x08 */ u8 VF_ID; /* 0x09 */ - u16 Reserved3; /* 0x0A */ - u32 SenseBufferLowAddress; /* 0x0C */ - u16 SGLFlags; /* 0x10 */ + __le16 Reserved3; /* 0x0A */ + __le32 SenseBufferLowAddress; /* 0x0C */ + __le16 SGLFlags; /* 0x10 */ u8 SenseBufferLength; /* 0x12 */ u8 Reserved4; /* 0x13 */ u8 SGLOffset0; /* 0x14 */ u8 SGLOffset1; /* 0x15 */ u8 SGLOffset2; /* 0x16 */ u8 SGLOffset3; /* 0x17 */ - u32 SkipCount; /* 0x18 */ - u32 DataLength; /* 0x1C */ - u32 BidirectionalDataLength; /* 0x20 */ - u16 IoFlags; /* 0x24 */ - u16 EEDPFlags; /* 0x26 */ - u32 EEDPBlockSize; /* 0x28 */ - u32 SecondaryReferenceTag; /* 0x2C */ - u16 SecondaryApplicationTag; /* 0x30 */ - u16 ApplicationTagTranslationMask; /* 0x32 */ + __le32 SkipCount; /* 0x18 */ + __le32 DataLength; /* 0x1C */ + __le32 BidirectionalDataLength; /* 0x20 */ + __le16 IoFlags; /* 0x24 */ + __le16 EEDPFlags; /* 0x26 */ + __le32 EEDPBlockSize; /* 0x28 */ + __le32 SecondaryReferenceTag; /* 0x2C */ + __le16 SecondaryApplicationTag; /* 0x30 */ + __le16 ApplicationTagTranslationMask; /* 0x32 */ u8 LUN[8]; /* 0x34 */ - u32 Control; /* 0x3C */ + __le32 Control; /* 0x3C */ union MPI2_SCSI_IO_CDB_UNION CDB; /* 0x40 */ struct RAID_CONTEXT RaidContext; /* 0x60 */ union MPI2_SGE_IO_UNION SGL; /* 0x80 */ @@ -315,45 +315,45 @@ struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR { struct MPI2_DEFAULT_REQUEST_DESCRIPTOR { u8 RequestFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u16 LMID; /* 0x04 */ - u16 DescriptorTypeDependent; /* 0x06 */ + __le16 SMID; /* 0x02 */ + __le16 LMID; /* 0x04 */ + __le16 DescriptorTypeDependent; /* 0x06 */ }; /* High Priority Request Descriptor */ struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR { u8 RequestFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u16 LMID; /* 0x04 */ - u16 Reserved1; /* 0x06 */ + __le16 SMID; /* 0x02 */ + __le16 LMID; /* 0x04 */ + __le16 Reserved1; /* 0x06 */ }; /* SCSI IO Request Descriptor */ struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR { u8 RequestFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u16 LMID; /* 0x04 */ - u16 DevHandle; /* 0x06 */ + __le16 SMID; /* 0x02 */ + __le16 LMID; /* 0x04 */ + __le16 DevHandle; /* 0x06 */ }; /* SCSI Target Request Descriptor */ struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR { u8 RequestFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u16 LMID; /* 0x04 */ - u16 IoIndex; /* 0x06 */ + __le16 SMID; /* 0x02 */ + __le16 LMID; /* 0x04 */ + __le16 IoIndex; /* 0x06 */ }; /* RAID Accelerator Request Descriptor */ struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR { u8 RequestFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u16 LMID; /* 0x04 */ - u16 Reserved; /* 0x06 */ + __le16 SMID; /* 0x02 */ + __le16 LMID; /* 0x04 */ + __le16 Reserved; /* 0x06 */ }; /* union of Request Descriptors */ @@ -366,10 +366,10 @@ union MEGASAS_REQUEST_DESCRIPTOR_UNION { struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR MFAIo; union { struct { - u32 low; - u32 high; + __le32 low; + __le32 high; } u; - u64 Words; + __le64 Words; }; }; @@ -377,35 +377,35 @@ union MEGASAS_REQUEST_DESCRIPTOR_UNION { struct MPI2_DEFAULT_REPLY_DESCRIPTOR { u8 ReplyFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 DescriptorTypeDependent1; /* 0x02 */ - u32 DescriptorTypeDependent2; /* 0x04 */ + __le16 DescriptorTypeDependent1; /* 0x02 */ + __le32 DescriptorTypeDependent2; /* 0x04 */ }; /* Address Reply Descriptor */ struct MPI2_ADDRESS_REPLY_DESCRIPTOR { u8 ReplyFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u32 ReplyFrameAddress; /* 0x04 */ + __le16 SMID; /* 0x02 */ + __le32 ReplyFrameAddress; /* 0x04 */ }; /* SCSI IO Success Reply Descriptor */ struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR { u8 ReplyFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u16 TaskTag; /* 0x04 */ - u16 Reserved1; /* 0x06 */ + __le16 SMID; /* 0x02 */ + __le16 TaskTag; /* 0x04 */ + __le16 Reserved1; /* 0x06 */ }; /* TargetAssist Success Reply Descriptor */ struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR { u8 ReplyFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ + __le16 SMID; /* 0x02 */ u8 SequenceNumber; /* 0x04 */ u8 Reserved1; /* 0x05 */ - u16 IoIndex; /* 0x06 */ + __le16 IoIndex; /* 0x06 */ }; /* Target Command Buffer Reply Descriptor */ @@ -414,16 +414,16 @@ struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR { u8 MSIxIndex; /* 0x01 */ u8 VP_ID; /* 0x02 */ u8 Flags; /* 0x03 */ - u16 InitiatorDevHandle; /* 0x04 */ - u16 IoIndex; /* 0x06 */ + __le16 InitiatorDevHandle; /* 0x04 */ + __le16 IoIndex; /* 0x06 */ }; /* RAID Accelerator Success Reply Descriptor */ struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR { u8 ReplyFlags; /* 0x00 */ u8 MSIxIndex; /* 0x01 */ - u16 SMID; /* 0x02 */ - u32 Reserved; /* 0x04 */ + __le16 SMID; /* 0x02 */ + __le32 Reserved; /* 0x04 */ }; /* union of Reply Descriptors */ @@ -435,7 +435,7 @@ union MPI2_REPLY_DESCRIPTORS_UNION { struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR TargetCommandBuffer; struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR RAIDAcceleratorSuccess; - u64 Words; + __le64 Words; }; /* IOCInit Request message */ @@ -444,28 +444,28 @@ struct MPI2_IOC_INIT_REQUEST { u8 Reserved1; /* 0x01 */ u8 ChainOffset; /* 0x02 */ u8 Function; /* 0x03 */ - u16 Reserved2; /* 0x04 */ + __le16 Reserved2; /* 0x04 */ u8 Reserved3; /* 0x06 */ u8 MsgFlags; /* 0x07 */ u8 VP_ID; /* 0x08 */ u8 VF_ID; /* 0x09 */ - u16 Reserved4; /* 0x0A */ - u16 MsgVersion; /* 0x0C */ - u16 HeaderVersion; /* 0x0E */ + __le16 Reserved4; /* 0x0A */ + __le16 MsgVersion; /* 0x0C */ + __le16 HeaderVersion; /* 0x0E */ u32 Reserved5; /* 0x10 */ - u16 Reserved6; /* 0x14 */ + __le16 Reserved6; /* 0x14 */ u8 Reserved7; /* 0x16 */ u8 HostMSIxVectors; /* 0x17 */ - u16 Reserved8; /* 0x18 */ - u16 SystemRequestFrameSize; /* 0x1A */ - u16 ReplyDescriptorPostQueueDepth; /* 0x1C */ - u16 ReplyFreeQueueDepth; /* 0x1E */ - u32 SenseBufferAddressHigh; /* 0x20 */ - u32 SystemReplyAddressHigh; /* 0x24 */ - u64 SystemRequestFrameBaseAddress; /* 0x28 */ - u64 ReplyDescriptorPostQueueAddress;/* 0x30 */ - u64 ReplyFreeQueueAddress; /* 0x38 */ - u64 TimeStamp; /* 0x40 */ + __le16 Reserved8; /* 0x18 */ + __le16 SystemRequestFrameSize; /* 0x1A */ + __le16 ReplyDescriptorPostQueueDepth; /* 0x1C */ + __le16 ReplyFreeQueueDepth; /* 0x1E */ + __le32 SenseBufferAddressHigh; /* 0x20 */ + __le32 SystemReplyAddressHigh; /* 0x24 */ + __le64 SystemRequestFrameBaseAddress; /* 0x28 */ + __le64 ReplyDescriptorPostQueueAddress;/* 0x30 */ + __le64 ReplyFreeQueueAddress; /* 0x38 */ + __le64 TimeStamp; /* 0x40 */ }; /* mrpriv defines */ @@ -491,41 +491,41 @@ struct MPI2_IOC_INIT_REQUEST { #define MR_DCMD_LD_VF_MAP_GET_ALL_LDS 0x03150200 struct MR_DEV_HANDLE_INFO { - u16 curDevHdl; + __le16 curDevHdl; u8 validHandles; u8 reserved; - u16 devHandle[2]; + __le16 devHandle[2]; }; struct MR_ARRAY_INFO { - u16 pd[MAX_RAIDMAP_ROW_SIZE]; + __le16 pd[MAX_RAIDMAP_ROW_SIZE]; }; struct MR_QUAD_ELEMENT { - u64 logStart; - u64 logEnd; - u64 offsetInSpan; - u32 diff; - u32 reserved1; + __le64 logStart; + __le64 logEnd; + __le64 offsetInSpan; + __le32 diff; + __le32 reserved1; }; struct MR_SPAN_INFO { - u32 noElements; - u32 reserved1; + __le32 noElements; + __le32 reserved1; struct MR_QUAD_ELEMENT quad[MAX_RAIDMAP_SPAN_DEPTH]; }; struct MR_LD_SPAN { - u64 startBlk; - u64 numBlks; - u16 arrayRef; + __le64 startBlk; + __le64 numBlks; + __le16 arrayRef; u8 spanRowSize; u8 spanRowDataSize; u8 reserved[4]; }; struct MR_SPAN_BLOCK_INFO { - u64 num_rows; + __le64 num_rows; struct MR_LD_SPAN span; struct MR_SPAN_INFO block_span_info; }; @@ -558,8 +558,8 @@ struct MR_LD_RAID { u32 reserved4:7; #endif } capability; - u32 reserved6; - u64 size; + __le32 reserved6; + __le64 size; u8 spanDepth; u8 level; u8 stripeShift; @@ -568,12 +568,12 @@ struct MR_LD_RAID { u8 writeMode; u8 PRL; u8 SRL; - u16 targetId; + __le16 targetId; u8 ldState; u8 regTypeReqOnWrite; u8 modFactor; u8 regTypeReqOnRead; - u16 seqNum; + __le16 seqNum; struct { u32 ldSyncRequired:1; @@ -592,20 +592,20 @@ struct MR_LD_SPAN_MAP { }; struct MR_FW_RAID_MAP { - u32 totalSize; + __le32 totalSize; union { struct { - u32 maxLd; - u32 maxSpanDepth; - u32 maxRowSize; - u32 maxPdCount; - u32 maxArrays; + __le32 maxLd; + __le32 maxSpanDepth; + __le32 maxRowSize; + __le32 maxPdCount; + __le32 maxArrays; } validationInfo; - u32 version[5]; + __le32 version[5]; }; - u32 ldCount; - u32 Reserved1; + __le32 ldCount; + __le32 Reserved1; u8 ldTgtIdToLd[MAX_RAIDMAP_LOGICAL_DRIVES+ MAX_RAIDMAP_VIEWS]; u8 fpPdIoTimeoutSec; @@ -620,7 +620,7 @@ struct IO_REQUEST_INFO { u32 numBlocks; u16 ldTgtId; u8 isRead; - u16 devHandle; + __le16 devHandle; u64 pdBlock; u8 fpOkForIo; u8 IoforUnevenSpan; @@ -634,7 +634,7 @@ struct IO_REQUEST_INFO { struct MR_LD_TARGET_SYNC { u8 targetId; u8 reserved; - u16 seqNum; + __le16 seqNum; }; #define IEEE_SGE_FLAGS_ADDR_MASK (0x03) @@ -719,27 +719,27 @@ struct MR_DRV_RAID_MAP { * This feild will be manupulated by driver for ext raid map, * else pick the value from firmware raid map. */ - u32 totalSize; + __le32 totalSize; union { struct { - u32 maxLd; - u32 maxSpanDepth; - u32 maxRowSize; - u32 maxPdCount; - u32 maxArrays; + __le32 maxLd; + __le32 maxSpanDepth; + __le32 maxRowSize; + __le32 maxPdCount; + __le32 maxArrays; } validationInfo; - u32 version[5]; + __le32 version[5]; }; /* timeout value used by driver in FP IOs*/ u8 fpPdIoTimeoutSec; u8 reserved2[7]; - u16 ldCount; - u16 arCount; - u16 spanCount; - u16 reserve3; + __le16 ldCount; + __le16 arCount; + __le16 spanCount; + __le16 reserve3; struct MR_DEV_HANDLE_INFO devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES]; u8 ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT]; @@ -778,10 +778,10 @@ struct MR_FW_RAID_MAP_EXT { u8 fpPdIoTimeoutSec; u8 reserved2[7]; - u16 ldCount; - u16 arCount; - u16 spanCount; - u16 reserve3; + __le16 ldCount; + __le16 arCount; + __le16 spanCount; + __le16 reserve3; struct MR_DEV_HANDLE_INFO devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES]; u8 ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT]; @@ -834,10 +834,10 @@ struct fusion_context { }; union desc_value { - u64 word; + __le64 word; struct { - u32 low; - u32 high; + __le32 low; + __le32 high; } u; }; -- cgit v1.2.3-59-g8ed1b From c6f5bf814f0ad7ff11bd0054d1b0ff15df20d4b5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:33:09 +0530 Subject: megaraid_sas : add endianness conversions for all ones Add noop conversions for all ones to make sparse happy. Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/megaraid/megaraid_sas_fp.c | 7 ++++--- drivers/scsi/megaraid/megaraid_sas_fusion.c | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index fcf1512d76ba..93bc657bd519 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1219,7 +1219,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, */ if (scp->device->type == TYPE_TAPE) { if ((scp->request->timeout / HZ) > 0xFFFF) - pthru->timeout = 0xFFFF; + pthru->timeout = cpu_to_le16(0xFFFF); else pthru->timeout = cpu_to_le16(scp->request->timeout / HZ); } diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c index e9138a23be7e..2001ffb181d5 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fp.c +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c @@ -769,7 +769,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld, if (pd != MR_PD_INVALID) *pDevHandle = MR_PdDevHandleGet(pd, map); else { - *pDevHandle = MR_PD_INVALID; + *pDevHandle = cpu_to_le16(MR_PD_INVALID); if ((raid->level >= 5) && (!do_invader || (do_invader && (raid->regTypeReqOnRead != REGION_TYPE_UNUSED)))) @@ -864,7 +864,8 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow, /* Get dev handle from Pd. */ *pDevHandle = MR_PdDevHandleGet(pd, map); else { - *pDevHandle = MR_PD_INVALID; /* set dev handle as invalid. */ + /* set dev handle as invalid. */ + *pDevHandle = cpu_to_le16(MR_PD_INVALID); if ((raid->level >= 5) && (!do_invader || (do_invader && (raid->regTypeReqOnRead != REGION_TYPE_UNUSED)))) @@ -1109,7 +1110,7 @@ MR_BuildRaidContext(struct megasas_instance *instance, ref_in_start_stripe, io_info, pRAID_Context, map); /* If IO on an invalid Pd, then FP is not possible.*/ - if (io_info->devHandle == MR_PD_INVALID) + if (io_info->devHandle == cpu_to_le16(MR_PD_INVALID)) io_info->fpOkForIo = FALSE; return retval; } else if (isRead) { diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 18873a783ae3..b995774d601e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -415,7 +415,7 @@ megasas_alloc_cmds_fusion(struct megasas_instance *instance) reply_desc = fusion->reply_frames_desc; for (i = 0; i < fusion->reply_q_depth * count; i++, reply_desc++) - reply_desc->Words = ULLONG_MAX; + reply_desc->Words = cpu_to_le64(ULLONG_MAX); io_frames_sz = fusion->io_frames_alloc_sz; @@ -1997,7 +1997,8 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) num_completed = 0; - while ((d_val.u.low != UINT_MAX) && (d_val.u.high != UINT_MAX)) { + while (d_val.u.low != cpu_to_le32(UINT_MAX) && + d_val.u.high != cpu_to_le32(UINT_MAX)) { smid = le16_to_cpu(reply_desc->SMID); cmd_fusion = fusion->cmd_list[smid - 1]; @@ -2061,7 +2062,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) fusion->reply_q_depth) fusion->last_reply_idx[MSIxIndex] = 0; - desc->Words = ULLONG_MAX; + desc->Words = cpu_to_le64(ULLONG_MAX); num_completed++; threshold_reply_count++; @@ -2488,7 +2489,7 @@ void megasas_reset_reply_desc(struct megasas_instance *instance) fusion->last_reply_idx[i] = 0; reply_desc = fusion->reply_frames_desc; for (i = 0 ; i < fusion->reply_q_depth * count; i++, reply_desc++) - reply_desc->Words = ULLONG_MAX; + reply_desc->Words = cpu_to_le64(ULLONG_MAX); } /* -- cgit v1.2.3-59-g8ed1b From 48100b0ed0e5a34873828c0cdae8708804d57ee5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:33:24 +0530 Subject: megaraid_sas : move endianness conversion into caller of megasas_get_seq_num Converting structure fields in place is always a bad idea, and in this case by moving it into the only caller we also only have to do a single byte swap as most fields of this structure are never used. Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 93bc657bd519..6911a3f230b9 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4887,11 +4887,11 @@ megasas_get_seq_num(struct megasas_instance *instance, /* * Copy the data back into callers buffer */ - eli->newest_seq_num = le32_to_cpu(el_info->newest_seq_num); - eli->oldest_seq_num = le32_to_cpu(el_info->oldest_seq_num); - eli->clear_seq_num = le32_to_cpu(el_info->clear_seq_num); - eli->shutdown_seq_num = le32_to_cpu(el_info->shutdown_seq_num); - eli->boot_seq_num = le32_to_cpu(el_info->boot_seq_num); + eli->newest_seq_num = el_info->newest_seq_num; + eli->oldest_seq_num = el_info->oldest_seq_num; + eli->clear_seq_num = el_info->clear_seq_num; + eli->shutdown_seq_num = el_info->shutdown_seq_num; + eli->boot_seq_num = el_info->boot_seq_num; } pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info), @@ -5051,7 +5051,7 @@ static int megasas_start_aen(struct megasas_instance *instance) class_locale.members.class = MR_EVT_CLASS_DEBUG; return megasas_register_aen(instance, - eli.newest_seq_num + 1, + le32_to_cpu(eli.newest_seq_num) + 1, class_locale.word); } -- cgit v1.2.3-59-g8ed1b From 48433bd77b386bbf0abe6f065fe7cd021564651c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:33:39 +0530 Subject: megaraid_sas : bytewise or should be done on native endian variables Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index b995774d601e..487cd343147e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -621,7 +621,9 @@ megasas_ioc_init_fusion(struct megasas_instance *instance) frame_hdr = &cmd->frame->hdr; frame_hdr->cmd_status = 0xFF; - frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE); + frame_hdr->flags = cpu_to_le16( + le16_to_cpu(frame_hdr->flags) | + MFI_FRAME_DONT_POST_IN_REPLY_QUEUE); init_frame->cmd = MFI_CMD_INIT; init_frame->cmd_status = 0xFF; -- cgit v1.2.3-59-g8ed1b From 2213a4673e46c951ed317792c095e4216e0d6b46 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:33:54 +0530 Subject: megaraid_sas : add missing byte swaps to the sriov code Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 46 +++++++++++++++++-------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6911a3f230b9..c4a5cb9e630a 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1911,20 +1911,22 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; - dcmd->flags = MFI_FRAME_DIR_BOTH; + dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH); dcmd->timeout = 0; dcmd->pad_0 = 0; - dcmd->data_xfer_len = sizeof(struct MR_LD_VF_AFFILIATION_111); - dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111; + dcmd->data_xfer_len = + cpu_to_le32(sizeof(struct MR_LD_VF_AFFILIATION_111)); + dcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111); if (initial) dcmd->sgl.sge32[0].phys_addr = - instance->vf_affiliation_111_h; + cpu_to_le32(instance->vf_affiliation_111_h); else - dcmd->sgl.sge32[0].phys_addr = new_affiliation_111_h; + dcmd->sgl.sge32[0].phys_addr = + cpu_to_le32(new_affiliation_111_h); - dcmd->sgl.sge32[0].length = - sizeof(struct MR_LD_VF_AFFILIATION_111); + dcmd->sgl.sge32[0].length = cpu_to_le32( + sizeof(struct MR_LD_VF_AFFILIATION_111)); printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation for " "scsi%d\n", instance->host->host_no); @@ -2022,20 +2024,22 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; - dcmd->flags = MFI_FRAME_DIR_BOTH; + dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH); dcmd->timeout = 0; dcmd->pad_0 = 0; - dcmd->data_xfer_len = (MAX_LOGICAL_DRIVES + 1) * - sizeof(struct MR_LD_VF_AFFILIATION); - dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS; + dcmd->data_xfer_len = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) * + sizeof(struct MR_LD_VF_AFFILIATION)); + dcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS); if (initial) - dcmd->sgl.sge32[0].phys_addr = instance->vf_affiliation_h; + dcmd->sgl.sge32[0].phys_addr = + cpu_to_le32(instance->vf_affiliation_h); else - dcmd->sgl.sge32[0].phys_addr = new_affiliation_h; + dcmd->sgl.sge32[0].phys_addr = + cpu_to_le32(new_affiliation_h); - dcmd->sgl.sge32[0].length = (MAX_LOGICAL_DRIVES + 1) * - sizeof(struct MR_LD_VF_AFFILIATION); + dcmd->sgl.sge32[0].length = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) * + sizeof(struct MR_LD_VF_AFFILIATION)); printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation for " "scsi%d\n", instance->host->host_no); @@ -2183,17 +2187,17 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance, memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); - dcmd->mbox.s[0] = sizeof(struct MR_CTRL_HB_HOST_MEM); + dcmd->mbox.s[0] = cpu_to_le16(sizeof(struct MR_CTRL_HB_HOST_MEM)); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; - dcmd->flags = MFI_FRAME_DIR_BOTH; + dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH); dcmd->timeout = 0; dcmd->pad_0 = 0; - dcmd->data_xfer_len = sizeof(struct MR_CTRL_HB_HOST_MEM); - dcmd->opcode = MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC; - dcmd->sgl.sge32[0].phys_addr = instance->hb_host_mem_h; - dcmd->sgl.sge32[0].length = sizeof(struct MR_CTRL_HB_HOST_MEM); + dcmd->data_xfer_len = cpu_to_le32(sizeof(struct MR_CTRL_HB_HOST_MEM)); + dcmd->opcode = cpu_to_le32(MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC); + dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->hb_host_mem_h); + dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct MR_CTRL_HB_HOST_MEM)); printk(KERN_WARNING "megasas: SR-IOV: Starting heartbeat for scsi%d\n", instance->host->host_no); -- cgit v1.2.3-59-g8ed1b From 01d7f03ba00796bda4ffee6767785e9a0eb80962 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:34:09 +0530 Subject: megaraid_sas : fix megasas_fire_cmd_fusion calling convention The fusion HBAs don't really use the instance template like the other variants, as it branches off at a much higher level. So instead of trying to squeeze megasas_fire_cmd_fusion into the wrong calling convention call it locally with argument data types that match what is passed. [jejb: fix up 32 bit compile failure] Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 72 +++++++++++++---------------- 1 file changed, 31 insertions(+), 41 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 487cd343147e..1c11a8bb8bf4 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -181,6 +181,31 @@ inline void megasas_return_cmd_fusion(struct megasas_instance *instance, memset(cmd->io_request, 0, sizeof(struct MPI2_RAID_SCSI_IO_REQUEST)); } +/** + * megasas_fire_cmd_fusion - Sends command to the FW + */ +static void +megasas_fire_cmd_fusion(struct megasas_instance *instance, + union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc) +{ +#if defined(writeq) && defined(CONFIG_64BIT) + u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) | + le32_to_cpu(req_desc->u.low)); + + writeq(req_data, &instance->reg_set->inbound_low_queue_port); +#else + unsigned long flags; + + spin_lock_irqsave(&instance->hba_lock, flags); + writel(le32_to_cpu(req_desc->u.low), + &instance->reg_set->inbound_low_queue_port); + writel(le32_to_cpu(req_desc->u.high), + &instance->reg_set->inbound_high_queue_port); + spin_unlock_irqrestore(&instance->hba_lock, flags); +#endif +} + + /** * megasas_teardown_frame_pool_fusion - Destroy the cmd frame DMA pool * @instance: Adapter soft state @@ -679,8 +704,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance) break; } - instance->instancet->fire_cmd(instance, req_desc.u.low, - req_desc.u.high, instance->reg_set); + megasas_fire_cmd_fusion(instance, &req_desc); wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS); @@ -1095,34 +1119,6 @@ fail_alloc_mfi_cmds: return 1; } -/** - * megasas_fire_cmd_fusion - Sends command to the FW - * @frame_phys_addr : Physical address of cmd - * @frame_count : Number of frames for the command - * @regs : MFI register set - */ -void -megasas_fire_cmd_fusion(struct megasas_instance *instance, - dma_addr_t req_desc_lo, - u32 req_desc_hi, - struct megasas_register_set __iomem *regs) -{ -#if defined(writeq) && defined(CONFIG_64BIT) - u64 req_data = (((u64)le32_to_cpu(req_desc_hi) << 32) | - le32_to_cpu(req_desc_lo)); - - writeq(req_data, &(regs)->inbound_low_queue_port); -#else - unsigned long flags; - - spin_lock_irqsave(&instance->hba_lock, flags); - - writel(le32_to_cpu(req_desc_lo), &(regs)->inbound_low_queue_port); - writel(le32_to_cpu(req_desc_hi), &(regs)->inbound_high_queue_port); - spin_unlock_irqrestore(&instance->hba_lock, flags); -#endif -} - /** * map_cmd_status - Maps FW cmd status to OS cmd status * @cmd : Pointer to cmd @@ -1948,9 +1944,7 @@ megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance, */ atomic_inc(&instance->fw_outstanding); - instance->instancet->fire_cmd(instance, - req_desc->u.low, req_desc->u.high, - instance->reg_set); + megasas_fire_cmd_fusion(instance, req_desc); return 0; } @@ -2311,8 +2305,7 @@ megasas_issue_dcmd_fusion(struct megasas_instance *instance, printk(KERN_ERR "Couldn't issue MFI pass thru cmd\n"); return; } - instance->instancet->fire_cmd(instance, req_desc->u.low, - req_desc->u.high, instance->reg_set); + megasas_fire_cmd_fusion(instance, req_desc); } /** @@ -2522,11 +2515,9 @@ void megasas_refire_mgmt_cmd(struct megasas_instance *instance) req_desc = megasas_get_request_descriptor (instance, smid - 1); if (req_desc && (cmd_mfi->frame->dcmd.opcode != - cpu_to_le32(MR_DCMD_LD_MAP_GET_INFO))) { - instance->instancet->fire_cmd(instance, - req_desc->u.low, req_desc->u.high, - instance->reg_set); - } else + cpu_to_le32(MR_DCMD_LD_MAP_GET_INFO))) + megasas_fire_cmd_fusion(instance, req_desc); + else megasas_return_cmd(instance, cmd_mfi); } } @@ -2961,7 +2952,6 @@ void megasas_fusion_ocr_wq(struct work_struct *work) } struct megasas_instance_template megasas_instance_template_fusion = { - .fire_cmd = megasas_fire_cmd_fusion, .enable_intr = megasas_enable_intr_fusion, .disable_intr = megasas_disable_intr_fusion, .clear_intr = megasas_clear_intr_fusion, -- cgit v1.2.3-59-g8ed1b From a9555534d52a058a6cc4bff51b51a790b6943eeb Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Apr 2015 16:34:24 +0530 Subject: megaraid_sas : swap whole register in megasas_register_aen Swap the whole 32 bits we read from the hardware instead of swapping just the 16bits we care about in place later. Signed-off-by: Christoph Hellwig Signed-off-by: Sumit Saxena Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index c4a5cb9e630a..1bc0c5af4f91 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4942,8 +4942,8 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num, if (instance->aen_cmd) { - prev_aen.word = instance->aen_cmd->frame->dcmd.mbox.w[1]; - prev_aen.members.locale = le16_to_cpu(prev_aen.members.locale); + prev_aen.word = + le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]); /* * A class whose enum value is smaller is inclusive of all -- cgit v1.2.3-59-g8ed1b From 2be2a98845e6742a96d48534294d2c5ba582e57f Mon Sep 17 00:00:00 2001 From: "Sumit.Saxena@avagotech.com" Date: Wed, 6 May 2015 19:01:02 +0530 Subject: megaraid_sas : Modify return value of megasas_issue_blocked_cmd() and wait_and_poll() to consider command status returned by firmware This patch is rebased on top of recently sent 18 patches(submitted by me) for megaraid_sas driver. Change the return value of wait_and_poll() and megsas_issue_blocked_cmd() based on MFI_STAT returned by firmware for that command. Earlier driver always send return type based on command completion (but never check MFI_STAT_OK for that command), so even if command is failed by firmware still driver will return SUCCESS status from these functions wait_and_poll() and megsas_issue_blocked_cmd() and if caller of these functions does not check command status (MFI_STAT), then it may endup using invalid data returned in DMA buffers(one of the example is megasas_ld_list_query DCMD). Best thing to avoid this type of issue is do error handling and set proper return type from caller function wait_and_poll() and megsas_issue_blocked_cmd(). The change proposed in this patch will fix the regression introduced in patch- "90dc9d9 megaraid_sas : MFI MPT linked list corruption fix" inside function megasas_ld_list_query(). Prior to this MFI MPT linked list corruption fix patch, megasas_ld_list_query() function used to check DCMD status(returned by firmware) but with this linked list corruption fix patch, DCMD status will not be checked inside function megasas_ld_list_query() and introduced this issue of wrong data being used by function megasas_ld_list_query(). Cc: Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena Reviewed-by: Tomas Henzl Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.h | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 67 ++++++++++++----------------- drivers/scsi/megaraid/megaraid_sas_fusion.c | 3 +- 3 files changed, 30 insertions(+), 42 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 53a3c3f64621..20c37541963f 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1894,7 +1894,7 @@ struct megasas_cmd { u32 index; u8 sync_cmd; - u8 cmd_status; + u8 cmd_status_drv; u8 abort_aen; u8 retry_for_fw_reset; diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 1bc0c5af4f91..a022c39153cf 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -898,7 +898,7 @@ extern struct megasas_instance_template megasas_instance_template_fusion; * @instance: Adapter soft state * @cmd: Command packet to be issued * - * For polling, MFI requires the cmd_status to be set to 0xFF before posting. + * For polling, MFI requires the cmd_status to be set to MFI_STAT_INVALID_STATUS before posting. */ int megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd) @@ -940,19 +940,20 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, int timeout) { int ret = 0; - cmd->cmd_status = ENODATA; + cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; instance->instancet->issue_dcmd(instance, cmd); if (timeout) { ret = wait_event_timeout(instance->int_cmd_wait_q, - cmd->cmd_status != ENODATA, timeout * HZ); + cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS, timeout * HZ); if (!ret) return 1; } else wait_event(instance->int_cmd_wait_q, - cmd->cmd_status != ENODATA); + cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS); - return 0; + return (cmd->cmd_status_drv == MFI_STAT_OK) ? + 0 : 1; } /** @@ -985,7 +986,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, * Prepare and issue the abort frame */ abort_fr->cmd = MFI_CMD_ABORT; - abort_fr->cmd_status = 0xFF; + abort_fr->cmd_status = MFI_STAT_INVALID_STATUS; abort_fr->flags = cpu_to_le16(0); abort_fr->abort_context = cpu_to_le32(cmd_to_abort->index); abort_fr->abort_mfi_phys_addr_lo = @@ -994,13 +995,13 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, cpu_to_le32(upper_32_bits(cmd_to_abort->frame_phys_addr)); cmd->sync_cmd = 1; - cmd->cmd_status = ENODATA; + cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; instance->instancet->issue_dcmd(instance, cmd); if (timeout) { ret = wait_event_timeout(instance->abort_cmd_wait_q, - cmd->cmd_status != ENODATA, timeout * HZ); + cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS, timeout * HZ); if (!ret) { dev_err(&instance->pdev->dev, "Command timedout" "from %s\n", __func__); @@ -1008,7 +1009,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, } } else wait_event(instance->abort_cmd_wait_q, - cmd->cmd_status != ENODATA); + cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS); cmd->sync_cmd = 0; @@ -1909,7 +1910,7 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH); dcmd->timeout = 0; @@ -2022,7 +2023,7 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH); dcmd->timeout = 0; @@ -2189,7 +2190,7 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance, dcmd->mbox.s[0] = cpu_to_le16(sizeof(struct MR_CTRL_HB_HOST_MEM)); dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH); dcmd->timeout = 0; @@ -2209,21 +2210,11 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance, retval = megasas_issue_polled(instance, cmd); if (retval) { - printk(KERN_WARNING "megasas: SR-IOV: MR_DCMD_CTRL_SHARED_HOST" - "_MEM_ALLOC DCMD timed out for scsi%d\n", - instance->host->host_no); - retval = 1; - goto out; - } - - - if (dcmd->cmd_status) { - printk(KERN_WARNING "megasas: SR-IOV: MR_DCMD_CTRL_SHARED_HOST" - "_MEM_ALLOC DCMD failed with status 0x%x for scsi%d\n", - dcmd->cmd_status, - instance->host->host_no); + dev_warn(&instance->pdev->dev, "SR-IOV: MR_DCMD_CTRL_SHARED_HOST" + "_MEM_ALLOC DCMD %s for scsi%d\n", + (dcmd->cmd_status == MFI_STAT_INVALID_STATUS) ? + "timed out" : "failed", instance->host->host_no); retval = 1; - goto out; } out: @@ -2319,7 +2310,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) "reset queue\n", reset_cmd); - reset_cmd->cmd_status = ENODATA; + reset_cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; instance->instancet->fire_cmd(instance, reset_cmd->frame_phys_addr, 0, instance->reg_set); @@ -2798,11 +2789,7 @@ static void megasas_complete_int_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) { - cmd->cmd_status = cmd->frame->io.cmd_status; - - if (cmd->cmd_status == ENODATA) { - cmd->cmd_status = 0; - } + cmd->cmd_status_drv = cmd->frame->io.cmd_status; wake_up(&instance->int_cmd_wait_q); } @@ -2821,7 +2808,7 @@ megasas_complete_abort(struct megasas_instance *instance, { if (cmd->sync_cmd) { cmd->sync_cmd = 0; - cmd->cmd_status = 0; + cmd->cmd_status_drv = 0; wake_up(&instance->abort_cmd_wait_q); } @@ -3067,7 +3054,7 @@ megasas_issue_pending_cmds_again(struct megasas_instance *instance) printk(KERN_NOTICE "megasas: %p synchronous cmd" "on the internal reset queue," "issue it again.\n", cmd); - cmd->cmd_status = ENODATA; + cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; instance->instancet->fire_cmd(instance, cmd->frame_phys_addr , 0, instance->reg_set); @@ -3807,7 +3794,7 @@ megasas_get_pd_list(struct megasas_instance *instance) dcmd->mbox.b[0] = MR_PD_QUERY_TYPE_EXPOSED_TO_HOST; dcmd->mbox.b[1] = 0; dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ); dcmd->timeout = 0; @@ -3903,7 +3890,7 @@ megasas_get_ld_list(struct megasas_instance *instance) if (instance->supportmax256vd) dcmd->mbox.b[0] = 1; dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ); dcmd->timeout = 0; @@ -3992,7 +3979,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type) dcmd->mbox.b[2] = 1; dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ); dcmd->timeout = 0; @@ -4125,7 +4112,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance) memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ); dcmd->timeout = 0; @@ -4197,7 +4184,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance, memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->mbox.b[0] = crash_buf_state; dcmd->cmd = MFI_CMD_DCMD; - dcmd->cmd_status = 0xFF; + dcmd->cmd_status = MFI_STAT_INVALID_STATUS; dcmd->sge_count = 1; dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_NONE); dcmd->timeout = 0; @@ -4264,7 +4251,7 @@ megasas_issue_init_mfi(struct megasas_instance *instance) initq_info->consumer_index_phys_addr_lo = cpu_to_le32(instance->consumer_h); init_frame->cmd = MFI_CMD_INIT; - init_frame->cmd_status = 0xFF; + init_frame->cmd_status = MFI_STAT_INVALID_STATUS; init_frame->queue_info_new_phys_addr_lo = cpu_to_le32(lower_32_bits(initq_info_h)); init_frame->queue_info_new_phys_addr_hi = diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 1c11a8bb8bf4..0637f42a0c36 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -584,7 +584,8 @@ wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, if (frame_hdr->cmd_status == 0xff) return -ETIME; - return 0; + return (frame_hdr->cmd_status == MFI_STAT_OK) ? + 0 : 1; } /** -- cgit v1.2.3-59-g8ed1b From 258c3af2b9309412d82e74b2ea87e8c140fe2072 Mon Sep 17 00:00:00 2001 From: Tomas Henzl Date: Tue, 2 Jun 2015 16:09:46 +0530 Subject: megaraid: fix irq setup process regression This fixes a regression caused by commit d3557fc8be11d25f316884581f487684f8e7dad3 megaraid_sas : Add separate function for setting up IRQs This makes boot end with 'root does not exist' message on certain adapters. The bug is that the driver does not setup ints for cards without msi-x support. This patch fixes it, in addition to that it moves tasklet initialisation before enable_intr, otherwise a kernel panic may occur, when an interrupt arrives before the tasklet is ready. Signed-off-by: Tomas Henzl Signed-off-by: Sumit Saxena Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/megaraid') diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index a022c39153cf..89bb4c6d86f9 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4619,18 +4619,18 @@ static int megasas_init_fw(struct megasas_instance *instance) instance->msix_vectors = i; else instance->msix_vectors = 0; + } - dev_info(&instance->pdev->dev, - "firmware supports msix\t: (%d)", fw_msix_count); - dev_info(&instance->pdev->dev, - "current msix/online cpus\t: (%d/%d)\n", - instance->msix_vectors, (unsigned int)num_online_cpus()); + dev_info(&instance->pdev->dev, + "firmware supports msix\t: (%d)", fw_msix_count); + dev_info(&instance->pdev->dev, + "current msix/online cpus\t: (%d/%d)\n", + instance->msix_vectors, (unsigned int)num_online_cpus()); - if (instance->msix_vectors ? - megasas_setup_irqs_msix(instance, 1) : - megasas_setup_irqs_ioapic(instance)) - goto fail_setup_irqs; - } + if (instance->msix_vectors ? + megasas_setup_irqs_msix(instance, 1) : + megasas_setup_irqs_ioapic(instance)) + goto fail_setup_irqs; instance->ctrl_info = kzalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL); @@ -4646,6 +4646,10 @@ static int megasas_init_fw(struct megasas_instance *instance) /* Get operational params, sge flags, send init cmd to controller */ if (instance->instancet->init_adapter(instance)) goto fail_init_adapter; + + tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, + (unsigned long)instance); + instance->instancet->enable_intr(instance); printk(KERN_ERR "megasas: INIT adapter done\n"); @@ -4762,12 +4766,6 @@ static int megasas_init_fw(struct megasas_instance *instance) instance->throttlequeuedepth = MEGASAS_THROTTLE_QUEUE_DEPTH; - /* - * Setup tasklet for cmd completion - */ - - tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, - (unsigned long)instance); /* Launch SR-IOV heartbeat timer */ if (instance->requestorId) { -- cgit v1.2.3-59-g8ed1b