From 51a26c6f67b3cf27ee7fc2012f78342527ef65d0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 15 Jun 2017 14:58:48 +0200 Subject: [PATCH] 4.9-stable patches added patches: drm-nouveau-handle-fbcon-suspend-resume-in-seperate-worker.patch drm-nouveau-intercept-acpi_video_notify_probe.patch drm-nouveau-rename-acpi_work-to-hpd_work.patch gtp-add-genl-family-modules-alias.patch --- ...on-suspend-resume-in-seperate-worker.patch | 115 +++++++++++++ ...au-intercept-acpi_video_notify_probe.patch | 158 ++++++++++++++++++ ...nouveau-rename-acpi_work-to-hpd_work.patch | 106 ++++++++++++ .../gtp-add-genl-family-modules-alias.patch | 30 ++++ queue-4.9/series | 4 + 5 files changed, 413 insertions(+) create mode 100644 queue-4.9/drm-nouveau-handle-fbcon-suspend-resume-in-seperate-worker.patch create mode 100644 queue-4.9/drm-nouveau-intercept-acpi_video_notify_probe.patch create mode 100644 queue-4.9/drm-nouveau-rename-acpi_work-to-hpd_work.patch create mode 100644 queue-4.9/gtp-add-genl-family-modules-alias.patch diff --git a/queue-4.9/drm-nouveau-handle-fbcon-suspend-resume-in-seperate-worker.patch b/queue-4.9/drm-nouveau-handle-fbcon-suspend-resume-in-seperate-worker.patch new file mode 100644 index 00000000000..5b8b5174e33 --- /dev/null +++ b/queue-4.9/drm-nouveau-handle-fbcon-suspend-resume-in-seperate-worker.patch @@ -0,0 +1,115 @@ +From foo@baz Thu Jun 15 14:56:50 CEST 2017 +From: Lyude Paul +Date: Wed, 11 Jan 2017 21:25:24 -0500 +Subject: drm/nouveau: Handle fbcon suspend/resume in seperate worker + +From: Lyude Paul + + +[ Upstream commit 15266ae38fe09dae07bd8812cb7a7717b1e1d992 ] + +Resuming from RPM can happen while already holding +dev->mode_config.mutex. This means we can't actually handle fbcon in +any RPM resume workers, since restoring fbcon requires grabbing +dev->mode_config.mutex again. So move the fbcon suspend/resume code into +it's own worker, and rely on that instead to avoid deadlocking. + +This fixes more deadlocks for runtime suspending the GPU on the ThinkPad +W541. Reproduction recipe: + + - Get a machine with both optimus and a nvidia card with connectors + attached to it + - Wait for the nvidia GPU to suspend + - Attempt to manually reprobe any of the connectors on the nvidia GPU + using sysfs + - *deadlock* + +[airlied: use READ_ONCE to address Hans's comment] + +Signed-off-by: Lyude +Cc: Hans de Goede +Cc: Kilian Singer +Cc: Lukas Wunner +Cc: David Airlie +Signed-off-by: Dave Airlie +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nouveau_drv.h | 2 + + drivers/gpu/drm/nouveau/nouveau_fbcon.c | 43 +++++++++++++++++++++++++------- + 2 files changed, 36 insertions(+), 9 deletions(-) + +--- a/drivers/gpu/drm/nouveau/nouveau_drv.h ++++ b/drivers/gpu/drm/nouveau/nouveau_drv.h +@@ -164,6 +164,8 @@ struct nouveau_drm { + struct nouveau_display *display; + struct backlight_device *backlight; + struct work_struct hpd_work; ++ struct work_struct fbcon_work; ++ int fbcon_new_state; + #ifdef CONFIG_ACPI + struct notifier_block acpi_nb; + #endif +--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c ++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c +@@ -491,19 +491,43 @@ static const struct drm_fb_helper_funcs + .fb_probe = nouveau_fbcon_create, + }; + ++static void ++nouveau_fbcon_set_suspend_work(struct work_struct *work) ++{ ++ struct nouveau_drm *drm = container_of(work, typeof(*drm), fbcon_work); ++ int state = READ_ONCE(drm->fbcon_new_state); ++ ++ if (state == FBINFO_STATE_RUNNING) ++ pm_runtime_get_sync(drm->dev->dev); ++ ++ console_lock(); ++ if (state == FBINFO_STATE_RUNNING) ++ nouveau_fbcon_accel_restore(drm->dev); ++ drm_fb_helper_set_suspend(&drm->fbcon->helper, state); ++ if (state != FBINFO_STATE_RUNNING) ++ nouveau_fbcon_accel_save_disable(drm->dev); ++ console_unlock(); ++ ++ if (state == FBINFO_STATE_RUNNING) { ++ pm_runtime_mark_last_busy(drm->dev->dev); ++ pm_runtime_put_sync(drm->dev->dev); ++ } ++} ++ + void + nouveau_fbcon_set_suspend(struct drm_device *dev, int state) + { + struct nouveau_drm *drm = nouveau_drm(dev); +- if (drm->fbcon) { +- console_lock(); +- if (state == FBINFO_STATE_RUNNING) +- nouveau_fbcon_accel_restore(dev); +- drm_fb_helper_set_suspend(&drm->fbcon->helper, state); +- if (state != FBINFO_STATE_RUNNING) +- nouveau_fbcon_accel_save_disable(dev); +- console_unlock(); +- } ++ ++ if (!drm->fbcon) ++ return; ++ ++ drm->fbcon_new_state = state; ++ /* Since runtime resume can happen as a result of a sysfs operation, ++ * it's possible we already have the console locked. So handle fbcon ++ * init/deinit from a seperate work thread ++ */ ++ schedule_work(&drm->fbcon_work); + } + + int +@@ -524,6 +548,7 @@ nouveau_fbcon_init(struct drm_device *de + + fbcon->dev = dev; + drm->fbcon = fbcon; ++ INIT_WORK(&drm->fbcon_work, nouveau_fbcon_set_suspend_work); + + drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs); + diff --git a/queue-4.9/drm-nouveau-intercept-acpi_video_notify_probe.patch b/queue-4.9/drm-nouveau-intercept-acpi_video_notify_probe.patch new file mode 100644 index 00000000000..e2ae62a3b2a --- /dev/null +++ b/queue-4.9/drm-nouveau-intercept-acpi_video_notify_probe.patch @@ -0,0 +1,158 @@ +From foo@baz Thu Jun 15 14:56:50 CEST 2017 +From: Hans de Goede +Date: Wed, 9 Nov 2016 18:17:44 +0100 +Subject: drm/nouveau: Intercept ACPI_VIDEO_NOTIFY_PROBE + +From: Hans de Goede + + +[ Upstream commit 3a6536c51d5db3adf58dcd466a3aee6233b58544 ] + +Various notebooks with nvidia GPUs generate an ACPI_VIDEO_NOTIFY_PROBE +acpi-video event when an external device gets plugged in (and again on +modesets on that connector), the default behavior in the acpi-video +driver for this is to send a KEY_SWITCHVIDEOMODE evdev event, which +causes e.g. gnome-settings-daemon to ask us to rescan the connectors +(good), but also causes g-s-d to switch to mirror mode on a newly plugged +monitor rather then using the monitor to extend the desktop (bad) +as KEY_SWITCHVIDEOMODE is supposed to switch between extend the desktop +vs mirror mode. + +More troublesome are the repeated ACPI_VIDEO_NOTIFY_PROBE events on +changing the mode on the connector, which cause g-s-d to switch +between mirror/extend mode, which causes a new ACPI_VIDEO_NOTIFY_PROBE +event and we end up with an endless loop. + +This commit fixes this by adding an acpi notifier block handler to +nouveau_display.c to intercept ACPI_VIDEO_NOTIFY_PROBE and: + +1) Wake-up runtime suspended GPUs and call drm_helper_hpd_irq_event() + on them, this is necessary in some cases for the GPU to detect connector + hotplug events while runtime suspended +2) Return NOTIFY_BAD to stop acpi-video from emitting a bogus + KEY_SWITCHVIDEOMODE key-press event + +There already is another acpi notifier block handler registered in +drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.c, but that is not +suitable since that one gets unregistered on runtime suspend, and +we also want to intercept ACPI_VIDEO_NOTIFY_PROBE when runtime suspended. + +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nouveau_display.c | 59 ++++++++++++++++++++++++++++++ + drivers/gpu/drm/nouveau/nouveau_drv.h | 6 +++ + 2 files changed, 65 insertions(+) + +--- a/drivers/gpu/drm/nouveau/nouveau_display.c ++++ b/drivers/gpu/drm/nouveau/nouveau_display.c +@@ -24,6 +24,7 @@ + * + */ + ++#include + #include + #include + +@@ -358,6 +359,55 @@ static struct nouveau_drm_prop_enum_list + } \ + } while(0) + ++#ifdef CONFIG_ACPI ++ ++/* ++ * Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch ++ * to the acpi subsys to move it there from drivers/acpi/acpi_video.c . ++ * This should be dropped once that is merged. ++ */ ++#ifndef ACPI_VIDEO_NOTIFY_PROBE ++#define ACPI_VIDEO_NOTIFY_PROBE 0x81 ++#endif ++ ++static void ++nouveau_display_acpi_work(struct work_struct *work) ++{ ++ struct nouveau_drm *drm = container_of(work, typeof(*drm), acpi_work); ++ ++ pm_runtime_get_sync(drm->dev->dev); ++ ++ drm_helper_hpd_irq_event(drm->dev); ++ ++ pm_runtime_mark_last_busy(drm->dev->dev); ++ pm_runtime_put_sync(drm->dev->dev); ++} ++ ++static int ++nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val, ++ void *data) ++{ ++ struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb); ++ struct acpi_bus_event *info = data; ++ ++ if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) { ++ if (info->type == ACPI_VIDEO_NOTIFY_PROBE) { ++ /* ++ * This may be the only indication we receive of a ++ * connector hotplug on a runtime suspended GPU, ++ * schedule acpi_work to check. ++ */ ++ schedule_work(&drm->acpi_work); ++ ++ /* acpi-video should not generate keypresses for this */ ++ return NOTIFY_BAD; ++ } ++ } ++ ++ return NOTIFY_DONE; ++} ++#endif ++ + int + nouveau_display_init(struct drm_device *dev) + { +@@ -537,6 +587,12 @@ nouveau_display_create(struct drm_device + } + + nouveau_backlight_init(dev); ++#ifdef CONFIG_ACPI ++ INIT_WORK(&drm->acpi_work, nouveau_display_acpi_work); ++ drm->acpi_nb.notifier_call = nouveau_display_acpi_ntfy; ++ register_acpi_notifier(&drm->acpi_nb); ++#endif ++ + return 0; + + vblank_err: +@@ -552,6 +608,9 @@ nouveau_display_destroy(struct drm_devic + { + struct nouveau_display *disp = nouveau_display(dev); + ++#ifdef CONFIG_ACPI ++ unregister_acpi_notifier(&nouveau_drm(dev)->acpi_nb); ++#endif + nouveau_backlight_exit(dev); + nouveau_display_vblank_fini(dev); + +--- a/drivers/gpu/drm/nouveau/nouveau_drv.h ++++ b/drivers/gpu/drm/nouveau/nouveau_drv.h +@@ -37,6 +37,8 @@ + * - implemented limited ABI16/NVIF interop + */ + ++#include ++ + #include + #include + #include +@@ -161,6 +163,10 @@ struct nouveau_drm { + struct nvbios vbios; + struct nouveau_display *display; + struct backlight_device *backlight; ++#ifdef CONFIG_ACPI ++ struct notifier_block acpi_nb; ++ struct work_struct acpi_work; ++#endif + + /* power management */ + struct nouveau_hwmon *hwmon; diff --git a/queue-4.9/drm-nouveau-rename-acpi_work-to-hpd_work.patch b/queue-4.9/drm-nouveau-rename-acpi_work-to-hpd_work.patch new file mode 100644 index 00000000000..22ac26cfcf2 --- /dev/null +++ b/queue-4.9/drm-nouveau-rename-acpi_work-to-hpd_work.patch @@ -0,0 +1,106 @@ +From foo@baz Thu Jun 15 14:56:50 CEST 2017 +From: Hans de Goede +Date: Mon, 21 Nov 2016 17:50:54 +0100 +Subject: drm/nouveau: Rename acpi_work to hpd_work + +From: Hans de Goede + + +[ Upstream commit 81280d0e24e76c35f40f997af26c779bcb10b04d ] + +We need to call drm_helper_hpd_irq_event() on resume to properly detect +monitor connection / disconnection on some laptops. For runtime-resume +(which gets called on resume from normal suspend too) we must call +drm_helper_hpd_irq_event() from a workqueue to avoid a deadlock. + +Rename acpi_work to hpd_work, and move it out of the #ifdef CONFIG_ACPI +blocks to make it suitable for generic work. + +Signed-off-by: Hans de Goede +Signed-off-by: Ben Skeggs +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nouveau_display.c | 32 +++++++++++++++--------------- + drivers/gpu/drm/nouveau/nouveau_drv.h | 2 - + 2 files changed, 17 insertions(+), 17 deletions(-) + +--- a/drivers/gpu/drm/nouveau/nouveau_display.c ++++ b/drivers/gpu/drm/nouveau/nouveau_display.c +@@ -359,21 +359,10 @@ static struct nouveau_drm_prop_enum_list + } \ + } while(0) + +-#ifdef CONFIG_ACPI +- +-/* +- * Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch +- * to the acpi subsys to move it there from drivers/acpi/acpi_video.c . +- * This should be dropped once that is merged. +- */ +-#ifndef ACPI_VIDEO_NOTIFY_PROBE +-#define ACPI_VIDEO_NOTIFY_PROBE 0x81 +-#endif +- + static void +-nouveau_display_acpi_work(struct work_struct *work) ++nouveau_display_hpd_work(struct work_struct *work) + { +- struct nouveau_drm *drm = container_of(work, typeof(*drm), acpi_work); ++ struct nouveau_drm *drm = container_of(work, typeof(*drm), hpd_work); + + pm_runtime_get_sync(drm->dev->dev); + +@@ -383,6 +372,17 @@ nouveau_display_acpi_work(struct work_st + pm_runtime_put_sync(drm->dev->dev); + } + ++#ifdef CONFIG_ACPI ++ ++/* ++ * Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch ++ * to the acpi subsys to move it there from drivers/acpi/acpi_video.c . ++ * This should be dropped once that is merged. ++ */ ++#ifndef ACPI_VIDEO_NOTIFY_PROBE ++#define ACPI_VIDEO_NOTIFY_PROBE 0x81 ++#endif ++ + static int + nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val, + void *data) +@@ -395,9 +395,9 @@ nouveau_display_acpi_ntfy(struct notifie + /* + * This may be the only indication we receive of a + * connector hotplug on a runtime suspended GPU, +- * schedule acpi_work to check. ++ * schedule hpd_work to check. + */ +- schedule_work(&drm->acpi_work); ++ schedule_work(&drm->hpd_work); + + /* acpi-video should not generate keypresses for this */ + return NOTIFY_BAD; +@@ -587,8 +587,8 @@ nouveau_display_create(struct drm_device + } + + nouveau_backlight_init(dev); ++ INIT_WORK(&drm->hpd_work, nouveau_display_hpd_work); + #ifdef CONFIG_ACPI +- INIT_WORK(&drm->acpi_work, nouveau_display_acpi_work); + drm->acpi_nb.notifier_call = nouveau_display_acpi_ntfy; + register_acpi_notifier(&drm->acpi_nb); + #endif +--- a/drivers/gpu/drm/nouveau/nouveau_drv.h ++++ b/drivers/gpu/drm/nouveau/nouveau_drv.h +@@ -163,9 +163,9 @@ struct nouveau_drm { + struct nvbios vbios; + struct nouveau_display *display; + struct backlight_device *backlight; ++ struct work_struct hpd_work; + #ifdef CONFIG_ACPI + struct notifier_block acpi_nb; +- struct work_struct acpi_work; + #endif + + /* power management */ diff --git a/queue-4.9/gtp-add-genl-family-modules-alias.patch b/queue-4.9/gtp-add-genl-family-modules-alias.patch new file mode 100644 index 00000000000..ecd9b59f75d --- /dev/null +++ b/queue-4.9/gtp-add-genl-family-modules-alias.patch @@ -0,0 +1,30 @@ +From foo@baz Thu Jun 15 14:56:50 CEST 2017 +From: Andreas Schultz +Date: Fri, 27 Jan 2017 10:40:56 +0100 +Subject: gtp: add genl family modules alias + +From: Andreas Schultz + + +[ Upstream commit ab729823ec16aef384f09fd2cffe0b3d3f6e6cba ] + +Auto-load the module when userspace asks for the gtp netlink +family. + +Signed-off-by: Andreas Schultz +Acked-by: Harald Welte +Acked-by: Pablo Neira Ayuso +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/gtp.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/gtp.c ++++ b/drivers/net/gtp.c +@@ -1372,3 +1372,4 @@ MODULE_LICENSE("GPL"); + MODULE_AUTHOR("Harald Welte "); + MODULE_DESCRIPTION("Interface driver for GTP encapsulated traffic"); + MODULE_ALIAS_RTNL_LINK("gtp"); ++MODULE_ALIAS_GENL_FAMILY("gtp"); diff --git a/queue-4.9/series b/queue-4.9/series index 34a843c7616..9480beca8ac 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -55,3 +55,7 @@ net-mlx5-e-switch-err-when-retrieving-steering-name-space-fails.patch net-mlx5-return-eopnotsupp-when-failing-to-get-steering-name-space.patch parisc-parport_gsc-fixes-for-printk-continuation-lines.patch net-phy-micrel-add-support-for-ksz8795.patch +gtp-add-genl-family-modules-alias.patch +drm-nouveau-intercept-acpi_video_notify_probe.patch +drm-nouveau-rename-acpi_work-to-hpd_work.patch +drm-nouveau-handle-fbcon-suspend-resume-in-seperate-worker.patch -- 2.47.3