From patchwork Wed Jul 25 09:42:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 10543767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2141139A for ; Wed, 25 Jul 2018 09:42:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1590296A3 for ; Wed, 25 Jul 2018 09:42:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3506295E9; Wed, 25 Jul 2018 09:42:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 678FC295E9 for ; Wed, 25 Jul 2018 09:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728754AbeGYKxO (ORCPT ); Wed, 25 Jul 2018 06:53:14 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33416 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728620AbeGYKxO (ORCPT ); Wed, 25 Jul 2018 06:53:14 -0400 Received: by mail-wm0-f67.google.com with SMTP id r24-v6so7812251wmh.0 for ; Wed, 25 Jul 2018 02:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=nLpGIL7I6d3t1sgU/YKA3MuZDeCuqVCmofeufhOAhpQ=; b=X234a2tjNIb7/0ROKPHX7zrY8Tr43I9LcmVB4FtmiAN0GpVwYoZSB9QBvIXtwWT2fS ga5WcBUIO6L0b7x1HTiOG4KeO4VvJzkd8f8VEfiAWtEtlhMNqfQXVvOBY+rwxFWCTIYT 5dzi4JZIVCm+gyYwLEvlzHTp73pg+1KFAwKOU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nLpGIL7I6d3t1sgU/YKA3MuZDeCuqVCmofeufhOAhpQ=; b=cnKaWZL/nrJnfEcCXrtEGohWMd7dARtwC/RxL7o32BNa5cCjFnIllh3/i9haH3YGQm TYec/DNcYLaSd4IUARvztnYTNnvGC1SWyMnJYc0qXU2boqn5b7iPNQFVUoP2i8HD3dz7 qL1G1+3rytX86H8HefaBZZBVvPsNLDpK+pZq+/TBvc9ceYN3sieJMXU3XkPJGoWcHTwX DDb8UlEs3ME1OotoPtH6NS/iMwa6PTUAHv5YsYzr03vnXlkEcqwUR9iN/z4A8UJb4Tlq ULWzxXZygSwOf/JSDrQFUIImIFa6g85rAakPZo4RlqtMrClvWw5QjBCMXC5O/5xnd/pS Afrg== X-Gm-Message-State: AOUpUlGiq+1kZiVWmW0csNXm2q0swZlbfs9VQjHxdK8u3YWv0zKwKnqC lqKrb/gf8AzvVtoAHwROjRbzeg== X-Google-Smtp-Source: AAOMgpfhulm6Sfq44Vv5WclOicV3J+CVpNeLk9nufEo1owPj0MfY4ZYTYLK+k7GqbvarcrRXtcK+Eg== X-Received: by 2002:a1c:c3c4:: with SMTP id t187-v6mr4402286wmf.123.1532511739755; Wed, 25 Jul 2018 02:42:19 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.252.250]) by smtp.gmail.com with ESMTPSA id d15-v6sm2291408wma.1.2018.07.25.02.42.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 02:42:18 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, sathya.prakash@broadcom.com, thenzl@redhat.com, davem@davemloft.net, Sreekanth Reddy Subject: [PATCH] mpt3sas: Swap I/O memory read value back to cpu endianness Date: Wed, 25 Jul 2018 05:42:05 -0400 Message-Id: <1532511725-7726-1-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 the patch cf6bf9710c (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 --- drivers/scsi/mpt3sas/mpt3sas_base.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 94359d8..c7738d1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3350,7 +3350,7 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, spinlock_t *writeq_lock) { unsigned long flags; - __u64 data_out = b; + __u64 data_out = cpu_to_le64(b); spin_lock_irqsave(writeq_lock, flags); writel((u32)(data_out), addr); @@ -3374,7 +3374,7 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, static inline void _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock) { - writeq(b, addr); + writeq(cpu_to_le64(b), addr); } #else static inline void @@ -5275,7 +5275,7 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, /* send message 32-bits at a time */ for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) { - writel((u32)(request[i]), &ioc->chip->Doorbell); + writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell); if ((_base_wait_for_doorbell_ack(ioc, 5))) failed = 1; } @@ -5296,7 +5296,7 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, } /* read the first two 16-bits, it gives the total length of the reply */ - reply[0] = (u16)(readl(&ioc->chip->Doorbell) + reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_DATA_MASK); writel(0, &ioc->chip->HostInterruptStatus); if ((_base_wait_for_doorbell_int(ioc, 5))) { @@ -5305,7 +5305,7 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, ioc->name, __LINE__); return -EFAULT; } - reply[1] = (u16)(readl(&ioc->chip->Doorbell) + reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_DATA_MASK); writel(0, &ioc->chip->HostInterruptStatus); @@ -5319,7 +5319,7 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, if (i >= reply_bytes/2) /* overflow case */ readl(&ioc->chip->Doorbell); else - reply[i] = (u16)(readl(&ioc->chip->Doorbell) + reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_DATA_MASK); writel(0, &ioc->chip->HostInterruptStatus); }