aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Vasquez <andrew.vasquez@qlogic.com>2009-03-24 12:07:55 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-04-03 10:22:44 -0400
commit08029990b25b76b1bc167336358bd21812567f2a (patch)
tree87cb617366a61bd643818996cc6186e817e23b63 /drivers
parent534841b3c110b0f149513c7695751879951d3f22 (diff)
[SCSI] qla2xxx: Refactor request/response-queue register handling.
Original code used an overabundance of indirect pointers to function helpers. Instead, the driver can exploit the immutable properties of a queue's ISP-association and ID, which are both known at queue initialization-time. Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h17
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c37
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c18
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c10
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c27
5 files changed, 31 insertions, 78 deletions
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index e0c5bb54b258..c2bc67c42648 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -372,10 +372,10 @@ struct device_reg_2xxx {
372}; 372};
373 373
374struct device_reg_25xxmq { 374struct device_reg_25xxmq {
375 volatile uint32_t req_q_in; 375 uint32_t req_q_in;
376 volatile uint32_t req_q_out; 376 uint32_t req_q_out;
377 volatile uint32_t rsp_q_in; 377 uint32_t rsp_q_in;
378 volatile uint32_t rsp_q_out; 378 uint32_t rsp_q_out;
379}; 379};
380 380
381typedef union { 381typedef union {
@@ -2102,9 +2102,6 @@ struct isp_operations {
2102 2102
2103 int (*get_flash_version) (struct scsi_qla_host *, void *); 2103 int (*get_flash_version) (struct scsi_qla_host *, void *);
2104 int (*start_scsi) (srb_t *); 2104 int (*start_scsi) (srb_t *);
2105 void (*wrt_req_reg) (struct qla_hw_data *, uint16_t, uint16_t);
2106 void (*wrt_rsp_reg) (struct qla_hw_data *, uint16_t, uint16_t);
2107 uint16_t (*rd_req_reg) (struct qla_hw_data *, uint16_t);
2108}; 2105};
2109 2106
2110/* MSI-X Support *************************************************************/ 2107/* MSI-X Support *************************************************************/
@@ -2200,6 +2197,8 @@ struct rsp_que {
2200 dma_addr_t dma; 2197 dma_addr_t dma;
2201 response_t *ring; 2198 response_t *ring;
2202 response_t *ring_ptr; 2199 response_t *ring_ptr;
2200 uint32_t __iomem *rsp_q_in; /* FWI2-capable only. */
2201 uint32_t __iomem *rsp_q_out;
2203 uint16_t ring_index; 2202 uint16_t ring_index;
2204 uint16_t out_ptr; 2203 uint16_t out_ptr;
2205 uint16_t length; 2204 uint16_t length;
@@ -2217,6 +2216,8 @@ struct req_que {
2217 dma_addr_t dma; 2216 dma_addr_t dma;
2218 request_t *ring; 2217 request_t *ring;
2219 request_t *ring_ptr; 2218 request_t *ring_ptr;
2219 uint32_t __iomem *req_q_in; /* FWI2-capable only. */
2220 uint32_t __iomem *req_q_out;
2220 uint16_t ring_index; 2221 uint16_t ring_index;
2221 uint16_t in_ptr; 2222 uint16_t in_ptr;
2222 uint16_t cnt; 2223 uint16_t cnt;
@@ -2277,7 +2278,7 @@ struct qla_hw_data {
2277 2278
2278#define MIN_IOBASE_LEN 0x100 2279#define MIN_IOBASE_LEN 0x100
2279/* Multi queue data structs */ 2280/* Multi queue data structs */
2280 device_reg_t *mqiobase; 2281 device_reg_t __iomem *mqiobase;
2281 uint16_t msix_count; 2282 uint16_t msix_count;
2282 uint8_t mqenable; 2283 uint8_t mqenable;
2283 struct req_que **req_q_map; 2284 struct req_que **req_q_map;
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 2258152b1f41..a8abbb95730d 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -776,7 +776,7 @@ qla24xx_start_scsi(srb_t *sp)
776 776
777 req_cnt = qla24xx_calc_iocbs(tot_dsds); 777 req_cnt = qla24xx_calc_iocbs(tot_dsds);
778 if (req->cnt < (req_cnt + 2)) { 778 if (req->cnt < (req_cnt + 2)) {
779 cnt = ha->isp_ops->rd_req_reg(ha, req->id); 779 cnt = RD_REG_DWORD_RELAXED(req->req_q_out);
780 780
781 if (req->ring_index < cnt) 781 if (req->ring_index < cnt)
782 req->cnt = cnt - req->ring_index; 782 req->cnt = cnt - req->ring_index;
@@ -836,7 +836,8 @@ qla24xx_start_scsi(srb_t *sp)
836 sp->flags |= SRB_DMA_VALID; 836 sp->flags |= SRB_DMA_VALID;
837 837
838 /* Set chip new ring index. */ 838 /* Set chip new ring index. */
839 ha->isp_ops->wrt_req_reg(ha, req->id, req->ring_index); 839 WRT_REG_DWORD(req->req_q_in, req->ring_index);
840 RD_REG_DWORD_RELAXED(&ha->iobase->isp24.hccr);
840 841
841 /* Manage unprocessed RIO/ZIO commands in response queue. */ 842 /* Manage unprocessed RIO/ZIO commands in response queue. */
842 if (vha->flags.process_response_queue && 843 if (vha->flags.process_response_queue &&
@@ -854,35 +855,3 @@ queuing_error:
854 855
855 return QLA_FUNCTION_FAILED; 856 return QLA_FUNCTION_FAILED;
856} 857}
857
858uint16_t
859qla24xx_rd_req_reg(struct qla_hw_data *ha, uint16_t id)
860{
861 device_reg_t __iomem *reg = (void *) ha->iobase;
862 return RD_REG_DWORD_RELAXED(&reg->isp24.req_q_out);
863}
864
865uint16_t
866qla25xx_rd_req_reg(struct qla_hw_data *ha, uint16_t id)
867{
868 device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id;
869 return RD_REG_DWORD_RELAXED(&reg->isp25mq.req_q_out);
870}
871
872void
873qla24xx_wrt_req_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index)
874{
875 device_reg_t __iomem *reg = (void *) ha->iobase;
876 WRT_REG_DWORD(&reg->isp24.req_q_in, index);
877 RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in);
878}
879
880void
881qla25xx_wrt_req_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index)
882{
883 device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id;
884 struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp;
885 WRT_REG_DWORD(&reg->isp25mq.req_q_in, index);
886 RD_REG_DWORD(&ioreg->hccr); /* PCI posting */
887}
888
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index f250e5b7897c..8e91f4aec977 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1499,7 +1499,6 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0)
1499void 1499void
1500qla24xx_process_response_queue(struct rsp_que *rsp) 1500qla24xx_process_response_queue(struct rsp_que *rsp)
1501{ 1501{
1502 struct qla_hw_data *ha = rsp->hw;
1503 struct sts_entry_24xx *pkt; 1502 struct sts_entry_24xx *pkt;
1504 struct scsi_qla_host *vha; 1503 struct scsi_qla_host *vha;
1505 1504
@@ -1553,7 +1552,7 @@ qla24xx_process_response_queue(struct rsp_que *rsp)
1553 } 1552 }
1554 1553
1555 /* Adjust ring index */ 1554 /* Adjust ring index */
1556 ha->isp_ops->wrt_rsp_reg(ha, rsp->id, rsp->ring_index); 1555 WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index);
1557} 1556}
1558 1557
1559static void 1558static void
@@ -2117,18 +2116,3 @@ int qla25xx_request_irq(struct rsp_que *rsp)
2117 msix->rsp = rsp; 2116 msix->rsp = rsp;
2118 return ret; 2117 return ret;
2119} 2118}
2120
2121void
2122qla25xx_wrt_rsp_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index)
2123{
2124 device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id;
2125 WRT_REG_DWORD(&reg->isp25mq.rsp_q_out, index);
2126}
2127
2128void
2129qla24xx_wrt_rsp_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index)
2130{
2131 device_reg_t __iomem *reg = (void *) ha->iobase;
2132 WRT_REG_DWORD(&reg->isp24.rsp_q_out, index);
2133}
2134
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 785c61279e6e..e2bd36e7e885 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -584,6 +584,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
584 struct req_que *req = NULL; 584 struct req_que *req = NULL;
585 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 585 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
586 uint16_t que_id = 0; 586 uint16_t que_id = 0;
587 device_reg_t __iomem *reg;
587 588
588 req = kzalloc(sizeof(struct req_que), GFP_KERNEL); 589 req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
589 if (req == NULL) { 590 if (req == NULL) {
@@ -631,6 +632,9 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
631 req->ring_index = 0; 632 req->ring_index = 0;
632 req->cnt = req->length; 633 req->cnt = req->length;
633 req->id = que_id; 634 req->id = que_id;
635 reg = ISP_QUE_REG(ha, que_id);
636 req->req_q_in = &reg->isp25mq.req_q_in;
637 req->req_q_out = &reg->isp25mq.req_q_out;
634 req->max_q_depth = ha->req_q_map[0]->max_q_depth; 638 req->max_q_depth = ha->req_q_map[0]->max_q_depth;
635 mutex_unlock(&ha->vport_lock); 639 mutex_unlock(&ha->vport_lock);
636 640
@@ -658,7 +662,8 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
658 int ret = 0; 662 int ret = 0;
659 struct rsp_que *rsp = NULL; 663 struct rsp_que *rsp = NULL;
660 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 664 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
661 uint16_t que_id = 0;; 665 uint16_t que_id = 0;
666 device_reg_t __iomem *reg;
662 667
663 rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); 668 rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
664 if (rsp == NULL) { 669 if (rsp == NULL) {
@@ -706,6 +711,9 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
706 rsp->ring_ptr = rsp->ring; 711 rsp->ring_ptr = rsp->ring;
707 rsp->ring_index = 0; 712 rsp->ring_index = 0;
708 rsp->id = que_id; 713 rsp->id = que_id;
714 reg = ISP_QUE_REG(ha, que_id);
715 rsp->rsp_q_in = &reg->isp25mq.rsp_q_in;
716 rsp->rsp_q_out = &reg->isp25mq.rsp_q_out;
709 mutex_unlock(&ha->vport_lock); 717 mutex_unlock(&ha->vport_lock);
710 718
711 ret = qla25xx_request_irq(rsp); 719 ret = qla25xx_request_irq(rsp);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3ddfa889e949..a6761ff73e24 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1351,9 +1351,6 @@ static struct isp_operations qla2100_isp_ops = {
1351 .write_optrom = qla2x00_write_optrom_data, 1351 .write_optrom = qla2x00_write_optrom_data,
1352 .get_flash_version = qla2x00_get_flash_version, 1352 .get_flash_version = qla2x00_get_flash_version,
1353 .start_scsi = qla2x00_start_scsi, 1353 .start_scsi = qla2x00_start_scsi,
1354 .wrt_req_reg = NULL,
1355 .wrt_rsp_reg = NULL,
1356 .rd_req_reg = NULL,
1357}; 1354};
1358 1355
1359static struct isp_operations qla2300_isp_ops = { 1356static struct isp_operations qla2300_isp_ops = {
@@ -1389,9 +1386,6 @@ static struct isp_operations qla2300_isp_ops = {
1389 .write_optrom = qla2x00_write_optrom_data, 1386 .write_optrom = qla2x00_write_optrom_data,
1390 .get_flash_version = qla2x00_get_flash_version, 1387 .get_flash_version = qla2x00_get_flash_version,
1391 .start_scsi = qla2x00_start_scsi, 1388 .start_scsi = qla2x00_start_scsi,
1392 .wrt_req_reg = NULL,
1393 .wrt_rsp_reg = NULL,
1394 .rd_req_reg = NULL,
1395}; 1389};
1396 1390
1397static struct isp_operations qla24xx_isp_ops = { 1391static struct isp_operations qla24xx_isp_ops = {
@@ -1427,9 +1421,6 @@ static struct isp_operations qla24xx_isp_ops = {
1427 .write_optrom = qla24xx_write_optrom_data, 1421 .write_optrom = qla24xx_write_optrom_data,
1428 .get_flash_version = qla24xx_get_flash_version, 1422 .get_flash_version = qla24xx_get_flash_version,
1429 .start_scsi = qla24xx_start_scsi, 1423 .start_scsi = qla24xx_start_scsi,
1430 .wrt_req_reg = qla24xx_wrt_req_reg,
1431 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1432 .rd_req_reg = qla24xx_rd_req_reg,
1433}; 1424};
1434 1425
1435static struct isp_operations qla25xx_isp_ops = { 1426static struct isp_operations qla25xx_isp_ops = {
@@ -1465,9 +1456,6 @@ static struct isp_operations qla25xx_isp_ops = {
1465 .write_optrom = qla24xx_write_optrom_data, 1456 .write_optrom = qla24xx_write_optrom_data,
1466 .get_flash_version = qla24xx_get_flash_version, 1457 .get_flash_version = qla24xx_get_flash_version,
1467 .start_scsi = qla24xx_start_scsi, 1458 .start_scsi = qla24xx_start_scsi,
1468 .wrt_req_reg = qla24xx_wrt_req_reg,
1469 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1470 .rd_req_reg = qla24xx_rd_req_reg,
1471}; 1459};
1472 1460
1473static struct isp_operations qla81xx_isp_ops = { 1461static struct isp_operations qla81xx_isp_ops = {
@@ -1503,9 +1491,6 @@ static struct isp_operations qla81xx_isp_ops = {
1503 .write_optrom = qla24xx_write_optrom_data, 1491 .write_optrom = qla24xx_write_optrom_data,
1504 .get_flash_version = qla24xx_get_flash_version, 1492 .get_flash_version = qla24xx_get_flash_version,
1505 .start_scsi = qla24xx_start_scsi, 1493 .start_scsi = qla24xx_start_scsi,
1506 .wrt_req_reg = qla24xx_wrt_req_reg,
1507 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1508 .rd_req_reg = qla24xx_rd_req_reg,
1509}; 1494};
1510 1495
1511static inline void 1496static inline void
@@ -1927,10 +1912,16 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1927 ha->rsp_q_map[0] = rsp; 1912 ha->rsp_q_map[0] = rsp;
1928 ha->req_q_map[0] = req; 1913 ha->req_q_map[0] = req;
1929 1914
1915 /* FWI2-capable only. */
1916 req->req_q_in = &ha->iobase->isp24.req_q_in;
1917 req->req_q_out = &ha->iobase->isp24.req_q_out;
1918 rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in;
1919 rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out;
1930 if (ha->mqenable) { 1920 if (ha->mqenable) {
1931 ha->isp_ops->wrt_req_reg = qla25xx_wrt_req_reg; 1921 req->req_q_in = &ha->mqiobase->isp25mq.req_q_in;
1932 ha->isp_ops->wrt_rsp_reg = qla25xx_wrt_rsp_reg; 1922 req->req_q_out = &ha->mqiobase->isp25mq.req_q_out;
1933 ha->isp_ops->rd_req_reg = qla25xx_rd_req_reg; 1923 rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in;
1924 rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out;
1934 } 1925 }
1935 1926
1936 if (qla2x00_initialize_adapter(base_vha)) { 1927 if (qla2x00_initialize_adapter(base_vha)) {