--- /dev/null
+From e85843bec6c2ea7c10ec61238396891cc2b753a9 Mon Sep 17 00:00:00 2001
+From: Kamal Mostafa <kamal@canonical.com>
+Date: Fri, 19 Jul 2013 15:02:01 -0700
+Subject: drm/i915: quirk no PCH_PWM_ENABLE for Dell XPS13 backlight
+
+From: Kamal Mostafa <kamal@canonical.com>
+
+commit e85843bec6c2ea7c10ec61238396891cc2b753a9 upstream.
+
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=47941
+BugLink: https://bugs.launchpad.net/bugs/1163720
+BugLink: https://bugs.launchpad.net/bugs/1162026
+
+Some machines suffer from non-functional backlight controls if
+BLM_PCH_PWM_ENABLE is set, so provide a quirk to avoid doing so.
+Apply this quirk to Dell XPS 13 models.
+
+[ kamal: backport to 3.4 ]
+
+Tested-by: Eric Griffith <EGriffith92@gmail.com>
+Tested-by: Kent Baxley <kent.baxley@canonical.com>
+Signed-off-by: Kamal Mostafa <kamal@canonical.com>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/i915_drv.h | 1 +
+ drivers/gpu/drm/i915/intel_display.c | 16 ++++++++++++++++
+ drivers/gpu/drm/i915/intel_lvds.c | 3 ++-
+ 3 files changed, 19 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/i915/i915_drv.h
++++ b/drivers/gpu/drm/i915/i915_drv.h
+@@ -296,6 +296,7 @@ enum intel_pch {
+
+ #define QUIRK_PIPEA_FORCE (1<<0)
+ #define QUIRK_LVDS_SSC_DISABLE (1<<1)
++#define QUIRK_NO_PCH_PWM_ENABLE (1<<2)
+
+ struct intel_fbdev;
+ struct intel_fbc_work;
+--- a/drivers/gpu/drm/i915/intel_display.c
++++ b/drivers/gpu/drm/i915/intel_display.c
+@@ -9160,6 +9160,17 @@ static void quirk_ssc_force_disable(stru
+ dev_priv->quirks |= QUIRK_LVDS_SSC_DISABLE;
+ }
+
++/*
++ * Some machines (Dell XPS13) suffer broken backlight controls if
++ * BLM_PCH_PWM_ENABLE is set.
++ */
++static void quirk_no_pcm_pwm_enable(struct drm_device *dev)
++{
++ struct drm_i915_private *dev_priv = dev->dev_private;
++ dev_priv->quirks |= QUIRK_NO_PCH_PWM_ENABLE;
++ DRM_INFO("applying no-PCH_PWM_ENABLE quirk\n");
++}
++
+ struct intel_quirk {
+ int device;
+ int subsystem_vendor;
+@@ -9192,6 +9203,11 @@ struct intel_quirk intel_quirks[] = {
+
+ /* Sony Vaio Y cannot use SSC on LVDS */
+ { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable },
++
++ /* Dell XPS13 HD Sandy Bridge */
++ { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable },
++ /* Dell XPS13 HD and XPS13 FHD Ivy Bridge */
++ { 0x0166, 0x1028, 0x058b, quirk_no_pcm_pwm_enable },
+ };
+
+ static void intel_init_quirks(struct drm_device *dev)
+--- a/drivers/gpu/drm/i915/intel_lvds.c
++++ b/drivers/gpu/drm/i915/intel_lvds.c
+@@ -1097,7 +1097,8 @@ bool intel_lvds_init(struct drm_device *
+ goto failed;
+
+ out:
+- if (HAS_PCH_SPLIT(dev)) {
++ if (HAS_PCH_SPLIT(dev) &&
++ !(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) {
+ u32 pwm;
+
+ pipe = (I915_READ(PCH_LVDS) & LVDS_PIPEB_SELECT) ? 1 : 0;
--- /dev/null
+From 9c5da09d266ca9b32eb16cf940f8161d949c2fe5 Mon Sep 17 00:00:00 2001
+From: Salman Qazi <sqazi@google.com>
+Date: Thu, 14 Jun 2012 15:31:09 -0700
+Subject: perf: Use css_tryget() to avoid propping up css refcount
+
+From: Salman Qazi <sqazi@google.com>
+
+commit 9c5da09d266ca9b32eb16cf940f8161d949c2fe5 upstream.
+
+An rmdir pushes css's ref count to zero. However, if the associated
+directory is open at the time, the dentry ref count is non-zero. If
+the fd for this directory is then passed into perf_event_open, it
+does a css_get(). This bounces the ref count back up from zero. This
+is a problem by itself. But what makes it turn into a crash is the
+fact that we end up doing an extra dput, since we perform a dput
+when css_put sees the ref count go down to zero.
+
+css_tryget() does not fall into that trap. So, we use that instead.
+
+Reproduction test-case for the bug:
+
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <linux/unistd.h>
+ #include <linux/perf_event.h>
+ #include <string.h>
+ #include <errno.h>
+ #include <stdio.h>
+
+ #define PERF_FLAG_PID_CGROUP (1U << 2)
+
+ int perf_event_open(struct perf_event_attr *hw_event_uptr,
+ pid_t pid, int cpu, int group_fd, unsigned long flags) {
+ return syscall(__NR_perf_event_open,hw_event_uptr, pid, cpu,
+ group_fd, flags);
+ }
+
+ /*
+ * Directly poke at the perf_event bug, since it's proving hard to repro
+ * depending on where in the kernel tree. what moved?
+ */
+ int main(int argc, char **argv)
+ {
+ int fd;
+ struct perf_event_attr attr;
+ memset(&attr, 0, sizeof(attr));
+ attr.exclude_kernel = 1;
+ attr.size = sizeof(attr);
+ mkdir("/dev/cgroup/perf_event/blah", 0777);
+ fd = open("/dev/cgroup/perf_event/blah", O_RDONLY);
+ perror("open");
+ rmdir("/dev/cgroup/perf_event/blah");
+ sleep(2);
+ perf_event_open(&attr, fd, 0, -1, PERF_FLAG_PID_CGROUP);
+ perror("perf_event_open");
+ close(fd);
+ return 0;
+ }
+
+Signed-off-by: Salman Qazi <sqazi@google.com>
+Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Acked-by: Tejun Heo <tj@kernel.org>
+Link: http://lkml.kernel.org/r/20120614223108.1025.2503.stgit@dungbeetle.mtv.corp.google.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Cc: Li Zefan <lizefan@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/events/core.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+--- a/kernel/events/core.c
++++ b/kernel/events/core.c
+@@ -250,9 +250,9 @@ perf_cgroup_match(struct perf_event *eve
+ return !event->cgrp || event->cgrp == cpuctx->cgrp;
+ }
+
+-static inline void perf_get_cgroup(struct perf_event *event)
++static inline bool perf_tryget_cgroup(struct perf_event *event)
+ {
+- css_get(&event->cgrp->css);
++ return css_tryget(&event->cgrp->css);
+ }
+
+ static inline void perf_put_cgroup(struct perf_event *event)
+@@ -481,7 +481,11 @@ static inline int perf_cgroup_connect(in
+ event->cgrp = cgrp;
+
+ /* must be done before we fput() the file */
+- perf_get_cgroup(event);
++ if (!perf_tryget_cgroup(event)) {
++ event->cgrp = NULL;
++ ret = -ENOENT;
++ goto out;
++ }
+
+ /*
+ * all events in a group must monitor
sched-fix-the-broken-sched_rr_get_interval.patch
fanotify-info-leak-in-copy_event_to_user.patch
perf-fix-event-group-context-move.patch
+x86-fpu-correct-the-asm-constraints-for-fxsave-unbreak-mxcsr.daz.patch
+drm-i915-quirk-no-pch_pwm_enable-for-dell-xps13-backlight.patch
+perf-use-css_tryget-to-avoid-propping-up-css-refcount.patch
--- /dev/null
+From eaa5a990191d204ba0f9d35dbe5505ec2cdd1460 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Fri, 26 Jul 2013 09:11:56 -0700
+Subject: x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz
+
+From: "H.J. Lu" <hjl.tools@gmail.com>
+
+commit eaa5a990191d204ba0f9d35dbe5505ec2cdd1460 upstream.
+
+GCC will optimize mxcsr_feature_mask_init in arch/x86/kernel/i387.c:
+
+ memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
+ asm volatile("fxsave %0" : : "m" (fx_scratch));
+ mask = fx_scratch.mxcsr_mask;
+ if (mask == 0)
+ mask = 0x0000ffbf;
+
+to
+
+ memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
+ asm volatile("fxsave %0" : : "m" (fx_scratch));
+ mask = 0x0000ffbf;
+
+since asm statement doesn’t say it will update fx_scratch. As the
+result, the DAZ bit will be cleared. This patch fixes it. This bug
+dates back to at least kernel 2.6.12.
+
+Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/i387.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/x86/kernel/i387.c
++++ b/arch/x86/kernel/i387.c
+@@ -132,7 +132,7 @@ static void __cpuinit mxcsr_feature_mask
+ clts();
+ if (cpu_has_fxsr) {
+ memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
+- asm volatile("fxsave %0" : : "m" (fx_scratch));
++ asm volatile("fxsave %0" : "+m" (fx_scratch));
+ mask = fx_scratch.mxcsr_mask;
+ if (mask == 0)
+ mask = 0x0000ffbf;