--- /dev/null
+From zhangzhiqiang.zhang@huawei.com Fri Oct 3 13:04:46 2014
+From: zhangzhiqiang <zhangzhiqiang.zhang@huawei.com>
+Date: Fri, 26 Sep 2014 15:44:22 +0800
+Subject: arm: armv7: perf: fix armv7 ref-cycles error
+To: <gregkh@linuxfoundation.org>, <lizefan@huawei.com>, <wangnan0@huawei.com>, <stable@vger.kernel.org>, <linux-kernel@vger.kernel.org>
+Message-ID: <54251956.6010407@huawei.com>
+
+
+From: Zhiqiang Zhang <zhangzhiqiang.zhang@huawei.com>
+
+ref-cycles event is specially to Intel core, but can still used in arm
+architecture with the wrong return value with 3.10 stable. this patch fix the
+bug and make it return NOT SUPPORTED distinctly.
+
+In upstream this bug has been fixed by other way, which changes more than one
+file and more than 1000 lines. the primary commit is
+6b7658ec8a100b608e59e3cde353434db51f5be0. besides we can not simply
+cherry-pick.
+
+Signed-off-by: Zhiqiang Zhang <zhangzhiqiang.zhang@huawei.com>
+Cc: Mark Rutland <mark.rutland@arm.com
+Cc: Will Deacon <will.deacon@arm.com>
+Cc: Christopher Covington <cov@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kernel/perf_event_v7.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/arch/arm/kernel/perf_event_v7.c
++++ b/arch/arm/kernel/perf_event_v7.c
+@@ -157,6 +157,7 @@ static const unsigned armv7_a8_perf_map[
+ [PERF_COUNT_HW_BUS_CYCLES] = HW_OP_UNSUPPORTED,
+ [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = ARMV7_A8_PERFCTR_STALL_ISIDE,
+ [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = HW_OP_UNSUPPORTED,
++ [PERF_COUNT_HW_REF_CPU_CYCLES] = HW_OP_UNSUPPORTED,
+ };
+
+ static const unsigned armv7_a8_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
+@@ -281,6 +282,7 @@ static const unsigned armv7_a9_perf_map[
+ [PERF_COUNT_HW_BUS_CYCLES] = HW_OP_UNSUPPORTED,
+ [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = ARMV7_A9_PERFCTR_STALL_ICACHE,
+ [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = ARMV7_A9_PERFCTR_STALL_DISPATCH,
++ [PERF_COUNT_HW_REF_CPU_CYCLES] = HW_OP_UNSUPPORTED,
+ };
+
+ static const unsigned armv7_a9_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
+@@ -405,6 +407,7 @@ static const unsigned armv7_a5_perf_map[
+ [PERF_COUNT_HW_BUS_CYCLES] = HW_OP_UNSUPPORTED,
+ [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = HW_OP_UNSUPPORTED,
+ [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = HW_OP_UNSUPPORTED,
++ [PERF_COUNT_HW_REF_CPU_CYCLES] = HW_OP_UNSUPPORTED,
+ };
+
+ static const unsigned armv7_a5_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
+@@ -527,6 +530,7 @@ static const unsigned armv7_a15_perf_map
+ [PERF_COUNT_HW_BUS_CYCLES] = ARMV7_PERFCTR_BUS_CYCLES,
+ [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = HW_OP_UNSUPPORTED,
+ [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = HW_OP_UNSUPPORTED,
++ [PERF_COUNT_HW_REF_CPU_CYCLES] = HW_OP_UNSUPPORTED,
+ };
+
+ static const unsigned armv7_a15_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
+@@ -651,6 +655,7 @@ static const unsigned armv7_a7_perf_map[
+ [PERF_COUNT_HW_BUS_CYCLES] = ARMV7_PERFCTR_BUS_CYCLES,
+ [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = HW_OP_UNSUPPORTED,
+ [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = HW_OP_UNSUPPORTED,
++ [PERF_COUNT_HW_REF_CPU_CYCLES] = HW_OP_UNSUPPORTED,
+ };
+
+ static const unsigned armv7_a7_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
--- /dev/null
+From 53beaa01e0fe8e4202f43485a03b32fcf5dfea74 Mon Sep 17 00:00:00 2001
+From: Alex Deucher <alexander.deucher@amd.com>
+Date: Fri, 12 Sep 2014 18:06:56 -0400
+Subject: drm/nouveau/runpm: fix module unload
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Alex Deucher <alexander.deucher@amd.com>
+
+commit 53beaa01e0fe8e4202f43485a03b32fcf5dfea74 upstream.
+
+Use the new vga_switcheroo_fini_domain_pm_ops function
+to unregister the pm ops.
+
+Based on a patch from:
+Pali Rohár <pali.rohar@gmail.com>
+
+bug:
+https://bugzilla.kernel.org/show_bug.cgi?id=84431
+
+Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Cc: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/nouveau/nouveau_vga.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
++++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
+@@ -106,7 +106,16 @@ void
+ nouveau_vga_fini(struct nouveau_drm *drm)
+ {
+ struct drm_device *dev = drm->dev;
++ bool runtime = false;
++
++ if (nouveau_runtime_pm == 1)
++ runtime = true;
++ if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_is_v1_dsm()))
++ runtime = true;
++
+ vga_switcheroo_unregister_client(dev->pdev);
++ if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus())
++ vga_switcheroo_fini_domain_pm_ops(drm->dev->dev);
+ vga_client_register(dev->pdev, NULL, NULL, NULL);
+ }
+
--- /dev/null
+From 2e97140dd58cab8772bf77d73eabda213e45202d Mon Sep 17 00:00:00 2001
+From: Alex Deucher <alexander.deucher@amd.com>
+Date: Fri, 12 Sep 2014 18:00:53 -0400
+Subject: drm/radeon/px: fix module unload
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Alex Deucher <alexander.deucher@amd.com>
+
+commit 2e97140dd58cab8772bf77d73eabda213e45202d upstream.
+
+Use the new vga_switcheroo_fini_domain_pm_ops function
+to unregister the pm ops.
+
+Based on a patch from:
+Pali Rohár <pali.rohar@gmail.com>
+
+bug:
+https://bugzilla.kernel.org/show_bug.cgi?id=84431
+
+Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
+Cc: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/radeon/radeon_device.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/radeon/radeon_device.c
++++ b/drivers/gpu/drm/radeon/radeon_device.c
+@@ -1350,7 +1350,7 @@ int radeon_device_init(struct radeon_dev
+
+ r = radeon_init(rdev);
+ if (r)
+- return r;
++ goto failed;
+
+ r = radeon_ib_ring_tests(rdev);
+ if (r)
+@@ -1370,7 +1370,7 @@ int radeon_device_init(struct radeon_dev
+ radeon_agp_disable(rdev);
+ r = radeon_init(rdev);
+ if (r)
+- return r;
++ goto failed;
+ }
+
+ if ((radeon_testing & 1)) {
+@@ -1392,6 +1392,11 @@ int radeon_device_init(struct radeon_dev
+ DRM_INFO("radeon: acceleration disabled, skipping benchmarks\n");
+ }
+ return 0;
++
++failed:
++ if (runtime)
++ vga_switcheroo_fini_domain_pm_ops(rdev->dev);
++ return r;
+ }
+
+ static void radeon_debugfs_remove_files(struct radeon_device *rdev);
+@@ -1412,6 +1417,8 @@ void radeon_device_fini(struct radeon_de
+ radeon_bo_evict_vram(rdev);
+ radeon_fini(rdev);
+ vga_switcheroo_unregister_client(rdev->pdev);
++ if (rdev->flags & RADEON_IS_PX)
++ vga_switcheroo_fini_domain_pm_ops(rdev->dev);
+ vga_client_register(rdev->pdev, NULL, NULL, NULL);
+ if (rdev->rio_mem)
+ pci_iounmap(rdev->pdev, rdev->rio_mem);
--- /dev/null
+From 153a9f131f50420b7ce008c94f1c6374cbc460d7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= <khalasa@piap.pl>
+Date: Thu, 18 Sep 2014 15:12:02 +0200
+Subject: Fix unbalanced mutex in dma_pool_create().
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= <khalasa@piap.pl>
+
+commit 153a9f131f50420b7ce008c94f1c6374cbc460d7 upstream.
+
+dma_pool_create() needs to unlock the mutex in error case. The bug was
+introduced in the 3.16 by commit cc6b664aa26d ("mm/dmapool.c: remove
+redundant NULL check for dev in dma_pool_create()")/
+
+Signed-off-by: Krzysztof Hałasa <khc@piap.pl>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ mm/dmapool.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/mm/dmapool.c
++++ b/mm/dmapool.c
+@@ -176,7 +176,7 @@ struct dma_pool *dma_pool_create(const c
+ if (list_empty(&dev->dma_pools) &&
+ device_create_file(dev, &dev_attr_pools)) {
+ kfree(retval);
+- return NULL;
++ retval = NULL;
+ } else
+ list_add(&retval->pools, &dev->dma_pools);
+ mutex_unlock(&pools_lock);
--- /dev/null
+From b440bde74f043c8ec31081cb59c9a53ade954701 Mon Sep 17 00:00:00 2001
+From: Bjorn Helgaas <bhelgaas@google.com>
+Date: Wed, 10 Sep 2014 13:45:01 -0600
+Subject: PCI: Add pci_ignore_hotplug() to ignore hotplug events for a device
+
+From: Bjorn Helgaas <bhelgaas@google.com>
+
+commit b440bde74f043c8ec31081cb59c9a53ade954701 upstream.
+
+Powering off a hot-pluggable device, e.g., with pci_set_power_state(D3cold),
+normally generates a hot-remove event that unbinds the driver.
+
+Some drivers expect to remain bound to a device even while they power it
+off and back on again. This can be dangerous, because if the device is
+removed or replaced while it is powered off, the driver doesn't know that
+anything changed. But some drivers accept that risk.
+
+Add pci_ignore_hotplug() for use by drivers that know their device cannot
+be removed. Using pci_ignore_hotplug() tells the PCI core that hot-plug
+events for the device should be ignored.
+
+The radeon and nouveau drivers use this to switch between a low-power,
+integrated GPU and a higher-power, higher-performance discrete GPU. They
+power off the unused GPU, but they want to remain bound to it.
+
+This is a reimplementation of f244d8b623da ("ACPIPHP / radeon / nouveau:
+Fix VGA switcheroo problem related to hotplug") but extends it to work with
+both acpiphp and pciehp.
+
+This fixes a problem where systems with dual GPUs using the radeon drivers
+become unusable, freezing every few seconds (see bugzillas below). The
+resume of the radeon device may also fail, e.g.,
+
+This fixes problems on dual GPU systems where the radeon driver becomes
+unusable because of problems while suspending the device, as in bug 79701:
+
+ [drm] radeon: finishing device.
+ radeon 0000:01:00.0: Userspace still has active objects !
+ radeon 0000:01:00.0: ffff8800cb4ec288 ffff8800cb4ec000 16384 4294967297 force free
+ ...
+ WARNING: CPU: 0 PID: 67 at /home/apw/COD/linux/drivers/gpu/drm/radeon/radeon_gart.c:234 radeon_gart_unbind+0xd2/0xe0 [radeon]()
+ trying to unbind memory from uninitialized GART !
+
+or while resuming it, as in bug 77261:
+
+ radeon 0000:01:00.0: ring 0 stalled for more than 10158msec
+ radeon 0000:01:00.0: GPU lockup ...
+ radeon 0000:01:00.0: GPU pci config reset
+ pciehp 0000:00:01.0:pcie04: Card not present on Slot(1-1)
+ radeon 0000:01:00.0: GPU reset succeeded, trying to resume
+ *ERROR* radeon: dpm resume failed
+ radeon 0000:01:00.0: Wait for MC idle timedout !
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=77261
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=79701
+Reported-by: Shawn Starr <shawn.starr@rogers.com>
+Reported-by: Jose P. <lbdkmjdf@sharklasers.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Acked-by: Alex Deucher <alexander.deucher@amd.com>
+Acked-by: Rajat Jain <rajatxjain@gmail.com>
+Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Acked-by: Dave Airlie <airlied@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/nouveau/nouveau_drm.c | 1 +
+ drivers/gpu/drm/radeon/radeon_drv.c | 1 +
+ drivers/pci/hotplug/acpiphp_glue.c | 16 ++++++----------
+ drivers/pci/hotplug/pciehp_hpc.c | 12 ++++++++++++
+ include/linux/pci.h | 6 ++++++
+ 5 files changed, 26 insertions(+), 10 deletions(-)
+
+--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
++++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
+@@ -596,6 +596,7 @@ int nouveau_pmops_suspend(struct device
+
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
++ pci_ignore_hotplug(pdev);
+ pci_set_power_state(pdev, PCI_D3hot);
+ return 0;
+ }
+--- a/drivers/gpu/drm/radeon/radeon_drv.c
++++ b/drivers/gpu/drm/radeon/radeon_drv.c
+@@ -429,6 +429,7 @@ static int radeon_pmops_runtime_suspend(
+ ret = radeon_suspend_kms(drm_dev, false, false);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
++ pci_ignore_hotplug(pdev);
+ pci_set_power_state(pdev, PCI_D3cold);
+ drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
+
+--- a/drivers/pci/hotplug/acpiphp_glue.c
++++ b/drivers/pci/hotplug/acpiphp_glue.c
+@@ -573,19 +573,15 @@ static void disable_slot(struct acpiphp_
+ slot->flags &= (~SLOT_ENABLED);
+ }
+
+-static bool acpiphp_no_hotplug(struct acpi_device *adev)
+-{
+- return adev && adev->flags.no_hotplug;
+-}
+-
+ static bool slot_no_hotplug(struct acpiphp_slot *slot)
+ {
+- struct acpiphp_func *func;
++ struct pci_bus *bus = slot->bus;
++ struct pci_dev *dev;
+
+- list_for_each_entry(func, &slot->funcs, sibling)
+- if (acpiphp_no_hotplug(func_to_acpi_device(func)))
++ list_for_each_entry(dev, &bus->devices, bus_list) {
++ if (PCI_SLOT(dev->devfn) == slot->device && dev->ignore_hotplug)
+ return true;
+-
++ }
+ return false;
+ }
+
+@@ -658,7 +654,7 @@ static void trim_stale_devices(struct pc
+
+ status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
+ alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
+- || acpiphp_no_hotplug(adev);
++ || dev->ignore_hotplug;
+ }
+ if (!alive)
+ alive = pci_device_is_present(dev);
+--- a/drivers/pci/hotplug/pciehp_hpc.c
++++ b/drivers/pci/hotplug/pciehp_hpc.c
+@@ -508,6 +508,8 @@ static irqreturn_t pcie_isr(int irq, voi
+ {
+ struct controller *ctrl = (struct controller *)dev_id;
+ struct pci_dev *pdev = ctrl_dev(ctrl);
++ struct pci_bus *subordinate = pdev->subordinate;
++ struct pci_dev *dev;
+ struct slot *slot = ctrl->slot;
+ u16 detected, intr_loc;
+
+@@ -541,6 +543,16 @@ static irqreturn_t pcie_isr(int irq, voi
+ wake_up(&ctrl->queue);
+ }
+
++ if (subordinate) {
++ list_for_each_entry(dev, &subordinate->devices, bus_list) {
++ if (dev->ignore_hotplug) {
++ ctrl_dbg(ctrl, "ignoring hotplug event %#06x (%s requested no hotplug)\n",
++ intr_loc, pci_name(dev));
++ return IRQ_HANDLED;
++ }
++ }
++ }
++
+ if (!(intr_loc & ~PCI_EXP_SLTSTA_CC))
+ return IRQ_HANDLED;
+
+--- a/include/linux/pci.h
++++ b/include/linux/pci.h
+@@ -303,6 +303,7 @@ struct pci_dev {
+ D3cold, not set for devices
+ powered on/off by the
+ corresponding bridge */
++ unsigned int ignore_hotplug:1; /* Ignore hotplug events */
+ unsigned int d3_delay; /* D3->D0 transition time in ms */
+ unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */
+
+@@ -1019,6 +1020,11 @@ bool pci_dev_run_wake(struct pci_dev *de
+ bool pci_check_pme_status(struct pci_dev *dev);
+ void pci_pme_wakeup_bus(struct pci_bus *bus);
+
++static inline void pci_ignore_hotplug(struct pci_dev *dev)
++{
++ dev->ignore_hotplug = 1;
++}
++
+ static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
+ bool enable)
+ {
--- /dev/null
+From 3577af70a2ce4853d58e57d832e687d739281479 Mon Sep 17 00:00:00 2001
+From: Cong Wang <cwang@twopensource.com>
+Date: Tue, 2 Sep 2014 15:27:20 -0700
+Subject: perf: Fix a race condition in perf_remove_from_context()
+
+From: Cong Wang <cwang@twopensource.com>
+
+commit 3577af70a2ce4853d58e57d832e687d739281479 upstream.
+
+We saw a kernel soft lockup in perf_remove_from_context(),
+it looks like the `perf` process, when exiting, could not go
+out of the retry loop. Meanwhile, the target process was forking
+a child. So either the target process should execute the smp
+function call to deactive the event (if it was running) or it should
+do a context switch which deactives the event.
+
+It seems we optimize out a context switch in perf_event_context_sched_out(),
+and what's more important, we still test an obsolete task pointer when
+retrying, so no one actually would deactive that event in this situation.
+Fix it directly by reloading the task pointer in perf_remove_from_context().
+
+This should cure the above soft lockup.
+
+Signed-off-by: Cong Wang <cwang@twopensource.com>
+Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Cc: Paul Mackerras <paulus@samba.org>
+Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Link: http://lkml.kernel.org/r/1409696840-843-1-git-send-email-xiyou.wangcong@gmail.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/events/core.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/kernel/events/core.c
++++ b/kernel/events/core.c
+@@ -1523,6 +1523,11 @@ retry:
+ */
+ if (ctx->is_active) {
+ raw_spin_unlock_irq(&ctx->lock);
++ /*
++ * Reload the task pointer, it might have been changed by
++ * a concurrent perf_event_context_sched_out().
++ */
++ task = ctx->task;
+ goto retry;
+ }
+
+@@ -1966,6 +1971,11 @@ retry:
+ */
+ if (ctx->is_active) {
+ raw_spin_unlock_irq(&ctx->lock);
++ /*
++ * Reload the task pointer, it might have been changed by
++ * a concurrent perf_event_context_sched_out().
++ */
++ task = ctx->task;
+ goto retry;
+ }
+
--- /dev/null
+From 7a0b33d4a45d30b9a838fba4efcd80b7b57d4d16 Mon Sep 17 00:00:00 2001
+From: Bjorn Helgaas <bhelgaas@google.com>
+Date: Fri, 19 Sep 2014 10:56:06 -0600
+Subject: Revert "PCI: Don't scan random busses in pci_scan_bridge()"
+
+From: Bjorn Helgaas <bhelgaas@google.com>
+
+commit 7a0b33d4a45d30b9a838fba4efcd80b7b57d4d16 upstream.
+
+This reverts commit fc1b253141b3 ("PCI: Don't scan random busses in
+pci_scan_bridge()") because it breaks CardBus on some machines.
+
+David tested a Dell Latitude D505 that worked like this prior to
+fc1b253141b3:
+
+ pci 0000:00:1e.0: PCI bridge to [bus 01]
+ pci 0000:01:01.0: CardBus bridge to [bus 02-05]
+
+Note that the 01:01.0 CardBus bridge has a bus number aperture of
+[bus 02-05], but those buses are all outside the 00:1e.0 PCI bridge bus
+number aperture, so accesses to buses 02-05 never reach CardBus. This is
+later patched up by yenta_fixup_parent_bridge(), which changes the
+subordinate bus number of the 00:1e.0 PCI bridge:
+
+ pci_bus 0000:01: Raising subordinate bus# of parent bus (#01) from #01 to #05
+
+With fc1b253141b3, pci_scan_bridge() fails immediately when it notices that
+we can't allocate a valid secondary bus number for the CardBus bridge, and
+CardBus doesn't work at all:
+
+ pci 0000:01:01.0: can't allocate child bus 01 from [bus 01]
+
+I'd prefer to fix this by integrating the yenta_fixup_parent_bridge() logic
+into pci_scan_bridge() so we fix the bus number apertures up front. But
+I don't think we can do that before v3.17, so I'm going to revert this to
+avoid the problem while we're working on the long-term fix.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=83441
+Link: http://lkml.kernel.org/r/1409303414-5196-1-git-send-email-david.henningsson@canonical.com
+Reported-by: David Henningsson <david.henningsson@canonical.com>
+Tested-by: David Henningsson <david.henningsson@canonical.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/probe.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+--- a/drivers/pci/probe.c
++++ b/drivers/pci/probe.c
+@@ -838,16 +838,12 @@ int pci_scan_bridge(struct pci_bus *bus,
+ goto out;
+ }
+
+- if (max >= bus->busn_res.end) {
+- dev_warn(&dev->dev, "can't allocate child bus %02x from %pR\n",
+- max, &bus->busn_res);
+- goto out;
+- }
+-
+ /* Clear errors */
+ pci_write_config_word(dev, PCI_STATUS, 0xffff);
+
+- /* The bus will already exist if we are rescanning */
++ /* Prevent assigning a bus number that already exists.
++ * This can happen when a bridge is hot-plugged, so in
++ * this case we only re-scan this bus. */
+ child = pci_find_bus(pci_domain_nr(bus), max+1);
+ if (!child) {
+ child = pci_add_new_bus(bus, dev, max+1);
ib-mlx4-avoid-null-pointer-dereference-in-mlx4_ib_scan_netdevs.patch
ib-mlx4-don-t-duplicate-the-default-roce-gid.patch
ib-core-when-marshaling-uverbs-path-clear-unused-fields.patch
+spi-fsl-don-t-use-devm_kzalloc-in-master-setup-callback.patch
+spi-dw-don-t-use-devm_kzalloc-in-master-setup-callback.patch
+spi-sirf-enable-rx_io_dma_int-interrupt.patch
+fix-unbalanced-mutex-in-dma_pool_create.patch
+perf-fix-a-race-condition-in-perf_remove_from_context.patch
+arm-armv7-perf-fix-armv7-ref-cycles-error.patch
+pci-add-pci_ignore_hotplug-to-ignore-hotplug-events-for-a-device.patch
+revert-pci-don-t-scan-random-busses-in-pci_scan_bridge.patch
+vgaswitcheroo-add-vga_switcheroo_fini_domain_pm_ops.patch
+drm-nouveau-runpm-fix-module-unload.patch
+drm-radeon-px-fix-module-unload.patch
--- /dev/null
+From a97c883a16da7e0691a3be5465926c92a8da4da6 Mon Sep 17 00:00:00 2001
+From: Axel Lin <axel.lin@ingics.com>
+Date: Sun, 31 Aug 2014 12:47:06 +0800
+Subject: spi: dw: Don't use devm_kzalloc in master->setup callback
+
+From: Axel Lin <axel.lin@ingics.com>
+
+commit a97c883a16da7e0691a3be5465926c92a8da4da6 upstream.
+
+device_add() expects that any memory allocated via devm_* API is only
+done in the device's probe function.
+
+Fix below boot warning:
+WARNING: CPU: 1 PID: 1 at drivers/base/dd.c:286 driver_probe_device+0x2b4/0x2f4()
+Modules linked in:
+CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.16.0-10474-g835c90b-dirty #160
+[<c0016364>] (unwind_backtrace) from [<c001251c>] (show_stack+0x20/0x24)
+[<c001251c>] (show_stack) from [<c04eaefc>] (dump_stack+0x7c/0x98)
+[<c04eaefc>] (dump_stack) from [<c0023d4c>] (warn_slowpath_common+0x78/0x9c)
+[<c0023d4c>] (warn_slowpath_common) from [<c0023d9c>] (warn_slowpath_null+0x2c/0x34)
+[<c0023d9c>] (warn_slowpath_null) from [<c0302c60>] (driver_probe_device+0x2b4/0x2f4)
+[<c0302c60>] (driver_probe_device) from [<c0302d90>] (__device_attach+0x50/0x54)
+[<c0302d90>] (__device_attach) from [<c0300e60>] (bus_for_each_drv+0x54/0x9c)
+[<c0300e60>] (bus_for_each_drv) from [<c0302958>] (device_attach+0x84/0x90)
+[<c0302958>] (device_attach) from [<c0301f10>] (bus_probe_device+0x94/0xb8)
+[<c0301f10>] (bus_probe_device) from [<c03000c0>] (device_add+0x434/0x4fc)
+[<c03000c0>] (device_add) from [<c0342dd4>] (spi_add_device+0x98/0x164)
+[<c0342dd4>] (spi_add_device) from [<c03444a4>] (spi_register_master+0x598/0x768)
+[<c03444a4>] (spi_register_master) from [<c03446b4>] (devm_spi_register_master+0x40/0x80)
+[<c03446b4>] (devm_spi_register_master) from [<c0346214>] (dw_spi_add_host+0x1a8/0x258)
+[<c0346214>] (dw_spi_add_host) from [<c0346920>] (dw_spi_mmio_probe+0x1d4/0x294)
+[<c0346920>] (dw_spi_mmio_probe) from [<c0304560>] (platform_drv_probe+0x3c/0x6c)
+[<c0304560>] (platform_drv_probe) from [<c0302a98>] (driver_probe_device+0xec/0x2f4)
+[<c0302a98>] (driver_probe_device) from [<c0302d3c>] (__driver_attach+0x9c/0xa0)
+[<c0302d3c>] (__driver_attach) from [<c0300f0c>] (bus_for_each_dev+0x64/0x98)
+[<c0300f0c>] (bus_for_each_dev) from [<c0302518>] (driver_attach+0x2c/0x30)
+[<c0302518>] (driver_attach) from [<c0302134>] (bus_add_driver+0xdc/0x1f4)
+[<c0302134>] (bus_add_driver) from [<c03035c8>] (driver_register+0x88/0x104)
+[<c03035c8>] (driver_register) from [<c030445c>] (__platform_driver_register+0x58/0x6c)
+[<c030445c>] (__platform_driver_register) from [<c0700f00>] (dw_spi_mmio_driver_init+0x18/0x20)
+[<c0700f00>] (dw_spi_mmio_driver_init) from [<c0008914>] (do_one_initcall+0x90/0x1d4)
+[<c0008914>] (do_one_initcall) from [<c06d7d90>] (kernel_init_freeable+0x178/0x248)
+[<c06d7d90>] (kernel_init_freeable) from [<c04e687c>] (kernel_init+0x18/0xfc)
+[<c04e687c>] (kernel_init) from [<c000ecd8>] (ret_from_fork+0x14/0x20)
+
+Reported-by: Thor Thayer <tthayer@opensource.altera.com>
+Signed-off-by: Axel Lin <axel.lin@ingics.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/spi/spi-dw.c | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+--- a/drivers/spi/spi-dw.c
++++ b/drivers/spi/spi-dw.c
+@@ -547,8 +547,7 @@ static int dw_spi_setup(struct spi_devic
+ /* Only alloc on first setup */
+ chip = spi_get_ctldata(spi);
+ if (!chip) {
+- chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
+- GFP_KERNEL);
++ chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
+ spi_set_ctldata(spi, chip);
+@@ -606,6 +605,14 @@ static int dw_spi_setup(struct spi_devic
+ return 0;
+ }
+
++static void dw_spi_cleanup(struct spi_device *spi)
++{
++ struct chip_data *chip = spi_get_ctldata(spi);
++
++ kfree(chip);
++ spi_set_ctldata(spi, NULL);
++}
++
+ /* Restart the controller, disable all interrupts, clean rx fifo */
+ static void spi_hw_init(struct dw_spi *dws)
+ {
+@@ -661,6 +668,7 @@ int dw_spi_add_host(struct device *dev,
+ master->bus_num = dws->bus_num;
+ master->num_chipselect = dws->num_cs;
+ master->setup = dw_spi_setup;
++ master->cleanup = dw_spi_cleanup;
+ master->transfer_one_message = dw_spi_transfer_one_message;
+ master->max_speed_hz = dws->max_freq;
+
--- /dev/null
+From d9f26748128c73ec6bed2846ca52fb1c2edc3ced Mon Sep 17 00:00:00 2001
+From: Axel Lin <axel.lin@ingics.com>
+Date: Sun, 31 Aug 2014 12:44:09 +0800
+Subject: spi: fsl: Don't use devm_kzalloc in master->setup callback
+
+From: Axel Lin <axel.lin@ingics.com>
+
+commit d9f26748128c73ec6bed2846ca52fb1c2edc3ced upstream.
+
+device_add() expects that any memory allocated via devm_* API is only
+done in the device's probe function.
+
+Fix below boot warning:
+[ 3.092348] WARNING: at drivers/base/dd.c:286
+[ 3.096637] Modules linked in:
+[ 3.099697] CPU: 0 PID: 25 Comm: kworker/u2:1 Tainted: G W 3.16.1-s3k-drv-999-svn5771_knld-999 #158
+[ 3.109610] Workqueue: deferwq deferred_probe_work_func
+[ 3.114736] task: c787f020 ti: c790c000 task.ti: c790c000
+[ 3.120062] NIP: c01df158 LR: c01df144 CTR: 00000000
+[ 3.124983] REGS: c790db30 TRAP: 0700 Tainted: G W (3.16.1-s3k-drv-999-svn5771_knld-999)
+[ 3.134162] MSR: 00029032 <EE,ME,IR,DR,RI> CR: 22002082 XER: 20000000
+[ 3.140703]
+[ 3.140703] GPR00: 00000001 c790dbe0 c787f020 00000044 00000054 00000308 c056da0e 20737069
+[ 3.140703] GPR08: 33323736 000ebfe0 00000308 000ebfdf 22002082 00000000 c046c5a0 c046c608
+[ 3.140703] GPR16: c046c614 c046c620 c046c62c c046c638 c046c648 c046c654 c046c68c c046c6c4
+[ 3.140703] GPR24: 00000000 00000000 00000003 c0401aa0 c0596638 c059662c c054e7a8 c7996800
+[ 3.170102] NIP [c01df158] driver_probe_device+0xf8/0x334
+[ 3.175431] LR [c01df144] driver_probe_device+0xe4/0x334
+[ 3.180633] Call Trace:
+[ 3.183093] [c790dbe0] [c01df144] driver_probe_device+0xe4/0x334 (unreliable)
+[ 3.190147] [c790dc10] [c01dd15c] bus_for_each_drv+0x7c/0xc0
+[ 3.195741] [c790dc40] [c01df5fc] device_attach+0xcc/0xf8
+[ 3.201076] [c790dc60] [c01dd6d4] bus_probe_device+0xb4/0xc4
+[ 3.206666] [c790dc80] [c01db9f8] device_add+0x270/0x564
+[ 3.211923] [c790dcc0] [c0219e84] spi_add_device+0xc0/0x190
+[ 3.217427] [c790dce0] [c021a79c] spi_register_master+0x720/0x834
+[ 3.223455] [c790dd40] [c021cb48] of_fsl_spi_probe+0x55c/0x614
+[ 3.229234] [c790dda0] [c01e0d2c] platform_drv_probe+0x30/0x74
+[ 3.234987] [c790ddb0] [c01df18c] driver_probe_device+0x12c/0x334
+[ 3.241008] [c790dde0] [c01dd15c] bus_for_each_drv+0x7c/0xc0
+[ 3.246602] [c790de10] [c01df5fc] device_attach+0xcc/0xf8
+[ 3.251937] [c790de30] [c01dd6d4] bus_probe_device+0xb4/0xc4
+[ 3.257536] [c790de50] [c01de9d8] deferred_probe_work_func+0x98/0xe0
+[ 3.263816] [c790de70] [c00305b8] process_one_work+0x18c/0x440
+[ 3.269577] [c790dea0] [c0030a00] worker_thread+0x194/0x67c
+[ 3.275105] [c790def0] [c0039198] kthread+0xd0/0xe4
+[ 3.279911] [c790df40] [c000c6d0] ret_from_kernel_thread+0x5c/0x64
+[ 3.285970] Instruction dump:
+[ 3.288900] 80de0000 419e01d0 3b7b0038 3c60c046 7f65db78 38635264 48211b99 813f00a0
+[ 3.296559] 381f00a0 7d290278 3169ffff 7c0b4910 <0f000000> 93df0044 7fe3fb78 4bfffd4d
+
+Reported-by: leroy christophe <christophe.leroy@c-s.fr>
+Signed-off-by: Axel Lin <axel.lin@ingics.com>
+Tested-by: Christophe Leroy <christophe.leroy@c-s.fr>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/spi/spi-fsl-espi.c | 15 ++++++++++++---
+ drivers/spi/spi-fsl-spi.c | 10 +++++++---
+ 2 files changed, 19 insertions(+), 6 deletions(-)
+
+--- a/drivers/spi/spi-fsl-espi.c
++++ b/drivers/spi/spi-fsl-espi.c
+@@ -452,16 +452,16 @@ static int fsl_espi_setup(struct spi_dev
+ int retval;
+ u32 hw_mode;
+ u32 loop_mode;
+- struct spi_mpc8xxx_cs *cs = spi->controller_state;
++ struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
+
+ if (!spi->max_speed_hz)
+ return -EINVAL;
+
+ if (!cs) {
+- cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
++ cs = kzalloc(sizeof(*cs), GFP_KERNEL);
+ if (!cs)
+ return -ENOMEM;
+- spi->controller_state = cs;
++ spi_set_ctldata(spi, cs);
+ }
+
+ mpc8xxx_spi = spi_master_get_devdata(spi->master);
+@@ -496,6 +496,14 @@ static int fsl_espi_setup(struct spi_dev
+ return 0;
+ }
+
++static void fsl_espi_cleanup(struct spi_device *spi)
++{
++ struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
++
++ kfree(cs);
++ spi_set_ctldata(spi, NULL);
++}
++
+ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
+ {
+ struct fsl_espi_reg *reg_base = mspi->reg_base;
+@@ -605,6 +613,7 @@ static struct spi_master * fsl_espi_prob
+
+ master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
+ master->setup = fsl_espi_setup;
++ master->cleanup = fsl_espi_cleanup;
+
+ mpc8xxx_spi = spi_master_get_devdata(master);
+ mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg;
+--- a/drivers/spi/spi-fsl-spi.c
++++ b/drivers/spi/spi-fsl-spi.c
+@@ -425,16 +425,16 @@ static int fsl_spi_setup(struct spi_devi
+ struct fsl_spi_reg *reg_base;
+ int retval;
+ u32 hw_mode;
+- struct spi_mpc8xxx_cs *cs = spi->controller_state;
++ struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
+
+ if (!spi->max_speed_hz)
+ return -EINVAL;
+
+ if (!cs) {
+- cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
++ cs = kzalloc(sizeof(*cs), GFP_KERNEL);
+ if (!cs)
+ return -ENOMEM;
+- spi->controller_state = cs;
++ spi_set_ctldata(spi, cs);
+ }
+ mpc8xxx_spi = spi_master_get_devdata(spi->master);
+
+@@ -496,9 +496,13 @@ static int fsl_spi_setup(struct spi_devi
+ static void fsl_spi_cleanup(struct spi_device *spi)
+ {
+ struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
++ struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
+
+ if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio))
+ gpio_free(spi->cs_gpio);
++
++ kfree(cs);
++ spi_set_ctldata(spi, NULL);
+ }
+
+ static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
--- /dev/null
+From f2a08b404691ef3e7be6ce81c185335cfc68b6db Mon Sep 17 00:00:00 2001
+From: Qipan Li <Qipan.Li@csr.com>
+Date: Tue, 2 Sep 2014 17:01:03 +0800
+Subject: spi: sirf: enable RX_IO_DMA_INT interrupt
+
+From: Qipan Li <Qipan.Li@csr.com>
+
+commit f2a08b404691ef3e7be6ce81c185335cfc68b6db upstream.
+
+in spi interrupt handler, we need check RX_IO_DMA status to ensure
+rx fifo have received the specify count data.
+
+if not set, the while statement in spi isr function will keep loop,
+at last, make the kernel hang.
+
+[The code is actually there in the interrupt handler but apparently it
+needs the interrupt unmasking so the handler sees the status -- broonie]
+
+Signed-off-by: Qipan Li <Qipan.Li@csr.com>
+Signed-off-by: Barry Song <Baohua.Song@csr.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/spi/spi-sirf.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/spi/spi-sirf.c
++++ b/drivers/spi/spi-sirf.c
+@@ -438,7 +438,8 @@ static void spi_sirfsoc_pio_transfer(str
+ sspi->tx_word(sspi);
+ writel(SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN |
+ SIRFSOC_SPI_TX_UFLOW_INT_EN |
+- SIRFSOC_SPI_RX_OFLOW_INT_EN,
++ SIRFSOC_SPI_RX_OFLOW_INT_EN |
++ SIRFSOC_SPI_RX_IO_DMA_INT_EN,
+ sspi->base + SIRFSOC_SPI_INT_EN);
+ writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN,
+ sspi->base + SIRFSOC_SPI_TX_RX_EN);
--- /dev/null
+From 766a53d059d1500c9755c8af017bd411bd8f1b20 Mon Sep 17 00:00:00 2001
+From: Alex Deucher <alexander.deucher@amd.com>
+Date: Fri, 12 Sep 2014 17:51:29 -0400
+Subject: vgaswitcheroo: add vga_switcheroo_fini_domain_pm_ops
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Alex Deucher <alexander.deucher@amd.com>
+
+commit 766a53d059d1500c9755c8af017bd411bd8f1b20 upstream.
+
+Drivers should call this on unload to unregister pmops.
+
+Bug:
+https://bugzilla.kernel.org/show_bug.cgi?id=84431
+
+Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
+Cc: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/vga/vga_switcheroo.c | 6 ++++++
+ include/linux/vga_switcheroo.h | 2 ++
+ 2 files changed, 8 insertions(+)
+
+--- a/drivers/gpu/vga/vga_switcheroo.c
++++ b/drivers/gpu/vga/vga_switcheroo.c
+@@ -660,6 +660,12 @@ int vga_switcheroo_init_domain_pm_ops(st
+ }
+ EXPORT_SYMBOL(vga_switcheroo_init_domain_pm_ops);
+
++void vga_switcheroo_fini_domain_pm_ops(struct device *dev)
++{
++ dev->pm_domain = NULL;
++}
++EXPORT_SYMBOL(vga_switcheroo_fini_domain_pm_ops);
++
+ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
+ {
+ struct pci_dev *pdev = to_pci_dev(dev);
+--- a/include/linux/vga_switcheroo.h
++++ b/include/linux/vga_switcheroo.h
+@@ -64,6 +64,7 @@ int vga_switcheroo_get_client_state(stru
+ void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
+
+ int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
++void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
+ int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
+ #else
+
+@@ -82,6 +83,7 @@ static inline int vga_switcheroo_get_cli
+ static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
+
+ static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
++static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
+ static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
+
+ #endif