Skip to content

Commit 09c2f95

Browse files
sreekanthbrcmmartinkpetersen
authored andcommitted
scsi: mpt3sas: Swap I/O memory read value back to cpu endianness
Swap the I/O memory read value back to cpu endianness before storing it in a data structures which are defined in the MPI headers where u8 components are not defined in the endianness order. In this area from day one mpt3sas driver is using le32_to_cpu() & cpu_to_le32() APIs. But in commit cf6bf97 (mpt3sas: Bug fix for big endian systems) we have removed these APIs before reading I/O memory which we should haven't done it. So in this patch I am correcting it by adding these APIs back before accessing I/O memory. Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 1550ec4 commit 09c2f95

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/scsi/mpt3sas/mpt3sas_base.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,11 +3343,10 @@ _base_mpi_ep_writeq(__u64 b, volatile void __iomem *addr,
33433343
spinlock_t *writeq_lock)
33443344
{
33453345
unsigned long flags;
3346-
__u64 data_out = b;
33473346

33483347
spin_lock_irqsave(writeq_lock, flags);
3349-
writel((u32)(data_out), addr);
3350-
writel((u32)(data_out >> 32), (addr + 4));
3348+
__raw_writel((u32)(b), addr);
3349+
__raw_writel((u32)(b >> 32), (addr + 4));
33513350
mmiowb();
33523351
spin_unlock_irqrestore(writeq_lock, flags);
33533352
}
@@ -3367,7 +3366,8 @@ _base_mpi_ep_writeq(__u64 b, volatile void __iomem *addr,
33673366
static inline void
33683367
_base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock)
33693368
{
3370-
writeq(b, addr);
3369+
__raw_writeq(b, addr);
3370+
mmiowb();
33713371
}
33723372
#else
33733373
static inline void
@@ -5268,7 +5268,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes,
52685268

52695269
/* send message 32-bits at a time */
52705270
for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) {
5271-
writel((u32)(request[i]), &ioc->chip->Doorbell);
5271+
writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell);
52725272
if ((_base_wait_for_doorbell_ack(ioc, 5)))
52735273
failed = 1;
52745274
}
@@ -5289,7 +5289,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes,
52895289
}
52905290

52915291
/* read the first two 16-bits, it gives the total length of the reply */
5292-
reply[0] = (u16)(readl(&ioc->chip->Doorbell)
5292+
reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell)
52935293
& MPI2_DOORBELL_DATA_MASK);
52945294
writel(0, &ioc->chip->HostInterruptStatus);
52955295
if ((_base_wait_for_doorbell_int(ioc, 5))) {
@@ -5298,7 +5298,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes,
52985298
ioc->name, __LINE__);
52995299
return -EFAULT;
53005300
}
5301-
reply[1] = (u16)(readl(&ioc->chip->Doorbell)
5301+
reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell)
53025302
& MPI2_DOORBELL_DATA_MASK);
53035303
writel(0, &ioc->chip->HostInterruptStatus);
53045304

@@ -5312,7 +5312,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes,
53125312
if (i >= reply_bytes/2) /* overflow case */
53135313
readl(&ioc->chip->Doorbell);
53145314
else
5315-
reply[i] = (u16)(readl(&ioc->chip->Doorbell)
5315+
reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell)
53165316
& MPI2_DOORBELL_DATA_MASK);
53175317
writel(0, &ioc->chip->HostInterruptStatus);
53185318
}

0 commit comments

Comments
 (0)