Commit 595bb0bd authored by Kashyap, Desai's avatar Kashyap, Desai Committed by James Bottomley

[SCSI] mpt2sas: Added SCSIIO, Internal and high priority memory pools to support multiple TM

1) create a pool of high priority message frames in the region of memory
between message frames and chains.  The modifications are in
_base_allocate_memory_pools.  Also create a seperate pool of memory for
internal commands located near the same region of memory.  The pool of high
priority message frames is restriced by the facts->HighPriorityCredit.

2) Create additional API for accessing request message frames. New function
mpt2sas_base_get_smid_hpr is for highpriority request. New function
mpt2sas_base_get_smid_scsiio for SCSI_IO, passing in the scsi command
pointer.  The mpt2sas_base_get_smid function is for requesting internal
commands.

3) Added new function _base_get_cb_idx to obtain the callback
index from one of the three pools of request message frames.

4) Removed wrapper functions _scsih_scsi_lookup_set and
_scsih_scsi_lookup_getclear. These were removed because this handling was
moved into mpt2sas_base_get_smid_scsiio and mpt2sas_base_free_smid.

5) The function mpt2sas_base_free_smid is modified so the request message
frames are put back on one of the three pools of request message frames.
Signed-off-by: default avatarKashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 19d3ebe3
This diff is collapsed.
...@@ -264,6 +264,13 @@ struct _internal_cmd { ...@@ -264,6 +264,13 @@ struct _internal_cmd {
* SAS Topology Structures * SAS Topology Structures
*/ */
#define MPTSAS_STATE_TR_SEND 0x0001
#define MPTSAS_STATE_TR_COMPLETE 0x0002
#define MPTSAS_STATE_CNTRL_SEND 0x0004
#define MPTSAS_STATE_CNTRL_COMPLETE 0x0008
#define MPT2SAS_REQ_SAS_CNTRL 0x0010
/** /**
* struct _sas_device - attached device information * struct _sas_device - attached device information
* @list: sas device list * @list: sas device list
...@@ -510,8 +517,9 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr); ...@@ -510,8 +517,9 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
* @config_page_sz: config page size * @config_page_sz: config page size
* @config_page: reserve memory for config page payload * @config_page: reserve memory for config page payload
* @config_page_dma: * @config_page_dma:
* @hba_queue_depth: hba request queue depth
* @sge_size: sg element size for either 32/64 bit * @sge_size: sg element size for either 32/64 bit
* @request_depth: hba request queue depth * @scsiio_depth: SCSI_IO queue depth
* @request_sz: per request frame size * @request_sz: per request frame size
* @request: pool of request frames * @request: pool of request frames
* @request_dma: * @request_dma:
...@@ -528,6 +536,18 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr); ...@@ -528,6 +536,18 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
* @chains_needed_per_io: max chains per io * @chains_needed_per_io: max chains per io
* @chain_offset_value_for_main_message: location 1st sg in main * @chain_offset_value_for_main_message: location 1st sg in main
* @chain_depth: total chains allocated * @chain_depth: total chains allocated
* @hi_priority_smid:
* @hi_priority:
* @hi_priority_dma:
* @hi_priority_depth:
* @hpr_lookup:
* @hpr_free_list:
* @internal_smid:
* @internal:
* @internal_dma:
* @internal_depth:
* @internal_lookup:
* @internal_free_list:
* @sense: pool of sense * @sense: pool of sense
* @sense_dma: * @sense_dma:
* @sense_dma_pool: * @sense_dma_pool:
...@@ -643,9 +663,10 @@ struct MPT2SAS_ADAPTER { ...@@ -643,9 +663,10 @@ struct MPT2SAS_ADAPTER {
void *config_page; void *config_page;
dma_addr_t config_page_dma; dma_addr_t config_page_dma;
/* request */ /* scsiio request */
u16 hba_queue_depth;
u16 sge_size; u16 sge_size;
u16 request_depth; u16 scsiio_depth;
u16 request_sz; u16 request_sz;
u8 *request; u8 *request;
dma_addr_t request_dma; dma_addr_t request_dma;
...@@ -665,6 +686,22 @@ struct MPT2SAS_ADAPTER { ...@@ -665,6 +686,22 @@ struct MPT2SAS_ADAPTER {
u16 chain_offset_value_for_main_message; u16 chain_offset_value_for_main_message;
u16 chain_depth; u16 chain_depth;
/* hi-priority queue */
u16 hi_priority_smid;
u8 *hi_priority;
dma_addr_t hi_priority_dma;
u16 hi_priority_depth;
struct request_tracker *hpr_lookup;
struct list_head hpr_free_list;
/* internal queue */
u16 internal_smid;
u8 *internal;
dma_addr_t internal_dma;
u16 internal_depth;
struct request_tracker *internal_lookup;
struct list_head internal_free_list;
/* sense */ /* sense */
u8 *sense; u8 *sense;
dma_addr_t sense_dma; dma_addr_t sense_dma;
...@@ -720,9 +757,13 @@ int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, ...@@ -720,9 +757,13 @@ int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid); void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid); void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr); void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
dma_addr_t mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid); dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
/* hi-priority queue */
u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
struct scsi_cmnd *scmd);
u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx); u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid); void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
......
...@@ -509,7 +509,7 @@ _ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg, ...@@ -509,7 +509,7 @@ _ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
handle = le16_to_cpu(tm_request->DevHandle); handle = le16_to_cpu(tm_request->DevHandle);
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
for (i = ioc->request_depth; i && !found; i--) { for (i = ioc->scsiio_depth; i && !found; i--) {
scmd = ioc->scsi_lookup[i - 1].scmd; scmd = ioc->scsi_lookup[i - 1].scmd;
if (scmd == NULL || scmd->device == NULL || if (scmd == NULL || scmd->device == NULL ||
scmd->device->hostdata == NULL) scmd->device->hostdata == NULL)
...@@ -616,7 +616,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc, ...@@ -616,7 +616,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n",
ioc->name, __func__); ioc->name, __func__);
smid = mpt2sas_base_get_smid(ioc, ioc->ctl_cb_idx); smid = mpt2sas_base_get_smid_scsiio(ioc, ioc->ctl_cb_idx, NULL);
if (!smid) { if (!smid) {
printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
ioc->name, __func__); ioc->name, __func__);
......
...@@ -762,66 +762,16 @@ _scsih_is_end_device(u32 device_info) ...@@ -762,66 +762,16 @@ _scsih_is_end_device(u32 device_info)
} }
/** /**
* _scsih_scsi_lookup_get - returns scmd entry * mptscsih_get_scsi_lookup - returns scmd entry
* @ioc: per adapter object * @ioc: per adapter object
* @smid: system request message index * @smid: system request message index
* Context: This function will acquire ioc->scsi_lookup_lock.
* *
* Returns the smid stored scmd pointer. * Returns the smid stored scmd pointer.
*/ */
static struct scsi_cmnd * static struct scsi_cmnd *
_scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid) _scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid)
{ {
unsigned long flags; return ioc->scsi_lookup[smid - 1].scmd;
struct scsi_cmnd *scmd;
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
scmd = ioc->scsi_lookup[smid - 1].scmd;
spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
return scmd;
}
/**
* mptscsih_getclear_scsi_lookup - returns scmd entry
* @ioc: per adapter object
* @smid: system request message index
* Context: This function will acquire ioc->scsi_lookup_lock.
*
* Returns the smid stored scmd pointer, as well as clearing the scmd pointer.
*/
static struct scsi_cmnd *
_scsih_scsi_lookup_getclear(struct MPT2SAS_ADAPTER *ioc, u16 smid)
{
unsigned long flags;
struct scsi_cmnd *scmd;
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
scmd = ioc->scsi_lookup[smid - 1].scmd;
ioc->scsi_lookup[smid - 1].scmd = NULL;
spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
return scmd;
}
/**
* _scsih_scsi_lookup_set - updates scmd entry in lookup
* @ioc: per adapter object
* @smid: system request message index
* @scmd: pointer to scsi command object
* Context: This function will acquire ioc->scsi_lookup_lock.
*
* This will save scmd pointer in the scsi_lookup array.
*
* Return nothing.
*/
static void
_scsih_scsi_lookup_set(struct MPT2SAS_ADAPTER *ioc, u16 smid,
struct scsi_cmnd *scmd)
{
unsigned long flags;
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
ioc->scsi_lookup[smid - 1].scmd = scmd;
spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
} }
/** /**
...@@ -844,9 +794,9 @@ _scsih_scsi_lookup_find_by_scmd(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd ...@@ -844,9 +794,9 @@ _scsih_scsi_lookup_find_by_scmd(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
smid = 0; smid = 0;
for (i = 0; i < ioc->request_depth; i++) { for (i = 0; i < ioc->scsiio_depth; i++) {
if (ioc->scsi_lookup[i].scmd == scmd) { if (ioc->scsi_lookup[i].scmd == scmd) {
smid = i + 1; smid = ioc->scsi_lookup[i].smid;
goto out; goto out;
} }
} }
...@@ -875,7 +825,7 @@ _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id, ...@@ -875,7 +825,7 @@ _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id,
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
found = 0; found = 0;
for (i = 0 ; i < ioc->request_depth; i++) { for (i = 0 ; i < ioc->scsiio_depth; i++) {
if (ioc->scsi_lookup[i].scmd && if (ioc->scsi_lookup[i].scmd &&
(ioc->scsi_lookup[i].scmd->device->id == id && (ioc->scsi_lookup[i].scmd->device->id == id &&
ioc->scsi_lookup[i].scmd->device->channel == channel)) { ioc->scsi_lookup[i].scmd->device->channel == channel)) {
...@@ -909,7 +859,7 @@ _scsih_scsi_lookup_find_by_lun(struct MPT2SAS_ADAPTER *ioc, int id, ...@@ -909,7 +859,7 @@ _scsih_scsi_lookup_find_by_lun(struct MPT2SAS_ADAPTER *ioc, int id,
spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
found = 0; found = 0;
for (i = 0 ; i < ioc->request_depth; i++) { for (i = 0 ; i < ioc->scsiio_depth; i++) {
if (ioc->scsi_lookup[i].scmd && if (ioc->scsi_lookup[i].scmd &&
(ioc->scsi_lookup[i].scmd->device->id == id && (ioc->scsi_lookup[i].scmd->device->id == id &&
ioc->scsi_lookup[i].scmd->device->channel == channel && ioc->scsi_lookup[i].scmd->device->channel == channel &&
...@@ -1119,7 +1069,7 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth) ...@@ -1119,7 +1069,7 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
} }
/** /**
* _scsih_change_queue_depth - changing device queue tag type * _scsih_change_queue_type - changing device queue tag type
* @sdev: scsi device struct * @sdev: scsi device struct
* @tag_type: requested tag type * @tag_type: requested tag type
* *
...@@ -1822,7 +1772,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, ...@@ -1822,7 +1772,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
goto issue_host_reset; goto issue_host_reset;
} }
smid = mpt2sas_base_get_smid(ioc, ioc->tm_cb_idx); smid = mpt2sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx);
if (!smid) { if (!smid) {
printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
ioc->name, __func__); ioc->name, __func__);
...@@ -1830,7 +1780,8 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, ...@@ -1830,7 +1780,8 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
} }
dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x)," dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x),"
" task_type(0x%02x), smid(%d)\n", ioc->name, handle, type, smid)); " task_type(0x%02x), smid(%d)\n", ioc->name, handle, type,
smid_task));
ioc->tm_cmds.status = MPT2_CMD_PENDING; ioc->tm_cmds.status = MPT2_CMD_PENDING;
mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
ioc->tm_cmds.smid = smid; ioc->tm_cmds.smid = smid;
...@@ -2082,7 +2033,7 @@ _scsih_target_reset(struct scsi_cmnd *scmd) ...@@ -2082,7 +2033,7 @@ _scsih_target_reset(struct scsi_cmnd *scmd)
} }
/** /**
* _scsih_abort - eh threads main host reset routine * _scsih_host_reset - eh threads main host reset routine
* @sdev: scsi device struct * @sdev: scsi device struct
* *
* Returns SUCCESS if command aborted else FAILED * Returns SUCCESS if command aborted else FAILED
...@@ -2440,8 +2391,8 @@ _scsih_flush_running_cmds(struct MPT2SAS_ADAPTER *ioc) ...@@ -2440,8 +2391,8 @@ _scsih_flush_running_cmds(struct MPT2SAS_ADAPTER *ioc)
u16 smid; u16 smid;
u16 count = 0; u16 count = 0;
for (smid = 1; smid <= ioc->request_depth; smid++) { for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
scmd = _scsih_scsi_lookup_getclear(ioc, smid); scmd = _scsih_scsi_lookup_get(ioc, smid);
if (!scmd) if (!scmd)
continue; continue;
count++; count++;
...@@ -2623,7 +2574,7 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *)) ...@@ -2623,7 +2574,7 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON)) if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON))
mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON; mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON;
smid = mpt2sas_base_get_smid(ioc, ioc->scsi_io_cb_idx); smid = mpt2sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd);
if (!smid) { if (!smid) {
printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
ioc->name, __func__); ioc->name, __func__);
...@@ -2665,7 +2616,6 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *)) ...@@ -2665,7 +2616,6 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
} }
} }
_scsih_scsi_lookup_set(ioc, smid, scmd);
mpt2sas_base_put_smid_scsi_io(ioc, smid, mpt2sas_base_put_smid_scsi_io(ioc, smid,
sas_device_priv_data->sas_target->handle); sas_device_priv_data->sas_target->handle);
return 0; return 0;
...@@ -2984,7 +2934,7 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) ...@@ -2984,7 +2934,7 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
u32 response_code; u32 response_code;
mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
scmd = _scsih_scsi_lookup_getclear(ioc, smid); scmd = _scsih_scsi_lookup_get(ioc, smid);
if (scmd == NULL) if (scmd == NULL)
return; return;
...@@ -3406,9 +3356,8 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle) ...@@ -3406,9 +3356,8 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
} }
} }
sas_address = le64_to_cpu(expander_pg0.SASAddress);
spin_lock_irqsave(&ioc->sas_node_lock, flags); spin_lock_irqsave(&ioc->sas_node_lock, flags);
sas_address = le64_to_cpu(expander_pg0.SASAddress);
sas_expander = mpt2sas_scsih_expander_find_by_sas_address(ioc, sas_expander = mpt2sas_scsih_expander_find_by_sas_address(ioc,
sas_address); sas_address);
spin_unlock_irqrestore(&ioc->sas_node_lock, flags); spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
...@@ -4081,7 +4030,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, ...@@ -4081,7 +4030,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
termination_count = 0; termination_count = 0;
query_count = 0; query_count = 0;
mpi_reply = ioc->tm_cmds.reply; mpi_reply = ioc->tm_cmds.reply;
for (smid = 1; smid <= ioc->request_depth; smid++) { for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
scmd = _scsih_scsi_lookup_get(ioc, smid); scmd = _scsih_scsi_lookup_get(ioc, smid);
if (!scmd) if (!scmd)
continue; continue;
...@@ -4145,8 +4094,8 @@ _scsih_sas_discovery_event(struct MPT2SAS_ADAPTER *ioc, ...@@ -4145,8 +4094,8 @@ _scsih_sas_discovery_event(struct MPT2SAS_ADAPTER *ioc,
(event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ? (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ?
"start" : "stop"); "start" : "stop");
if (event_data->DiscoveryStatus) if (event_data->DiscoveryStatus)
printk(MPT2SAS_DEBUG_FMT ", discovery_status(0x%08x)", printk("discovery_status(0x%08x)",
ioc->name, le32_to_cpu(event_data->DiscoveryStatus)); le32_to_cpu(event_data->DiscoveryStatus));
printk("\n"); printk("\n");
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment