]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.16.14/drm-i915-lvds-move-acpi-lid-notification-registration-to-registration-phase.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.16.14 / drm-i915-lvds-move-acpi-lid-notification-registration-to-registration-phase.patch
CommitLineData
4758c0b1
GKH
1From b9eb9c92899a509fe258d38dd6c214b1de69eee0 Mon Sep 17 00:00:00 2001
2From: Chris Wilson <chris@chris-wilson.co.uk>
3Date: Fri, 18 May 2018 08:48:40 +0100
4Subject: drm/i915/lvds: Move acpi lid notification registration to registration phase
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Chris Wilson <chris@chris-wilson.co.uk>
10
11commit b9eb9c92899a509fe258d38dd6c214b1de69eee0 upstream.
12
13Delay registering ourselves with the acpi lid notification mechanism
14until we are registering the connectors after initialisation is
15complete. This prevents a possibility of trying to handle the lid
16notification before we are ready with the danger of chasing
17uninitialised function pointers.
18
19 BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
20 IP: (null)
21 PGD 0 P4D 0
22 Oops: 0010 [#1] PREEMPT SMP PTI
23 Modules linked in: arc4(+) iwldvm(+) i915(+) mac80211 i2c_algo_bit coretemp mei_wdt iwlwifi drm_kms_helper kvm_intel wmi_bmof iTCO_wdt iTCO_vendor_support kvm snd_hda_codec_conexant snd_hda_codec_generic drm psmouse cfg80211 irqbypass input_leds pcspkr i2c_i801 snd_hda_intel snd_hda_codec thinkpad_acpi snd_hda_core mei_me lpc_ich snd_hwdep e1000e wmi nvram snd_pcm mei snd_timer shpchp ptp pps_core rfkill syscopyarea snd intel_agp sysfillrect intel_gtt soundcore sysimgblt battery led_class fb_sys_fops ac rtc_cmos agpgart evdev mac_hid acpi_cpufreq ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 fscrypto crypto_simd glue_helper cryptd aes_x86_64 xts algif_skcipher af_alg dm_crypt dm_mod sd_mod uas usb_storage serio_raw atkbd libps2 ahci libahci uhci_hcd libata scsi_mod ehci_pci
24 ehci_hcd usbcore usb_common i8042 serio
25 CPU: 1 PID: 378 Comm: systemd-logind Not tainted 4.16.8-1-ARCH #1
26 Hardware name: LENOVO 7454CTO/7454CTO, BIOS 6DET72WW (3.22 ) 10/25/2012
27 RIP: 0010: (null)
28 RSP: 0018:ffffaf4580c33a18 EFLAGS: 00010287
29 RAX: 0000000000000000 RBX: ffff947533558000 RCX: 000000000000003e
30 RDX: ffffffffc0aa80c0 RSI: ffffaf4580c33a3c RDI: ffff947534e4c000
31 RBP: ffff947533558338 R08: ffff947534598930 R09: ffffffffc0a928b1
32 R10: ffffd8f181d5fd40 R11: 0000000000000000 R12: ffffffffc0a928b1
33 R13: ffff947533558368 R14: ffffffffc0a928a9 R15: ffff947534e4c000
34 FS: 00007f3dc4ddb940(0000) GS:ffff947539280000(0000) knlGS:0000000000000000
35 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
36 CR2: 0000000000000000 CR3: 000000006e214000 CR4: 00000000000406e0
37 Call Trace:
38 ? intel_modeset_setup_hw_state+0x385/0xf60 [i915]
39 ? __intel_display_resume+0x1e/0xc0 [i915]
40 ? intel_display_resume+0xcc/0x120 [i915]
41 ? intel_lid_notify+0xbc/0xc0 [i915]
42 ? notifier_call_chain+0x47/0x70
43 ? blocking_notifier_call_chain+0x3e/0x60
44 ? acpi_lid_notify_state+0x8f/0x1d0
45 ? acpi_lid_update_state+0x49/0x70
46 ? acpi_lid_input_open+0x60/0x90
47 ? input_open_device+0x5d/0xa0
48 ? evdev_open+0x1ba/0x1e0 [evdev]
49 ? chrdev_open+0xa3/0x1b0
50 ? cdev_put.part.0+0x20/0x20
51 ? do_dentry_open+0x14c/0x300
52 ? path_openat+0x30c/0x1240
53 ? current_time+0x16/0x60
54 ? do_filp_open+0x93/0x100
55 ? __check_object_size+0xfb/0x180
56 ? do_sys_open+0x186/0x210
57 ? do_syscall_64+0x74/0x190
58 ? entry_SYSCALL_64_after_hwframe+0x3d/0xa2
59 Code: Bad RIP value.
60 RIP: (null) RSP: ffffaf4580c33a18
61 CR2: 0000000000000000
62
63Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106559
64Fixes: c1c7af608920 ("drm/i915: force mode set at lid open time")
65Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
66Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
67Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
68Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
69Reviewed-by: Jani Nikula <jani.nikula@intel.com>
70Link: https://patchwork.freedesktop.org/patch/msgid/20180518074840.16194-1-chris@chris-wilson.co.uk
71Cc: stable@vger.kernel.org
72(cherry picked from commit e578a570dc7c20475774d1ff993825e3bd7a7011)
73Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
74Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
75
76---
77 drivers/gpu/drm/i915/intel_lvds.c | 43 ++++++++++++++++++++++++++++----------
78 1 file changed, 32 insertions(+), 11 deletions(-)
79
80--- a/drivers/gpu/drm/i915/intel_lvds.c
81+++ b/drivers/gpu/drm/i915/intel_lvds.c
82@@ -567,6 +567,36 @@ exit:
83 return NOTIFY_OK;
84 }
85
86+static int
87+intel_lvds_connector_register(struct drm_connector *connector)
88+{
89+ struct intel_lvds_connector *lvds = to_lvds_connector(connector);
90+ int ret;
91+
92+ ret = intel_connector_register(connector);
93+ if (ret)
94+ return ret;
95+
96+ lvds->lid_notifier.notifier_call = intel_lid_notify;
97+ if (acpi_lid_notifier_register(&lvds->lid_notifier)) {
98+ DRM_DEBUG_KMS("lid notifier registration failed\n");
99+ lvds->lid_notifier.notifier_call = NULL;
100+ }
101+
102+ return 0;
103+}
104+
105+static void
106+intel_lvds_connector_unregister(struct drm_connector *connector)
107+{
108+ struct intel_lvds_connector *lvds = to_lvds_connector(connector);
109+
110+ if (lvds->lid_notifier.notifier_call)
111+ acpi_lid_notifier_unregister(&lvds->lid_notifier);
112+
113+ intel_connector_unregister(connector);
114+}
115+
116 /**
117 * intel_lvds_destroy - unregister and free LVDS structures
118 * @connector: connector to free
119@@ -579,9 +609,6 @@ static void intel_lvds_destroy(struct dr
120 struct intel_lvds_connector *lvds_connector =
121 to_lvds_connector(connector);
122
123- if (lvds_connector->lid_notifier.notifier_call)
124- acpi_lid_notifier_unregister(&lvds_connector->lid_notifier);
125-
126 if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
127 kfree(lvds_connector->base.edid);
128
129@@ -602,8 +629,8 @@ static const struct drm_connector_funcs
130 .fill_modes = drm_helper_probe_single_connector_modes,
131 .atomic_get_property = intel_digital_connector_atomic_get_property,
132 .atomic_set_property = intel_digital_connector_atomic_set_property,
133- .late_register = intel_connector_register,
134- .early_unregister = intel_connector_unregister,
135+ .late_register = intel_lvds_connector_register,
136+ .early_unregister = intel_lvds_connector_unregister,
137 .destroy = intel_lvds_destroy,
138 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
139 .atomic_duplicate_state = intel_digital_connector_duplicate_state,
140@@ -1138,12 +1165,6 @@ out:
141
142 lvds_encoder->a3_power = lvds & LVDS_A3_POWER_MASK;
143
144- lvds_connector->lid_notifier.notifier_call = intel_lid_notify;
145- if (acpi_lid_notifier_register(&lvds_connector->lid_notifier)) {
146- DRM_DEBUG_KMS("lid notifier registration failed\n");
147- lvds_connector->lid_notifier.notifier_call = NULL;
148- }
149-
150 return;
151
152 failed: