diff options
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_config.c')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_config.c | 904 |
1 files changed, 226 insertions, 678 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c index 6ddee161beb..ab8c560865d 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_config.c +++ b/drivers/scsi/mpt2sas/mpt2sas_config.c @@ -72,15 +72,15 @@ /** * struct config_request - obtain dma memory via routine - * @config_page_sz: size - * @config_page: virt pointer - * @config_page_dma: phys pointer + * @sz: size + * @page: virt pointer + * @page_dma: phys pointer * */ struct config_request{ - u16 config_page_sz; - void *config_page; - dma_addr_t config_page_dma; + u16 sz; + void *page; + dma_addr_t page_dma; }; #ifdef CONFIG_SCSI_MPT2SAS_LOGGING @@ -175,6 +175,55 @@ _config_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid, #endif /** + * _config_alloc_config_dma_memory - obtain physical memory + * @ioc: per adapter object + * @mem: struct config_request + * + * A wrapper for obtaining dma-able memory for config page request. + * + * Returns 0 for success, non-zero for failure. + */ +static int +_config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, + struct config_request *mem) +{ + int r = 0; + + if (mem->sz > ioc->config_page_sz) { + mem->page = dma_alloc_coherent(&ioc->pdev->dev, mem->sz, + &mem->page_dma, GFP_KERNEL); + if (!mem->page) { + printk(MPT2SAS_ERR_FMT "%s: dma_alloc_coherent" + " failed asking for (%d) bytes!!\n", + ioc->name, __func__, mem->sz); + r = -ENOMEM; + } + } else { /* use tmp buffer if less than 512 bytes */ + mem->page = ioc->config_page; + mem->page_dma = ioc->config_page_dma; + } + return r; +} + +/** + * _config_free_config_dma_memory - wrapper to free the memory + * @ioc: per adapter object + * @mem: struct config_request + * + * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory. + * + * Returns 0 for success, non-zero for failure. + */ +static void +_config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, + struct config_request *mem) +{ + if (mem->sz > ioc->config_page_sz) + dma_free_coherent(&ioc->pdev->dev, mem->sz, mem->page, + mem->page_dma); +} + +/** * mpt2sas_config_done - config page completion routine * @ioc: per adapter object * @smid: system request message index @@ -206,6 +255,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) #ifdef CONFIG_SCSI_MPT2SAS_LOGGING _config_display_some_debug(ioc, smid, "config_done", mpi_reply); #endif + ioc->config_cmds.smid = USHORT_MAX; complete(&ioc->config_cmds.done); } @@ -215,7 +265,9 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) * @mpi_request: request message frame * @mpi_reply: reply mf payload returned from firmware * @timeout: timeout in seconds - * Context: sleep, the calling function needs to acquire the config_cmds.mutex + * @config_page: contents of the config page + * @config_page_sz: size of config page + * Context: sleep * * A generic API for config page requests to firmware. * @@ -228,16 +280,17 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) */ static int _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t - *mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout) + *mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout, + void *config_page, u16 config_page_sz) { u16 smid; u32 ioc_state; unsigned long timeleft; Mpi2ConfigRequest_t *config_request; int r; - u8 retry_count; - u8 issue_host_reset = 0; + u8 retry_count, issue_host_reset = 0; u16 wait_state_count; + struct config_request mem; mutex_lock(&ioc->config_cmds.mutex); if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) { @@ -246,12 +299,44 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t mutex_unlock(&ioc->config_cmds.mutex); return -EAGAIN; } + retry_count = 0; + memset(&mem, 0, sizeof(struct config_request)); + + if (config_page) { + mpi_request->Header.PageVersion = mpi_reply->Header.PageVersion; + mpi_request->Header.PageNumber = mpi_reply->Header.PageNumber; + mpi_request->Header.PageType = mpi_reply->Header.PageType; + mpi_request->Header.PageLength = mpi_reply->Header.PageLength; + mpi_request->ExtPageLength = mpi_reply->ExtPageLength; + mpi_request->ExtPageType = mpi_reply->ExtPageType; + if (mpi_request->Header.PageLength) + mem.sz = mpi_request->Header.PageLength * 4; + else + mem.sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; + r = _config_alloc_config_dma_memory(ioc, &mem); + if (r != 0) + goto out; + if (mpi_request->Action == + MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT) { + ioc->base_add_sg_single(&mpi_request->PageBufferSGE, + MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.sz, + mem.page_dma); + memcpy(mem.page, config_page, min_t(u16, mem.sz, + config_page_sz)); + } else { + memset(config_page, 0, config_page_sz); + ioc->base_add_sg_single(&mpi_request->PageBufferSGE, + MPT2_CONFIG_COMMON_SGLFLAGS | mem.sz, mem.page_dma); + } + } retry_config: if (retry_count) { - if (retry_count > 2) /* attempt only 2 retries */ - return -EFAULT; + if (retry_count > 2) { /* attempt only 2 retries */ + r = -EFAULT; + goto free_mem; + } printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n", ioc->name, __func__, retry_count); } @@ -262,8 +347,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t printk(MPT2SAS_ERR_FMT "%s: failed due to ioc not operational\n", ioc->name, __func__); + ioc->config_cmds.status = MPT2_CMD_NOT_USED; r = -EFAULT; - goto out; + goto free_mem; } ssleep(1); ioc_state = mpt2sas_base_get_iocstate(ioc, 1); @@ -279,8 +365,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t if (!smid) { printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", ioc->name, __func__); + ioc->config_cmds.status = MPT2_CMD_NOT_USED; r = -EAGAIN; - goto out; + goto free_mem; } r = 0; @@ -292,6 +379,7 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t #ifdef CONFIG_SCSI_MPT2SAS_LOGGING _config_display_some_debug(ioc, smid, "config_request", NULL); #endif + init_completion(&ioc->config_cmds.done); mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID); timeleft = wait_for_completion_timeout(&ioc->config_cmds.done, timeout*HZ); @@ -303,22 +391,31 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t retry_count++; if (ioc->config_cmds.smid == smid) mpt2sas_base_free_smid(ioc, smid); - if ((ioc->shost_recovery) || - (ioc->config_cmds.status & MPT2_CMD_RESET)) + if ((ioc->shost_recovery) || (ioc->config_cmds.status & + MPT2_CMD_RESET)) goto retry_config; issue_host_reset = 1; r = -EFAULT; - goto out; + goto free_mem; } + if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID) memcpy(mpi_reply, ioc->config_cmds.reply, sizeof(Mpi2ConfigReply_t)); if (retry_count) - printk(MPT2SAS_INFO_FMT "%s: retry completed!!\n", - ioc->name, __func__); -out: + printk(MPT2SAS_INFO_FMT "%s: retry (%d) completed!!\n", + ioc->name, __func__, retry_count); + if (config_page && mpi_request->Action == + MPI2_CONFIG_ACTION_PAGE_READ_CURRENT) + memcpy(config_page, mem.page, min_t(u16, mem.sz, + config_page_sz)); + free_mem: + if (config_page) + _config_free_config_dma_memory(ioc, &mem); + out: ioc->config_cmds.status = MPT2_CMD_NOT_USED; mutex_unlock(&ioc->config_cmds.mutex); + if (issue_host_reset) mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, FORCE_BIG_HAMMER); @@ -326,46 +423,43 @@ out: } /** - * _config_alloc_config_dma_memory - obtain physical memory + * mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0 * @ioc: per adapter object - * @mem: struct config_request - * - * A wrapper for obtaining dma-able memory for config page request. + * @mpi_reply: reply mf payload returned from firmware + * @config_page: contents of the config page + * Context: sleep. * * Returns 0 for success, non-zero for failure. */ -static int -_config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, - struct config_request *mem) +int +mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page) { - int r = 0; + Mpi2ConfigRequest_t mpi_request; + int r; - mem->config_page = pci_alloc_consistent(ioc->pdev, mem->config_page_sz, - &mem->config_page_dma); - if (!mem->config_page) - r = -ENOMEM; - return r; -} + memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); + mpi_request.Function = MPI2_FUNCTION_CONFIG; + mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; + mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_MANUFACTURING; + mpi_request.Header.PageNumber = 0; + mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; + mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); + r = _config_request(ioc, &mpi_request, mpi_reply, + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); + if (r) + goto out; -/** - * _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); + mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; + r = _config_request(ioc, &mpi_request, mpi_reply, + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); + out: + return r; } /** - * mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0 + * mpt2sas_config_get_manufacturing_pg10 - obtain manufacturing page 10 * @ioc: per adapter object * @mpi_reply: reply mf payload returned from firmware * @config_page: contents of the config page @@ -374,53 +468,28 @@ _config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, * Returns 0 for success, non-zero for failure. */ int -mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, - Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page) +mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page) { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ManufacturingPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_MANUFACTURING; - mpi_request.Header.PageNumber = 0; + mpi_request.Header.PageNumber = 10; mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ManufacturingPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -440,9 +509,7 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2BiosPage2_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -451,37 +518,14 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2BiosPage2_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -501,9 +545,7 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2BiosPage3_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -512,37 +554,14 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2BiosPage3_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -562,9 +581,7 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2IOUnitPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -573,37 +590,14 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2IOUnitPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -623,9 +617,7 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2IOUnitPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -634,37 +626,14 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2IOUnitPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -680,11 +649,10 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, */ int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, - Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t config_page) + Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t *config_page) { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; @@ -694,38 +662,14 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - - memset(mem.config_page, 0, mem.config_page_sz); - memcpy(mem.config_page, &config_page, - sizeof(Mpi2IOUnitPage1_t)); - - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -745,9 +689,7 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2IOCPage8_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -756,37 +698,14 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2IOCPage8_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -808,9 +727,7 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasDevicePage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -820,39 +737,15 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageNumber = 0; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasDevicePage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -874,9 +767,7 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasDevicePage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -886,39 +777,15 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageNumber = 1; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasDevicePage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -936,11 +803,11 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys) { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; u16 ioc_status; Mpi2ConfigReply_t mpi_reply; Mpi2SasIOUnitPage0_t config_page; + *num_phys = 0; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -950,44 +817,20 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys) mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; - mpi_request.Header.PageType = mpi_reply.Header.PageType; - mpi_request.ExtPageLength = mpi_reply.ExtPageLength; - mpi_request.ExtPageType = mpi_reply.ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply.ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page, + sizeof(Mpi2SasIOUnitPage0_t)); if (!r) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { - memcpy(&config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasIOUnitPage0_t))); + if (ioc_status == MPI2_IOCSTATUS_SUCCESS) *num_phys = config_page.NumPhys; - } } - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - out: return r; } @@ -1011,8 +854,7 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sz); + memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1022,37 +864,13 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, sz, mem.config_page_sz)); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); out: return r; } @@ -1076,9 +894,7 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sz); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1088,37 +904,13 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, sz, mem.config_page_sz)); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); out: return r; } @@ -1140,9 +932,7 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ExpanderPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1152,39 +942,15 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ExpanderPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1207,9 +973,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2ExpanderPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1219,7 +983,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; @@ -1227,33 +991,9 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM | (phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2ExpanderPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1275,9 +1015,7 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasEnclosurePage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1287,39 +1025,15 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasEnclosurePage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1340,9 +1054,7 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasPhyPage0_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1352,40 +1064,16 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasPhyPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1406,9 +1094,7 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2SasPhyPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1418,40 +1104,16 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.ExtPageLength = mpi_reply->ExtPageLength; - mpi_request.ExtPageType = mpi_reply->ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2SasPhyPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1474,9 +1136,7 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; - memset(config_page, 0, sizeof(Mpi2RaidVolPage1_t)); memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; @@ -1485,38 +1145,15 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2RaidVolPage1_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1535,10 +1172,9 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds) { Mpi2ConfigRequest_t mpi_request; - Mpi2RaidVolPage0_t *config_page; + Mpi2RaidVolPage0_t config_page; Mpi2ConfigReply_t mpi_reply; int r; - struct config_request mem; u16 ioc_status; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); @@ -1550,43 +1186,23 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; - mpi_request.Header.PageType = mpi_reply.Header.PageType; - mpi_request.Header.PageLength = mpi_reply.Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply.Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page, + sizeof(Mpi2RaidVolPage0_t)); if (!r) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { - config_page = mem.config_page; - *num_pds = config_page->NumPhysDisks; - } + if (ioc_status == MPI2_IOCSTATUS_SUCCESS) + *num_pds = config_page.NumPhysDisks; } - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - out: return r; } @@ -1610,10 +1226,8 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); - memset(config_page, 0, sz); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME; @@ -1621,37 +1235,14 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | handle); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, sz, mem.config_page_sz)); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); out: return r; } @@ -1674,10 +1265,8 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t { Mpi2ConfigRequest_t mpi_request; int r; - struct config_request mem; memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); - memset(config_page, 0, sizeof(Mpi2RaidPhysDiskPage0_t)); mpi_request.Function = MPI2_FUNCTION_CONFIG; mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK; @@ -1685,38 +1274,15 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(form | form_specific); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; - mpi_request.Header.PageType = mpi_reply->Header.PageType; - mpi_request.Header.PageLength = mpi_reply->Header.PageLength; - mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); r = _config_request(ioc, &mpi_request, mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); - if (!r) - memcpy(config_page, mem.config_page, - min_t(u16, mem.config_page_sz, - sizeof(Mpi2RaidPhysDiskPage0_t))); - - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + sizeof(*config_page)); out: return r; } @@ -1734,11 +1300,10 @@ int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, u16 *volume_handle) { - Mpi2RaidConfigurationPage0_t *config_page; + Mpi2RaidConfigurationPage0_t *config_page = NULL; Mpi2ConfigRequest_t mpi_request; Mpi2ConfigReply_t mpi_reply; - int r, i; - struct config_request mem; + int r, i, config_page_sz; u16 ioc_status; *volume_handle = 0; @@ -1751,40 +1316,27 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, mpi_request.Header.PageNumber = 0; mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); if (r) goto out; mpi_request.PageAddress = cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG); mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; - mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; - mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; - mpi_request.Header.PageType = mpi_reply.Header.PageType; - mpi_request.ExtPageLength = mpi_reply.ExtPageLength; - mpi_request.ExtPageType = mpi_reply.ExtPageType; - mem.config_page_sz = le16_to_cpu(mpi_reply.ExtPageLength) * 4; - if (mem.config_page_sz > ioc->config_page_sz) { - r = _config_alloc_config_dma_memory(ioc, &mem); - if (r) - goto out; - } else { - mem.config_page_dma = ioc->config_page_dma; - mem.config_page = ioc->config_page; - } - ioc->base_add_sg_single(&mpi_request.PageBufferSGE, - MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, - mem.config_page_dma); + config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4); + config_page = kmalloc(config_page_sz, GFP_KERNEL); + if (!config_page) + goto out; r = _config_request(ioc, &mpi_request, &mpi_reply, - MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); + MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, + config_page_sz); if (r) goto out; r = -1; ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; if (ioc_status != MPI2_IOCSTATUS_SUCCESS) - goto done; - config_page = mem.config_page; + goto out; for (i = 0; i < config_page->NumElements; i++) { if ((config_page->ConfigElement[i].ElementFlags & MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != @@ -1795,15 +1347,11 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, *volume_handle = le16_to_cpu(config_page-> ConfigElement[i].VolDevHandle); r = 0; - goto done; + goto out; } } - - done: - if (mem.config_page_sz > ioc->config_page_sz) - _config_free_config_dma_memory(ioc, &mem); - out: + kfree(config_page); return r; } |