aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdheer Chandravanshi <adheer.chandravanshi@qlogic.com>2013-04-05 07:06:06 -0400
committerJames Bottomley <JBottomley@Parallels.com>2013-04-11 19:45:48 -0400
commit039acc1e70ba354a430023c3c997f680d7c098b9 (patch)
treea6779e749a59d4fcb6ea564c9e82635b48bcdbc5
parent4eeb587e4b62749c544e0e3bf62c0934d1b3852b (diff)
[SCSI] qla4xxx: Use correct flash ddb offset for ISP40XX
Use correct flash ddb offset to add and delete flash target entries for ISP40XX Signed-off-by: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com> Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c7
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c57
2 files changed, 43 insertions, 21 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 8985997de576..a501beab3ffe 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1421,7 +1421,7 @@ int qla4xxx_flashdb_by_index(struct scsi_qla_host *ha,
1421 struct dev_db_entry *fw_ddb_entry, 1421 struct dev_db_entry *fw_ddb_entry,
1422 dma_addr_t fw_ddb_entry_dma, uint16_t ddb_index) 1422 dma_addr_t fw_ddb_entry_dma, uint16_t ddb_index)
1423{ 1423{
1424 uint32_t dev_db_start_offset = FLASH_OFFSET_DB_INFO; 1424 uint32_t dev_db_start_offset;
1425 uint32_t dev_db_end_offset; 1425 uint32_t dev_db_end_offset;
1426 int status = QLA_ERROR; 1426 int status = QLA_ERROR;
1427 1427
@@ -1429,6 +1429,7 @@ int qla4xxx_flashdb_by_index(struct scsi_qla_host *ha,
1429 1429
1430 if (is_qla40XX(ha)) { 1430 if (is_qla40XX(ha)) {
1431 dev_db_start_offset = FLASH_OFFSET_DB_INFO; 1431 dev_db_start_offset = FLASH_OFFSET_DB_INFO;
1432 dev_db_end_offset = FLASH_OFFSET_DB_END;
1432 } else { 1433 } else {
1433 dev_db_start_offset = FLASH_RAW_ACCESS_ADDR + 1434 dev_db_start_offset = FLASH_RAW_ACCESS_ADDR +
1434 (ha->hw.flt_region_ddb << 2); 1435 (ha->hw.flt_region_ddb << 2);
@@ -1437,9 +1438,11 @@ int qla4xxx_flashdb_by_index(struct scsi_qla_host *ha,
1437 */ 1438 */
1438 if (ha->port_num == 1) 1439 if (ha->port_num == 1)
1439 dev_db_start_offset += (ha->hw.flt_ddb_size / 2); 1440 dev_db_start_offset += (ha->hw.flt_ddb_size / 2);
1441
1442 dev_db_end_offset = dev_db_start_offset +
1443 (ha->hw.flt_ddb_size / 2);
1440 } 1444 }
1441 1445
1442 dev_db_end_offset = dev_db_start_offset + (ha->hw.flt_ddb_size / 2);
1443 dev_db_start_offset += (ddb_index * sizeof(*fw_ddb_entry)); 1446 dev_db_start_offset += (ddb_index * sizeof(*fw_ddb_entry));
1444 1447
1445 if (dev_db_start_offset > dev_db_end_offset) { 1448 if (dev_db_start_offset > dev_db_end_offset) {
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 95a951c6e579..5f7a2bc32069 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6582,6 +6582,8 @@ static int qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess)
6582 struct dev_db_entry *fw_ddb_entry = NULL; 6582 struct dev_db_entry *fw_ddb_entry = NULL;
6583 dma_addr_t fw_ddb_entry_dma; 6583 dma_addr_t fw_ddb_entry_dma;
6584 uint16_t *ddb_cookie = NULL; 6584 uint16_t *ddb_cookie = NULL;
6585 size_t ddb_size;
6586 void *pddb = NULL;
6585 int target_id; 6587 int target_id;
6586 int rc = 0; 6588 int rc = 0;
6587 6589
@@ -6601,18 +6603,12 @@ static int qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess)
6601 if (fnode_sess->flash_state == DEV_DB_NON_PERSISTENT) 6603 if (fnode_sess->flash_state == DEV_DB_NON_PERSISTENT)
6602 goto sysfs_ddb_del; 6604 goto sysfs_ddb_del;
6603 6605
6604 ddb_cookie = dma_alloc_coherent(&ha->pdev->dev, sizeof(*ddb_cookie),
6605 &fw_ddb_entry_dma, GFP_KERNEL);
6606 if (!ddb_cookie) {
6607 rc = -ENOMEM;
6608 DEBUG2(ql4_printk(KERN_ERR, ha,
6609 "%s: Unable to allocate dma buffer\n",
6610 __func__));
6611 goto exit_ddb_del;
6612 }
6613
6614 if (is_qla40XX(ha)) { 6606 if (is_qla40XX(ha)) {
6615 dev_db_start_offset = FLASH_OFFSET_DB_INFO; 6607 dev_db_start_offset = FLASH_OFFSET_DB_INFO;
6608 dev_db_end_offset = FLASH_OFFSET_DB_END;
6609 dev_db_start_offset += (fnode_sess->target_id *
6610 sizeof(*fw_ddb_entry));
6611 ddb_size = sizeof(*fw_ddb_entry);
6616 } else { 6612 } else {
6617 dev_db_start_offset = FLASH_RAW_ACCESS_ADDR + 6613 dev_db_start_offset = FLASH_RAW_ACCESS_ADDR +
6618 (ha->hw.flt_region_ddb << 2); 6614 (ha->hw.flt_region_ddb << 2);
@@ -6621,12 +6617,17 @@ static int qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess)
6621 */ 6617 */
6622 if (ha->port_num == 1) 6618 if (ha->port_num == 1)
6623 dev_db_start_offset += (ha->hw.flt_ddb_size / 2); 6619 dev_db_start_offset += (ha->hw.flt_ddb_size / 2);
6624 }
6625 6620
6626 dev_db_end_offset = dev_db_start_offset + (ha->hw.flt_ddb_size / 2); 6621 dev_db_end_offset = dev_db_start_offset +
6627 dev_db_start_offset += (fnode_sess->target_id * sizeof(*fw_ddb_entry)); 6622 (ha->hw.flt_ddb_size / 2);
6628 dev_db_start_offset += (void *)&(fw_ddb_entry->cookie) - 6623
6629 (void *)fw_ddb_entry; 6624 dev_db_start_offset += (fnode_sess->target_id *
6625 sizeof(*fw_ddb_entry));
6626 dev_db_start_offset += (void *)&(fw_ddb_entry->cookie) -
6627 (void *)fw_ddb_entry;
6628
6629 ddb_size = sizeof(*ddb_cookie);
6630 }
6630 6631
6631 DEBUG2(ql4_printk(KERN_ERR, ha, "%s: start offset=%u, end offset=%u\n", 6632 DEBUG2(ql4_printk(KERN_ERR, ha, "%s: start offset=%u, end offset=%u\n",
6632 __func__, dev_db_start_offset, dev_db_end_offset)); 6633 __func__, dev_db_start_offset, dev_db_end_offset));
@@ -6638,10 +6639,28 @@ static int qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess)
6638 goto exit_ddb_del; 6639 goto exit_ddb_del;
6639 } 6640 }
6640 6641
6642 pddb = dma_alloc_coherent(&ha->pdev->dev, ddb_size,
6643 &fw_ddb_entry_dma, GFP_KERNEL);
6644 if (!pddb) {
6645 rc = -ENOMEM;
6646 DEBUG2(ql4_printk(KERN_ERR, ha,
6647 "%s: Unable to allocate dma buffer\n",
6648 __func__));
6649 goto exit_ddb_del;
6650 }
6651
6652 if (is_qla40XX(ha)) {
6653 fw_ddb_entry = pddb;
6654 memset(fw_ddb_entry, 0, ddb_size);
6655 ddb_cookie = &fw_ddb_entry->cookie;
6656 } else {
6657 ddb_cookie = pddb;
6658 }
6659
6641 /* invalidate the cookie */ 6660 /* invalidate the cookie */
6642 *ddb_cookie = 0xFFEE; 6661 *ddb_cookie = 0xFFEE;
6643 qla4xxx_set_flash(ha, fw_ddb_entry_dma, dev_db_start_offset, 6662 qla4xxx_set_flash(ha, fw_ddb_entry_dma, dev_db_start_offset,
6644 sizeof(*ddb_cookie), FLASH_OPT_RMW_COMMIT); 6663 ddb_size, FLASH_OPT_RMW_COMMIT);
6645 6664
6646sysfs_ddb_del: 6665sysfs_ddb_del:
6647 target_id = fnode_sess->target_id; 6666 target_id = fnode_sess->target_id;
@@ -6650,9 +6669,9 @@ sysfs_ddb_del:
6650 "%s: session and conn entries for flashnode %u of host %lu deleted\n", 6669 "%s: session and conn entries for flashnode %u of host %lu deleted\n",
6651 __func__, target_id, ha->host_no); 6670 __func__, target_id, ha->host_no);
6652exit_ddb_del: 6671exit_ddb_del:
6653 if (ddb_cookie) 6672 if (pddb)
6654 dma_free_coherent(&ha->pdev->dev, sizeof(*ddb_cookie), 6673 dma_free_coherent(&ha->pdev->dev, ddb_size, pddb,
6655 ddb_cookie, fw_ddb_entry_dma); 6674 fw_ddb_entry_dma);
6656 return rc; 6675 return rc;
6657} 6676}
6658 6677