From aace34c0bb8ea3c8bdcec865b6a4be4db0a68e33 Mon Sep 17 00:00:00 2001
From: Tin Huynh <tnhuynh@apm.com>
Date: Mon, 22 May 2017 16:19:20 +0700
Subject: [PATCH] leds: pca955x: Correct I2C Functionality

The driver checks an incorrect flag of functionality of adapter.
When a driver requires i2c_smbus_read_byte_data and
i2c_smbus_write_byte_data, it should check I2C_FUNC_SMBUS_BYTE_DATA
instead I2C_FUNC_I2C.
This patch fixes the problem.

Signed-off-by: Tin Huynh <tnhuynh@apm.com>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
 drivers/leds/leds-pca955x.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 78a7ce8..9a87311 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -285,7 +285,7 @@ static int pca955x_probe(struct i2c_client *client,
 			"slave address 0x%02x\n",
 			client->name, chip->bits, client->addr);
 
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 		return -EIO;
 
 	if (pdata) {
-- 
1.7.1

From e83596b41cb9729837468a1c14de56a5529a2aa6 Mon Sep 17 00:00:00 2001
From: David Daney <david.daney@cavium.com>
Date: Wed, 13 Apr 2016 14:26:56 -0700
Subject: [PATCH] pm80xx: Remove bogus address masking in pm8001_ioremap()

It is unclear what the original intent of the masking was, but it is
clearly incorrect to truncate a physical address before calling
ioremap().  On systems where there are valid physical address bits above
bit-31 (arm64 for example) the result is an eventual OOPs when
initializing the driver.

Remove the bogus code to fix it.

Signed-off-by: David Daney <david.daney@cavium.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/scsi/pm8001/pm8001_init.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 062ab34..6bd7bf4 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -418,8 +418,6 @@ static int pm8001_ioremap(struct pm8001_hba_info *pm8001_ha)
 		if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
 			pm8001_ha->io_mem[logicalBar].membase =
 				pci_resource_start(pdev, bar);
-			pm8001_ha->io_mem[logicalBar].membase &=
-				(u32)PCI_BASE_ADDRESS_MEM_MASK;
 			pm8001_ha->io_mem[logicalBar].memsize =
 				pci_resource_len(pdev, bar);
 			pm8001_ha->io_mem[logicalBar].memvirtaddr =
-- 
1.7.1

From 83c3d3400c87d6d943bf97fce4b30f4fe6870253 Mon Sep 17 00:00:00 2001
From: Kefeng Wang <wangkefeng.wang@huawei.com>
Date: Tue, 12 Jul 2016 17:43:25 +0800
Subject: [PATCH] mpt3sas: Fix panic when aer correct error occurred

The _scsih_pci_mmio_enabled called if scsih_pci_error_detected returns
PCI_ERS_RESULT_CAN_RECOVER, at this point, read/write to the device
still works, no need to reset slot.

Or the mpt3sas_base_map_resources in scsih_pci_slot_reset will fail,
and iounamp ioc->chip, then we will meet issue when read ioc->chip
in mpt3sas_base_get_iocstate from _base_fault_reset_work.

Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Chaitra P B <chaitra.basappa@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index cd6be7b..cd91a68 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -9035,8 +9035,11 @@ static void sas_device_make_active(struct MPT3SAS_ADAPTER *ioc,
 
 	/* TODO - dump whatever for debugging purposes */
 
-	/* Request a slot reset. */
-	return PCI_ERS_RESULT_NEED_RESET;
+	/* This called only if scsih_pci_error_detected returns
+	 * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still
+	 * works, no need to reset slot.
+	 */
+	return PCI_ERS_RESULT_RECOVERED;
 }
 
 /*
-- 
1.7.1

From 0eb952134c15bcbc25a2f779348eb8f05afc7132 Mon Sep 17 00:00:00 2001
From: Duc Dang <dhdang@apm.com>
Date: Wed, 8 Feb 2017 16:28:18 -0600
Subject: [PATCH] scsi: mpt3sas: Fix BDI reregistration race with sas3ircu utility

When creating a second RAID volume from sas3ircu utility, system tries
to create a duplicate virtual bdi, thus a race condition occurs and
causes kernel crashing.

This patch will make mpt3sas driver unregister the registered bdi devices
before creating the new one.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1581326

Change-Id: Ic96553d2c97145c4d817f12a7652315f945a9586
Signed-off-by: Huy Duong <hduong@apm.com>
Signed-off-by: Duc Dang <dhdang@apm.com>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |    3 +++
 mm/backing-dev.c                     |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 9ab77b0..ceb053a 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -54,6 +54,7 @@
 #include <linux/interrupt.h>
 #include <linux/aer.h>
 #include <linux/raid_class.h>
+#include <linux/backing-dev.h>
 #include <asm/unaligned.h>
 
 #include "mpt3sas_base.h"
@@ -6115,6 +6116,8 @@ _scsih_reprobe_lun(struct scsi_device *sdev, void *no_uld_attach)
 	sdev->no_uld_attach = no_uld_attach ? 1 : 0;
 	sdev_printk(KERN_INFO, sdev, "%s raid component\n",
 	    sdev->no_uld_attach ? "hidding" : "exposing");
+	if (sdev->no_uld_attach)
+		bdi_unregister(&sdev->request_queue->backing_dev_info);
 	rc = scsi_device_reprobe(sdev);
 }
 
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index c554d17..d5b9ea0 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -850,6 +850,7 @@ void bdi_unregister(struct backing_dev_info *bdi)
 		bdi->dev = NULL;
 	}
 }
+EXPORT_SYMBOL(bdi_unregister);
 
 void bdi_exit(struct backing_dev_info *bdi)
 {
-- 
1.7.1

