<div dir="ltr">Hi,<div><br></div><div>Finally I did it. Interested parties can find it below. If anybody has better ways to do it please suggest.</div><div><br></div><div><br></div><div>1) Revert the commit 77961eb984c7e5394bd29cc7be2ab0bf0cc7e7b1.</div>
<div>With this commit DP hotplug events are not coming after doing "<span style="font-family:arial,sans-serif;font-size:13px">xset dpms force off"</span></div><div><br></div><div><div>commit bfcbf45b5b458ebdc38118ca67279a1cd90e085d</div>
<div>Author: Arun Chandran <<a href="mailto:achandran@mvista.com">achandran@mvista.com</a>></div><div>Date: Fri Apr 11 16:16:32 2014 +0530</div><div><br></div><div> Revert "drm/i915: power domains: add vlv power wells"</div>
<div> </div><div> This reverts commit 77961eb984c7e5394bd29cc7be2ab0bf0cc7e7b1.</div><div><br></div><div>2) Modify the code to inject uvents when DP cable is removed/inserted</div><div><br></div></div><div>#################################</div>
<div><div>diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c</div><div>index 4069703..84b3251 100644</div><div>--- a/drivers/gpu/drm/i915/i915_irq.c</div><div>+++ b/drivers/gpu/drm/i915/i915_irq.c</div>
<div>@@ -987,6 +987,12 @@ static bool intel_hpd_irq_event(struct drm_device *dev,</div><div> */</div><div> #define I915_REENABLE_HOTPLUG_DELAY (2*60*1000)</div><div> </div><div>+static int hpd_status;</div><div>+static struct intel_dp *intel_attached_dp(struct drm_connector *connector)</div>
<div>+{</div><div>+ return enc_to_intel_dp(&intel_attached_encoder(connector)->base);</div><div>+}</div><div>+</div><div> static void i915_hotplug_work_func(struct work_struct *work)</div><div> {</div><div> struct drm_i915_private *dev_priv =</div>
<div>@@ -994,6 +1000,7 @@ static void i915_hotplug_work_func(struct work_struct *work)</div><div> struct drm_device *dev = dev_priv->dev;</div><div> struct drm_mode_config *mode_config = &dev->mode_config;</div>
<div> struct intel_connector *intel_connector;</div><div>+ struct intel_dp *intel_dp;</div><div> struct intel_encoder *intel_encoder;</div><div> struct drm_connector *connector;</div><div> unsigned long irqflags;</div>
<div>@@ -1045,6 +1052,15 @@ static void i915_hotplug_work_func(struct work_struct *work)</div><div> list_for_each_entry(connector, &mode_config->connector_list, head) {</div><div> intel_connector = to_intel_connector(connector);</div>
<div> intel_encoder = intel_connector->encoder;</div><div>+ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {</div><div>+ DRM_DEBUG_KMS("arun edp %x\n", hpd_status);</div>
<div>+ intel_dp = intel_attached_dp(connector);</div><div>+</div><div>+ if (hpd_status & (1 << 28))</div><div>+ kobject_uevent(&intel_dp->aux.ddc.dev.kobj, KOBJ_ADD);</div>
<div>+ else</div><div>+ kobject_uevent(&intel_dp->aux.ddc.dev.kobj, KOBJ_REMOVE);</div><div>+ }</div><div> if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) {</div>
<div> if (intel_encoder->hot_plug)</div><div> intel_encoder->hot_plug(intel_encoder);</div><div>@@ -1639,11 +1655,14 @@ static void valleyview_pipestat_irq_handler(struct drm_device *dev, u32 iir)</div>
<div> gmbus_irq_handler(dev);</div><div> }</div><div> </div><div>+</div><div> static void i9xx_hpd_irq_handler(struct drm_device *dev)</div><div> {</div><div> struct drm_i915_private *dev_priv = dev->dev_private;</div>
<div> u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT);</div><div> </div><div>+ hpd_status = hotplug_status;</div><div>+</div><div> if (IS_G4X(dev)) {</div><div> u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_G4X;</div>
</div><div><br></div><div>##########################################</div><div><br></div><div><br></div><div>3) Add a udev rule</div><div><div>arun@arun-valley-view:~$ cat /etc/udev/rules.d/95-dpmonitor-hotplug.rules </div>
<div>KERNEL=="i2c-7", SUBSYSTEM=="i2c", ATTR{name}=="DPDDC-C", RUN+="/usr/local/bin/hpd.sh"</div></div><div><br></div><div>4) Finally the script doing on/off</div><div><br></div><div>
<div>arun@arun-valley-view:~$ cat /usr/local/bin/hpd.sh</div><div>#! /bin/bash</div><div>export XAUTHORITY=/home/arun/.Xauthority</div><div>export DISPLAY=:0</div><div><br></div><div>echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >> /tmp/hpd.log</div>
<div>echo "`date`" >> /tmp/hpd.log</div><div><br></div><div>if [ "$ACTION" == "add" ] ; then</div><div> echo "Powering on" >> /tmp/hpd.log</div><div> xset dpms force on</div>
<div>fi</div><div><br></div><div><br></div><div>if [ "$ACTION" == "remove" ] ; then</div><div> echo "Powering off" >> /tmp/hpd.log</div><div> sleep 1; xset dpms force off</div>
<div>fi</div></div><div><br></div><div><br></div><div>Regards,</div><div>Arun C</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 10, 2014 at 3:58 PM, Arun Chandran <span dir="ltr"><<a href="mailto:achandran@mvista.com" target="_blank">achandran@mvista.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Hi,<br><br><div class="gmail_quote"><div><div class="h5">On Thu, Apr 10, 2014 at 12:54 PM, Daniel Vetter <span dir="ltr"><<a href="mailto:daniel@ffwll.ch" target="_blank">daniel@ffwll.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>On Thu, Apr 10, 2014 at 12:06:15PM +0530, Arun Chandran wrote:<br>
> I have connected only a DP monitor on Bayley Bay platform and booting<br>
> ubuntu 13.10 with the kernel<br>
> <a href="http://cgit.freedesktop.org/drm-intel/log/?h=drm-intel-fixes" target="_blank">http://cgit.freedesktop.org/drm-intel/log/?h=drm-intel-fixes</a>.<br>
><br>
> I am experimenting with the HPD feature of display port with debug<br>
> messages enabled. (drm.debug=0xe).<br>
><br>
> When I plug in/out DP cable I am able to see the below kernel messages<br>
> and ubuntu desktop is displayed on the DP monitor<br>
><br>
> ##############################<br>
><br>
><br>
> root@arun-valley-view:~# uname -a<br>
> Linux arun-valley-view 3.14.0-00528-g67e9d82 #34 SMP PREEMPT Wed Apr 9<br>
> 18:48:30 IST 2014 i686 i686 i686 GNU/Linux<br>
><br>
> root@arun-valley-view:~# dmesg -c<br>
><br>
> [ 1028.506188] [drm:intel_hpd_irq_handler] hotplug event received,<br>
> stat 0x00100000<br>
> [ 1028.506217] [drm:intel_hpd_irq_handler] Received HPD interrupt on<br>
> PIN 5 - cnt: 0<br>
> [ 1028.513858] [drm:i915_hotplug_work_func] running encoder hotplug functions<br>
> [ 1028.513880] [drm:i915_hotplug_work_func] Connector eDP-1 (pin 5)<br>
> received hotplug event.<br>
> [ 1028.513896] [drm:i915_hotplug_work_func] Connector HDMI-A-2 (pin 5)<br>
> received hotplug event.<br>
> [ 1028.513913] [drm:_edp_panel_vdd_on] Turning eDP VDD on<br>
> [ 1028.513931] [drm:_edp_panel_vdd_on] PP_STATUS: 0x80000008<br>
> PP_CONTROL: 0xabcd000f<br>
> [ 1028.515064] [drm:intel_dp_get_dpcd] DPCD: 11 0a 84 01 01 00 01 80<br>
> 02 00 00 00 00 00 00<br>
> [ 1028.516563] [drm:intel_dp_check_link_status] TMDS-22: channel EQ<br>
> not ok, retraining<br>
> [ 1028.530884] [drm:intel_dp_set_signal_levels] Using signal levels 00000000<br>
> [ 1028.546113] [drm:intel_dp_set_signal_levels] Using signal levels 00000000<br>
> [ 1028.547233] [drm:intel_dp_start_link_train] clock recovery OK<br>
> [ 1028.548711] [drm:intel_dp_complete_link_train] Channel EQ done. DP<br>
> Training successful<br>
> [ 1028.549264] [drm:intel_dp_detect] [CONNECTOR:23:eDP-1]<br>
> [ 1028.549761] [drm:intel_dp_probe_oui] Sink OUI: 00e04c<br>
> [ 1028.550262] [drm:intel_dp_probe_oui] Branch OUI: 000000<br>
> [ 1028.550343] [drm:intel_hdmi_detect] [CONNECTOR:21:HDMI-A-2]<br>
> [ 1028.550595] [drm:gmbus_xfer] GMBUS [i915 gmbus dpc] NAK for addr: 0050 r(1)<br>
> [ 1028.550611] [drm:drm_do_probe_ddc_edid] drm: skipping non-existent<br>
> adapter i915 gmbus dpc<br>
><br>
> ##################################<br>
><br>
> After booting I am executing the below steps<br>
><br>
> 1) unplug DP cable.<br>
><br>
> 2) Mask the pin 18 (HPD) of DP cable using a paper strip then connect it<br>
> back<br>
> I have checked the dmesg output and the there is no messages related to<br>
> HPD. So kernel is<br>
> unaware that I have connected a DP monitor<br>
><br>
> But still I see ubuntu desktop coming on the DP monitor. This means kernel<br>
> does not stop pumping display data after step 1.<br>
><br>
> Is this the right behavior? . When kernel knows that the last existing<br>
> display is removed (via the HPD feature) it can save power by stopping the<br>
> data output to DP monitor (or shutting down the DP hardware related part.)<br>
><br>
> Does anybody knows how to use the HPD feature to save power? Or anybody has<br>
> done this before?<br>
<br>
</div></div>Yes, this is expected behaviour. Userspace asked the kernel to shovel<br>
pixels to the DP screen, the kernel obeyed. If you want to kill the pipe<br>
when unplugged, you need to make that policy decision in userspace.<br>
<br></blockquote><div><br></div></div></div><div>OK I understood that this is the expected behavior. </div><div><br></div><div>In order to simulate power-saving with HPD I am now doing.</div><div><br></div><div>1) Boot <a href="http://cgit.freedesktop.org/drm-intel/log/?h=drm-intel-fixes" target="_blank">http://cgit.freedesktop.org/drm-intel/log/?h=drm-intel-nightly</a></div>
<div><div>arun@arun-valley-view:~$ uname -a</div><div>Linux arun-valley-view 3.14.0-00345-gd22313b #35 SMP PREEMPT Thu Apr 10 14:54:09 IST 2014 i686 i686 i686 GNU/Linux</div></div><div><br></div><div><br></div><div>2) sudo dmesg -c > /dev/null; xset dpms force off ( I am planning to do this when DP cable is unplugged by sending event to userspace)</div>
<div><br></div><div> Then take dmesg from serial console after display goes blank.</div><div><br></div><div>####################################</div><div><div>arun@arun-valley-view:~$ sudo dmesg -c </div><div>[ 955.521469] [drm:valleyview_set_rps] GPU freq request from 167 MHz (191) to 542 MHz (209)</div>
<div>[ 956.085890] [drm:valleyview_set_rps] GPU freq request from 167 MHz (191) to 791 MHz (221)</div><div>[ 956.101376] [drm:valleyview_set_rps] GPU freq request from 791 MHz (221) to 791 MHz (221)</div><div>[ 956.102478] [drm:valleyview_set_rps] GPU freq request from 791 MHz (221) to 791 MHz (221)</div>
<div>[ 956.103167] [drm:valleyview_set_rps] GPU freq request from 791 MHz (221) to 791 MHz (221)</div><div>[ 958.852674] [drm:valleyview_set_rps] GPU freq request from 167 MHz (191) to 542 MHz (209)</div><div>[ 963.907584] [drm:_edp_panel_vdd_on] Turning eDP VDD on</div>
<div>[ 963.907614] [drm:_edp_panel_vdd_on] PP_STATUS: 0x80000008 PP_CONTROL: 0xabcd000f</div><div>[ 963.907631] [drm:intel_panel_actually_set_backlight] set backlight PWM = 0</div><div>[ 963.907646] [drm:intel_edp_backlight_off] </div>
<div>[ 963.908150] [drm:intel_edp_panel_off] Turn eDP power off</div><div>[ 964.109165] [drm:wait_panel_off] Wait for panel power off time</div><div>[ 964.109194] [drm:wait_panel_status] mask b0000000 value 00000000 status 80000008 control abcd0000</div>
<div>[ 964.153214] [drm:wait_panel_status] Wait complete</div><div>[ 964.181035] [drm:intel_dp_link_down] </div><div>[ 964.233101] ------------[ cut here ]------------</div><div>[ 964.233139] WARNING: CPU: 0 PID: 1013 at drivers/gpu/drm/i915/intel_display.c:768 g4x_wait_for_vblank+0xa5/0xbe()</div>
<div>[ 964.233150] vblank wait timed out</div><div>[ 964.233159] Modules linked in:</div><div>[ 964.233181] CPU: 0 PID: 1013 Comm: Xorg Tainted: G W 3.14.0-00345-gd22313b #35</div><div>[ 964.233193] Hardware name: Intel Corp. VALLEYVIEW B0 PLATFORM/NOTEBOOK, BIOS BYTICRB1.86C.0072.R11.1401221240 01/22/2014</div>
<div>[ 964.233204] 00000300 ee793d68 c090f720 c0b2bb3f ee793d80 c0436ce0 c06f63b4 f3b40000</div><div>[ 964.233239] 001f0040 0000041b ee793d98 c0436d5b 00000009 ee793d90 c0b2dd12 ee793dac</div><div>[ 964.233271] ee793dc0 c06f63b4 c0b2bb3f 00000300 c0b2dd12 000a1ab1 000a1ae4 f3b40000</div>
<div>[ 964.233304] Call Trace:</div><div>[ 964.233327] [<c090f720>] dump_stack+0x48/0x70</div><div>[ 964.233349] [<c0436ce0>] warn_slowpath_common+0x63/0x7a</div><div>[ 964.233368] [<c06f63b4>] ? g4x_wait_for_vblank+0xa5/0xbe</div>
<div>[ 964.233387] [<c0436d5b>] warn_slowpath_fmt+0x26/0x2a</div><div>[ 964.233407] [<c06f63b4>] g4x_wait_for_vblank+0xa5/0xbe</div><div>[ 964.233426] [<c06f63f1>] intel_wait_for_vblank+0x24/0xe6</div>
<div>[ 964.233447] [<c070ab0d>] intel_dp_link_down+0xdb/0x18f</div><div>[ 964.233468] [<c070abcc>] vlv_post_disable_dp+0xb/0xd</div><div>[ 964.233488] [<c06fdba4>] i9xx_crtc_disable+0x151/0x237</div>
<div>[ 964.233510] [<c06ee8f5>] intel_crtc_update_dpms+0x56/0x68</div><div>[ 964.233529] [<c06f85b2>] intel_connector_dpms+0x3e/0x48</div><div>[ 964.233550] [<c06b1c01>] drm_mode_obj_set_property_ioctl+0x1c0/0x2e7</div>
<div>[ 964.233573] [<c0605c99>] ? kobject_uevent+0xc/0xc</div><div>[ 964.233592] [<c06f8574>] ? intel_modeset_check_state+0x6f/0x6f</div><div>[ 964.233612] [<c06b1d57>] drm_mode_connector_property_set_ioctl+0x2f/0x37</div>
<div>[ 964.233631] [<c06a9370>] drm_ioctl+0x248/0x350</div><div>[ 964.233650] [<c06b1d28>] ? drm_mode_obj_set_property_ioctl+0x2e7/0x2e7</div><div>[ 964.233672] [<c047e9b4>] ? __call_rcu_core+0x11/0xc2</div>
<div>[ 964.233692] [<c0507280>] ? mntput_no_expire+0x20/0x108</div><div>[ 964.233710] [<c050738a>] ? mntput+0x22/0x24</div><div>[ 964.233728] [<c06a9128>] ? drm_ioctl_permit+0x6a/0x6a</div><div>[ 964.233748] [<c04fde57>] do_vfs_ioctl+0x219/0x232</div>
<div>[ 964.233767] [<c04fdeac>] SyS_ioctl+0x3c/0x56</div><div>[ 964.233789] [<c0913bbe>] sysenter_do_call+0x12/0x26</div><div>[ 964.233802] ---[ end trace a3724fec7053be94 ]---</div><div>[ 964.284395] [drm:valleyview_update_wm] Setting FIFO watermarks - A: plane=2, cursor=2, B: plane=2, cursor=2, SR: plane=0, cursor=0</div>
<div>[ 964.284666] [drm:check_encoder_state] [ENCODER:13:DAC-13]</div><div>[ 964.284703] [drm:check_encoder_state] [ENCODER:14:TMDS-14]</div><div>[ 964.284771] [drm:check_encoder_state] [ENCODER:18:TMDS-18]</div><div>
[ 964.284839] [drm:check_encoder_state] [ENCODER:20:TMDS-20]</div>
<div>[ 964.284907] [drm:check_encoder_state] [ENCODER:22:TMDS-22]</div><div>[ 964.285029] [drm:check_crtc_state] [CRTC:5]</div><div>[ 964.285110] [drm:check_crtc_state] [CRTC:9]</div><div>[ 964.285192] [drm:drm_mode_setcrtc] [CRTC:5]</div>
<div>[ 964.285207] [drm:intel_crtc_set_config] [CRTC:5] [NOFB]</div><div>[ 964.285226] [drm:intel_set_config_compute_mode_changes] computed changes for [CRTC:5], mode_changed=1, fb_changed=0</div><div>[ 964.285240] [drm:intel_modeset_stage_output_state] [CONNECTOR:23:eDP-1] to [NOCRTC]</div>
<div>[ 964.285252] [drm:intel_modeset_stage_output_state] encoder changed, full mode switch</div><div>[ 964.285264] [drm:intel_modeset_stage_output_state] crtc changed, full mode switch</div><div>[ 964.285276] [drm:intel_modeset_stage_output_state] crtc disabled, full mode switch</div>
<div>[ 964.285293] [drm:intel_modeset_affected_pipes] set mode pipe masks: modeset: 0, prepare: 0, disable: 1</div><div>[ 964.285358] [drm:intel_display_power_put] disabling dpio-tx-c-23</div><div>[ 964.287059] [drm:intel_display_power_put] disabling dpio-tx-c-01</div>
<div>[ 964.293119] [drm:intel_display_power_put] disabling dpio-tx-b-23</div><div>[ 964.301223] [drm:intel_display_power_put] disabling dpio-tx-b-01</div><div>[ 964.303065] [drm:intel_display_power_put] disabling dpio-common</div>
<div>[ 964.305075] [drm:intel_display_power_put] disabling display</div><div>[ 964.307260] [drm:check_encoder_state] [ENCODER:13:DAC-13]</div><div>[ 964.307291] [drm:check_encoder_state] [ENCODER:14:TMDS-14]</div><div>
[ 964.307316] [drm:check_encoder_state] [ENCODER:18:TMDS-18]</div><div>[ 964.307340] [drm:check_encoder_state] [ENCODER:20:TMDS-20]</div><div>[ 964.307364] [drm:check_encoder_state] [ENCODER:22:TMDS-22]</div><div>[ 964.307388] [drm:check_crtc_state] [CRTC:5]</div>
<div>[ 964.307411] [drm:check_crtc_state] [CRTC:9]</div></div><div><br></div><div>#############################################</div><div> </div><div>3) Unplug DP cable</div><div> </div><div><div>arun@arun-valley-view:~$ sudo dmesg -c </div>
</div><div><br></div><div>(empty printk buffer)<br></div><div><br></div><div>4) Plug DP cable (planning to send event to userspace to do '$xset dpms force on'</div><div>arun@arun-valley-view:~$ sudo dmesg -c <br>
</div>
<div><br></div><div>(empty printk buffer)</div><div><br></div><div>I was hoping to see HPD events from step 3&4. But no events are generated.</div><div><br></div><div>Is there any way to keep the HPD detection part awake so that I can send</div>
<div>it to userspace to do '$xset dpms force on'</div><div><br></div><div><br></div><div>Regards,</div><div>Arun C</div></div></div></div>
</blockquote></div><br></div>