--- /dev/null
+From 156bddd8e505b295540f3ca0e27dda68cb0d49aa Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Mon, 3 Sep 2012 16:50:42 +0200
+Subject: ext3: Fix fdatasync() for files with only i_size changes
+
+From: Jan Kara <jack@suse.cz>
+
+commit 156bddd8e505b295540f3ca0e27dda68cb0d49aa upstream.
+
+Code tracking when transaction needs to be committed on fdatasync(2) forgets
+to handle a situation when only inode's i_size is changed. Thus in such
+situations fdatasync(2) doesn't force transaction with new i_size to disk
+and that can result in wrong i_size after a crash.
+
+Fix the issue by updating inode's i_datasync_tid whenever its size is
+updated.
+
+Reported-by: Kristian Nielsen <knielsen@knielsen-hq.org>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext3/inode.c | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+--- a/fs/ext3/inode.c
++++ b/fs/ext3/inode.c
+@@ -3072,6 +3072,8 @@ static int ext3_do_update_inode(handle_t
+ struct ext3_inode_info *ei = EXT3_I(inode);
+ struct buffer_head *bh = iloc->bh;
+ int err = 0, rc, block;
++ int need_datasync = 0;
++ __le32 disksize;
+ uid_t i_uid;
+ gid_t i_gid;
+
+@@ -3113,7 +3115,11 @@ again:
+ raw_inode->i_gid_high = 0;
+ }
+ raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
+- raw_inode->i_size = cpu_to_le32(ei->i_disksize);
++ disksize = cpu_to_le32(ei->i_disksize);
++ if (disksize != raw_inode->i_size) {
++ need_datasync = 1;
++ raw_inode->i_size = disksize;
++ }
+ raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
+ raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
+ raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
+@@ -3129,8 +3135,11 @@ again:
+ if (!S_ISREG(inode->i_mode)) {
+ raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl);
+ } else {
+- raw_inode->i_size_high =
+- cpu_to_le32(ei->i_disksize >> 32);
++ disksize = cpu_to_le32(ei->i_disksize >> 32);
++ if (disksize != raw_inode->i_size_high) {
++ raw_inode->i_size_high = disksize;
++ need_datasync = 1;
++ }
+ if (ei->i_disksize > 0x7fffffffULL) {
+ struct super_block *sb = inode->i_sb;
+ if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
+@@ -3183,6 +3192,8 @@ again:
+ ext3_clear_inode_state(inode, EXT3_STATE_NEW);
+
+ atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid);
++ if (need_datasync)
++ atomic_set(&ei->i_datasync_tid, handle->h_transaction->t_tid);
+ out_brelse:
+ brelse (bh);
+ ext3_std_error(inode->i_sb, err);
--- /dev/null
+From c9e67d483776d8d2a5f3f70491161b205930ffe1 Mon Sep 17 00:00:00 2001
+From: Miklos Szeredi <mszeredi@suse.cz>
+Date: Tue, 4 Sep 2012 18:45:54 +0200
+Subject: fuse: fix retrieve length
+
+From: Miklos Szeredi <mszeredi@suse.cz>
+
+commit c9e67d483776d8d2a5f3f70491161b205930ffe1 upstream.
+
+In some cases fuse_retrieve() would return a short byte count if offset was
+non-zero. The data returned was correct, though.
+
+Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/fuse/dev.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/fs/fuse/dev.c
++++ b/fs/fuse/dev.c
+@@ -1576,6 +1576,7 @@ static int fuse_retrieve(struct fuse_con
+ req->pages[req->num_pages] = page;
+ req->num_pages++;
+
++ offset = 0;
+ num -= this_num;
+ total_len += this_num;
+ index++;
--- /dev/null
+From e68bb91baa0bb9817567bd45d560919e8e26373b Mon Sep 17 00:00:00 2001
+From: Axel Lin <axel.lin@gmail.com>
+Date: Mon, 10 Sep 2012 10:14:02 +0200
+Subject: i2c-designware: Fix build error if CONFIG_I2C_DESIGNWARE_PLATFORM=y && CONFIG_I2C_DESIGNWARE_PCI=y
+
+From: Axel Lin <axel.lin@gmail.com>
+
+commit e68bb91baa0bb9817567bd45d560919e8e26373b upstream.
+
+This patch adds config I2C_DESIGNWARE_CORE in Kconfig, and let
+I2C_DESIGNWARE_PLATFORM and I2C_DESIGNWARE_PCI select I2C_DESIGNWARE_CORE.
+
+Because both I2C_DESIGNWARE_PLATFORM and I2C_DESIGNWARE_PCI can be built as
+built-in or module, we also need to export the functions in i2c-designware-core.
+
+This fixes below build error when CONFIG_I2C_DESIGNWARE_PLATFORM=y &&
+CONFIG_I2C_DESIGNWARE_PCI=y:
+
+ LD drivers/i2c/busses/built-in.o
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_clear_int':
+i2c-designware-core.c:(.text+0xa10): multiple definition of `i2c_dw_clear_int'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x928): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_init':
+i2c-designware-core.c:(.text+0x178): multiple definition of `i2c_dw_init'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x90): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `dw_readl':
+i2c-designware-core.c:(.text+0xe8): multiple definition of `dw_readl'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x0): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_isr':
+i2c-designware-core.c:(.text+0x724): multiple definition of `i2c_dw_isr'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x63c): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_xfer':
+i2c-designware-core.c:(.text+0x4b0): multiple definition of `i2c_dw_xfer'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x3c8): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_is_enabled':
+i2c-designware-core.c:(.text+0x9d4): multiple definition of `i2c_dw_is_enabled'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8ec): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `dw_writel':
+i2c-designware-core.c:(.text+0x124): multiple definition of `dw_writel'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x3c): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_xfer_msg':
+i2c-designware-core.c:(.text+0x2e8): multiple definition of `i2c_dw_xfer_msg'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x200): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_enable':
+i2c-designware-core.c:(.text+0x9c8): multiple definition of `i2c_dw_enable'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8e0): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_read_comp_param':
+i2c-designware-core.c:(.text+0xa24): multiple definition of `i2c_dw_read_comp_param'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x93c): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_disable':
+i2c-designware-core.c:(.text+0x9dc): multiple definition of `i2c_dw_disable'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8f4): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_func':
+i2c-designware-core.c:(.text+0x710): multiple definition of `i2c_dw_func'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x628): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_disable_int':
+i2c-designware-core.c:(.text+0xa18): multiple definition of `i2c_dw_disable_int'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x930): first defined here
+make[3]: *** [drivers/i2c/busses/built-in.o] Error 1
+make[2]: *** [drivers/i2c/busses] Error 2
+make[1]: *** [drivers/i2c] Error 2
+make: *** [drivers] Error 2
+
+Signed-off-by: Axel Lin <axel.lin@gmail.com>
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Tested-by: Jiri Slaby <jslaby@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/i2c/busses/Kconfig | 5 +++++
+ drivers/i2c/busses/Makefile | 5 +++--
+ drivers/i2c/busses/i2c-designware-core.c | 11 +++++++++++
+ 3 files changed, 19 insertions(+), 2 deletions(-)
+
+--- a/drivers/i2c/busses/Kconfig
++++ b/drivers/i2c/busses/Kconfig
+@@ -350,9 +350,13 @@ config I2C_DAVINCI
+ devices such as DaVinci NIC.
+ For details please see http://www.ti.com/davinci
+
++config I2C_DESIGNWARE_CORE
++ tristate
++
+ config I2C_DESIGNWARE_PLATFORM
+ tristate "Synopsys DesignWare Platform"
+ depends on HAVE_CLK
++ select I2C_DESIGNWARE_CORE
+ help
+ If you say yes to this option, support will be included for the
+ Synopsys DesignWare I2C adapter. Only master mode is supported.
+@@ -363,6 +367,7 @@ config I2C_DESIGNWARE_PLATFORM
+ config I2C_DESIGNWARE_PCI
+ tristate "Synopsys DesignWare PCI"
+ depends on PCI
++ select I2C_DESIGNWARE_CORE
+ help
+ If you say yes to this option, support will be included for the
+ Synopsys DesignWare I2C adapter. Only master mode is supported.
+--- a/drivers/i2c/busses/Makefile
++++ b/drivers/i2c/busses/Makefile
+@@ -33,10 +33,11 @@ obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
+ obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+ obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
+ obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
++obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o
+ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
+-i2c-designware-platform-objs := i2c-designware-platdrv.o i2c-designware-core.o
++i2c-designware-platform-objs := i2c-designware-platdrv.o
+ obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
+-i2c-designware-pci-objs := i2c-designware-pcidrv.o i2c-designware-core.o
++i2c-designware-pci-objs := i2c-designware-pcidrv.o
+ obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
+ obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+ obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
+--- a/drivers/i2c/busses/i2c-designware-core.c
++++ b/drivers/i2c/busses/i2c-designware-core.c
+@@ -25,6 +25,7 @@
+ * ----------------------------------------------------------------------------
+ *
+ */
++#include <linux/export.h>
+ #include <linux/clk.h>
+ #include <linux/errno.h>
+ #include <linux/err.h>
+@@ -316,6 +317,7 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
+ dw_writel(dev, dev->master_cfg , DW_IC_CON);
+ return 0;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_init);
+
+ /*
+ * Waiting for bus not busy
+@@ -568,12 +570,14 @@ done:
+
+ return ret;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_xfer);
+
+ u32 i2c_dw_func(struct i2c_adapter *adap)
+ {
+ struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
+ return dev->functionality;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_func);
+
+ static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
+ {
+@@ -678,17 +682,20 @@ tx_aborted:
+
+ return IRQ_HANDLED;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_isr);
+
+ void i2c_dw_enable(struct dw_i2c_dev *dev)
+ {
+ /* Enable the adapter */
+ dw_writel(dev, 1, DW_IC_ENABLE);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_enable);
+
+ u32 i2c_dw_is_enabled(struct dw_i2c_dev *dev)
+ {
+ return dw_readl(dev, DW_IC_ENABLE);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_is_enabled);
+
+ void i2c_dw_disable(struct dw_i2c_dev *dev)
+ {
+@@ -699,18 +706,22 @@ void i2c_dw_disable(struct dw_i2c_dev *d
+ dw_writel(dev, 0, DW_IC_INTR_MASK);
+ dw_readl(dev, DW_IC_CLR_INTR);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_disable);
+
+ void i2c_dw_clear_int(struct dw_i2c_dev *dev)
+ {
+ dw_readl(dev, DW_IC_CLR_INTR);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_clear_int);
+
+ void i2c_dw_disable_int(struct dw_i2c_dev *dev)
+ {
+ dw_writel(dev, 0, DW_IC_INTR_MASK);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_disable_int);
+
+ u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
+ {
+ return dw_readl(dev, DW_IC_COMP_PARAM_1);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param);
--- /dev/null
+From 4a8f1ddde942e232387e6129ce4f4c412e43802f Mon Sep 17 00:00:00 2001
+From: James Ralston <james.d.ralston@intel.com>
+Date: Mon, 10 Sep 2012 10:14:02 +0200
+Subject: i2c-i801: Add Device IDs for Intel Lynx Point-LP PCH
+
+From: James Ralston <james.d.ralston@intel.com>
+
+commit 4a8f1ddde942e232387e6129ce4f4c412e43802f upstream.
+
+Add the SMBus Device IDs for the Intel Lynx Point-LP PCH.
+
+Signed-off-by: James Ralston <james.d.ralston@intel.com>
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Documentation/i2c/busses/i2c-i801 | 1 +
+ drivers/i2c/busses/Kconfig | 1 +
+ drivers/i2c/busses/i2c-i801.c | 3 +++
+ 3 files changed, 5 insertions(+)
+
+--- a/Documentation/i2c/busses/i2c-i801
++++ b/Documentation/i2c/busses/i2c-i801
+@@ -21,6 +21,7 @@ Supported adapters:
+ * Intel DH89xxCC (PCH)
+ * Intel Panther Point (PCH)
+ * Intel Lynx Point (PCH)
++ * Intel Lynx Point-LP (PCH)
+ Datasheets: Publicly available at the Intel website
+
+ On Intel Patsburg and later chipsets, both the normal host SMBus controller
+--- a/drivers/i2c/busses/Kconfig
++++ b/drivers/i2c/busses/Kconfig
+@@ -104,6 +104,7 @@ config I2C_I801
+ DH89xxCC (PCH)
+ Panther Point (PCH)
+ Lynx Point (PCH)
++ Lynx Point-LP (PCH)
+
+ This driver can also be built as a module. If so, the module
+ will be called i2c-i801.
+--- a/drivers/i2c/busses/i2c-i801.c
++++ b/drivers/i2c/busses/i2c-i801.c
+@@ -52,6 +52,7 @@
+ DH89xxCC (PCH) 0x2330 32 hard yes yes yes
+ Panther Point (PCH) 0x1e22 32 hard yes yes yes
+ Lynx Point (PCH) 0x8c22 32 hard yes yes yes
++ Lynx Point-LP (PCH) 0x9c22 32 hard yes yes yes
+
+ Features supported by this driver:
+ Software PEC no
+@@ -147,6 +148,7 @@
+ #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330
+ #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30
+ #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22
++#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22
+
+ struct i801_priv {
+ struct i2c_adapter adapter;
+@@ -636,6 +638,7 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids)
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) },
++ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS) },
+ { 0, }
+ };
+
--- /dev/null
+From 14216561e164671ce147458653b1fea06a4ada1e Mon Sep 17 00:00:00 2001
+From: James Bottomley <JBottomley@Parallels.com>
+Date: Wed, 25 Jul 2012 23:55:55 +0400
+Subject: SCSI: Fix 'Device not ready' issue on mpt2sas
+
+From: James Bottomley <JBottomley@Parallels.com>
+
+commit 14216561e164671ce147458653b1fea06a4ada1e upstream.
+
+This is a particularly nasty SCSI ATA Translation Layer (SATL) problem.
+
+SAT-2 says (section 8.12.2)
+
+ if the device is in the stopped state as the result of
+ processing a START STOP UNIT command (see 9.11), then the SATL
+ shall terminate the TEST UNIT READY command with CHECK CONDITION
+ status with the sense key set to NOT READY and the additional
+ sense code of LOGICAL UNIT NOT READY, INITIALIZING COMMAND
+ REQUIRED;
+
+mpt2sas internal SATL seems to implement this. The result is very confusing
+standby behaviour (using hdparm -y). If you suspend a drive and then send
+another command, usually it wakes up. However, if the next command is a TEST
+UNIT READY, the SATL sees that the drive is suspended and proceeds to follow
+the SATL rules for this, returning NOT READY to all subsequent commands. This
+means that the ordering of TEST UNIT READY is crucial: if you send TUR and
+then a command, you get a NOT READY to both back. If you send a command and
+then a TUR, you get GOOD status because the preceeding command woke the drive.
+
+This bit us badly because
+
+commit 85ef06d1d252f6a2e73b678591ab71caad4667bb
+Author: Tejun Heo <tj@kernel.org>
+Date: Fri Jul 1 16:17:47 2011 +0200
+
+ block: flush MEDIA_CHANGE from drivers on close(2)
+
+Changed our ordering on TEST UNIT READY commands meaning that SATA drives
+connected to an mpt2sas now suspend and refuse to wake (because the mpt2sas
+SATL sees the suspend *before* the drives get awoken by the next ATA command)
+resulting in lots of failed commands.
+
+The standard is completely nuts forcing this inconsistent behaviour, but we
+have to work around it.
+
+The fix for this is twofold:
+
+ 1. Set the allow_restart flag so we wake the drive when we see it has been
+ suspended
+
+ 2. Return all TEST UNIT READY status directly to the mid layer without any
+ further error handling which prevents us causing error handling which
+ may offline the device just because of a media check TUR.
+
+Reported-by: Matthias Prager <linux@matthiasprager.de>
+Signed-off-by: James Bottomley <JBottomley@Parallels.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/scsi_error.c | 10 ++++++++++
+ drivers/scsi/scsi_scan.c | 10 ++++++++++
+ 2 files changed, 20 insertions(+)
+
+--- a/drivers/scsi/scsi_error.c
++++ b/drivers/scsi/scsi_error.c
+@@ -42,6 +42,8 @@
+
+ #include <trace/events/scsi.h>
+
++static void scsi_eh_done(struct scsi_cmnd *scmd);
++
+ #define SENSE_TIMEOUT (10*HZ)
+
+ /*
+@@ -241,6 +243,14 @@ static int scsi_check_sense(struct scsi_
+ if (! scsi_command_normalize_sense(scmd, &sshdr))
+ return FAILED; /* no valid sense data */
+
++ if (scmd->cmnd[0] == TEST_UNIT_READY && scmd->scsi_done != scsi_eh_done)
++ /*
++ * nasty: for mid-layer issued TURs, we need to return the
++ * actual sense data without any recovery attempt. For eh
++ * issued ones, we need to try to recover and interpret
++ */
++ return SUCCESS;
++
+ if (scsi_sense_is_deferred(&sshdr))
+ return NEEDS_RETRY;
+
+--- a/drivers/scsi/scsi_scan.c
++++ b/drivers/scsi/scsi_scan.c
+@@ -779,6 +779,16 @@ static int scsi_add_lun(struct scsi_devi
+ sdev->model = (char *) (sdev->inquiry + 16);
+ sdev->rev = (char *) (sdev->inquiry + 32);
+
++ if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
++ /*
++ * sata emulation layer device. This is a hack to work around
++ * the SATL power management specifications which state that
++ * when the SATL detects the device has gone into standby
++ * mode, it shall respond with NOT READY.
++ */
++ sdev->allow_restart = 1;
++ }
++
+ if (*bflags & BLIST_ISROM) {
+ sdev->type = TYPE_ROM;
+ sdev->removable = 1;
--- /dev/null
+From bd8d6dd43a77bfd2b8fef5b094b9d6095e169dee Mon Sep 17 00:00:00 2001
+From: Kashyap Desai <Kashyap.Desai@lsi.com>
+Date: Tue, 17 Jul 2012 18:20:44 -0700
+Subject: SCSI: megaraid_sas: Move poll_aen_lock initializer
+
+From: Kashyap Desai <Kashyap.Desai@lsi.com>
+
+commit bd8d6dd43a77bfd2b8fef5b094b9d6095e169dee upstream.
+
+The following patch moves the poll_aen_lock initializer from
+megasas_probe_one() to megasas_init(). This prevents a crash when a user
+loads the driver and tries to issue a poll() system call on the ioctl
+interface with no adapters present.
+
+Signed-off-by: Kashyap Desai <Kashyap.Desai@lsi.com>
+Signed-off-by: Adam Radford <aradford@gmail.com>
+Signed-off-by: James Bottomley <JBottomley@Parallels.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/megaraid/megaraid_sas_base.c
++++ b/drivers/scsi/megaraid/megaraid_sas_base.c
+@@ -4066,7 +4066,6 @@ megasas_probe_one(struct pci_dev *pdev,
+ spin_lock_init(&instance->cmd_pool_lock);
+ spin_lock_init(&instance->hba_lock);
+ spin_lock_init(&instance->completion_lock);
+- spin_lock_init(&poll_aen_lock);
+
+ mutex_init(&instance->aen_mutex);
+ mutex_init(&instance->reset_mutex);
+@@ -5392,6 +5391,8 @@ static int __init megasas_init(void)
+ printk(KERN_INFO "megasas: %s %s\n", MEGASAS_VERSION,
+ MEGASAS_EXT_VERSION);
+
++ spin_lock_init(&poll_aen_lock);
++
+ support_poll_for_event = 2;
+ support_device_change = 1;
+
--- /dev/null
+From 338b131a3269881c7431234855c93c219b0979b6 Mon Sep 17 00:00:00 2001
+From: "sreekanth.reddy@lsi.com" <sreekanth.reddy@lsi.com>
+Date: Tue, 17 Jul 2012 15:57:05 +0530
+Subject: SCSI: mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value
+
+From: "sreekanth.reddy@lsi.com" <sreekanth.reddy@lsi.com>
+
+commit 338b131a3269881c7431234855c93c219b0979b6 upstream.
+
+If the specified max_queue_depth setting is less than the
+expected number of internal commands, then driver will calculate
+the queue depth size to a negitive number. This negitive number
+is actually a very large number because variable is unsigned
+16bit integer. So, the driver will ask for a very large amount of
+memory for message frames and resulting into oops as memory
+allocation routines will not able to handle such a large request.
+
+So, in order to limit this kind of oops, The driver need to set
+the max_queue_depth to a scsi mid layer's can_queue value. Then
+the overall message frames required for IO is minimum of either
+(max_queue_depth plus internal commands) or the IOC global
+credits.
+
+Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
+Signed-off-by: James Bottomley <JBottomley@Parallels.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/mpt2sas/mpt2sas_base.c | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
++++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
+@@ -2424,10 +2424,13 @@ _base_allocate_memory_pools(struct MPT2S
+ }
+
+ /* command line tunables for max controller queue depth */
+- if (max_queue_depth != -1)
+- max_request_credit = (max_queue_depth < facts->RequestCredit)
+- ? max_queue_depth : facts->RequestCredit;
+- else
++ if (max_queue_depth != -1 && max_queue_depth != 0) {
++ max_request_credit = min_t(u16, max_queue_depth +
++ ioc->hi_priority_depth + ioc->internal_depth,
++ facts->RequestCredit);
++ if (max_request_credit > MAX_HBA_QUEUE_DEPTH)
++ max_request_credit = MAX_HBA_QUEUE_DEPTH;
++ } else
+ max_request_credit = min_t(u16, facts->RequestCredit,
+ MAX_HBA_QUEUE_DEPTH);
+
+@@ -2502,7 +2505,7 @@ _base_allocate_memory_pools(struct MPT2S
+ /* set the scsi host can_queue depth
+ * with some internal commands that could be outstanding
+ */
+- ioc->shost->can_queue = ioc->scsiio_depth - (2);
++ ioc->shost->can_queue = ioc->scsiio_depth;
+ dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
+ "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
+
--- /dev/null
+From 27c419739b67decced4650440829b8d51bef954b Mon Sep 17 00:00:00 2001
+From: Mike Snitzer <snitzer@redhat.com>
+Date: Thu, 31 May 2012 15:05:33 -0400
+Subject: SCSI: scsi_lib: fix scsi_io_completion's SG_IO error propagation
+
+From: Mike Snitzer <snitzer@redhat.com>
+
+commit 27c419739b67decced4650440829b8d51bef954b upstream.
+
+The following v3.4-rc1 commit unmasked an existing bug in scsi_io_completion's
+SG_IO error handling: 47ac56d [SCSI] scsi_error: classify some ILLEGAL_REQUEST
+sense as a permanent TARGET_ERROR
+
+Given that certain ILLEGAL_REQUEST are now properly categorized as
+TARGET_ERROR the host_byte is being set (before host_byte wasn't ever
+set for these ILLEGAL_REQUEST).
+
+In scsi_io_completion, initialize req->errors with cmd->result _after_
+the SG_IO block that calls __scsi_error_from_host_byte (which may
+modify the host_byte).
+
+Before this fix:
+
+ cdb to send: 12 01 01 00 00 00
+ioctl(3, SG_IO, {'S', SG_DXFER_NONE, cmd[6]=[12, 01, 01, 00, 00, 00],
+ mx_sb_len=32, iovec_count=0, dxfer_len=0, timeout=20000, flags=0,
+ status=02, masked_status=01, sb[19]=[70, 00, 05, 00, 00, 00, 00, 0b,
+ 00, 00, 00, 00, 24, 00, 00, 00, 00, 00, 00], host_status=0x10,
+ driver_status=0x8, resid=0, duration=0, info=0x1}) = 0
+SCSI Status: Check Condition
+
+Sense Information:
+sense buffer empty
+
+After:
+
+ cdb to send: 12 01 01 00 00 00
+ioctl(3, SG_IO, {'S', SG_DXFER_NONE, cmd[6]=[12, 01, 01, 00, 00, 00],
+ mx_sb_len=32, iovec_count=0, dxfer_len=0, timeout=20000, flags=0,
+ status=02, masked_status=01, sb[19]=[70, 00, 05, 00, 00, 00, 00, 0b,
+ 00, 00, 00, 00, 24, 00, 00, 00, 00, 00, 00], host_status=0,
+ driver_status=0x8, resid=0, duration=0, info=0x1}) = 0
+SCSI Status: Check Condition
+
+Sense Information:
+ Fixed format, current; Sense key: Illegal Request
+ Additional sense: Invalid field in cdb
+ Raw sense data (in hex):
+ 70 00 05 00 00 00 00 0b 00 00 00 00 24 00 00 00
+ 00 00 00
+
+Reported-by: Paolo Bonzini <pbonzini@redhat.com>
+Tested-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Mike Snitzer <snitzer@redhat.com>
+Reviewed-by: Babu Moger <babu.moger@netapp.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: James Bottomley <JBottomley@Parallels.com>
+
+---
+ drivers/scsi/scsi_lib.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/scsi_lib.c
++++ b/drivers/scsi/scsi_lib.c
+@@ -760,7 +760,6 @@ void scsi_io_completion(struct scsi_cmnd
+ }
+
+ if (req->cmd_type == REQ_TYPE_BLOCK_PC) { /* SG_IO ioctl from block level */
+- req->errors = result;
+ if (result) {
+ if (sense_valid && req->sense) {
+ /*
+@@ -776,6 +775,10 @@ void scsi_io_completion(struct scsi_cmnd
+ if (!sense_deferred)
+ error = __scsi_error_from_host_byte(cmd, result);
+ }
++ /*
++ * __scsi_error_from_host_byte may have reset the host_byte
++ */
++ req->errors = cmd->result;
+
+ req->resid_len = scsi_get_resid(cmd);
+
remove-user-triggerable-bug-from-mpol_to_str.patch
fix-order-of-arguments-to-compat_put_time.patch
usbnet-fix-deadlock-in-resume.patch
+scsi-megaraid_sas-move-poll_aen_lock-initializer.patch
+scsi-scsi_lib-fix-scsi_io_completion-s-sg_io-error-propagation.patch
+scsi-mpt2sas-fix-for-driver-oops-when-loading-driver-with-max_queue_depth-command-line-option-to-a-very-small-value.patch
+scsi-fix-device-not-ready-issue-on-mpt2sas.patch
+udf-fix-data-corruption-for-files-in-icb.patch
+ext3-fix-fdatasync-for-files-with-only-i_size-changes.patch
+fuse-fix-retrieve-length.patch
+i2c-designware-fix-build-error-if-config_i2c_designware_platform-y-config_i2c_designware_pci-y.patch
+i2c-i801-add-device-ids-for-intel-lynx-point-lp-pch.patch
--- /dev/null
+From 9c2fc0de1a6e638fe58c354a463f544f42a90a09 Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Wed, 5 Sep 2012 15:48:23 +0200
+Subject: udf: Fix data corruption for files in ICB
+
+From: Jan Kara <jack@suse.cz>
+
+commit 9c2fc0de1a6e638fe58c354a463f544f42a90a09 upstream.
+
+When a file is stored in ICB (inode), we overwrite part of the file, and
+the page containing file's data is not in page cache, we end up corrupting
+file's data by overwriting them with zeros. The problem is we use
+simple_write_begin() which simply zeroes parts of the page which are not
+written to. The problem has been introduced by be021ee4 (udf: convert to
+new aops).
+
+Fix the problem by providing a ->write_begin function which makes the page
+properly uptodate.
+
+Reported-by: Ian Abbott <abbotti@mev.co.uk>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/udf/file.c | 35 +++++++++++++++++++++++++++++------
+ 1 file changed, 29 insertions(+), 6 deletions(-)
+
+--- a/fs/udf/file.c
++++ b/fs/udf/file.c
+@@ -39,20 +39,24 @@
+ #include "udf_i.h"
+ #include "udf_sb.h"
+
+-static int udf_adinicb_readpage(struct file *file, struct page *page)
++static void __udf_adinicb_readpage(struct page *page)
+ {
+ struct inode *inode = page->mapping->host;
+ char *kaddr;
+ struct udf_inode_info *iinfo = UDF_I(inode);
+
+- BUG_ON(!PageLocked(page));
+-
+ kaddr = kmap(page);
+- memset(kaddr, 0, PAGE_CACHE_SIZE);
+ memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);
++ memset(kaddr + inode->i_size, 0, PAGE_CACHE_SIZE - inode->i_size);
+ flush_dcache_page(page);
+ SetPageUptodate(page);
+ kunmap(page);
++}
++
++static int udf_adinicb_readpage(struct file *file, struct page *page)
++{
++ BUG_ON(!PageLocked(page));
++ __udf_adinicb_readpage(page);
+ unlock_page(page);
+
+ return 0;
+@@ -77,6 +81,25 @@ static int udf_adinicb_writepage(struct
+ return 0;
+ }
+
++static int udf_adinicb_write_begin(struct file *file,
++ struct address_space *mapping, loff_t pos,
++ unsigned len, unsigned flags, struct page **pagep,
++ void **fsdata)
++{
++ struct page *page;
++
++ if (WARN_ON_ONCE(pos >= PAGE_CACHE_SIZE))
++ return -EIO;
++ page = grab_cache_page_write_begin(mapping, 0, flags);
++ if (!page)
++ return -ENOMEM;
++ *pagep = page;
++
++ if (!PageUptodate(page) && len != PAGE_CACHE_SIZE)
++ __udf_adinicb_readpage(page);
++ return 0;
++}
++
+ static int udf_adinicb_write_end(struct file *file,
+ struct address_space *mapping,
+ loff_t pos, unsigned len, unsigned copied,
+@@ -98,8 +121,8 @@ static int udf_adinicb_write_end(struct
+ const struct address_space_operations udf_adinicb_aops = {
+ .readpage = udf_adinicb_readpage,
+ .writepage = udf_adinicb_writepage,
+- .write_begin = simple_write_begin,
+- .write_end = udf_adinicb_write_end,
++ .write_begin = udf_adinicb_write_begin,
++ .write_end = udf_adinicb_write_end,
+ };
+
+ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,