drm/i915/gen4: Extra CRT hotplug paranoia
Subsystems (2)
PATCH 1/1 drm/i915/gen4: Extra CRT hotplug paranoia
Disable the CRT plug interrupt while doing the force cycle, explicitly clear any CRT interrupt we may have generated, and restore when done. Should mitigate interrupt storms from hotplug detection.
--- drivers/gpu/drm/i915/i915_reg.h | 1 - drivers/gpu/drm/i915/intel_crt.c | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -1
@@ -1055,7 +1055,6 @@#define CRT_HOTPLUG_DETECT_VOLTAGE_325MV (0 << 2)#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2)#define CRT_HOTPLUG_MASK (0x3fc)/* Bits 9-2 */ -#define CRT_FORCE_HOTPLUG_MASK 0xfffffe1f#define PORT_HOTPLUG_STAT 0x61114#define HDMIB_HOTPLUG_INT_STATUS (1 << 29)
drivers/gpu/drm/i915/intel_crt.c +14 -7
@@ -217,7 +217,8 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) {struct drm_device *dev = connector->dev;struct drm_i915_private *dev_priv = dev->dev_private; -u32 hotplug_en; +u32 hotplug_en, orig, stat; +bool ret = false;int i, tries =0 ;if (HAS_PCH_SPLIT (dev))
@@ -232,8 +233,8 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) tries =2 ; else tries =1 ; - hotplug_en =I915_READ (PORT_HOTPLUG_EN ); - hotplug_en &=CRT_FORCE_HOTPLUG_MASK ; + hotplug_en = orig =I915_READ (PORT_HOTPLUG_EN ); + hotplug_en &=CRT_HOTPLUG_MASK ; hotplug_en |=CRT_HOTPLUG_FORCE_DETECT ;if (IS_G4X (dev))
@@ -255,11 +256,17 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) }while (time_after (timeout, jiffies)); } -if ((I915_READ (PORT_HOTPLUG_STAT ) &CRT_HOTPLUG_MONITOR_MASK ) != -CRT_HOTPLUG_MONITOR_NONE ) -return true; + stat =I915_READ (PORT_HOTPLUG_STAT ); +if ((stat &CRT_HOTPLUG_MONITOR_MASK ) !=CRT_HOTPLUG_MONITOR_NONE ) + ret = true; + +/* clear the interrupt we just generated, if any */ +I915_WRITE (PORT_HOTPLUG_STAT ,CRT_HOTPLUG_INT_STATUS ); -return false; +/* and put the bits back */ +I915_WRITE (PORT_HOTPLUG_EN , orig); + +return ret; }static bool intel_crt_detect_ddc (struct drm_encoder *encoder)
Signature · 1 line
1.7.0.1
Quoted 4 lines · Adam Jackson
Disable the CRT plug interrupt while doing the force cycle, explicitly clear any CRT interrupt we may have generated, and restore when done. Should mitigate interrupt storms from hotplug detection.
Is there any locking in here to protect PORT_HOTPLUG_EN? I'm asking because I *still* can't use mainline kernels reliably without commenting out digital output initialization, and that's one place where a bug might be lurking.
--Andy
Quoted 10 lines · Andrew Lutomirski
Quoted 4 lines · Adam Jackson
Disable the CRT plug interrupt while doing the force cycle, explicitly clear any CRT interrupt we may have generated, and restore when done. Should mitigate interrupt storms from hotplug detection.
Is there any locking in here to protect
PORT_HOTPLUG_EN? I'm asking because I *still* can't use mainline kernels reliably without commenting out digital output initialization, and that's one place where a bug might be lurking.
At least in d-i-n, PORT_HOTPLUG_EN is only ever written to from ->detect in the connector vtable, and from IRQ setup. I don't have a firm understanding of the locking around either path, but I'd be rather surprised if it was racy in any practical sense, since neither of those should get called from interrupt context and you typically only have one app doing setup.
- ajax
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 12 lines · Adam Jackson
Quoted 10 lines · Andrew Lutomirski
Quoted 4 lines · Adam Jackson
Disable the CRT plug interrupt while doing the force cycle, explicitly clear any CRT interrupt we may have generated, and restore when done. Should mitigate interrupt storms from hotplug detection.
Is there any locking in here to protect
PORT_HOTPLUG_EN? I'm asking because I *still* can't use mainline kernels reliably without commenting out digital output initialization, and that's one place where a bug might be lurking.
Quoted 6 lines
At least in d-i-n,
PORT_HOTPLUG_ENis only ever written to from ->detect in the connector vtable, and from IRQ setup. I don't have a firm understanding of the locking around either path, but I'd be rather surprised if it was racy in any practical sense, since neither of those should get called from interrupt context and you typically only have one app doing setup.
->detect seems to be called from status_show in drm_sysfs.c, which makes its way into intel_crt_detect_hotplug, which plays with PORT_HOTPLUG_EN without any locking. If another detect function (or the same one, even) is called at the same time, PORT_HOTPLUG_EN can be left in a bad state.
There should probably be a mutex protecting PORT_HOTPLUG_EN.
--Andy
Quoted 3 lines
- ajax
Quoted 3 lines · Adam Jackson
Disable the CRT plug interrupt while doing the force cycle, explicitly clear any CRT interrupt we may have generated, and restore when done. Should mitigate interrupt storms from hotplug detection.
Nice, I've been hoping someone would write a patch like this. Probably for TV, too.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx