aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa
diff options
context:
space:
mode:
authorJing Huang <huangj@brocade.com>2010-03-19 14:06:05 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 10:24:17 -0400
commit2eba0d4c000777ce43012d7fda806b075f6cf877 (patch)
treefdebad0f55465301bfcbd4f119311f63d358c353 /drivers/scsi/bfa
parentb504293fe9dc42917a919044f2b672fb361329d0 (diff)
[SCSI] bfa: fix the issue of not handling scsi_cmnd sg chaining case
Currently the driver doesn't take into consideraion of possible sg chaining when it walks through the sg list. This is fixed by using the sg_next() which automatically handles the chaining case. Obosolete code is removed as a result of this change. Signed-off-by: Jing Huang <huangj@brocade.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/bfa')
-rw-r--r--drivers/scsi/bfa/bfa_cb_ioim_macros.h29
-rw-r--r--drivers/scsi/bfa/bfa_ioim.c22
2 files changed, 17 insertions, 34 deletions
diff --git a/drivers/scsi/bfa/bfa_cb_ioim_macros.h b/drivers/scsi/bfa/bfa_cb_ioim_macros.h
index 961fe439daad..53a616f5f50d 100644
--- a/drivers/scsi/bfa/bfa_cb_ioim_macros.h
+++ b/drivers/scsi/bfa/bfa_cb_ioim_macros.h
@@ -117,35 +117,6 @@ bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio)
117} 117}
118 118
119/** 119/**
120 * Get SG element for the I/O request given the SG element index
121 */
122static inline union bfi_addr_u
123bfa_cb_ioim_get_sgaddr(struct bfad_ioim_s *dio, int sgeid)
124{
125 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
126 struct scatterlist *sge;
127 u64 addr;
128
129 sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid;
130 addr = (u64) sg_dma_address(sge);
131
132 return *((union bfi_addr_u *) &addr);
133}
134
135static inline u32
136bfa_cb_ioim_get_sglen(struct bfad_ioim_s *dio, int sgeid)
137{
138 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
139 struct scatterlist *sge;
140 u32 len;
141
142 sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid;
143 len = sg_dma_len(sge);
144
145 return len;
146}
147
148/**
149 * Get Command Reference Number for the I/O request. 0 if none. 120 * Get Command Reference Number for the I/O request. 0 if none.
150 */ 121 */
151static inline u8 122static inline u8
diff --git a/drivers/scsi/bfa/bfa_ioim.c b/drivers/scsi/bfa/bfa_ioim.c
index 5b107abe46e5..8a1be201d29b 100644
--- a/drivers/scsi/bfa/bfa_ioim.c
+++ b/drivers/scsi/bfa/bfa_ioim.c
@@ -731,6 +731,9 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
731 static struct fcp_cmnd_s cmnd_z0 = { 0 }; 731 static struct fcp_cmnd_s cmnd_z0 = { 0 };
732 struct bfi_sge_s *sge; 732 struct bfi_sge_s *sge;
733 u32 pgdlen = 0; 733 u32 pgdlen = 0;
734 u64 addr;
735 struct scatterlist *sg;
736 struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio;
734 737
735 /** 738 /**
736 * check for room in queue to send request now 739 * check for room in queue to send request now
@@ -754,8 +757,10 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
754 */ 757 */
755 sge = &m->sges[0]; 758 sge = &m->sges[0];
756 if (ioim->nsges) { 759 if (ioim->nsges) {
757 sge->sga = bfa_cb_ioim_get_sgaddr(ioim->dio, 0); 760 sg = (struct scatterlist *)scsi_sglist(cmnd);
758 pgdlen = bfa_cb_ioim_get_sglen(ioim->dio, 0); 761 addr = (u64) sg_dma_address(sg);
762 sge->sga = *(union bfi_addr_u *) &addr;
763 pgdlen = sg_dma_len(sg);
759 sge->sg_len = pgdlen; 764 sge->sg_len = pgdlen;
760 sge->flags = (ioim->nsges > BFI_SGE_INLINE) ? 765 sge->flags = (ioim->nsges > BFI_SGE_INLINE) ?
761 BFI_SGE_DATA_CPL : BFI_SGE_DATA_LAST; 766 BFI_SGE_DATA_CPL : BFI_SGE_DATA_LAST;
@@ -868,10 +873,16 @@ bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim)
868 struct bfi_sge_s *sge; 873 struct bfi_sge_s *sge;
869 struct bfa_sgpg_s *sgpg; 874 struct bfa_sgpg_s *sgpg;
870 u32 pgcumsz; 875 u32 pgcumsz;
876 u64 addr;
877 struct scatterlist *sg;
878 struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio;
871 879
872 sgeid = BFI_SGE_INLINE; 880 sgeid = BFI_SGE_INLINE;
873 ioim->sgpg = sgpg = bfa_q_first(&ioim->sgpg_q); 881 ioim->sgpg = sgpg = bfa_q_first(&ioim->sgpg_q);
874 882
883 sg = scsi_sglist(cmnd);
884 sg = sg_next(sg);
885
875 do { 886 do {
876 sge = sgpg->sgpg->sges; 887 sge = sgpg->sgpg->sges;
877 nsges = ioim->nsges - sgeid; 888 nsges = ioim->nsges - sgeid;
@@ -879,9 +890,10 @@ bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim)
879 nsges = BFI_SGPG_DATA_SGES; 890 nsges = BFI_SGPG_DATA_SGES;
880 891
881 pgcumsz = 0; 892 pgcumsz = 0;
882 for (i = 0; i < nsges; i++, sge++, sgeid++) { 893 for (i = 0; i < nsges; i++, sge++, sgeid++, sg = sg_next(sg)) {
883 sge->sga = bfa_cb_ioim_get_sgaddr(ioim->dio, sgeid); 894 addr = (u64) sg_dma_address(sg);
884 sge->sg_len = bfa_cb_ioim_get_sglen(ioim->dio, sgeid); 895 sge->sga = *(union bfi_addr_u *) &addr;
896 sge->sg_len = sg_dma_len(sg);
885 pgcumsz += sge->sg_len; 897 pgcumsz += sge->sg_len;
886 898
887 /** 899 /**