aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mpt2sas/mpt2sas_config.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-01-09 02:38:23 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-01-09 02:38:23 -0500
commitda733563be5a9da26fe81d9f007262d00b846e22 (patch)
treedb28291df94a2043af2123911984c5c173da4e6f /drivers/scsi/mpt2sas/mpt2sas_config.c
parent6ccbcf2cb41131f8d56ef0723bf3f7c1f8486076 (diff)
parentdab78d7924598ea4031663dd10db814e2e324928 (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_config.c')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_config.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c
index 6861244249a3..36ea0b2d8020 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -41,7 +41,6 @@
41 * USA. 41 * USA.
42 */ 42 */
43 43
44#include <linux/version.h>
45#include <linux/module.h> 44#include <linux/module.h>
46#include <linux/kernel.h> 45#include <linux/kernel.h>
47#include <linux/init.h> 46#include <linux/init.h>
@@ -1357,6 +1356,9 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1357 Mpi2ConfigReply_t mpi_reply; 1356 Mpi2ConfigReply_t mpi_reply;
1358 int r, i, config_page_sz; 1357 int r, i, config_page_sz;
1359 u16 ioc_status; 1358 u16 ioc_status;
1359 int config_num;
1360 u16 element_type;
1361 u16 phys_disk_dev_handle;
1360 1362
1361 *volume_handle = 0; 1363 *volume_handle = 0;
1362 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1364 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
@@ -1372,35 +1374,53 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1372 if (r) 1374 if (r)
1373 goto out; 1375 goto out;
1374 1376
1375 mpi_request.PageAddress =
1376 cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG);
1377 mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; 1377 mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
1378 config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4); 1378 config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4);
1379 config_page = kmalloc(config_page_sz, GFP_KERNEL); 1379 config_page = kmalloc(config_page_sz, GFP_KERNEL);
1380 if (!config_page) 1380 if (!config_page) {
1381 goto out; 1381 r = -1;
1382 r = _config_request(ioc, &mpi_request, &mpi_reply,
1383 MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
1384 config_page_sz);
1385 if (r)
1386 goto out; 1382 goto out;
1387 1383 }
1388 r = -1; 1384 config_num = 0xff;
1389 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; 1385 while (1) {
1390 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) 1386 mpi_request.PageAddress = cpu_to_le32(config_num +
1391 goto out; 1387 MPI2_RAID_PGAD_FORM_GET_NEXT_CONFIGNUM);
1392 for (i = 0; i < config_page->NumElements; i++) { 1388 r = _config_request(ioc, &mpi_request, &mpi_reply,
1393 if ((le16_to_cpu(config_page->ConfigElement[i].ElementFlags) & 1389 MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
1394 MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != 1390 config_page_sz);
1395 MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT) 1391 if (r)
1396 continue; 1392 goto out;
1397 if (le16_to_cpu(config_page->ConfigElement[i]. 1393 r = -1;
1398 PhysDiskDevHandle) == pd_handle) { 1394 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
1399 *volume_handle = le16_to_cpu(config_page-> 1395 MPI2_IOCSTATUS_MASK;
1400 ConfigElement[i].VolDevHandle); 1396 if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
1401 r = 0;
1402 goto out; 1397 goto out;
1398 for (i = 0; i < config_page->NumElements; i++) {
1399 element_type = le16_to_cpu(config_page->
1400 ConfigElement[i].ElementFlags) &
1401 MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE;
1402 if (element_type ==
1403 MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT ||
1404 element_type ==
1405 MPI2_RAIDCONFIG0_EFLAGS_OCE_ELEMENT) {
1406 phys_disk_dev_handle =
1407 le16_to_cpu(config_page->ConfigElement[i].
1408 PhysDiskDevHandle);
1409 if (phys_disk_dev_handle == pd_handle) {
1410 *volume_handle =
1411 le16_to_cpu(config_page->
1412 ConfigElement[i].VolDevHandle);
1413 r = 0;
1414 goto out;
1415 }
1416 } else if (element_type ==
1417 MPI2_RAIDCONFIG0_EFLAGS_HOT_SPARE_ELEMENT) {
1418 *volume_handle = 0;
1419 r = 0;
1420 goto out;
1421 }
1403 } 1422 }
1423 config_num = config_page->ConfigNum;
1404 } 1424 }
1405 out: 1425 out:
1406 kfree(config_page); 1426 kfree(config_page);