summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin M. Forbes <jforbes@fedoraproject.org>2019-12-31 19:16:19 -0600
committerJustin M. Forbes <jforbes@fedoraproject.org>2019-12-31 19:16:19 -0600
commite6583aee72e0f349c64d8ba237dd63623cbe7400 (patch)
tree51695f92f368169cc193634e4dbd1d6c8f1a5ca4
parent23912b3a68adb9ad33e907c98b15a5e3cd01934a (diff)
downloadkernel-e6583aee72e0f349c64d8ba237dd63623cbe7400.tar.gz
kernel-e6583aee72e0f349c64d8ba237dd63623cbe7400.tar.xz
kernel-e6583aee72e0f349c64d8ba237dd63623cbe7400.zip
Forgot to add patches
-rw-r--r--0001-drm-nouveau-Move-the-declaration-of-struct-nouveau_c.patch158
-rw-r--r--0001-tracing-Do-not-create-directories-if-lockdown-is-in-.patch91
-rw-r--r--0002-drm-nouveau-Fix-drm-core-using-atomic-code-paths-on-.patch115
-rw-r--r--ARM-fix-__get_user_check-in-case-uaccess_-calls-are-not-inlined.patch143
-rw-r--r--alsa-5.6.patch390
-rw-r--r--arm64-tegra186-enable-USB-on-Jetson-TX2.patch51
-rw-r--r--arm64-usb-host-xhci-tegra-set-MODULE_FIRMWARE-for-tegra186.patch36
-rw-r--r--gpio-max77620-Use-correct-unit-for-debounce-times.patch475
-rw-r--r--lift-lockdown-sysrq.patch287
9 files changed, 1746 insertions, 0 deletions
diff --git a/0001-drm-nouveau-Move-the-declaration-of-struct-nouveau_c.patch b/0001-drm-nouveau-Move-the-declaration-of-struct-nouveau_c.patch
new file mode 100644
index 000000000..548304eab
--- /dev/null
+++ b/0001-drm-nouveau-Move-the-declaration-of-struct-nouveau_c.patch
@@ -0,0 +1,158 @@
+From 37a68eab4cd92b507c9e8afd760fdc18e4fecac6 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Thu, 24 Oct 2019 10:52:52 +0200
+Subject: [PATCH v2 1/2] drm/nouveau: Move the declaration of struct
+ nouveau_conn_atom up a bit
+
+Place the declaration of struct nouveau_conn_atom above that of
+struct nouveau_connector. This commit makes no changes to the moved
+block what so ever, it just moves it up a bit.
+
+This is a preparation patch to fix some issues with connector handling
+on pre nv50 displays (which do not use atomic modesetting).
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Reviewed-by: Lyude Paul <lyude@redhat.com>
+Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+---
+ drivers/gpu/drm/nouveau/nouveau_connector.h | 110 ++++++++++----------
+ 1 file changed, 55 insertions(+), 55 deletions(-)
+
+diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h
+index f43a8d63aef8..de9588420884 100644
+--- a/drivers/gpu/drm/nouveau/nouveau_connector.h
++++ b/drivers/gpu/drm/nouveau/nouveau_connector.h
+@@ -29,6 +29,7 @@
+
+ #include <nvif/notify.h>
+
++#include <drm/drm_crtc.h>
+ #include <drm/drm_edid.h>
+ #include <drm/drm_encoder.h>
+ #include <drm/drm_dp_helper.h>
+@@ -44,6 +45,60 @@ struct dcb_output;
+ struct nouveau_backlight;
+ #endif
+
++#define nouveau_conn_atom(p) \
++ container_of((p), struct nouveau_conn_atom, state)
++
++struct nouveau_conn_atom {
++ struct drm_connector_state state;
++
++ struct {
++ /* The enum values specifically defined here match nv50/gf119
++ * hw values, and the code relies on this.
++ */
++ enum {
++ DITHERING_MODE_OFF = 0x00,
++ DITHERING_MODE_ON = 0x01,
++ DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
++ DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
++ DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
++ DITHERING_MODE_AUTO
++ } mode;
++ enum {
++ DITHERING_DEPTH_6BPC = 0x00,
++ DITHERING_DEPTH_8BPC = 0x02,
++ DITHERING_DEPTH_AUTO
++ } depth;
++ } dither;
++
++ struct {
++ int mode; /* DRM_MODE_SCALE_* */
++ struct {
++ enum {
++ UNDERSCAN_OFF,
++ UNDERSCAN_ON,
++ UNDERSCAN_AUTO,
++ } mode;
++ u32 hborder;
++ u32 vborder;
++ } underscan;
++ bool full;
++ } scaler;
++
++ struct {
++ int color_vibrance;
++ int vibrant_hue;
++ } procamp;
++
++ union {
++ struct {
++ bool dither:1;
++ bool scaler:1;
++ bool procamp:1;
++ };
++ u8 mask;
++ } set;
++};
++
+ struct nouveau_connector {
+ struct drm_connector base;
+ enum dcb_connector_type type;
+@@ -121,61 +176,6 @@ extern int nouveau_ignorelid;
+ extern int nouveau_duallink;
+ extern int nouveau_hdmimhz;
+
+-#include <drm/drm_crtc.h>
+-#define nouveau_conn_atom(p) \
+- container_of((p), struct nouveau_conn_atom, state)
+-
+-struct nouveau_conn_atom {
+- struct drm_connector_state state;
+-
+- struct {
+- /* The enum values specifically defined here match nv50/gf119
+- * hw values, and the code relies on this.
+- */
+- enum {
+- DITHERING_MODE_OFF = 0x00,
+- DITHERING_MODE_ON = 0x01,
+- DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
+- DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
+- DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
+- DITHERING_MODE_AUTO
+- } mode;
+- enum {
+- DITHERING_DEPTH_6BPC = 0x00,
+- DITHERING_DEPTH_8BPC = 0x02,
+- DITHERING_DEPTH_AUTO
+- } depth;
+- } dither;
+-
+- struct {
+- int mode; /* DRM_MODE_SCALE_* */
+- struct {
+- enum {
+- UNDERSCAN_OFF,
+- UNDERSCAN_ON,
+- UNDERSCAN_AUTO,
+- } mode;
+- u32 hborder;
+- u32 vborder;
+- } underscan;
+- bool full;
+- } scaler;
+-
+- struct {
+- int color_vibrance;
+- int vibrant_hue;
+- } procamp;
+-
+- union {
+- struct {
+- bool dither:1;
+- bool scaler:1;
+- bool procamp:1;
+- };
+- u8 mask;
+- } set;
+-};
+-
+ void nouveau_conn_attach_properties(struct drm_connector *);
+ void nouveau_conn_reset(struct drm_connector *);
+ struct drm_connector_state *
+--
+2.23.0
+
diff --git a/0001-tracing-Do-not-create-directories-if-lockdown-is-in-.patch b/0001-tracing-Do-not-create-directories-if-lockdown-is-in-.patch
new file mode 100644
index 000000000..911ffe64e
--- /dev/null
+++ b/0001-tracing-Do-not-create-directories-if-lockdown-is-in-.patch
@@ -0,0 +1,91 @@
+From a356646a56857c2e5ad875beec734d7145ecd49a Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 2 Dec 2019 16:25:27 -0500
+Subject: [PATCH] tracing: Do not create directories if lockdown is in affect
+
+If lockdown is disabling tracing on boot up, it prevents the tracing files
+from even bering created. But when that happens, there's several places that
+will give a warning that the files were not created as that is usually a
+sign of a bug.
+
+Add in strategic locations where a check is made to see if tracing is
+disabled by lockdown, and if it is, do not go further, and fail silently
+(but print that tracing is disabled by lockdown, without doing a WARN_ON()).
+
+Cc: Matthew Garrett <mjg59@google.com>
+Fixes: 17911ff38aa5 ("tracing: Add locked_down checks to the open calls of files created for tracefs")
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+---
+ kernel/trace/ring_buffer.c | 6 ++++++
+ kernel/trace/trace.c | 17 +++++++++++++++++
+ 2 files changed, 23 insertions(+)
+
+diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
+index 66358d66c933..4bf050fcfe3b 100644
+--- a/kernel/trace/ring_buffer.c
++++ b/kernel/trace/ring_buffer.c
+@@ -11,6 +11,7 @@
+ #include <linux/trace_seq.h>
+ #include <linux/spinlock.h>
+ #include <linux/irq_work.h>
++#include <linux/security.h>
+ #include <linux/uaccess.h>
+ #include <linux/hardirq.h>
+ #include <linux/kthread.h> /* for self test */
+@@ -5068,6 +5069,11 @@ static __init int test_ringbuffer(void)
+ int cpu;
+ int ret = 0;
+
++ if (security_locked_down(LOCKDOWN_TRACEFS)) {
++ pr_warning("Lockdown is enabled, skipping ring buffer tests\n");
++ return 0;
++ }
++
+ pr_info("Running ring buffer tests...\n");
+
+ buffer = ring_buffer_alloc(RB_TEST_BUFFER_SIZE, RB_FL_OVERWRITE);
+diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
+index 02a23a6e5e00..23459d53d576 100644
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -1888,6 +1888,12 @@ int __init register_tracer(struct tracer *type)
+ return -1;
+ }
+
++ if (security_locked_down(LOCKDOWN_TRACEFS)) {
++ pr_warning("Can not register tracer %s due to lockdown\n",
++ type->name);
++ return -EPERM;
++ }
++
+ mutex_lock(&trace_types_lock);
+
+ tracing_selftest_running = true;
+@@ -8789,6 +8795,11 @@ struct dentry *tracing_init_dentry(void)
+ {
+ struct trace_array *tr = &global_trace;
+
++ if (security_locked_down(LOCKDOWN_TRACEFS)) {
++ pr_warning("Tracing disabled due to lockdown\n");
++ return ERR_PTR(-EPERM);
++ }
++
+ /* The top level trace array uses NULL as parent */
+ if (tr->dir)
+ return NULL;
+@@ -9231,6 +9242,12 @@ __init static int tracer_alloc_buffers(void)
+ int ring_buf_size;
+ int ret = -ENOMEM;
+
++
++ if (security_locked_down(LOCKDOWN_TRACEFS)) {
++ pr_warning("Tracing disabled due to lockdown\n");
++ return -EPERM;
++ }
++
+ /*
+ * Make sure we don't accidently add more trace options
+ * than we have bits for.
+--
+2.24.1
+
diff --git a/0002-drm-nouveau-Fix-drm-core-using-atomic-code-paths-on-.patch b/0002-drm-nouveau-Fix-drm-core-using-atomic-code-paths-on-.patch
new file mode 100644
index 000000000..077f391ca
--- /dev/null
+++ b/0002-drm-nouveau-Fix-drm-core-using-atomic-code-paths-on-.patch
@@ -0,0 +1,115 @@
+From 64d17f25dcad518461ccf0c260544e1e379c5b35 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Thu, 24 Oct 2019 10:52:53 +0200
+Subject: [PATCH v2 2/2] drm/nouveau: Fix drm-core using atomic code-paths on
+ pre-nv50 hardware
+
+We do not support atomic modesetting on pre-nv50 hardware, but until now
+our connector code was setting drm_connector->state on pre-nv50 hardware.
+
+This causes the core to enter atomic modesetting paths in at least:
+
+1. drm_connector_get_encoder(), returning connector->state->best_encoder
+which is always 0, causing us to always report 0 as encoder_id in
+the drmModeConnector struct returned by drmModeGetConnector().
+
+2. drm_encoder_get_crtc(), returning NULL because uses_atomic get set,
+causing us to always report 0 as crtc_id in the drmModeEncoder struct
+returned by drmModeGetEncoder()
+
+Which in turn confuses userspace, at least plymouth thinks that the pipe
+has changed because of this and tries to reconfigure it unnecessarily.
+
+More in general we should not set drm_connector->state in the non-atomic
+code as this violates the drm-core's expectations.
+
+This commit fixes this by using a nouveau_conn_atom struct embedded in the
+nouveau_connector struct for property handling in the non-atomic case.
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1706557
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+---
+ drivers/gpu/drm/nouveau/nouveau_connector.c | 28 +++++++++++++++------
+ drivers/gpu/drm/nouveau/nouveau_connector.h | 6 +++++
+ 2 files changed, 27 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
+index 5b413588b823..9a9a7f5003d3 100644
+--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
++++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
+@@ -245,14 +245,22 @@ nouveau_conn_atomic_duplicate_state(struct drm_connector *connector)
+ void
+ nouveau_conn_reset(struct drm_connector *connector)
+ {
++ struct nouveau_connector *nv_connector = nouveau_connector(connector);
+ struct nouveau_conn_atom *asyc;
+
+- if (WARN_ON(!(asyc = kzalloc(sizeof(*asyc), GFP_KERNEL))))
+- return;
++ if (drm_drv_uses_atomic_modeset(connector->dev)) {
++ if (WARN_ON(!(asyc = kzalloc(sizeof(*asyc), GFP_KERNEL))))
++ return;
++
++ if (connector->state)
++ nouveau_conn_atomic_destroy_state(connector,
++ connector->state);
++
++ __drm_atomic_helper_connector_reset(connector, &asyc->state);
++ } else {
++ asyc = &nv_connector->properties_state;
++ }
+
+- if (connector->state)
+- nouveau_conn_atomic_destroy_state(connector, connector->state);
+- __drm_atomic_helper_connector_reset(connector, &asyc->state);
+ asyc->dither.mode = DITHERING_MODE_AUTO;
+ asyc->dither.depth = DITHERING_DEPTH_AUTO;
+ asyc->scaler.mode = DRM_MODE_SCALE_NONE;
+@@ -276,8 +284,14 @@ void
+ nouveau_conn_attach_properties(struct drm_connector *connector)
+ {
+ struct drm_device *dev = connector->dev;
+- struct nouveau_conn_atom *armc = nouveau_conn_atom(connector->state);
+ struct nouveau_display *disp = nouveau_display(dev);
++ struct nouveau_connector *nv_connector = nouveau_connector(connector);
++ struct nouveau_conn_atom *armc;
++
++ if (drm_drv_uses_atomic_modeset(connector->dev))
++ armc = nouveau_conn_atom(connector->state);
++ else
++ armc = &nv_connector->properties_state;
+
+ /* Init DVI-I specific properties. */
+ if (connector->connector_type == DRM_MODE_CONNECTOR_DVII)
+@@ -748,9 +762,9 @@ static int
+ nouveau_connector_set_property(struct drm_connector *connector,
+ struct drm_property *property, uint64_t value)
+ {
+- struct nouveau_conn_atom *asyc = nouveau_conn_atom(connector->state);
+ struct nouveau_connector *nv_connector = nouveau_connector(connector);
+ struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
++ struct nouveau_conn_atom *asyc = &nv_connector->properties_state;
+ struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
+ int ret;
+
+diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h
+index de9588420884..de84fb4708c7 100644
+--- a/drivers/gpu/drm/nouveau/nouveau_connector.h
++++ b/drivers/gpu/drm/nouveau/nouveau_connector.h
+@@ -118,6 +118,12 @@ struct nouveau_connector {
+ #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
+ struct nouveau_backlight *backlight;
+ #endif
++ /*
++ * Our connector property code expects a nouveau_conn_atom struct
++ * even on pre-nv50 where we do not support atomic. This embedded
++ * version gets used in the non atomic modeset case.
++ */
++ struct nouveau_conn_atom properties_state;
+ };
+
+ static inline struct nouveau_connector *nouveau_connector(
+--
+2.23.0
+
diff --git a/ARM-fix-__get_user_check-in-case-uaccess_-calls-are-not-inlined.patch b/ARM-fix-__get_user_check-in-case-uaccess_-calls-are-not-inlined.patch
new file mode 100644
index 000000000..db893d26e
--- /dev/null
+++ b/ARM-fix-__get_user_check-in-case-uaccess_-calls-are-not-inlined.patch
@@ -0,0 +1,143 @@
+From patchwork Mon Sep 30 05:59:25 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Masahiro Yamada <yamada.masahiro@socionext.com>
+X-Patchwork-Id: 1132459
+Return-Path: <SRS0=rUXN=XZ=vger.kernel.org=linux-kernel-owner@kernel.org>
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id DF215C4360C
+ for <linux-kernel@archiver.kernel.org>; Mon, 30 Sep 2019 06:02:56 +0000 (UTC)
+Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
+ by mail.kernel.org (Postfix) with ESMTP id B032A20815
+ for <linux-kernel@archiver.kernel.org>; Mon, 30 Sep 2019 06:02:56 +0000 (UTC)
+Authentication-Results: mail.kernel.org;
+ dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com
+ header.b="sVJyT1RO"
+Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
+ id S1729635AbfI3GCz (ORCPT
+ <rfc822;linux-kernel@archiver.kernel.org>);
+ Mon, 30 Sep 2019 02:02:55 -0400
+Received: from conuserg-10.nifty.com ([210.131.2.77]:65305 "EHLO
+ conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
+ with ESMTP id S1726121AbfI3GCz (ORCPT
+ <rfc822;linux-kernel@vger.kernel.org>);
+ Mon, 30 Sep 2019 02:02:55 -0400
+Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp
+ [153.142.97.92]) (authenticated)
+ by conuserg-10.nifty.com with ESMTP id x8U60ANM011158;
+ Mon, 30 Sep 2019 15:00:10 +0900
+DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x8U60ANM011158
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com;
+ s=dec2015msa; t=1569823213;
+ bh=31RHoPop8t0h2pCPRnwABR+VMelvfuLJ6qwFWQxvRAk=;
+ h=From:To:Cc:Subject:Date:From;
+ b=sVJyT1ROU+6mzkZMRTb0M214/0QcKkmxRbNgDwh2q1TPJpEjPLOoE+y1jkVndgyce
+ qBfr7v3nYiN5WSsx5xTwPYvHohsWcSS3AWwyVRw8Kxjd0CGrX8l5WcF76SmCvJPLCB
+ wLRZ7C1/Z/zv9v8AVlB2BGhDmSvNQJ9bvuGi42d+JbBXGDfg0HZGGHEj7yDDLBV9nW
+ EZkTGzP6wtIdqgD6DM5Lj4LA7FnlzH8Ocy6yp5agIZ7tdaiVh4E+Xb97KFsLgRin/o
+ kTPCap5ub1TziurVW+1pbzwH+G3TNVeY+yJdYcAQRFzXXOrTa7s5zIJUtObrYVGCA2
+ ctH5uaN1kjx1g==
+X-Nifty-SrcIP: [153.142.97.92]
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+To: linux-arm-kernel@lists.infradead.org,
+ Russell King <rmk+kernel@armlinux.org.uk>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>,
+ Olof Johansson <olof@lixom.net>, Arnd Bergmann <arnd@arndb.de>,
+ Nick Desaulniers <ndesaulniers@google.com>,
+ Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
+ Masahiro Yamada <yamada.masahiro@socionext.com>,
+ Julien Thierry <julien.thierry.kdev@gmail.com>,
+ Russell King <linux@armlinux.org.uk>,
+ Stefan Agner <stefan@agner.ch>,
+ Thomas Gleixner <tglx@linutronix.de>,
+ Vincent Whitchurch <vincent.whitchurch@axis.com>,
+ linux-kernel@vger.kernel.org
+Subject: [PATCH] ARM: fix __get_user_check() in case uaccess_* calls are not
+ inlined
+Date: Mon, 30 Sep 2019 14:59:25 +0900
+Message-Id: <20190930055925.25842-1-yamada.masahiro@socionext.com>
+X-Mailer: git-send-email 2.17.1
+Sender: linux-kernel-owner@vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List: linux-kernel@vger.kernel.org
+
+KernelCI reports that bcm2835_defconfig is no longer booting since
+commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
+forcibly"):
+
+ https://lkml.org/lkml/2019/9/26/825
+
+I also received a regression report from Nicolas Saenz Julienne:
+
+ https://lkml.org/lkml/2019/9/27/263
+
+This problem has cropped up on arch/arm/config/bcm2835_defconfig
+because it enables CONFIG_CC_OPTIMIZE_FOR_SIZE. The compiler tends
+to prefer not inlining functions with -Os. I was able to reproduce
+it with other boards and defconfig files by manually enabling
+CONFIG_CC_OPTIMIZE_FOR_SIZE.
+
+The __get_user_check() specifically uses r0, r1, r2 registers.
+So, uaccess_save_and_enable() and uaccess_restore() must be inlined
+in order to avoid those registers being overwritten in the callees.
+
+Prior to commit 9012d011660e ("compiler: allow all arches to enable
+CONFIG_OPTIMIZE_INLINING"), the 'inline' marker was always enough for
+inlining functions, except on x86.
+
+Since that commit, all architectures can enable CONFIG_OPTIMIZE_INLINING.
+So, __always_inline is now the only guaranteed way of forcible inlining.
+
+I want to keep as much compiler's freedom as possible about the inlining
+decision. So, I changed the function call order instead of adding
+__always_inline around.
+
+Call uaccess_save_and_enable() before assigning the __p ("r0"), and
+uaccess_restore() after evacuating the __e ("r0").
+
+Fixes: 9012d011660e ("compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING")
+Reported-by: "kernelci.org bot" <bot@kernelci.org>
+Reported-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Tested-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+---
+
+ arch/arm/include/asm/uaccess.h | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
+index 303248e5b990..559f252d7e3c 100644
+--- a/arch/arm/include/asm/uaccess.h
++++ b/arch/arm/include/asm/uaccess.h
+@@ -191,11 +191,12 @@ extern int __get_user_64t_4(void *);
+ #define __get_user_check(x, p) \
+ ({ \
+ unsigned long __limit = current_thread_info()->addr_limit - 1; \
++ unsigned int __ua_flags = uaccess_save_and_enable(); \
+ register typeof(*(p)) __user *__p asm("r0") = (p); \
+ register __inttype(x) __r2 asm("r2"); \
+ register unsigned long __l asm("r1") = __limit; \
+ register int __e asm("r0"); \
+- unsigned int __ua_flags = uaccess_save_and_enable(); \
++ unsigned int __err; \
+ switch (sizeof(*(__p))) { \
+ case 1: \
+ if (sizeof((x)) >= 8) \
+@@ -223,9 +224,10 @@ extern int __get_user_64t_4(void *);
+ break; \
+ default: __e = __get_user_bad(); break; \
+ } \
+- uaccess_restore(__ua_flags); \
++ __err = __e; \
+ x = (typeof(*(p))) __r2; \
+- __e; \
++ uaccess_restore(__ua_flags); \
++ __err; \
+ })
+
+ #define get_user(x, p) \
diff --git a/alsa-5.6.patch b/alsa-5.6.patch
new file mode 100644
index 000000000..b128cc7e6
--- /dev/null
+++ b/alsa-5.6.patch
@@ -0,0 +1,390 @@
+From 4ef91c45a5a283dc8899402bc68adfe0aa9a026d Mon Sep 17 00:00:00 2001
+From: Jaroslav Kysela <perex@perex.cz>
+Date: Wed, 4 Dec 2019 15:15:44 -0600
+Subject: [PATCH 1/4] ASoC: intel/skl/hda - export number of digital
+ microphones via control components
+
+It is required for the auto-detection in the user space (for UCM).
+
+Signed-off-by: Jaroslav Kysela <perex@perex.cz>
+Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Cc: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/r/20191204211556.12671-2-pierre-louis.bossart@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+
+Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
+(cherry picked from commit 8cd9956f61c65022209ce6d1e55ed12aea12357d)
+Bugzilla: 1772498
+---
+ sound/soc/intel/boards/skl_hda_dsp_generic.c | 8 ++++++++
+ sound/soc/sof/intel/hda.c | 3 ++-
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
+index 4e45901e3a2f..11eaee9ae41f 100644
+--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
++++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
+@@ -100,6 +100,8 @@ static struct snd_soc_card hda_soc_card = {
+ .late_probe = skl_hda_card_late_probe,
+ };
+
++static char hda_soc_components[30];
++
+ #define IDISP_DAI_COUNT 3
+ #define HDAC_DAI_COUNT 2
+ #define DMIC_DAI_COUNT 2
+@@ -183,6 +185,12 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
+ hda_soc_card.dev = &pdev->dev;
+ snd_soc_card_set_drvdata(&hda_soc_card, ctx);
+
++ if (mach->mach_params.dmic_num > 0) {
++ snprintf(hda_soc_components, sizeof(hda_soc_components),
++ "cfg-dmics:%d", mach->mach_params.dmic_num);
++ hda_soc_card.components = hda_soc_components;
++ }
++
+ return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
+ }
+
+diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
+index 91bd88fddac7..eea01f75d23d 100644
+--- a/sound/soc/sof/intel/hda.c
++++ b/sound/soc/sof/intel/hda.c
+@@ -351,7 +351,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
+ const char *tplg_filename;
+ const char *idisp_str;
+ const char *dmic_str;
+- int dmic_num;
++ int dmic_num = 0;
+ int codec_num = 0;
+ int i;
+ #endif
+@@ -472,6 +472,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
+ mach_params->codec_mask = bus->codec_mask;
+ mach_params->platform = dev_name(sdev->dev);
+ mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi;
++ mach_params->dmic_num = dmic_num;
+ }
+
+ /* create codec instances */
+--
+2.20.1
+
+
+From 89be5f69889f7e9aeab05279869bba3e9e0d2002 Mon Sep 17 00:00:00 2001
+From: Jaroslav Kysela <perex@perex.cz>
+Date: Wed, 4 Dec 2019 15:15:45 -0600
+Subject: [PATCH 2/4] ASoC: Intel - use control components to describe card
+ config
+
+Use the control interface (field 'components' in the info structure)
+to pass the I/O configuration details. The goal is to replace
+the card long name with this.
+
+Signed-off-by: Jaroslav Kysela <perex@perex.cz>
+Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Cc: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/r/20191204211556.12671-3-pierre-louis.bossart@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+
+Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
+(cherry picked from commit 0d5c8187562848b619a35f2ffc5e18ce703e9f3d)
+Bugzilla: 1772498
+---
+ sound/soc/intel/boards/bytcht_es8316.c | 9 ++++++++-
+ sound/soc/intel/boards/bytcr_rt5640.c | 6 ++++++
+ sound/soc/intel/boards/bytcr_rt5651.c | 18 +++++++++++-------
+ 3 files changed, 25 insertions(+), 8 deletions(-)
+
+diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
+index 46612331f5ea..efa33f30dcac 100644
+--- a/sound/soc/intel/boards/bytcht_es8316.c
++++ b/sound/soc/intel/boards/bytcht_es8316.c
+@@ -361,6 +361,7 @@ static struct snd_soc_dai_link byt_cht_es8316_dais[] = {
+ /* SoC card */
+ static char codec_name[SND_ACPI_I2C_ID_LEN];
+ static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */
++static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */
+
+ static int byt_cht_es8316_suspend(struct snd_soc_card *card)
+ {
+@@ -572,11 +573,17 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
+ }
+ }
+
+- /* register the soc card */
++ snprintf(components_string, sizeof(components_string),
++ "cfg-spk:%s cfg-mic:%s",
++ (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "1" : "2",
++ mic_name[BYT_CHT_ES8316_MAP(quirk)]);
++ byt_cht_es8316_card.components = components_string;
+ snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic",
+ (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo",
+ mic_name[BYT_CHT_ES8316_MAP(quirk)]);
+ byt_cht_es8316_card.long_name = long_name;
++
++ /* register the soc card */
+ snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
+
+ ret = devm_snd_soc_register_card(dev, &byt_cht_es8316_card);
+diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
+index dd2b5ad08659..7bc6d3cec94c 100644
+--- a/sound/soc/intel/boards/bytcr_rt5640.c
++++ b/sound/soc/intel/boards/bytcr_rt5640.c
+@@ -1083,6 +1083,7 @@ static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN];
+ static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */
+ static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
+ static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
++static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */
+
+ static int byt_rt5640_suspend(struct snd_soc_card *card)
+ {
+@@ -1305,6 +1306,11 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
+ }
+ }
+
++ snprintf(byt_rt5640_components, sizeof(byt_rt5640_components),
++ "cfg-spk:%s cfg-mic:%s",
++ (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "1" : "2",
++ map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
++ byt_rt5640_card.components = byt_rt5640_components;
+ snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
+ "bytcr-rt5640-%s-spk-%s-mic",
+ (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ?
+diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
+index 4606f6f582d6..80a5674ddb1b 100644
+--- a/sound/soc/intel/boards/bytcr_rt5651.c
++++ b/sound/soc/intel/boards/bytcr_rt5651.c
+@@ -798,6 +798,7 @@ static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN];
+ static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */
+ static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
+ static char byt_rt5651_long_name[50]; /* = "bytcr-rt5651-*-spk-*-mic[-swapped-hp]" */
++static char byt_rt5651_components[50]; /* = "cfg-spk:* cfg-mic:*" */
+
+ static int byt_rt5651_suspend(struct snd_soc_card *card)
+ {
+@@ -876,7 +877,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
+ const char *platform_name;
+ struct acpi_device *adev;
+ struct device *codec_dev;
+- const char *hp_swapped;
+ bool is_bytcr = false;
+ int ret_val = 0;
+ int dai_index = 0;
+@@ -1080,16 +1080,20 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
+ }
+ }
+
+- if (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED)
+- hp_swapped = "-hp-swapped";
+- else
+- hp_swapped = "";
+-
++ snprintf(byt_rt5651_components, sizeof(byt_rt5651_components),
++ "cfg-spk:%s cfg-mic:%s%s",
++ (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ? "1" : "2",
++ mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)],
++ (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
++ " cfg-hp:lrswap" : "");
++ byt_rt5651_card.components = byt_rt5651_components;
+ snprintf(byt_rt5651_long_name, sizeof(byt_rt5651_long_name),
+ "bytcr-rt5651-%s-spk-%s-mic%s",
+ (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ?
+ "mono" : "stereo",
+- mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)], hp_swapped);
++ mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)],
++ (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
++ "-hp-swapped" : "");
+ byt_rt5651_card.long_name = byt_rt5651_long_name;
+
+ /* override plaform name, if required */
+--
+2.20.1
+
+
+From 36c175e19e9cbb685708519d41e27cd803206737 Mon Sep 17 00:00:00 2001
+From: Jaroslav Kysela <perex@perex.cz>
+Date: Wed, 4 Dec 2019 15:15:46 -0600
+Subject: [PATCH 3/4] ASoC: Intel - do not describe I/O configuration in the
+ long card name
+
+The long card name might be used in GUI. This information should be hidden.
+
+Add CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES configuration option.
+
+Signed-off-by: Jaroslav Kysela <perex@perex.cz>
+Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Cc: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/r/20191204211556.12671-4-pierre-louis.bossart@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+
+Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
+(cherry picked from commit b5706f8ec29fb461571d25e3e813ede121fe31cd)
+Bugzilla: 1772498
+---
+ sound/soc/intel/boards/Kconfig | 13 +++++++++++++
+ sound/soc/intel/boards/bytcht_es8316.c | 4 ++++
+ sound/soc/intel/boards/bytcr_rt5640.c | 4 ++++
+ sound/soc/intel/boards/bytcr_rt5651.c | 4 ++++
+ 4 files changed, 25 insertions(+)
+
+diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
+index ef20316e83d1..145eb55bd691 100644
+--- a/sound/soc/intel/boards/Kconfig
++++ b/sound/soc/intel/boards/Kconfig
+@@ -13,6 +13,19 @@ menuconfig SND_SOC_INTEL_MACH
+
+ if SND_SOC_INTEL_MACH
+
++config SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES
++ bool "Use more user friendly long card names"
++ help
++ Some drivers report the I/O configuration to userspace through the
++ soundcard's long card name in the control user space AP. An unfortunate
++ side effect is that this long name may also be used by the GUI,
++ confusing users with information they don't need.
++ This option prevents the long name from being modified, and the I/O
++ configuration will be provided through a different component interface.
++ Select Y if userspace like UCM (Use Case Manager) uses the component
++ interface.
++ If unsure select N.
++
+ if SND_SOC_INTEL_HASWELL
+
+ config SND_SOC_INTEL_HASWELL_MACH
+diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
+index efa33f30dcac..12a1c5255484 100644
+--- a/sound/soc/intel/boards/bytcht_es8316.c
++++ b/sound/soc/intel/boards/bytcht_es8316.c
+@@ -360,7 +360,9 @@ static struct snd_soc_dai_link byt_cht_es8316_dais[] = {
+
+ /* SoC card */
+ static char codec_name[SND_ACPI_I2C_ID_LEN];
++#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
+ static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */
++#endif
+ static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */
+
+ static int byt_cht_es8316_suspend(struct snd_soc_card *card)
+@@ -578,10 +580,12 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
+ (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "1" : "2",
+ mic_name[BYT_CHT_ES8316_MAP(quirk)]);
+ byt_cht_es8316_card.components = components_string;
++#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
+ snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic",
+ (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo",
+ mic_name[BYT_CHT_ES8316_MAP(quirk)]);
+ byt_cht_es8316_card.long_name = long_name;
++#endif
+
+ /* register the soc card */
+ snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
+diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
+index 7bc6d3cec94c..648fcc1d07b5 100644
+--- a/sound/soc/intel/boards/bytcr_rt5640.c
++++ b/sound/soc/intel/boards/bytcr_rt5640.c
+@@ -1082,7 +1082,9 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = {
+ static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN];
+ static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */
+ static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
++#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
+ static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
++#endif
+ static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */
+
+ static int byt_rt5640_suspend(struct snd_soc_card *card)
+@@ -1311,12 +1313,14 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
+ (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "1" : "2",
+ map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
+ byt_rt5640_card.components = byt_rt5640_components;
++#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
+ snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
+ "bytcr-rt5640-%s-spk-%s-mic",
+ (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ?
+ "mono" : "stereo",
+ map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
+ byt_rt5640_card.long_name = byt_rt5640_long_name;
++#endif
+
+ /* override plaform name, if required */
+ platform_name = mach->mach_params.platform;
+diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
+index 80a5674ddb1b..c0d322a859f7 100644
+--- a/sound/soc/intel/boards/bytcr_rt5651.c
++++ b/sound/soc/intel/boards/bytcr_rt5651.c
+@@ -797,7 +797,9 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = {
+ static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN];
+ static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */
+ static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
++#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
+ static char byt_rt5651_long_name[50]; /* = "bytcr-rt5651-*-spk-*-mic[-swapped-hp]" */
++#endif
+ static char byt_rt5651_components[50]; /* = "cfg-spk:* cfg-mic:*" */
+
+ static int byt_rt5651_suspend(struct snd_soc_card *card)
+@@ -1087,6 +1089,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
+ (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
+ " cfg-hp:lrswap" : "");
+ byt_rt5651_card.components = byt_rt5651_components;
++#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
+ snprintf(byt_rt5651_long_name, sizeof(byt_rt5651_long_name),
+ "bytcr-rt5651-%s-spk-%s-mic%s",
+ (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ?
+@@ -1095,6 +1098,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
+ (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
+ "-hp-swapped" : "");
+ byt_rt5651_card.long_name = byt_rt5651_long_name;
++#endif
+
+ /* override plaform name, if required */
+ platform_name = mach->mach_params.platform;
+--
+2.20.1
+
+
+From 9aa9b367e35494f2d02112ca440a78908f645a04 Mon Sep 17 00:00:00 2001
+From: Jaroslav Kysela <perex@perex.cz>
+Date: Fri, 22 Nov 2019 09:31:03 +0100
+Subject: [PATCH 4/4] ASoC: SOF - topology - do not change the link triger
+ order for old firmare
+
+This is patch for SOF v1.3 firmware. The DSP firmware will crash
+without this patch. The 1.4.1 firmare has this issue fixed.
+
+BugLink: https://github.com/thesofproject/sof/issues/2102
+Signed-off-by: Jaroslav Kysela <perex@perex.cz>
+---
+ sound/soc/sof/topology.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
+index d82ab981e840..cbbbf96416ef 100644
+--- a/sound/soc/sof/topology.c
++++ b/sound/soc/sof/topology.c
+@@ -2971,6 +2971,7 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,
+ struct snd_soc_tplg_private *private = &cfg->priv;
+ struct sof_ipc_dai_config config;
+ struct snd_soc_tplg_hw_config *hw_config;
++ struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
+ int num_hw_configs;
+ int ret;
+ int i = 0;
+@@ -2988,9 +2989,12 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,
+ if (!link->no_pcm) {
+ link->nonatomic = true;
+
+- /* set trigger order */
+- link->trigger[0] = SND_SOC_DPCM_TRIGGER_POST;
+- link->trigger[1] = SND_SOC_DPCM_TRIGGER_POST;
++ /* this causes DSP panic on firmware v1.3 */
++ if (SOF_ABI_VER(v->major, v->minor, v->micro) > SOF_ABI_VER(3, 7, 0)) {
++ /* set trigger order */
++ link->trigger[0] = SND_SOC_DPCM_TRIGGER_POST;
++ link->trigger[1] = SND_SOC_DPCM_TRIGGER_POST;
++ }
+
+ /* nothing more to do for FE dai links */
+ return 0;
+--
+2.20.1
+
diff --git a/arm64-tegra186-enable-USB-on-Jetson-TX2.patch b/arm64-tegra186-enable-USB-on-Jetson-TX2.patch
new file mode 100644
index 000000000..ea0287c2b
--- /dev/null
+++ b/arm64-tegra186-enable-USB-on-Jetson-TX2.patch
@@ -0,0 +1,51 @@
+From e5ccb943712d261b8ebb3e8ac92a82be4b244ce4 Mon Sep 17 00:00:00 2001
+From: Peter Robinson <pbrobinson@gmail.com>
+Date: Sun, 6 Oct 2019 14:44:25 +0100
+Subject: [PATCH] arm64: tegra186: enable USB on Jetson-TX2
+
+Based on the following patch series:
+https://www.spinics.net/lists/linux-tegra/msg44216.html
+
+Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
+---
+ arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts | 4 ++--
+ arch/arm64/boot/dts/nvidia/tegra186.dtsi | 1 +
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts b/arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts
+index bdace01561ba..2e6195764268 100644
+--- a/arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts
++++ b/arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts
+@@ -115,7 +115,7 @@
+ };
+
+ padctl@3520000 {
+- status = "disabled";
++ status = "okay";
+
+ avdd-pll-erefeut-supply = <&vdd_1v8_pll>;
+ avdd-usb-supply = <&vdd_3v3_sys>;
+@@ -193,7 +193,7 @@
+ };
+
+ usb@3530000 {
+- status = "disabled";
++ status = "okay";
+
+ phys = <&{/padctl@3520000/pads/usb2/lanes/usb2-0}>,
+ <&{/padctl@3520000/pads/usb2/lanes/usb2-1}>,
+diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi
+index 47cd831fcf44..abdc81f555b9 100644
+--- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi
++++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi
+@@ -525,6 +525,7 @@
+ <0x0 0x03538000 0x0 0x1000>;
+ reg-names = "hcd", "fpci";
+
++ iommus = <&smmu TEGRA186_SID_XUSB_HOST>;
+ interrupts = <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
+--
+2.21.0
+
diff --git a/arm64-usb-host-xhci-tegra-set-MODULE_FIRMWARE-for-tegra186.patch b/arm64-usb-host-xhci-tegra-set-MODULE_FIRMWARE-for-tegra186.patch
new file mode 100644
index 000000000..b55daaaeb
--- /dev/null
+++ b/arm64-usb-host-xhci-tegra-set-MODULE_FIRMWARE-for-tegra186.patch
@@ -0,0 +1,36 @@
+From 5a39c1ffc4e18603f2c9af3c0a556e2db6e70705 Mon Sep 17 00:00:00 2001
+From: Peter Robinson <pbrobinson@gmail.com>
+Date: Sat, 2 Nov 2019 16:52:15 +0000
+Subject: [PATCH 1/2] usb: host: xhci-tegra: set MODULE_FIRMWARE for tegra186
+
+Set the MODULE_FIRMWARE for tegra186, it's registered for 124/210 and
+ensures the firmware is available at the appropriate time such as in
+the initrd, else if the firmware is unavailable the driver fails with
+the following errors:
+
+tegra-xusb 3530000.usb: Direct firmware load for nvidia/tegra186/xusb.bin failed with error -2
+tegra-xusb 3530000.usb: failed to request firmware: -2
+tegra-xusb 3530000.usb: failed to load firmware: -2
+tegra-xusb: probe of 3530000.usb failed with error -2
+
+Fixes: 5f9be5f3f899 ("usb: host: xhci-tegra: Add Tegra186 XUSB support")
+Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
+---
+ drivers/usb/host/xhci-tegra.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
+index 2ff7c911fbd0..d25aba8fa219 100644
+--- a/drivers/usb/host/xhci-tegra.c
++++ b/drivers/usb/host/xhci-tegra.c
+@@ -1433,6 +1433,7 @@ static const struct tegra_xusb_soc tegra186_soc = {
+ .scale_ss_clock = false,
+ .has_ipfs = false,
+ };
++MODULE_FIRMWARE("nvidia/tegra186/xusb.bin");
+
+ static const struct of_device_id tegra_xusb_of_match[] = {
+ { .compatible = "nvidia,tegra124-xusb", .data = &tegra124_soc },
+--
+2.23.0
+
diff --git a/gpio-max77620-Use-correct-unit-for-debounce-times.patch b/gpio-max77620-Use-correct-unit-for-debounce-times.patch
new file mode 100644
index 000000000..4d4b79d33
--- /dev/null
+++ b/gpio-max77620-Use-correct-unit-for-debounce-times.patch
@@ -0,0 +1,475 @@
+From patchwork Wed Oct 2 12:28:24 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Thierry Reding <thierry.reding@gmail.com>
+X-Patchwork-Id: 1170635
+Return-Path: <linux-gpio-owner@vger.kernel.org>
+X-Original-To: incoming@patchwork.ozlabs.org
+Delivered-To: patchwork-incoming@bilbo.ozlabs.org
+Authentication-Results: ozlabs.org;
+ spf=none (mailfrom) smtp.mailfrom=vger.kernel.org
+ (client-ip=209.132.180.67; helo=vger.kernel.org;
+ envelope-from=linux-gpio-owner@vger.kernel.org;
+ receiver=<UNKNOWN>)
+Authentication-Results: ozlabs.org;
+ dmarc=pass (p=none dis=none) header.from=gmail.com
+Authentication-Results: ozlabs.org; dkim=pass (2048-bit key;
+ unprotected) header.d=gmail.com header.i=@gmail.com
+ header.b="ZNLKx8UP"; dkim-atps=neutral
+Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
+ by ozlabs.org (Postfix) with ESMTP id 46jwRG4D1Dz9sPj
+ for <incoming@patchwork.ozlabs.org>;
+ Wed, 2 Oct 2019 22:28:42 +1000 (AEST)
+Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
+ id S1726684AbfJBM2d (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);
+ Wed, 2 Oct 2019 08:28:33 -0400
+Received: from mail-wr1-f66.google.com ([209.85.221.66]:43919 "EHLO
+ mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
+ with ESMTP id S1725848AbfJBM2c (ORCPT
+ <rfc822; linux-gpio@vger.kernel.org>); Wed, 2 Oct 2019 08:28:32 -0400
+Received: by mail-wr1-f66.google.com with SMTP id q17so19436519wrx.10;
+ Wed, 02 Oct 2019 05:28:30 -0700 (PDT)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
+ h=from:to:cc:subject:date:message-id:in-reply-to:references
+ :mime-version:content-transfer-encoding;
+ bh=iB2sFoZ4x2KF5IYNHgeqY98wXl2bB2JULeTFtyoqdVY=;
+ b=ZNLKx8UP+ukUsboEbPQ9oqLgg5M+37mex1mpr0SgaI7zjToRbmdCJL/chPAEK2r7t8
+ C+RcBU7oQnbO3L1hTZQh1VyMX84xXmn0x8g7AskW0bydPo29O2lwBgM9BeNJiMt7gaS7
+ LtCbNGe/ttaTfoTsJSOmpLgAJLVJ7mpN5r3h18HtAYcsB5NqjcgFF1yFZ9FvmXOIhxAm
+ 1MxDJ7tO9pJbc4JQ8iR/yPEsCNibvlX1qtkuBUWdy6aJHG4CkqIbqb+V+84d3R5bsmoe
+ sDx7f/mMbJ6cF7dCarqOe47Quscz7UkGw/gZywhaYNS/7p6JBvKDCe0bbruzj3MEXMRy
+ 2tlw==
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=1e100.net; s=20161025;
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
+ :references:mime-version:content-transfer-encoding;
+ bh=iB2sFoZ4x2KF5IYNHgeqY98wXl2bB2JULeTFtyoqdVY=;
+ b=E8tcBQ6lyFYE0z3JyOT1cT/Bgc194gfYXxSrFLZnHENJjrNz2Ijr9mgmTvanMcmLgs
+ qvPIH6L5rKKzPpmhxkGCVNMunQuR3U4+g4lCHaJuDE3QikN/dAMpfidmgej7UBcnxYXq
+ c8yhdhWsg36bVdUYmTdrPVNYayH3WqNj6h3724+nRQnwGs5Y+emoWuhckIBZQR2fJd3Z
+ jEEmej1F2QBBv4/Cf7RoOd9BVX1DFI3LgOoGADQcGnuCW/+2clFWp860wnWLGdTGqPKI
+ KCaPoNOzFDkbQCyhebPt8recsiTexB8AmRdTCOszf/TYQwmlvVUUSVqdwY4/P2N0uAGO
+ 8kOA==
+X-Gm-Message-State: APjAAAVWUbix6mCYosiAjDRWTB69Pz3baQGdU6UKJJJba2d6nCyRFzs3
+ w1iyx5KVIbR84BwLezjxgUk=
+X-Google-Smtp-Source: APXvYqylRlhdhO5L5gTZTUh+KEGBPZYsf15BqzctBqRpCy2v75DzIQkOOs8h+NZd8ePk6530OH8SlA==
+X-Received: by 2002:adf:f112:: with SMTP id r18mr2493221wro.88.1570019309276;
+ Wed, 02 Oct 2019 05:28:29 -0700 (PDT)
+Received: from localhost (p2E5BE2CE.dip0.t-ipconnect.de. [46.91.226.206])
+ by smtp.gmail.com with ESMTPSA id
+ h17sm10777194wme.6.2019.10.02.05.28.28
+ (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
+ Wed, 02 Oct 2019 05:28:28 -0700 (PDT)
+From: Thierry Reding <thierry.reding@gmail.com>
+To: Linus Walleij <linus.walleij@linaro.org>,
+ Bartosz Golaszewski <bgolaszewski@baylibre.com>
+Cc: Timo Alho <talho@nvidia.com>, linux-gpio@vger.kernel.org,
+ linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
+Subject: [PATCH 2/3] gpio: max77620: Do not allocate IRQs upfront
+Date: Wed, 2 Oct 2019 14:28:24 +0200
+Message-Id: <20191002122825.3948322-2-thierry.reding@gmail.com>
+X-Mailer: git-send-email 2.23.0
+In-Reply-To: <20191002122825.3948322-1-thierry.reding@gmail.com>
+References: <20191002122825.3948322-1-thierry.reding@gmail.com>
+MIME-Version: 1.0
+Sender: linux-gpio-owner@vger.kernel.org
+Precedence: bulk
+List-ID: <linux-gpio.vger.kernel.org>
+X-Mailing-List: linux-gpio@vger.kernel.org
+
+From: Thierry Reding <treding@nvidia.com>
+
+regmap_add_irq_chip() will try to allocate all of the IRQ descriptors
+upfront if passed a non-zero irq_base parameter. However, the intention
+is to allocate IRQ descriptors on an as-needed basis if possible. Pass 0
+instead of -1 to fix that use-case.
+
+Signed-off-by: Thierry Reding <treding@nvidia.com>
+---
+ drivers/gpio/gpio-max77620.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c
+index faf86ea9c51a..c58b56e5291e 100644
+--- a/drivers/gpio/gpio-max77620.c
++++ b/drivers/gpio/gpio-max77620.c
+@@ -304,7 +304,7 @@ static int max77620_gpio_probe(struct platform_device *pdev)
+ }
+
+ ret = devm_regmap_add_irq_chip(&pdev->dev, chip->rmap, gpio_irq,
+- IRQF_ONESHOT, -1,
++ IRQF_ONESHOT, 0,
+ &max77620_gpio_irq_chip,
+ &chip->gpio_irq_data);
+ if (ret < 0) {
+
+From patchwork Wed Oct 2 12:28:25 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Thierry Reding <thierry.reding@gmail.com>
+X-Patchwork-Id: 1170633
+Return-Path: <linux-gpio-owner@vger.kernel.org>
+X-Original-To: incoming@patchwork.ozlabs.org
+Delivered-To: patchwork-incoming@bilbo.ozlabs.org
+Authentication-Results: ozlabs.org;
+ spf=none (mailfrom) smtp.mailfrom=vger.kernel.org
+ (client-ip=209.132.180.67; helo=vger.kernel.org;
+ envelope-from=linux-gpio-owner@vger.kernel.org;
+ receiver=<UNKNOWN>)
+Authentication-Results: ozlabs.org;
+ dmarc=pass (p=none dis=none) header.from=gmail.com
+Authentication-Results: ozlabs.org; dkim=pass (2048-bit key;
+ unprotected) header.d=gmail.com header.i=@gmail.com
+ header.b="TsA9TpB7"; dkim-atps=neutral
+Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
+ by ozlabs.org (Postfix) with ESMTP id 46jwRD5mmDz9sPq
+ for <incoming@patchwork.ozlabs.org>;
+ Wed, 2 Oct 2019 22:28:40 +1000 (AEST)
+Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
+ id S1727456AbfJBM2f (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);
+ Wed, 2 Oct 2019 08:28:35 -0400
+Received: from mail-wm1-f66.google.com ([209.85.128.66]:34525 "EHLO
+ mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
+ with ESMTP id S1726682AbfJBM2e (ORCPT
+ <rfc822; linux-gpio@vger.kernel.org>); Wed, 2 Oct 2019 08:28:34 -0400
+Received: by mail-wm1-f66.google.com with SMTP id y135so4823030wmc.1;
+ Wed, 02 Oct 2019 05:28:32 -0700 (PDT)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
+ h=from:to:cc:subject:date:message-id:in-reply-to:references
+ :mime-version:content-transfer-encoding;
+ bh=CBafHZOcPLRsPg6HMh6RW3fmvKDiW2MODjit57xEepE=;
+ b=TsA9TpB72Q02EPmaBqcc4zzucsjsdc5mtjgAgTak5YrKh+mRT2HMioWeCxrLu5Cl+6
+ 66PhcUzrRtOnct3yEqC1hueFX+K8TsDr1bJq2f3L5LqA9rYz5Hdk93jVmwyEKtrPUOa5
+ DNgu/r4ppuWX/d9nuLpVLcFGOzWYjz/GSfyRm/B0MNSsiIFx/VfjsK6OQk48uN2gyMPf
+ LsirANA0HYZPyXaUFBkchtTE71HqGFSIzJGUSVGm12Z26puMZ9GiUid1l1XJjdDuFfhU
+ 3k9TQnvLEpZDHArb2G8JrwRI8fRZ/OBDLPyKvH/EEdDYa/FfJOzliZBqMgVFpXpXGTZ6
+ 7YAw==
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=1e100.net; s=20161025;
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
+ :references:mime-version:content-transfer-encoding;
+ bh=CBafHZOcPLRsPg6HMh6RW3fmvKDiW2MODjit57xEepE=;
+ b=MVU3M5NDj2W8TitA2MM98hE9Vgb07UODtrRolwf9TaeTgf2XRMgYAWr9v5zaHvBU2q
+ 4q/HPqbn0WAW3OBfSQLW6CFcdiHOkjfR+r8tKHpNMNBbeDrj1DeeKE/A25plLXxg+Ypz
+ 1bKJe6DPvjIqLvrpVmPADaRtsAkgDFTt/h41ti2uTwS5xq4qEf1mwz6lFyJkGyf+Qjb5
+ pnViJ3Lv89RLBvJwWj0j2t/EzzznPZn9xP663YkNrUNRYrAM7ZBauvK7kMyf8LnKo96E
+ +niJu7OV4PnRspOC8AS3PPM4DHGctXZl6QMcJ1LyPwBkd8EHJioV1iDJKqHQIbxew46f
+ AzCA==
+X-Gm-Message-State: APjAAAWbRYKoHNSgs+vkRdoNeam2jbbuVKAFxN3ysahEdBul5DIjNFsz
+ JRjkPkilW+LPTwy2EmDLNUE=
+X-Google-Smtp-Source: APXvYqyfSTFvcH9+iLVzVGJ5KDEauN0ssdr9eBfIIdRWe8prWnP7KBGuKItc0GAk8lMLMDzdLKlWtw==
+X-Received: by 2002:a1c:7306:: with SMTP id d6mr2864027wmb.62.1570019311374;
+ Wed, 02 Oct 2019 05:28:31 -0700 (PDT)
+Received: from localhost (p2E5BE2CE.dip0.t-ipconnect.de. [46.91.226.206])
+ by smtp.gmail.com with ESMTPSA id
+ 90sm3179450wrr.1.2019.10.02.05.28.30
+ (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
+ Wed, 02 Oct 2019 05:28:30 -0700 (PDT)
+From: Thierry Reding <thierry.reding@gmail.com>
+To: Linus Walleij <linus.walleij@linaro.org>,
+ Bartosz Golaszewski <bgolaszewski@baylibre.com>
+Cc: Timo Alho <talho@nvidia.com>, linux-gpio@vger.kernel.org,
+ linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
+Subject: [PATCH 3/3] gpio: max77620: Fix interrupt handling
+Date: Wed, 2 Oct 2019 14:28:25 +0200
+Message-Id: <20191002122825.3948322-3-thierry.reding@gmail.com>
+X-Mailer: git-send-email 2.23.0
+In-Reply-To: <20191002122825.3948322-1-thierry.reding@gmail.com>
+References: <20191002122825.3948322-1-thierry.reding@gmail.com>
+MIME-Version: 1.0
+Sender: linux-gpio-owner@vger.kernel.org
+Precedence: bulk
+List-ID: <linux-gpio.vger.kernel.org>
+X-Mailing-List: linux-gpio@vger.kernel.org
+
+From: Timo Alho <talho@nvidia.com>
+
+The interrupt-related register fields on the MAX77620 GPIO controller
+share registers with GPIO related fields. If the IRQ chip is implemented
+with regmap-irq, this causes the IRQ controller code to overwrite fields
+previously configured by the GPIO controller code.
+
+Two examples where this causes problems are the NVIDIA Jetson TX1 and
+Jetson TX2 boards, where some of the GPIOs are used to enable vital
+power regulators. The MAX77620 GPIO controller also provides the USB OTG
+ID pin. If configured as an interrupt, this causes some of the
+regulators to be powered off.
+
+Signed-off-by: Timo Alho <talho@nvidia.com>
+Signed-off-by: Thierry Reding <treding@nvidia.com>
+---
+ drivers/gpio/gpio-max77620.c | 231 ++++++++++++++++++-----------------
+ 1 file changed, 117 insertions(+), 114 deletions(-)
+
+diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c
+index c58b56e5291e..c5b64a4ac172 100644
+--- a/drivers/gpio/gpio-max77620.c
++++ b/drivers/gpio/gpio-max77620.c
+@@ -18,109 +18,115 @@ struct max77620_gpio {
+ struct gpio_chip gpio_chip;
+ struct regmap *rmap;
+ struct device *dev;
++ struct mutex buslock; /* irq_bus_lock */
++ unsigned int irq_type[8];
++ bool irq_enabled[8];
+ };
+
+-static const struct regmap_irq max77620_gpio_irqs[] = {
+- [0] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE0,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 0,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [1] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE1,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 1,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [2] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE2,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 2,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [3] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE3,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 3,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [4] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE4,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 4,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [5] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE5,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 5,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [6] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE6,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 6,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+- [7] = {
+- .reg_offset = 0,
+- .mask = MAX77620_IRQ_LVL2_GPIO_EDGE7,
+- .type = {
+- .type_rising_val = MAX77620_CNFG_GPIO_INT_RISING,
+- .type_falling_val = MAX77620_CNFG_GPIO_INT_FALLING,
+- .type_reg_mask = MAX77620_CNFG_GPIO_INT_MASK,
+- .type_reg_offset = 7,
+- .types_supported = IRQ_TYPE_EDGE_BOTH,
+- },
+- },
+-};
++static irqreturn_t max77620_gpio_irqhandler(int irq, void *data)
++{
++ struct max77620_gpio *gpio = data;
++ unsigned int value, offset;
++ unsigned long pending;
++ int err;
++
++ err = regmap_read(gpio->rmap, MAX77620_REG_IRQ_LVL2_GPIO, &value);
++ if (err < 0) {
++ dev_err(gpio->dev, "REG_IRQ_LVL2_GPIO read failed: %d\n", err);
++ return IRQ_NONE;
++ }
++
++ pending = value;
++
++ for_each_set_bit(offset, &pending, 8) {
++ unsigned int virq;
++
++ virq = irq_find_mapping(gpio->gpio_chip.irq.domain, offset);
++ handle_nested_irq(virq);
++ }
++
++ return IRQ_HANDLED;
++}
++
++static void max77620_gpio_irq_mask(struct irq_data *data)
++{
++ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
++ struct max77620_gpio *gpio = gpiochip_get_data(chip);
++
++ gpio->irq_enabled[data->hwirq] = false;
++}
+
+-static const struct regmap_irq_chip max77620_gpio_irq_chip = {
+- .name = "max77620-gpio",
+- .irqs = max77620_gpio_irqs,
+- .num_irqs = ARRAY_SIZE(max77620_gpio_irqs),
+- .num_regs = 1,
+- .num_type_reg = 8,
+- .irq_reg_stride = 1,
+- .type_reg_stride = 1,
+- .status_base = MAX77620_REG_IRQ_LVL2_GPIO,
+- .type_base = MAX77620_REG_GPIO0,
++static void max77620_gpio_irq_unmask(struct irq_data *data)
++{
++ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
++ struct max77620_gpio *gpio = gpiochip_get_data(chip);
++
++ gpio->irq_enabled[data->hwirq] = true;
++}
++
++static int max77620_gpio_set_irq_type(struct irq_data *data, unsigned int type)
++{
++ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
++ struct max77620_gpio *gpio = gpiochip_get_data(chip);
++ unsigned int irq_type;
++
++ switch (type) {
++ case IRQ_TYPE_EDGE_RISING:
++ irq_type = MAX77620_CNFG_GPIO_INT_RISING;
++ break;
++
++ case IRQ_TYPE_EDGE_FALLING:
++ irq_type = MAX77620_CNFG_GPIO_INT_FALLING;
++ break;
++
++ case IRQ_TYPE_EDGE_BOTH:
++ irq_type = MAX77620_CNFG_GPIO_INT_RISING |
++ MAX77620_CNFG_GPIO_INT_FALLING;
++ break;
++
++ default:
++ return -EINVAL;
++ }
++
++ gpio->irq_type[data->hwirq] = irq_type;
++
++ return 0;
++}
++
++static void max77620_gpio_bus_lock(struct irq_data *data)
++{
++ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
++ struct max77620_gpio *gpio = gpiochip_get_data(chip);
++
++ mutex_lock(&gpio->buslock);
++}
++
++static void max77620_gpio_bus_sync_unlock(struct irq_data *data)
++{
++ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
++ struct max77620_gpio *gpio = gpiochip_get_data(chip);
++ unsigned int value, offset = data->hwirq;
++ int err;
++
++ value = gpio->irq_enabled[offset] ? gpio->irq_type[offset] : 0;
++
++ err = regmap_update_bits(gpio->rmap, GPIO_REG_ADDR(offset),
++ MAX77620_CNFG_GPIO_INT_MASK, value);
++ if (err < 0)
++ dev_err(chip->parent, "failed to update interrupt mask: %d\n",
++ err);
++
++ mutex_unlock(&gpio->buslock);
++}
++
++static struct irq_chip max77620_gpio_irqchip = {
++ .name = "max77620-gpio",
++ .irq_mask = max77620_gpio_irq_mask,
++ .irq_unmask = max77620_gpio_irq_unmask,
++ .irq_set_type = max77620_gpio_set_irq_type,
++ .irq_bus_lock = max77620_gpio_bus_lock,
++ .irq_bus_sync_unlock = max77620_gpio_bus_sync_unlock,
++ .flags = IRQCHIP_MASK_ON_SUSPEND,
+ };
+
+ static int max77620_gpio_dir_input(struct gpio_chip *gc, unsigned int offset)
+@@ -254,14 +260,6 @@ static int max77620_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
+ return -ENOTSUPP;
+ }
+
+-static int max77620_gpio_to_irq(struct gpio_chip *gc, unsigned int offset)
+-{
+- struct max77620_gpio *mgpio = gpiochip_get_data(gc);
+- struct max77620_chip *chip = dev_get_drvdata(mgpio->dev->parent);
+-
+- return regmap_irq_get_virq(chip->gpio_irq_data, offset);
+-}
+-
+ static int max77620_gpio_probe(struct platform_device *pdev)
+ {
+ struct max77620_chip *chip = dev_get_drvdata(pdev->dev.parent);
+@@ -287,7 +285,6 @@ static int max77620_gpio_probe(struct platform_device *pdev)
+ mgpio->gpio_chip.direction_output = max77620_gpio_dir_output;
+ mgpio->gpio_chip.set = max77620_gpio_set;
+ mgpio->gpio_chip.set_config = max77620_gpio_set_config;
+- mgpio->gpio_chip.to_irq = max77620_gpio_to_irq;
+ mgpio->gpio_chip.ngpio = MAX77620_GPIO_NR;
+ mgpio->gpio_chip.can_sleep = 1;
+ mgpio->gpio_chip.base = -1;
+@@ -303,15 +300,21 @@ static int max77620_gpio_probe(struct platform_device *pdev)
+ return ret;
+ }
+
+- ret = devm_regmap_add_irq_chip(&pdev->dev, chip->rmap, gpio_irq,
+- IRQF_ONESHOT, 0,
+- &max77620_gpio_irq_chip,
+- &chip->gpio_irq_data);
++ mutex_init(&mgpio->buslock);
++
++ gpiochip_irqchip_add_nested(&mgpio->gpio_chip, &max77620_gpio_irqchip,
++ 0, handle_edge_irq, IRQ_TYPE_NONE);
++
++ ret = request_threaded_irq(gpio_irq, NULL, max77620_gpio_irqhandler,
++ IRQF_ONESHOT, "max77620-gpio", mgpio);
+ if (ret < 0) {
+- dev_err(&pdev->dev, "Failed to add gpio irq_chip %d\n", ret);
++ dev_err(&pdev->dev, "failed to request IRQ: %d\n", ret);
+ return ret;
+ }
+
++ gpiochip_set_nested_irqchip(&mgpio->gpio_chip, &max77620_gpio_irqchip,
++ gpio_irq);
++
+ return 0;
+ }
+
diff --git a/lift-lockdown-sysrq.patch b/lift-lockdown-sysrq.patch
new file mode 100644
index 000000000..b465143fb
--- /dev/null
+++ b/lift-lockdown-sysrq.patch
@@ -0,0 +1,287 @@
+From c2eb371cede78df9a47bf3a125aa9a45dd833da7 Mon Sep 17 00:00:00 2001
+From: Kyle McMartin <kyle@redhat.com>
+Date: Mon, 9 Apr 2018 09:52:45 +0100
+Subject: [PATCH] Add a SysRq option to lift kernel lockdown
+
+Make an option to provide a sysrq key that will lift the kernel lockdown,
+thereby allowing the running kernel image to be accessed and modified.
+
+On x86 this is triggered with SysRq+x, but this key may not be available on
+all arches, so it is set by setting LOCKDOWN_LIFT_KEY in asm/setup.h.
+Since this macro must be defined in an arch to be able to use this facility
+for that arch, the Kconfig option is restricted to arches that support it.
+
+Signed-off-by: Kyle McMartin <kyle@redhat.com>
+Signed-off-by: David Howells <dhowells@redhat.com>
+cc: x86@kernel.org
+Signed-off-by: Jeremy Cline <jcline@redhat.com>
+---
+ arch/x86/include/asm/setup.h | 2 ++
+ drivers/input/misc/uinput.c | 1 +
+ drivers/tty/sysrq.c | 27 +++++++++++++---------
+ include/linux/input.h | 5 +++++
+ include/linux/sysrq.h | 8 ++++++-
+ kernel/debug/kdb/kdb_main.c | 2 +-
+ security/lockdown/Kconfig | 11 +++++++++
+ security/lockdown/lockdown.c | 43 ++++++++++++++++++++++++++++++++++++
+ 8 files changed, 87 insertions(+), 12 deletions(-)
+
+diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
+index ed8ec011a9fd..8daf633a5347 100644
+--- a/arch/x86/include/asm/setup.h
++++ b/arch/x86/include/asm/setup.h
+@@ -9,6 +9,8 @@
+ #include <linux/linkage.h>
+ #include <asm/page_types.h>
+
++#define LOCKDOWN_LIFT_KEY 'x'
++
+ #ifdef __i386__
+
+ #include <linux/pfn.h>
+diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
+index 84051f20b18a..583ab2bc1916 100644
+--- a/drivers/input/misc/uinput.c
++++ b/drivers/input/misc/uinput.c
+@@ -353,6 +353,7 @@ static int uinput_create_device(struct uinput_device *udev)
+ dev->flush = uinput_dev_flush;
+ }
+
++ dev->flags |= INPUTDEV_FLAGS_SYNTHETIC;
+ dev->event = uinput_dev_event;
+
+ input_set_drvdata(udev->dev, udev);
+diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
+index 573b2055173c..99082faafc44 100644
+--- a/drivers/tty/sysrq.c
++++ b/drivers/tty/sysrq.c
+@@ -480,6 +480,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
+ /* x: May be registered on mips for TLB dump */
+ /* x: May be registered on ppc/powerpc for xmon */
+ /* x: May be registered on sparc64 for global PMU dump */
++ /* x: May be registered on x86_64 for disabling secure boot */
+ NULL, /* x */
+ /* y: May be registered on sparc64 for global register dump */
+ NULL, /* y */
+@@ -523,7 +524,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
+ sysrq_key_table[i] = op_p;
+ }
+
+-void __handle_sysrq(int key, bool check_mask)
++void __handle_sysrq(int key, unsigned int from)
+ {
+ struct sysrq_key_op *op_p;
+ int orig_log_level;
+@@ -546,11 +547,15 @@ void __handle_sysrq(int key, bool check_mask)
+
+ op_p = __sysrq_get_key_op(key);
+ if (op_p) {
+- /*
+- * Should we check for enabled operations (/proc/sysrq-trigger
+- * should not) and is the invoked operation enabled?
+- */
+- if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
++ /* Ban synthetic events from some sysrq functionality */
++ if ((from == SYSRQ_FROM_PROC || from == SYSRQ_FROM_SYNTHETIC) &&
++ op_p->enable_mask & SYSRQ_DISABLE_USERSPACE) {
++ printk("This sysrq operation is disabled from userspace.\n");
++ } else if (from == SYSRQ_FROM_KERNEL || sysrq_on_mask(op_p->enable_mask)) {
++ /*
++ * Should we check for enabled operations (/proc/sysrq-trigger
++ * should not) and is the invoked operation enabled?
++ */
+ pr_info("%s\n", op_p->action_msg);
+ console_loglevel = orig_log_level;
+ op_p->handler(key);
+@@ -585,7 +590,7 @@ void __handle_sysrq(int key, bool check_mask)
+ void handle_sysrq(int key)
+ {
+ if (sysrq_on())
+- __handle_sysrq(key, true);
++ __handle_sysrq(key, SYSRQ_FROM_KERNEL);
+ }
+ EXPORT_SYMBOL(handle_sysrq);
+
+@@ -665,7 +670,7 @@ static void sysrq_do_reset(struct timer_list *t)
+ static void sysrq_handle_reset_request(struct sysrq_state *state)
+ {
+ if (state->reset_requested)
+- __handle_sysrq(sysrq_xlate[KEY_B], false);
++ __handle_sysrq(sysrq_xlate[KEY_B], SYSRQ_FROM_KERNEL);
+
+ if (sysrq_reset_downtime_ms)
+ mod_timer(&state->keyreset_timer,
+@@ -818,8 +823,10 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
+
+ default:
+ if (sysrq->active && value && value != 2) {
++ int from = sysrq->handle.dev->flags & INPUTDEV_FLAGS_SYNTHETIC ?
++ SYSRQ_FROM_SYNTHETIC : 0;
+ sysrq->need_reinject = false;
+- __handle_sysrq(sysrq_xlate[code], true);
++ __handle_sysrq(sysrq_xlate[code], from);
+ }
+ break;
+ }
+@@ -1102,7 +1109,7 @@ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
+
+ if (get_user(c, buf))
+ return -EFAULT;
+- __handle_sysrq(c, false);
++ __handle_sysrq(c, SYSRQ_FROM_PROC);
+ }
+
+ return count;
+diff --git a/include/linux/input.h b/include/linux/input.h
+index 94f277cd806a..8539afa2c001 100644
+--- a/include/linux/input.h
++++ b/include/linux/input.h
+@@ -48,6 +48,7 @@ enum input_clock_type {
+ * @phys: physical path to the device in the system hierarchy
+ * @uniq: unique identification code for the device (if device has it)
+ * @id: id of the device (struct input_id)
++ * @flags: input device flags (SYNTHETIC, etc.)
+ * @propbit: bitmap of device properties and quirks
+ * @evbit: bitmap of types of events supported by the device (EV_KEY,
+ * EV_REL, etc.)
+@@ -134,6 +135,8 @@ struct input_dev {
+ const char *uniq;
+ struct input_id id;
+
++ unsigned int flags;
++
+ unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
+
+ unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
+@@ -204,6 +207,8 @@ struct input_dev {
+ };
+ #define to_input_dev(d) container_of(d, struct input_dev, dev)
+
++#define INPUTDEV_FLAGS_SYNTHETIC 0x000000001
++
+ /*
+ * Verify that we are in sync with input_device_id mod_devicetable.h #defines
+ */
+diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
+index 8c71874e8485..7de1f08b60a9 100644
+--- a/include/linux/sysrq.h
++++ b/include/linux/sysrq.h
+@@ -29,6 +29,8 @@
+ #define SYSRQ_ENABLE_BOOT 0x0080
+ #define SYSRQ_ENABLE_RTNICE 0x0100
+
++#define SYSRQ_DISABLE_USERSPACE 0x00010000
++
+ struct sysrq_key_op {
+ void (*handler)(int);
+ char *help_msg;
+@@ -43,8 +45,12 @@ struct sysrq_key_op {
+ * are available -- else NULL's).
+ */
+
++#define SYSRQ_FROM_KERNEL 0x0001
++#define SYSRQ_FROM_PROC 0x0002
++#define SYSRQ_FROM_SYNTHETIC 0x0004
++
+ void handle_sysrq(int key);
+-void __handle_sysrq(int key, bool check_mask);
++void __handle_sysrq(int key, unsigned int from);
+ int register_sysrq_key(int key, struct sysrq_key_op *op);
+ int unregister_sysrq_key(int key, struct sysrq_key_op *op);
+ struct sysrq_key_op *__sysrq_get_key_op(int key);
+diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
+index 4567fe998c30..d05142ef44c4 100644
+--- a/kernel/debug/kdb/kdb_main.c
++++ b/kernel/debug/kdb/kdb_main.c
+@@ -1981,7 +1981,7 @@ static int kdb_sr(int argc, const char **argv)
+ return KDB_ARGCOUNT;
+
+ kdb_trap_printk++;
+- __handle_sysrq(*argv[1], check_mask);
++ __handle_sysrq(*argv[1], check_mask ? SYSRQ_FROM_KERNEL : 0);
+ kdb_trap_printk--;
+
+ return 0;
+diff --git a/security/lockdown/Kconfig b/security/lockdown/Kconfig
+index e84ddf484010..20e979178e1c 100644
+--- a/security/lockdown/Kconfig
++++ b/security/lockdown/Kconfig
+@@ -45,3 +45,14 @@ config LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY
+ disabled.
+
+ endchoice
++
++config ALLOW_LOCKDOWN_LIFT_BY_SYSRQ
++ bool "Allow the kernel lockdown to be lifted by SysRq"
++ depends on SECURITY_LOCKDOWN_LSM
++ depends on !LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY
++ depends on !LOCK_DOWN_KERNEL_FORCE_INTEGRITY
++ depends on MAGIC_SYSRQ
++ depends on X86
++ help
++ Allow setting the lockdown mode to "none" by pressing a SysRq key
++ combination on a wired keyboard. On x86, this is SysRq+x
+diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
+index 8a10b43daf74..df4662257309 100644
+--- a/security/lockdown/lockdown.c
++++ b/security/lockdown/lockdown.c
+@@ -13,6 +13,8 @@
+ #include <linux/security.h>
+ #include <linux/export.h>
+ #include <linux/lsm_hooks.h>
++#include <linux/sysrq.h>
++#include <asm/setup.h>
+
+ static enum lockdown_reason kernel_locked_down;
+
+@@ -179,6 +181,47 @@ static int __init lockdown_secfs_init(void)
+ return PTR_ERR_OR_ZERO(dentry);
+ }
+
++#ifdef CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ
++
++/*
++ * Take the kernel out of lockdown mode.
++ */
++static void lift_kernel_lockdown(void)
++{
++ pr_notice("Lifting lockdown\n");
++ kernel_locked_down = LOCKDOWN_NONE;
++}
++
++/*
++ * Allow lockdown to be lifted by pressing something like SysRq+x (and not by
++ * echoing the appropriate letter into the sysrq-trigger file).
++ */
++static void sysrq_handle_lockdown_lift(int key)
++{
++ if (kernel_locked_down)
++ lift_kernel_lockdown();
++}
++
++static struct sysrq_key_op lockdown_lift_sysrq_op = {
++ .handler = sysrq_handle_lockdown_lift,
++ .help_msg = "unSB(x)",
++ .action_msg = "Disabling Secure Boot restrictions",
++ .enable_mask = SYSRQ_DISABLE_USERSPACE,
++};
++
++static int __init lockdown_lift_sysrq(void)
++{
++ if (kernel_locked_down) {
++ lockdown_lift_sysrq_op.help_msg[5] = LOCKDOWN_LIFT_KEY;
++ register_sysrq_key(LOCKDOWN_LIFT_KEY, &lockdown_lift_sysrq_op);
++ }
++ return 0;
++}
++
++late_initcall(lockdown_lift_sysrq);
++
++#endif /* CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ */
++
+ core_initcall(lockdown_secfs_init);
+
+ #ifdef CONFIG_SECURITY_LOCKDOWN_LSM_EARLY
+--
+2.21.0
+