Commit 5b768581 authored by Kashyap, Desai's avatar Kashyap, Desai Committed by James Bottomley

[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: default avatarKashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: default avatarEric Moore <Eric.moore@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent ed79f128
...@@ -687,6 +687,14 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) ...@@ -687,6 +687,14 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc)
ioc->mask_interrupts = 0; ioc->mask_interrupts = 0;
} }
union reply_descriptor {
u64 word;
struct {
u32 low;
u32 high;
} u;
};
/** /**
* _base_interrupt - MPT adapter (IOC) specific interrupt handler. * _base_interrupt - MPT adapter (IOC) specific interrupt handler.
* @irq: irq number (not used) * @irq: irq number (not used)
...@@ -698,47 +706,38 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) ...@@ -698,47 +706,38 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc)
static irqreturn_t static irqreturn_t
_base_interrupt(int irq, void *bus_id) _base_interrupt(int irq, void *bus_id)
{ {
union reply_descriptor {
u64 word;
struct {
u32 low;
u32 high;
} u;
};
union reply_descriptor rd; union reply_descriptor rd;
u32 post_index, post_index_next, completed_cmds; u32 completed_cmds;
u8 request_desript_type; u8 request_desript_type;
u16 smid; u16 smid;
u8 cb_idx; u8 cb_idx;
u32 reply; u32 reply;
u8 VF_ID; u8 VF_ID;
int i;
struct MPT2SAS_ADAPTER *ioc = bus_id; struct MPT2SAS_ADAPTER *ioc = bus_id;
Mpi2ReplyDescriptorsUnion_t *rpf;
if (ioc->mask_interrupts) if (ioc->mask_interrupts)
return IRQ_NONE; return IRQ_NONE;
post_index = ioc->reply_post_host_index; rpf = &ioc->reply_post_free[ioc->reply_post_host_index];
request_desript_type = ioc->reply_post_free[post_index]. request_desript_type = rpf->Default.ReplyFlags
Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
return IRQ_NONE; return IRQ_NONE;
completed_cmds = 0; completed_cmds = 0;
do { 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) if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX)
goto out; goto out;
reply = 0; reply = 0;
cb_idx = 0xFF; cb_idx = 0xFF;
smid = le16_to_cpu(ioc->reply_post_free[post_index]. smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1);
Default.DescriptorTypeDependent1); VF_ID = rpf->Default.VF_ID;
VF_ID = ioc->reply_post_free[post_index].
Default.VF_ID;
if (request_desript_type == if (request_desript_type ==
MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) {
reply = le32_to_cpu(ioc->reply_post_free[post_index]. reply = le32_to_cpu
AddressReply.ReplyFrameAddress); (rpf->AddressReply.ReplyFrameAddress);
} else if (request_desript_type == } else if (request_desript_type ==
MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER) MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER)
goto next; goto next;
...@@ -765,21 +764,27 @@ _base_interrupt(int irq, void *bus_id) ...@@ -765,21 +764,27 @@ _base_interrupt(int irq, void *bus_id)
0 : ioc->reply_free_host_index + 1; 0 : ioc->reply_free_host_index + 1;
ioc->reply_free[ioc->reply_free_host_index] = ioc->reply_free[ioc->reply_free_host_index] =
cpu_to_le32(reply); cpu_to_le32(reply);
wmb();
writel(ioc->reply_free_host_index, writel(ioc->reply_free_host_index,
&ioc->chip->ReplyFreeHostIndex); &ioc->chip->ReplyFreeHostIndex);
wmb();
} }
next: 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 = request_desript_type =
ioc->reply_post_free[post_index_next].Default.ReplyFlags ioc->reply_post_free[ioc->reply_post_host_index].Default.
& MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
completed_cmds++; completed_cmds++;
if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
goto out; goto out;
post_index = post_index_next; if (!ioc->reply_post_host_index)
rpf = ioc->reply_post_free;
else
rpf++;
} while (1); } while (1);
out: out:
...@@ -787,19 +792,8 @@ _base_interrupt(int irq, void *bus_id) ...@@ -787,19 +792,8 @@ _base_interrupt(int irq, void *bus_id)
if (!completed_cmds) if (!completed_cmds)
return IRQ_NONE; 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(); wmb();
writel(ioc->reply_post_host_index, &ioc->chip->ReplyPostHostIndex);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -1650,7 +1644,7 @@ _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc) ...@@ -1650,7 +1644,7 @@ _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc)
iounit_pg1_flags |= iounit_pg1_flags |=
MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING; MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING;
ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); 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) ...@@ -3306,13 +3300,11 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
ioc->tm_cmds.status = MPT2_CMD_NOT_USED; ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
mutex_init(&ioc->tm_cmds.mutex); mutex_init(&ioc->tm_cmds.mutex);
init_completion(&ioc->tm_cmds.done);
/* config page internal command bits */ /* config page internal command bits */
ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
ioc->config_cmds.status = MPT2_CMD_NOT_USED; ioc->config_cmds.status = MPT2_CMD_NOT_USED;
mutex_init(&ioc->config_cmds.mutex); mutex_init(&ioc->config_cmds.mutex);
init_completion(&ioc->config_cmds.done);
/* ctl module internal command bits */ /* ctl module internal command bits */
ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
...@@ -3436,6 +3428,7 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) ...@@ -3436,6 +3428,7 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
if (ioc->config_cmds.status & MPT2_CMD_PENDING) { if (ioc->config_cmds.status & MPT2_CMD_PENDING) {
ioc->config_cmds.status |= MPT2_CMD_RESET; ioc->config_cmds.status |= MPT2_CMD_RESET;
mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid);
ioc->config_cmds.smid = USHORT_MAX;
complete(&ioc->config_cmds.done); complete(&ioc->config_cmds.done);
} }
break; break;
......
...@@ -785,7 +785,7 @@ int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRep ...@@ -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 int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
*mpi_reply, Mpi2IOUnitPage1_t *config_page); *mpi_reply, Mpi2IOUnitPage1_t *config_page);
int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 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 int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
*mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz); *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
......
...@@ -72,15 +72,15 @@ ...@@ -72,15 +72,15 @@
/** /**
* struct config_request - obtain dma memory via routine * struct config_request - obtain dma memory via routine
* @config_page_sz: size * @sz: size
* @config_page: virt pointer * @page: virt pointer
* @config_page_dma: phys pointer * @page_dma: phys pointer
* *
*/ */
struct config_request{ struct config_request{
u16 config_page_sz; u16 sz;
void *config_page; void *page;
dma_addr_t config_page_dma; dma_addr_t page_dma;
}; };
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
...@@ -174,6 +174,55 @@ _config_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid, ...@@ -174,6 +174,55 @@ _config_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid,
} }
#endif #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 * mpt2sas_config_done - config page completion routine
* @ioc: per adapter object * @ioc: per adapter object
...@@ -206,6 +255,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) ...@@ -206,6 +255,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
_config_display_some_debug(ioc, smid, "config_done", mpi_reply); _config_display_some_debug(ioc, smid, "config_done", mpi_reply);
#endif #endif
ioc->config_cmds.smid = USHORT_MAX;
complete(&ioc->config_cmds.done); complete(&ioc->config_cmds.done);
} }
...@@ -215,7 +265,9 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) ...@@ -215,7 +265,9 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
* @mpi_request: request message frame * @mpi_request: request message frame
* @mpi_reply: reply mf payload returned from firmware * @mpi_reply: reply mf payload returned from firmware
* @timeout: timeout in seconds * @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. * 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) ...@@ -228,16 +280,17 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
*/ */
static int static int
_config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t _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; u16 smid;
u32 ioc_state; u32 ioc_state;
unsigned long timeleft; unsigned long timeleft;
Mpi2ConfigRequest_t *config_request; Mpi2ConfigRequest_t *config_request;
int r; int r;
u8 retry_count; u8 retry_count, issue_host_reset = 0;
u8 issue_host_reset = 0;
u16 wait_state_count; u16 wait_state_count;
struct config_request mem;
mutex_lock(&ioc->config_cmds.mutex); mutex_lock(&ioc->config_cmds.mutex);
if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) { if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) {
...@@ -246,12 +299,44 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t ...@@ -246,12 +299,44 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
mutex_unlock(&ioc->config_cmds.mutex); mutex_unlock(&ioc->config_cmds.mutex);
return -EAGAIN; return -EAGAIN;
} }
retry_count = 0; 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: retry_config:
if (retry_count) { if (retry_count) {
if (retry_count > 2) /* attempt only 2 retries */ if (retry_count > 2) { /* attempt only 2 retries */
return -EFAULT; r = -EFAULT;
goto free_mem;
}
printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n", printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n",
ioc->name, __func__, retry_count); ioc->name, __func__, retry_count);
} }
...@@ -262,8 +347,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t ...@@ -262,8 +347,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
printk(MPT2SAS_ERR_FMT printk(MPT2SAS_ERR_FMT
"%s: failed due to ioc not operational\n", "%s: failed due to ioc not operational\n",
ioc->name, __func__); ioc->name, __func__);
ioc->config_cmds.status = MPT2_CMD_NOT_USED;
r = -EFAULT; r = -EFAULT;
goto out; goto free_mem;
} }
ssleep(1); ssleep(1);
ioc_state = mpt2sas_base_get_iocstate(ioc, 1); ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
...@@ -279,8 +365,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t ...@@ -279,8 +365,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
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__);
ioc->config_cmds.status = MPT2_CMD_NOT_USED;
r = -EAGAIN; r = -EAGAIN;
goto out; goto free_mem;
} }
r = 0; r = 0;
...@@ -292,6 +379,7 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t ...@@ -292,6 +379,7 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
_config_display_some_debug(ioc, smid, "config_request", NULL); _config_display_some_debug(ioc, smid, "config_request", NULL);
#endif #endif
init_completion(&ioc->config_cmds.done);
mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID); mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID);
timeleft = wait_for_completion_timeout(&ioc->config_cmds.done, timeleft = wait_for_completion_timeout(&ioc->config_cmds.done,
timeout*HZ); timeout*HZ);
...@@ -303,67 +391,37 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t ...@@ -303,67 +391,37 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
retry_count++; retry_count++;
if (ioc->config_cmds.smid == smid) if (ioc->config_cmds.smid == smid)
mpt2sas_base_free_smid(ioc, smid); mpt2sas_base_free_smid(ioc, smid);
if ((ioc->shost_recovery) || if ((ioc->shost_recovery) || (ioc->config_cmds.status &
(ioc->config_cmds.status & MPT2_CMD_RESET)) MPT2_CMD_RESET))
goto retry_config; goto retry_config;
issue_host_reset = 1; issue_host_reset = 1;
r = -EFAULT; r = -EFAULT;
goto out; goto free_mem;
} }
if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID) if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID)
memcpy(mpi_reply, ioc->config_cmds.reply, memcpy(mpi_reply, ioc->config_cmds.reply,
sizeof(Mpi2ConfigReply_t)); sizeof(Mpi2ConfigReply_t));
if (retry_count) if (retry_count)
printk(MPT2SAS_INFO_FMT "%s: retry completed!!\n", printk(MPT2SAS_INFO_FMT "%s: retry (%d) completed!!\n",
ioc->name, __func__); ioc->name, __func__, retry_count);
out: 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; ioc->config_cmds.status = MPT2_CMD_NOT_USED;
mutex_unlock(&ioc->config_cmds.mutex); mutex_unlock(&ioc->config_cmds.mutex);
if (issue_host_reset) if (issue_host_reset)
mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
FORCE_BIG_HAMMER); FORCE_BIG_HAMMER);
return r; 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 * mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0
* @ioc: per adapter object * @ioc: per adapter object
...@@ -379,9 +437,7 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, ...@@ -379,9 +437,7 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2ManufacturingPage0_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -390,37 +446,14 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, ...@@ -390,37 +446,14 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -440,9 +473,7 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, ...@@ -440,9 +473,7 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2ManufacturingPage10_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -451,37 +482,14 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, ...@@ -451,37 +482,14 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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: out:
return r; return r;
} }
...@@ -501,9 +509,7 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, ...@@ -501,9 +509,7 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2BiosPage2_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -512,37 +518,14 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, ...@@ -512,37 +518,14 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -562,9 +545,7 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -562,9 +545,7 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2BiosPage3_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -573,37 +554,14 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -573,37 +554,14 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -623,9 +581,7 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, ...@@ -623,9 +581,7 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2IOUnitPage0_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -634,37 +590,14 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, ...@@ -634,37 +590,14 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -684,9 +617,7 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, ...@@ -684,9 +617,7 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2IOUnitPage1_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -695,37 +626,14 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, ...@@ -695,37 +626,14 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -741,11 +649,10 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, ...@@ -741,11 +649,10 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
*/ */
int int
mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, 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; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
...@@ -755,38 +662,14 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, ...@@ -755,38 +662,14 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
sizeof(*config_page));
if (mem.config_page_sz > ioc->config_page_sz)
_config_free_config_dma_memory(ioc, &mem);
out: out:
return r; return r;
} }
...@@ -806,9 +689,7 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, ...@@ -806,9 +689,7 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2IOCPage8_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -817,37 +698,14 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, ...@@ -817,37 +698,14 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -869,9 +727,7 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -869,9 +727,7 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2SasDevicePage0_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -881,39 +737,15 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -881,39 +737,15 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageNumber = 0; mpi_request.Header.PageNumber = 0;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.PageAddress = cpu_to_le32(form | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -935,9 +767,7 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -935,9 +767,7 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2SasDevicePage1_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -947,39 +777,15 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -947,39 +777,15 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageNumber = 1; mpi_request.Header.PageNumber = 1;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.PageAddress = cpu_to_le32(form | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -997,11 +803,11 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys) ...@@ -997,11 +803,11 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys)
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
u16 ioc_status; u16 ioc_status;
Mpi2ConfigReply_t mpi_reply; Mpi2ConfigReply_t mpi_reply;
Mpi2SasIOUnitPage0_t config_page; Mpi2SasIOUnitPage0_t config_page;
*num_phys = 0;
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; 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) ...@@ -1011,44 +817,20 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys)
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, &mpi_reply, r = _config_request(ioc, &mpi_request, &mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, 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) { if (!r) {
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
MPI2_IOCSTATUS_MASK; MPI2_IOCSTATUS_MASK;
if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { if (ioc_status == MPI2_IOCSTATUS_SUCCESS)
memcpy(&config_page, mem.config_page,
min_t(u16, mem.config_page_sz,
sizeof(Mpi2SasIOUnitPage0_t)));
*num_phys = config_page.NumPhys; *num_phys = config_page.NumPhys;
}
} }
if (mem.config_page_sz > ioc->config_page_sz)
_config_free_config_dma_memory(ioc, &mem);
out: out:
return r; return r;
} }
...@@ -1072,8 +854,7 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1072,8 +854,7 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sz);
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1083,37 +864,13 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1083,37 +864,13 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
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);
out: out:
return r; return r;
} }
...@@ -1137,9 +894,7 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1137,9 +894,7 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sz);
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1149,37 +904,13 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1149,37 +904,13 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
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);
out: out:
return r; return r;
} }
...@@ -1201,9 +932,7 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1201,9 +932,7 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2ExpanderPage0_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1213,39 +942,15 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1213,39 +942,15 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.PageAddress = cpu_to_le32(form | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1268,9 +973,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1268,9 +973,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2ExpanderPage1_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1280,7 +983,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1280,7 +983,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
...@@ -1288,33 +991,9 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -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 | cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM |
(phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle); (phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1336,9 +1015,7 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1336,9 +1015,7 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2SasEnclosurePage0_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1348,39 +1025,15 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1348,39 +1025,15 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.PageAddress = cpu_to_le32(form | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1401,9 +1054,7 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1401,9 +1054,7 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2SasPhyPage0_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1413,40 +1064,16 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1413,40 +1064,16 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = mpi_request.PageAddress =
cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1467,9 +1094,7 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1467,9 +1094,7 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2SasPhyPage1_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1479,40 +1104,16 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1479,40 +1104,16 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = mpi_request.PageAddress =
cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1535,9 +1136,7 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, ...@@ -1535,9 +1136,7 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(config_page, 0, sizeof(Mpi2RaidVolPage1_t));
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
...@@ -1546,38 +1145,15 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, ...@@ -1546,38 +1145,15 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.PageAddress = cpu_to_le32(form | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1596,10 +1172,9 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, ...@@ -1596,10 +1172,9 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle,
u8 *num_pds) u8 *num_pds)
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
Mpi2RaidVolPage0_t *config_page; Mpi2RaidVolPage0_t config_page;
Mpi2ConfigReply_t mpi_reply; Mpi2ConfigReply_t mpi_reply;
int r; int r;
struct config_request mem;
u16 ioc_status; u16 ioc_status;
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
...@@ -1611,43 +1186,23 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, ...@@ -1611,43 +1186,23 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle,
mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, &mpi_reply, r = _config_request(ioc, &mpi_request, &mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = mpi_request.PageAddress =
cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle); cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, 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) { if (!r) {
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
MPI2_IOCSTATUS_MASK; MPI2_IOCSTATUS_MASK;
if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { if (ioc_status == MPI2_IOCSTATUS_SUCCESS)
config_page = mem.config_page; *num_pds = config_page.NumPhysDisks;
*num_pds = config_page->NumPhysDisks;
}
} }
if (mem.config_page_sz > ioc->config_page_sz)
_config_free_config_dma_memory(ioc, &mem);
out: out:
return r; return r;
} }
...@@ -1671,10 +1226,8 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, ...@@ -1671,10 +1226,8 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc,
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
memset(config_page, 0, sz);
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME; mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME;
...@@ -1682,37 +1235,14 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, ...@@ -1682,37 +1235,14 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc,
mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.PageAddress = cpu_to_le32(form | handle);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
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);
out: out:
return r; return r;
} }
...@@ -1735,10 +1265,8 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t ...@@ -1735,10 +1265,8 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
{ {
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
int r; int r;
struct config_request mem;
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
memset(config_page, 0, sizeof(Mpi2RaidPhysDiskPage0_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK; 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 ...@@ -1746,38 +1274,15 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION; mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = cpu_to_le32(form | form_specific); mpi_request.PageAddress = cpu_to_le32(form | form_specific);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 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, r = _config_request(ioc, &mpi_request, mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
if (!r) sizeof(*config_page));
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);
out: out:
return r; return r;
} }
...@@ -1795,11 +1300,10 @@ int ...@@ -1795,11 +1300,10 @@ int
mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
u16 *volume_handle) u16 *volume_handle)
{ {
Mpi2RaidConfigurationPage0_t *config_page; Mpi2RaidConfigurationPage0_t *config_page = NULL;
Mpi2ConfigRequest_t mpi_request; Mpi2ConfigRequest_t mpi_request;
Mpi2ConfigReply_t mpi_reply; Mpi2ConfigReply_t mpi_reply;
int r, i; int r, i, config_page_sz;
struct config_request mem;
u16 ioc_status; u16 ioc_status;
*volume_handle = 0; *volume_handle = 0;
...@@ -1812,40 +1316,27 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, ...@@ -1812,40 +1316,27 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
mpi_request.Header.PageNumber = 0; mpi_request.Header.PageNumber = 0;
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, &mpi_reply, r = _config_request(ioc, &mpi_request, &mpi_reply,
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r) if (r)
goto out; goto out;
mpi_request.PageAddress = mpi_request.PageAddress =
cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG); cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG);
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4);
mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; config_page = kmalloc(config_page_sz, GFP_KERNEL);
mpi_request.Header.PageType = mpi_reply.Header.PageType; if (!config_page)
mpi_request.ExtPageLength = mpi_reply.ExtPageLength; goto out;
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, 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) if (r)
goto out; goto out;
r = -1; r = -1;
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
if (ioc_status != MPI2_IOCSTATUS_SUCCESS) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
goto done; goto out;
config_page = mem.config_page;
for (i = 0; i < config_page->NumElements; i++) { for (i = 0; i < config_page->NumElements; i++) {
if ((config_page->ConfigElement[i].ElementFlags & if ((config_page->ConfigElement[i].ElementFlags &
MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) !=
...@@ -1856,15 +1347,11 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, ...@@ -1856,15 +1347,11 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
*volume_handle = le16_to_cpu(config_page-> *volume_handle = le16_to_cpu(config_page->
ConfigElement[i].VolDevHandle); ConfigElement[i].VolDevHandle);
r = 0; r = 0;
goto done; goto out;
} }
} }
done:
if (mem.config_page_sz > ioc->config_page_sz)
_config_free_config_dma_memory(ioc, &mem);
out: out:
kfree(config_page);
return r; return r;
} }
......
...@@ -1836,6 +1836,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, ...@@ -1836,6 +1836,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
mpi_request->TaskMID = cpu_to_le16(smid_task); mpi_request->TaskMID = cpu_to_le16(smid_task);
int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN);
mpt2sas_scsih_set_tm_flag(ioc, handle); mpt2sas_scsih_set_tm_flag(ioc, handle);
init_completion(&ioc->tm_cmds.done);
mpt2sas_base_put_smid_hi_priority(ioc, smid, VF_ID); mpt2sas_base_put_smid_hi_priority(ioc, smid, VF_ID);
timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ);
mpt2sas_scsih_clear_tm_flag(ioc, handle); mpt2sas_scsih_clear_tm_flag(ioc, handle);
......
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