linux/drivers/gpu/drm/i915
Daniel Vetter 6e9f798d91 drm: Split connection_mutex out of mode_config.mutex (v3)
After the split-out of crtc locks from the big mode_config.mutex
there's still two major areas it protects:
- Various connector probe states, like connector->status, EDID
  properties, probed mode lists and similar information.
- The links from connector->encoder and encoder->crtc and other
  modeset-relevant connector state (e.g. properties which control the
  panel fitter).

The later is used by modeset operations. But they don't really care
about the former since it's allowed to e.g. enable a disconnected VGA
output or with a mode not in the probed list.

Thus far this hasn't been a problem, but for the atomic modeset
conversion Rob Clark needs to convert all modeset relevant locks into
w/w locks. This is required because the order of acquisition is
determined by how userspace supplies the atomic modeset data. This has
run into troubles in the detect path since the i915 load detect code
needs _both_ protections offered by the mode_config.mutex: It updates
probe state and it needs to change the modeset configuration to enable
the temporary load detect pipe.

The big deal here is that for the probe/detect users of this lock a
plain mutex fits best, but for atomic modesets we really want a w/w
mutex. To fix this lets split out a new connection_mutex lock for the
modeset relevant parts.

For simplicity I've decided to only add one additional lock for all
connector/encoder links and modeset configuration states. We have
piles of different modeset objects in addition to those (like bridges
or panels), so adding per-object locks would be much more effort.

Also, we're guaranteed (at least for now) to do a full modeset if we
need to acquire this lock. Which means that fine-grained locking is
fairly irrelevant compared to the amount of time the full modeset will
take.

I've done a full audit, and there's just a few things that justify
special focus:
- Locking in drm_sysfs.c is almost completely absent. We should
  sprinkle mode_config.connection_mutex over this file a bit, but
  since it already lacks mode_config.mutex this patch wont make the
  situation any worse. This is material for a follow-up patch.

- omap has a omap_framebuffer_flush function which walks the
  connector->encoder->crtc links and is called from many contexts.
  Some look like they don't acquire mode_config.mutex, so this is
  already racy. Again fixing this is material for a separate patch.

- The radeon hot_plug function to retrain DP links looks at
  connector->dpms. Currently this happens without any locking, so is
  already racy. I think radeon_hotplug_work_func should gain
  mutex_lock/unlock calls for the mode_config.connection_mutex.

- Same applies to i915's intel_dp_hot_plug. But again, this is already
  racy.

- i915 load_detect code needs to acquire this lock. Which means the
  w/w dance due to Rob's work will be nicely contained to _just_ this
  function.

I've added fixme comments everywhere where it looks suspicious but in
the sysfs code. After a quick irc discussion with Dave Airlie it
sounds like the lack of locking in there is due to sysfs cleanup fun
at module unload.

v1: original (only compile tested)

v2: missing mutex_init(), etc (from Rob Clark)

v3: i915 needs more care in the conversion:
- Protect the edp pp logic with the connection_mutex.
- Use connection_mutex in the backlight code due to
  get_pipe_from_connector.
- Use drm_modeset_lock_all in suspend/resume paths.
- Update lock checks in the overlay code.

Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2014-06-04 13:25:21 +10:00
..
dvo.h
dvo_ch7xxx.c drm/i915: Remove spurious semicolons 2014-04-09 21:54:33 +02:00
dvo_ch7017.c
dvo_ivch.c drm/i915: Remove spurious semicolons 2014-04-09 21:54:33 +02:00
dvo_ns2501.c drm/i915: Remove spurious semicolons 2014-04-09 21:54:33 +02:00
dvo_sil164.c drm/i915: Remove spurious semicolons 2014-04-09 21:54:33 +02:00
dvo_tfp410.c drm/i915: Remove spurious semicolons 2014-04-09 21:54:33 +02:00
i915_cmd_parser.c drm/i915: s/intel_ring_buffer/intel_engine_cs 2014-05-22 23:01:05 +02:00
i915_debugfs.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
i915_dma.c drm/i915: Split the ringbuffers from the rings (3/3) 2014-05-22 23:30:18 +02:00
i915_drv.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
i915_drv.h drm/i915: Kill private_default_ctx off 2014-05-22 23:44:44 +02:00
i915_gem.c drm/i915: s/i915_hw_context/intel_context 2014-05-22 23:41:17 +02:00
i915_gem_context.c drm/i915: Kill private_default_ctx off 2014-05-22 23:44:44 +02:00
i915_gem_debug.c drm/i915: prefer struct drm_i915_private to drm_i915_private_t 2014-03-31 15:34:21 +02:00
i915_gem_dmabuf.c drm/i915: Introduce mapping of user pages into video memory (userptr) ioctl 2014-05-16 19:31:29 +02:00
i915_gem_evict.c drm/i915: prefer struct drm_i915_private to drm_i915_private_t 2014-03-31 15:34:21 +02:00
i915_gem_execbuffer.c drm/i915: s/i915_hw_context/intel_context 2014-05-22 23:41:17 +02:00
i915_gem_gtt.c drm/i915: s/intel_ring_buffer/intel_engine_cs 2014-05-22 23:01:05 +02:00
i915_gem_gtt.h drm/i915: s/i915_hw_context/intel_context 2014-05-22 23:41:17 +02:00
i915_gem_render_state.c drm/i915: s/intel_ring_buffer/intel_engine_cs 2014-05-22 23:01:05 +02:00
i915_gem_stolen.c drm/i915: restrict vt-d stolen memory workaround to pre-gen8 2014-03-31 10:45:34 +02:00
i915_gem_tiling.c drm/i915: prefer struct drm_i915_private to drm_i915_private_t 2014-03-31 15:34:21 +02:00
i915_gem_userptr.c drm/i915: Introduce mapping of user pages into video memory (userptr) ioctl 2014-05-16 19:31:29 +02:00
i915_gpu_error.c drm/i915: Split the ringbuffers from the rings (2/3) 2014-05-22 23:27:25 +02:00
i915_ioc32.c
i915_irq.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
i915_params.c drm/i915: Add debug module option for VTd validation 2014-04-03 11:23:11 +02:00
i915_reg.h drm/i915: Implement WaVcpClkGateDisableForMediaReset:ctg, elk 2014-05-22 16:34:57 +02:00
i915_suspend.c drm/i915: disable GT power saving early during system suspend 2014-05-22 21:53:27 +02:00
i915_sysfs.c drm/i915: s/i915_hw_context/intel_context 2014-05-22 23:41:17 +02:00
i915_trace.h drm/i915: s/intel_ring_buffer/intel_engine_cs 2014-05-22 23:01:05 +02:00
i915_trace_points.c
i915_ums.c drm/i915: Only restore backlight combination mode reg for ums 2014-01-24 17:22:45 +01:00
intel_acpi.c Merge branch 'acpi-dsm' 2014-01-12 23:45:52 +01:00
intel_bios.c drm/i915: Validate VBT header before trusting it 2014-05-05 09:08:59 +02:00
intel_bios.h Merge tag 'drm-intel-next-2014-04-16' of git://anongit.freedesktop.org/drm-intel into drm-next 2014-05-01 09:11:37 +10:00
intel_crt.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_ddi.c drm/i915: grab the audio power domain when enabling audio on HSW+ 2014-05-22 15:06:33 +02:00
intel_display.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
intel_dp.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
intel_drv.h drm/i915: s/intel_ring_buffer/intel_engine_cs 2014-05-22 23:01:05 +02:00
intel_dsi.c drm/i915: Add MIPI mmio reg base 2014-05-19 17:56:40 +02:00
intel_dsi.h drm/i915: MIPI PPS delays added 2014-05-15 22:44:21 +02:00
intel_dsi_cmd.c drm/i915: Send DPI command explicitely in LP mode 2014-04-09 21:54:30 +02:00
intel_dsi_cmd.h drm/i915: Send DPI command explicitely in LP mode 2014-04-09 21:54:30 +02:00
intel_dsi_pll.c drm/i915: Try harder to get best m, n, p values with minimal error 2013-12-11 23:52:18 +01:00
intel_dvo.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_fbdev.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_hdmi.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_i2c.c drm/i915: Disable dp aux irq on g4x 2014-02-07 16:40:07 +01:00
intel_lvds.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_modes.c
intel_opregion.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
intel_overlay.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
intel_panel.c drm: Split connection_mutex out of mode_config.mutex (v3) 2014-06-04 13:25:21 +10:00
intel_pm.c drm/i915: s/intel_ring_buffer/intel_engine_cs 2014-05-22 23:01:05 +02:00
intel_renderstate.h drm/i915: add render state initialization 2014-05-14 19:16:13 +02:00
intel_renderstate_gen6.c drm/i915: add null render states for gen6, gen7 and gen8 2014-05-14 19:17:08 +02:00
intel_renderstate_gen7.c drm/i915: add null render states for gen6, gen7 and gen8 2014-05-14 19:17:08 +02:00
intel_renderstate_gen8.c drm/i915: add null render states for gen6, gen7 and gen8 2014-05-14 19:17:08 +02:00
intel_ringbuffer.c drm/i915: Split the ringbuffers from the rings (3/3) 2014-05-22 23:30:18 +02:00
intel_ringbuffer.h drm/i915: s/i915_hw_context/intel_context 2014-05-22 23:41:17 +02:00
intel_sdvo.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_sdvo_regs.h drm/i915: use __packed instead of __attribute__((packed)) 2013-12-03 18:19:49 +01:00
intel_sideband.c drm/i915: vlv/chv: fix DSI sideband register accessing 2014-05-19 17:50:14 +02:00
intel_sprite.c drm/i915: Wait for pending page flips before enabling/disabling the primary plane 2014-05-22 15:06:33 +02:00
intel_tv.c drm/i915: replace drm_get_connector_name() with direct name field use 2014-06-04 13:14:37 +10:00
intel_uncore.c drm/i915: s/i915_hw_context/intel_context 2014-05-22 23:41:17 +02:00
Kconfig drm/i915: Introduce mapping of user pages into video memory (userptr) ioctl 2014-05-16 19:31:29 +02:00
Makefile drm/i915: Introduce mapping of user pages into video memory (userptr) ioctl 2014-05-16 19:31:29 +02:00