Skip to content

Commit 077424e

Browse files
Jing HuangJames Bottomley
authored andcommitted
[SCSI] bfa: sg addr big endian fix
sg address in IO request is not set up correctly for big endian platform. add new macros to properly swap the address. Signed-off-by: Jing Huang <huangj@brocade.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 42b426e commit 077424e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

drivers/scsi/bfa/bfa_ioim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
758758
sge = &m->sges[0];
759759
if (ioim->nsges) {
760760
sg = (struct scatterlist *)scsi_sglist(cmnd);
761-
addr = (u64) sg_dma_address(sg);
761+
addr = bfa_os_sgaddr(sg_dma_address(sg));
762762
sge->sga = *(union bfi_addr_u *) &addr;
763763
pgdlen = sg_dma_len(sg);
764764
sge->sg_len = pgdlen;
@@ -891,7 +891,7 @@ bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim)
891891

892892
pgcumsz = 0;
893893
for (i = 0; i < nsges; i++, sge++, sgeid++, sg = sg_next(sg)) {
894-
addr = (u64) sg_dma_address(sg);
894+
addr = bfa_os_sgaddr(sg_dma_address(sg));
895895
sge->sga = *(union bfi_addr_u *) &addr;
896896
sge->sg_len = sg_dma_len(sg);
897897
pgcumsz += sge->sg_len;

drivers/scsi/bfa/bfa_os_inc.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#include <scsi/scsi_transport_fc.h>
5151
#include <scsi/scsi_transport.h>
5252

53+
#ifdef __BIG_ENDIAN
54+
#define __BIGENDIAN
55+
#endif
56+
5357
#define BFA_ERR KERN_ERR
5458
#define BFA_WARNING KERN_WARNING
5559
#define BFA_NOTICE KERN_NOTICE
@@ -123,6 +127,15 @@ int bfa_os_MWB(void *);
123127
(((_x) & 0x00ff0000) >> 8) | \
124128
(((_x) & 0xff000000) >> 24))
125129

130+
#define bfa_os_swap_sgaddr(_x) ((u64)( \
131+
(((u64)(_x) & (u64)0x00000000000000ffull) << 32) | \
132+
(((u64)(_x) & (u64)0x000000000000ff00ull) << 32) | \
133+
(((u64)(_x) & (u64)0x0000000000ff0000ull) << 32) | \
134+
(((u64)(_x) & (u64)0x00000000ff000000ull) << 32) | \
135+
(((u64)(_x) & (u64)0x000000ff00000000ull) >> 32) | \
136+
(((u64)(_x) & (u64)0x0000ff0000000000ull) >> 32) | \
137+
(((u64)(_x) & (u64)0x00ff000000000000ull) >> 32) | \
138+
(((u64)(_x) & (u64)0xff00000000000000ull) >> 32)))
126139

127140
#ifndef __BIGENDIAN
128141
#define bfa_os_htons(_x) ((u16)((((_x) & 0xff00) >> 8) | \
@@ -133,6 +146,7 @@ int bfa_os_MWB(void *);
133146
#define bfa_os_hton3b(_x) bfa_swap_3b(_x)
134147

135148
#define bfa_os_wtole(_x) (_x)
149+
#define bfa_os_sgaddr(_x) (_x)
136150

137151
#else
138152

@@ -141,6 +155,7 @@ int bfa_os_MWB(void *);
141155
#define bfa_os_hton3b(_x) (_x)
142156
#define bfa_os_htonll(_x) (_x)
143157
#define bfa_os_wtole(_x) bfa_os_swap32(_x)
158+
#define bfa_os_sgaddr(_x) bfa_os_swap_sgaddr(_x)
144159

145160
#endif
146161

0 commit comments

Comments
 (0)