From patchwork Fri Jul 27 12:19:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 10547049 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 E7D1513BB for ; Fri, 27 Jul 2018 12:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D72372B852 for ; Fri, 27 Jul 2018 12:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2DB2B859; Fri, 27 Jul 2018 12:19:55 +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 B5BCE2B858 for ; Fri, 27 Jul 2018 12:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730801AbeG0Nle (ORCPT ); Fri, 27 Jul 2018 09:41:34 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35885 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729493AbeG0Nle (ORCPT ); Fri, 27 Jul 2018 09:41:34 -0400 Received: by mail-qt0-f193.google.com with SMTP id t5-v6so4776636qtn.3 for ; Fri, 27 Jul 2018 05:19:53 -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=h9xHeHEjvSDpc1PuPNxz2XnGzO/tYAisASQ0KHMnlyk=; b=EAr6MZ4BvYGTJTdTdlSUH3vMd3wmtLACzObmmCoEC7DzWnz7gVvHRk+s3jXQM7K0Tl 0/r/x14Np2WwD+M7Y8ZMqWDWB/cUid06QTHIJ2woj7/jBG6ZA8hH0iQEUIv53KpYTH+6 fCLvofBrWrBundb0e9Gss6KlbWp8whiVYtp+o= 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=h9xHeHEjvSDpc1PuPNxz2XnGzO/tYAisASQ0KHMnlyk=; b=VLXcohos/+kB+zkesQp/Y8G0wSMH/AnFbGf9Qaub1+OMJRG02nTIRMzN1rjgzYFIHP qpPUB3W/YWKsLlgV7qdpVii9yr4Y2I+OGrQ/RCqZ04EaHF2CxDwuEalJ6aUdmgkDVlTW pIrTCwvffCS7YMi8PgrXiZfl6sYBX28PYhWw+GxODLPglDU6zyqMFe7eJ1YXnqXl6naq k4LbvgeKUfrIw5Itqdp+T8FsPg9aTn8G+y93Dpb5CdmgKP+DKYq/9NQCHGrc7tyxkGW0 txIQzBsUUIO3qpGIwem0r98bMaum5rUU9cNSSl2y0/0vFZqPzNonwLufD6fTrLgA9t0x 2UGA== X-Gm-Message-State: AOUpUlH+64rHD2bM+JL7ttDjGntaiv+uG+sSqB16YClonrlZ5m2LNptt tU1c4s/8v01WXH4XWppfqLDWYw== X-Google-Smtp-Source: AAOMgpdc+szcAqsRrvFPSqd/Cy5FrI8UyaXtfCINkAkGPi9GGTmTgENGnCi1z+gK3JhjGtyMrdP3SA== X-Received: by 2002:ac8:3531:: with SMTP id y46-v6mr5646201qtb.92.1532693992759; Fri, 27 Jul 2018 05:19:52 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.252.250]) by smtp.gmail.com with ESMTPSA id k89-v6sm2322382qte.14.2018.07.27.05.19.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 05:19:51 -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 v1] mpt3sas: Swap I/O memory read value back to cpu endianness Date: Fri, 27 Jul 2018 08:19:39 -0400 Message-Id: <1532693979-12574-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. v1: Changelog: Replaced writeq API with __raw_writeq() & mmiowb() APIs. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 94359d8..c75e88a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3350,11 +3350,10 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, spinlock_t *writeq_lock) { unsigned long flags; - __u64 data_out = b; spin_lock_irqsave(writeq_lock, flags); - writel((u32)(data_out), addr); - writel((u32)(data_out >> 32), (addr + 4)); + __raw_writel((u32)(b), addr); + __raw_writel((u32)(b >> 32), (addr + 4)); mmiowb(); spin_unlock_irqrestore(writeq_lock, flags); } @@ -3374,7 +3373,8 @@ 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); + __raw_writeq(b, addr); + mmiowb(); } #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); }