From cd4e12e8ad246ec5bc23ab04d0da0e6985025620 Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:20:54 +0530 Subject: [SCSI] mpt2sas : Rescan topology from Interrupt context instead of work thread Following host reset its possible that the controller firmware could assign new handles for devices, as well as adding or deleting devices. There is code in the driver that will rescan the topology folowing host reset; updating device handles, and remove devices that are no longer responding. This patch will improve the responsivness by moving this rescaning from the delayed hotplug worker thread to immediately following the host reset. Signed-off-by: Kashyap Desai Reviewed-by: Eric Moore Cc: Stable Tree Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index acdcff150a35..998a7b847b3d 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -119,6 +119,7 @@ #define MPT2_IOC_PRE_RESET 1 /* prior to host reset */ #define MPT2_IOC_AFTER_RESET 2 /* just after host reset */ #define MPT2_IOC_DONE_RESET 3 /* links re-initialized */ +#define MPT2_IOC_RUNNING 4 /* shost running */ /* * logging format -- cgit v1.2.3 From 155dd4c763694222c125e65438d823f58ea653bc Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:22:00 +0530 Subject: [SCSI] mpt2sas: Prevent sending command to FW while Host Reset This patch renames the flag for indicating host reset from ioc_reset_in_progress to shost_recovery. It also removes the spin locks surrounding the setting of this flag, which are unnecessary. Sanity checks on the shost_recovery flag were added thru out the code so as to prevent sending firmware commands during host reset. Also, the setting of the shost state to SHOST_RECOVERY was removed to prevent deadlocks, this is actually better handled by the shost_recovery flag. Signed-off-by: Kashyap Desai Reviewed-by: Eric Moore Cc: Stable Tree Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.c | 13 +++-------- drivers/scsi/mpt2sas/mpt2sas_base.h | 3 +-- drivers/scsi/mpt2sas/mpt2sas_ctl.c | 16 ++----------- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 40 +++++++++++++++++++------------- drivers/scsi/mpt2sas/mpt2sas_transport.c | 29 +++++++++++++---------- 5 files changed, 47 insertions(+), 54 deletions(-) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index cc5a8dae4ae1..1cfb503125b6 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c @@ -94,7 +94,7 @@ _base_fault_reset_work(struct work_struct *work) int rc; spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->ioc_reset_in_progress) + if (ioc->shost_recovery) goto rearm_timer; spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); @@ -3501,20 +3501,13 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, __func__)); spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->ioc_reset_in_progress) { + if (ioc->shost_recovery) { spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); printk(MPT2SAS_ERR_FMT "%s: busy\n", ioc->name, __func__); return -EBUSY; } - ioc->ioc_reset_in_progress = 1; ioc->shost_recovery = 1; - if (ioc->shost->shost_state == SHOST_RUNNING) { - /* set back to SHOST_RUNNING in mpt2sas_scsih.c */ - scsi_host_set_state(ioc->shost, SHOST_RECOVERY); - printk(MPT2SAS_INFO_FMT "putting controller into " - "SHOST_RECOVERY\n", ioc->name); - } spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); _base_reset_handler(ioc, MPT2_IOC_PRE_RESET); @@ -3534,7 +3527,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, ioc->name, __func__, ((r == 0) ? "SUCCESS" : "FAILED"))); spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - ioc->ioc_reset_in_progress = 0; + ioc->shost_recovery = 0; spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); if (!r) diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index 998a7b847b3d..15827582a90e 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -432,7 +432,7 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr); * @fw_event_list: list of fw events * @aen_event_read_flag: event log was read * @broadcast_aen_busy: broadcast aen waiting to be serviced - * @ioc_reset_in_progress: host reset in progress + * @shost_recovery: host reset in progress * @ioc_reset_in_progress_lock: * @ioc_link_reset_in_progress: phy/hard reset in progress * @ignore_loginfos: ignore loginfos during task managment @@ -545,7 +545,6 @@ struct MPT2SAS_ADAPTER { /* misc flags */ int aen_event_read_flag; u8 broadcast_aen_busy; - u8 ioc_reset_in_progress; u8 shost_recovery; spinlock_t ioc_reset_in_progress_lock; u8 ioc_link_reset_in_progress; diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index 14e473d1fa7b..c2a51018910f 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c @@ -1963,7 +1963,6 @@ _ctl_ioctl_main(struct file *file, unsigned int cmd, void __user *arg) { enum block_state state; long ret = -EINVAL; - unsigned long flags; state = (file->f_flags & O_NONBLOCK) ? NON_BLOCKING : BLOCKING; @@ -1989,13 +1988,8 @@ _ctl_ioctl_main(struct file *file, unsigned int cmd, void __user *arg) !ioc) return -ENODEV; - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->shost_recovery) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, - flags); + if (ioc->shost_recovery) return -EAGAIN; - } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); if (_IOC_SIZE(cmd) == sizeof(struct mpt2_ioctl_command)) { uarg = arg; @@ -2098,7 +2092,6 @@ _ctl_compat_mpt_command(struct file *file, unsigned cmd, unsigned long arg) struct mpt2_ioctl_command karg; struct MPT2SAS_ADAPTER *ioc; enum block_state state; - unsigned long flags; if (_IOC_SIZE(cmd) != sizeof(struct mpt2_ioctl_command32)) return -EINVAL; @@ -2113,13 +2106,8 @@ _ctl_compat_mpt_command(struct file *file, unsigned cmd, unsigned long arg) if (_ctl_verify_adapter(karg32.hdr.ioc_number, &ioc) == -1 || !ioc) return -ENODEV; - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->shost_recovery) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, - flags); + if (ioc->shost_recovery) return -EAGAIN; - } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); memset(&karg, 0, sizeof(struct mpt2_ioctl_command)); karg.hdr.ioc_number = karg32.hdr.ioc_number; diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 471c3b604596..195f5e5aabf1 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -1785,17 +1785,18 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, u32 ioc_state; unsigned long timeleft; u8 VF_ID = 0; - unsigned long flags; - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->tm_cmds.status != MPT2_CMD_NOT_USED || - ioc->shost_recovery) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); + if (ioc->tm_cmds.status != MPT2_CMD_NOT_USED) { + printk(MPT2SAS_INFO_FMT "%s: tm_cmd busy!!!\n", + __func__, ioc->name); + return; + } + + if (ioc->shost_recovery) { printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", __func__, ioc->name); return; } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); ioc_state = mpt2sas_base_get_iocstate(ioc, 0); if (ioc_state & MPI2_DOORBELL_USED) { @@ -2553,7 +2554,6 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *)) Mpi2SCSIIORequest_t *mpi_request; u32 mpi_control; u16 smid; - unsigned long flags; scmd->scsi_done = done; sas_device_priv_data = scmd->device->hostdata; @@ -2572,13 +2572,10 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *)) } /* see if we are busy with task managment stuff */ - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (sas_target_priv_data->tm_busy || - ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); + if (sas_target_priv_data->tm_busy) + return SCSI_MLQUEUE_DEVICE_BUSY; + else if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) return SCSI_MLQUEUE_HOST_BUSY; - } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); if (scmd->sc_data_direction == DMA_FROM_DEVICE) mpi_control = MPI2_SCSIIO_CONTROL_READ; @@ -3374,6 +3371,9 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle) if (!handle) return -1; + if (ioc->shost_recovery) + return -1; + if ((mpt2sas_config_get_expander_pg0(ioc, &mpi_reply, &expander_pg0, MPI2_SAS_EXPAND_PGAD_FORM_HNDL, handle))) { printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", @@ -3510,6 +3510,9 @@ _scsih_expander_remove(struct MPT2SAS_ADAPTER *ioc, u16 handle) struct _sas_node *sas_expander; unsigned long flags; + if (ioc->shost_recovery) + return; + spin_lock_irqsave(&ioc->sas_node_lock, flags); sas_expander = mpt2sas_scsih_expander_find_by_handle(ioc, handle); spin_unlock_irqrestore(&ioc->sas_node_lock, flags); @@ -3681,6 +3684,8 @@ _scsih_remove_device(struct MPT2SAS_ADAPTER *ioc, u16 handle) mutex_unlock(&ioc->tm_cmds.mutex); dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "issue target reset " "done: handle(0x%04x)\n", ioc->name, device_handle)); + if (ioc->shost_recovery) + goto out; } /* SAS_IO_UNIT_CNTR - send REMOVE_DEVICE */ @@ -3846,6 +3851,8 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, "expander event\n", ioc->name)); return; } + if (ioc->shost_recovery) + return; if (event_data->PHY[i].PhyStatus & MPI2_EVENT_SAS_TOPO_PHYSTATUS_VACANT) continue; @@ -5217,13 +5224,10 @@ _firmware_event_work(struct work_struct *work) } spin_unlock_irqrestore(&ioc->fw_event_lock, flags); - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); if (ioc->shost_recovery) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); _scsih_fw_event_requeue(ioc, fw_event, 1000); return; } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); switch (fw_event->event) { case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST: @@ -5425,6 +5429,8 @@ _scsih_expander_node_remove(struct MPT2SAS_ADAPTER *ioc, if (!sas_device) continue; _scsih_remove_device(ioc, sas_device->handle); + if (ioc->shost_recovery) + return; goto retry_device_search; } } @@ -5446,6 +5452,8 @@ _scsih_expander_node_remove(struct MPT2SAS_ADAPTER *ioc, if (!expander_sibling) continue; _scsih_expander_remove(ioc, expander_sibling->handle); + if (ioc->shost_recovery) + return; goto retry_expander_search; } } diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c index 686695b155c7..a53086d0381a 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_transport.c +++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c @@ -140,11 +140,18 @@ _transport_set_identify(struct MPT2SAS_ADAPTER *ioc, u16 handle, u32 device_info; u32 ioc_status; + if (ioc->shost_recovery) { + printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", + __func__, ioc->name); + return -EFAULT; + } + if ((mpt2sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", + ioc->name, __FILE__, __LINE__, __func__); - return -1; + return -ENXIO; } ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & @@ -153,7 +160,7 @@ _transport_set_identify(struct MPT2SAS_ADAPTER *ioc, u16 handle, printk(MPT2SAS_ERR_FMT "handle(0x%04x), ioc_status(0x%04x)" "\nfailure at %s:%d/%s()!\n", ioc->name, handle, ioc_status, __FILE__, __LINE__, __func__); - return -1; + return -EIO; } memset(identify, 0, sizeof(identify)); @@ -288,21 +295,17 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc, void *psge; u32 sgl_flags; u8 issue_reset = 0; - unsigned long flags; void *data_out = NULL; dma_addr_t data_out_dma; u32 sz; u64 *sas_address_le; u16 wait_state_count; - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->ioc_reset_in_progress) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); + if (ioc->shost_recovery) { printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", __func__, ioc->name); return -EFAULT; } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); mutex_lock(&ioc->transport_cmds.mutex); @@ -806,6 +809,12 @@ mpt2sas_transport_update_phy_link_change(struct MPT2SAS_ADAPTER *ioc, struct _sas_node *sas_node; struct _sas_phy *mpt2sas_phy; + if (ioc->shost_recovery) { + printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", + __func__, ioc->name); + return; + } + spin_lock_irqsave(&ioc->sas_node_lock, flags); sas_node = _transport_sas_node_find_by_handle(ioc, handle); spin_unlock_irqrestore(&ioc->sas_node_lock, flags); @@ -1025,7 +1034,6 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, void *psge; u32 sgl_flags; u8 issue_reset = 0; - unsigned long flags; dma_addr_t dma_addr_in = 0; dma_addr_t dma_addr_out = 0; u16 wait_state_count; @@ -1045,14 +1053,11 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, return -EINVAL; } - spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); - if (ioc->ioc_reset_in_progress) { - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); + if (ioc->shost_recovery) { printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", __func__, ioc->name); return -EFAULT; } - spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); rc = mutex_lock_interruptible(&ioc->transport_cmds.mutex); if (rc) -- cgit v1.2.3 From cc0f5207664f85da8d0b2ebdacec5daaee0ce95f Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:22:39 +0530 Subject: [SCSI] mpt2sas: Removed wrapper funtions _scsih_link_change. Deleted the wrapper function called _scsih_link_change. This function was implemented for compatibility reasons only, between different kernel versions. Currently this function is no longer needed. The calling function are converted to calling mpt2sas_transport_update_phy_link_change directly in the transport layer. Signed-off-by: Kashyap Desai Reviewed-by: Eric Moore Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.h | 2 +- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 44 ++++++++++---------------------- drivers/scsi/mpt2sas/mpt2sas_transport.c | 4 +-- 3 files changed, 17 insertions(+), 33 deletions(-) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index 15827582a90e..39dc69627bc7 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -798,7 +798,7 @@ int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev); int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev); -void mpt2sas_transport_update_phy_link_change(struct MPT2SAS_ADAPTER *ioc, u16 handle, +void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle, u16 attached_handle, u8 phy_number, u8 link_rate); extern struct sas_function_template mpt2sas_transport_functions; extern struct scsi_transport_template *mpt2sas_transport_template; diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 195f5e5aabf1..c0d5d5e1f9c8 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -3123,25 +3123,6 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) scmd->scsi_done(scmd); } -/** - * _scsih_link_change - process phy link changes - * @ioc: per adapter object - * @handle: phy handle - * @attached_handle: valid for devices attached to link - * @phy_number: phy number - * @link_rate: new link rate - * Context: user. - * - * Return nothing. - */ -static void -_scsih_link_change(struct MPT2SAS_ADAPTER *ioc, u16 handle, u16 attached_handle, - u8 phy_number, u8 link_rate) -{ - mpt2sas_transport_update_phy_link_change(ioc, handle, attached_handle, - phy_number, link_rate); -} - /** * _scsih_sas_host_refresh - refreshing sas host object contents * @ioc: per adapter object @@ -3186,7 +3167,8 @@ _scsih_sas_host_refresh(struct MPT2SAS_ADAPTER *ioc, u8 update) le16_to_cpu(sas_iounit_pg0->PhyData[i]. ControllerDevHandle); if (update) - _scsih_link_change(ioc, + mpt2sas_transport_update_links( + ioc, ioc->sas_hba.phy[i].handle, le16_to_cpu(sas_iounit_pg0->PhyData[i]. AttachedDevHandle), i, @@ -3868,9 +3850,10 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, case MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED: if (!parent_handle) { if (phy_number < ioc->sas_hba.num_phys) - _scsih_link_change(ioc, - ioc->sas_hba.phy[phy_number].handle, - handle, phy_number, link_rate_); + mpt2sas_transport_update_links( + ioc, + ioc->sas_hba.phy[phy_number].handle, + handle, phy_number, link_rate_); } else { spin_lock_irqsave(&ioc->sas_node_lock, flags); sas_expander = @@ -3880,11 +3863,12 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, flags); if (sas_expander) { if (phy_number < sas_expander->num_phys) - _scsih_link_change(ioc, - sas_expander-> - phy[phy_number].handle, - handle, phy_number, - link_rate_); + mpt2sas_transport_update_links( + ioc, + sas_expander-> + phy[phy_number].handle, + handle, phy_number, + link_rate_); } } if (reason_code == MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED) { @@ -4400,7 +4384,7 @@ _scsih_sas_pd_add(struct MPT2SAS_ADAPTER *ioc, return; } - _scsih_link_change(ioc, + mpt2sas_transport_update_links(ioc, le16_to_cpu(sas_device_pg0.ParentDevHandle), handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5); @@ -4689,7 +4673,7 @@ _scsih_sas_ir_physical_disk_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, return; } - _scsih_link_change(ioc, + mpt2sas_transport_update_links(ioc, le16_to_cpu(sas_device_pg0.ParentDevHandle), handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5); diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c index a53086d0381a..742324a0a11e 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_transport.c +++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c @@ -792,7 +792,7 @@ mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy } /** - * mpt2sas_transport_update_phy_link_change - refreshing phy link changes and attached devices + * mpt2sas_transport_update_links - refreshing phy link changes * @ioc: per adapter object * @handle: handle to sas_host or expander * @attached_handle: attached device handle @@ -802,7 +802,7 @@ mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy * Returns nothing. */ void -mpt2sas_transport_update_phy_link_change(struct MPT2SAS_ADAPTER *ioc, +mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle, u16 attached_handle, u8 phy_number, u8 link_rate) { unsigned long flags; -- cgit v1.2.3 From 34a03bef2202d0c9983a8da0a8abaee37d285847 Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:23:19 +0530 Subject: [SCSI] mpt2sas: setting SDEV into RUNNING state from Interrupt context Changing SDEV Running state from interrupt context. Previously It was handle in work queue thread. With this change It will not wait for work queue thread to execute scsih_ublock_io_device to put SDEV into Running state. This will reduce delay for Device becoming RUNNING. Modified this patch considering James comment "Not to change SDEV state using scsi_device_set_state API, instead use scsi_internal_device_unblock scsi_internal_device_block API" Signed-off-by: Kashyap Desai Reviewed-by: Eric Moore Cc: Stable Tree Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.h | 2 ++ drivers/scsi/mpt2sas/mpt2sas_scsih.c | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index 39dc69627bc7..1f3efd6569d3 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -802,5 +802,7 @@ void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle, u16 attached_handle, u8 phy_number, u8 link_rate); extern struct sas_function_template mpt2sas_transport_functions; extern struct scsi_transport_template *mpt2sas_transport_template; +extern int scsi_internal_device_block(struct scsi_device *sdev); +extern int scsi_internal_device_unblock(struct scsi_device *sdev); #endif /* MPT2SAS_BASE_H_INCLUDED */ diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index c0d5d5e1f9c8..6e6d5af6b365 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -2222,7 +2222,7 @@ _scsih_ublock_io_device(struct MPT2SAS_ADAPTER *ioc, u16 handle) MPT2SAS_INFO_FMT "SDEV_RUNNING: " "handle(0x%04x)\n", ioc->name, handle)); sas_device_priv_data->block = 0; - scsi_device_set_state(sdev, SDEV_RUNNING); + scsi_internal_device_unblock(sdev); } } } @@ -2251,7 +2251,7 @@ _scsih_block_io_device(struct MPT2SAS_ADAPTER *ioc, u16 handle) MPT2SAS_INFO_FMT "SDEV_BLOCK: " "handle(0x%04x)\n", ioc->name, handle)); sas_device_priv_data->block = 1; - scsi_device_set_state(sdev, SDEV_BLOCK); + scsi_internal_device_block(sdev); } } } @@ -2327,6 +2327,7 @@ _scsih_block_io_to_children_attached_directly(struct MPT2SAS_ADAPTER *ioc, u16 handle; u16 reason_code; u8 phy_number; + u8 link_rate; for (i = 0; i < event_data->NumEntries; i++) { handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); @@ -2337,6 +2338,11 @@ _scsih_block_io_to_children_attached_directly(struct MPT2SAS_ADAPTER *ioc, MPI2_EVENT_SAS_TOPO_RC_MASK; if (reason_code == MPI2_EVENT_SAS_TOPO_RC_DELAY_NOT_RESPONDING) _scsih_block_io_device(ioc, handle); + if (reason_code == MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED) { + link_rate = event_data->PHY[i].LinkRate >> 4; + if (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5) + _scsih_ublock_io_device(ioc, handle); + } } } @@ -3690,6 +3696,9 @@ _scsih_remove_device(struct MPT2SAS_ADAPTER *ioc, u16 handle) le32_to_cpu(mpi_reply.IOCLogInfo))); out: + + _scsih_ublock_io_device(ioc, handle); + mpt2sas_transport_port_remove(ioc, sas_device->sas_address, sas_device->parent_handle); @@ -3871,10 +3880,6 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, link_rate_); } } - if (reason_code == MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED) { - if (link_rate_ >= MPI2_SAS_NEG_LINK_RATE_1_5) - _scsih_ublock_io_device(ioc, handle); - } if (reason_code == MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED) { if (link_rate_ < MPI2_SAS_NEG_LINK_RATE_1_5) break; -- cgit v1.2.3 From ed79f1280d1bc54f168abcffc8c3e0bf8ffb1873 Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:23:49 +0530 Subject: [SCSI] mpt2sas: Raid 10 Volume is showing as Raid 1E in dmesg This patch modifies the slave_configure callback so the messages that get sent to system log for RAID1E volumes contain the string "RAID10" instead of "RAID1E". These messages contain information regarding what kind of scsi device is being added. Certain OEMS can enable displaying the RAID10 string instead of RAID1E via manufacturing page 10. The driver will read this config page at driver load time, then determine from the GenericFlags0 bits whether display the RAID10 or RAID1E string, also even drive count is taken into consideration. Signed-off-by: Kashyap Desai Reviewed-by: Eric Moore Cc: Stable Tree Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.c | 7 ++-- drivers/scsi/mpt2sas/mpt2sas_base.h | 37 ++++++++++++++++++++- drivers/scsi/mpt2sas/mpt2sas_config.c | 61 +++++++++++++++++++++++++++++++++++ drivers/scsi/mpt2sas/mpt2sas_scsih.c | 8 ++++- 4 files changed, 109 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 1cfb503125b6..2e4bc3d2b435 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c @@ -1542,6 +1542,8 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc) (ioc->bios_pg3.BiosVersion & 0x0000FF00) >> 8, ioc->bios_pg3.BiosVersion & 0x000000FF); + _base_display_dell_branding(ioc); + printk(MPT2SAS_INFO_FMT "Protocol=(", ioc->name); if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR) { @@ -1554,8 +1556,6 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc) i++; } - _base_display_dell_branding(ioc); - i = 0; printk("), "); printk("Capabilities=("); @@ -1627,6 +1627,9 @@ _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc) u32 iounit_pg1_flags; mpt2sas_config_get_manufacturing_pg0(ioc, &mpi_reply, &ioc->manu_pg0); + if (ioc->ir_firmware) + mpt2sas_config_get_manufacturing_pg10(ioc, &mpi_reply, + &ioc->manu_pg10); mpt2sas_config_get_bios_pg2(ioc, &mpi_reply, &ioc->bios_pg2); mpt2sas_config_get_bios_pg3(ioc, &mpi_reply, &ioc->bios_pg3); mpt2sas_config_get_ioc_pg8(ioc, &mpi_reply, &ioc->ioc_pg8); diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index 1f3efd6569d3..ff05ae1e43ba 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -197,6 +197,38 @@ struct MPT2SAS_TARGET { * @block: device is in SDEV_BLOCK state * @tlr_snoop_check: flag used in determining whether to disable TLR */ + +/* OEM Identifiers */ +#define MFG10_OEM_ID_INVALID (0x00000000) +#define MFG10_OEM_ID_DELL (0x00000001) +#define MFG10_OEM_ID_FSC (0x00000002) +#define MFG10_OEM_ID_SUN (0x00000003) +#define MFG10_OEM_ID_IBM (0x00000004) + +/* GENERIC Flags 0*/ +#define MFG10_GF0_OCE_DISABLED (0x00000001) +#define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002) +#define MFG10_GF0_R10_DISPLAY (0x00000004) +#define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008) +#define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010) + +/* OEM Specific Flags will come from OEM specific header files */ +typedef struct _MPI2_CONFIG_PAGE_MAN_10 { + MPI2_CONFIG_PAGE_HEADER Header; /* 00h */ + U8 OEMIdentifier; /* 04h */ + U8 Reserved1; /* 05h */ + U16 Reserved2; /* 08h */ + U32 Reserved3; /* 0Ch */ + U32 GenericFlags0; /* 10h */ + U32 GenericFlags1; /* 14h */ + U32 Reserved4; /* 18h */ + U32 OEMSpecificFlags0; /* 1Ch */ + U32 OEMSpecificFlags1; /* 20h */ + U32 Reserved5[18]; /* 24h-60h*/ +} MPI2_CONFIG_PAGE_MAN_10, + MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10, + Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t; + struct MPT2SAS_DEVICE { struct MPT2SAS_TARGET *sas_target; unsigned int lun; @@ -461,6 +493,7 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr); * @facts: static facts data * @pfacts: static port facts data * @manu_pg0: static manufacturing page 0 + * @manu_pg10: static manufacturing page 10 * @bios_pg2: static bios page 2 * @bios_pg3: static bios page 3 * @ioc_pg8: static ioc page 8 @@ -663,6 +696,7 @@ struct MPT2SAS_ADAPTER { dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT]; u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT]; u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT]; + Mpi2ManufacturingPage10_t manu_pg10; u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23]; u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT]; }; @@ -734,6 +768,8 @@ void mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 re int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys); int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page); +int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page); int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t *mpi_reply, Mpi2BiosPage2_t *config_page); int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t @@ -776,7 +812,6 @@ int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, u16 *volume_handle); int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle, u64 *wwid); - /* ctl shared API */ extern struct device_attribute *mpt2sas_host_attrs[]; extern struct device_attribute *mpt2sas_dev_attrs[]; diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c index 6ddee161beb3..b9f4d0f97e50 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_config.c +++ b/drivers/scsi/mpt2sas/mpt2sas_config.c @@ -425,6 +425,67 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, return r; } +/** + * mpt2sas_config_get_manufacturing_pg10 - obtain manufacturing page 10 + * @ioc: per adapter object + * @mpi_reply: reply mf payload returned from firmware + * @config_page: contents of the config page + * Context: sleep. + * + * Returns 0 for success, non-zero for failure. + */ +int +mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page) +{ + Mpi2ConfigRequest_t mpi_request; + int r; + struct config_request mem; + + memset(config_page, 0, sizeof(Mpi2ManufacturingPage10_t)); + memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); + mpi_request.Function = MPI2_FUNCTION_CONFIG; + mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; + mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_MANUFACTURING; + mpi_request.Header.PageNumber = 10; + mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; + mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); + r = _config_request(ioc, &mpi_request, mpi_reply, + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + if (r) + goto out; + + mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; + mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; + mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; + mpi_request.Header.PageType = mpi_reply->Header.PageType; + mpi_request.Header.PageLength = mpi_reply->Header.PageLength; + mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; + if (mem.config_page_sz > ioc->config_page_sz) { + r = _config_alloc_config_dma_memory(ioc, &mem); + if (r) + goto out; + } else { + mem.config_page_dma = ioc->config_page_dma; + mem.config_page = ioc->config_page; + } + ioc->base_add_sg_single(&mpi_request.PageBufferSGE, + MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, + mem.config_page_dma); + r = _config_request(ioc, &mpi_request, mpi_reply, + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + if (!r) + memcpy(config_page, mem.config_page, + min_t(u16, mem.config_page_sz, + sizeof(Mpi2ManufacturingPage10_t))); + + if (mem.config_page_sz > ioc->config_page_sz) + _config_free_config_dma_memory(ioc, &mem); + + out: + return r; +} + /** * mpt2sas_config_get_bios_pg2 - obtain bios page 2 * @ioc: per adapter object diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 6e6d5af6b365..e71a6c04298b 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -1501,7 +1501,13 @@ _scsih_slave_configure(struct scsi_device *sdev) break; case MPI2_RAID_VOL_TYPE_RAID1E: qdepth = MPT2SAS_RAID_QUEUE_DEPTH; - r_level = "RAID1E"; + if (ioc->manu_pg10.OEMIdentifier && + (ioc->manu_pg10.GenericFlags0 & + MFG10_GF0_R10_DISPLAY) && + !(raid_device->num_pds % 2)) + r_level = "RAID10"; + else + r_level = "RAID1E"; break; case MPI2_RAID_VOL_TYPE_RAID1: qdepth = MPT2SAS_RAID_QUEUE_DEPTH; -- cgit v1.2.3 From 5b768581ea722172f059ad5a5eebea9008961af0 Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:24:31 +0530 Subject: [SCSI] mpt2sas: cleanup interrupt routine and config_request optimization Cleaned up base_interrupt routine to be more effiecent. Deleted about a third of the config page API by moving redundant code from all the calling functions to _config_request. Signed-off-by: Kashyap Desai Reviewed-by: Eric Moore Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.c | 73 ++- drivers/scsi/mpt2sas/mpt2sas_base.h | 2 +- drivers/scsi/mpt2sas/mpt2sas_config.c | 911 ++++++++-------------------------- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 1 + 4 files changed, 234 insertions(+), 753 deletions(-) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 2e4bc3d2b435..d95d2f274cb3 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c @@ -687,6 +687,14 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) ioc->mask_interrupts = 0; } +union reply_descriptor { + u64 word; + struct { + u32 low; + u32 high; + } u; +}; + /** * _base_interrupt - MPT adapter (IOC) specific interrupt handler. * @irq: irq number (not used) @@ -698,47 +706,38 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) static irqreturn_t _base_interrupt(int irq, void *bus_id) { - union reply_descriptor { - u64 word; - struct { - u32 low; - u32 high; - } u; - }; union reply_descriptor rd; - u32 post_index, post_index_next, completed_cmds; + u32 completed_cmds; u8 request_desript_type; u16 smid; u8 cb_idx; u32 reply; u8 VF_ID; - int i; struct MPT2SAS_ADAPTER *ioc = bus_id; + Mpi2ReplyDescriptorsUnion_t *rpf; if (ioc->mask_interrupts) return IRQ_NONE; - post_index = ioc->reply_post_host_index; - request_desript_type = ioc->reply_post_free[post_index]. - Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; + rpf = &ioc->reply_post_free[ioc->reply_post_host_index]; + request_desript_type = rpf->Default.ReplyFlags + & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) return IRQ_NONE; completed_cmds = 0; do { - rd.word = ioc->reply_post_free[post_index].Words; + rd.word = rpf->Words; if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX) goto out; reply = 0; cb_idx = 0xFF; - smid = le16_to_cpu(ioc->reply_post_free[post_index]. - Default.DescriptorTypeDependent1); - VF_ID = ioc->reply_post_free[post_index]. - Default.VF_ID; + smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1); + VF_ID = rpf->Default.VF_ID; if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { - reply = le32_to_cpu(ioc->reply_post_free[post_index]. - AddressReply.ReplyFrameAddress); + reply = le32_to_cpu + (rpf->AddressReply.ReplyFrameAddress); } else if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER) goto next; @@ -765,21 +764,27 @@ _base_interrupt(int irq, void *bus_id) 0 : ioc->reply_free_host_index + 1; ioc->reply_free[ioc->reply_free_host_index] = cpu_to_le32(reply); + wmb(); writel(ioc->reply_free_host_index, &ioc->chip->ReplyFreeHostIndex); - wmb(); } next: - post_index_next = (post_index == (ioc->reply_post_queue_depth - - 1)) ? 0 : post_index + 1; + + rpf->Words = ULLONG_MAX; + ioc->reply_post_host_index = (ioc->reply_post_host_index == + (ioc->reply_post_queue_depth - 1)) ? 0 : + ioc->reply_post_host_index + 1; request_desript_type = - ioc->reply_post_free[post_index_next].Default.ReplyFlags - & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; + ioc->reply_post_free[ioc->reply_post_host_index].Default. + ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; completed_cmds++; if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) goto out; - post_index = post_index_next; + if (!ioc->reply_post_host_index) + rpf = ioc->reply_post_free; + else + rpf++; } while (1); out: @@ -787,19 +792,8 @@ _base_interrupt(int irq, void *bus_id) if (!completed_cmds) return IRQ_NONE; - /* reply post descriptor handling */ - post_index_next = ioc->reply_post_host_index; - for (i = 0 ; i < completed_cmds; i++) { - post_index = post_index_next; - /* poison the reply post descriptor */ - ioc->reply_post_free[post_index_next].Words = ULLONG_MAX; - post_index_next = (post_index == - (ioc->reply_post_queue_depth - 1)) - ? 0 : post_index + 1; - } - ioc->reply_post_host_index = post_index_next; - writel(post_index_next, &ioc->chip->ReplyPostHostIndex); wmb(); + writel(ioc->reply_post_host_index, &ioc->chip->ReplyPostHostIndex); return IRQ_HANDLED; } @@ -1650,7 +1644,7 @@ _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc) iounit_pg1_flags |= MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING; ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); - mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, ioc->iounit_pg1); + mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); } /** @@ -3306,13 +3300,11 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); ioc->tm_cmds.status = MPT2_CMD_NOT_USED; mutex_init(&ioc->tm_cmds.mutex); - init_completion(&ioc->tm_cmds.done); /* config page internal command bits */ ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); ioc->config_cmds.status = MPT2_CMD_NOT_USED; mutex_init(&ioc->config_cmds.mutex); - init_completion(&ioc->config_cmds.done); /* ctl module internal command bits */ ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); @@ -3436,6 +3428,7 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) if (ioc->config_cmds.status & MPT2_CMD_PENDING) { ioc->config_cmds.status |= MPT2_CMD_RESET; mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); + ioc->config_cmds.smid = USHORT_MAX; complete(&ioc->config_cmds.done); } break; diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index ff05ae1e43ba..f4bf7ff8f480 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -785,7 +785,7 @@ int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRep int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t *config_page); int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t - *mpi_reply, Mpi2IOUnitPage1_t config_page); + *mpi_reply, Mpi2IOUnitPage1_t *config_page); int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz); int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c index b9f4d0f97e50..ab8c560865d8 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_config.c +++ b/drivers/scsi/mpt2sas/mpt2sas_config.c @@ -72,15 +72,15 @@ /** * struct config_request - obtain dma memory via routine - * @config_page_sz: size - * @config_page: virt pointer - * @config_page_dma: phys pointer + * @sz: size + * @page: virt pointer + * @page_dma: phys pointer * */ struct config_request{ - u16 config_page_sz; - void *config_page; - dma_addr_t config_page_dma; + u16 sz; + void *page; + dma_addr_t page_dma; }; #ifdef CONFIG_SCSI_MPT2SAS_LOGGING @@ -174,6 +174,55 @@ _config_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid, } #endif +/** + * _config_alloc_config_dma_memory - obtain physical memory + * @ioc: per adapter object + * @mem: struct config_request + * + * A wrapper for obtaining dma-able memory for config page request. + * + * Returns 0 for success, non-zero for failure. + */ +static int +_config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, + struct config_request *mem) +{ + int r = 0; + + if (mem->sz > ioc->config_page_sz) { + mem->page = dma_alloc_coherent(&ioc->pdev->dev, mem->sz, + &mem->page_dma, GFP_KERNEL); + if (!mem->page) { + printk(MPT2SAS_ERR_FMT "%s: dma_alloc_coherent" + " failed asking for (%d) bytes!!\n", + ioc->name, __func__, mem->sz); + r = -ENOMEM; + } + } else { /* use tmp buffer if less than 512 bytes */ + mem->page = ioc->config_page; + mem->page_dma = ioc->config_page_dma; + } + return r; +} + +/** + * _config_free_config_dma_memory - wrapper to free the memory + * @ioc: per adapter object + * @mem: struct config_request + * + * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory. + * + * Returns 0 for success, non-zero for failure. + */ +static void +_config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, + struct config_request *mem) +{ + if (mem->sz > ioc->config_page_sz) + dma_free_coherent(&ioc->pdev->dev, mem->sz, mem->page, + mem->page_dma); +} + /** * mpt2sas_config_done - config page completion routine * @ioc: per adapter object @@ -206,6 +255,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) #ifdef CONFIG_SCSI_MPT2SAS_LOGGING _config_display_some_debug(ioc, smid, "config_done", mpi_reply); #endif + ioc->config_cmds.smid = USHORT_MAX; complete(&ioc->config_cmds.done); } @@ -215,7 +265,9 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) * @mpi_request: request message frame * @mpi_reply: reply mf payload returned from firmware * @timeout: timeout in seconds - * Context: sleep, the calling function needs to acquire the config_cmds.mutex + * @config_page: contents of the config page + * @config_page_sz: size of config page + * Context: sleep * * A generic API for config page requests to firmware. * @@ -228,16 +280,17 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) */ static int _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t - *mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout) + *mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout, + void *config_page, u16 config_page_sz) { u16 smid; u32 ioc_state; unsigned long timeleft; Mpi2ConfigRequest_t *config_request; int r; - u8 retry_count; - u8 issue_host_reset = 0; + u8 retry_count, issue_host_reset = 0; u16 wait_state_count; + struct config_request mem; mutex_lock(&ioc->config_cmds.mutex); if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) { @@ -246,12 +299,44 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t mutex_unlock(&ioc->config_cmds.mutex); return -EAGAIN; } + retry_count = 0; + memset(&mem, 0, sizeof(struct config_request)); + + if (config_page) { + mpi_request->Header.PageVersion = mpi_reply->Header.PageVersion; + mpi_request->Header.PageNumber = mpi_reply->Header.PageNumber; + mpi_request->Header.PageType = mpi_reply->Header.PageType; + mpi_request->Header.PageLength = mpi_reply->Header.PageLength; + mpi_request->ExtPageLength = mpi_reply->ExtPageLength; + mpi_request->ExtPageType = mpi_reply->ExtPageType; + if (mpi_request->Header.PageLength) + mem.sz = mpi_request->Header.PageLength * 4; + else + mem.sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; + r = _config_alloc_config_dma_memory(ioc, &mem); + if (r != 0) + goto out; + if (mpi_request->Action == + MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT) { + ioc->base_add_sg_single(&mpi_request->PageBufferSGE, + MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.sz, + mem.page_dma); + memcpy(mem.page, config_page, min_t(u16, mem.sz, + config_page_sz)); + } else { + memset(config_page, 0, config_page_sz); + ioc->base_add_sg_single(&mpi_request->PageBufferSGE, + MPT2_CONFIG_COMMON_SGLFLAGS | mem.sz, mem.page_dma); + } + } retry_config: if (retry_count) { - if (retry_count > 2) /* attempt only 2 retries */ - return -EFAULT; + if (retry_count > 2) { /* attempt only 2 retries */ + r = -EFAULT; + goto free_mem; + } printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n", ioc->name, __func__, retry_count); } @@ -262,8 +347,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t printk(MPT2SAS_ERR_FMT "%s: failed due to ioc not operational\n", ioc->name, __func__); + ioc->config_cmds.status = MPT2_CMD_NOT_USED; r = -EFAULT; - goto out; + goto free_mem; } ssleep(1); ioc_state = mpt2sas_base_get_iocstate(ioc, 1); @@ -279,8 +365,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t if (!smid) { printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", ioc->name, __func__); + ioc->config_cmds.status = MPT2_CMD_NOT_USED; r = -EAGAIN; - goto out; + goto free_mem; } r = 0; @@ -292,6 +379,7 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t #ifdef CONFIG_SCSI_MPT2SAS_LOGGING _config_display_some_debug(ioc, smid, "config_request", NULL); #endif + init_completion(&ioc->config_cmds.done); mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID); timeleft = wait_for_completion_timeout(&ioc->config_cmds.done, timeout*HZ); @@ -303,67 +391,37 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t retry_count++; if (ioc->config_cmds.smid == smid) mpt2sas_base_free_smid(ioc, smid); - if ((ioc->shost_recovery) || - (ioc->config_cmds.status & MPT2_CMD_RESET)) + if ((ioc->shost_recovery) || (ioc->config_cmds.status & + MPT2_CMD_RESET)) goto retry_config; issue_host_reset = 1; r = -EFAULT; - goto out; + goto free_mem; } + if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID) memcpy(mpi_reply, ioc->config_cmds.reply, sizeof(Mpi2ConfigReply_t)); if (retry_count) - printk(MPT2SAS_INFO_FMT "%s: retry completed!!\n", - ioc->name, __func__); -out: + printk(MPT2SAS_INFO_FMT "%s: retry (%d) completed!!\n", + ioc->name, __func__, retry_count); + if (config_page && mpi_request->Action == + MPI2_CONFIG_ACTION_PAGE_READ_CURRENT) + memcpy(config_page, mem.page, min_t(u16, mem.sz, + config_page_sz)); + free_mem: + if (config_page) + _config_free_config_dma_memory(ioc, &mem); + out: ioc->config_cmds.status = MPT2_CMD_NOT_USED; mutex_unlock(&ioc->config_cmds.mutex); + if (issue_host_reset) mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, FORCE_BIG_HAMMER); return r; } -/** - * _config_alloc_config_dma_memory - obtain physical memory - * @ioc: per adapter object - * @mem: struct config_request - * - * A wrapper for obtaining dma-able memory for config page request. - * - * Returns 0 for success, non-zero for failure. - */ -static int -_config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, - struct config_request *mem) -{ - int r = 0; - - mem->config_page = pci_alloc_consistent(ioc->pdev, mem->config_page_sz, - &mem->config_page_dma); - if (!mem->config_page) - r = -ENOMEM; - return r; -} - -/** - * _config_free_config_dma_memory - wrapper to free the memory - * @ioc: per adapter object - * @mem: struct config_request - * - * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory. - * - * Returns 0 for success, non-zero for failure. - */ -static void -_config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, - struct config_request *mem) -{ - pci_free_consistent(ioc->pdev, mem->config_page_sz, mem->config_page, - mem->config_page_dma); -} - /** * mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0 * @ioc: per adapter object @@ -379,9 +437,7 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ManufacturingPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -390,37 +446,14 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ManufacturingPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -440,9 +473,7 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ManufacturingPage10_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -451,37 +482,14 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ManufacturingPage10_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -501,9 +509,7 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2BiosPage2_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -512,37 +518,14 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2BiosPage2_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -562,9 +545,7 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2BiosPage3_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -573,37 +554,14 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2BiosPage3_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -623,9 +581,7 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2IOUnitPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -634,37 +590,14 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2IOUnitPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -684,9 +617,7 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2IOUnitPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -695,37 +626,14 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2IOUnitPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -741,11 +649,10 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, */ int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, - Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t config_page) + Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t *config_page) { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; @@ -755,38 +662,14 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - - memset(mem.config_page, 0, mem.config_page_sz); - memcpy(mem.config_page, &config_page, - sizeof(Mpi2IOUnitPage1_t)); - - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -806,9 +689,7 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2IOCPage8_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -817,37 +698,14 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2IOCPage8_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -869,9 +727,7 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasDevicePage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -881,39 +737,15 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageNumber = 0; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasDevicePage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -935,9 +767,7 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasDevicePage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -947,39 +777,15 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageNumber = 1; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasDevicePage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -997,11 +803,11 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys) { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; u16 ioc_status; Mpi2ConfigReply_t mpi_reply; Mpi2SasIOUnitPage0_t config_page; + *num_phys = 0; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1011,44 +817,20 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys) mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; - mpi_request.Header.PageType = mpi_reply.Header.PageType; - mpi_request.ExtPageLength = mpi_reply.ExtPageLength; - mpi_request.ExtPageType = mpi_reply.ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply.ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page, + sizeof(Mpi2SasIOUnitPage0_t)); if (!r) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { - memcpy(&config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasIOUnitPage0_t))); + if (ioc_status == MPI2_IOCSTATUS_SUCCESS) *num_phys = config_page.NumPhys; - } } - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - out: return r; } @@ -1072,8 +854,7 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sz); + memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1083,37 +864,13 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, sz, mem.config_page_sz)); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); out: return r; } @@ -1137,9 +894,7 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sz); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1149,37 +904,13 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, sz, mem.config_page_sz)); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); out: return r; } @@ -1201,9 +932,7 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ExpanderPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1213,39 +942,15 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ExpanderPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1268,9 +973,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ExpanderPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1280,7 +983,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; @@ -1288,33 +991,9 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM | (phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ExpanderPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1336,9 +1015,7 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasEnclosurePage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1348,39 +1025,15 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasEnclosurePage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1401,9 +1054,7 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasPhyPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1413,40 +1064,16 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasPhyPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1467,9 +1094,7 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasPhyPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1479,40 +1104,16 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasPhyPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1535,9 +1136,7 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2RaidVolPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1546,38 +1145,15 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2RaidVolPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1596,10 +1172,9 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds) { Mpi2ConfigRequest_t mpi_request; - Mpi2RaidVolPage0_t *config_page; + Mpi2RaidVolPage0_t config_page; Mpi2ConfigReply_t mpi_reply; int r; - struct config_request mem; u16 ioc_status; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); @@ -1611,43 +1186,23 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; - mpi_request.Header.PageType = mpi_reply.Header.PageType; - mpi_request.Header.PageLength = mpi_reply.Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply.Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page, + sizeof(Mpi2RaidVolPage0_t)); if (!r) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { - config_page = mem.config_page; - *num_pds = config_page->NumPhysDisks; - } + if (ioc_status == MPI2_IOCSTATUS_SUCCESS) + *num_pds = config_page.NumPhysDisks; } - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - out: return r; } @@ -1671,10 +1226,8 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); - memset(config_page, 0, sz); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME; @@ -1682,37 +1235,14 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, sz, mem.config_page_sz)); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); out: return r; } @@ -1735,10 +1265,8 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); - memset(config_page, 0, sizeof(Mpi2RaidPhysDiskPage0_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK; @@ -1746,38 +1274,15 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | form_specific); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2RaidPhysDiskPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1795,11 +1300,10 @@ int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, u16 *volume_handle) { - Mpi2RaidConfigurationPage0_t *config_page; + Mpi2RaidConfigurationPage0_t *config_page = NULL; Mpi2ConfigRequest_t mpi_request; Mpi2ConfigReply_t mpi_reply; - int r, i; - struct config_request mem; + int r, i, config_page_sz; u16 ioc_status; *volume_handle = 0; @@ -1812,40 +1316,27 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, mpi_request.Header.PageNumber = 0; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; - mpi_request.Header.PageType = mpi_reply.Header.PageType; - mpi_request.ExtPageLength = mpi_reply.ExtPageLength; - mpi_request.ExtPageType = mpi_reply.ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply.ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); + config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4); + config_page = kmalloc(config_page_sz, GFP_KERNEL); + if (!config_page) + goto out; r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + config_page_sz); if (r) goto out; r = -1; ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; if (ioc_status != MPI2_IOCSTATUS_SUCCESS) - goto done; - config_page = mem.config_page; + goto out; for (i = 0; i < config_page->NumElements; i++) { if ((config_page->ConfigElement[i].ElementFlags & MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != @@ -1856,15 +1347,11 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, *volume_handle = le16_to_cpu(config_page-> ConfigElement[i].VolDevHandle); r = 0; - goto done; + goto out; } } - - done: - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - out: + kfree(config_page); return r; } diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index e71a6c04298b..774b34525bba 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -1836,6 +1836,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, mpi_request->TaskMID = cpu_to_le16(smid_task); int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); mpt2sas_scsih_set_tm_flag(ioc, handle); + init_completion(&ioc->tm_cmds.done); mpt2sas_base_put_smid_hi_priority(ioc, smid, VF_ID); timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); mpt2sas_scsih_clear_tm_flag(ioc, handle); -- cgit v1.2.3 From dc162b63bfc4201ca5c13df3fc8836c56979eb07 Mon Sep 17 00:00:00 2001 From: "Kashyap, Desai" Date: Thu, 20 Aug 2009 13:25:03 +0530 Subject: [SCSI] mpt2sas: Bump driver version 01.100.06.00 Bump version to 01.100.06.00 Signed-off-by: Kashyap Desai Reviewed-by:: Eric Moore Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h') diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index f4bf7ff8f480..2faab1e690e9 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -69,10 +69,10 @@ #define MPT2SAS_DRIVER_NAME "mpt2sas" #define MPT2SAS_AUTHOR "LSI Corporation " #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver" -#define MPT2SAS_DRIVER_VERSION "01.100.04.00" +#define MPT2SAS_DRIVER_VERSION "01.100.06.00" #define MPT2SAS_MAJOR_VERSION 01 #define MPT2SAS_MINOR_VERSION 100 -#define MPT2SAS_BUILD_VERSION 04 +#define MPT2SAS_BUILD_VERSION 06 #define MPT2SAS_RELEASE_VERSION 00 /* -- cgit v1.2.3