+++ /dev/null
-From 3c499ea0c662e2f38aafbd4f516b08aab8cfa0e5 Mon Sep 17 00:00:00 2001
-From: Lyude Paul <lyude@redhat.com>
-Date: Mon, 17 Sep 2018 13:37:33 -0400
-Subject: drm/atomic: Use drm_drv_uses_atomic_modeset() for debugfs creation
-
-From: Lyude Paul <lyude@redhat.com>
-
-commit 3c499ea0c662e2f38aafbd4f516b08aab8cfa0e5 upstream.
-
-As pointed out by Daniel Vetter, we should be usinng
-drm_drv_uses_atomic_modeset() for determining whether or not we want to
-make the debugfs nodes for atomic instead of checking DRIVER_ATOMIC, as
-the former isn't an accurate representation of whether or not the driver
-is actually using atomic modesetting internally (even though it might
-not be exposing atomic capabilities).
-
-Signed-off-by: Lyude Paul <lyude@redhat.com>
-Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
-Cc: stable@vger.kernel.org
-Reviewed-by: Sean Paul <seanpaul@chromium.org>
-Link: https://patchwork.freedesktop.org/patch/msgid/20180917173733.21293-1-lyude@redhat.com
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/gpu/drm/drm_atomic.c | 2 +-
- drivers/gpu/drm/drm_debugfs.c | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
---- a/drivers/gpu/drm/drm_atomic.c
-+++ b/drivers/gpu/drm/drm_atomic.c
-@@ -1748,7 +1748,7 @@ static void __drm_state_dump(struct drm_
- struct drm_connector *connector;
- struct drm_connector_list_iter conn_iter;
-
-- if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
-+ if (!drm_drv_uses_atomic_modeset(dev))
- return;
-
- list_for_each_entry(plane, &config->plane_list, head) {
---- a/drivers/gpu/drm/drm_debugfs.c
-+++ b/drivers/gpu/drm/drm_debugfs.c
-@@ -150,7 +150,7 @@ int drm_debugfs_init(struct drm_minor *m
- return ret;
- }
-
-- if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
-+ if (drm_drv_uses_atomic_modeset(dev)) {
- ret = drm_atomic_debugfs_init(minor);
- if (ret) {
- DRM_ERROR("Failed to create atomic debugfs files\n");
drm-vc4-fix-the-no-scaling-case-on-multi-planar-yuv-formats.patch
drm-udl-destroy-framebuffer-only-if-it-was-initialized.patch
drm-amdgpu-add-new-polaris-pci-id.patch
-drm-atomic-use-drm_drv_uses_atomic_modeset-for-debugfs-creation.patch
tty-vt_ioctl-fix-potential-spectre-v1.patch
ext4-check-to-make-sure-the-rename-2-s-destination-is-not-freed.patch
ext4-avoid-divide-by-zero-fault-when-deleting-corrupted-inline-directories.patch
vmw_balloon-include-asm-io.h.patch
iw_cxgb4-only-allow-1-flush-on-user-qps.patch
tick-nohz-prevent-bogus-softirq-pending-warning.patch
+spi-fix-double-idr-allocation-with-dt-aliases.patch
--- /dev/null
+From 04b2d03a75652bda989de1595048f0501dc0c0a0 Mon Sep 17 00:00:00 2001
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+Date: Tue, 21 Aug 2018 11:53:03 +0200
+Subject: spi: Fix double IDR allocation with DT aliases
+
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+
+commit 04b2d03a75652bda989de1595048f0501dc0c0a0 upstream.
+
+If the SPI bus number is provided by a DT alias, idr_alloc() is called
+twice, leading to:
+
+ WARNING: CPU: 1 PID: 1 at drivers/spi/spi.c:2179 spi_register_controller+0x11c/0x5d8
+ couldn't get idr
+
+Fix this by moving the handling of fixed SPI bus numbers up, before the
+DT handling code fills in ctlr->bus_num.
+
+Fixes: 1a4327fbf4554d5b ("spi: fix IDR collision on systems with both fixed and dynamic SPI bus numbers")
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+Cc: Kirill Kapranov <kirill.kapranov@compulab.co.il>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/spi/spi.c | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+--- a/drivers/spi/spi.c
++++ b/drivers/spi/spi.c
+@@ -2108,8 +2108,17 @@ int spi_register_controller(struct spi_c
+ */
+ if (ctlr->num_chipselect == 0)
+ return -EINVAL;
+- /* allocate dynamic bus number using Linux idr */
+- if ((ctlr->bus_num < 0) && ctlr->dev.of_node) {
++ if (ctlr->bus_num >= 0) {
++ /* devices with a fixed bus num must check-in with the num */
++ mutex_lock(&board_lock);
++ id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
++ ctlr->bus_num + 1, GFP_KERNEL);
++ mutex_unlock(&board_lock);
++ if (WARN(id < 0, "couldn't get idr"))
++ return id == -ENOSPC ? -EBUSY : id;
++ ctlr->bus_num = id;
++ } else if (ctlr->dev.of_node) {
++ /* allocate dynamic bus number using Linux idr */
+ id = of_alias_get_id(ctlr->dev.of_node, "spi");
+ if (id >= 0) {
+ ctlr->bus_num = id;
+@@ -2135,15 +2144,6 @@ int spi_register_controller(struct spi_c
+ if (WARN(id < 0, "couldn't get idr"))
+ return id;
+ ctlr->bus_num = id;
+- } else {
+- /* devices with a fixed bus num must check-in with the num */
+- mutex_lock(&board_lock);
+- id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
+- ctlr->bus_num + 1, GFP_KERNEL);
+- mutex_unlock(&board_lock);
+- if (WARN(id < 0, "couldn't get idr"))
+- return id == -ENOSPC ? -EBUSY : id;
+- ctlr->bus_num = id;
+ }
+ INIT_LIST_HEAD(&ctlr->queue);
+ spin_lock_init(&ctlr->queue_lock);