at v4.18 665 lines 21 kB view raw
1/* 2 * Copyright © 2015 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#include <linux/kernel.h> 25 26#include <drm/drmP.h> 27#include <drm/i915_drm.h> 28 29#include "i915_drv.h" 30#include "intel_drv.h" 31 32/** 33 * DOC: Hotplug 34 * 35 * Simply put, hotplug occurs when a display is connected to or disconnected 36 * from the system. However, there may be adapters and docking stations and 37 * Display Port short pulses and MST devices involved, complicating matters. 38 * 39 * Hotplug in i915 is handled in many different levels of abstraction. 40 * 41 * The platform dependent interrupt handling code in i915_irq.c enables, 42 * disables, and does preliminary handling of the interrupts. The interrupt 43 * handlers gather the hotplug detect (HPD) information from relevant registers 44 * into a platform independent mask of hotplug pins that have fired. 45 * 46 * The platform independent interrupt handler intel_hpd_irq_handler() in 47 * intel_hotplug.c does hotplug irq storm detection and mitigation, and passes 48 * further processing to appropriate bottom halves (Display Port specific and 49 * regular hotplug). 50 * 51 * The Display Port work function i915_digport_work_func() calls into 52 * intel_dp_hpd_pulse() via hooks, which handles DP short pulses and DP MST long 53 * pulses, with failures and non-MST long pulses triggering regular hotplug 54 * processing on the connector. 55 * 56 * The regular hotplug work function i915_hotplug_work_func() calls connector 57 * detect hooks, and, if connector status changes, triggers sending of hotplug 58 * uevent to userspace via drm_kms_helper_hotplug_event(). 59 * 60 * Finally, the userspace is responsible for triggering a modeset upon receiving 61 * the hotplug uevent, disabling or enabling the crtc as needed. 62 * 63 * The hotplug interrupt storm detection and mitigation code keeps track of the 64 * number of interrupts per hotplug pin per a period of time, and if the number 65 * of interrupts exceeds a certain threshold, the interrupt is disabled for a 66 * while before being re-enabled. The intention is to mitigate issues raising 67 * from broken hardware triggering massive amounts of interrupts and grinding 68 * the system to a halt. 69 * 70 * Current implementation expects that hotplug interrupt storm will not be 71 * seen when display port sink is connected, hence on platforms whose DP 72 * callback is handled by i915_digport_work_func reenabling of hpd is not 73 * performed (it was never expected to be disabled in the first place ;) ) 74 * this is specific to DP sinks handled by this routine and any other display 75 * such as HDMI or DVI enabled on the same port will have proper logic since 76 * it will use i915_hotplug_work_func where this logic is handled. 77 */ 78 79/** 80 * intel_hpd_port - return port hard associated with certain pin. 81 * @dev_priv: private driver data pointer 82 * @pin: the hpd pin to get associated port 83 * 84 * Return port that is associatade with @pin and PORT_NONE if no port is 85 * hard associated with that @pin. 86 */ 87enum port intel_hpd_pin_to_port(struct drm_i915_private *dev_priv, 88 enum hpd_pin pin) 89{ 90 switch (pin) { 91 case HPD_PORT_A: 92 return PORT_A; 93 case HPD_PORT_B: 94 return PORT_B; 95 case HPD_PORT_C: 96 return PORT_C; 97 case HPD_PORT_D: 98 return PORT_D; 99 case HPD_PORT_E: 100 if (IS_CNL_WITH_PORT_F(dev_priv)) 101 return PORT_F; 102 return PORT_E; 103 case HPD_PORT_F: 104 return PORT_F; 105 default: 106 return PORT_NONE; /* no port for this pin */ 107 } 108} 109 110/** 111 * intel_hpd_pin_default - return default pin associated with certain port. 112 * @dev_priv: private driver data pointer 113 * @port: the hpd port to get associated pin 114 * 115 * It is only valid and used by digital port encoder. 116 * 117 * Return pin that is associatade with @port and HDP_NONE if no pin is 118 * hard associated with that @port. 119 */ 120enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv, 121 enum port port) 122{ 123 switch (port) { 124 case PORT_A: 125 return HPD_PORT_A; 126 case PORT_B: 127 return HPD_PORT_B; 128 case PORT_C: 129 return HPD_PORT_C; 130 case PORT_D: 131 return HPD_PORT_D; 132 case PORT_E: 133 return HPD_PORT_E; 134 case PORT_F: 135 if (IS_CNL_WITH_PORT_F(dev_priv)) 136 return HPD_PORT_E; 137 return HPD_PORT_F; 138 default: 139 MISSING_CASE(port); 140 return HPD_NONE; 141 } 142} 143 144#define HPD_STORM_DETECT_PERIOD 1000 145#define HPD_STORM_REENABLE_DELAY (2 * 60 * 1000) 146 147/** 148 * intel_hpd_irq_storm_detect - gather stats and detect HPD irq storm on a pin 149 * @dev_priv: private driver data pointer 150 * @pin: the pin to gather stats on 151 * 152 * Gather stats about HPD irqs from the specified @pin, and detect irq 153 * storms. Only the pin specific stats and state are changed, the caller is 154 * responsible for further action. 155 * 156 * The number of irqs that are allowed within @HPD_STORM_DETECT_PERIOD is 157 * stored in @dev_priv->hotplug.hpd_storm_threshold which defaults to 158 * @HPD_STORM_DEFAULT_THRESHOLD. If this threshold is exceeded, it's 159 * considered an irq storm and the irq state is set to @HPD_MARK_DISABLED. 160 * 161 * The HPD threshold can be controlled through i915_hpd_storm_ctl in debugfs, 162 * and should only be adjusted for automated hotplug testing. 163 * 164 * Return true if an irq storm was detected on @pin. 165 */ 166static bool intel_hpd_irq_storm_detect(struct drm_i915_private *dev_priv, 167 enum hpd_pin pin) 168{ 169 unsigned long start = dev_priv->hotplug.stats[pin].last_jiffies; 170 unsigned long end = start + msecs_to_jiffies(HPD_STORM_DETECT_PERIOD); 171 const int threshold = dev_priv->hotplug.hpd_storm_threshold; 172 bool storm = false; 173 174 if (!time_in_range(jiffies, start, end)) { 175 dev_priv->hotplug.stats[pin].last_jiffies = jiffies; 176 dev_priv->hotplug.stats[pin].count = 0; 177 DRM_DEBUG_KMS("Received HPD interrupt on PIN %d - cnt: 0\n", pin); 178 } else if (dev_priv->hotplug.stats[pin].count > threshold && 179 threshold) { 180 dev_priv->hotplug.stats[pin].state = HPD_MARK_DISABLED; 181 DRM_DEBUG_KMS("HPD interrupt storm detected on PIN %d\n", pin); 182 storm = true; 183 } else { 184 dev_priv->hotplug.stats[pin].count++; 185 DRM_DEBUG_KMS("Received HPD interrupt on PIN %d - cnt: %d\n", pin, 186 dev_priv->hotplug.stats[pin].count); 187 } 188 189 return storm; 190} 191 192static void intel_hpd_irq_storm_disable(struct drm_i915_private *dev_priv) 193{ 194 struct drm_device *dev = &dev_priv->drm; 195 struct intel_connector *intel_connector; 196 struct intel_encoder *intel_encoder; 197 struct drm_connector *connector; 198 struct drm_connector_list_iter conn_iter; 199 enum hpd_pin pin; 200 bool hpd_disabled = false; 201 202 lockdep_assert_held(&dev_priv->irq_lock); 203 204 drm_connector_list_iter_begin(dev, &conn_iter); 205 drm_for_each_connector_iter(connector, &conn_iter) { 206 if (connector->polled != DRM_CONNECTOR_POLL_HPD) 207 continue; 208 209 intel_connector = to_intel_connector(connector); 210 intel_encoder = intel_connector->encoder; 211 if (!intel_encoder) 212 continue; 213 214 pin = intel_encoder->hpd_pin; 215 if (pin == HPD_NONE || 216 dev_priv->hotplug.stats[pin].state != HPD_MARK_DISABLED) 217 continue; 218 219 DRM_INFO("HPD interrupt storm detected on connector %s: " 220 "switching from hotplug detection to polling\n", 221 connector->name); 222 223 dev_priv->hotplug.stats[pin].state = HPD_DISABLED; 224 connector->polled = DRM_CONNECTOR_POLL_CONNECT 225 | DRM_CONNECTOR_POLL_DISCONNECT; 226 hpd_disabled = true; 227 } 228 drm_connector_list_iter_end(&conn_iter); 229 230 /* Enable polling and queue hotplug re-enabling. */ 231 if (hpd_disabled) { 232 drm_kms_helper_poll_enable(dev); 233 mod_delayed_work(system_wq, &dev_priv->hotplug.reenable_work, 234 msecs_to_jiffies(HPD_STORM_REENABLE_DELAY)); 235 } 236} 237 238static void intel_hpd_irq_storm_reenable_work(struct work_struct *work) 239{ 240 struct drm_i915_private *dev_priv = 241 container_of(work, typeof(*dev_priv), 242 hotplug.reenable_work.work); 243 struct drm_device *dev = &dev_priv->drm; 244 int i; 245 246 intel_runtime_pm_get(dev_priv); 247 248 spin_lock_irq(&dev_priv->irq_lock); 249 for_each_hpd_pin(i) { 250 struct drm_connector *connector; 251 struct drm_connector_list_iter conn_iter; 252 253 if (dev_priv->hotplug.stats[i].state != HPD_DISABLED) 254 continue; 255 256 dev_priv->hotplug.stats[i].state = HPD_ENABLED; 257 258 drm_connector_list_iter_begin(dev, &conn_iter); 259 drm_for_each_connector_iter(connector, &conn_iter) { 260 struct intel_connector *intel_connector = to_intel_connector(connector); 261 262 if (intel_connector->encoder->hpd_pin == i) { 263 if (connector->polled != intel_connector->polled) 264 DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n", 265 connector->name); 266 connector->polled = intel_connector->polled; 267 if (!connector->polled) 268 connector->polled = DRM_CONNECTOR_POLL_HPD; 269 } 270 } 271 drm_connector_list_iter_end(&conn_iter); 272 } 273 if (dev_priv->display_irqs_enabled && dev_priv->display.hpd_irq_setup) 274 dev_priv->display.hpd_irq_setup(dev_priv); 275 spin_unlock_irq(&dev_priv->irq_lock); 276 277 intel_runtime_pm_put(dev_priv); 278} 279 280bool intel_encoder_hotplug(struct intel_encoder *encoder, 281 struct intel_connector *connector) 282{ 283 struct drm_device *dev = connector->base.dev; 284 enum drm_connector_status old_status; 285 286 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); 287 old_status = connector->base.status; 288 289 connector->base.status = 290 drm_helper_probe_detect(&connector->base, NULL, false); 291 292 if (old_status == connector->base.status) 293 return false; 294 295 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", 296 connector->base.base.id, 297 connector->base.name, 298 drm_get_connector_status_name(old_status), 299 drm_get_connector_status_name(connector->base.status)); 300 301 return true; 302} 303 304static void i915_digport_work_func(struct work_struct *work) 305{ 306 struct drm_i915_private *dev_priv = 307 container_of(work, struct drm_i915_private, hotplug.dig_port_work); 308 u32 long_port_mask, short_port_mask; 309 struct intel_digital_port *intel_dig_port; 310 int i; 311 u32 old_bits = 0; 312 313 spin_lock_irq(&dev_priv->irq_lock); 314 long_port_mask = dev_priv->hotplug.long_port_mask; 315 dev_priv->hotplug.long_port_mask = 0; 316 short_port_mask = dev_priv->hotplug.short_port_mask; 317 dev_priv->hotplug.short_port_mask = 0; 318 spin_unlock_irq(&dev_priv->irq_lock); 319 320 for (i = 0; i < I915_MAX_PORTS; i++) { 321 bool valid = false; 322 bool long_hpd = false; 323 intel_dig_port = dev_priv->hotplug.irq_port[i]; 324 if (!intel_dig_port || !intel_dig_port->hpd_pulse) 325 continue; 326 327 if (long_port_mask & (1 << i)) { 328 valid = true; 329 long_hpd = true; 330 } else if (short_port_mask & (1 << i)) 331 valid = true; 332 333 if (valid) { 334 enum irqreturn ret; 335 336 ret = intel_dig_port->hpd_pulse(intel_dig_port, long_hpd); 337 if (ret == IRQ_NONE) { 338 /* fall back to old school hpd */ 339 old_bits |= (1 << intel_dig_port->base.hpd_pin); 340 } 341 } 342 } 343 344 if (old_bits) { 345 spin_lock_irq(&dev_priv->irq_lock); 346 dev_priv->hotplug.event_bits |= old_bits; 347 spin_unlock_irq(&dev_priv->irq_lock); 348 schedule_work(&dev_priv->hotplug.hotplug_work); 349 } 350} 351 352/* 353 * Handle hotplug events outside the interrupt handler proper. 354 */ 355static void i915_hotplug_work_func(struct work_struct *work) 356{ 357 struct drm_i915_private *dev_priv = 358 container_of(work, struct drm_i915_private, hotplug.hotplug_work); 359 struct drm_device *dev = &dev_priv->drm; 360 struct intel_connector *intel_connector; 361 struct intel_encoder *intel_encoder; 362 struct drm_connector *connector; 363 struct drm_connector_list_iter conn_iter; 364 bool changed = false; 365 u32 hpd_event_bits; 366 367 mutex_lock(&dev->mode_config.mutex); 368 DRM_DEBUG_KMS("running encoder hotplug functions\n"); 369 370 spin_lock_irq(&dev_priv->irq_lock); 371 372 hpd_event_bits = dev_priv->hotplug.event_bits; 373 dev_priv->hotplug.event_bits = 0; 374 375 /* Disable hotplug on connectors that hit an irq storm. */ 376 intel_hpd_irq_storm_disable(dev_priv); 377 378 spin_unlock_irq(&dev_priv->irq_lock); 379 380 drm_connector_list_iter_begin(dev, &conn_iter); 381 drm_for_each_connector_iter(connector, &conn_iter) { 382 intel_connector = to_intel_connector(connector); 383 if (!intel_connector->encoder) 384 continue; 385 intel_encoder = intel_connector->encoder; 386 if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) { 387 DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n", 388 connector->name, intel_encoder->hpd_pin); 389 390 changed |= intel_encoder->hotplug(intel_encoder, 391 intel_connector); 392 } 393 } 394 drm_connector_list_iter_end(&conn_iter); 395 mutex_unlock(&dev->mode_config.mutex); 396 397 if (changed) 398 drm_kms_helper_hotplug_event(dev); 399} 400 401 402/** 403 * intel_hpd_irq_handler - main hotplug irq handler 404 * @dev_priv: drm_i915_private 405 * @pin_mask: a mask of hpd pins that have triggered the irq 406 * @long_mask: a mask of hpd pins that may be long hpd pulses 407 * 408 * This is the main hotplug irq handler for all platforms. The platform specific 409 * irq handlers call the platform specific hotplug irq handlers, which read and 410 * decode the appropriate registers into bitmasks about hpd pins that have 411 * triggered (@pin_mask), and which of those pins may be long pulses 412 * (@long_mask). The @long_mask is ignored if the port corresponding to the pin 413 * is not a digital port. 414 * 415 * Here, we do hotplug irq storm detection and mitigation, and pass further 416 * processing to appropriate bottom halves. 417 */ 418void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, 419 u32 pin_mask, u32 long_mask) 420{ 421 int i; 422 enum port port; 423 bool storm_detected = false; 424 bool queue_dig = false, queue_hp = false; 425 bool is_dig_port; 426 427 if (!pin_mask) 428 return; 429 430 spin_lock(&dev_priv->irq_lock); 431 for_each_hpd_pin(i) { 432 if (!(BIT(i) & pin_mask)) 433 continue; 434 435 port = intel_hpd_pin_to_port(dev_priv, i); 436 is_dig_port = port != PORT_NONE && 437 dev_priv->hotplug.irq_port[port]; 438 439 if (is_dig_port) { 440 bool long_hpd = long_mask & BIT(i); 441 442 DRM_DEBUG_DRIVER("digital hpd port %c - %s\n", port_name(port), 443 long_hpd ? "long" : "short"); 444 /* 445 * For long HPD pulses we want to have the digital queue happen, 446 * but we still want HPD storm detection to function. 447 */ 448 queue_dig = true; 449 if (long_hpd) { 450 dev_priv->hotplug.long_port_mask |= (1 << port); 451 } else { 452 /* for short HPD just trigger the digital queue */ 453 dev_priv->hotplug.short_port_mask |= (1 << port); 454 continue; 455 } 456 } 457 458 if (dev_priv->hotplug.stats[i].state == HPD_DISABLED) { 459 /* 460 * On GMCH platforms the interrupt mask bits only 461 * prevent irq generation, not the setting of the 462 * hotplug bits itself. So only WARN about unexpected 463 * interrupts on saner platforms. 464 */ 465 WARN_ONCE(!HAS_GMCH_DISPLAY(dev_priv), 466 "Received HPD interrupt on pin %d although disabled\n", i); 467 continue; 468 } 469 470 if (dev_priv->hotplug.stats[i].state != HPD_ENABLED) 471 continue; 472 473 if (!is_dig_port) { 474 dev_priv->hotplug.event_bits |= BIT(i); 475 queue_hp = true; 476 } 477 478 if (intel_hpd_irq_storm_detect(dev_priv, i)) { 479 dev_priv->hotplug.event_bits &= ~BIT(i); 480 storm_detected = true; 481 } 482 } 483 484 if (storm_detected && dev_priv->display_irqs_enabled) 485 dev_priv->display.hpd_irq_setup(dev_priv); 486 spin_unlock(&dev_priv->irq_lock); 487 488 /* 489 * Our hotplug handler can grab modeset locks (by calling down into the 490 * fb helpers). Hence it must not be run on our own dev-priv->wq work 491 * queue for otherwise the flush_work in the pageflip code will 492 * deadlock. 493 */ 494 if (queue_dig) 495 queue_work(dev_priv->hotplug.dp_wq, &dev_priv->hotplug.dig_port_work); 496 if (queue_hp) 497 schedule_work(&dev_priv->hotplug.hotplug_work); 498} 499 500/** 501 * intel_hpd_init - initializes and enables hpd support 502 * @dev_priv: i915 device instance 503 * 504 * This function enables the hotplug support. It requires that interrupts have 505 * already been enabled with intel_irq_init_hw(). From this point on hotplug and 506 * poll request can run concurrently to other code, so locking rules must be 507 * obeyed. 508 * 509 * This is a separate step from interrupt enabling to simplify the locking rules 510 * in the driver load and resume code. 511 * 512 * Also see: intel_hpd_poll_init(), which enables connector polling 513 */ 514void intel_hpd_init(struct drm_i915_private *dev_priv) 515{ 516 int i; 517 518 for_each_hpd_pin(i) { 519 dev_priv->hotplug.stats[i].count = 0; 520 dev_priv->hotplug.stats[i].state = HPD_ENABLED; 521 } 522 523 WRITE_ONCE(dev_priv->hotplug.poll_enabled, false); 524 schedule_work(&dev_priv->hotplug.poll_init_work); 525 526 /* 527 * Interrupt setup is already guaranteed to be single-threaded, this is 528 * just to make the assert_spin_locked checks happy. 529 */ 530 if (dev_priv->display_irqs_enabled && dev_priv->display.hpd_irq_setup) { 531 spin_lock_irq(&dev_priv->irq_lock); 532 if (dev_priv->display_irqs_enabled) 533 dev_priv->display.hpd_irq_setup(dev_priv); 534 spin_unlock_irq(&dev_priv->irq_lock); 535 } 536} 537 538static void i915_hpd_poll_init_work(struct work_struct *work) 539{ 540 struct drm_i915_private *dev_priv = 541 container_of(work, struct drm_i915_private, 542 hotplug.poll_init_work); 543 struct drm_device *dev = &dev_priv->drm; 544 struct drm_connector *connector; 545 struct drm_connector_list_iter conn_iter; 546 bool enabled; 547 548 mutex_lock(&dev->mode_config.mutex); 549 550 enabled = READ_ONCE(dev_priv->hotplug.poll_enabled); 551 552 drm_connector_list_iter_begin(dev, &conn_iter); 553 drm_for_each_connector_iter(connector, &conn_iter) { 554 struct intel_connector *intel_connector = 555 to_intel_connector(connector); 556 connector->polled = intel_connector->polled; 557 558 /* MST has a dynamic intel_connector->encoder and it's reprobing 559 * is all handled by the MST helpers. */ 560 if (intel_connector->mst_port) 561 continue; 562 563 if (!connector->polled && I915_HAS_HOTPLUG(dev_priv) && 564 intel_connector->encoder->hpd_pin > HPD_NONE) { 565 connector->polled = enabled ? 566 DRM_CONNECTOR_POLL_CONNECT | 567 DRM_CONNECTOR_POLL_DISCONNECT : 568 DRM_CONNECTOR_POLL_HPD; 569 } 570 } 571 drm_connector_list_iter_end(&conn_iter); 572 573 if (enabled) 574 drm_kms_helper_poll_enable(dev); 575 576 mutex_unlock(&dev->mode_config.mutex); 577 578 /* 579 * We might have missed any hotplugs that happened while we were 580 * in the middle of disabling polling 581 */ 582 if (!enabled) 583 drm_helper_hpd_irq_event(dev); 584} 585 586/** 587 * intel_hpd_poll_init - enables/disables polling for connectors with hpd 588 * @dev_priv: i915 device instance 589 * 590 * This function enables polling for all connectors, regardless of whether or 591 * not they support hotplug detection. Under certain conditions HPD may not be 592 * functional. On most Intel GPUs, this happens when we enter runtime suspend. 593 * On Valleyview and Cherryview systems, this also happens when we shut off all 594 * of the powerwells. 595 * 596 * Since this function can get called in contexts where we're already holding 597 * dev->mode_config.mutex, we do the actual hotplug enabling in a seperate 598 * worker. 599 * 600 * Also see: intel_hpd_init(), which restores hpd handling. 601 */ 602void intel_hpd_poll_init(struct drm_i915_private *dev_priv) 603{ 604 WRITE_ONCE(dev_priv->hotplug.poll_enabled, true); 605 606 /* 607 * We might already be holding dev->mode_config.mutex, so do this in a 608 * seperate worker 609 * As well, there's no issue if we race here since we always reschedule 610 * this worker anyway 611 */ 612 schedule_work(&dev_priv->hotplug.poll_init_work); 613} 614 615void intel_hpd_init_work(struct drm_i915_private *dev_priv) 616{ 617 INIT_WORK(&dev_priv->hotplug.hotplug_work, i915_hotplug_work_func); 618 INIT_WORK(&dev_priv->hotplug.dig_port_work, i915_digport_work_func); 619 INIT_WORK(&dev_priv->hotplug.poll_init_work, i915_hpd_poll_init_work); 620 INIT_DELAYED_WORK(&dev_priv->hotplug.reenable_work, 621 intel_hpd_irq_storm_reenable_work); 622} 623 624void intel_hpd_cancel_work(struct drm_i915_private *dev_priv) 625{ 626 spin_lock_irq(&dev_priv->irq_lock); 627 628 dev_priv->hotplug.long_port_mask = 0; 629 dev_priv->hotplug.short_port_mask = 0; 630 dev_priv->hotplug.event_bits = 0; 631 632 spin_unlock_irq(&dev_priv->irq_lock); 633 634 cancel_work_sync(&dev_priv->hotplug.dig_port_work); 635 cancel_work_sync(&dev_priv->hotplug.hotplug_work); 636 cancel_work_sync(&dev_priv->hotplug.poll_init_work); 637 cancel_delayed_work_sync(&dev_priv->hotplug.reenable_work); 638} 639 640bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin) 641{ 642 bool ret = false; 643 644 if (pin == HPD_NONE) 645 return false; 646 647 spin_lock_irq(&dev_priv->irq_lock); 648 if (dev_priv->hotplug.stats[pin].state == HPD_ENABLED) { 649 dev_priv->hotplug.stats[pin].state = HPD_DISABLED; 650 ret = true; 651 } 652 spin_unlock_irq(&dev_priv->irq_lock); 653 654 return ret; 655} 656 657void intel_hpd_enable(struct drm_i915_private *dev_priv, enum hpd_pin pin) 658{ 659 if (pin == HPD_NONE) 660 return; 661 662 spin_lock_irq(&dev_priv->irq_lock); 663 dev_priv->hotplug.stats[pin].state = HPD_ENABLED; 664 spin_unlock_irq(&dev_priv->irq_lock); 665}