--- /dev/null
+From 2fa97feb4406c546b52e35b6b6c50cb8f63425d2 Mon Sep 17 00:00:00 2001
+From: Lan Tianyu <tianyu.lan@intel.com>
+Date: Wed, 5 Jun 2013 02:27:50 +0000
+Subject: ACPI: Add CMOS RTC Operation Region handler support
+
+From: Lan Tianyu <tianyu.lan@intel.com>
+
+commit 2fa97feb4406c546b52e35b6b6c50cb8f63425d2 upstream.
+
+On HP Folio 13-2000, the BIOS defines a CMOS RTC Operation Region and
+the EC's _REG methord accesses that region. Thus an appropriate
+address space handler must be registered for that region before the
+EC driver is loaded.
+
+Introduce a mechanism for adding CMOS RTC address space handlers.
+Register an ACPI scan handler for CMOS RTC devices such that, when
+a device of that kind is detected during an ACPI namespace scan, a
+common CMOS RTC operation region address space handler will be
+installed for it.
+
+References: https://bugzilla.kernel.org/show_bug.cgi?id=54621
+Reported-and-tested-by: Stefan Nagy <public@stefan-nagy.at>
+Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/Makefile | 1
+ drivers/acpi/acpi_cmos_rtc.c | 92 +++++++++++++++++++++++++++++++++++++++++++
+ drivers/acpi/internal.h | 5 ++
+ drivers/acpi/scan.c | 1
+ 4 files changed, 99 insertions(+)
+
+--- a/drivers/acpi/Makefile
++++ b/drivers/acpi/Makefile
+@@ -43,6 +43,7 @@ acpi-y += acpi_platform.o
+ acpi-y += power.o
+ acpi-y += event.o
+ acpi-y += sysfs.o
++acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
+ acpi-$(CONFIG_DEBUG_FS) += debugfs.o
+ acpi-$(CONFIG_ACPI_NUMA) += numa.o
+ acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
+--- /dev/null
++++ b/drivers/acpi/acpi_cmos_rtc.c
+@@ -0,0 +1,92 @@
++/*
++ * ACPI support for CMOS RTC Address Space access
++ *
++ * Copyright (C) 2013, Intel Corporation
++ * Authors: Lan Tianyu <tianyu.lan@intel.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ */
++
++#include <linux/acpi.h>
++#include <linux/device.h>
++#include <linux/err.h>
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <asm-generic/rtc.h>
++
++#include "internal.h"
++
++#define PREFIX "ACPI: "
++
++ACPI_MODULE_NAME("cmos rtc");
++
++static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
++ { "PNP0B00" },
++ { "PNP0B01" },
++ { "PNP0B02" },
++ {}
++};
++
++static acpi_status
++acpi_cmos_rtc_space_handler(u32 function, acpi_physical_address address,
++ u32 bits, u64 *value64,
++ void *handler_context, void *region_context)
++{
++ int i;
++ u8 *value = (u8 *)&value64;
++
++ if (address > 0xff || !value64)
++ return AE_BAD_PARAMETER;
++
++ if (function != ACPI_WRITE && function != ACPI_READ)
++ return AE_BAD_PARAMETER;
++
++ spin_lock_irq(&rtc_lock);
++
++ for (i = 0; i < DIV_ROUND_UP(bits, 8); ++i, ++address, ++value)
++ if (function == ACPI_READ)
++ *value = CMOS_READ(address);
++ else
++ CMOS_WRITE(*value, address);
++
++ spin_unlock_irq(&rtc_lock);
++
++ return AE_OK;
++}
++
++static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,
++ const struct acpi_device_id *id)
++{
++ acpi_status status;
++
++ status = acpi_install_address_space_handler(adev->handle,
++ ACPI_ADR_SPACE_CMOS,
++ &acpi_cmos_rtc_space_handler,
++ NULL, NULL);
++ if (ACPI_FAILURE(status)) {
++ pr_err(PREFIX "Error installing CMOS-RTC region handler\n");
++ return -ENODEV;
++ }
++
++ return 0;
++}
++
++static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev)
++{
++ if (ACPI_FAILURE(acpi_remove_address_space_handler(adev->handle,
++ ACPI_ADR_SPACE_CMOS, &acpi_cmos_rtc_space_handler)))
++ pr_err(PREFIX "Error removing CMOS-RTC region handler\n");
++}
++
++static struct acpi_scan_handler cmos_rtc_handler = {
++ .ids = acpi_cmos_rtc_ids,
++ .attach = acpi_install_cmos_rtc_space_handler,
++ .detach = acpi_remove_cmos_rtc_space_handler,
++};
++
++void __init acpi_cmos_rtc_init(void)
++{
++ acpi_scan_add_handler(&cmos_rtc_handler);
++}
+--- a/drivers/acpi/internal.h
++++ b/drivers/acpi/internal.h
+@@ -50,6 +50,11 @@ void acpi_memory_hotplug_init(void);
+ #else
+ static inline void acpi_memory_hotplug_init(void) {}
+ #endif
++#ifdef CONFIG_X86
++void acpi_cmos_rtc_init(void);
++#else
++static inline void acpi_cmos_rtc_init(void) {}
++#endif
+
+ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
+ const char *name);
+--- a/drivers/acpi/scan.c
++++ b/drivers/acpi/scan.c
+@@ -2040,6 +2040,7 @@ int __init acpi_scan_init(void)
+ acpi_pci_link_init();
+ acpi_platform_init();
+ acpi_lpss_init();
++ acpi_cmos_rtc_init();
+ acpi_container_init();
+ acpi_memory_hotplug_init();
+ acpi_dock_init();
--- /dev/null
+From eff9a4b62b14cf0d9913e3caf1f26f8b7a6105c9 Mon Sep 17 00:00:00 2001
+From: Lan Tianyu <tianyu.lan@intel.com>
+Date: Wed, 5 Jun 2013 02:27:51 +0000
+Subject: ACPI / EC: Add HP Folio 13 to ec_dmi_table in order to skip DSDT scan
+
+From: Lan Tianyu <tianyu.lan@intel.com>
+
+commit eff9a4b62b14cf0d9913e3caf1f26f8b7a6105c9 upstream.
+
+HP Folio 13's BIOS defines CMOS RTC Operation Region and the EC's
+_REG method will access that region. To allow the CMOS RTC region
+handler to be installed before the EC _REG method is first invoked,
+add ec_skip_dsdt_scan() as HP Folio 13's callback to ec_dmi_table.
+
+References: https://bugzilla.kernel.org/show_bug.cgi?id=54621
+Reported-and-tested-by: Stefan Nagy <public@stefan-nagy.at>
+Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/ec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/acpi/ec.c
++++ b/drivers/acpi/ec.c
+@@ -983,6 +983,10 @@ static struct dmi_system_id __initdata e
+ ec_enlarge_storm_threshold, "CLEVO hardware", {
+ DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL},
++ {
++ ec_skip_dsdt_scan, "HP Folio 13", {
++ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
++ DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13"),}, NULL},
+ {},
+ };
+
--- /dev/null
+From 91bdad0b6237c25a7bf8fd4604d0cc64a2005a23 Mon Sep 17 00:00:00 2001
+From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
+Date: Thu, 4 Jul 2013 13:22:11 +0200
+Subject: ACPI / PM: Fix corner case in acpi_bus_update_power()
+
+From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
+
+commit 91bdad0b6237c25a7bf8fd4604d0cc64a2005a23 upstream.
+
+The role of acpi_bus_update_power() is to update the given ACPI
+device object's power.state field to reflect the current physical
+state of the device (as inferred from the configuration of power
+resources and _PSC, if available). For this purpose it calls
+acpi_device_set_power() that should update the power resources'
+reference counters and set power.state as appropriate. However,
+that doesn't work if the "new" state is D1, D2 or D3hot and the
+the current value of power.state means D3cold, because in that
+case acpi_device_set_power() will refuse to transition the device
+from D3cold to non-D0.
+
+To address this problem, make acpi_bus_update_power() call
+acpi_power_transition() directly to update the power resources'
+reference counters and only use acpi_device_set_power() to put
+the device into D0 if the current physical state of it cannot
+be determined.
+
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/device_pm.c | 23 ++++++++++++++++++-----
+ 1 file changed, 18 insertions(+), 5 deletions(-)
+
+--- a/drivers/acpi/device_pm.c
++++ b/drivers/acpi/device_pm.c
+@@ -324,14 +324,27 @@ int acpi_bus_update_power(acpi_handle ha
+ if (result)
+ return result;
+
+- if (state == ACPI_STATE_UNKNOWN)
++ if (state == ACPI_STATE_UNKNOWN) {
+ state = ACPI_STATE_D0;
+-
+- result = acpi_device_set_power(device, state);
+- if (!result && state_p)
++ result = acpi_device_set_power(device, state);
++ if (result)
++ return result;
++ } else {
++ if (device->power.flags.power_resources) {
++ /*
++ * We don't need to really switch the state, bu we need
++ * to update the power resources' reference counters.
++ */
++ result = acpi_power_transition(device, state);
++ if (result)
++ return result;
++ }
++ device->power.state = state;
++ }
++ if (state_p)
+ *state_p = state;
+
+- return result;
++ return 0;
+ }
+ EXPORT_SYMBOL_GPL(acpi_bus_update_power);
+
--- /dev/null
+From 7cec7048fe22e3e92389da2cd67098f6c4284e7f Mon Sep 17 00:00:00 2001
+From: Lv Zheng <lv.zheng@intel.com>
+Date: Sat, 8 Jun 2013 00:59:18 +0000
+Subject: ACPICA: Do not use extended sleep registers unless HW-reduced bit is set
+
+From: Lv Zheng <lv.zheng@intel.com>
+
+commit 7cec7048fe22e3e92389da2cd67098f6c4284e7f upstream.
+
+Previous implementation incorrectly used the ACPI 5.0 extended
+sleep registers if they were simply populated. This caused
+problems on some non-HW-reduced machines. As per the ACPI spec,
+they should only be used if the HW-reduced bit is set. Lv Zheng,
+ACPICA BZ 1020.
+
+References: https://bugzilla.kernel.org/show_bug.cgi?id=54181
+References: https://bugs.acpica.org/show_bug.cgi?id=1020
+Reported-by: Daniel Rowe <bart@fathom13.com>
+Bisected-by: Brint E. Kriebel <kernel@bekit.net>
+Signed-off-by: Lv Zheng <lv.zheng@intel.com>
+Signed-off-by: Bob Moore <robert.moore@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/acpica/hwxfsleep.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/drivers/acpi/acpica/hwxfsleep.c
++++ b/drivers/acpi/acpica/hwxfsleep.c
+@@ -240,12 +240,14 @@ static acpi_status acpi_hw_sleep_dispatc
+ &acpi_sleep_dispatch[function_id];
+
+ #if (!ACPI_REDUCED_HARDWARE)
+-
+ /*
+ * If the Hardware Reduced flag is set (from the FADT), we must
+- * use the extended sleep registers
++ * use the extended sleep registers (FADT). Note: As per the ACPI
++ * specification, these extended registers are to be used for HW-reduced
++ * platforms only. They are not general-purpose replacements for the
++ * legacy PM register sleep support.
+ */
+- if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
++ if (acpi_gbl_reduced_hardware) {
+ status = sleep_functions->extended_function(sleep_state);
+ } else {
+ /* Legacy sleep */
--- /dev/null
+From fafe5c3d82a470d73de53e6b08eb4e28d974d895 Mon Sep 17 00:00:00 2001
+From: Shane Huang <shane.huang@amd.com>
+Date: Mon, 3 Jun 2013 18:24:10 +0800
+Subject: ahci: Add AMD CZ SATA device ID
+
+From: Shane Huang <shane.huang@amd.com>
+
+commit fafe5c3d82a470d73de53e6b08eb4e28d974d895 upstream.
+
+To add AMD CZ SATA controller device ID of IDE mode.
+
+[bhelgaas: drop pci_ids.h update]
+Signed-off-by: Shane Huang <shane.huang@amd.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Reviewed-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/ahci.c | 1 +
+ drivers/pci/quirks.c | 2 ++
+ 2 files changed, 3 insertions(+)
+
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -310,6 +310,7 @@ static const struct pci_device_id ahci_p
+
+ /* AMD */
+ { PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD Hudson-2 */
++ { PCI_VDEVICE(AMD, 0x7900), board_ahci }, /* AMD CZ */
+ /* AMD is using RAID class only for ahci controllers */
+ { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+ PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci },
+--- a/drivers/pci/quirks.c
++++ b/drivers/pci/quirks.c
+@@ -1022,6 +1022,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_A
+ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
+ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode);
++DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode);
+
+ /*
+ * Serverworks CSB5 IDE does not fully support native mode
--- /dev/null
+From 1cfc7df3de10c40ed459e13cce6de616023bf41c Mon Sep 17 00:00:00 2001
+From: Seth Heasley <seth.heasley@intel.com>
+Date: Wed, 19 Jun 2013 16:36:45 -0700
+Subject: ahci: AHCI-mode SATA patch for Intel Coleto Creek DeviceIDs
+
+From: Seth Heasley <seth.heasley@intel.com>
+
+commit 1cfc7df3de10c40ed459e13cce6de616023bf41c upstream.
+
+This patch adds the AHCI-mode SATA DeviceIDs for the Intel Coleto Creek PCH.
+
+Signed-off-by: Seth Heasley <seth.heasley@intel.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/ahci.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -291,6 +291,7 @@ static const struct pci_device_id ahci_p
+ { PCI_VDEVICE(INTEL, 0x8d64), board_ahci }, /* Wellsburg RAID */
+ { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */
+ { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */
++ { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */
+
+ /* JMicron 360/1/3/5/6, match class to avoid IDE function */
+ { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
--- /dev/null
+From 912b9ac683b112615d5605686f1dc086402ce9f7 Mon Sep 17 00:00:00 2001
+From: Shane Huang <shane.huang@amd.com>
+Date: Sat, 8 Jun 2013 16:00:16 +0800
+Subject: ahci: remove pmp link online check in FBS EH
+
+From: Shane Huang <shane.huang@amd.com>
+
+commit 912b9ac683b112615d5605686f1dc086402ce9f7 upstream.
+
+ata_link_online() check in ahci_error_intr() is unnecessary, it should
+be removed otherwise may lead to lockup with FBS enabled PMP.
+http://marc.info/?l=linux-ide&m=137050421603272&w=2
+
+Reported-by: Yu Liu <liuyu.ac@gmail.com>
+Signed-off-by: Shane Huang <shane.huang@amd.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/libahci.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/ata/libahci.c
++++ b/drivers/ata/libahci.c
+@@ -1560,8 +1560,7 @@ static void ahci_error_intr(struct ata_p
+ u32 fbs = readl(port_mmio + PORT_FBS);
+ int pmp = fbs >> PORT_FBS_DWE_OFFSET;
+
+- if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links) &&
+- ata_link_online(&ap->pmp_link[pmp])) {
++ if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links)) {
+ link = &ap->pmp_link[pmp];
+ fbs_need_dec = true;
+ }
--- /dev/null
+From fe74650166dd6905b0cf66594eb79222dc9d7109 Mon Sep 17 00:00:00 2001
+From: Chen Gang <gang.chen@asianux.com>
+Date: Wed, 3 Jul 2013 15:00:42 -0700
+Subject: arch: c6x: mm: include "asm/uaccess.h" to pass compiling
+
+From: Chen Gang <gang.chen@asianux.com>
+
+commit fe74650166dd6905b0cf66594eb79222dc9d7109 upstream.
+
+Need include "asm/uaccess.h" to pass compiling.
+
+The related error (with allmodconfig):
+
+ arch/c6x/mm/init.c: In function `paging_init':
+ arch/c6x/mm/init.c:46:2: error: implicit declaration of function `set_fs' [-Werror=implicit-function-declaration]
+ arch/c6x/mm/init.c:46:9: error: `KERNEL_DS' undeclared (first use in this function)
+ arch/c6x/mm/init.c:46:9: note: each undeclared identifier is reported only once for each function it appears in
+
+Signed-off-by: Chen Gang <gang.chen@asianux.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/c6x/mm/init.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/c6x/mm/init.c
++++ b/arch/c6x/mm/init.c
+@@ -18,6 +18,7 @@
+ #include <linux/initrd.h>
+
+ #include <asm/sections.h>
++#include <asm/uaccess.h>
+
+ /*
+ * ZERO_PAGE is a special page that is used for zero-initialized
--- /dev/null
+From 139f807a1eba1e484941a98fb93ee32ad859a6a1 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <jbacik@fusionio.com>
+Date: Mon, 20 May 2013 11:26:50 -0400
+Subject: Btrfs: fix estale with btrfs send
+
+From: Josef Bacik <jbacik@fusionio.com>
+
+commit 139f807a1eba1e484941a98fb93ee32ad859a6a1 upstream.
+
+This fixes bugzilla 57491. If we take a snapshot of a fs with a unlink ongoing
+and then try to send that root we will run into problems. When comparing with a
+parent root we will search the parents and the send roots commit_root, which if
+we've just created the snapshot will include the file that needs to be evicted
+by the orphan cleanup. So when we find a changed extent we will try and copy
+that info into the send stream, but when we lookup the inode we use the normal
+root, which no longer has the inode because the orphan cleanup deleted it. The
+best solution I have for this is to check our otransid with the generation of
+the commit root and if they match just commit the transaction again, that way we
+get the changes from the orphan cleanup. With this patch the reproducer I made
+for this bugzilla no longer returns ESTALE when trying to do the send. Thanks,
+
+Reported-by: Chris Wilson <jakdaw@gmail.com>
+Signed-off-by: Josef Bacik <jbacik@fusionio.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/send.c | 35 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 35 insertions(+)
+
+--- a/fs/btrfs/send.c
++++ b/fs/btrfs/send.c
+@@ -4579,6 +4579,41 @@ long btrfs_ioctl_send(struct file *mnt_f
+ send_root = BTRFS_I(file_inode(mnt_file))->root;
+ fs_info = send_root->fs_info;
+
++ /*
++ * This is done when we lookup the root, it should already be complete
++ * by the time we get here.
++ */
++ WARN_ON(send_root->orphan_cleanup_state != ORPHAN_CLEANUP_DONE);
++
++ /*
++ * If we just created this root we need to make sure that the orphan
++ * cleanup has been done and committed since we search the commit root,
++ * so check its commit root transid with our otransid and if they match
++ * commit the transaction to make sure everything is updated.
++ */
++ down_read(&send_root->fs_info->extent_commit_sem);
++ if (btrfs_header_generation(send_root->commit_root) ==
++ btrfs_root_otransid(&send_root->root_item)) {
++ struct btrfs_trans_handle *trans;
++
++ up_read(&send_root->fs_info->extent_commit_sem);
++
++ trans = btrfs_attach_transaction_barrier(send_root);
++ if (IS_ERR(trans)) {
++ if (PTR_ERR(trans) != -ENOENT) {
++ ret = PTR_ERR(trans);
++ goto out;
++ }
++ /* ENOENT means theres no transaction */
++ } else {
++ ret = btrfs_commit_transaction(trans, send_root);
++ if (ret)
++ goto out;
++ }
++ } else {
++ up_read(&send_root->fs_info->extent_commit_sem);
++ }
++
+ arg = memdup_user(arg_, sizeof(*arg));
+ if (IS_ERR(arg)) {
+ ret = PTR_ERR(arg);
--- /dev/null
+From f1ca7e98a67da618d8595866e0860308525154da Mon Sep 17 00:00:00 2001
+From: Josef Bacik <jbacik@fusionio.com>
+Date: Sat, 29 Jun 2013 23:15:19 -0400
+Subject: Btrfs: hold the tree mod lock in __tree_mod_log_rewind
+
+From: Josef Bacik <jbacik@fusionio.com>
+
+commit f1ca7e98a67da618d8595866e0860308525154da upstream.
+
+We need to hold the tree mod log lock in __tree_mod_log_rewind since we walk
+forward in the tree mod entries, otherwise we'll end up with random entries and
+trip the BUG_ON() at the front of __tree_mod_log_rewind. This fixes the panics
+people were seeing when running
+
+find /whatever -type f -exec btrfs fi defrag {} \;
+
+Thansk,
+
+Signed-off-by: Josef Bacik <jbacik@fusionio.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/ctree.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+--- a/fs/btrfs/ctree.c
++++ b/fs/btrfs/ctree.c
+@@ -1161,8 +1161,8 @@ __tree_mod_log_oldest_root(struct btrfs_
+ * time_seq).
+ */
+ static void
+-__tree_mod_log_rewind(struct extent_buffer *eb, u64 time_seq,
+- struct tree_mod_elem *first_tm)
++__tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
++ u64 time_seq, struct tree_mod_elem *first_tm)
+ {
+ u32 n;
+ struct rb_node *next;
+@@ -1172,6 +1172,7 @@ __tree_mod_log_rewind(struct extent_buff
+ unsigned long p_size = sizeof(struct btrfs_key_ptr);
+
+ n = btrfs_header_nritems(eb);
++ tree_mod_log_read_lock(fs_info);
+ while (tm && tm->seq >= time_seq) {
+ /*
+ * all the operations are recorded with the operator used for
+@@ -1226,6 +1227,7 @@ __tree_mod_log_rewind(struct extent_buff
+ if (tm->index != first_tm->index)
+ break;
+ }
++ tree_mod_log_read_unlock(fs_info);
+ btrfs_set_header_nritems(eb, n);
+ }
+
+@@ -1274,7 +1276,7 @@ tree_mod_log_rewind(struct btrfs_fs_info
+
+ extent_buffer_get(eb_rewin);
+ btrfs_tree_read_lock(eb_rewin);
+- __tree_mod_log_rewind(eb_rewin, time_seq, tm);
++ __tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm);
+ WARN_ON(btrfs_header_nritems(eb_rewin) >
+ BTRFS_NODEPTRS_PER_BLOCK(fs_info->tree_root));
+
+@@ -1350,7 +1352,7 @@ get_old_root(struct btrfs_root *root, u6
+ btrfs_set_header_generation(eb, old_generation);
+ }
+ if (tm)
+- __tree_mod_log_rewind(eb, time_seq, tm);
++ __tree_mod_log_rewind(root->fs_info, eb, time_seq, tm);
+ else
+ WARN_ON(btrfs_header_level(eb) != 0);
+ WARN_ON(btrfs_header_nritems(eb) > BTRFS_NODEPTRS_PER_BLOCK(root));
--- /dev/null
+From 7fb7d76f96bfcbea25007d190ba828b18e13d29d Mon Sep 17 00:00:00 2001
+From: Josef Bacik <jbacik@fusionio.com>
+Date: Mon, 1 Jul 2013 16:10:16 -0400
+Subject: Btrfs: only do the tree_mod_log_free_eb if this is our last
+ ref
+
+From: Josef Bacik <jbacik@fusionio.com>
+
+commit 7fb7d76f96bfcbea25007d190ba828b18e13d29d upstream.
+
+There is another bug in the tree mod log stuff in that we're calling
+tree_mod_log_free_eb every single time a block is cow'ed. The problem with this
+is that if this block is shared by multiple snapshots we will call this multiple
+times per block, so if we go to rewind the mod log for this block we'll BUG_ON()
+in __tree_mod_log_rewind because we try to rewind a free twice. We only want to
+call tree_mod_log_free_eb if we are actually freeing the block. With this patch
+I no longer hit the panic in __tree_mod_log_rewind. Thanks,
+
+Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
+Signed-off-by: Josef Bacik <jbacik@fusionio.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/ctree.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/fs/btrfs/ctree.c
++++ b/fs/btrfs/ctree.c
+@@ -1089,7 +1089,8 @@ static noinline int __btrfs_cow_block(st
+ btrfs_set_node_ptr_generation(parent, parent_slot,
+ trans->transid);
+ btrfs_mark_buffer_dirty(parent);
+- tree_mod_log_free_eb(root->fs_info, buf);
++ if (last_ref)
++ tree_mod_log_free_eb(root->fs_info, buf);
+ btrfs_free_tree_block(trans, root, buf, parent_start,
+ last_ref);
+ }
--- /dev/null
+From 29ecd78c0fd6ee05f2c6b07b23823a6ae43c13ff Mon Sep 17 00:00:00 2001
+From: Axel Lin <axel.lin@ingics.com>
+Date: Wed, 3 Jul 2013 15:06:45 -0700
+Subject: drivers/rtc/rtc-rv3029c2.c: fix disabling AIE irq
+
+From: Axel Lin <axel.lin@ingics.com>
+
+commit 29ecd78c0fd6ee05f2c6b07b23823a6ae43c13ff upstream.
+
+In the disable AIE irq code path, current code passes "1" to enable
+parameter of rv3029c2_rtc_i2c_alarm_set_irq(). Thus it does not disable
+AIE irq.
+
+Signed-off-by: Axel Lin <axel.lin@ingics.com>
+Acked-by: Heiko Schocher <hs@denx.de>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/rtc/rtc-rv3029c2.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/rtc/rtc-rv3029c2.c
++++ b/drivers/rtc/rtc-rv3029c2.c
+@@ -310,7 +310,7 @@ static int rv3029c2_rtc_i2c_set_alarm(st
+ dev_dbg(&client->dev, "alarm IRQ armed\n");
+ } else {
+ /* disable AIE irq */
+- ret = rv3029c2_rtc_i2c_alarm_set_irq(client, 1);
++ ret = rv3029c2_rtc_i2c_alarm_set_irq(client, 0);
+ if (ret)
+ return ret;
+
--- /dev/null
+From 2779db8d37d4b542d9ca2575f5f178dbeaca6c86 Mon Sep 17 00:00:00 2001
+From: Ben Hutchings <ben@decadent.org.uk>
+Date: Fri, 28 Jun 2013 02:40:30 +0100
+Subject: genirq: Fix can_request_irq() for IRQs without an action
+
+From: Ben Hutchings <ben@decadent.org.uk>
+
+commit 2779db8d37d4b542d9ca2575f5f178dbeaca6c86 upstream.
+
+Commit 02725e7471b8 ('genirq: Use irq_get/put functions'),
+inadvertently changed can_request_irq() to return 0 for IRQs that have
+no action. This causes pcibios_lookup_irq() to select only IRQs that
+already have an action with IRQF_SHARED set, or to fail if there are
+none. Change can_request_irq() to return 1 for IRQs that have no
+action (if the first two conditions are met).
+
+Reported-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
+Tested-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is> (against 3.2)
+Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
+Cc: 709647@bugs.debian.org
+Link: http://bugs.debian.org/709647
+Link: http://lkml.kernel.org/r/1372383630.23847.40.camel@deadeye.wl.decadent.org.uk
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/irq/manage.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/kernel/irq/manage.c
++++ b/kernel/irq/manage.c
+@@ -555,9 +555,9 @@ int can_request_irq(unsigned int irq, un
+ return 0;
+
+ if (irq_settings_can_request(desc)) {
+- if (desc->action)
+- if (irqflags & desc->action->flags & IRQF_SHARED)
+- canrequest =1;
++ if (!desc->action ||
++ irqflags & desc->action->flags & IRQF_SHARED)
++ canrequest = 1;
+ }
+ irq_put_desc_unlock(desc, flags);
+ return canrequest;
--- /dev/null
+From 9d9a04ee758b4c1fcc7586d065cdde7a7607e156 Mon Sep 17 00:00:00 2001
+From: Dmitry Torokhov <rydberg@euromail.se>
+Date: Mon, 1 Jul 2013 11:46:27 -0700
+Subject: HID: apple: Add support for the 2013 Macbook Air
+
+From: Dmitry Torokhov <rydberg@euromail.se>
+
+commit 9d9a04ee758b4c1fcc7586d065cdde7a7607e156 upstream.
+
+This patch adds keyboard support for MacbookAir6,2 as WELLSPRING8
+(0x0291, 0x0292, 0x0293). The touchpad is handled in a separate
+bcm5974 patch, as usual.
+
+Reported-and-tested-by: Brad Ford <plymouthffl@gmail.com>
+Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/hid/hid-apple.c | 6 ++++++
+ drivers/hid/hid-core.c | 6 ++++++
+ drivers/hid/hid-ids.h | 3 +++
+ 3 files changed, 15 insertions(+)
+
+--- a/drivers/hid/hid-apple.c
++++ b/drivers/hid/hid-apple.c
+@@ -524,6 +524,12 @@ static const struct hid_device_id apple_
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
+ .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
++ .driver_data = APPLE_HAS_FN },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
++ .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
++ .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
+ .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
+--- a/drivers/hid/hid-core.c
++++ b/drivers/hid/hid-core.c
+@@ -1547,6 +1547,9 @@ static const struct hid_device_id hid_ha
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
+@@ -2179,6 +2182,9 @@ static const struct hid_device_id hid_mo
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
+ { }
+--- a/drivers/hid/hid-ids.h
++++ b/drivers/hid/hid-ids.h
+@@ -135,6 +135,9 @@
+ #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
+ #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255
+ #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
++#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0291
++#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0292
++#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0293
+ #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
+ #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
+ #define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
--- /dev/null
+From 148c1c8ad3c4170186ebe6ea5900adde27d2a0e7 Mon Sep 17 00:00:00 2001
+From: Dmitry Torokhov <rydberg@euromail.se>
+Date: Mon, 1 Jul 2013 11:47:51 -0700
+Subject: Input: bcm5974 - add support for the 2013 MacBook Air
+
+From: Dmitry Torokhov <rydberg@euromail.se>
+
+commit 148c1c8ad3c4170186ebe6ea5900adde27d2a0e7 upstream.
+
+The June 2013 Macbook Air (13'') has a new trackpad protocol; four new
+values are inserted in the header, and the mode switch is no longer
+needed. This patch adds support for the new devices.
+
+Reported-and-tested-by: Brad Ford <plymouthffl@gmail.com>
+Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/input/mouse/bcm5974.c | 36 ++++++++++++++++++++++++++++++++++--
+ 1 file changed, 34 insertions(+), 2 deletions(-)
+
+--- a/drivers/input/mouse/bcm5974.c
++++ b/drivers/input/mouse/bcm5974.c
+@@ -88,6 +88,10 @@
+ #define USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI 0x0259
+ #define USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO 0x025a
+ #define USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS 0x025b
++/* MacbookAir6,2 (unibody, June 2013) */
++#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0291
++#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0292
++#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0293
+
+ #define BCM5974_DEVICE(prod) { \
+ .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
+@@ -145,6 +149,10 @@ static const struct usb_device_id bcm597
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
++ /* MacbookAir6,2 */
++ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
++ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
++ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
+ /* Terminating entry */
+ {}
+ };
+@@ -172,15 +180,18 @@ struct bt_data {
+ /* trackpad header types */
+ enum tp_type {
+ TYPE1, /* plain trackpad */
+- TYPE2 /* button integrated in trackpad */
++ TYPE2, /* button integrated in trackpad */
++ TYPE3 /* additional header fields since June 2013 */
+ };
+
+ /* trackpad finger data offsets, le16-aligned */
+ #define FINGER_TYPE1 (13 * sizeof(__le16))
+ #define FINGER_TYPE2 (15 * sizeof(__le16))
++#define FINGER_TYPE3 (19 * sizeof(__le16))
+
+ /* trackpad button data offsets */
+ #define BUTTON_TYPE2 15
++#define BUTTON_TYPE3 23
+
+ /* list of device capability bits */
+ #define HAS_INTEGRATED_BUTTON 1
+@@ -400,6 +411,19 @@ static const struct bcm5974_config bcm59
+ { SN_COORD, -150, 6730 },
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
+ },
++ {
++ USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI,
++ USB_DEVICE_ID_APPLE_WELLSPRING8_ISO,
++ USB_DEVICE_ID_APPLE_WELLSPRING8_JIS,
++ HAS_INTEGRATED_BUTTON,
++ 0, sizeof(struct bt_data),
++ 0x83, TYPE3, FINGER_TYPE3, FINGER_TYPE3 + SIZEOF_ALL_FINGERS,
++ { SN_PRESSURE, 0, 300 },
++ { SN_WIDTH, 0, 2048 },
++ { SN_COORD, -4620, 5140 },
++ { SN_COORD, -150, 6600 },
++ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
++ },
+ {}
+ };
+
+@@ -557,6 +581,9 @@ static int report_tp_state(struct bcm597
+ input_report_key(input, BTN_LEFT, ibt);
+ }
+
++ if (c->tp_type == TYPE3)
++ input_report_key(input, BTN_LEFT, dev->tp_data[BUTTON_TYPE3]);
++
+ input_sync(input);
+
+ return 0;
+@@ -572,9 +599,14 @@ static int report_tp_state(struct bcm597
+
+ static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on)
+ {
+- char *data = kmalloc(8, GFP_KERNEL);
+ int retval = 0, size;
++ char *data;
++
++ /* Type 3 does not require a mode switch */
++ if (dev->cfg.tp_type == TYPE3)
++ return 0;
+
++ data = kmalloc(8, GFP_KERNEL);
+ if (!data) {
+ dev_err(&dev->intf->dev, "out of memory\n");
+ retval = -ENOMEM;
--- /dev/null
+From b967613d7e7c7bad176f5627c55e2d8c5aa2480e Mon Sep 17 00:00:00 2001
+From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Date: Thu, 13 Jun 2013 11:45:59 +0300
+Subject: iwlwifi: pcie: fix race in queue unmapping
+
+From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+
+commit b967613d7e7c7bad176f5627c55e2d8c5aa2480e upstream.
+
+When a queue is disabled, it frees all its entries. Later,
+the op_mode might still get notifications from the firmware
+that triggers to free entries in the tx queue. The transport
+should be prepared for these races and know to ignore
+reclaim calls on queues that have been disabled and whose
+entries have been freed.
+
+Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/iwlwifi/pcie/tx.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/net/wireless/iwlwifi/pcie/tx.c
++++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
+@@ -576,9 +576,12 @@ static void iwl_pcie_txq_unmap(struct iw
+
+ spin_lock_bh(&txq->lock);
+ while (q->write_ptr != q->read_ptr) {
++ IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n",
++ txq_id, q->read_ptr);
+ iwl_pcie_txq_free_tfd(trans, txq);
+ q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
+ }
++ txq->active = false;
+ spin_unlock_bh(&txq->lock);
+ }
+
+@@ -927,6 +930,12 @@ void iwl_trans_pcie_reclaim(struct iwl_t
+
+ spin_lock_bh(&txq->lock);
+
++ if (!txq->active) {
++ IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n",
++ txq_id, ssn);
++ goto out;
++ }
++
+ if (txq->q.read_ptr == tfd_num)
+ goto out;
+
+@@ -1103,6 +1112,7 @@ void iwl_trans_pcie_txq_enable(struct iw
+ (fifo << SCD_QUEUE_STTS_REG_POS_TXF) |
+ (1 << SCD_QUEUE_STTS_REG_POS_WSL) |
+ SCD_QUEUE_STTS_REG_MSK);
++ trans_pcie->txq[txq_id].active = true;
+ IWL_DEBUG_TX_QUEUES(trans, "Activate queue %d on FIFO %d WrPtr: %d\n",
+ txq_id, fifo, ssn & 0xff);
+ }
--- /dev/null
+From 8a487b1a7432b20ff3f82387a8ce7555a964b44e Mon Sep 17 00:00:00 2001
+From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Date: Thu, 13 Jun 2013 13:10:00 +0300
+Subject: iwlwifi: pcie: wake the queue if stopped when being unmapped
+
+From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+
+commit 8a487b1a7432b20ff3f82387a8ce7555a964b44e upstream.
+
+When the queue is unmapped while it was so loaded that
+mac80211's was stopped, we need to wake the queue after
+having freed all the packets in the queue.
+Not doing so can result in weird stuff like:
+
+* run lots of traffic (mac80211's queue gets stopped)
+* RFKILL
+* de-assert RFKILL
+* no traffic
+
+Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/iwlwifi/pcie/tx.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/wireless/iwlwifi/pcie/tx.c
++++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
+@@ -583,6 +583,9 @@ static void iwl_pcie_txq_unmap(struct iw
+ }
+ txq->active = false;
+ spin_unlock_bh(&txq->lock);
++
++ /* just in case - this queue may have been stopped */
++ iwl_wake_queue(trans, txq);
+ }
+
+ /*
--- /dev/null
+From c378f70adbc1bbecd9e6db145019f14b2f688c7c Mon Sep 17 00:00:00 2001
+From: Paul Clements <paul.clements@steeleye.com>
+Date: Wed, 3 Jul 2013 15:09:04 -0700
+Subject: nbd: correct disconnect behavior
+
+From: Paul Clements <paul.clements@steeleye.com>
+
+commit c378f70adbc1bbecd9e6db145019f14b2f688c7c upstream.
+
+Currently, when a disconnect is requested by the user (via NBD_DISCONNECT
+ioctl) the return from NBD_DO_IT is undefined (it is usually one of
+several error codes). This means that nbd-client does not know if a
+manual disconnect was performed or whether a network error occurred.
+Because of this, nbd-client's persist mode (which tries to reconnect after
+error, but not after manual disconnect) does not always work correctly.
+
+This change fixes this by causing NBD_DO_IT to always return 0 if a user
+requests a disconnect. This means that nbd-client can correctly either
+persist the connection (if an error occurred) or disconnect (if the user
+requested it).
+
+Signed-off-by: Paul Clements <paul.clements@steeleye.com>
+Acked-by: Rob Landley <rob@landley.net>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/block/nbd.c | 7 ++++++-
+ include/linux/nbd.h | 1 +
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+--- a/drivers/block/nbd.c
++++ b/drivers/block/nbd.c
+@@ -623,8 +623,10 @@ static int __nbd_ioctl(struct block_devi
+ if (!nbd->sock)
+ return -EINVAL;
+
++ nbd->disconnect = 1;
++
+ nbd_send_req(nbd, &sreq);
+- return 0;
++ return 0;
+ }
+
+ case NBD_CLEAR_SOCK: {
+@@ -654,6 +656,7 @@ static int __nbd_ioctl(struct block_devi
+ nbd->sock = SOCKET_I(inode);
+ if (max_part > 0)
+ bdev->bd_invalidated = 1;
++ nbd->disconnect = 0; /* we're connected now */
+ return 0;
+ } else {
+ fput(file);
+@@ -743,6 +746,8 @@ static int __nbd_ioctl(struct block_devi
+ set_capacity(nbd->disk, 0);
+ if (max_part > 0)
+ ioctl_by_bdev(bdev, BLKRRPART, 0);
++ if (nbd->disconnect) /* user requested, ignore socket errors */
++ return 0;
+ return nbd->harderror;
+ }
+
+--- a/include/linux/nbd.h
++++ b/include/linux/nbd.h
+@@ -41,6 +41,7 @@ struct nbd_device {
+ u64 bytesize;
+ pid_t pid; /* pid of nbd-client, if attached */
+ int xmit_timeout;
++ int disconnect; /* a disconnect has been requested by user */
+ };
+
+ #endif
--- /dev/null
+From ef962df057aaafd714f5c22ba3de1be459571fdf Mon Sep 17 00:00:00 2001
+From: Junxiao Bi <junxiao.bi@oracle.com>
+Date: Wed, 3 Jul 2013 15:01:03 -0700
+Subject: ocfs2: xattr: fix inlined xattr reflink
+
+From: Junxiao Bi <junxiao.bi@oracle.com>
+
+commit ef962df057aaafd714f5c22ba3de1be459571fdf upstream.
+
+Inlined xattr shared free space of inode block with inlined data or data
+extent record, so the size of the later two should be adjusted when
+inlined xattr is enabled. See ocfs2_xattr_ibody_init(). But this isn't
+done well when reflink. For inode with inlined data, its max inlined
+data size is adjusted in ocfs2_duplicate_inline_data(), no problem. But
+for inode with data extent record, its record count isn't adjusted. Fix
+it, or data extent record and inlined xattr may overwrite each other,
+then cause data corruption or xattr failure.
+
+One panic caused by this bug in our test environment is the following:
+
+ kernel BUG at fs/ocfs2/xattr.c:1435!
+ invalid opcode: 0000 [#1] SMP
+ Pid: 10871, comm: multi_reflink_t Not tainted 2.6.39-300.17.1.el5uek #1
+ RIP: ocfs2_xa_offset_pointer+0x17/0x20 [ocfs2]
+ RSP: e02b:ffff88007a587948 EFLAGS: 00010283
+ RAX: 0000000000000000 RBX: 0000000000000010 RCX: 00000000000051e4
+ RDX: ffff880057092060 RSI: 0000000000000f80 RDI: ffff88007a587a68
+ RBP: ffff88007a587948 R08: 00000000000062f4 R09: 0000000000000000
+ R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000010
+ R13: ffff88007a587a68 R14: 0000000000000001 R15: ffff88007a587c68
+ FS: 00007fccff7f06e0(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
+ CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b
+ CR2: 00000000015cf000 CR3: 000000007aa76000 CR4: 0000000000000660
+ DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+ DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
+ Process multi_reflink_t
+ Call Trace:
+ ocfs2_xa_reuse_entry+0x60/0x280 [ocfs2]
+ ocfs2_xa_prepare_entry+0x17e/0x2a0 [ocfs2]
+ ocfs2_xa_set+0xcc/0x250 [ocfs2]
+ ocfs2_xattr_ibody_set+0x98/0x230 [ocfs2]
+ __ocfs2_xattr_set_handle+0x4f/0x700 [ocfs2]
+ ocfs2_xattr_set+0x6c6/0x890 [ocfs2]
+ ocfs2_xattr_user_set+0x46/0x50 [ocfs2]
+ generic_setxattr+0x70/0x90
+ __vfs_setxattr_noperm+0x80/0x1a0
+ vfs_setxattr+0xa9/0xb0
+ setxattr+0xc3/0x120
+ sys_fsetxattr+0xa8/0xd0
+ system_call_fastpath+0x16/0x1b
+
+Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
+Reviewed-by: Jie Liu <jeff.liu@oracle.com>
+Acked-by: Joel Becker <jlbec@evilplan.org>
+Cc: Mark Fasheh <mfasheh@suse.com>
+Cc: Sunil Mushran <sunil.mushran@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ocfs2/xattr.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/fs/ocfs2/xattr.c
++++ b/fs/ocfs2/xattr.c
+@@ -6499,6 +6499,16 @@ static int ocfs2_reflink_xattr_inline(st
+ }
+
+ new_oi = OCFS2_I(args->new_inode);
++ /*
++ * Adjust extent record count to reserve space for extended attribute.
++ * Inline data count had been adjusted in ocfs2_duplicate_inline_data().
++ */
++ if (!(new_oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) &&
++ !(ocfs2_inode_is_fast_symlink(args->new_inode))) {
++ struct ocfs2_extent_list *el = &new_di->id2.i_list;
++ le16_add_cpu(&el->l_count, -(inline_size /
++ sizeof(struct ocfs2_extent_rec)));
++ }
+ spin_lock(&new_oi->ip_lock);
+ new_oi->ip_dyn_features |= OCFS2_HAS_XATTR_FL | OCFS2_INLINE_XATTR_FL;
+ new_di->i_dyn_features = cpu_to_le16(new_oi->ip_dyn_features);
--- /dev/null
+From fbf33f516bdbcc2ab1ba1e54dfb720b0cfaa6874 Mon Sep 17 00:00:00 2001
+From: Xudong Hao <xudong.hao@intel.com>
+Date: Fri, 31 May 2013 12:21:29 +0800
+Subject: PCI: Finish SR-IOV VF setup before adding the device
+
+From: Xudong Hao <xudong.hao@intel.com>
+
+commit fbf33f516bdbcc2ab1ba1e54dfb720b0cfaa6874 upstream.
+
+Commit 4f535093cf "PCI: Put pci_dev in device tree as early as possible"
+moves device registering from pci_bus_add_devices() to pci_device_add().
+That causes problems for virtual functions because device_add(&virtfn->dev)
+is called before setting the virtfn->is_virtfn flag, which then causes Xen
+to report PCI virtual functions as PCI physical functions.
+
+Fix it by setting virtfn->is_virtfn before calling pci_device_add().
+
+[Jiang Liu]: Move the setting of virtfn->is_virtfn ahead further for better
+readability and modify changelog.
+
+Signed-off-by: Xudong Hao <xudong.hao@intel.com>
+Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/iov.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/drivers/pci/iov.c
++++ b/drivers/pci/iov.c
+@@ -92,6 +92,8 @@ static int virtfn_add(struct pci_dev *de
+ pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
+ pci_setup_device(virtfn);
+ virtfn->dev.parent = dev->dev.parent;
++ virtfn->physfn = pci_dev_get(dev);
++ virtfn->is_virtfn = 1;
+
+ for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
+ res = dev->resource + PCI_IOV_RESOURCES + i;
+@@ -113,9 +115,6 @@ static int virtfn_add(struct pci_dev *de
+ pci_device_add(virtfn, virtfn->bus);
+ mutex_unlock(&iov->dev->sriov->lock);
+
+- virtfn->physfn = pci_dev_get(dev);
+- virtfn->is_virtfn = 1;
+-
+ rc = pci_bus_add_device(virtfn);
+ sprintf(buf, "virtfn%u", id);
+ rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
--- /dev/null
+From 343df771e671d821478dd3ef525a0610b808dbf8 Mon Sep 17 00:00:00 2001
+From: Jiang Liu <liuj97@gmail.com>
+Date: Fri, 7 Jun 2013 01:10:08 +0800
+Subject: PCI: Fix refcount issue in pci_create_root_bus() error recovery path
+
+From: Jiang Liu <liuj97@gmail.com>
+
+commit 343df771e671d821478dd3ef525a0610b808dbf8 upstream.
+
+After calling device_register(&bridge->dev), the bridge is reference-
+counted, and it is illegal to call kfree() on it except in the release
+function.
+
+[bhelgaas: changelog, use put_device() after device_register() failure]
+Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/probe.c | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+--- a/drivers/pci/probe.c
++++ b/drivers/pci/probe.c
+@@ -1703,12 +1703,16 @@ struct pci_bus *pci_create_root_bus(stru
+ bridge->dev.release = pci_release_bus_bridge_dev;
+ dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+ error = pcibios_root_bridge_prepare(bridge);
+- if (error)
+- goto bridge_dev_reg_err;
++ if (error) {
++ kfree(bridge);
++ goto err_out;
++ }
+
+ error = device_register(&bridge->dev);
+- if (error)
+- goto bridge_dev_reg_err;
++ if (error) {
++ put_device(&bridge->dev);
++ goto err_out;
++ }
+ b->bridge = get_device(&bridge->dev);
+ device_enable_async_suspend(b->bridge);
+ pci_set_bus_of_node(b);
+@@ -1764,8 +1768,6 @@ struct pci_bus *pci_create_root_bus(stru
+ class_dev_reg_err:
+ put_device(&bridge->dev);
+ device_unregister(&bridge->dev);
+-bridge_dev_reg_err:
+- kfree(bridge);
+ err_out:
+ kfree(b);
+ return NULL;
parisc-ensure-volatile-space-register-sr1-is-not-clobbered.patch
parisc-fix-lmmio-mismatch-between-pat-length-and-mask-register.patch
parisc-optimize-mtsp-0-sr-inline-assembly.patch
+x86-efi-retry-exitbootservices-on-failure.patch
+xen-time-remove-blocked-time-accounting-from-xen-clockchip.patch
+xen-pcifront-deal-with-toolstack-missing-xenbusstateclosing-state.patch
+genirq-fix-can_request_irq-for-irqs-without-an-action.patch
+drivers-rtc-rtc-rv3029c2.c-fix-disabling-aie-irq.patch
+acpi-add-cmos-rtc-operation-region-handler-support.patch
+acpi-ec-add-hp-folio-13-to-ec_dmi_table-in-order-to-skip-dsdt-scan.patch
+acpica-do-not-use-extended-sleep-registers-unless-hw-reduced-bit-is-set.patch
+acpi-pm-fix-corner-case-in-acpi_bus_update_power.patch
+hid-apple-add-support-for-the-2013-macbook-air.patch
+input-bcm5974-add-support-for-the-2013-macbook-air.patch
+arch-c6x-mm-include-asm-uaccess.h-to-pass-compiling.patch
+ocfs2-xattr-fix-inlined-xattr-reflink.patch
+nbd-correct-disconnect-behavior.patch
+pci-finish-sr-iov-vf-setup-before-adding-the-device.patch
+pci-fix-refcount-issue-in-pci_create_root_bus-error-recovery-path.patch
+iwlwifi-pcie-fix-race-in-queue-unmapping.patch
+iwlwifi-pcie-wake-the-queue-if-stopped-when-being-unmapped.patch
+ahci-add-amd-cz-sata-device-id.patch
+ahci-ahci-mode-sata-patch-for-intel-coleto-creek-deviceids.patch
+ahci-remove-pmp-link-online-check-in-fbs-eh.patch
+timer-fix-jiffies-wrap-behavior-of-round_jiffies_common.patch
+btrfs-fix-estale-with-btrfs-send.patch
+btrfs-hold-the-tree-mod-lock-in-__tree_mod_log_rewind.patch
+btrfs-only-do-the-tree_mod_log_free_eb-if-this-is-our-last.patch
--- /dev/null
+From 9e04d3804d3ac97d8c03a41d78d0f0674b5d01e1 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bart.vanassche@gmail.com>
+Date: Tue, 21 May 2013 20:43:50 +0200
+Subject: timer: Fix jiffies wrap behavior of round_jiffies_common()
+
+From: Bart Van Assche <bart.vanassche@gmail.com>
+
+commit 9e04d3804d3ac97d8c03a41d78d0f0674b5d01e1 upstream.
+
+Direct compare of jiffies related values does not work in the wrap
+around case. Replace it with time_is_after_jiffies().
+
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Cc: Arjan van de Ven <arjan@infradead.org>
+Cc: Stephen Rothwell <sfr@canb.auug.org.au>
+Link: http://lkml.kernel.org/r/519BC066.5080600@acm.org
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/timer.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/kernel/timer.c
++++ b/kernel/timer.c
+@@ -149,9 +149,11 @@ static unsigned long round_jiffies_commo
+ /* now that we have rounded, subtract the extra skew again */
+ j -= cpu * 3;
+
+- if (j <= jiffies) /* rounding ate our timeout entirely; */
+- return original;
+- return j;
++ /*
++ * Make sure j is still in the future. Otherwise return the
++ * unmodified value.
++ */
++ return time_is_after_jiffies(j) ? j : original;
+ }
+
+ /**
--- /dev/null
+From d3768d885c6ccbf8a137276843177d76c49033a7 Mon Sep 17 00:00:00 2001
+From: Zach Bobroff <zacharyb@ami.com>
+Date: Fri, 7 Jun 2013 13:02:50 +0100
+Subject: x86, efi: retry ExitBootServices() on failure
+
+From: Zach Bobroff <zacharyb@ami.com>
+
+commit d3768d885c6ccbf8a137276843177d76c49033a7 upstream.
+
+ExitBootServices is absolutely supposed to return a failure if any
+ExitBootServices event handler changes the memory map. Basically the
+get_map loop should run again if ExitBootServices returns an error the
+first time. I would say it would be fair that if ExitBootServices gives
+an error the second time then Linux would be fine in returning control
+back to BIOS.
+
+The second change is the following line:
+
+again:
+ size += sizeof(*mem_map) * 2;
+
+Originally you were incrementing it by the size of one memory map entry.
+The issue here is all related to the low_alloc routine you are using.
+In this routine you are making allocations to get the memory map itself.
+Doing this allocation or allocations can affect the memory map by more
+than one record.
+
+[ mfleming - changelog, code style ]
+Signed-off-by: Zach Bobroff <zacharyb@ami.com>
+Signed-off-by: Matt Fleming <matt.fleming@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/boot/compressed/eboot.c | 20 +++++++++++++++++---
+ 1 file changed, 17 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/boot/compressed/eboot.c
++++ b/arch/x86/boot/compressed/eboot.c
+@@ -992,18 +992,20 @@ static efi_status_t exit_boot(struct boo
+ efi_memory_desc_t *mem_map;
+ efi_status_t status;
+ __u32 desc_version;
++ bool called_exit = false;
+ u8 nr_entries;
+ int i;
+
+ size = sizeof(*mem_map) * 32;
+
+ again:
+- size += sizeof(*mem_map);
++ size += sizeof(*mem_map) * 2;
+ _size = size;
+ status = low_alloc(size, 1, (unsigned long *)&mem_map);
+ if (status != EFI_SUCCESS)
+ return status;
+
++get_map:
+ status = efi_call_phys5(sys_table->boottime->get_memory_map, &size,
+ mem_map, &key, &desc_size, &desc_version);
+ if (status == EFI_BUFFER_TOO_SMALL) {
+@@ -1029,8 +1031,20 @@ again:
+ /* Might as well exit boot services now */
+ status = efi_call_phys2(sys_table->boottime->exit_boot_services,
+ handle, key);
+- if (status != EFI_SUCCESS)
+- goto free_mem_map;
++ if (status != EFI_SUCCESS) {
++ /*
++ * ExitBootServices() will fail if any of the event
++ * handlers change the memory map. In which case, we
++ * must be prepared to retry, but only once so that
++ * we're guaranteed to exit on repeated failures instead
++ * of spinning forever.
++ */
++ if (called_exit)
++ goto free_mem_map;
++
++ called_exit = true;
++ goto get_map;
++ }
+
+ /* Historic? */
+ boot_params->alt_mem_k = 32 * 1024;
--- /dev/null
+From 098b1aeaf4d6149953b8f1f8d55c21d85536fbff Mon Sep 17 00:00:00 2001
+From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Date: Mon, 10 Jun 2013 16:48:09 -0400
+Subject: xen/pcifront: Deal with toolstack missing 'XenbusStateClosing' state.
+
+From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+
+commit 098b1aeaf4d6149953b8f1f8d55c21d85536fbff upstream.
+
+There are two tool-stack that can instruct the Xen PCI frontend
+and backend to change states: 'xm' (Python code with a daemon),
+and 'xl' (C library - does not keep state changes).
+
+With the 'xm', the path to disconnect a single PCI device (xm pci-detach
+<guest> <BDF>) is:
+
+4(Connected)->7(Reconfiguring*)-> 8(Reconfigured)-> 4(Connected)->5(Closing*).
+
+The * is for states that the tool-stack sets. For 'xl', it is similar:
+
+4(Connected)->7(Reconfiguring*)-> 8(Reconfigured)-> 4(Connected)
+
+Both of them also tear down the XenBus structure, so the backend
+state ends up going in the 3(Initialised) and calls pcifront_xenbus_remove.
+
+When a PCI device is plugged back in (xm pci-attach <guest> <BDF>)
+both of them follow the same pattern:
+
+2(InitWait*), 3(Initialized*), 4(Connected*)->4(Connected).
+
+[xen-pcifront ignores the 2,3 state changes and only acts when
+4 (Connected) has been reached]
+
+Note that this is for a _single_ PCI device. If there were two
+PCI devices and only one was disconnected 'xm' would show the same
+state changes.
+
+The problem is that git commit 3d925320e9e2de162bd138bf97816bda8c3f71be
+("xen/pcifront: Use Xen-SWIOTLB when initting if required") introduced
+a mechanism to initialize the SWIOTLB when the Xen PCI front moves to
+Connected state. It also had some aggressive seatbelt code check that
+would warn the user if one tried to change to Connected state without
+hitting first the Closing state:
+
+ pcifront pci-0: PCI frontend already installed!
+
+However, that code can be relaxed and we can continue on working
+even if the frontend is instructed to be the 'Connected' state with
+no devices and then gets tickled to be in 'Connected' state again.
+
+In other words, this 4(Connected)->5(Closing)->4(Connected) state
+was expected, while 4(Connected)->.... anything but 5(Closing)->4(Connected)
+was not. This patch removes that aggressive check and allows
+Xen pcifront to work with the 'xl' toolstack (for one or more
+PCI devices) and with 'xm' toolstack (for more than two PCI
+devices).
+
+Acked-by: Bjorn Helgaas <bhelgaas@google.com>
+Cc: linux-pci@vger.kernel.org
+[v2: Added in the description about two PCI devices]
+Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/xen-pcifront.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+--- a/drivers/pci/xen-pcifront.c
++++ b/drivers/pci/xen-pcifront.c
+@@ -678,10 +678,9 @@ static int pcifront_connect_and_init_dma
+ if (!pcifront_dev) {
+ dev_info(&pdev->xdev->dev, "Installing PCI frontend\n");
+ pcifront_dev = pdev;
+- } else {
+- dev_err(&pdev->xdev->dev, "PCI frontend already installed!\n");
++ } else
+ err = -EEXIST;
+- }
++
+ spin_unlock(&pcifront_dev_lock);
+
+ if (!err && !swiotlb_nr_tbl()) {
+@@ -848,7 +847,7 @@ static int pcifront_try_connect(struct p
+ goto out;
+
+ err = pcifront_connect_and_init_dma(pdev);
+- if (err) {
++ if (err && err != -EEXIST) {
+ xenbus_dev_fatal(pdev->xdev, err,
+ "Error setting up PCI Frontend");
+ goto out;
--- /dev/null
+From 0b0c002c340e78173789f8afaa508070d838cf3d Mon Sep 17 00:00:00 2001
+From: Laszlo Ersek <lersek@redhat.com>
+Date: Tue, 18 Oct 2011 22:42:59 +0200
+Subject: xen/time: remove blocked time accounting from xen "clockchip"
+
+From: Laszlo Ersek <lersek@redhat.com>
+
+commit 0b0c002c340e78173789f8afaa508070d838cf3d upstream.
+
+... because the "clock_event_device framework" already accounts for idle
+time through the "event_handler" function pointer in
+xen_timer_interrupt().
+
+The patch is intended as the completion of [1]. It should fix the double
+idle times seen in PV guests' /proc/stat [2]. It should be orthogonal to
+stolen time accounting (the removed code seems to be isolated).
+
+The approach may be completely misguided.
+
+[1] https://lkml.org/lkml/2011/10/6/10
+[2] http://lists.xensource.com/archives/html/xen-devel/2010-08/msg01068.html
+
+John took the time to retest this patch on top of v3.10 and reported:
+"idle time is correctly incremented for pv and hvm for the normal
+case, nohz=off and nohz=idle." so lets put this patch in.
+
+Signed-off-by: Laszlo Ersek <lersek@redhat.com>
+Signed-off-by: John Haxby <john.haxby@oracle.com>
+Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/xen/time.c | 17 ++---------------
+ 1 file changed, 2 insertions(+), 15 deletions(-)
+
+--- a/arch/x86/xen/time.c
++++ b/arch/x86/xen/time.c
+@@ -36,9 +36,8 @@ static DEFINE_PER_CPU(struct vcpu_runsta
+ /* snapshots of runstate info */
+ static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate_snapshot);
+
+-/* unused ns of stolen and blocked time */
++/* unused ns of stolen time */
+ static DEFINE_PER_CPU(u64, xen_residual_stolen);
+-static DEFINE_PER_CPU(u64, xen_residual_blocked);
+
+ /* return an consistent snapshot of 64-bit time/counter value */
+ static u64 get64(const u64 *p)
+@@ -115,7 +114,7 @@ static void do_stolen_accounting(void)
+ {
+ struct vcpu_runstate_info state;
+ struct vcpu_runstate_info *snap;
+- s64 blocked, runnable, offline, stolen;
++ s64 runnable, offline, stolen;
+ cputime_t ticks;
+
+ get_runstate_snapshot(&state);
+@@ -125,7 +124,6 @@ static void do_stolen_accounting(void)
+ snap = &__get_cpu_var(xen_runstate_snapshot);
+
+ /* work out how much time the VCPU has not been runn*ing* */
+- blocked = state.time[RUNSTATE_blocked] - snap->time[RUNSTATE_blocked];
+ runnable = state.time[RUNSTATE_runnable] - snap->time[RUNSTATE_runnable];
+ offline = state.time[RUNSTATE_offline] - snap->time[RUNSTATE_offline];
+
+@@ -141,17 +139,6 @@ static void do_stolen_accounting(void)
+ ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen);
+ __this_cpu_write(xen_residual_stolen, stolen);
+ account_steal_ticks(ticks);
+-
+- /* Add the appropriate number of ticks of blocked time,
+- including any left-overs from last time. */
+- blocked += __this_cpu_read(xen_residual_blocked);
+-
+- if (blocked < 0)
+- blocked = 0;
+-
+- ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked);
+- __this_cpu_write(xen_residual_blocked, blocked);
+- account_idle_ticks(ticks);
+ }
+
+ /* Get the TSC speed from Xen */