diff options
author | Kashyap, Desai <kashyap.desai@lsi.com> | 2009-08-20 03:54:31 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-09-05 10:36:30 -0400 |
commit | 5b768581ea722172f059ad5a5eebea9008961af0 (patch) | |
tree | 1bd620747bcbcf6abae9e8f8e46ce0beb6029bfc /drivers/scsi/mpt2sas | |
parent | ed79f1280d1bc54f168abcffc8c3e0bf8ffb1873 (diff) |
[SCSI] mpt2sas: cleanup interrupt routine and config_request optimization
Cleaned up base_interrupt routine to be more effiecent.
Deleted about a third of the config page API by moving redundant code from all
the calling functions to _config_request.
Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/mpt2sas')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.c | 73 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.h | 2 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_config.c | 911 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_scsih.c | 1 |
4 files changed, 234 insertions, 753 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 2e4bc3d2b435..d95d2f274cb3 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -687,6 +687,14 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) | |||
687 | ioc->mask_interrupts = 0; | 687 | ioc->mask_interrupts = 0; |
688 | } | 688 | } |
689 | 689 | ||
690 | union reply_descriptor { | ||
691 | u64 word; | ||
692 | struct { | ||
693 | u32 low; | ||
694 | u32 high; | ||
695 | } u; | ||
696 | }; | ||
697 | |||
690 | /** | 698 | /** |
691 | * _base_interrupt - MPT adapter (IOC) specific interrupt handler. | 699 | * _base_interrupt - MPT adapter (IOC) specific interrupt handler. |
692 | * @irq: irq number (not used) | 700 | * @irq: irq number (not used) |
@@ -698,47 +706,38 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) | |||
698 | static irqreturn_t | 706 | static irqreturn_t |
699 | _base_interrupt(int irq, void *bus_id) | 707 | _base_interrupt(int irq, void *bus_id) |
700 | { | 708 | { |
701 | union reply_descriptor { | ||
702 | u64 word; | ||
703 | struct { | ||
704 | u32 low; | ||
705 | u32 high; | ||
706 | } u; | ||
707 | }; | ||
708 | union reply_descriptor rd; | 709 | union reply_descriptor rd; |
709 | u32 post_index, post_index_next, completed_cmds; | 710 | u32 completed_cmds; |
710 | u8 request_desript_type; | 711 | u8 request_desript_type; |
711 | u16 smid; | 712 | u16 smid; |
712 | u8 cb_idx; | 713 | u8 cb_idx; |
713 | u32 reply; | 714 | u32 reply; |
714 | u8 VF_ID; | 715 | u8 VF_ID; |
715 | int i; | ||
716 | struct MPT2SAS_ADAPTER *ioc = bus_id; | 716 | struct MPT2SAS_ADAPTER *ioc = bus_id; |
717 | Mpi2ReplyDescriptorsUnion_t *rpf; | ||
717 | 718 | ||
718 | if (ioc->mask_interrupts) | 719 | if (ioc->mask_interrupts) |
719 | return IRQ_NONE; | 720 | return IRQ_NONE; |
720 | 721 | ||
721 | post_index = ioc->reply_post_host_index; | 722 | rpf = &ioc->reply_post_free[ioc->reply_post_host_index]; |
722 | request_desript_type = ioc->reply_post_free[post_index]. | 723 | request_desript_type = rpf->Default.ReplyFlags |
723 | Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; | 724 | & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; |
724 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) | 725 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) |
725 | return IRQ_NONE; | 726 | return IRQ_NONE; |
726 | 727 | ||
727 | completed_cmds = 0; | 728 | completed_cmds = 0; |
728 | do { | 729 | do { |
729 | rd.word = ioc->reply_post_free[post_index].Words; | 730 | rd.word = rpf->Words; |
730 | if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX) | 731 | if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX) |
731 | goto out; | 732 | goto out; |
732 | reply = 0; | 733 | reply = 0; |
733 | cb_idx = 0xFF; | 734 | cb_idx = 0xFF; |
734 | smid = le16_to_cpu(ioc->reply_post_free[post_index]. | 735 | smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1); |
735 | Default.DescriptorTypeDependent1); | 736 | VF_ID = rpf->Default.VF_ID; |
736 | VF_ID = ioc->reply_post_free[post_index]. | ||
737 | Default.VF_ID; | ||
738 | if (request_desript_type == | 737 | if (request_desript_type == |
739 | MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { | 738 | MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { |
740 | reply = le32_to_cpu(ioc->reply_post_free[post_index]. | 739 | reply = le32_to_cpu |
741 | AddressReply.ReplyFrameAddress); | 740 | (rpf->AddressReply.ReplyFrameAddress); |
742 | } else if (request_desript_type == | 741 | } else if (request_desript_type == |
743 | MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER) | 742 | MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER) |
744 | goto next; | 743 | goto next; |
@@ -765,21 +764,27 @@ _base_interrupt(int irq, void *bus_id) | |||
765 | 0 : ioc->reply_free_host_index + 1; | 764 | 0 : ioc->reply_free_host_index + 1; |
766 | ioc->reply_free[ioc->reply_free_host_index] = | 765 | ioc->reply_free[ioc->reply_free_host_index] = |
767 | cpu_to_le32(reply); | 766 | cpu_to_le32(reply); |
767 | wmb(); | ||
768 | writel(ioc->reply_free_host_index, | 768 | writel(ioc->reply_free_host_index, |
769 | &ioc->chip->ReplyFreeHostIndex); | 769 | &ioc->chip->ReplyFreeHostIndex); |
770 | wmb(); | ||
771 | } | 770 | } |
772 | 771 | ||
773 | next: | 772 | next: |
774 | post_index_next = (post_index == (ioc->reply_post_queue_depth - | 773 | |
775 | 1)) ? 0 : post_index + 1; | 774 | rpf->Words = ULLONG_MAX; |
775 | ioc->reply_post_host_index = (ioc->reply_post_host_index == | ||
776 | (ioc->reply_post_queue_depth - 1)) ? 0 : | ||
777 | ioc->reply_post_host_index + 1; | ||
776 | request_desript_type = | 778 | request_desript_type = |
777 | ioc->reply_post_free[post_index_next].Default.ReplyFlags | 779 | ioc->reply_post_free[ioc->reply_post_host_index].Default. |
778 | & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; | 780 | ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; |
779 | completed_cmds++; | 781 | completed_cmds++; |
780 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) | 782 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) |
781 | goto out; | 783 | goto out; |
782 | post_index = post_index_next; | 784 | if (!ioc->reply_post_host_index) |
785 | rpf = ioc->reply_post_free; | ||
786 | else | ||
787 | rpf++; | ||
783 | } while (1); | 788 | } while (1); |
784 | 789 | ||
785 | out: | 790 | out: |
@@ -787,19 +792,8 @@ _base_interrupt(int irq, void *bus_id) | |||
787 | if (!completed_cmds) | 792 | if (!completed_cmds) |
788 | return IRQ_NONE; | 793 | return IRQ_NONE; |
789 | 794 | ||
790 | /* reply post descriptor handling */ | ||
791 | post_index_next = ioc->reply_post_host_index; | ||
792 | for (i = 0 ; i < completed_cmds; i++) { | ||
793 | post_index = post_index_next; | ||
794 | /* poison the reply post descriptor */ | ||
795 | ioc->reply_post_free[post_index_next].Words = ULLONG_MAX; | ||
796 | post_index_next = (post_index == | ||
797 | (ioc->reply_post_queue_depth - 1)) | ||
798 | ? 0 : post_index + 1; | ||
799 | } | ||
800 | ioc->reply_post_host_index = post_index_next; | ||
801 | writel(post_index_next, &ioc->chip->ReplyPostHostIndex); | ||
802 | wmb(); | 795 | wmb(); |
796 | writel(ioc->reply_post_host_index, &ioc->chip->ReplyPostHostIndex); | ||
803 | return IRQ_HANDLED; | 797 | return IRQ_HANDLED; |
804 | } | 798 | } |
805 | 799 | ||
@@ -1650,7 +1644,7 @@ _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc) | |||
1650 | iounit_pg1_flags |= | 1644 | iounit_pg1_flags |= |
1651 | MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING; | 1645 | MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING; |
1652 | ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); | 1646 | ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); |
1653 | mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, ioc->iounit_pg1); | 1647 | mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); |
1654 | } | 1648 | } |
1655 | 1649 | ||
1656 | /** | 1650 | /** |
@@ -3306,13 +3300,11 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3306 | ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3300 | ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3307 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; | 3301 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; |
3308 | mutex_init(&ioc->tm_cmds.mutex); | 3302 | mutex_init(&ioc->tm_cmds.mutex); |
3309 | init_completion(&ioc->tm_cmds.done); | ||
3310 | 3303 | ||
3311 | /* config page internal command bits */ | 3304 | /* config page internal command bits */ |
3312 | ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3305 | ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3313 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; | 3306 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; |
3314 | mutex_init(&ioc->config_cmds.mutex); | 3307 | mutex_init(&ioc->config_cmds.mutex); |
3315 | init_completion(&ioc->config_cmds.done); | ||
3316 | 3308 | ||
3317 | /* ctl module internal command bits */ | 3309 | /* ctl module internal command bits */ |
3318 | ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3310 | 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 | if (ioc->config_cmds.status & MPT2_CMD_PENDING) { | 3428 | if (ioc->config_cmds.status & MPT2_CMD_PENDING) { |
3437 | ioc->config_cmds.status |= MPT2_CMD_RESET; | 3429 | ioc->config_cmds.status |= MPT2_CMD_RESET; |
3438 | mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); | 3430 | mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); |
3431 | ioc->config_cmds.smid = USHORT_MAX; | ||
3439 | complete(&ioc->config_cmds.done); | 3432 | complete(&ioc->config_cmds.done); |
3440 | } | 3433 | } |
3441 | break; | 3434 | break; |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index ff05ae1e43ba..f4bf7ff8f480 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h | |||
@@ -785,7 +785,7 @@ int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRep | |||
785 | int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | 785 | int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t |
786 | *mpi_reply, Mpi2IOUnitPage1_t *config_page); | 786 | *mpi_reply, Mpi2IOUnitPage1_t *config_page); |
787 | int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | 787 | int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t |
788 | *mpi_reply, Mpi2IOUnitPage1_t config_page); | 788 | *mpi_reply, Mpi2IOUnitPage1_t *config_page); |
789 | int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | 789 | int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t |
790 | *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz); | 790 | *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz); |
791 | int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | 791 | int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c index b9f4d0f97e50..ab8c560865d8 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_config.c +++ b/drivers/scsi/mpt2sas/mpt2sas_config.c | |||
@@ -72,15 +72,15 @@ | |||
72 | 72 | ||
73 | /** | 73 | /** |
74 | * struct config_request - obtain dma memory via routine | 74 | * struct config_request - obtain dma memory via routine |
75 | * @config_page_sz: size | 75 | * @sz: size |
76 | * @config_page: virt pointer | 76 | * @page: virt pointer |
77 | * @config_page_dma: phys pointer | 77 | * @page_dma: phys pointer |
78 | * | 78 | * |
79 | */ | 79 | */ |
80 | struct config_request{ | 80 | struct config_request{ |
81 | u16 config_page_sz; | 81 | u16 sz; |
82 | void *config_page; | 82 | void *page; |
83 | dma_addr_t config_page_dma; | 83 | dma_addr_t page_dma; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 86 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING |
@@ -175,6 +175,55 @@ _config_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid, | |||
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * _config_alloc_config_dma_memory - obtain physical memory | ||
179 | * @ioc: per adapter object | ||
180 | * @mem: struct config_request | ||
181 | * | ||
182 | * A wrapper for obtaining dma-able memory for config page request. | ||
183 | * | ||
184 | * Returns 0 for success, non-zero for failure. | ||
185 | */ | ||
186 | static int | ||
187 | _config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, | ||
188 | struct config_request *mem) | ||
189 | { | ||
190 | int r = 0; | ||
191 | |||
192 | if (mem->sz > ioc->config_page_sz) { | ||
193 | mem->page = dma_alloc_coherent(&ioc->pdev->dev, mem->sz, | ||
194 | &mem->page_dma, GFP_KERNEL); | ||
195 | if (!mem->page) { | ||
196 | printk(MPT2SAS_ERR_FMT "%s: dma_alloc_coherent" | ||
197 | " failed asking for (%d) bytes!!\n", | ||
198 | ioc->name, __func__, mem->sz); | ||
199 | r = -ENOMEM; | ||
200 | } | ||
201 | } else { /* use tmp buffer if less than 512 bytes */ | ||
202 | mem->page = ioc->config_page; | ||
203 | mem->page_dma = ioc->config_page_dma; | ||
204 | } | ||
205 | return r; | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * _config_free_config_dma_memory - wrapper to free the memory | ||
210 | * @ioc: per adapter object | ||
211 | * @mem: struct config_request | ||
212 | * | ||
213 | * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory. | ||
214 | * | ||
215 | * Returns 0 for success, non-zero for failure. | ||
216 | */ | ||
217 | static void | ||
218 | _config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, | ||
219 | struct config_request *mem) | ||
220 | { | ||
221 | if (mem->sz > ioc->config_page_sz) | ||
222 | dma_free_coherent(&ioc->pdev->dev, mem->sz, mem->page, | ||
223 | mem->page_dma); | ||
224 | } | ||
225 | |||
226 | /** | ||
178 | * mpt2sas_config_done - config page completion routine | 227 | * mpt2sas_config_done - config page completion routine |
179 | * @ioc: per adapter object | 228 | * @ioc: per adapter object |
180 | * @smid: system request message index | 229 | * @smid: system request message index |
@@ -206,6 +255,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) | |||
206 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 255 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING |
207 | _config_display_some_debug(ioc, smid, "config_done", mpi_reply); | 256 | _config_display_some_debug(ioc, smid, "config_done", mpi_reply); |
208 | #endif | 257 | #endif |
258 | ioc->config_cmds.smid = USHORT_MAX; | ||
209 | complete(&ioc->config_cmds.done); | 259 | complete(&ioc->config_cmds.done); |
210 | } | 260 | } |
211 | 261 | ||
@@ -215,7 +265,9 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) | |||
215 | * @mpi_request: request message frame | 265 | * @mpi_request: request message frame |
216 | * @mpi_reply: reply mf payload returned from firmware | 266 | * @mpi_reply: reply mf payload returned from firmware |
217 | * @timeout: timeout in seconds | 267 | * @timeout: timeout in seconds |
218 | * Context: sleep, the calling function needs to acquire the config_cmds.mutex | 268 | * @config_page: contents of the config page |
269 | * @config_page_sz: size of config page | ||
270 | * Context: sleep | ||
219 | * | 271 | * |
220 | * A generic API for config page requests to firmware. | 272 | * A generic API for config page requests to firmware. |
221 | * | 273 | * |
@@ -228,16 +280,17 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) | |||
228 | */ | 280 | */ |
229 | static int | 281 | static int |
230 | _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t | 282 | _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t |
231 | *mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout) | 283 | *mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout, |
284 | void *config_page, u16 config_page_sz) | ||
232 | { | 285 | { |
233 | u16 smid; | 286 | u16 smid; |
234 | u32 ioc_state; | 287 | u32 ioc_state; |
235 | unsigned long timeleft; | 288 | unsigned long timeleft; |
236 | Mpi2ConfigRequest_t *config_request; | 289 | Mpi2ConfigRequest_t *config_request; |
237 | int r; | 290 | int r; |
238 | u8 retry_count; | 291 | u8 retry_count, issue_host_reset = 0; |
239 | u8 issue_host_reset = 0; | ||
240 | u16 wait_state_count; | 292 | u16 wait_state_count; |
293 | struct config_request mem; | ||
241 | 294 | ||
242 | mutex_lock(&ioc->config_cmds.mutex); | 295 | mutex_lock(&ioc->config_cmds.mutex); |
243 | if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) { | 296 | if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) { |
@@ -246,12 +299,44 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t | |||
246 | mutex_unlock(&ioc->config_cmds.mutex); | 299 | mutex_unlock(&ioc->config_cmds.mutex); |
247 | return -EAGAIN; | 300 | return -EAGAIN; |
248 | } | 301 | } |
302 | |||
249 | retry_count = 0; | 303 | retry_count = 0; |
304 | memset(&mem, 0, sizeof(struct config_request)); | ||
305 | |||
306 | if (config_page) { | ||
307 | mpi_request->Header.PageVersion = mpi_reply->Header.PageVersion; | ||
308 | mpi_request->Header.PageNumber = mpi_reply->Header.PageNumber; | ||
309 | mpi_request->Header.PageType = mpi_reply->Header.PageType; | ||
310 | mpi_request->Header.PageLength = mpi_reply->Header.PageLength; | ||
311 | mpi_request->ExtPageLength = mpi_reply->ExtPageLength; | ||
312 | mpi_request->ExtPageType = mpi_reply->ExtPageType; | ||
313 | if (mpi_request->Header.PageLength) | ||
314 | mem.sz = mpi_request->Header.PageLength * 4; | ||
315 | else | ||
316 | mem.sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
317 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
318 | if (r != 0) | ||
319 | goto out; | ||
320 | if (mpi_request->Action == | ||
321 | MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT) { | ||
322 | ioc->base_add_sg_single(&mpi_request->PageBufferSGE, | ||
323 | MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.sz, | ||
324 | mem.page_dma); | ||
325 | memcpy(mem.page, config_page, min_t(u16, mem.sz, | ||
326 | config_page_sz)); | ||
327 | } else { | ||
328 | memset(config_page, 0, config_page_sz); | ||
329 | ioc->base_add_sg_single(&mpi_request->PageBufferSGE, | ||
330 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.sz, mem.page_dma); | ||
331 | } | ||
332 | } | ||
250 | 333 | ||
251 | retry_config: | 334 | retry_config: |
252 | if (retry_count) { | 335 | if (retry_count) { |
253 | if (retry_count > 2) /* attempt only 2 retries */ | 336 | if (retry_count > 2) { /* attempt only 2 retries */ |
254 | return -EFAULT; | 337 | r = -EFAULT; |
338 | goto free_mem; | ||
339 | } | ||
255 | printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n", | 340 | printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n", |
256 | ioc->name, __func__, retry_count); | 341 | ioc->name, __func__, retry_count); |
257 | } | 342 | } |
@@ -262,8 +347,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t | |||
262 | printk(MPT2SAS_ERR_FMT | 347 | printk(MPT2SAS_ERR_FMT |
263 | "%s: failed due to ioc not operational\n", | 348 | "%s: failed due to ioc not operational\n", |
264 | ioc->name, __func__); | 349 | ioc->name, __func__); |
350 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; | ||
265 | r = -EFAULT; | 351 | r = -EFAULT; |
266 | goto out; | 352 | goto free_mem; |
267 | } | 353 | } |
268 | ssleep(1); | 354 | ssleep(1); |
269 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); | 355 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
@@ -279,8 +365,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t | |||
279 | if (!smid) { | 365 | if (!smid) { |
280 | printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", | 366 | printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", |
281 | ioc->name, __func__); | 367 | ioc->name, __func__); |
368 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; | ||
282 | r = -EAGAIN; | 369 | r = -EAGAIN; |
283 | goto out; | 370 | goto free_mem; |
284 | } | 371 | } |
285 | 372 | ||
286 | r = 0; | 373 | r = 0; |
@@ -292,6 +379,7 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t | |||
292 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 379 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING |
293 | _config_display_some_debug(ioc, smid, "config_request", NULL); | 380 | _config_display_some_debug(ioc, smid, "config_request", NULL); |
294 | #endif | 381 | #endif |
382 | init_completion(&ioc->config_cmds.done); | ||
295 | mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID); | 383 | mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID); |
296 | timeleft = wait_for_completion_timeout(&ioc->config_cmds.done, | 384 | timeleft = wait_for_completion_timeout(&ioc->config_cmds.done, |
297 | timeout*HZ); | 385 | timeout*HZ); |
@@ -303,22 +391,31 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t | |||
303 | retry_count++; | 391 | retry_count++; |
304 | if (ioc->config_cmds.smid == smid) | 392 | if (ioc->config_cmds.smid == smid) |
305 | mpt2sas_base_free_smid(ioc, smid); | 393 | mpt2sas_base_free_smid(ioc, smid); |
306 | if ((ioc->shost_recovery) || | 394 | if ((ioc->shost_recovery) || (ioc->config_cmds.status & |
307 | (ioc->config_cmds.status & MPT2_CMD_RESET)) | 395 | MPT2_CMD_RESET)) |
308 | goto retry_config; | 396 | goto retry_config; |
309 | issue_host_reset = 1; | 397 | issue_host_reset = 1; |
310 | r = -EFAULT; | 398 | r = -EFAULT; |
311 | goto out; | 399 | goto free_mem; |
312 | } | 400 | } |
401 | |||
313 | if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID) | 402 | if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID) |
314 | memcpy(mpi_reply, ioc->config_cmds.reply, | 403 | memcpy(mpi_reply, ioc->config_cmds.reply, |
315 | sizeof(Mpi2ConfigReply_t)); | 404 | sizeof(Mpi2ConfigReply_t)); |
316 | if (retry_count) | 405 | if (retry_count) |
317 | printk(MPT2SAS_INFO_FMT "%s: retry completed!!\n", | 406 | printk(MPT2SAS_INFO_FMT "%s: retry (%d) completed!!\n", |
318 | ioc->name, __func__); | 407 | ioc->name, __func__, retry_count); |
319 | out: | 408 | if (config_page && mpi_request->Action == |
409 | MPI2_CONFIG_ACTION_PAGE_READ_CURRENT) | ||
410 | memcpy(config_page, mem.page, min_t(u16, mem.sz, | ||
411 | config_page_sz)); | ||
412 | free_mem: | ||
413 | if (config_page) | ||
414 | _config_free_config_dma_memory(ioc, &mem); | ||
415 | out: | ||
320 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; | 416 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; |
321 | mutex_unlock(&ioc->config_cmds.mutex); | 417 | mutex_unlock(&ioc->config_cmds.mutex); |
418 | |||
322 | if (issue_host_reset) | 419 | if (issue_host_reset) |
323 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, | 420 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, |
324 | FORCE_BIG_HAMMER); | 421 | FORCE_BIG_HAMMER); |
@@ -326,45 +423,6 @@ out: | |||
326 | } | 423 | } |
327 | 424 | ||
328 | /** | 425 | /** |
329 | * _config_alloc_config_dma_memory - obtain physical memory | ||
330 | * @ioc: per adapter object | ||
331 | * @mem: struct config_request | ||
332 | * | ||
333 | * A wrapper for obtaining dma-able memory for config page request. | ||
334 | * | ||
335 | * Returns 0 for success, non-zero for failure. | ||
336 | */ | ||
337 | static int | ||
338 | _config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, | ||
339 | struct config_request *mem) | ||
340 | { | ||
341 | int r = 0; | ||
342 | |||
343 | mem->config_page = pci_alloc_consistent(ioc->pdev, mem->config_page_sz, | ||
344 | &mem->config_page_dma); | ||
345 | if (!mem->config_page) | ||
346 | r = -ENOMEM; | ||
347 | return r; | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * _config_free_config_dma_memory - wrapper to free the memory | ||
352 | * @ioc: per adapter object | ||
353 | * @mem: struct config_request | ||
354 | * | ||
355 | * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory. | ||
356 | * | ||
357 | * Returns 0 for success, non-zero for failure. | ||
358 | */ | ||
359 | static void | ||
360 | _config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc, | ||
361 | struct config_request *mem) | ||
362 | { | ||
363 | pci_free_consistent(ioc->pdev, mem->config_page_sz, mem->config_page, | ||
364 | mem->config_page_dma); | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0 | 426 | * mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0 |
369 | * @ioc: per adapter object | 427 | * @ioc: per adapter object |
370 | * @mpi_reply: reply mf payload returned from firmware | 428 | * @mpi_reply: reply mf payload returned from firmware |
@@ -379,9 +437,7 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, | |||
379 | { | 437 | { |
380 | Mpi2ConfigRequest_t mpi_request; | 438 | Mpi2ConfigRequest_t mpi_request; |
381 | int r; | 439 | int r; |
382 | struct config_request mem; | ||
383 | 440 | ||
384 | memset(config_page, 0, sizeof(Mpi2ManufacturingPage0_t)); | ||
385 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 441 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
386 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 442 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
387 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 443 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -390,37 +446,14 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, | |||
390 | mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; | 446 | mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; |
391 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 447 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
392 | r = _config_request(ioc, &mpi_request, mpi_reply, | 448 | r = _config_request(ioc, &mpi_request, mpi_reply, |
393 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 449 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
394 | if (r) | 450 | if (r) |
395 | goto out; | 451 | goto out; |
396 | 452 | ||
397 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 453 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
398 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
399 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
400 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
401 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
402 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
403 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
404 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
405 | if (r) | ||
406 | goto out; | ||
407 | } else { | ||
408 | mem.config_page_dma = ioc->config_page_dma; | ||
409 | mem.config_page = ioc->config_page; | ||
410 | } | ||
411 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
412 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
413 | mem.config_page_dma); | ||
414 | r = _config_request(ioc, &mpi_request, mpi_reply, | 454 | r = _config_request(ioc, &mpi_request, mpi_reply, |
415 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 455 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
416 | if (!r) | 456 | sizeof(*config_page)); |
417 | memcpy(config_page, mem.config_page, | ||
418 | min_t(u16, mem.config_page_sz, | ||
419 | sizeof(Mpi2ManufacturingPage0_t))); | ||
420 | |||
421 | if (mem.config_page_sz > ioc->config_page_sz) | ||
422 | _config_free_config_dma_memory(ioc, &mem); | ||
423 | |||
424 | out: | 457 | out: |
425 | return r; | 458 | return r; |
426 | } | 459 | } |
@@ -440,9 +473,7 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, | |||
440 | { | 473 | { |
441 | Mpi2ConfigRequest_t mpi_request; | 474 | Mpi2ConfigRequest_t mpi_request; |
442 | int r; | 475 | int r; |
443 | struct config_request mem; | ||
444 | 476 | ||
445 | memset(config_page, 0, sizeof(Mpi2ManufacturingPage10_t)); | ||
446 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 477 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
447 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 478 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
448 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 479 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -451,37 +482,14 @@ mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, | |||
451 | mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; | 482 | mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION; |
452 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 483 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
453 | r = _config_request(ioc, &mpi_request, mpi_reply, | 484 | r = _config_request(ioc, &mpi_request, mpi_reply, |
454 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 485 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
455 | if (r) | 486 | if (r) |
456 | goto out; | 487 | goto out; |
457 | 488 | ||
458 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 489 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
459 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
460 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
461 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
462 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
463 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
464 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
465 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
466 | if (r) | ||
467 | goto out; | ||
468 | } else { | ||
469 | mem.config_page_dma = ioc->config_page_dma; | ||
470 | mem.config_page = ioc->config_page; | ||
471 | } | ||
472 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
473 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
474 | mem.config_page_dma); | ||
475 | r = _config_request(ioc, &mpi_request, mpi_reply, | 490 | r = _config_request(ioc, &mpi_request, mpi_reply, |
476 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 491 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
477 | if (!r) | 492 | sizeof(*config_page)); |
478 | memcpy(config_page, mem.config_page, | ||
479 | min_t(u16, mem.config_page_sz, | ||
480 | sizeof(Mpi2ManufacturingPage10_t))); | ||
481 | |||
482 | if (mem.config_page_sz > ioc->config_page_sz) | ||
483 | _config_free_config_dma_memory(ioc, &mem); | ||
484 | |||
485 | out: | 493 | out: |
486 | return r; | 494 | return r; |
487 | } | 495 | } |
@@ -501,9 +509,7 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, | |||
501 | { | 509 | { |
502 | Mpi2ConfigRequest_t mpi_request; | 510 | Mpi2ConfigRequest_t mpi_request; |
503 | int r; | 511 | int r; |
504 | struct config_request mem; | ||
505 | 512 | ||
506 | memset(config_page, 0, sizeof(Mpi2BiosPage2_t)); | ||
507 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 513 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
508 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 514 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
509 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 515 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -512,37 +518,14 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, | |||
512 | mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION; | 518 | mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION; |
513 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 519 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
514 | r = _config_request(ioc, &mpi_request, mpi_reply, | 520 | r = _config_request(ioc, &mpi_request, mpi_reply, |
515 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 521 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
516 | if (r) | 522 | if (r) |
517 | goto out; | 523 | goto out; |
518 | 524 | ||
519 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 525 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
520 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
521 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
522 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
523 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
524 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
525 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
526 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
527 | if (r) | ||
528 | goto out; | ||
529 | } else { | ||
530 | mem.config_page_dma = ioc->config_page_dma; | ||
531 | mem.config_page = ioc->config_page; | ||
532 | } | ||
533 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
534 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
535 | mem.config_page_dma); | ||
536 | r = _config_request(ioc, &mpi_request, mpi_reply, | 526 | r = _config_request(ioc, &mpi_request, mpi_reply, |
537 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 527 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
538 | if (!r) | 528 | sizeof(*config_page)); |
539 | memcpy(config_page, mem.config_page, | ||
540 | min_t(u16, mem.config_page_sz, | ||
541 | sizeof(Mpi2BiosPage2_t))); | ||
542 | |||
543 | if (mem.config_page_sz > ioc->config_page_sz) | ||
544 | _config_free_config_dma_memory(ioc, &mem); | ||
545 | |||
546 | out: | 529 | out: |
547 | return r; | 530 | return r; |
548 | } | 531 | } |
@@ -562,9 +545,7 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
562 | { | 545 | { |
563 | Mpi2ConfigRequest_t mpi_request; | 546 | Mpi2ConfigRequest_t mpi_request; |
564 | int r; | 547 | int r; |
565 | struct config_request mem; | ||
566 | 548 | ||
567 | memset(config_page, 0, sizeof(Mpi2BiosPage3_t)); | ||
568 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 549 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
569 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 550 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
570 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 551 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -573,37 +554,14 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
573 | mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION; | 554 | mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION; |
574 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 555 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
575 | r = _config_request(ioc, &mpi_request, mpi_reply, | 556 | r = _config_request(ioc, &mpi_request, mpi_reply, |
576 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 557 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
577 | if (r) | 558 | if (r) |
578 | goto out; | 559 | goto out; |
579 | 560 | ||
580 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 561 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
581 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
582 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
583 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
584 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
585 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
586 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
587 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
588 | if (r) | ||
589 | goto out; | ||
590 | } else { | ||
591 | mem.config_page_dma = ioc->config_page_dma; | ||
592 | mem.config_page = ioc->config_page; | ||
593 | } | ||
594 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
595 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
596 | mem.config_page_dma); | ||
597 | r = _config_request(ioc, &mpi_request, mpi_reply, | 562 | r = _config_request(ioc, &mpi_request, mpi_reply, |
598 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 563 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
599 | if (!r) | 564 | sizeof(*config_page)); |
600 | memcpy(config_page, mem.config_page, | ||
601 | min_t(u16, mem.config_page_sz, | ||
602 | sizeof(Mpi2BiosPage3_t))); | ||
603 | |||
604 | if (mem.config_page_sz > ioc->config_page_sz) | ||
605 | _config_free_config_dma_memory(ioc, &mem); | ||
606 | |||
607 | out: | 565 | out: |
608 | return r; | 566 | return r; |
609 | } | 567 | } |
@@ -623,9 +581,7 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, | |||
623 | { | 581 | { |
624 | Mpi2ConfigRequest_t mpi_request; | 582 | Mpi2ConfigRequest_t mpi_request; |
625 | int r; | 583 | int r; |
626 | struct config_request mem; | ||
627 | 584 | ||
628 | memset(config_page, 0, sizeof(Mpi2IOUnitPage0_t)); | ||
629 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 585 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
630 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 586 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
631 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 587 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -634,37 +590,14 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, | |||
634 | mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION; | 590 | mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION; |
635 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 591 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
636 | r = _config_request(ioc, &mpi_request, mpi_reply, | 592 | r = _config_request(ioc, &mpi_request, mpi_reply, |
637 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 593 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
638 | if (r) | 594 | if (r) |
639 | goto out; | 595 | goto out; |
640 | 596 | ||
641 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 597 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
642 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
643 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
644 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
645 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
646 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
647 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
648 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
649 | if (r) | ||
650 | goto out; | ||
651 | } else { | ||
652 | mem.config_page_dma = ioc->config_page_dma; | ||
653 | mem.config_page = ioc->config_page; | ||
654 | } | ||
655 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
656 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
657 | mem.config_page_dma); | ||
658 | r = _config_request(ioc, &mpi_request, mpi_reply, | 598 | r = _config_request(ioc, &mpi_request, mpi_reply, |
659 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 599 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
660 | if (!r) | 600 | sizeof(*config_page)); |
661 | memcpy(config_page, mem.config_page, | ||
662 | min_t(u16, mem.config_page_sz, | ||
663 | sizeof(Mpi2IOUnitPage0_t))); | ||
664 | |||
665 | if (mem.config_page_sz > ioc->config_page_sz) | ||
666 | _config_free_config_dma_memory(ioc, &mem); | ||
667 | |||
668 | out: | 601 | out: |
669 | return r; | 602 | return r; |
670 | } | 603 | } |
@@ -684,9 +617,7 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, | |||
684 | { | 617 | { |
685 | Mpi2ConfigRequest_t mpi_request; | 618 | Mpi2ConfigRequest_t mpi_request; |
686 | int r; | 619 | int r; |
687 | struct config_request mem; | ||
688 | 620 | ||
689 | memset(config_page, 0, sizeof(Mpi2IOUnitPage1_t)); | ||
690 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 621 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
691 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 622 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
692 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 623 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -695,37 +626,14 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, | |||
695 | mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; | 626 | mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; |
696 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 627 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
697 | r = _config_request(ioc, &mpi_request, mpi_reply, | 628 | r = _config_request(ioc, &mpi_request, mpi_reply, |
698 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 629 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
699 | if (r) | 630 | if (r) |
700 | goto out; | 631 | goto out; |
701 | 632 | ||
702 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 633 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
703 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
704 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
705 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
706 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
707 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
708 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
709 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
710 | if (r) | ||
711 | goto out; | ||
712 | } else { | ||
713 | mem.config_page_dma = ioc->config_page_dma; | ||
714 | mem.config_page = ioc->config_page; | ||
715 | } | ||
716 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
717 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
718 | mem.config_page_dma); | ||
719 | r = _config_request(ioc, &mpi_request, mpi_reply, | 634 | r = _config_request(ioc, &mpi_request, mpi_reply, |
720 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 635 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
721 | if (!r) | 636 | sizeof(*config_page)); |
722 | memcpy(config_page, mem.config_page, | ||
723 | min_t(u16, mem.config_page_sz, | ||
724 | sizeof(Mpi2IOUnitPage1_t))); | ||
725 | |||
726 | if (mem.config_page_sz > ioc->config_page_sz) | ||
727 | _config_free_config_dma_memory(ioc, &mem); | ||
728 | |||
729 | out: | 637 | out: |
730 | return r; | 638 | return r; |
731 | } | 639 | } |
@@ -741,11 +649,10 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, | |||
741 | */ | 649 | */ |
742 | int | 650 | int |
743 | mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, | 651 | mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, |
744 | Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t config_page) | 652 | Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t *config_page) |
745 | { | 653 | { |
746 | Mpi2ConfigRequest_t mpi_request; | 654 | Mpi2ConfigRequest_t mpi_request; |
747 | int r; | 655 | int r; |
748 | struct config_request mem; | ||
749 | 656 | ||
750 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 657 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
751 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 658 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
@@ -755,38 +662,14 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, | |||
755 | mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; | 662 | mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION; |
756 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 663 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
757 | r = _config_request(ioc, &mpi_request, mpi_reply, | 664 | r = _config_request(ioc, &mpi_request, mpi_reply, |
758 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 665 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
759 | if (r) | 666 | if (r) |
760 | goto out; | 667 | goto out; |
761 | 668 | ||
762 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT; | 669 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT; |
763 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
764 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
765 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
766 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
767 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
768 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
769 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
770 | if (r) | ||
771 | goto out; | ||
772 | } else { | ||
773 | mem.config_page_dma = ioc->config_page_dma; | ||
774 | mem.config_page = ioc->config_page; | ||
775 | } | ||
776 | |||
777 | memset(mem.config_page, 0, mem.config_page_sz); | ||
778 | memcpy(mem.config_page, &config_page, | ||
779 | sizeof(Mpi2IOUnitPage1_t)); | ||
780 | |||
781 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
782 | MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.config_page_sz, | ||
783 | mem.config_page_dma); | ||
784 | r = _config_request(ioc, &mpi_request, mpi_reply, | 670 | r = _config_request(ioc, &mpi_request, mpi_reply, |
785 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 671 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
786 | 672 | sizeof(*config_page)); | |
787 | if (mem.config_page_sz > ioc->config_page_sz) | ||
788 | _config_free_config_dma_memory(ioc, &mem); | ||
789 | |||
790 | out: | 673 | out: |
791 | return r; | 674 | return r; |
792 | } | 675 | } |
@@ -806,9 +689,7 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, | |||
806 | { | 689 | { |
807 | Mpi2ConfigRequest_t mpi_request; | 690 | Mpi2ConfigRequest_t mpi_request; |
808 | int r; | 691 | int r; |
809 | struct config_request mem; | ||
810 | 692 | ||
811 | memset(config_page, 0, sizeof(Mpi2IOCPage8_t)); | ||
812 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 693 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
813 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 694 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
814 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 695 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -817,37 +698,14 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, | |||
817 | mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION; | 698 | mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION; |
818 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 699 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
819 | r = _config_request(ioc, &mpi_request, mpi_reply, | 700 | r = _config_request(ioc, &mpi_request, mpi_reply, |
820 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 701 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
821 | if (r) | 702 | if (r) |
822 | goto out; | 703 | goto out; |
823 | 704 | ||
824 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 705 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
825 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
826 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
827 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
828 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
829 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
830 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
831 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
832 | if (r) | ||
833 | goto out; | ||
834 | } else { | ||
835 | mem.config_page_dma = ioc->config_page_dma; | ||
836 | mem.config_page = ioc->config_page; | ||
837 | } | ||
838 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
839 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
840 | mem.config_page_dma); | ||
841 | r = _config_request(ioc, &mpi_request, mpi_reply, | 706 | r = _config_request(ioc, &mpi_request, mpi_reply, |
842 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 707 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
843 | if (!r) | 708 | sizeof(*config_page)); |
844 | memcpy(config_page, mem.config_page, | ||
845 | min_t(u16, mem.config_page_sz, | ||
846 | sizeof(Mpi2IOCPage8_t))); | ||
847 | |||
848 | if (mem.config_page_sz > ioc->config_page_sz) | ||
849 | _config_free_config_dma_memory(ioc, &mem); | ||
850 | |||
851 | out: | 709 | out: |
852 | return r; | 710 | return r; |
853 | } | 711 | } |
@@ -869,9 +727,7 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
869 | { | 727 | { |
870 | Mpi2ConfigRequest_t mpi_request; | 728 | Mpi2ConfigRequest_t mpi_request; |
871 | int r; | 729 | int r; |
872 | struct config_request mem; | ||
873 | 730 | ||
874 | memset(config_page, 0, sizeof(Mpi2SasDevicePage0_t)); | ||
875 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 731 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
876 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 732 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
877 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 733 | 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 | mpi_request.Header.PageNumber = 0; | 737 | mpi_request.Header.PageNumber = 0; |
882 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 738 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
883 | r = _config_request(ioc, &mpi_request, mpi_reply, | 739 | r = _config_request(ioc, &mpi_request, mpi_reply, |
884 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 740 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
885 | if (r) | 741 | if (r) |
886 | goto out; | 742 | goto out; |
887 | 743 | ||
888 | mpi_request.PageAddress = cpu_to_le32(form | handle); | 744 | mpi_request.PageAddress = cpu_to_le32(form | handle); |
889 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 745 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
890 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
891 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
892 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
893 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
894 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
895 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
896 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
897 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
898 | if (r) | ||
899 | goto out; | ||
900 | } else { | ||
901 | mem.config_page_dma = ioc->config_page_dma; | ||
902 | mem.config_page = ioc->config_page; | ||
903 | } | ||
904 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
905 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
906 | mem.config_page_dma); | ||
907 | r = _config_request(ioc, &mpi_request, mpi_reply, | 746 | r = _config_request(ioc, &mpi_request, mpi_reply, |
908 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 747 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
909 | if (!r) | 748 | sizeof(*config_page)); |
910 | memcpy(config_page, mem.config_page, | ||
911 | min_t(u16, mem.config_page_sz, | ||
912 | sizeof(Mpi2SasDevicePage0_t))); | ||
913 | |||
914 | if (mem.config_page_sz > ioc->config_page_sz) | ||
915 | _config_free_config_dma_memory(ioc, &mem); | ||
916 | |||
917 | out: | 749 | out: |
918 | return r; | 750 | return r; |
919 | } | 751 | } |
@@ -935,9 +767,7 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
935 | { | 767 | { |
936 | Mpi2ConfigRequest_t mpi_request; | 768 | Mpi2ConfigRequest_t mpi_request; |
937 | int r; | 769 | int r; |
938 | struct config_request mem; | ||
939 | 770 | ||
940 | memset(config_page, 0, sizeof(Mpi2SasDevicePage1_t)); | ||
941 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 771 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
942 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 772 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
943 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 773 | 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 | mpi_request.Header.PageNumber = 1; | 777 | mpi_request.Header.PageNumber = 1; |
948 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 778 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
949 | r = _config_request(ioc, &mpi_request, mpi_reply, | 779 | r = _config_request(ioc, &mpi_request, mpi_reply, |
950 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 780 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
951 | if (r) | 781 | if (r) |
952 | goto out; | 782 | goto out; |
953 | 783 | ||
954 | mpi_request.PageAddress = cpu_to_le32(form | handle); | 784 | mpi_request.PageAddress = cpu_to_le32(form | handle); |
955 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 785 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
956 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
957 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
958 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
959 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
960 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
961 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
962 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
963 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
964 | if (r) | ||
965 | goto out; | ||
966 | } else { | ||
967 | mem.config_page_dma = ioc->config_page_dma; | ||
968 | mem.config_page = ioc->config_page; | ||
969 | } | ||
970 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
971 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
972 | mem.config_page_dma); | ||
973 | r = _config_request(ioc, &mpi_request, mpi_reply, | 786 | r = _config_request(ioc, &mpi_request, mpi_reply, |
974 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 787 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
975 | if (!r) | 788 | sizeof(*config_page)); |
976 | memcpy(config_page, mem.config_page, | ||
977 | min_t(u16, mem.config_page_sz, | ||
978 | sizeof(Mpi2SasDevicePage1_t))); | ||
979 | |||
980 | if (mem.config_page_sz > ioc->config_page_sz) | ||
981 | _config_free_config_dma_memory(ioc, &mem); | ||
982 | |||
983 | out: | 789 | out: |
984 | return r; | 790 | return r; |
985 | } | 791 | } |
@@ -997,11 +803,11 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys) | |||
997 | { | 803 | { |
998 | Mpi2ConfigRequest_t mpi_request; | 804 | Mpi2ConfigRequest_t mpi_request; |
999 | int r; | 805 | int r; |
1000 | struct config_request mem; | ||
1001 | u16 ioc_status; | 806 | u16 ioc_status; |
1002 | Mpi2ConfigReply_t mpi_reply; | 807 | Mpi2ConfigReply_t mpi_reply; |
1003 | Mpi2SasIOUnitPage0_t config_page; | 808 | Mpi2SasIOUnitPage0_t config_page; |
1004 | 809 | ||
810 | *num_phys = 0; | ||
1005 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 811 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1006 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 812 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1007 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 813 | 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 | mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; | 817 | mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; |
1012 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 818 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1013 | r = _config_request(ioc, &mpi_request, &mpi_reply, | 819 | r = _config_request(ioc, &mpi_request, &mpi_reply, |
1014 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 820 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1015 | if (r) | 821 | if (r) |
1016 | goto out; | 822 | goto out; |
1017 | 823 | ||
1018 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 824 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1019 | mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; | ||
1020 | mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; | ||
1021 | mpi_request.Header.PageType = mpi_reply.Header.PageType; | ||
1022 | mpi_request.ExtPageLength = mpi_reply.ExtPageLength; | ||
1023 | mpi_request.ExtPageType = mpi_reply.ExtPageType; | ||
1024 | mem.config_page_sz = le16_to_cpu(mpi_reply.ExtPageLength) * 4; | ||
1025 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1026 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1027 | if (r) | ||
1028 | goto out; | ||
1029 | } else { | ||
1030 | mem.config_page_dma = ioc->config_page_dma; | ||
1031 | mem.config_page = ioc->config_page; | ||
1032 | } | ||
1033 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1034 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1035 | mem.config_page_dma); | ||
1036 | r = _config_request(ioc, &mpi_request, &mpi_reply, | 825 | r = _config_request(ioc, &mpi_request, &mpi_reply, |
1037 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 826 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page, |
827 | sizeof(Mpi2SasIOUnitPage0_t)); | ||
1038 | if (!r) { | 828 | if (!r) { |
1039 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & | 829 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & |
1040 | MPI2_IOCSTATUS_MASK; | 830 | MPI2_IOCSTATUS_MASK; |
1041 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { | 831 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) |
1042 | memcpy(&config_page, mem.config_page, | ||
1043 | min_t(u16, mem.config_page_sz, | ||
1044 | sizeof(Mpi2SasIOUnitPage0_t))); | ||
1045 | *num_phys = config_page.NumPhys; | 832 | *num_phys = config_page.NumPhys; |
1046 | } | ||
1047 | } | 833 | } |
1048 | |||
1049 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1050 | _config_free_config_dma_memory(ioc, &mem); | ||
1051 | |||
1052 | out: | 834 | out: |
1053 | return r; | 835 | return r; |
1054 | } | 836 | } |
@@ -1072,8 +854,7 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1072 | { | 854 | { |
1073 | Mpi2ConfigRequest_t mpi_request; | 855 | Mpi2ConfigRequest_t mpi_request; |
1074 | int r; | 856 | int r; |
1075 | struct config_request mem; | 857 | |
1076 | memset(config_page, 0, sz); | ||
1077 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 858 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1078 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 859 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1079 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 860 | 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 | mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; | 864 | mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; |
1084 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 865 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1085 | r = _config_request(ioc, &mpi_request, mpi_reply, | 866 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1086 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 867 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1087 | if (r) | 868 | if (r) |
1088 | goto out; | 869 | goto out; |
1089 | 870 | ||
1090 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 871 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1091 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1092 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1093 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1094 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1095 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1096 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1097 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1098 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1099 | if (r) | ||
1100 | goto out; | ||
1101 | } else { | ||
1102 | mem.config_page_dma = ioc->config_page_dma; | ||
1103 | mem.config_page = ioc->config_page; | ||
1104 | } | ||
1105 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1106 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1107 | mem.config_page_dma); | ||
1108 | r = _config_request(ioc, &mpi_request, mpi_reply, | 872 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1109 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 873 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); |
1110 | if (!r) | ||
1111 | memcpy(config_page, mem.config_page, | ||
1112 | min_t(u16, sz, mem.config_page_sz)); | ||
1113 | |||
1114 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1115 | _config_free_config_dma_memory(ioc, &mem); | ||
1116 | |||
1117 | out: | 874 | out: |
1118 | return r; | 875 | return r; |
1119 | } | 876 | } |
@@ -1137,9 +894,7 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1137 | { | 894 | { |
1138 | Mpi2ConfigRequest_t mpi_request; | 895 | Mpi2ConfigRequest_t mpi_request; |
1139 | int r; | 896 | int r; |
1140 | struct config_request mem; | ||
1141 | 897 | ||
1142 | memset(config_page, 0, sz); | ||
1143 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 898 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1144 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 899 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1145 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 900 | 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 | mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; | 904 | mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION; |
1150 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 905 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1151 | r = _config_request(ioc, &mpi_request, mpi_reply, | 906 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1152 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 907 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1153 | if (r) | 908 | if (r) |
1154 | goto out; | 909 | goto out; |
1155 | 910 | ||
1156 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 911 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1157 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1158 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1159 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1160 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1161 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1162 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1163 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1164 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1165 | if (r) | ||
1166 | goto out; | ||
1167 | } else { | ||
1168 | mem.config_page_dma = ioc->config_page_dma; | ||
1169 | mem.config_page = ioc->config_page; | ||
1170 | } | ||
1171 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1172 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1173 | mem.config_page_dma); | ||
1174 | r = _config_request(ioc, &mpi_request, mpi_reply, | 912 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1175 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 913 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); |
1176 | if (!r) | ||
1177 | memcpy(config_page, mem.config_page, | ||
1178 | min_t(u16, sz, mem.config_page_sz)); | ||
1179 | |||
1180 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1181 | _config_free_config_dma_memory(ioc, &mem); | ||
1182 | |||
1183 | out: | 914 | out: |
1184 | return r; | 915 | return r; |
1185 | } | 916 | } |
@@ -1201,9 +932,7 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1201 | { | 932 | { |
1202 | Mpi2ConfigRequest_t mpi_request; | 933 | Mpi2ConfigRequest_t mpi_request; |
1203 | int r; | 934 | int r; |
1204 | struct config_request mem; | ||
1205 | 935 | ||
1206 | memset(config_page, 0, sizeof(Mpi2ExpanderPage0_t)); | ||
1207 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 936 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1208 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 937 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1209 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 938 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -1213,39 +942,15 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1213 | mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION; | 942 | mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION; |
1214 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 943 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1215 | r = _config_request(ioc, &mpi_request, mpi_reply, | 944 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1216 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 945 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1217 | if (r) | 946 | if (r) |
1218 | goto out; | 947 | goto out; |
1219 | 948 | ||
1220 | mpi_request.PageAddress = cpu_to_le32(form | handle); | 949 | mpi_request.PageAddress = cpu_to_le32(form | handle); |
1221 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 950 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1222 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1223 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1224 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1225 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1226 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1227 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1228 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1229 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1230 | if (r) | ||
1231 | goto out; | ||
1232 | } else { | ||
1233 | mem.config_page_dma = ioc->config_page_dma; | ||
1234 | mem.config_page = ioc->config_page; | ||
1235 | } | ||
1236 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1237 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1238 | mem.config_page_dma); | ||
1239 | r = _config_request(ioc, &mpi_request, mpi_reply, | 951 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1240 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 952 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1241 | if (!r) | 953 | sizeof(*config_page)); |
1242 | memcpy(config_page, mem.config_page, | ||
1243 | min_t(u16, mem.config_page_sz, | ||
1244 | sizeof(Mpi2ExpanderPage0_t))); | ||
1245 | |||
1246 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1247 | _config_free_config_dma_memory(ioc, &mem); | ||
1248 | |||
1249 | out: | 954 | out: |
1250 | return r; | 955 | return r; |
1251 | } | 956 | } |
@@ -1268,9 +973,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1268 | { | 973 | { |
1269 | Mpi2ConfigRequest_t mpi_request; | 974 | Mpi2ConfigRequest_t mpi_request; |
1270 | int r; | 975 | int r; |
1271 | struct config_request mem; | ||
1272 | 976 | ||
1273 | memset(config_page, 0, sizeof(Mpi2ExpanderPage1_t)); | ||
1274 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 977 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1275 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 978 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1276 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 979 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -1280,7 +983,7 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1280 | mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION; | 983 | mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION; |
1281 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 984 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1282 | r = _config_request(ioc, &mpi_request, mpi_reply, | 985 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1283 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 986 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1284 | if (r) | 987 | if (r) |
1285 | goto out; | 988 | goto out; |
1286 | 989 | ||
@@ -1288,33 +991,9 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1288 | cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM | | 991 | cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM | |
1289 | (phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle); | 992 | (phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle); |
1290 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 993 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1291 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1292 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1293 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1294 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1295 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1296 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1297 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1298 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1299 | if (r) | ||
1300 | goto out; | ||
1301 | } else { | ||
1302 | mem.config_page_dma = ioc->config_page_dma; | ||
1303 | mem.config_page = ioc->config_page; | ||
1304 | } | ||
1305 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1306 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1307 | mem.config_page_dma); | ||
1308 | r = _config_request(ioc, &mpi_request, mpi_reply, | 994 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1309 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 995 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1310 | if (!r) | 996 | sizeof(*config_page)); |
1311 | memcpy(config_page, mem.config_page, | ||
1312 | min_t(u16, mem.config_page_sz, | ||
1313 | sizeof(Mpi2ExpanderPage1_t))); | ||
1314 | |||
1315 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1316 | _config_free_config_dma_memory(ioc, &mem); | ||
1317 | |||
1318 | out: | 997 | out: |
1319 | return r; | 998 | return r; |
1320 | } | 999 | } |
@@ -1336,9 +1015,7 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1336 | { | 1015 | { |
1337 | Mpi2ConfigRequest_t mpi_request; | 1016 | Mpi2ConfigRequest_t mpi_request; |
1338 | int r; | 1017 | int r; |
1339 | struct config_request mem; | ||
1340 | 1018 | ||
1341 | memset(config_page, 0, sizeof(Mpi2SasEnclosurePage0_t)); | ||
1342 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1019 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1343 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 1020 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1344 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 1021 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -1348,39 +1025,15 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1348 | mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION; | 1025 | mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION; |
1349 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1026 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1350 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1027 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1351 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1028 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1352 | if (r) | 1029 | if (r) |
1353 | goto out; | 1030 | goto out; |
1354 | 1031 | ||
1355 | mpi_request.PageAddress = cpu_to_le32(form | handle); | 1032 | mpi_request.PageAddress = cpu_to_le32(form | handle); |
1356 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1033 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1357 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1358 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1359 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1360 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1361 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1362 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1363 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1364 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1365 | if (r) | ||
1366 | goto out; | ||
1367 | } else { | ||
1368 | mem.config_page_dma = ioc->config_page_dma; | ||
1369 | mem.config_page = ioc->config_page; | ||
1370 | } | ||
1371 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1372 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1373 | mem.config_page_dma); | ||
1374 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1034 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1375 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1035 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1376 | if (!r) | 1036 | sizeof(*config_page)); |
1377 | memcpy(config_page, mem.config_page, | ||
1378 | min_t(u16, mem.config_page_sz, | ||
1379 | sizeof(Mpi2SasEnclosurePage0_t))); | ||
1380 | |||
1381 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1382 | _config_free_config_dma_memory(ioc, &mem); | ||
1383 | |||
1384 | out: | 1037 | out: |
1385 | return r; | 1038 | return r; |
1386 | } | 1039 | } |
@@ -1401,9 +1054,7 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1401 | { | 1054 | { |
1402 | Mpi2ConfigRequest_t mpi_request; | 1055 | Mpi2ConfigRequest_t mpi_request; |
1403 | int r; | 1056 | int r; |
1404 | struct config_request mem; | ||
1405 | 1057 | ||
1406 | memset(config_page, 0, sizeof(Mpi2SasPhyPage0_t)); | ||
1407 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1058 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1408 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 1059 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1409 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 1060 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -1413,40 +1064,16 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1413 | mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION; | 1064 | mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION; |
1414 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1065 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1415 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1066 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1416 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1067 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1417 | if (r) | 1068 | if (r) |
1418 | goto out; | 1069 | goto out; |
1419 | 1070 | ||
1420 | mpi_request.PageAddress = | 1071 | mpi_request.PageAddress = |
1421 | cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); | 1072 | cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); |
1422 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1073 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1423 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1424 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1425 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1426 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1427 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1428 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1429 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1430 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1431 | if (r) | ||
1432 | goto out; | ||
1433 | } else { | ||
1434 | mem.config_page_dma = ioc->config_page_dma; | ||
1435 | mem.config_page = ioc->config_page; | ||
1436 | } | ||
1437 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1438 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1439 | mem.config_page_dma); | ||
1440 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1074 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1441 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1075 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1442 | if (!r) | 1076 | sizeof(*config_page)); |
1443 | memcpy(config_page, mem.config_page, | ||
1444 | min_t(u16, mem.config_page_sz, | ||
1445 | sizeof(Mpi2SasPhyPage0_t))); | ||
1446 | |||
1447 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1448 | _config_free_config_dma_memory(ioc, &mem); | ||
1449 | |||
1450 | out: | 1077 | out: |
1451 | return r; | 1078 | return r; |
1452 | } | 1079 | } |
@@ -1467,9 +1094,7 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1467 | { | 1094 | { |
1468 | Mpi2ConfigRequest_t mpi_request; | 1095 | Mpi2ConfigRequest_t mpi_request; |
1469 | int r; | 1096 | int r; |
1470 | struct config_request mem; | ||
1471 | 1097 | ||
1472 | memset(config_page, 0, sizeof(Mpi2SasPhyPage1_t)); | ||
1473 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1098 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1474 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 1099 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1475 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 1100 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -1479,40 +1104,16 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1479 | mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION; | 1104 | mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION; |
1480 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1105 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1481 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1106 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1482 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1107 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1483 | if (r) | 1108 | if (r) |
1484 | goto out; | 1109 | goto out; |
1485 | 1110 | ||
1486 | mpi_request.PageAddress = | 1111 | mpi_request.PageAddress = |
1487 | cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); | 1112 | cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number); |
1488 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1113 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1489 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1490 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1491 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1492 | mpi_request.ExtPageLength = mpi_reply->ExtPageLength; | ||
1493 | mpi_request.ExtPageType = mpi_reply->ExtPageType; | ||
1494 | mem.config_page_sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4; | ||
1495 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1496 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1497 | if (r) | ||
1498 | goto out; | ||
1499 | } else { | ||
1500 | mem.config_page_dma = ioc->config_page_dma; | ||
1501 | mem.config_page = ioc->config_page; | ||
1502 | } | ||
1503 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1504 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1505 | mem.config_page_dma); | ||
1506 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1114 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1507 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1115 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1508 | if (!r) | 1116 | sizeof(*config_page)); |
1509 | memcpy(config_page, mem.config_page, | ||
1510 | min_t(u16, mem.config_page_sz, | ||
1511 | sizeof(Mpi2SasPhyPage1_t))); | ||
1512 | |||
1513 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1514 | _config_free_config_dma_memory(ioc, &mem); | ||
1515 | |||
1516 | out: | 1117 | out: |
1517 | return r; | 1118 | return r; |
1518 | } | 1119 | } |
@@ -1535,9 +1136,7 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, | |||
1535 | { | 1136 | { |
1536 | Mpi2ConfigRequest_t mpi_request; | 1137 | Mpi2ConfigRequest_t mpi_request; |
1537 | int r; | 1138 | int r; |
1538 | struct config_request mem; | ||
1539 | 1139 | ||
1540 | memset(config_page, 0, sizeof(Mpi2RaidVolPage1_t)); | ||
1541 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1140 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1542 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 1141 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1543 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 1142 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
@@ -1546,38 +1145,15 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, | |||
1546 | mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION; | 1145 | mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION; |
1547 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1146 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1548 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1147 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1549 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1148 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1550 | if (r) | 1149 | if (r) |
1551 | goto out; | 1150 | goto out; |
1552 | 1151 | ||
1553 | mpi_request.PageAddress = cpu_to_le32(form | handle); | 1152 | mpi_request.PageAddress = cpu_to_le32(form | handle); |
1554 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1153 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1555 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1556 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1557 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1558 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
1559 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
1560 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1561 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1562 | if (r) | ||
1563 | goto out; | ||
1564 | } else { | ||
1565 | mem.config_page_dma = ioc->config_page_dma; | ||
1566 | mem.config_page = ioc->config_page; | ||
1567 | } | ||
1568 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1569 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1570 | mem.config_page_dma); | ||
1571 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1154 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1572 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1155 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1573 | if (!r) | 1156 | sizeof(*config_page)); |
1574 | memcpy(config_page, mem.config_page, | ||
1575 | min_t(u16, mem.config_page_sz, | ||
1576 | sizeof(Mpi2RaidVolPage1_t))); | ||
1577 | |||
1578 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1579 | _config_free_config_dma_memory(ioc, &mem); | ||
1580 | |||
1581 | out: | 1157 | out: |
1582 | return r; | 1158 | return r; |
1583 | } | 1159 | } |
@@ -1596,10 +1172,9 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, | |||
1596 | u8 *num_pds) | 1172 | u8 *num_pds) |
1597 | { | 1173 | { |
1598 | Mpi2ConfigRequest_t mpi_request; | 1174 | Mpi2ConfigRequest_t mpi_request; |
1599 | Mpi2RaidVolPage0_t *config_page; | 1175 | Mpi2RaidVolPage0_t config_page; |
1600 | Mpi2ConfigReply_t mpi_reply; | 1176 | Mpi2ConfigReply_t mpi_reply; |
1601 | int r; | 1177 | int r; |
1602 | struct config_request mem; | ||
1603 | u16 ioc_status; | 1178 | u16 ioc_status; |
1604 | 1179 | ||
1605 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1180 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
@@ -1611,43 +1186,23 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, | |||
1611 | mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; | 1186 | mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; |
1612 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1187 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1613 | r = _config_request(ioc, &mpi_request, &mpi_reply, | 1188 | r = _config_request(ioc, &mpi_request, &mpi_reply, |
1614 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1189 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1615 | if (r) | 1190 | if (r) |
1616 | goto out; | 1191 | goto out; |
1617 | 1192 | ||
1618 | mpi_request.PageAddress = | 1193 | mpi_request.PageAddress = |
1619 | cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle); | 1194 | cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle); |
1620 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1195 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1621 | mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; | ||
1622 | mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; | ||
1623 | mpi_request.Header.PageType = mpi_reply.Header.PageType; | ||
1624 | mpi_request.Header.PageLength = mpi_reply.Header.PageLength; | ||
1625 | mem.config_page_sz = le16_to_cpu(mpi_reply.Header.PageLength) * 4; | ||
1626 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1627 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1628 | if (r) | ||
1629 | goto out; | ||
1630 | } else { | ||
1631 | mem.config_page_dma = ioc->config_page_dma; | ||
1632 | mem.config_page = ioc->config_page; | ||
1633 | } | ||
1634 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1635 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1636 | mem.config_page_dma); | ||
1637 | r = _config_request(ioc, &mpi_request, &mpi_reply, | 1196 | r = _config_request(ioc, &mpi_request, &mpi_reply, |
1638 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1197 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page, |
1198 | sizeof(Mpi2RaidVolPage0_t)); | ||
1639 | if (!r) { | 1199 | if (!r) { |
1640 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & | 1200 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & |
1641 | MPI2_IOCSTATUS_MASK; | 1201 | MPI2_IOCSTATUS_MASK; |
1642 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { | 1202 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) |
1643 | config_page = mem.config_page; | 1203 | *num_pds = config_page.NumPhysDisks; |
1644 | *num_pds = config_page->NumPhysDisks; | ||
1645 | } | ||
1646 | } | 1204 | } |
1647 | 1205 | ||
1648 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1649 | _config_free_config_dma_memory(ioc, &mem); | ||
1650 | |||
1651 | out: | 1206 | out: |
1652 | return r; | 1207 | return r; |
1653 | } | 1208 | } |
@@ -1671,10 +1226,8 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, | |||
1671 | { | 1226 | { |
1672 | Mpi2ConfigRequest_t mpi_request; | 1227 | Mpi2ConfigRequest_t mpi_request; |
1673 | int r; | 1228 | int r; |
1674 | struct config_request mem; | ||
1675 | 1229 | ||
1676 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1230 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1677 | memset(config_page, 0, sz); | ||
1678 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 1231 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1679 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 1232 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
1680 | mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME; | 1233 | mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME; |
@@ -1682,37 +1235,14 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, | |||
1682 | mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; | 1235 | mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION; |
1683 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1236 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1684 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1237 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1685 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1238 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1686 | if (r) | 1239 | if (r) |
1687 | goto out; | 1240 | goto out; |
1688 | 1241 | ||
1689 | mpi_request.PageAddress = cpu_to_le32(form | handle); | 1242 | mpi_request.PageAddress = cpu_to_le32(form | handle); |
1690 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1243 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1691 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1692 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1693 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1694 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
1695 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
1696 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1697 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1698 | if (r) | ||
1699 | goto out; | ||
1700 | } else { | ||
1701 | mem.config_page_dma = ioc->config_page_dma; | ||
1702 | mem.config_page = ioc->config_page; | ||
1703 | } | ||
1704 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1705 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1706 | mem.config_page_dma); | ||
1707 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1244 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1708 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1245 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz); |
1709 | if (!r) | ||
1710 | memcpy(config_page, mem.config_page, | ||
1711 | min_t(u16, sz, mem.config_page_sz)); | ||
1712 | |||
1713 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1714 | _config_free_config_dma_memory(ioc, &mem); | ||
1715 | |||
1716 | out: | 1246 | out: |
1717 | return r; | 1247 | return r; |
1718 | } | 1248 | } |
@@ -1735,10 +1265,8 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t | |||
1735 | { | 1265 | { |
1736 | Mpi2ConfigRequest_t mpi_request; | 1266 | Mpi2ConfigRequest_t mpi_request; |
1737 | int r; | 1267 | int r; |
1738 | struct config_request mem; | ||
1739 | 1268 | ||
1740 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); | 1269 | memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); |
1741 | memset(config_page, 0, sizeof(Mpi2RaidPhysDiskPage0_t)); | ||
1742 | mpi_request.Function = MPI2_FUNCTION_CONFIG; | 1270 | mpi_request.Function = MPI2_FUNCTION_CONFIG; |
1743 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; | 1271 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; |
1744 | mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK; | 1272 | 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 | mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION; | 1274 | mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION; |
1747 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1275 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1748 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1276 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1749 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1277 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1750 | if (r) | 1278 | if (r) |
1751 | goto out; | 1279 | goto out; |
1752 | 1280 | ||
1753 | mpi_request.PageAddress = cpu_to_le32(form | form_specific); | 1281 | mpi_request.PageAddress = cpu_to_le32(form | form_specific); |
1754 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1282 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1755 | mpi_request.Header.PageVersion = mpi_reply->Header.PageVersion; | ||
1756 | mpi_request.Header.PageNumber = mpi_reply->Header.PageNumber; | ||
1757 | mpi_request.Header.PageType = mpi_reply->Header.PageType; | ||
1758 | mpi_request.Header.PageLength = mpi_reply->Header.PageLength; | ||
1759 | mem.config_page_sz = le16_to_cpu(mpi_reply->Header.PageLength) * 4; | ||
1760 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1761 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1762 | if (r) | ||
1763 | goto out; | ||
1764 | } else { | ||
1765 | mem.config_page_dma = ioc->config_page_dma; | ||
1766 | mem.config_page = ioc->config_page; | ||
1767 | } | ||
1768 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1769 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1770 | mem.config_page_dma); | ||
1771 | r = _config_request(ioc, &mpi_request, mpi_reply, | 1283 | r = _config_request(ioc, &mpi_request, mpi_reply, |
1772 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1284 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1773 | if (!r) | 1285 | sizeof(*config_page)); |
1774 | memcpy(config_page, mem.config_page, | ||
1775 | min_t(u16, mem.config_page_sz, | ||
1776 | sizeof(Mpi2RaidPhysDiskPage0_t))); | ||
1777 | |||
1778 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1779 | _config_free_config_dma_memory(ioc, &mem); | ||
1780 | |||
1781 | out: | 1286 | out: |
1782 | return r; | 1287 | return r; |
1783 | } | 1288 | } |
@@ -1795,11 +1300,10 @@ int | |||
1795 | mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, | 1300 | mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, |
1796 | u16 *volume_handle) | 1301 | u16 *volume_handle) |
1797 | { | 1302 | { |
1798 | Mpi2RaidConfigurationPage0_t *config_page; | 1303 | Mpi2RaidConfigurationPage0_t *config_page = NULL; |
1799 | Mpi2ConfigRequest_t mpi_request; | 1304 | Mpi2ConfigRequest_t mpi_request; |
1800 | Mpi2ConfigReply_t mpi_reply; | 1305 | Mpi2ConfigReply_t mpi_reply; |
1801 | int r, i; | 1306 | int r, i, config_page_sz; |
1802 | struct config_request mem; | ||
1803 | u16 ioc_status; | 1307 | u16 ioc_status; |
1804 | 1308 | ||
1805 | *volume_handle = 0; | 1309 | *volume_handle = 0; |
@@ -1812,40 +1316,27 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, | |||
1812 | mpi_request.Header.PageNumber = 0; | 1316 | mpi_request.Header.PageNumber = 0; |
1813 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); | 1317 | mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE); |
1814 | r = _config_request(ioc, &mpi_request, &mpi_reply, | 1318 | r = _config_request(ioc, &mpi_request, &mpi_reply, |
1815 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1319 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); |
1816 | if (r) | 1320 | if (r) |
1817 | goto out; | 1321 | goto out; |
1818 | 1322 | ||
1819 | mpi_request.PageAddress = | 1323 | mpi_request.PageAddress = |
1820 | cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG); | 1324 | cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG); |
1821 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; | 1325 | mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; |
1822 | mpi_request.Header.PageVersion = mpi_reply.Header.PageVersion; | 1326 | config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4); |
1823 | mpi_request.Header.PageNumber = mpi_reply.Header.PageNumber; | 1327 | config_page = kmalloc(config_page_sz, GFP_KERNEL); |
1824 | mpi_request.Header.PageType = mpi_reply.Header.PageType; | 1328 | if (!config_page) |
1825 | mpi_request.ExtPageLength = mpi_reply.ExtPageLength; | 1329 | goto out; |
1826 | mpi_request.ExtPageType = mpi_reply.ExtPageType; | ||
1827 | mem.config_page_sz = le16_to_cpu(mpi_reply.ExtPageLength) * 4; | ||
1828 | if (mem.config_page_sz > ioc->config_page_sz) { | ||
1829 | r = _config_alloc_config_dma_memory(ioc, &mem); | ||
1830 | if (r) | ||
1831 | goto out; | ||
1832 | } else { | ||
1833 | mem.config_page_dma = ioc->config_page_dma; | ||
1834 | mem.config_page = ioc->config_page; | ||
1835 | } | ||
1836 | ioc->base_add_sg_single(&mpi_request.PageBufferSGE, | ||
1837 | MPT2_CONFIG_COMMON_SGLFLAGS | mem.config_page_sz, | ||
1838 | mem.config_page_dma); | ||
1839 | r = _config_request(ioc, &mpi_request, &mpi_reply, | 1330 | r = _config_request(ioc, &mpi_request, &mpi_reply, |
1840 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT); | 1331 | MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, |
1332 | config_page_sz); | ||
1841 | if (r) | 1333 | if (r) |
1842 | goto out; | 1334 | goto out; |
1843 | 1335 | ||
1844 | r = -1; | 1336 | r = -1; |
1845 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; | 1337 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; |
1846 | if (ioc_status != MPI2_IOCSTATUS_SUCCESS) | 1338 | if (ioc_status != MPI2_IOCSTATUS_SUCCESS) |
1847 | goto done; | 1339 | goto out; |
1848 | config_page = mem.config_page; | ||
1849 | for (i = 0; i < config_page->NumElements; i++) { | 1340 | for (i = 0; i < config_page->NumElements; i++) { |
1850 | if ((config_page->ConfigElement[i].ElementFlags & | 1341 | if ((config_page->ConfigElement[i].ElementFlags & |
1851 | MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != | 1342 | MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != |
@@ -1856,15 +1347,11 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, | |||
1856 | *volume_handle = le16_to_cpu(config_page-> | 1347 | *volume_handle = le16_to_cpu(config_page-> |
1857 | ConfigElement[i].VolDevHandle); | 1348 | ConfigElement[i].VolDevHandle); |
1858 | r = 0; | 1349 | r = 0; |
1859 | goto done; | 1350 | goto out; |
1860 | } | 1351 | } |
1861 | } | 1352 | } |
1862 | |||
1863 | done: | ||
1864 | if (mem.config_page_sz > ioc->config_page_sz) | ||
1865 | _config_free_config_dma_memory(ioc, &mem); | ||
1866 | |||
1867 | out: | 1353 | out: |
1354 | kfree(config_page); | ||
1868 | return r; | 1355 | return r; |
1869 | } | 1356 | } |
1870 | 1357 | ||
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index e71a6c04298b..774b34525bba 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c | |||
@@ -1836,6 +1836,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, | |||
1836 | mpi_request->TaskMID = cpu_to_le16(smid_task); | 1836 | mpi_request->TaskMID = cpu_to_le16(smid_task); |
1837 | int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); | 1837 | int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); |
1838 | mpt2sas_scsih_set_tm_flag(ioc, handle); | 1838 | mpt2sas_scsih_set_tm_flag(ioc, handle); |
1839 | init_completion(&ioc->tm_cmds.done); | ||
1839 | mpt2sas_base_put_smid_hi_priority(ioc, smid, VF_ID); | 1840 | mpt2sas_base_put_smid_hi_priority(ioc, smid, VF_ID); |
1840 | timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); | 1841 | timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); |
1841 | mpt2sas_scsih_clear_tm_flag(ioc, handle); | 1842 | mpt2sas_scsih_clear_tm_flag(ioc, handle); |