diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix
index adc05f60231..9e7cfbd686c 100644
--- a/nixos/modules/config/networking.nix
+++ b/nixos/modules/config/networking.nix
@@ -57,7 +57,7 @@ in
 
     networking.dnsExtensionMechanism = lib.mkOption {
       type = types.bool;
-      default = false;
+      default = true;
       description = ''
         Enable the <code>edns0</code> option in <filename>resolv.conf</filename>. With
         that option set, <code>glibc</code> supports use of the extension mechanisms for
diff --git a/pkgs/applications/misc/subsurface/default.nix b/pkgs/applications/misc/subsurface/default.nix
index a4aef9def60..06b367fa6e7 100644
--- a/pkgs/applications/misc/subsurface/default.nix
+++ b/pkgs/applications/misc/subsurface/default.nix
@@ -24,9 +24,9 @@ stdenv.mkDerivation rec {
   name = "subsurface-${version}";
 
   src = fetchgit {
-    sha256 = "0mbf8m5sbimbyvlh65sjlydrycr4ssfyfzdlqyl0wcpzw7h0qfp8";
+    sha256 = "035ywhicadmr9sh7zhfxsvpchwa9sywccacbspfam39n2hpyqnmm";
     url = "git://git.subsurface-divelog.org/subsurface";
-    rev = "5f15ad5a86ada3c5e574041a5f9d85235322dabb";
+    rev = "72bcb6481f3b935444d7868a74599dda133f9b43";
     branchName = "master";
   };
 
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix
index d199ea3ece3..8ae86eed02c 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix
@@ -73,7 +73,7 @@ let
 in
 stdenv.mkDerivation rec {
   name = "flashplayer-${version}";
-  version = "24.0.0.186";
+  version = "24.0.0.194";
 
   src = fetchurl {
     url =
@@ -84,14 +84,14 @@ stdenv.mkDerivation rec {
     sha256 =
       if debug then
         if arch == "x86_64" then
-          "0i7c861n42vb2zd9hnp26lxjakkv0fxp53smcwzc9xhdbjr14ail"
+          "197s3ksx6h3dkfx8q7v9c8mf8ai9s1jpqnaczjdkmzcyp5jd29w9"
         else
-          "0gj59iinh8gbjm5bn24qi3niyvi8x6byyc1sa6qvqkvjwh1ckdi3"
+          "0ll0ddss3gkzngmm96pyvnf4a6mf8axraxlqpjdl63ghrndd1gkc"
       else
         if arch == "x86_64" then
-          "0qs6hx31p1q2zqsr8jcf7niwsp6nncpqs3igb6l9f9fi0a8va8f7"
+          "0bri8kjqy9g929ix4qx4whmxz5rzbgjff253kvs6dlr8vyglz0gx"
         else
-          "1zcinq7629bgbashx25krby8r91sag2v8382q620951iiww06n1v";
+          "1lrfwwhl18411bk9qsizhch8n3ilcvhmj4i7sak5zjv5r6mwnqgl";
   };
 
   nativeBuildInputs = [ unzip ];
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/standalone.nix b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/standalone.nix
index c9de87f1b25..be33cf139d2 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/standalone.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/standalone.nix
@@ -57,7 +57,7 @@ let
 in
 stdenv.mkDerivation rec {
   name = "flashplayer-standalone-${version}";
-  version = "24.0.0.186";
+  version = "24.0.0.194";
 
   src = fetchurl {
     url =
@@ -67,9 +67,9 @@ stdenv.mkDerivation rec {
         "https://fpdownload.macromedia.com/pub/flashplayer/updaters/24/flash_player_sa_linux.x86_64.tar.gz";
     sha256 =
       if debug then
-        "09653jphzijk3w3dcd05f4pya1ciaymna31qqrmcwhxa0ginxhz2"
+        "0yiln97l8b27s5c6nv9m09cdgwa4c47idnf2p6y6i0slfcqj1cxv"
       else
-        "0q0wc2lgjzi1v4lpcr5x5nszigli3vsryfq2zk4qq4pqy3i6aq7q";
+        "1f34qm8grj3141p6kym6y2pqisrmn9l6nkhbfmfhsd472g5q85v1";
   };
 
   nativeBuildInputs = [ unzip ];
diff --git a/pkgs/applications/networking/cluster/terragrunt/default.nix b/pkgs/applications/networking/cluster/terragrunt/default.nix
new file mode 100644
index 00000000000..e4a267ec1b5
--- /dev/null
+++ b/pkgs/applications/networking/cluster/terragrunt/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub, terraform, makeWrapper }:
+
+buildGoPackage rec {
+  name = "terragrunt-${version}";
+  version = "0.8.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/gruntwork-io/terragrunt";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner  = "gruntwork-io";
+    repo   = "terragrunt";
+    sha256 = "1d035p2r6d8c1crxvpi5ayb9jx6f2pdgzw2197zhllavyi8n8dw1";
+  };
+
+  goDeps = ./deps.nix;
+
+  buildInputs = [ makeWrapper terraform ];
+
+  postInstall = ''
+    wrapProgram $bin/bin/terragrunt \
+      --suffix PATH : ${lib.makeBinPath [ terraform ]}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A thin wrapper for Terraform that supports locking for Terraform state and enforces best practices.";
+    homepage = https://github.com/gruntwork-io/terragrunt/;
+    license = licenses.mit;
+    maintainers = with maintainers; [ peterhoeg ];
+  };
+}
diff --git a/pkgs/applications/networking/cluster/terragrunt/deps.nix b/pkgs/applications/networking/cluster/terragrunt/deps.nix
new file mode 100644
index 00000000000..ba1ac2b6a1e
--- /dev/null
+++ b/pkgs/applications/networking/cluster/terragrunt/deps.nix
@@ -0,0 +1,66 @@
+# This file was generated by go2nix.
+[
+  {
+    goPackagePath = "github.com/aws/aws-sdk-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/aws/aws-sdk-go";
+      rev = "8649d278323ebf6bd20c9cd56ecb152b1c617375";
+      sha256 = "0m2nxdlvi90vw68ds9qby291skc5d0dgqi3pkalr8ma3kd9r9khv";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-errors/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-errors/errors";
+      rev = "8fa88b06e5974e97fbf9899a7f86a344bfd1f105";
+      sha256 = "02mvb2clbmfcqb4yclv5zhs4clkk9jxi2hiawsynl5fwmgn0d3xa";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/hcl";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/hcl";
+      rev = "eb6f65b2d77ed5078887f960ff570fbddbbeb49d";
+      sha256 = "1wx6hpxmq5sby54025j9hliz10gv5v0bq6q1z2cd0asznj154ij1";
+    };
+  }
+  {
+    goPackagePath = "github.com/mattn/go-zglob";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mattn/go-zglob";
+      rev = "0b24567ec079616e9897f635f542e3bf56abb3d0";
+      sha256 = "0380dqsy0qdjranl5qfmmcr6a4g7sw4z26g1bld9y1s66madl03l";
+    };
+  }
+  {
+    goPackagePath = "github.com/mitchellh/mapstructure";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mitchellh/mapstructure";
+      rev = "bfdb1a85537d60bc7e954e600c250219ea497417";
+      sha256 = "141kkh801jyp1r6hba14krydqg1iivp13j12is70j0g05z9fbji8";
+    };
+  }
+  {
+    goPackagePath = "github.com/stretchr/testify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stretchr/testify";
+      rev = "2402e8e7a02fc811447d11f881aa9746cdc57983";
+      sha256 = "01qaz781cvrv3h1428xqq8knf5ahdcj93m5k9dnivg2hcrlnqibj";
+    };
+  }
+  {
+    goPackagePath = "github.com/urfave/cli";
+    fetch = {
+      type = "git";
+      url = "https://github.com/urfave/cli";
+      rev = "8ef3805c9de2519805c3f060524b695bba2cd715";
+      sha256 = "0680rd87skmz8p8s3cwy55siz4bgjls314agfi03d7640gz7mp24";
+    };
+  }
+]
diff --git a/pkgs/applications/networking/insync/default.nix b/pkgs/applications/networking/insync/default.nix
index a0b727a97f8..86cc9bded10 100644
--- a/pkgs/applications/networking/insync/default.nix
+++ b/pkgs/applications/networking/insync/default.nix
@@ -31,6 +31,8 @@ stdenv.mkDerivation rec {
      computer.  It has more advanced features than Google's official client
      such as multiple account support, Google Doc conversion, symlink support,
      and built in sharing.
+
+     There is a 15-day free trial, and it is a paid application after that.
     '';
   };
 }
diff --git a/pkgs/applications/version-management/git-and-tools/hub/default.nix b/pkgs/applications/version-management/git-and-tools/hub/default.nix
index 98999e93db7..5c70b2cb205 100644
--- a/pkgs/applications/version-management/git-and-tools/hub/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/hub/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "hub-${version}";
-  version = "2.2.8";
+  version = "2.2.9";
 
   src = fetchgit {
     url = https://github.com/github/hub.git;
     rev = "refs/tags/v${version}";
-    sha256 = "1fv4jb9vsbkscnb79gss2mwnd1yf9jhgzw1mhimhx25xizbx1fck";
+    sha256 = "195ckp1idz2azv0mm1q258yjz2n51sia9xdcjnqlprmq9aig5ldh";
   };
 
 
diff --git a/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix b/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix
index 9ab6f7a1089..a1f289f5f2b 100644
--- a/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix
+++ b/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix
@@ -61,13 +61,9 @@ stdenv.mkDerivation {
         fi
     done
 
-    ln -s "$env/share" "$out"
-
+    mkdir -p "$out/nix-support"
     for drv in $unwrapped; do
-        if [ -a "$drv/nix-support/propagated-user-env-packages" ]; then
-            mkdir -p "$out/nix-support"
-            cat "$drv/nix-support/propagated-user-env-packages" >> "$out/nix-support/propagated-user-env-packages"
-        fi
+        echo "$drv" >> "$out/nix-support/propagated-user-env-packages"
     done
   '';
 }
diff --git a/pkgs/development/ruby-modules/bundler/default.nix b/pkgs/development/ruby-modules/bundler/default.nix
index 8f128001235..1b4fa285142 100644
--- a/pkgs/development/ruby-modules/bundler/default.nix
+++ b/pkgs/development/ruby-modules/bundler/default.nix
@@ -4,8 +4,8 @@ buildRubyGem rec {
   inherit ruby;
   name = "${gemName}-${version}";
   gemName = "bundler";
-  version = "1.13.6";
-  sha256 = "1xyhy9cn8w9passp64p6hb3df2fpiqbds6rj7xha1335xpgj5zgs";
+  version = "1.13.7";
+  sha256 = "1avvvdzw0k5k2m5n79b96nkmdfd0sjamc676fz7asz4prz2wiw59";
   dontPatchShebangs = true;
 
   postFixup = ''
diff --git a/pkgs/development/tools/jid/default.nix b/pkgs/development/tools/jid/default.nix
index e77921c5437..9c52ac61551 100644
--- a/pkgs/development/tools/jid/default.nix
+++ b/pkgs/development/tools/jid/default.nix
@@ -3,8 +3,8 @@
 
 buildGoPackage rec {
   name = "jid-${version}";
-  version = "0.6.1";
-  rev = "0.6.1";
+  version = "0.7.1";
+  rev = "${version}";
 
   goPackagePath = "github.com/simeji/jid";
 
@@ -12,7 +12,7 @@ buildGoPackage rec {
     owner = "simeji";
     repo = "jid";
     inherit rev;
-    sha256 = "0hnda2nqgirwbqbzq38kbl83cr0kn7hxsh4wim4fwwla0hs2nwjg";
+    sha256 = "08snlqqch91w88zysfcavmqsafq93zzpkdjqkq1y7hx516fdaz1w";
   };
 
   goDeps = ./deps.nix;
diff --git a/pkgs/development/tools/jid/deps.nix b/pkgs/development/tools/jid/deps.nix
index 4bc32247c08..c3ec502b2a9 100644
--- a/pkgs/development/tools/jid/deps.nix
+++ b/pkgs/development/tools/jid/deps.nix
@@ -9,6 +9,33 @@
       sha256 = "0n9f9dz1jn1jx86d48569nznpjn9fmq3knn7r65xpy7jhih284jj";
     };
   }
+  {
+    goPackagePath = "github.com/fatih/color";
+    fetch = {
+      type = "git";
+      url = "https://github.com/fatih/color";
+      rev = "e8e01ee22a7d4a91b49646e39245fe08e69c7878";
+      sha256 = "1660g29qhshk6zxhpnc0f52m69jdqqdw2ccbkqw9y4kilnripfvl";
+    };
+  }
+  {
+    goPackagePath = "github.com/mattn/go-colorable";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mattn/go-colorable";
+      rev = "d228849504861217f796da67fae4f6e347643f15";
+      sha256 = "0ch5sfcpmqczsh8kjbwpzdw31lacbkfyzvpzh4disnhhydbxjq0d";
+    };
+  }
+  {
+    goPackagePath = "github.com/mattn/go-isatty";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mattn/go-isatty";
+      rev = "30a891c33c7cde7b02a981314b4228ec99380cca";
+      sha256 = "03gsxn89pgkj4jkxm9avnj4f0ckvcskc6fj2lcd98l3akrz50ndg";
+    };
+  }
   {
     goPackagePath = "github.com/mattn/go-runewidth";
     fetch = {
@@ -23,8 +50,17 @@
     fetch = {
       type = "git";
       url = "https://github.com/nsf/termbox-go";
-      rev = "0b413bfa31e8c6843db20dce4454566b1951709e";
-      sha256 = "1n45cq3p7z5533bmsqj3a0xvp7c8ncb52k3l8zqvd37f34zpsyxb";
+      rev = "abe82ce5fb7a42fbd6784a5ceb71aff977e09ed8";
+      sha256 = "156i8apkga8b3272kjhapyqwspgcfkrr9kpqwc5lii43k4swghpv";
+    };
+  }
+  {
+    goPackagePath = "github.com/nwidger/jsoncolor";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nwidger/jsoncolor";
+      rev = "0192e84d44af834c3a90c8a17bf670483b91ad5a";
+      sha256 = "17mndgd1d233c22bd19xv4v2l2i5k8kz7y6n4n54a9i7fi9d10al";
     };
   }
   {
diff --git a/pkgs/development/tools/misc/universal-ctags/default.nix b/pkgs/development/tools/misc/universal-ctags/default.nix
index b4710cc8406..903359f5c76 100644
--- a/pkgs/development/tools/misc/universal-ctags/default.nix
+++ b/pkgs/development/tools/misc/universal-ctags/default.nix
@@ -2,17 +2,20 @@
 
 stdenv.mkDerivation rec {
   name = "universal-ctags-${version}";
-  version = "2016-12-17";
+  version = "2017-01-08";
 
   src = fetchFromGitHub {
     owner = "universal-ctags";
     repo = "ctags";
-    rev = "3093f73e81cddbea5d122dccd4fd9a6323ebbbd3";
-    sha256 = "091359v3p865d39gchpc1x5qplf1s1y4nsph344ng5x1nkx44qsi";
+    rev = "9668032d8715265ca5b4ff16eb2efa8f1c450883";
+    sha256 = "0nwcf5mh3ba0g23zw7ym73pgpfdass412k2fy67ryr9vnc709jkj";
   };
 
   buildInputs = [ autoreconfHook pkgconfig ];
 
+  # remove when https://github.com/universal-ctags/ctags/pull/1267 is merged
+  patches = [ ./sed-test.patch ];
+
   autoreconfPhase = ''
     ./autogen.sh --tmpdir
   '';
diff --git a/pkgs/development/tools/misc/universal-ctags/sed-test.patch b/pkgs/development/tools/misc/universal-ctags/sed-test.patch
new file mode 100644
index 00000000000..7c44d699d79
--- /dev/null
+++ b/pkgs/development/tools/misc/universal-ctags/sed-test.patch
@@ -0,0 +1,12 @@
+--- a/Tmain/sorted-help-message.d/run.sh	2017-01-10 11:20:51.515093465 +0100
++++ b/Tmain/sorted-help-message.d/run.sh	2017-01-10 11:17:56.639213720 +0100
+@@ -27,7 +27,7 @@
+ extract_long_options()
+ {
+     sed -n '/Usage:/,$p'  | \
+-    sed -n 's/\(^  --[:alnum:][<>[:alnum:]_-]*\).*/\1/p'
++    sed -n 's/\(^  --[[:alnum:]][<>[:alnum:]_-]*\).*/\1/p'
+ }
+
+ extract_debug_options()
+
diff --git a/pkgs/os-specific/linux/amdgpu-pro/default.nix b/pkgs/os-specific/linux/amdgpu-pro/default.nix
index 4a0527242c7..cbfa2e1b030 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/default.nix
+++ b/pkgs/os-specific/linux/amdgpu-pro/default.nix
@@ -30,9 +30,9 @@ let
 
 in stdenv.mkDerivation rec {
 
-  version = "16.40";
+  version = "16.50";
   pname = "amdgpu-pro";
-  build = "16.40-348864";
+  build = "${version}-362463";
 
   libCompatDir = "/run/lib/${libArch}";
 
@@ -41,7 +41,7 @@ in stdenv.mkDerivation rec {
   src = fetchurl {
     url =
     "https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-${build}.tar.xz";
-    sha256 = "1c06lx07irmlpmbmgb3qcgpzj6q6rimszrbbdrgz8kqnfpcv3mjr";
+    sha256 = "1wl8mabk9g7s43bdarzl2i5crp8rl1advnb5mw3p3821sqzh2nd9";
     curlOpts = "--referer http://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%e2%80%93Release-Notes.aspx";
   };
 
@@ -58,20 +58,18 @@ in stdenv.mkDerivation rec {
   '';
 
   modulePatches = [
-    ./patches/0001-Find-correct-System.map.patch
-    ./patches/0002-Fix-kernel-module-install-location.patch
-    ./patches/0003-Add-Gentoo-as-build-option.patch
-    ./patches/0004-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
-    ./patches/0005-Remove-first-param-from-drm_gem_object_lookup.patch
-    ./patches/0006-Remove-vblank_disable_allowed-assignment.patch
-    ./patches/0007-Fix-__drm_atomic_helper_connector_destroy_state-call.patch
-    ./patches/0008-Change-seq_printf-format-for-64-bit-context.patch
-    ./patches/0009-Fix-vblank-calls.patch
-    ./patches/0010-Fix-crtc_gamma-functions-for-4.8.0.patch
-    ./patches/0011-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
-    ./patches/0012-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
-    ./patches/0013-Remove-dependency-on-System.map.patch
-    ./patches/0014-disable-dal-by-default.patch
+    ./patches/0001-Fix-kernel-module-install-location.patch
+    ./patches/0002-Add-Gentoo-as-build-option.patch
+    ./patches/0003-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
+    ./patches/0004-Change-seq_printf-format-for-64-bit-context.patch
+    ./patches/0005-Fix-vblank-calls.patch
+    ./patches/0006-Fix-crtc_gamma-functions-for-4.8.0.patch
+    ./patches/0007-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
+    ./patches/0008-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
+    ./patches/0009-Remove-dependency-on-System.map.patch
+    ./patches/0010-disable-dal-by-default.patch
+    ./patches/0011-kcl-fixes-for-16.50-linux-4.8.patch
+    ./patches/0012-use-kernel-fence_array-in-4.8.patch
   ];
 
   patchPhase = optionalString (!libsOnly) ''
@@ -137,7 +135,6 @@ in stdenv.mkDerivation rec {
       patchelf --interpreter "$interpreter" --set-rpath "$libPath" "$out/bin/$prog"
     done
   '' + ''
-    ln -s libgbm.so.1.0.0 $out/lib/libgbm.so.1
     ln -s ${makeLibraryPath [ncurses5]}/libncursesw.so.5 $out/lib/libtinfo.so.5
   '';
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0001-Find-correct-System.map.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0001-Find-correct-System.map.patch
deleted file mode 100644
index 2a086cf37bc..00000000000
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0001-Find-correct-System.map.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 4243cf67bcdf8c3865efbfe19dc8841c88ab2daa Mon Sep 17 00:00:00 2001
-From: "Luke A. Guest" <laguest@archeia.com>
-Date: Sun, 25 Sep 2016 15:30:26 +0100
-Subject: [PATCH 01/14] Find correct System.map
-
----
- pre-build.sh | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/pre-build.sh b/pre-build.sh
-index 95457bd..169ccf0 100755
---- a/pre-build.sh
-+++ b/pre-build.sh
-@@ -27,7 +27,7 @@ source amd/backport/symbols
- 
- echo '// auto generated by DKMS pre-build.sh' > amd/backport/symbols.c
- for sym in $SYMS; do
--    addr=$(grep $sym /boot/System.map-$KERNELVER | awk -F' ' '{print $1}')
-+    addr=$(grep $sym /boot/System.map*-$KERNELVER | awk -F' ' '{print $1}')
-     echo "void *$sym = (void *)0x$addr;" >> amd/backport/symbols.c
- done
- 
--- 
-2.10.1
-
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0002-Fix-kernel-module-install-location.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0001-Fix-kernel-module-install-location.patch
similarity index 65%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0002-Fix-kernel-module-install-location.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0001-Fix-kernel-module-install-location.patch
index be886883556..5af823a9394 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0002-Fix-kernel-module-install-location.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0001-Fix-kernel-module-install-location.patch
@@ -1,25 +1,25 @@
-From c1860b4e8c2ebb784a07d6ba067c510950e67d24 Mon Sep 17 00:00:00 2001
+From e787277fd4f43399de2da355b08e478c2a58d589 Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 15:31:13 +0100
-Subject: [PATCH 02/14] Fix kernel module install location
+Subject: [PATCH 01/11] Fix kernel module install location
 
 ---
  dkms.conf | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/dkms.conf b/dkms.conf
-index d1a5e1d..0e03f08 100644
+index 7f11158..2f080e2 100644
 --- a/dkms.conf
 +++ b/dkms.conf
 @@ -2,7 +2,7 @@ PACKAGE_NAME="amdgpu-pro"
- PACKAGE_VERSION="16.40-348864"
+ PACKAGE_VERSION="16.50-362463"
  BUILT_MODULE_NAME[0]="amdgpu"
  BUILT_MODULE_LOCATION[0]="amd/amdgpu"
--DEST_MODULE_LOCATION[0]="/extra"
+-DEST_MODULE_LOCATION[0]="/updates"
 +DEST_MODULE_LOCATION[0]="/kernel/drivers/gpu/drm/amd/amdgpu"
  AUTOINSTALL="yes"
  PRE_BUILD="pre-build.sh $kernelver"
- REMAKE_INITRD="yes"
+ 
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0003-Add-Gentoo-as-build-option.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0002-Add-Gentoo-as-build-option.patch
similarity index 62%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0003-Add-Gentoo-as-build-option.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0002-Add-Gentoo-as-build-option.patch
index d8b0f289d84..be627992c06 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0003-Add-Gentoo-as-build-option.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0002-Add-Gentoo-as-build-option.patch
@@ -1,20 +1,20 @@
-From c26c7670869e02c39c0d0f6dee9094a621f42252 Mon Sep 17 00:00:00 2001
+From da51551f671be3282b6f69ef76e495b169a5dc3f Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 15:31:49 +0100
-Subject: [PATCH 03/14] Add Gentoo as build option
+Subject: [PATCH 02/11] Add Gentoo as build option
 
 ---
  amd/backport/Makefile | 5 +++++
  1 file changed, 5 insertions(+)
 
 diff --git a/amd/backport/Makefile b/amd/backport/Makefile
-index 0c285ef..dcc94d5 100644
+index a6ab7fe..ff9339d 100644
 --- a/amd/backport/Makefile
 +++ b/amd/backport/Makefile
-@@ -17,8 +17,13 @@ else ifeq ("ubuntu",$(OS_NAME))
- ccflags-y += -DOS_NAME_UBUNTU
- else ifeq ("steamos",$(OS_NAME))
- ccflags-y += -DOS_NAME_STEAMOS
+@@ -22,8 +22,13 @@ else ifeq ("sled",$(OS_NAME))
+ ccflags-y += -DOS_NAME_SLE
+ else ifeq ("sles",$(OS_NAME))
+ ccflags-y += -DOS_NAME_SLE
 +else ifeq ("gentoo",$(OS_NAME))
 +ccflags-y += -DOS_NAME_GENTOO
 +# We don't have a version inside /etc/os-release.
@@ -26,5 +26,5 @@ index 0c285ef..dcc94d5 100644
  
  ccflags-y += \
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0004-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0003-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
similarity index 75%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0004-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0003-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
index 794da9b5fb7..ae5b62b1d23 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0004-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0003-Remove-extra-parameter-from-ttm_bo_reserve-for-4.7.0.patch
@@ -1,17 +1,17 @@
-From d21e811c6f26674a0e1c2398dce6d247a1dd4918 Mon Sep 17 00:00:00 2001
+From 999a30883f34c4603c3b747a58a89d4924583769 Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 15:46:58 +0100
-Subject: [PATCH 04/14] Remove extra parameter from ttm_bo_reserve for 4.7.0
+Subject: [PATCH 03/11] Remove extra parameter from ttm_bo_reserve for 4.7.0
 
 ---
  amd/backport/include/kcl/kcl_ttm.h | 4 ++++
  1 file changed, 4 insertions(+)
 
 diff --git a/amd/backport/include/kcl/kcl_ttm.h b/amd/backport/include/kcl/kcl_ttm.h
-index 05c444b..c5a602c 100644
+index 6e5a170..52cdbc8 100644
 --- a/amd/backport/include/kcl/kcl_ttm.h
 +++ b/amd/backport/include/kcl/kcl_ttm.h
-@@ -106,7 +106,11 @@ static inline int kcl_ttm_bo_reserve(struct ttm_buffer_object *bo,
+@@ -113,7 +113,11 @@ static inline int kcl_ttm_bo_reserve(struct ttm_buffer_object *bo,
  				 struct ww_acquire_ctx *ticket)
  {
  #if defined(BUILD_AS_DKMS)
@@ -24,5 +24,5 @@ index 05c444b..c5a602c 100644
  	return ttm_bo_reserve(bo, interruptible, no_wait, ticket);
  #endif
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0004-Change-seq_printf-format-for-64-bit-context.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0004-Change-seq_printf-format-for-64-bit-context.patch
new file mode 100644
index 00000000000..925a92e2a7e
--- /dev/null
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0004-Change-seq_printf-format-for-64-bit-context.patch
@@ -0,0 +1,25 @@
+From 084b2915e6876d8fdb913938569c0ce7ffef65bc Mon Sep 17 00:00:00 2001
+From: "Luke A. Guest" <laguest@archeia.com>
+Date: Sun, 25 Sep 2016 16:46:39 +0100
+Subject: [PATCH 04/11] Change seq_printf format for 64 bit context
+
+---
+ amd/amdgpu/amdgpu_sa.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/amd/amdgpu/amdgpu_sa.c b/amd/amdgpu/amdgpu_sa.c
+index 052f745..5886b9a 100644
+--- a/amd/amdgpu/amdgpu_sa.c
++++ b/amd/amdgpu/amdgpu_sa.c
+@@ -428,7 +428,7 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
+ 			   soffset, eoffset, eoffset - soffset);
+ 
+ 		if (i->fence)
+-#if defined(BUILD_AS_DKMS)
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
+ 			seq_printf(m, " protected by 0x%08x on context %d",
+ 				   i->fence->seqno, i->fence->context);
+ #else
+-- 
+2.11.0
+
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0009-Fix-vblank-calls.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0005-Fix-vblank-calls.patch
similarity index 68%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0009-Fix-vblank-calls.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0005-Fix-vblank-calls.patch
index 82db5905a45..99b54aca2ab 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0009-Fix-vblank-calls.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0005-Fix-vblank-calls.patch
@@ -1,18 +1,19 @@
-From 9da98ec93816277a2d4e93d3205da044bace08bc Mon Sep 17 00:00:00 2001
+From 1884ef3a813f3dac0029c7539654ba978635d5d3 Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 16:49:09 +0100
-Subject: [PATCH 09/14] Fix vblank calls
+Subject: [PATCH 05/11] Fix vblank calls
 
 ---
  amd/amdgpu/amdgpu_display.c   | 8 ++++++++
- amd/amdgpu/dce_v10_0.c        | 8 ++++++++
- amd/amdgpu/dce_v11_0.c        | 8 ++++++++
- amd/amdgpu/dce_v8_0.c         | 8 ++++++++
+ amd/amdgpu/dce_v10_0.c        | 4 ++++
+ amd/amdgpu/dce_v11_0.c        | 4 ++++
+ amd/amdgpu/dce_v8_0.c         | 4 ++++
+ amd/amdgpu/dce_virtual.c      | 8 ++++++++
  amd/dal/amdgpu_dm/amdgpu_dm.c | 4 ++++
- 5 files changed, 36 insertions(+)
+ 6 files changed, 32 insertions(+)
 
 diff --git a/amd/amdgpu/amdgpu_display.c b/amd/amdgpu/amdgpu_display.c
-index 862611c..267c65f 100644
+index 8425b1d..d6cd383 100644
 --- a/amd/amdgpu/amdgpu_display.c
 +++ b/amd/amdgpu/amdgpu_display.c
 @@ -268,7 +268,11 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
@@ -38,20 +39,12 @@ index 862611c..267c65f 100644
 +#endif
  
  pflip_cleanup:
- 	if (unlikely(amdgpu_bo_reserve(new_rbo, false) != 0)) {
+ 	if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) {
 diff --git a/amd/amdgpu/dce_v10_0.c b/amd/amdgpu/dce_v10_0.c
-index 0fd1e4f..5f0044c 100644
+index 650d193..b1880ac 100644
 --- a/amd/amdgpu/dce_v10_0.c
 +++ b/amd/amdgpu/dce_v10_0.c
-@@ -3372,11 +3372,19 @@ static int dce_v10_0_pageflip_irq(struct amdgpu_device *adev,
- 
- 	/* wakeup usersapce */
- 	if (works->event)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-+		drm_crtc_send_vblank_event(&amdgpu_crtc->base, works->event);
-+#else
- 		drm_send_vblank_event(adev->ddev, crtc_id, works->event);
-+#endif
+@@ -3342,7 +3342,11 @@ static int dce_v10_0_pageflip_irq(struct amdgpu_device *adev,
  
  	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
  
@@ -64,18 +57,10 @@ index 0fd1e4f..5f0044c 100644
  
  	return 0;
 diff --git a/amd/amdgpu/dce_v11_0.c b/amd/amdgpu/dce_v11_0.c
-index a85eb5f..8edc670 100644
+index ca03d8e..b654b64 100644
 --- a/amd/amdgpu/dce_v11_0.c
 +++ b/amd/amdgpu/dce_v11_0.c
-@@ -3432,11 +3432,19 @@ static int dce_v11_0_pageflip_irq(struct amdgpu_device *adev,
- 
- 	/* wakeup usersapce */
- 	if(works->event)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-+		drm_crtc_send_vblank_event(&amdgpu_crtc->base, works->event);
-+#else
- 		drm_send_vblank_event(adev->ddev, crtc_id, works->event);
-+#endif
+@@ -3391,7 +3391,11 @@ static int dce_v11_0_pageflip_irq(struct amdgpu_device *adev,
  
  	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
  
@@ -88,15 +73,31 @@ index a85eb5f..8edc670 100644
  
  	return 0;
 diff --git a/amd/amdgpu/dce_v8_0.c b/amd/amdgpu/dce_v8_0.c
-index 308f5e4..57e8014 100644
+index 8e4dff7..b598caa 100644
 --- a/amd/amdgpu/dce_v8_0.c
 +++ b/amd/amdgpu/dce_v8_0.c
-@@ -3323,11 +3323,19 @@ static int dce_v8_0_pageflip_irq(struct amdgpu_device *adev,
+@@ -3252,7 +3252,11 @@ static int dce_v8_0_pageflip_irq(struct amdgpu_device *adev,
+ 
+ 	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
++	drm_crtc_vblank_put(&amdgpu_crtc->base);
++#else
+ 	drm_vblank_put(adev->ddev, amdgpu_crtc->crtc_id);
++#endif
+ 	schedule_work(&works->unpin_work);
+ 
+ 	return 0;
+diff --git a/amd/amdgpu/dce_virtual.c b/amd/amdgpu/dce_virtual.c
+index 0c6e873..36e2094 100644
+--- a/amd/amdgpu/dce_virtual.c
++++ b/amd/amdgpu/dce_virtual.c
+@@ -746,11 +746,19 @@ static int dce_virtual_pageflip_irq(struct amdgpu_device *adev,
  
  	/* wakeup usersapce */
  	if (works->event)
 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-+		drm_crtc_send_vblank_event(&amdgpu_crtc->base, works->event);
++    drm_crtc_send_vblank_event(&amdgpu_crtc->base, works->event);
 +#else
  		drm_send_vblank_event(adev->ddev, crtc_id, works->event);
 +#endif
@@ -112,10 +113,10 @@ index 308f5e4..57e8014 100644
  
  	return 0;
 diff --git a/amd/dal/amdgpu_dm/amdgpu_dm.c b/amd/dal/amdgpu_dm/amdgpu_dm.c
-index 30865ec..f49999b 100644
+index c5fcf5a..e9892d8 100644
 --- a/amd/dal/amdgpu_dm/amdgpu_dm.c
 +++ b/amd/dal/amdgpu_dm/amdgpu_dm.c
-@@ -196,10 +196,14 @@ static void dm_pflip_high_irq(void *interrupt_params)
+@@ -213,10 +213,14 @@ static void dm_pflip_high_irq(void *interrupt_params)
  
  	/* wakeup usersapce */
  	if(works->event)
@@ -131,5 +132,5 @@ index 30865ec..f49999b 100644
  	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
  
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0005-Remove-first-param-from-drm_gem_object_lookup.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0005-Remove-first-param-from-drm_gem_object_lookup.patch
deleted file mode 100644
index 94cb3e72ed5..00000000000
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0005-Remove-first-param-from-drm_gem_object_lookup.patch
+++ /dev/null
@@ -1,196 +0,0 @@
-From 4ac701dce0a4139e89c80237fc4eaa65f48c6f07 Mon Sep 17 00:00:00 2001
-From: "Luke A. Guest" <laguest@archeia.com>
-Date: Sun, 25 Sep 2016 15:53:50 +0100
-Subject: [PATCH 05/14] Remove first param from drm_gem_object_lookup
-
----
- amd/amdgpu/amdgpu_bo_list.c         |  4 ++++
- amd/amdgpu/amdgpu_cs.c              |  4 ++++
- amd/amdgpu/amdgpu_display.c         |  4 ++++
- amd/amdgpu/amdgpu_gem.c             | 20 ++++++++++++++++++++
- amd/amdgpu/dce_v10_0.c              |  4 ++++
- amd/amdgpu/dce_v11_0.c              |  4 ++++
- amd/amdgpu/dce_v8_0.c               |  4 ++++
- amd/dal/amdgpu_dm/amdgpu_dm_types.c |  4 ++++
- 8 files changed, 48 insertions(+)
-
-diff --git a/amd/amdgpu/amdgpu_bo_list.c b/amd/amdgpu/amdgpu_bo_list.c
-index 844214d..7ae09cf 100644
---- a/amd/amdgpu/amdgpu_bo_list.c
-+++ b/amd/amdgpu/amdgpu_bo_list.c
-@@ -107,7 +107,11 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
- 		struct amdgpu_bo *bo;
- 		struct mm_struct *usermm;
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+		gobj = drm_gem_object_lookup(filp, info[i].bo_handle);
-+#else
- 		gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
-+#endif
- 		if (!gobj) {
- 			r = -ENOENT;
- 			goto error_free;
-diff --git a/amd/amdgpu/amdgpu_cs.c b/amd/amdgpu/amdgpu_cs.c
-index 20f6ab2..22363ab 100644
---- a/amd/amdgpu/amdgpu_cs.c
-+++ b/amd/amdgpu/amdgpu_cs.c
-@@ -92,8 +92,12 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,
- {
- 	struct drm_gem_object *gobj;
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	gobj = drm_gem_object_lookup(p->filp, data->handle);
-+#else
- 	gobj = drm_gem_object_lookup(p->adev->ddev, p->filp,
- 				     data->handle);
-+#endif
- 	if (gobj == NULL)
- 		return -EINVAL;
- 
-diff --git a/amd/amdgpu/amdgpu_display.c b/amd/amdgpu/amdgpu_display.c
-index 96c4fa5..862611c 100644
---- a/amd/amdgpu/amdgpu_display.c
-+++ b/amd/amdgpu/amdgpu_display.c
-@@ -601,7 +601,11 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,
- 	struct amdgpu_framebuffer *amdgpu_fb;
- 	int ret;
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
-+#else
- 	obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
-+#endif
- 	if (obj ==  NULL) {
- 		dev_err(&dev->pdev->dev, "No GEM object associated to handle 0x%08X, "
- 			"can't create framebuffer\n", mode_cmd->handles[0]);
-diff --git a/amd/amdgpu/amdgpu_gem.c b/amd/amdgpu/amdgpu_gem.c
-index 0069aec..6da025b 100644
---- a/amd/amdgpu/amdgpu_gem.c
-+++ b/amd/amdgpu/amdgpu_gem.c
-@@ -397,7 +397,11 @@ int amdgpu_mode_dumb_mmap(struct drm_file *filp,
- 	struct drm_gem_object *gobj;
- 	struct amdgpu_bo *robj;
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	gobj = drm_gem_object_lookup(filp, handle);
-+#else
- 	gobj = drm_gem_object_lookup(dev, filp, handle);
-+#endif
- 	if (gobj == NULL) {
- 		return -ENOENT;
- 	}
-@@ -461,7 +465,11 @@ int amdgpu_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
- 	int r = 0;
- 	long ret;
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	gobj = drm_gem_object_lookup(filp, handle);
-+#else
- 	gobj = drm_gem_object_lookup(dev, filp, handle);
-+#endif
- 	if (gobj == NULL) {
- 		return -ENOENT;
- 	}
-@@ -495,7 +503,11 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
- 	int r = -1;
- 
- 	DRM_DEBUG("%d \n", args->handle);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	gobj = drm_gem_object_lookup(filp, args->handle);
-+#else
- 	gobj = drm_gem_object_lookup(dev, filp, args->handle);
-+#endif
- 	if (gobj == NULL)
- 		return -ENOENT;
- 	robj = gem_to_amdgpu_bo(gobj);
-@@ -643,7 +655,11 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
- 		return -EINVAL;
- 	}
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	gobj = drm_gem_object_lookup(filp, args->handle);
-+#else
- 	gobj = drm_gem_object_lookup(dev, filp, args->handle);
-+#endif
- 	if (gobj == NULL)
- 		return -ENOENT;
- 	rbo = gem_to_amdgpu_bo(gobj);
-@@ -705,7 +721,11 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
- 	struct amdgpu_bo *robj;
- 	int r;
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	gobj = drm_gem_object_lookup(filp, args->handle);
-+#else
- 	gobj = drm_gem_object_lookup(dev, filp, args->handle);
-+#endif
- 	if (gobj == NULL) {
- 		return -ENOENT;
- 	}
-diff --git a/amd/amdgpu/dce_v10_0.c b/amd/amdgpu/dce_v10_0.c
-index 3fae88d..0fd1e4f 100644
---- a/amd/amdgpu/dce_v10_0.c
-+++ b/amd/amdgpu/dce_v10_0.c
-@@ -2594,7 +2594,11 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,
- 		return -EINVAL;
- 	}
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	obj = drm_gem_object_lookup(file_priv, handle);
-+#else
- 	obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
-+#endif
- 	if (!obj) {
- 		DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id);
- 		return -ENOENT;
-diff --git a/amd/amdgpu/dce_v11_0.c b/amd/amdgpu/dce_v11_0.c
-index fe87795..a85eb5f 100644
---- a/amd/amdgpu/dce_v11_0.c
-+++ b/amd/amdgpu/dce_v11_0.c
-@@ -2604,7 +2604,11 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,
- 		return -EINVAL;
- 	}
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	obj = drm_gem_object_lookup(file_priv, handle);
-+#else
- 	obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
-+#endif
- 	if (!obj) {
- 		DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id);
- 		return -ENOENT;
-diff --git a/amd/amdgpu/dce_v8_0.c b/amd/amdgpu/dce_v8_0.c
-index 1f5959b..308f5e4 100644
---- a/amd/amdgpu/dce_v8_0.c
-+++ b/amd/amdgpu/dce_v8_0.c
-@@ -2448,7 +2448,11 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,
- 		return -EINVAL;
- 	}
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	obj = drm_gem_object_lookup(file_priv, handle);
-+#else
- 	obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
-+#endif
- 	if (!obj) {
- 		DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id);
- 		return -ENOENT;
-diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-index d14c96f..a9de2e5 100644
---- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-+++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-@@ -156,7 +156,11 @@ static int dm_crtc_pin_cursor_bo_new(
- 
- 		amdgpu_crtc = to_amdgpu_crtc(crtc);
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+		obj = drm_gem_object_lookup(file_priv, handle);
-+#else
- 		obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
-+#endif
- 
- 		if (!obj) {
- 			DRM_ERROR(
--- 
-2.10.1
-
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0010-Fix-crtc_gamma-functions-for-4.8.0.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0006-Fix-crtc_gamma-functions-for-4.8.0.patch
similarity index 83%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0010-Fix-crtc_gamma-functions-for-4.8.0.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0006-Fix-crtc_gamma-functions-for-4.8.0.patch
index b11ab3e557e..566b7039bb3 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0010-Fix-crtc_gamma-functions-for-4.8.0.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0006-Fix-crtc_gamma-functions-for-4.8.0.patch
@@ -1,7 +1,7 @@
-From b41eafa282a003cde9729e2ff486f55dc54f12c6 Mon Sep 17 00:00:00 2001
+From 12660ae02838f99c0784194908f7a189bc2ab0ae Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 16:56:47 +0100
-Subject: [PATCH 10/14] Fix crtc_gamma functions for 4.8.0
+Subject: [PATCH 06/11] Fix crtc_gamma functions for 4.8.0
 
 ---
  amd/amdgpu/dce_v10_0.c              | 19 +++++++++++++++++++
@@ -11,10 +11,10 @@ Subject: [PATCH 10/14] Fix crtc_gamma functions for 4.8.0
  4 files changed, 69 insertions(+)
 
 diff --git a/amd/amdgpu/dce_v10_0.c b/amd/amdgpu/dce_v10_0.c
-index 5f0044c..85378aa 100644
+index b1880ac..53746fa 100644
 --- a/amd/amdgpu/dce_v10_0.c
 +++ b/amd/amdgpu/dce_v10_0.c
-@@ -2671,6 +2671,24 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
+@@ -2627,6 +2627,24 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
  	}
  }
  
@@ -39,7 +39,7 @@ index 5f0044c..85378aa 100644
  static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
  				    u16 *blue, uint32_t start, uint32_t size)
  {
-@@ -2685,6 +2703,7 @@ static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green
+@@ -2641,6 +2659,7 @@ static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green
  	}
  	dce_v10_0_crtc_load_lut(crtc);
  }
@@ -48,10 +48,10 @@ index 5f0044c..85378aa 100644
  static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
  {
 diff --git a/amd/amdgpu/dce_v11_0.c b/amd/amdgpu/dce_v11_0.c
-index 8edc670..0129543 100644
+index b654b64..3edd66d 100644
 --- a/amd/amdgpu/dce_v11_0.c
 +++ b/amd/amdgpu/dce_v11_0.c
-@@ -2681,6 +2681,24 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
+@@ -2643,6 +2643,24 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
  	}
  }
  
@@ -76,7 +76,7 @@ index 8edc670..0129543 100644
  static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
  				    u16 *blue, uint32_t start, uint32_t size)
  {
-@@ -2695,6 +2713,7 @@ static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green
+@@ -2657,6 +2675,7 @@ static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green
  	}
  	dce_v11_0_crtc_load_lut(crtc);
  }
@@ -85,10 +85,10 @@ index 8edc670..0129543 100644
  static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
  {
 diff --git a/amd/amdgpu/dce_v8_0.c b/amd/amdgpu/dce_v8_0.c
-index 57e8014..d0d9267 100644
+index b598caa..d203894 100644
 --- a/amd/amdgpu/dce_v8_0.c
 +++ b/amd/amdgpu/dce_v8_0.c
-@@ -2525,6 +2525,24 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
+@@ -2478,6 +2478,24 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
  	}
  }
  
@@ -113,7 +113,7 @@ index 57e8014..d0d9267 100644
  static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
  				    u16 *blue, uint32_t start, uint32_t size)
  {
-@@ -2539,6 +2557,7 @@ static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+@@ -2492,6 +2510,7 @@ static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
  	}
  	dce_v8_0_crtc_load_lut(crtc);
  }
@@ -122,10 +122,10 @@ index 57e8014..d0d9267 100644
  static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
  {
 diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-index fedf490..c1f3c27 100644
+index edc8e86..32755a9 100644
 --- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
 +++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-@@ -995,6 +995,13 @@ void amdgpu_dm_crtc_destroy(struct drm_crtc *crtc)
+@@ -998,6 +998,13 @@ void amdgpu_dm_crtc_destroy(struct drm_crtc *crtc)
  	kfree(crtc);
  }
  
@@ -139,7 +139,7 @@ index fedf490..c1f3c27 100644
  static void amdgpu_dm_atomic_crtc_gamma_set(
  		struct drm_crtc *crtc,
  		u16 *red,
-@@ -1002,6 +1009,7 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
+@@ -1005,6 +1012,7 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
  		u16 *blue,
  		uint32_t start,
  		uint32_t size)
@@ -147,7 +147,7 @@ index fedf490..c1f3c27 100644
  {
  	struct drm_device *dev = crtc->dev;
  	struct drm_property *prop = dev->mode_config.prop_crtc_id;
-@@ -1009,6 +1017,10 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
+@@ -1012,6 +1020,10 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
  	crtc->state->mode.private_flags |= AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET;
  
  	drm_atomic_helper_crtc_set_property(crtc, prop, 0);
@@ -159,5 +159,5 @@ index fedf490..c1f3c27 100644
  
  static int dm_crtc_funcs_atomic_set_property(
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0006-Remove-vblank_disable_allowed-assignment.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0006-Remove-vblank_disable_allowed-assignment.patch
deleted file mode 100644
index dc35fe4c96a..00000000000
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0006-Remove-vblank_disable_allowed-assignment.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From d4a070e6d68ff7ce8ac49c6135acc759c9a1cf6e Mon Sep 17 00:00:00 2001
-From: "Luke A. Guest" <laguest@archeia.com>
-Date: Sun, 25 Sep 2016 16:01:43 +0100
-Subject: [PATCH 06/14] Remove vblank_disable_allowed assignment
-
----
- amd/amdgpu/amdgpu_irq.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/amd/amdgpu/amdgpu_irq.c b/amd/amdgpu/amdgpu_irq.c
-index 6e85e69..71358c9 100644
---- a/amd/amdgpu/amdgpu_irq.c
-+++ b/amd/amdgpu/amdgpu_irq.c
-@@ -240,7 +240,9 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
- 		INIT_WORK(&adev->hotplug_work,
- 				amdgpu_hotplug_work_func);
- 	}
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
- 	adev->ddev->vblank_disable_allowed = true;
-+#endif
- 
- 	INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func);
- 
--- 
-2.10.1
-
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0007-Fix-__drm_atomic_helper_connector_destroy_state-call.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0007-Fix-__drm_atomic_helper_connector_destroy_state-call.patch
deleted file mode 100644
index 9e8749a31ca..00000000000
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0007-Fix-__drm_atomic_helper_connector_destroy_state-call.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 406bb3a83b51b2bcf61a972721aa116e69c0a771 Mon Sep 17 00:00:00 2001
-From: "Luke A. Guest" <laguest@archeia.com>
-Date: Sun, 25 Sep 2016 16:10:27 +0100
-Subject: [PATCH 07/14] Fix __drm_atomic_helper_connector_destroy_state call
-
----
- amd/dal/amdgpu_dm/amdgpu_dm_types.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-index a9de2e5..fedf490 100644
---- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-+++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-@@ -1224,7 +1224,11 @@ void amdgpu_dm_connector_atomic_destroy_state(
- 	struct dm_connector_state *dm_state =
- 		to_dm_connector_state(state);
- 
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
-+	__drm_atomic_helper_connector_destroy_state(connector->state);
-+#else
- 	__drm_atomic_helper_connector_destroy_state(connector, state);
-+#endif
- 
- 	kfree(dm_state);
- }
--- 
-2.10.1
-
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0011-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0007-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
similarity index 73%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0011-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0007-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
index d205fc3189c..197fdd32b10 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0011-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0007-Fix-drm_atomic_helper_swap_state-for-4.8.0.patch
@@ -1,17 +1,17 @@
-From 32422de1ddaf539d284b32de5fe43d07b7553499 Mon Sep 17 00:00:00 2001
+From 7a5d45874b1e2bbbff2d2410f38203b5b0ae67c4 Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 17:00:32 +0100
-Subject: [PATCH 11/14] Fix drm_atomic_helper_swap_state for 4.8.0
+Subject: [PATCH 07/11] Fix drm_atomic_helper_swap_state for 4.8.0
 
 ---
  amd/dal/amdgpu_dm/amdgpu_dm_types.c | 4 ++++
  1 file changed, 4 insertions(+)
 
 diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-index c1f3c27..60cba1a 100644
+index 32755a9..60ca073 100644
 --- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
 +++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
-@@ -2331,7 +2331,11 @@ int amdgpu_dm_atomic_commit(
+@@ -2528,7 +2528,11 @@ int amdgpu_dm_atomic_commit(
  	 * the software side now.
  	 */
  
@@ -24,5 +24,5 @@ index c1f3c27..60cba1a 100644
  	/*
  	 * From this point state become old state really. New state is
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0012-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0008-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
similarity index 75%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0012-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0008-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
index 77b0cf79640..8674c3537e8 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0012-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0008-Add-extra-flag-to-ttm_bo_move_ttm-for-4.8.0-rc2.patch
@@ -1,17 +1,17 @@
-From 69207f061e13e6f02418d5706d230135abcc1a72 Mon Sep 17 00:00:00 2001
+From 7c536e8b9f73926014c0622eb101f2cf174b507b Mon Sep 17 00:00:00 2001
 From: "Luke A. Guest" <laguest@archeia.com>
 Date: Sun, 25 Sep 2016 19:19:45 +0100
-Subject: [PATCH 12/14] Add extra flag to ttm_bo_move_ttm for >=4.8.0-rc2
+Subject: [PATCH 08/11] Add extra flag to ttm_bo_move_ttm for >=4.8.0-rc2
 
 ---
  amd/amdgpu/amdgpu_ttm.c | 8 ++++++++
  1 file changed, 8 insertions(+)
 
 diff --git a/amd/amdgpu/amdgpu_ttm.c b/amd/amdgpu/amdgpu_ttm.c
-index 145732a..dd691fa 100644
+index 89760f8..d102224 100644
 --- a/amd/amdgpu/amdgpu_ttm.c
 +++ b/amd/amdgpu/amdgpu_ttm.c
-@@ -344,7 +344,11 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
+@@ -428,7 +428,11 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
  	if (unlikely(r)) {
  		goto out_cleanup;
  	}
@@ -23,7 +23,7 @@ index 145732a..dd691fa 100644
  out_cleanup:
  	ttm_bo_mem_put(bo, &tmp_mem);
  	return r;
-@@ -377,7 +381,11 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
+@@ -461,7 +465,11 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
  	if (unlikely(r)) {
  		return r;
  	}
@@ -36,5 +36,5 @@ index 145732a..dd691fa 100644
  		goto out_cleanup;
  	}
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0008-Change-seq_printf-format-for-64-bit-context.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0008-Change-seq_printf-format-for-64-bit-context.patch
deleted file mode 100644
index 827237a5f9a..00000000000
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0008-Change-seq_printf-format-for-64-bit-context.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From f268e7fa537fd8e12f4023803df795b2e29747e7 Mon Sep 17 00:00:00 2001
-From: "Luke A. Guest" <laguest@archeia.com>
-Date: Sun, 25 Sep 2016 16:46:39 +0100
-Subject: [PATCH 08/14] Change seq_printf format for 64 bit context
-
----
- amd/amdgpu/amdgpu_sa.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/amd/amdgpu/amdgpu_sa.c b/amd/amdgpu/amdgpu_sa.c
-index 768a265..51d118e 100644
---- a/amd/amdgpu/amdgpu_sa.c
-+++ b/amd/amdgpu/amdgpu_sa.c
-@@ -428,8 +428,13 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
- 			   soffset, eoffset, eoffset - soffset);
- 
- 		if (i->fence)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-+			seq_printf(m, " protected by 0x%08x on context %llu",
-+				   i->fence->seqno, i->fence->context);
-+#else
- 			seq_printf(m, " protected by 0x%08x on context %d",
- 				   i->fence->seqno, i->fence->context);
-+#endif
- 
- 		seq_printf(m, "\n");
- 	}
--- 
-2.10.1
-
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0013-Remove-dependency-on-System.map.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0009-Remove-dependency-on-System.map.patch
similarity index 61%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0013-Remove-dependency-on-System.map.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0009-Remove-dependency-on-System.map.patch
index 23a648e0d52..52c5f7f4593 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0013-Remove-dependency-on-System.map.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0009-Remove-dependency-on-System.map.patch
@@ -1,36 +1,32 @@
-From 115cdb5a06b112674d9652ef44d7f19583ff0136 Mon Sep 17 00:00:00 2001
+From 4d645984264e449d6a4507af033b26daed952eac Mon Sep 17 00:00:00 2001
 From: David McFarland <corngood@gmail.com>
 Date: Wed, 26 Oct 2016 22:26:39 -0300
-Subject: [PATCH 13/14] Remove dependency on System.map
+Subject: [PATCH 09/11] Remove dependency on System.map
 
 ---
- amd/backport/Makefile    |  3 +--
+ amd/backport/Makefile    |  1 -
  amd/backport/kcl_fence.c | 10 ++++++++--
- amd/backport/symbols     |  3 ---
- 3 files changed, 9 insertions(+), 7 deletions(-)
+ amd/backport/symbols     |  7 -------
+ 3 files changed, 8 insertions(+), 10 deletions(-)
  delete mode 100644 amd/backport/symbols
 
 diff --git a/amd/backport/Makefile b/amd/backport/Makefile
-index dcc94d5..ef27e94 100644
+index ff9339d..3f2d9ea 100644
 --- a/amd/backport/Makefile
 +++ b/amd/backport/Makefile
-@@ -55,10 +55,9 @@ ccflags-y += -DOS_NAME_RHEL_7
+@@ -64,7 +64,6 @@ ccflags-y += -DOS_NAME_RHEL_7_3
  endif
  endif
  
 -BACKPORT_OBJS = symbols.o
  endif
  
--BACKPORT_OBJS += kcl_drm.o kcl_ttm.o kcl_amdgpu.o kcl_fence.o kcl_mn.o
-+BACKPORT_OBJS = kcl_drm.o kcl_ttm.o kcl_amdgpu.o kcl_fence.o kcl_mn.o
- 
- amdgpu-y += $(addprefix ../backport/,$(BACKPORT_OBJS))
- 
+ BACKPORT_OBJS += kcl_drm.o kcl_ttm.o kcl_amdgpu.o kcl_fence.o kcl_mn.o amdgpu_kcl.o kcl_fence_array.o kcl_kthread.o
 diff --git a/amd/backport/kcl_fence.c b/amd/backport/kcl_fence.c
-index 8c697aa..85d96d3 100644
+index 54ad819..39f6d61 100644
 --- a/amd/backport/kcl_fence.c
 +++ b/amd/backport/kcl_fence.c
-@@ -25,8 +25,14 @@ struct default_wait_cb {
+@@ -52,8 +52,14 @@ struct default_wait_cb {
  	struct task_struct *task;
  };
  
@@ -49,13 +45,17 @@ index 8c697aa..85d96d3 100644
  _kcl_fence_wait_any_timeout(struct fence **fences, uint32_t count,
 diff --git a/amd/backport/symbols b/amd/backport/symbols
 deleted file mode 100644
-index 2d3f2ee..0000000
+index 68cae63..0000000
 --- a/amd/backport/symbols
 +++ /dev/null
-@@ -1,3 +0,0 @@
+@@ -1,7 +0,0 @@
 -SYMS=""
 -
 -SYMS+="fence_default_wait_cb"
+-
+-if version_lt 2.6.33; then
+-    SYMS+=" kallsyms_lookup_name"
+-fi
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0014-disable-dal-by-default.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0010-disable-dal-by-default.patch
similarity index 68%
rename from pkgs/os-specific/linux/amdgpu-pro/patches/0014-disable-dal-by-default.patch
rename to pkgs/os-specific/linux/amdgpu-pro/patches/0010-disable-dal-by-default.patch
index 693985ec2a2..e69e5c58319 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/patches/0014-disable-dal-by-default.patch
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0010-disable-dal-by-default.patch
@@ -1,19 +1,19 @@
-From 942064886eae63ed7aa0a63c07e9f175898dddf7 Mon Sep 17 00:00:00 2001
+From 5ab8e5e36634391a5c440bf78463226b2074485e Mon Sep 17 00:00:00 2001
 From: David McFarland <corngood@gmail.com>
 Date: Thu, 25 Aug 2016 22:17:06 -0300
-Subject: [PATCH 14/14] disable dal by default
+Subject: [PATCH 10/11] disable dal by default
 
 ---
  amd/amdgpu/amdgpu_drv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/amd/amdgpu/amdgpu_drv.c b/amd/amdgpu/amdgpu_drv.c
-index 66f3242..df62815 100644
+index d6b3f35..4477865 100755
 --- a/amd/amdgpu/amdgpu_drv.c
 +++ b/amd/amdgpu/amdgpu_drv.c
-@@ -79,7 +79,7 @@ int amdgpu_vm_block_size = -1;
- int amdgpu_vm_fault_stop = 0;
+@@ -88,7 +88,7 @@ int amdgpu_vm_fault_stop = 0;
  int amdgpu_vm_debug = 0;
+ int amdgpu_vram_page_split = -1;
  int amdgpu_exp_hw_support = 0;
 -int amdgpu_dal = -1;
 +int amdgpu_dal = 0;
@@ -21,5 +21,5 @@ index 66f3242..df62815 100644
  int amdgpu_sched_hw_submission = 2;
  int amdgpu_powerplay = -1;
 -- 
-2.10.1
+2.11.0
 
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0011-kcl-fixes-for-16.50-linux-4.8.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0011-kcl-fixes-for-16.50-linux-4.8.patch
new file mode 100644
index 00000000000..0cf3ad262f6
--- /dev/null
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0011-kcl-fixes-for-16.50-linux-4.8.patch
@@ -0,0 +1,114 @@
+From 156445f6eda047ee5a5d6e4bde36c3e9ccbbd7d9 Mon Sep 17 00:00:00 2001
+From: David McFarland <corngood@gmail.com>
+Date: Thu, 29 Dec 2016 14:20:06 -0400
+Subject: [PATCH 11/11] kcl fixes for 16.50 + linux-4.8
+
+---
+ amd/amdgpu/dce_v6_0.c              |  5 +++--
+ amd/amdgpu/dce_virtual.c           |  5 +++--
+ amd/backport/include/kcl/kcl_drm.h | 12 ++++++++++++
+ amd/backport/include/kcl/kcl_ttm.h |  2 +-
+ amd/backport/kcl_drm.c             |  4 ++++
+ 5 files changed, 23 insertions(+), 5 deletions(-)
+
+diff --git a/amd/amdgpu/dce_v6_0.c b/amd/amdgpu/dce_v6_0.c
+index fd3eeb0..1f1874c 100644
+--- a/amd/amdgpu/dce_v6_0.c
++++ b/amd/amdgpu/dce_v6_0.c
+@@ -1946,9 +1946,9 @@ static void dce_v6_0_cursor_reset(struct drm_crtc *crtc)
+ 	}
+ }
+ 
+-static void dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+-				    u16 *blue, uint32_t start, uint32_t size)
++static kcl_crtc_gamma_set_callback(dce_v6_0_crtc_gamma_set)
+ {
++  kcl_crtc_gamma_set_pre
+ 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+ 	int end = (start + size > 256) ? 256 : start + size, i;
+ 
+@@ -1959,6 +1959,7 @@ static void dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+ 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
+ 	}
+ 	dce_v6_0_crtc_load_lut(crtc);
++  kcl_crtc_gamma_set_suf
+ }
+ 
+ static void dce_v6_0_crtc_destroy(struct drm_crtc *crtc)
+diff --git a/amd/amdgpu/dce_virtual.c b/amd/amdgpu/dce_virtual.c
+index 36e2094..11b98e2 100644
+--- a/amd/amdgpu/dce_virtual.c
++++ b/amd/amdgpu/dce_virtual.c
+@@ -152,9 +152,9 @@ static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
+ 	return;
+ }
+ 
+-static void dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+-				    u16 *blue, uint32_t start, uint32_t size)
++static kcl_crtc_gamma_set_callback(dce_virtual_crtc_gamma_set)
+ {
++  kcl_crtc_gamma_set_pre
+ 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+ 	int end = (start + size > 256) ? 256 : start + size, i;
+ 
+@@ -164,6 +164,7 @@ static void dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *gre
+ 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
+ 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
+ 	}
++  kcl_crtc_gamma_set_suf
+ }
+ 
+ static void dce_virtual_crtc_destroy(struct drm_crtc *crtc)
+diff --git a/amd/backport/include/kcl/kcl_drm.h b/amd/backport/include/kcl/kcl_drm.h
+index 95bf640..61c38b1 100644
+--- a/amd/backport/include/kcl/kcl_drm.h
++++ b/amd/backport/include/kcl/kcl_drm.h
+@@ -206,4 +206,16 @@ int drm_atomic_helper_resume(struct drm_device *dev,
+ 
+ #endif
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
++#define kcl_crtc_gamma_set_callback(n) int n(struct drm_crtc *crtc, \
++    u16 *red, u16 *green, u16 *blue, uint32_t size)
++#define kcl_crtc_gamma_set_pre uint32_t start = 0;
++#define kcl_crtc_gamma_set_suf return 0;
++#else
++#define kcl_crtc_gamma_set_callback(n) void n(struct drm_crtc *crtc, \
++    u16 *red, u16 *green, u16 *blue, uint32_t start, uint32_t size)
++#define kcl_crtc_gamma_set_pre
++#define kcl_crtc_gamma_set_suf
++#endif
++
+ #endif /* AMDGPU_BACKPORT_KCL_DRM_H */
+diff --git a/amd/backport/include/kcl/kcl_ttm.h b/amd/backport/include/kcl/kcl_ttm.h
+index 52cdbc8..cdda0b5 100644
+--- a/amd/backport/include/kcl/kcl_ttm.h
++++ b/amd/backport/include/kcl/kcl_ttm.h
+@@ -152,7 +152,7 @@ static inline int kcl_ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
+ 		bool evict, bool no_wait_gpu,
+ 		struct ttm_mem_reg *new_mem)
+ {
+-#if defined(BUILD_AS_DKMS)
++#if defined(BUILD_AS_DKMS) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
+ 	return ttm_bo_move_accel_cleanup(bo, fence,
+ 			evict, no_wait_gpu, new_mem);
+ #else
+diff --git a/amd/backport/kcl_drm.c b/amd/backport/kcl_drm.c
+index 27d4aaa..a083c87 100644
+--- a/amd/backport/kcl_drm.c
++++ b/amd/backport/kcl_drm.c
+@@ -178,7 +178,11 @@ static inline struct drm_plane_state *
+ _kcl_drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
+                     struct drm_plane *plane)
+ {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
++    return drm_atomic_get_existing_plane_state(state, plane);
++#else
+     return state->plane_states[drm_plane_index(plane)];
++#endif
+ }
+ 
+ void
+-- 
+2.11.0
+
diff --git a/pkgs/os-specific/linux/amdgpu-pro/patches/0012-use-kernel-fence_array-in-4.8.patch b/pkgs/os-specific/linux/amdgpu-pro/patches/0012-use-kernel-fence_array-in-4.8.patch
new file mode 100644
index 00000000000..07ce868c29d
--- /dev/null
+++ b/pkgs/os-specific/linux/amdgpu-pro/patches/0012-use-kernel-fence_array-in-4.8.patch
@@ -0,0 +1,55 @@
+From 73e77e056427e2042b8d84933c02db92e17cf233 Mon Sep 17 00:00:00 2001
+From: David McFarland <corngood@gmail.com>
+Date: Thu, 29 Dec 2016 14:49:18 -0400
+Subject: [PATCH] use kernel fence_array in 4.8+
+
+---
+ amd/backport/include/kcl/kcl_fence_array.h | 10 ++++++++--
+ amd/backport/kcl_fence_array.c             |  2 +-
+ 2 files changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/amd/backport/include/kcl/kcl_fence_array.h b/amd/backport/include/kcl/kcl_fence_array.h
+index bb4401e..0d9f344 100644
+--- a/amd/backport/include/kcl/kcl_fence_array.h
++++ b/amd/backport/include/kcl/kcl_fence_array.h
+@@ -19,11 +19,15 @@
+  * more details.
+  */
+ 
+-#ifndef __LINUX_FENCE_ARRAY_H
+-#define __LINUX_FENCE_ARRAY_H
++#ifndef __KCL_FENCE_ARRAY_H
++#define __KCL_FENCE_ARRAY_H
+ 
+ #include <linux/fence.h>
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0)
++#include <linux/fence-array.h>
++#else
++
+ /**
+  * struct fence_array_cb - callback helper for fence array
+  * @cb: fence callback structure for signaling
+@@ -72,4 +76,6 @@ struct fence_array *fence_array_create(int num_fences, struct fence **fences,
+ 				       u64 context, unsigned seqno,
+ 				       bool signal_on_any);
+ 
++#endif
++
+ #endif /* __LINUX_FENCE_ARRAY_H */
+diff --git a/amd/backport/kcl_fence_array.c b/amd/backport/kcl_fence_array.c
+index d7ee15c..1865444 100644
+--- a/amd/backport/kcl_fence_array.c
++++ b/amd/backport/kcl_fence_array.c
+@@ -21,7 +21,7 @@
+ #include <linux/export.h>
+ #include <linux/slab.h>
+ 
+-#if defined(BUILD_AS_DKMS)
++#if defined(BUILD_AS_DKMS) && LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
+ static void fence_array_cb_func(struct fence *f, struct fence_cb *cb);
+ 
+ static const char *fence_array_get_driver_name(struct fence *fence)
+-- 
+2.11.0
+
diff --git a/pkgs/os-specific/linux/kernel/linux-4.4.nix b/pkgs/os-specific/linux/kernel/linux-4.4.nix
index 649cf013591..f3eceb5fe26 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.4.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.4.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.4.40";
+  version = "4.4.41";
   extraMeta.branch = "4.4";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "1qd431bk3q9xcvnlw4fvcsw4l8k44s14nwdkq4y3kmrywzb5xg64";
+    sha256 = "1z26frg7sx5n9bvkpg9pfspwhxxvlnnfnrnjr7aqhcgsbxzq8vca";
   };
 
   kernelPatches = args.kernelPatches;
diff --git a/pkgs/os-specific/linux/kernel/linux-4.8.nix b/pkgs/os-specific/linux/kernel/linux-4.8.nix
index 8a71a771c4f..a5ce23ee3e4 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.8.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.8.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.8.16";
+  version = "4.8.17";
   extraMeta.branch = "4.8";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "1aml6vhsfpvm8rsadraff7qj0ivgd9aw75k2q65drz4iby1pqb9h";
+    sha256 = "1zk0q6bvqgz2pk1axd5z0cx71vqk96314f1zn8apwa4raylf9fpa";
   };
 
   kernelPatches = args.kernelPatches;
diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix
index 25e9eac0365..29f0eba7175 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.9.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.9.1";
+  version = "4.9.2";
   extraMeta.branch = "4.9";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "06jlfdmfgmhj80q1q9pglkjygjc1s1b5fslhf5bzkicsw4r2369j";
+    sha256 = "0f2p12pkzgrh9k5c7g2wwjnv6gzqha8bgd7b0qgbzq3ss7nrmnld";
   };
 
   kernelPatches = args.kernelPatches;
diff --git a/pkgs/os-specific/linux/mdadm/4.nix b/pkgs/os-specific/linux/mdadm/4.nix
new file mode 100644
index 00000000000..d929668a26a
--- /dev/null
+++ b/pkgs/os-specific/linux/mdadm/4.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, groff }:
+
+assert stdenv.isLinux;
+
+stdenv.mkDerivation rec {
+  name = "mdadm-4.0";
+
+  src = fetchurl {
+    url = "mirror://kernel/linux/utils/raid/mdadm/${name}.tar.xz";
+    sha256 = "1ad3mma641946wn5lsllwf0lifw9lps34fv1nnkhyfpd9krffshx";
+  };
+
+  # This is to avoid self-references, which causes the initrd to explode
+  # in size and in turn prevents mdraid systems from booting.
+  allowedReferences = [ stdenv.glibc.out ];
+
+  patches = [ ./no-self-references.patch ];
+
+  makeFlags = [
+    "NIXOS=1" "INSTALL=install" "INSTALL_BINDIR=$(out)/sbin"
+    "MANDIR=$(out)/share/man" "RUN_DIR=/dev/.mdadm"
+  ] ++ stdenv.lib.optionals (stdenv ? cross) [
+    "CROSS_COMPILE=${stdenv.cross.config}-"
+  ];
+
+  nativeBuildInputs = [ groff ];
+
+  # Attempt removing if building with gcc5 when updating
+  NIX_CFLAGS_COMPILE = "-std=gnu89";
+
+  preConfigure = ''
+    sed -e 's@/lib/udev@''${out}/lib/udev@' \
+        -e 's@ -Werror @ @' \
+        -e 's@/usr/sbin/sendmail@/var/setuid-wrappers/sendmail@' -i Makefile
+  '';
+
+  meta = {
+    description = "Programs for managing RAID arrays under Linux";
+    homepage = http://neil.brown.name/blog/mdadm;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/servers/mpd/darwin-enable-cxx-exceptions.patch b/pkgs/servers/mpd/darwin-enable-cxx-exceptions.patch
deleted file mode 100644
index db330a913cb..00000000000
--- a/pkgs/servers/mpd/darwin-enable-cxx-exceptions.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-diff -Naur mpd-0.19.9.orig/configure mpd-0.19.9/configure
---- mpd-0.19.9.orig/configure	2015-01-26 19:47:27.000000000 +0000
-+++ mpd-0.19.9/configure	2015-01-26 19:47:27.000000000 +0000
-@@ -17113,138 +17113,6 @@
- done
- 
- 
--if test x$no_exceptions = xyes; then
--
--
--
--
--for flag in -fno-exceptions; do
--  as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags__$flag" | $as_tr_sh`
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts $flag" >&5
--$as_echo_n "checking whether C++ compiler accepts $flag... " >&6; }
--if eval \${$as_CACHEVAR+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--
--  ax_check_save_flags=$CXXFLAGS
--  CXXFLAGS="$CXXFLAGS  $flag"
--  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--int
--main ()
--{
--
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_cxx_try_compile "$LINENO"; then :
--  eval "$as_CACHEVAR=yes"
--else
--  eval "$as_CACHEVAR=no"
--fi
--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
--  CXXFLAGS=$ax_check_save_flags
--fi
--eval ac_res=\$$as_CACHEVAR
--	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
--$as_echo "$ac_res" >&6; }
--if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
--  if ${CXXFLAGS+:} false; then :
--  case " $CXXFLAGS " in
--    *" $flag "*)
--      { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS already contains \$flag"; } >&5
--  (: CXXFLAGS already contains $flag) 2>&5
--  ac_status=$?
--  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--  test $ac_status = 0; }
--      ;;
--    *)
--      { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$flag\""; } >&5
--  (: CXXFLAGS="$CXXFLAGS $flag") 2>&5
--  ac_status=$?
--  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--  test $ac_status = 0; }
--      CXXFLAGS="$CXXFLAGS $flag"
--      ;;
--   esac
--else
--  CXXFLAGS="$flag"
--fi
--
--else
--  :
--fi
--
--done
--
--
--
--
--
--for flag in -fno-rtti; do
--  as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags__$flag" | $as_tr_sh`
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts $flag" >&5
--$as_echo_n "checking whether C++ compiler accepts $flag... " >&6; }
--if eval \${$as_CACHEVAR+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--
--  ax_check_save_flags=$CXXFLAGS
--  CXXFLAGS="$CXXFLAGS  $flag"
--  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--int
--main ()
--{
--
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_cxx_try_compile "$LINENO"; then :
--  eval "$as_CACHEVAR=yes"
--else
--  eval "$as_CACHEVAR=no"
--fi
--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
--  CXXFLAGS=$ax_check_save_flags
--fi
--eval ac_res=\$$as_CACHEVAR
--	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
--$as_echo "$ac_res" >&6; }
--if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
--  if ${CXXFLAGS+:} false; then :
--  case " $CXXFLAGS " in
--    *" $flag "*)
--      { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS already contains \$flag"; } >&5
--  (: CXXFLAGS already contains $flag) 2>&5
--  ac_status=$?
--  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--  test $ac_status = 0; }
--      ;;
--    *)
--      { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$flag\""; } >&5
--  (: CXXFLAGS="$CXXFLAGS $flag") 2>&5
--  ac_status=$?
--  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--  test $ac_status = 0; }
--      CXXFLAGS="$CXXFLAGS $flag"
--      ;;
--   esac
--else
--  CXXFLAGS="$flag"
--fi
--
--else
--  :
--fi
--
--done
--
--fi
- 
- 
- 
diff --git a/pkgs/servers/mpd/default.nix b/pkgs/servers/mpd/default.nix
index 5b2195b3d7e..c07ca6a8342 100644
--- a/pkgs/servers/mpd/default.nix
+++ b/pkgs/servers/mpd/default.nix
@@ -39,8 +39,6 @@ in stdenv.mkDerivation rec {
     sha256 = "068nxsfkp2ppcjh3fmcbapkiwnjpvkii73bfydpw4bf2yphdvsa8";
   };
 
-  patches = stdenv.lib.optionals stdenv.isDarwin ./darwin-enable-cxx-exceptions.patch;
-
   buildInputs = [ pkgconfig glib boost ]
     ++ opt stdenv.isDarwin darwin.apple_sdk.frameworks.CoreAudioKit
     ++ opt stdenv.isLinux systemd
diff --git a/pkgs/servers/owncloud/default.nix b/pkgs/servers/owncloud/default.nix
index ada198a171a..c452ac869fc 100644
--- a/pkgs/servers/owncloud/default.nix
+++ b/pkgs/servers/owncloud/default.nix
@@ -43,28 +43,28 @@ in {
   };
 
   owncloud80 = common {
-    versiona = "8.0.15";
-    sha256 = "18042jkp4p3b6xh394zm80126975g94r4ka8gzwhyvgfwpgxrx84";
+    versiona = "8.0.16";
+    sha256 = "1pgfawrmx6n02h7h6g5wk0sa1kgablqa8ljfiywyw8znxxa5lnrm";
   };
 
   owncloud81 = common {
-    versiona = "8.1.10";
-    sha256 = "1vspsd3l86mrhhddmyafwdr961f4dy6ln2j4dds2h45wf6296c63";
+    versiona = "8.1.11";
+    sha256 = "04izfzj3ckcs0x882kkggp6y7zcrhdihm71wkd9vk6j5fn8k9am0";
   };
 
   owncloud82 = common {
-    versiona = "8.2.8";
-    sha256 = "0k10b3gfpfk3imxhkra0vn6a004xmcma09lw6pgxnalpmpbm8jiy";
+    versiona = "8.2.9";
+    sha256 = "09gzpxd9gjg8h57m8j0r6xnr85fdb951ykwmjby811c6730769pw";
   };
 
   owncloud90 = common {
-    versiona = "9.0.5";
-    sha256 = "1igpjc4rfaxqrkf2dln85wvdii54nrmwlh17fq3g0232l3vw9hn8";
+    versiona = "9.0.7";
+    sha256 = "1j6xrd4dhc0v0maa3z8n392nfc9hrnvbxxyqr8g8kz88w9vbqa6h";
   };
 
   owncloud91 = common {
-    versiona = "9.1.1";
-    sha256 = "1fd73ggzj2v43j284is2c6936gwkmz1inr5fm88rmq5pxcqkbgx6";
+    versiona = "9.1.3";
+    sha256 = "1sgnsj2ng14lh05n5kc3jv03xk6xnkyx7xj1rasxlqgvzwsyp8g0";
   };
 
 }
diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix
index 60cfe4a2814..48d42e6533a 100644
--- a/pkgs/tools/audio/beets/default.nix
+++ b/pkgs/tools/audio/beets/default.nix
@@ -56,12 +56,12 @@ let
   };
 
   pluginsWithoutDeps = [
-    "beatport" "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
-    "export" "filefilter" "freedesktop" "fromfilename" "ftintitle" "fuzzy" "hook" "ihate"
-    "importadded" "importfeeds" "info" "inline" "ipfs" "lyrics"
-    "mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "permissions" "play"
-    "plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
-    "types" "zero"
+    "absubmit" "beatport" "bench" "bpd" "bpm" "bucket" "cue" "duplicates"
+    "edit" "embedart" "export" "filefilter" "freedesktop" "fromfilename"
+    "ftintitle" "fuzzy" "hook" "ihate" "importadded" "importfeeds" "info"
+    "inline" "ipfs" "lyrics" "mbcollection" "mbsubmit" "mbsync" "metasync"
+    "missing" "permissions" "play" "plexupdate" "random" "rewrite" "scrub"
+    "smartplaylist" "spotify" "the" "types" "zero"
   ];
 
   enabledOptionalPlugins = attrNames (filterAttrs (_: id) optionalPlugins);
@@ -74,13 +74,13 @@ let
 
 in pythonPackages.buildPythonApplication rec {
   name = "beets-${version}";
-  version = "1.4.1";
+  version = "1.4.3";
 
   src = fetchFromGitHub {
     owner = "beetbox";
     repo = "beets";
     rev = "v${version}";
-    sha256 = "1yj2m7l157lldhxanwifp3yv1c6k649iwhn061mcf26q4n8qmspk";
+    sha256 = "0sh2ap7jbqh7p8h63kgrx1ja9lyqlxjpfnh6axxw9p1mh78cgc1v";
   };
 
   propagatedBuildInputs = [
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 46ab2193ac4..f3a321c9065 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -11496,6 +11496,7 @@ in
   mbpfan = callPackage ../os-specific/linux/mbpfan { };
 
   mdadm = callPackage ../os-specific/linux/mdadm { };
+  mdadm4 = callPackage ../os-specific/linux/mdadm/4.nix { };
 
   mingetty = callPackage ../os-specific/linux/mingetty { };
 
@@ -17707,6 +17708,8 @@ in
 
   terraform = callPackage ../applications/networking/cluster/terraform {};
 
+  terragrunt = callPackage ../applications/networking/cluster/terragrunt {};
+
   tetex = callPackage ../tools/typesetting/tex/tetex { libpng = libpng12; };
 
   tewi-font = callPackage ../data/fonts/tewi  {};
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 687889f0b14..1b93cc43d75 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -7719,6 +7719,27 @@ in {
     };
   };
 
+  ipfsapi = buildPythonPackage rec {
+    name = "ipfsapi-${version}";
+    version = "0.4.0";
+    disabled = isPy26 || isPy27;
+
+    src = pkgs.fetchurl {
+      url = "mirror://pypi/i/ipfsapi/${name}.tar.gz";
+      sha256 = "0mqqsihannxzaqi8zcj9nca7fxwg1c85bp7xxic3xqa5zslcdcc3";
+    };
+
+    buildInputs = with self; [ pkgs.pandoc ];
+    propagatedBuildInputs = with self; [ six requests2 ];
+
+    meta = {
+      description = "A python client library for the IPFS API";
+      license = licenses.mit;
+      maintainers = with maintainers; [ mguentner ];
+      homepage = "https://pypi.python.org/pypi/ipfsapi";
+    };
+  };
+
   itsdangerous = buildPythonPackage rec {
     name = "itsdangerous-0.24";
 
@@ -10072,12 +10093,12 @@ in {
 
   django_1_10 = buildPythonPackage rec {
     name = "Django-${version}";
-    version = "1.10.4";
+    version = "1.10.5";
     disabled = pythonOlder "2.7";
 
     src = pkgs.fetchurl {
       url = "http://www.djangoproject.com/m/releases/1.10/${name}.tar.gz";
-      sha256 = "0asw60i4r5cdxb2jp6r09pdrwxxp8mvwbkz7vnx15n0hwmig1xzz";
+      sha256 = "12szjsmnfhh2yr54sfynyjr8vl0q9gb6qak3ayqcifcinrs97f0d";
     };
 
     patches = [