public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>,
	Sasha Levin <alexander.levin@verizon.com>
Subject: [PATCH 4.9 059/108] drm/nouveau: Intercept ACPI_VIDEO_NOTIFY_PROBE
Date: Thu, 15 Jun 2017 19:53:05 +0200	[thread overview]
Message-ID: <20170615175339.992569615@linuxfoundation.org> (raw)
In-Reply-To: <20170615175337.190782107@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Hans de Goede <hdegoede@redhat.com>


[ 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 <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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 <acpi/video.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 
@@ -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 <linux/notifier.h>
+
 #include <nvif/client.h>
 #include <nvif/device.h>
 #include <nvif/ioctl.h>
@@ -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;

  parent reply	other threads:[~2017-06-15 18:07 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 17:52 [PATCH 4.9 000/108] 4.9.33-stable review Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 001/108] PCI/PM: Add needs_resume flag to avoid suspend complete optimization Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 003/108] partitions/msdos: FreeBSD UFS2 file systems are not recognized Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 004/108] netfilter: nf_conntrack_sip: fix wrong memory initialisation Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 005/108] ibmvnic: Fix endian errors in error reporting output Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 006/108] ibmvnic: Fix endian error when requesting device capabilities Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 007/108] net: xilinx_emaclite: fix freezes due to unordered I/O Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 008/108] net: xilinx_emaclite: fix receive buffer overflow Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 009/108] tcp: tcp_probe: use spin_lock_bh() Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 010/108] ipv6: Handle IPv4-mapped src to in6addr_any dst Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 011/108] ipv6: Inhibit IPv4-mapped src address on the wire Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 012/108] tipc: Fix tipc_sk_reinit race conditions Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 013/108] gfs2: Use rhashtable walk interface in glock_hash_walk Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 014/108] NET: Fix /proc/net/arp for AX.25 Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 015/108] ibmvnic: Call napi_disable instead of napi_enable in failure path Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 016/108] ibmvnic: Initialize completion variables before starting work Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 017/108] NET: mkiss: Fix panic Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 018/108] net: hns: Fix the device being used for dma mapping during TX Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 021/108] i2c: piix4: Request the SMBUS semaphore inside the mutex Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 022/108] i2c: piix4: Fix request_region size Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 023/108] powerpc/powernv: Properly set "host-ipi" on IPIs Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 024/108] kernel/ucount.c: mark user_header with kmemleak_ignore() Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 025/108] net: thunderx: Fix PHY autoneg for SGMII QLM mode Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 026/108] ipv6: addrconf: fix generation of new temporary addresses Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 027/108] vfio/spapr_tce: Set window when adding additional groups to container Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 029/108] ARM: defconfigs: make NF_CT_PROTO_SCTP and NF_CT_PROTO_UDPLITE built-in Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 030/108] PM / runtime: Avoid false-positive warnings from might_sleep_if() Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 031/108] jump label: pass kbuild_cflags when checking for asm goto support Greg Kroah-Hartman
2017-06-19 15:29   ` Gleb Fotengauer-Malinovskiy
2017-06-27 11:33     ` Greg Kroah-Hartman
2017-06-27 13:44       ` Levin, Alexander (Sasha Levin)
2017-06-27 14:14         ` Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 032/108] shmem: fix sleeping from atomic context Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 033/108] kasan: respect /proc/sys/kernel/traceoff_on_warning Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 034/108] log2: make order_base_2() behave correctly on const input value zero Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 035/108] ethtool: do not vzalloc(0) on registers dump Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 036/108] net: phy: Fix lack of reference count on PHY driver Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 037/108] net: phy: Fix PHY module checks and NULL deref in phy_attach_direct() Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 038/108] net: fix ndo_features_check/ndo_fix_features comment ordering Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 039/108] fscache: Fix dead object requeue Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 040/108] fscache: Clear outstanding writes when disabling a cookie Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 041/108] FS-Cache: Initialise stores_lock in netfs cookie Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 042/108] ipv6: fix flow labels when the traffic class is non-0 Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 043/108] drm/nouveau: prevent userspace from deleting client object Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 044/108] drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 045/108] net/mlx4_core: Avoid command timeouts during VF driver device shutdown Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 046/108] gianfar: synchronize DMA API usage by free_skb_rx_queue w/ gfar_new_page Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 047/108] pinctrl: baytrail: Rectify debounce support (part 2) Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 048/108] [media] cec: fix wrong last_la determination Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 049/108] drm: prevent double-(un)registration for connectors Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 050/108] drm: Dont race connector registration Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 051/108] pinctrl: berlin-bg4ct: fix the value for "sd1a" of pin SCRD0_CRD_PRES Greg Kroah-Hartman
2017-06-15 17:52 ` [PATCH 4.9 052/108] net: adaptec: starfire: add checks for dma mapping errors Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 054/108] net/mlx5: E-Switch, Err when retrieving steering name-space fails Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 055/108] net/mlx5: Return EOPNOTSUPP when failing to get steering name-space Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 056/108] parisc, parport_gsc: Fixes for printk continuation lines Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 057/108] net: phy: micrel: add support for KSZ8795 Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 058/108] gtp: add genl family modules alias Greg Kroah-Hartman
2017-06-15 17:53 ` Greg Kroah-Hartman [this message]
2017-06-15 17:53 ` [PATCH 4.9 060/108] drm/nouveau: Rename acpi_work to hpd_work Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 061/108] drm/nouveau: Handle fbcon suspend/resume in seperate worker Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 062/108] drm/nouveau: Dont enabling polling twice on runtime resume Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 063/108] drm/nouveau: Fix drm poll_helper handling Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 064/108] drm/ast: Fixed system hanged if disable P2A Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 065/108] ravb: unmap descriptors when freeing rings Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 066/108] nfs: Fix "Dont increment lock sequence ID after NFS4ERR_MOVED" Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 067/108] nvmet-rdma: Fix missing dma sync to nvme data structures Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 068/108] r8152: avoid start_xmit to call napi_schedule during autosuspend Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 069/108] r8152: check rx after napi is enabled Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 070/108] r8152: re-schedule napi for tx Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 071/108] r8152: fix rtl8152_post_reset function Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 072/108] r8152: avoid start_xmit to schedule napi when napi is disabled Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 073/108] net-next: ethernet: mediatek: change the compatible string Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 074/108] bnxt_en: Fix bnxt_reset() in the slow path task Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 075/108] bnxt_en: Enhance autoneg support Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 076/108] bnxt_en: Fix RTNL lock usage on bnxt_update_link() Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 077/108] bnxt_en: Fix RTNL lock usage on bnxt_get_port_module_status() Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 078/108] sctp: sctp gso should set feature with NETIF_F_SG when calling skb_segment Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 079/108] sctp: sctp_addr_id2transport should verify the addr before looking up assoc Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 080/108] usb: musb: Fix external abort on non-linefetch for musb_irq_work() Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 081/108] mn10300: fix build error of missing fpu_save() Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 082/108] romfs: use different way to generate fsid for BLOCK or MTD Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 083/108] frv: add atomic64_add_unless() Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 084/108] frv: add missing atomic64 operations Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 085/108] proc: add a schedule point in proc_pid_readdir() Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 086/108] userfaultfd: fix SIGBUS resulting from false rwsem wakeups Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 087/108] kernel/watchdog.c: move hardlockup detector to separate file Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 088/108] kernel/watchdog.c: move shared definitions to nmi.h Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 089/108] kernel/watchdog: prevent false hardlockup on overloaded system Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 090/108] vhost/vsock: handle vhost_vq_init_access() error Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 091/108] ARC: smp-boot: Decouple Non masters waiting API from jump to entry point Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 092/108] ARCv2: smp-boot: wake_flag polling by non-Masters needs to be uncached Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 093/108] tipc: ignore requests when the connection state is not CONNECTED Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 094/108] tipc: fix connection refcount error Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 095/108] tipc: add subscription refcount to avoid invalid delete Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 096/108] tipc: fix nametbl_lock soft lockup at node/link events Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 097/108] netfilter: nf_tables: fix set->nelems counting with no NLM_F_EXCL Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 098/108] netfilter: nft_log: restrict the log prefix length to 127 Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 099/108] RDMA/qedr: Dispatch port active event from qedr_add Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 100/108] RDMA/qedr: Fix and simplify memory leak in PD alloc Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 101/108] RDMA/qedr: Dont reset QP when queues arent flushed Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 102/108] RDMA/qedr: Dont spam dmesg if QP is in error state Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 103/108] RDMA/qedr: Return max inline data in QP query result Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 104/108] xtensa: dont use linux IRQ #0 Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 105/108] s390/kvm: do not rely on the ILC on kvm host protection fauls Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 107/108] drm/i915: Always recompute watermarks when distrust_bios_wm is set, v2 Greg Kroah-Hartman
2017-06-15 17:53 ` [PATCH 4.9 108/108] sparc64: make string buffers large enough Greg Kroah-Hartman
2017-06-15 22:23 ` [PATCH 4.9 000/108] 4.9.33-stable review Shuah Khan
2017-06-16  0:40 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170615175339.992569615@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.levin@verizon.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox