Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'topic/drm-misc-2016-01-17' of git://anongit.freedesktop.org/drm-intel into drm-next

Since your main drm-next pull isn't out of the door yet I figured I might
as well flush out drm-misc instead of delaying for 4.6. It's really just
random stuff all over, biggest thing probably connector_mask tracking from
Maarten.

* tag 'topic/drm-misc-2016-01-17' of git://anongit.freedesktop.org/drm-intel: (24 commits)
drm/fb_cma_helper: Remove implicit call to disable_unused_functions
drm/sysfs: use kobj_to_dev()
drm/i915: Init power domains early in driver load
drm: Do not set connector->encoder in drivers
apple-gmux: Add initial documentation
drm: move MODULE_PARM_DESC to other file
drm/edid: index CEA/HDMI mode tables using the VIC
drm/atomic: Remove drm_atomic_connectors_for_crtc.
drm/i915: Update connector_mask during readout, v2.
drm: Remove opencoded drm_gem_object_release_handle()
drm: Do not set outparam on error during GEM handle allocation
drm/docs: more leftovers from the big vtable documentation pile
drm/atomic-helper: Reject legacy flips on a disabled pipe
drm/atomic: add connector mask to drm_crtc_state.
drm/tegra: Use __drm_atomic_helper_reset_connector for subclassing connector state, v2.
drm/atomic: Add __drm_atomic_helper_connector_reset, v2.
drm/i915: Set connector_state->connector using the helper.
drm: Use a normal idr allocation for the obj->name
drm: Only bump object-reference count when adding first handle
drm: Balance error path for GEM handle allocation
...

+437 -387
+42 -208
Documentation/DocBook/gpu.tmpl
··· 1579 1579 entities. 1580 1580 </para> 1581 1581 <sect2> 1582 - <title>Legacy CRTC Helper Operations</title> 1583 - <itemizedlist> 1584 - <listitem id="drm-helper-crtc-mode-fixup"> 1585 - <synopsis>bool (*mode_fixup)(struct drm_crtc *crtc, 1586 - const struct drm_display_mode *mode, 1587 - struct drm_display_mode *adjusted_mode);</synopsis> 1588 - <para> 1589 - Let CRTCs adjust the requested mode or reject it completely. This 1590 - operation returns true if the mode is accepted (possibly after being 1591 - adjusted) or false if it is rejected. 1592 - </para> 1593 - <para> 1594 - The <methodname>mode_fixup</methodname> operation should reject the 1595 - mode if it can't reasonably use it. The definition of "reasonable" 1596 - is currently fuzzy in this context. One possible behaviour would be 1597 - to set the adjusted mode to the panel timings when a fixed-mode 1598 - panel is used with hardware capable of scaling. Another behaviour 1599 - would be to accept any input mode and adjust it to the closest mode 1600 - supported by the hardware (FIXME: This needs to be clarified). 1601 - </para> 1602 - </listitem> 1603 - <listitem> 1604 - <synopsis>int (*mode_set_base)(struct drm_crtc *crtc, int x, int y, 1605 - struct drm_framebuffer *old_fb)</synopsis> 1606 - <para> 1607 - Move the CRTC on the current frame buffer (stored in 1608 - <literal>crtc-&gt;fb</literal>) to position (x,y). Any of the frame 1609 - buffer, x position or y position may have been modified. 1610 - </para> 1611 - <para> 1612 - This helper operation is optional. If not provided, the 1613 - <function>drm_crtc_helper_set_config</function> function will fall 1614 - back to the <methodname>mode_set</methodname> helper operation. 1615 - </para> 1616 - <note><para> 1617 - FIXME: Why are x and y passed as arguments, as they can be accessed 1618 - through <literal>crtc-&gt;x</literal> and 1619 - <literal>crtc-&gt;y</literal>? 1620 - </para></note> 1621 - </listitem> 1622 - <listitem> 1623 - <synopsis>void (*prepare)(struct drm_crtc *crtc);</synopsis> 1624 - <para> 1625 - Prepare the CRTC for mode setting. This operation is called after 1626 - validating the requested mode. Drivers use it to perform 1627 - device-specific operations required before setting the new mode. 1628 - </para> 1629 - </listitem> 1630 - <listitem> 1631 - <synopsis>int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, 1632 - struct drm_display_mode *adjusted_mode, int x, int y, 1633 - struct drm_framebuffer *old_fb);</synopsis> 1634 - <para> 1635 - Set a new mode, position and frame buffer. Depending on the device 1636 - requirements, the mode can be stored internally by the driver and 1637 - applied in the <methodname>commit</methodname> operation, or 1638 - programmed to the hardware immediately. 1639 - </para> 1640 - <para> 1641 - The <methodname>mode_set</methodname> operation returns 0 on success 1642 - or a negative error code if an error occurs. 1643 - </para> 1644 - </listitem> 1645 - <listitem> 1646 - <synopsis>void (*commit)(struct drm_crtc *crtc);</synopsis> 1647 - <para> 1648 - Commit a mode. This operation is called after setting the new mode. 1649 - Upon return the device must use the new mode and be fully 1650 - operational. 1651 - </para> 1652 - </listitem> 1653 - </itemizedlist> 1654 - </sect2> 1655 - <sect2> 1656 - <title>Encoder Helper Operations</title> 1657 - <itemizedlist> 1658 - <listitem> 1659 - <synopsis>bool (*mode_fixup)(struct drm_encoder *encoder, 1660 - const struct drm_display_mode *mode, 1661 - struct drm_display_mode *adjusted_mode);</synopsis> 1662 - <para> 1663 - Let encoders adjust the requested mode or reject it completely. This 1664 - operation returns true if the mode is accepted (possibly after being 1665 - adjusted) or false if it is rejected. See the 1666 - <link linkend="drm-helper-crtc-mode-fixup">mode_fixup CRTC helper 1667 - operation</link> for an explanation of the allowed adjustments. 1668 - </para> 1669 - </listitem> 1670 - <listitem> 1671 - <synopsis>void (*prepare)(struct drm_encoder *encoder);</synopsis> 1672 - <para> 1673 - Prepare the encoder for mode setting. This operation is called after 1674 - validating the requested mode. Drivers use it to perform 1675 - device-specific operations required before setting the new mode. 1676 - </para> 1677 - </listitem> 1678 - <listitem> 1679 - <synopsis>void (*mode_set)(struct drm_encoder *encoder, 1680 - struct drm_display_mode *mode, 1681 - struct drm_display_mode *adjusted_mode);</synopsis> 1682 - <para> 1683 - Set a new mode. Depending on the device requirements, the mode can 1684 - be stored internally by the driver and applied in the 1685 - <methodname>commit</methodname> operation, or programmed to the 1686 - hardware immediately. 1687 - </para> 1688 - </listitem> 1689 - <listitem> 1690 - <synopsis>void (*commit)(struct drm_encoder *encoder);</synopsis> 1691 - <para> 1692 - Commit a mode. This operation is called after setting the new mode. 1693 - Upon return the device must use the new mode and be fully 1694 - operational. 1695 - </para> 1696 - </listitem> 1697 - </itemizedlist> 1698 - </sect2> 1699 - <sect2> 1700 - <title>Connector Helper Operations</title> 1701 - <itemizedlist> 1702 - <listitem> 1703 - <synopsis>struct drm_encoder *(*best_encoder)(struct drm_connector *connector);</synopsis> 1704 - <para> 1705 - Return a pointer to the best encoder for the connecter. Device that 1706 - map connectors to encoders 1:1 simply return the pointer to the 1707 - associated encoder. This operation is mandatory. 1708 - </para> 1709 - </listitem> 1710 - <listitem> 1711 - <synopsis>int (*get_modes)(struct drm_connector *connector);</synopsis> 1712 - <para> 1713 - Fill the connector's <structfield>probed_modes</structfield> list 1714 - by parsing EDID data with <function>drm_add_edid_modes</function>, 1715 - adding standard VESA DMT modes with <function>drm_add_modes_noedid</function>, 1716 - or calling <function>drm_mode_probed_add</function> directly for every 1717 - supported mode and return the number of modes it has detected. This 1718 - operation is mandatory. 1719 - </para> 1720 - <para> 1721 - Note that the caller function will automatically add standard VESA 1722 - DMT modes up to 1024x768 if the <methodname>get_modes</methodname> 1723 - helper operation returns no mode and if the connector status is 1724 - connector_status_connected. There is no need to call 1725 - <function>drm_add_edid_modes</function> manually in that case. 1726 - </para> 1727 - <para> 1728 - The <structfield>vrefresh</structfield> value is computed by 1729 - <function>drm_helper_probe_single_connector_modes</function>. 1730 - </para> 1731 - <para> 1732 - When parsing EDID data, <function>drm_add_edid_modes</function> fills the 1733 - connector <structfield>display_info</structfield> 1734 - <structfield>width_mm</structfield> and 1735 - <structfield>height_mm</structfield> fields. When creating modes 1736 - manually the <methodname>get_modes</methodname> helper operation must 1737 - set the <structfield>display_info</structfield> 1738 - <structfield>width_mm</structfield> and 1739 - <structfield>height_mm</structfield> fields if they haven't been set 1740 - already (for instance at initialization time when a fixed-size panel is 1741 - attached to the connector). The mode <structfield>width_mm</structfield> 1742 - and <structfield>height_mm</structfield> fields are only used internally 1743 - during EDID parsing and should not be set when creating modes manually. 1744 - </para> 1745 - </listitem> 1746 - <listitem> 1747 - <synopsis>int (*mode_valid)(struct drm_connector *connector, 1748 - struct drm_display_mode *mode);</synopsis> 1749 - <para> 1750 - Verify whether a mode is valid for the connector. Return MODE_OK for 1751 - supported modes and one of the enum drm_mode_status values (MODE_*) 1752 - for unsupported modes. This operation is optional. 1753 - </para> 1754 - <para> 1755 - As the mode rejection reason is currently not used beside for 1756 - immediately removing the unsupported mode, an implementation can 1757 - return MODE_BAD regardless of the exact reason why the mode is not 1758 - valid. 1759 - </para> 1760 - <note><para> 1761 - Note that the <methodname>mode_valid</methodname> helper operation is 1762 - only called for modes detected by the device, and 1763 - <emphasis>not</emphasis> for modes set by the user through the CRTC 1764 - <methodname>set_config</methodname> operation. 1765 - </para></note> 1766 - </listitem> 1767 - </itemizedlist> 1768 - </sect2> 1769 - <sect2> 1770 1582 <title>Atomic Modeset Helper Functions Reference</title> 1771 1583 <sect3> 1772 1584 <title>Overview</title> ··· 3437 3625 3438 3626 <chapter id="modes_of_use"> 3439 3627 <title>Modes of Use</title> 3440 - <sect1> 3441 - <title>Manual switching and manual power control</title> 3628 + <sect1> 3629 + <title>Manual switching and manual power control</title> 3442 3630 !Pdrivers/gpu/vga/vga_switcheroo.c Manual switching and manual power control 3443 - </sect1> 3444 - <sect1> 3445 - <title>Driver power control</title> 3631 + </sect1> 3632 + <sect1> 3633 + <title>Driver power control</title> 3446 3634 !Pdrivers/gpu/vga/vga_switcheroo.c Driver power control 3447 - </sect1> 3635 + </sect1> 3448 3636 </chapter> 3449 3637 3450 - <chapter id="pubfunctions"> 3451 - <title>Public functions</title> 3638 + <chapter id="api"> 3639 + <title>API</title> 3640 + <sect1> 3641 + <title>Public functions</title> 3452 3642 !Edrivers/gpu/vga/vga_switcheroo.c 3453 - </chapter> 3454 - 3455 - <chapter id="pubstructures"> 3456 - <title>Public structures</title> 3643 + </sect1> 3644 + <sect1> 3645 + <title>Public structures</title> 3457 3646 !Finclude/linux/vga_switcheroo.h vga_switcheroo_handler 3458 3647 !Finclude/linux/vga_switcheroo.h vga_switcheroo_client_ops 3459 - </chapter> 3460 - 3461 - <chapter id="pubconstants"> 3462 - <title>Public constants</title> 3648 + </sect1> 3649 + <sect1> 3650 + <title>Public constants</title> 3463 3651 !Finclude/linux/vga_switcheroo.h vga_switcheroo_client_id 3464 3652 !Finclude/linux/vga_switcheroo.h vga_switcheroo_state 3465 - </chapter> 3466 - 3467 - <chapter id="privstructures"> 3468 - <title>Private structures</title> 3653 + </sect1> 3654 + <sect1> 3655 + <title>Private structures</title> 3469 3656 !Fdrivers/gpu/vga/vga_switcheroo.c vgasr_priv 3470 3657 !Fdrivers/gpu/vga/vga_switcheroo.c vga_switcheroo_client 3658 + </sect1> 3659 + </chapter> 3660 + 3661 + <chapter id="handlers"> 3662 + <title>Handlers</title> 3663 + <sect1> 3664 + <title>apple-gmux Handler</title> 3665 + !Pdrivers/platform/x86/apple-gmux.c Overview 3666 + !Pdrivers/platform/x86/apple-gmux.c Interrupt 3667 + <sect2> 3668 + <title>Graphics mux</title> 3669 + !Pdrivers/platform/x86/apple-gmux.c Graphics mux 3670 + </sect2> 3671 + <sect2> 3672 + <title>Power control</title> 3673 + !Pdrivers/platform/x86/apple-gmux.c Power control 3674 + </sect2> 3675 + <sect2> 3676 + <title>Backlight control</title> 3677 + !Pdrivers/platform/x86/apple-gmux.c Backlight control 3678 + </sect2> 3679 + </sect1> 3471 3680 </chapter> 3472 3681 3473 3682 !Cdrivers/gpu/vga/vga_switcheroo.c 3474 3683 !Cinclude/linux/vga_switcheroo.h 3684 + !Cdrivers/platform/x86/apple-gmux.c 3475 3685 </part> 3476 3686 3477 3687 </book>
-2
drivers/gpu/drm/bridge/dw-hdmi.c
··· 1667 1667 &dw_hdmi_connector_funcs, 1668 1668 DRM_MODE_CONNECTOR_HDMIA); 1669 1669 1670 - hdmi->connector.encoder = encoder; 1671 - 1672 1670 drm_mode_connector_attach_encoder(&hdmi->connector, encoder); 1673 1671 1674 1672 return 0;
+27 -30
drivers/gpu/drm/drm_atomic.c
··· 508 508 return -EINVAL; 509 509 } 510 510 511 + /* 512 + * Reject event generation for when a CRTC is off and stays off. 513 + * It wouldn't be hard to implement this, but userspace has a track 514 + * record of happily burning through 100% cpu (or worse, crash) when the 515 + * display pipe is suspended. To avoid all that fun just reject updates 516 + * that ask for events since likely that indicates a bug in the 517 + * compositor's drawing loop. This is consistent with the vblank IOCTL 518 + * and legacy page_flip IOCTL which also reject service on a disabled 519 + * pipe. 520 + */ 521 + if (state->event && !state->active && !crtc->state->active) { 522 + DRM_DEBUG_ATOMIC("[CRTC:%d] requesting event but off\n", 523 + crtc->base.id); 524 + return -EINVAL; 525 + } 526 + 511 527 return 0; 512 528 } 513 529 ··· 1079 1063 { 1080 1064 struct drm_crtc_state *crtc_state; 1081 1065 1066 + if (conn_state->crtc && conn_state->crtc != crtc) { 1067 + crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state, 1068 + conn_state->crtc); 1069 + 1070 + crtc_state->connector_mask &= 1071 + ~(1 << drm_connector_index(conn_state->connector)); 1072 + } 1073 + 1082 1074 if (crtc) { 1083 1075 crtc_state = drm_atomic_get_crtc_state(conn_state->state, crtc); 1084 1076 if (IS_ERR(crtc_state)) 1085 1077 return PTR_ERR(crtc_state); 1078 + 1079 + crtc_state->connector_mask |= 1080 + 1 << drm_connector_index(conn_state->connector); 1086 1081 } 1087 1082 1088 1083 conn_state->crtc = crtc; ··· 1197 1170 return 0; 1198 1171 } 1199 1172 EXPORT_SYMBOL(drm_atomic_add_affected_planes); 1200 - 1201 - /** 1202 - * drm_atomic_connectors_for_crtc - count number of connected outputs 1203 - * @state: atomic state 1204 - * @crtc: DRM crtc 1205 - * 1206 - * This function counts all connectors which will be connected to @crtc 1207 - * according to @state. Useful to recompute the enable state for @crtc. 1208 - */ 1209 - int 1210 - drm_atomic_connectors_for_crtc(struct drm_atomic_state *state, 1211 - struct drm_crtc *crtc) 1212 - { 1213 - struct drm_connector *connector; 1214 - struct drm_connector_state *conn_state; 1215 - 1216 - int i, num_connected_connectors = 0; 1217 - 1218 - for_each_connector_in_state(state, connector, conn_state, i) { 1219 - if (conn_state->crtc == crtc) 1220 - num_connected_connectors++; 1221 - } 1222 - 1223 - DRM_DEBUG_ATOMIC("State %p has %i connectors for [CRTC:%d:%s]\n", 1224 - state, num_connected_connectors, 1225 - crtc->base.id, crtc->name); 1226 - 1227 - return num_connected_connectors; 1228 - } 1229 - EXPORT_SYMBOL(drm_atomic_connectors_for_crtc); 1230 1173 1231 1174 /** 1232 1175 * drm_atomic_legacy_backoff - locking backoff for legacy ioctls
+39 -10
drivers/gpu/drm/drm_atomic_helper.c
··· 463 463 * crtc only changed its mode but has the same set of connectors. 464 464 */ 465 465 for_each_crtc_in_state(state, crtc, crtc_state, i) { 466 - int num_connectors; 466 + bool has_connectors = 467 + !!crtc_state->connector_mask; 467 468 468 469 /* 469 470 * We must set ->active_changed after walking connectors for ··· 493 492 if (ret != 0) 494 493 return ret; 495 494 496 - num_connectors = drm_atomic_connectors_for_crtc(state, 497 - crtc); 498 - 499 - if (crtc_state->enable != !!num_connectors) { 495 + if (crtc_state->enable != has_connectors) { 500 496 DRM_DEBUG_ATOMIC("[CRTC:%d:%s] enabled/connectors mismatch\n", 501 497 crtc->base.id, crtc->name); 502 498 ··· 1752 1754 if (crtc == set->crtc) 1753 1755 continue; 1754 1756 1755 - if (!drm_atomic_connectors_for_crtc(state, crtc)) { 1757 + if (!crtc_state->connector_mask) { 1756 1758 ret = drm_atomic_set_mode_prop_for_crtc(crtc_state, 1757 1759 NULL); 1758 1760 if (ret < 0) ··· 2282 2284 goto fail; 2283 2285 drm_atomic_set_fb_for_plane(plane_state, fb); 2284 2286 2287 + /* Make sure we don't accidentally do a full modeset. */ 2288 + state->allow_modeset = false; 2289 + if (!crtc_state->active) { 2290 + DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n", 2291 + crtc->base.id); 2292 + ret = -EINVAL; 2293 + goto fail; 2294 + } 2295 + 2285 2296 ret = drm_atomic_async_commit(state); 2286 2297 if (ret != 0) 2287 2298 goto fail; ··· 2613 2606 EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state); 2614 2607 2615 2608 /** 2609 + * __drm_atomic_helper_connector_reset - reset state on connector 2610 + * @connector: drm connector 2611 + * @conn_state: connector state to assign 2612 + * 2613 + * Initializes the newly allocated @conn_state and assigns it to 2614 + * #connector ->state, usually required when initializing the drivers 2615 + * or when called from the ->reset hook. 2616 + * 2617 + * This is useful for drivers that subclass the connector state. 2618 + */ 2619 + void 2620 + __drm_atomic_helper_connector_reset(struct drm_connector *connector, 2621 + struct drm_connector_state *conn_state) 2622 + { 2623 + if (conn_state) 2624 + conn_state->connector = connector; 2625 + 2626 + connector->state = conn_state; 2627 + } 2628 + EXPORT_SYMBOL(__drm_atomic_helper_connector_reset); 2629 + 2630 + /** 2616 2631 * drm_atomic_helper_connector_reset - default ->reset hook for connectors 2617 2632 * @connector: drm connector 2618 2633 * ··· 2644 2615 */ 2645 2616 void drm_atomic_helper_connector_reset(struct drm_connector *connector) 2646 2617 { 2647 - kfree(connector->state); 2648 - connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL); 2618 + struct drm_connector_state *conn_state = 2619 + kzalloc(sizeof(*conn_state), GFP_KERNEL); 2649 2620 2650 - if (connector->state) 2651 - connector->state->connector = connector; 2621 + kfree(connector->state); 2622 + __drm_atomic_helper_connector_reset(connector, conn_state); 2652 2623 } 2653 2624 EXPORT_SYMBOL(drm_atomic_helper_connector_reset); 2654 2625
+14
drivers/gpu/drm/drm_crtc.c
··· 5054 5054 { 5055 5055 int i; 5056 5056 5057 + /* 5058 + * In the past, drivers have attempted to model the static association 5059 + * of connector to encoder in simple connector/encoder devices using a 5060 + * direct assignment of connector->encoder = encoder. This connection 5061 + * is a logical one and the responsibility of the core, so drivers are 5062 + * expected not to mess with this. 5063 + * 5064 + * Note that the error return should've been enough here, but a large 5065 + * majority of drivers ignores the return value, so add in a big WARN 5066 + * to get people's attention. 5067 + */ 5068 + if (WARN_ON(connector->encoder)) 5069 + return -EINVAL; 5070 + 5057 5071 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 5058 5072 if (connector->encoder_ids[i] == 0) { 5059 5073 connector->encoder_ids[i] = encoder->base.id;
-4
drivers/gpu/drm/drm_drv.c
··· 44 44 MODULE_DESCRIPTION(CORE_DESC); 45 45 MODULE_LICENSE("GPL and additional rights"); 46 46 MODULE_PARM_DESC(debug, "Enable debug output"); 47 - MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately)"); 48 - MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]"); 49 - MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps"); 50 - 51 47 module_param_named(debug, drm_debug, int, 0600); 52 48 53 49 static DEFINE_SPINLOCK(drm_minor_lock);
+53 -41
drivers/gpu/drm/drm_edid.c
··· 637 637 /* 638 638 * Probably taken from CEA-861 spec. 639 639 * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c. 640 + * 641 + * Index using the VIC. 640 642 */ 641 643 static const struct drm_display_mode edid_cea_modes[] = { 644 + /* 0 - dummy, VICs start at 1 */ 645 + { }, 642 646 /* 1 - 640x480@60Hz */ 643 647 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, 644 648 752, 800, 0, 480, 490, 492, 525, 0, ··· 991 987 }; 992 988 993 989 /* 994 - * HDMI 1.4 4k modes. 990 + * HDMI 1.4 4k modes. Index using the VIC. 995 991 */ 996 992 static const struct drm_display_mode edid_4k_modes[] = { 993 + /* 0 - dummy, VICs start at 1 */ 994 + { }, 997 995 /* 1 - 3840x2160@30Hz */ 998 996 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 999 997 3840, 4016, 4104, 4400, 0, ··· 2554 2548 static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match, 2555 2549 unsigned int clock_tolerance) 2556 2550 { 2557 - u8 mode; 2551 + u8 vic; 2558 2552 2559 2553 if (!to_match->clock) 2560 2554 return 0; 2561 2555 2562 - for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) { 2563 - const struct drm_display_mode *cea_mode = &edid_cea_modes[mode]; 2556 + for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) { 2557 + const struct drm_display_mode *cea_mode = &edid_cea_modes[vic]; 2564 2558 unsigned int clock1, clock2; 2565 2559 2566 2560 /* Check both 60Hz and 59.94Hz */ ··· 2572 2566 continue; 2573 2567 2574 2568 if (drm_mode_equal_no_clocks(to_match, cea_mode)) 2575 - return mode + 1; 2569 + return vic; 2576 2570 } 2577 2571 2578 2572 return 0; ··· 2587 2581 */ 2588 2582 u8 drm_match_cea_mode(const struct drm_display_mode *to_match) 2589 2583 { 2590 - u8 mode; 2584 + u8 vic; 2591 2585 2592 2586 if (!to_match->clock) 2593 2587 return 0; 2594 2588 2595 - for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) { 2596 - const struct drm_display_mode *cea_mode = &edid_cea_modes[mode]; 2589 + for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) { 2590 + const struct drm_display_mode *cea_mode = &edid_cea_modes[vic]; 2597 2591 unsigned int clock1, clock2; 2598 2592 2599 2593 /* Check both 60Hz and 59.94Hz */ ··· 2603 2597 if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) || 2604 2598 KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) && 2605 2599 drm_mode_equal_no_clocks_no_stereo(to_match, cea_mode)) 2606 - return mode + 1; 2600 + return vic; 2607 2601 } 2608 2602 return 0; 2609 2603 } 2610 2604 EXPORT_SYMBOL(drm_match_cea_mode); 2605 + 2606 + static bool drm_valid_cea_vic(u8 vic) 2607 + { 2608 + return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes); 2609 + } 2611 2610 2612 2611 /** 2613 2612 * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to ··· 2623 2612 */ 2624 2613 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code) 2625 2614 { 2626 - /* return picture aspect ratio for video_code - 1 to access the 2627 - * right array element 2628 - */ 2629 - return edid_cea_modes[video_code-1].picture_aspect_ratio; 2615 + return edid_cea_modes[video_code].picture_aspect_ratio; 2630 2616 } 2631 2617 EXPORT_SYMBOL(drm_get_cea_aspect_ratio); 2632 2618 ··· 2647 2639 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match, 2648 2640 unsigned int clock_tolerance) 2649 2641 { 2650 - u8 mode; 2642 + u8 vic; 2651 2643 2652 2644 if (!to_match->clock) 2653 2645 return 0; 2654 2646 2655 - for (mode = 0; mode < ARRAY_SIZE(edid_4k_modes); mode++) { 2656 - const struct drm_display_mode *hdmi_mode = &edid_4k_modes[mode]; 2647 + for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { 2648 + const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; 2657 2649 unsigned int clock1, clock2; 2658 2650 2659 2651 /* Make sure to also match alternate clocks */ ··· 2665 2657 continue; 2666 2658 2667 2659 if (drm_mode_equal_no_clocks(to_match, hdmi_mode)) 2668 - return mode + 1; 2660 + return vic; 2669 2661 } 2670 2662 2671 2663 return 0; ··· 2681 2673 */ 2682 2674 static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match) 2683 2675 { 2684 - u8 mode; 2676 + u8 vic; 2685 2677 2686 2678 if (!to_match->clock) 2687 2679 return 0; 2688 2680 2689 - for (mode = 0; mode < ARRAY_SIZE(edid_4k_modes); mode++) { 2690 - const struct drm_display_mode *hdmi_mode = &edid_4k_modes[mode]; 2681 + for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { 2682 + const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; 2691 2683 unsigned int clock1, clock2; 2692 2684 2693 2685 /* Make sure to also match alternate clocks */ ··· 2697 2689 if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) || 2698 2690 KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) && 2699 2691 drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode)) 2700 - return mode + 1; 2692 + return vic; 2701 2693 } 2702 2694 return 0; 2695 + } 2696 + 2697 + static bool drm_valid_hdmi_vic(u8 vic) 2698 + { 2699 + return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes); 2703 2700 } 2704 2701 2705 2702 static int ··· 2726 2713 list_for_each_entry(mode, &connector->probed_modes, head) { 2727 2714 const struct drm_display_mode *cea_mode = NULL; 2728 2715 struct drm_display_mode *newmode; 2729 - u8 mode_idx = drm_match_cea_mode(mode) - 1; 2716 + u8 vic = drm_match_cea_mode(mode); 2730 2717 unsigned int clock1, clock2; 2731 2718 2732 - if (mode_idx < ARRAY_SIZE(edid_cea_modes)) { 2733 - cea_mode = &edid_cea_modes[mode_idx]; 2719 + if (drm_valid_cea_vic(vic)) { 2720 + cea_mode = &edid_cea_modes[vic]; 2734 2721 clock2 = cea_mode_alternate_clock(cea_mode); 2735 2722 } else { 2736 - mode_idx = drm_match_hdmi_mode(mode) - 1; 2737 - if (mode_idx < ARRAY_SIZE(edid_4k_modes)) { 2738 - cea_mode = &edid_4k_modes[mode_idx]; 2723 + vic = drm_match_hdmi_mode(mode); 2724 + if (drm_valid_hdmi_vic(vic)) { 2725 + cea_mode = &edid_4k_modes[vic]; 2739 2726 clock2 = hdmi_mode_alternate_clock(cea_mode); 2740 2727 } 2741 2728 } ··· 2786 2773 { 2787 2774 struct drm_device *dev = connector->dev; 2788 2775 struct drm_display_mode *newmode; 2789 - u8 cea_mode; 2776 + u8 vic; 2790 2777 2791 2778 if (video_db == NULL || video_index >= video_len) 2792 2779 return NULL; 2793 2780 2794 2781 /* CEA modes are numbered 1..127 */ 2795 - cea_mode = (video_db[video_index] & 127) - 1; 2796 - if (cea_mode >= ARRAY_SIZE(edid_cea_modes)) 2782 + vic = (video_db[video_index] & 127); 2783 + if (!drm_valid_cea_vic(vic)) 2797 2784 return NULL; 2798 2785 2799 - newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); 2786 + newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]); 2800 2787 if (!newmode) 2801 2788 return NULL; 2802 2789 ··· 2891 2878 struct drm_device *dev = connector->dev; 2892 2879 struct drm_display_mode *newmode; 2893 2880 2894 - vic--; /* VICs start at 1 */ 2895 - if (vic >= ARRAY_SIZE(edid_4k_modes)) { 2881 + if (!drm_valid_hdmi_vic(vic)) { 2896 2882 DRM_ERROR("Unknown HDMI VIC: %d\n", vic); 2897 2883 return 0; 2898 2884 } ··· 3182 3170 { 3183 3171 const struct drm_display_mode *cea_mode; 3184 3172 int clock1, clock2, clock; 3185 - u8 mode_idx; 3173 + u8 vic; 3186 3174 const char *type; 3187 3175 3188 3176 /* 3189 3177 * allow 5kHz clock difference either way to account for 3190 3178 * the 10kHz clock resolution limit of detailed timings. 3191 3179 */ 3192 - mode_idx = drm_match_cea_mode_clock_tolerance(mode, 5) - 1; 3193 - if (mode_idx < ARRAY_SIZE(edid_cea_modes)) { 3180 + vic = drm_match_cea_mode_clock_tolerance(mode, 5); 3181 + if (drm_valid_cea_vic(vic)) { 3194 3182 type = "CEA"; 3195 - cea_mode = &edid_cea_modes[mode_idx]; 3183 + cea_mode = &edid_cea_modes[vic]; 3196 3184 clock1 = cea_mode->clock; 3197 3185 clock2 = cea_mode_alternate_clock(cea_mode); 3198 3186 } else { 3199 - mode_idx = drm_match_hdmi_mode_clock_tolerance(mode, 5) - 1; 3200 - if (mode_idx < ARRAY_SIZE(edid_4k_modes)) { 3187 + vic = drm_match_hdmi_mode_clock_tolerance(mode, 5); 3188 + if (drm_valid_hdmi_vic(vic)) { 3201 3189 type = "HDMI"; 3202 - cea_mode = &edid_4k_modes[mode_idx]; 3190 + cea_mode = &edid_4k_modes[vic]; 3203 3191 clock1 = cea_mode->clock; 3204 3192 clock2 = hdmi_mode_alternate_clock(cea_mode); 3205 3193 } else { ··· 3217 3205 return; 3218 3206 3219 3207 DRM_DEBUG("detailed mode matches %s VIC %d, adjusting clock %d -> %d\n", 3220 - type, mode_idx + 1, mode->clock, clock); 3208 + type, vic, mode->clock, clock); 3221 3209 mode->clock = clock; 3222 3210 } 3223 3211
-3
drivers/gpu/drm/drm_fb_cma_helper.c
··· 348 348 349 349 } 350 350 351 - /* disable all the possible outputs/crtcs before entering KMS mode */ 352 - drm_helper_disable_unused_functions(dev); 353 - 354 351 ret = drm_fb_helper_initial_config(helper, preferred_bpp); 355 352 if (ret < 0) { 356 353 dev_err(dev->dev, "Failed to set initial hw configuration.\n");
+1 -1
drivers/gpu/drm/drm_fb_helper.c
··· 1251 1251 goto fail; 1252 1252 1253 1253 plane = mode_set->crtc->primary; 1254 - plane_mask |= drm_plane_index(plane); 1254 + plane_mask |= (1 << drm_plane_index(plane)); 1255 1255 plane->old_fb = plane->fb; 1256 1256 } 1257 1257
+57 -52
drivers/gpu/drm/drm_gem.c
··· 220 220 static void 221 221 drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) 222 222 { 223 + struct drm_device *dev = obj->dev; 224 + bool final = false; 225 + 223 226 if (WARN_ON(obj->handle_count == 0)) 224 227 return; 225 228 ··· 232 229 * checked for a name 233 230 */ 234 231 235 - mutex_lock(&obj->dev->object_name_lock); 232 + mutex_lock(&dev->object_name_lock); 236 233 if (--obj->handle_count == 0) { 237 234 drm_gem_object_handle_free(obj); 238 235 drm_gem_object_exported_dma_buf_free(obj); 236 + final = true; 239 237 } 240 - mutex_unlock(&obj->dev->object_name_lock); 238 + mutex_unlock(&dev->object_name_lock); 241 239 242 - drm_gem_object_unreference_unlocked(obj); 240 + if (final) 241 + drm_gem_object_unreference_unlocked(obj); 242 + } 243 + 244 + /* 245 + * Called at device or object close to release the file's 246 + * handle references on objects. 247 + */ 248 + static int 249 + drm_gem_object_release_handle(int id, void *ptr, void *data) 250 + { 251 + struct drm_file *file_priv = data; 252 + struct drm_gem_object *obj = ptr; 253 + struct drm_device *dev = obj->dev; 254 + 255 + if (drm_core_check_feature(dev, DRIVER_PRIME)) 256 + drm_gem_remove_prime_handles(obj, file_priv); 257 + drm_vma_node_revoke(&obj->vma_node, file_priv->filp); 258 + 259 + if (dev->driver->gem_close_object) 260 + dev->driver->gem_close_object(obj, file_priv); 261 + 262 + drm_gem_object_handle_unreference_unlocked(obj); 263 + 264 + return 0; 243 265 } 244 266 245 267 /** ··· 305 277 idr_remove(&filp->object_idr, handle); 306 278 spin_unlock(&filp->table_lock); 307 279 308 - if (drm_core_check_feature(dev, DRIVER_PRIME)) 309 - drm_gem_remove_prime_handles(obj, filp); 310 - drm_vma_node_revoke(&obj->vma_node, filp->filp); 311 - 312 - if (dev->driver->gem_close_object) 313 - dev->driver->gem_close_object(obj, filp); 314 - drm_gem_object_handle_unreference_unlocked(obj); 315 - 280 + drm_gem_object_release_handle(handle, obj, filp); 316 281 return 0; 317 282 } 318 283 EXPORT_SYMBOL(drm_gem_handle_delete); ··· 347 326 u32 *handlep) 348 327 { 349 328 struct drm_device *dev = obj->dev; 329 + u32 handle; 350 330 int ret; 351 331 352 332 WARN_ON(!mutex_is_locked(&dev->object_name_lock)); 333 + if (obj->handle_count++ == 0) 334 + drm_gem_object_reference(obj); 353 335 354 336 /* 355 337 * Get the user-visible handle using idr. Preload and perform ··· 362 338 spin_lock(&file_priv->table_lock); 363 339 364 340 ret = idr_alloc(&file_priv->object_idr, obj, 1, 0, GFP_NOWAIT); 365 - drm_gem_object_reference(obj); 366 - obj->handle_count++; 341 + 367 342 spin_unlock(&file_priv->table_lock); 368 343 idr_preload_end(); 344 + 369 345 mutex_unlock(&dev->object_name_lock); 370 - if (ret < 0) { 371 - drm_gem_object_handle_unreference_unlocked(obj); 372 - return ret; 373 - } 374 - *handlep = ret; 346 + if (ret < 0) 347 + goto err_unref; 348 + 349 + handle = ret; 375 350 376 351 ret = drm_vma_node_allow(&obj->vma_node, file_priv->filp); 377 - if (ret) { 378 - drm_gem_handle_delete(file_priv, *handlep); 379 - return ret; 380 - } 352 + if (ret) 353 + goto err_remove; 381 354 382 355 if (dev->driver->gem_open_object) { 383 356 ret = dev->driver->gem_open_object(obj, file_priv); 384 - if (ret) { 385 - drm_gem_handle_delete(file_priv, *handlep); 386 - return ret; 387 - } 357 + if (ret) 358 + goto err_revoke; 388 359 } 389 360 361 + *handlep = handle; 390 362 return 0; 363 + 364 + err_revoke: 365 + drm_vma_node_revoke(&obj->vma_node, file_priv->filp); 366 + err_remove: 367 + spin_lock(&file_priv->table_lock); 368 + idr_remove(&file_priv->object_idr, handle); 369 + spin_unlock(&file_priv->table_lock); 370 + err_unref: 371 + drm_gem_object_handle_unreference_unlocked(obj); 372 + return ret; 391 373 } 392 374 393 375 /** ··· 660 630 return -ENOENT; 661 631 662 632 mutex_lock(&dev->object_name_lock); 663 - idr_preload(GFP_KERNEL); 664 633 /* prevent races with concurrent gem_close. */ 665 634 if (obj->handle_count == 0) { 666 635 ret = -ENOENT; ··· 667 638 } 668 639 669 640 if (!obj->name) { 670 - ret = idr_alloc(&dev->object_name_idr, obj, 1, 0, GFP_NOWAIT); 641 + ret = idr_alloc(&dev->object_name_idr, obj, 1, 0, GFP_KERNEL); 671 642 if (ret < 0) 672 643 goto err; 673 644 ··· 678 649 ret = 0; 679 650 680 651 err: 681 - idr_preload_end(); 682 652 mutex_unlock(&dev->object_name_lock); 683 653 drm_gem_object_unreference_unlocked(obj); 684 654 return ret; ··· 740 712 { 741 713 idr_init(&file_private->object_idr); 742 714 spin_lock_init(&file_private->table_lock); 743 - } 744 - 745 - /* 746 - * Called at device close to release the file's 747 - * handle references on objects. 748 - */ 749 - static int 750 - drm_gem_object_release_handle(int id, void *ptr, void *data) 751 - { 752 - struct drm_file *file_priv = data; 753 - struct drm_gem_object *obj = ptr; 754 - struct drm_device *dev = obj->dev; 755 - 756 - if (drm_core_check_feature(dev, DRIVER_PRIME)) 757 - drm_gem_remove_prime_handles(obj, file_priv); 758 - drm_vma_node_revoke(&obj->vma_node, file_priv->filp); 759 - 760 - if (dev->driver->gem_close_object) 761 - dev->driver->gem_close_object(obj, file_priv); 762 - 763 - drm_gem_object_handle_unreference_unlocked(obj); 764 - 765 - return 0; 766 715 } 767 716 768 717 /**
+3
drivers/gpu/drm/drm_irq.c
··· 73 73 module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600); 74 74 module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600); 75 75 module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600); 76 + MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately)"); 77 + MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]"); 78 + MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps"); 76 79 77 80 static void store_vblank(struct drm_device *dev, unsigned int pipe, 78 81 u32 vblank_count_inc,
+1 -1
drivers/gpu/drm/drm_sysfs.c
··· 240 240 struct bin_attribute *attr, char *buf, loff_t off, 241 241 size_t count) 242 242 { 243 - struct device *connector_dev = container_of(kobj, struct device, kobj); 243 + struct device *connector_dev = kobj_to_dev(kobj); 244 244 struct drm_connector *connector = to_drm_connector(connector_dev); 245 245 unsigned char *edid; 246 246 size_t size;
+2 -2
drivers/gpu/drm/gma500/power.c
··· 187 187 */ 188 188 int gma_power_suspend(struct device *_dev) 189 189 { 190 - struct pci_dev *pdev = container_of(_dev, struct pci_dev, dev); 190 + struct pci_dev *pdev = to_pci_dev(_dev); 191 191 struct drm_device *dev = pci_get_drvdata(pdev); 192 192 struct drm_psb_private *dev_priv = dev->dev_private; 193 193 ··· 214 214 */ 215 215 int gma_power_resume(struct device *_dev) 216 216 { 217 - struct pci_dev *pdev = container_of(_dev, struct pci_dev, dev); 217 + struct pci_dev *pdev = to_pci_dev(_dev); 218 218 struct drm_device *dev = pci_get_drvdata(pdev); 219 219 220 220 mutex_lock(&power_mutex);
-1
drivers/gpu/drm/i2c/tda998x_drv.c
··· 1446 1446 if (ret) 1447 1447 goto err_sysfs; 1448 1448 1449 - priv->connector.encoder = &priv->encoder; 1450 1449 drm_mode_connector_attach_encoder(&priv->connector, &priv->encoder); 1451 1450 1452 1451 return 0;
+3 -3
drivers/gpu/drm/i915/i915_dma.c
··· 406 406 if (ret) 407 407 goto cleanup_gem_stolen; 408 408 409 + intel_setup_gmbus(dev); 410 + 409 411 /* Important: The output setup functions called by modeset_init need 410 412 * working irqs for e.g. gmbus and dp aux transfers. */ 411 413 intel_modeset_init(dev); ··· 457 455 cleanup_irq: 458 456 intel_guc_ucode_fini(dev); 459 457 drm_irq_uninstall(dev); 458 + intel_teardown_gmbus(dev); 460 459 cleanup_gem_stolen: 461 460 i915_gem_cleanup_stolen(dev); 462 461 cleanup_vga_switcheroo: ··· 1031 1028 1032 1029 /* Try to make sure MCHBAR is enabled before poking at it */ 1033 1030 intel_setup_mchbar(dev); 1034 - intel_setup_gmbus(dev); 1035 1031 intel_opregion_setup(dev); 1036 1032 1037 1033 i915_gem_load(dev); ··· 1103 1101 if (dev->pdev->msi_enabled) 1104 1102 pci_disable_msi(dev->pdev); 1105 1103 1106 - intel_teardown_gmbus(dev); 1107 1104 intel_teardown_mchbar(dev); 1108 1105 pm_qos_remove_request(&dev_priv->pm_qos); 1109 1106 destroy_workqueue(dev_priv->gpu_error.hangcheck_wq); ··· 1204 1203 1205 1204 intel_csr_ucode_fini(dev_priv); 1206 1205 1207 - intel_teardown_gmbus(dev); 1208 1206 intel_teardown_mchbar(dev); 1209 1207 1210 1208 destroy_workqueue(dev_priv->hotplug.dp_wq);
+20 -5
drivers/gpu/drm/i915/intel_display.c
··· 6492 6492 6493 6493 int intel_connector_init(struct intel_connector *connector) 6494 6494 { 6495 - struct drm_connector_state *connector_state; 6495 + drm_atomic_helper_connector_reset(&connector->base); 6496 6496 6497 - connector_state = kzalloc(sizeof *connector_state, GFP_KERNEL); 6498 - if (!connector_state) 6497 + if (!connector->base.state) 6499 6498 return -ENOMEM; 6500 6499 6501 - connector->base.state = connector_state; 6502 6500 return 0; 6503 6501 } 6504 6502 ··· 15444 15446 WARN_ON(drm_atomic_set_mode_for_crtc(crtc->base.state, NULL) < 0); 15445 15447 crtc->base.state->active = crtc->active; 15446 15448 crtc->base.enabled = crtc->active; 15449 + crtc->base.state->connector_mask = 0; 15447 15450 15448 15451 /* Because we only establish the connector -> encoder -> 15449 15452 * crtc links if something is active, this means the ··· 15647 15648 for_each_intel_connector(dev, connector) { 15648 15649 if (connector->get_hw_state(connector)) { 15649 15650 connector->base.dpms = DRM_MODE_DPMS_ON; 15650 - connector->base.encoder = &connector->encoder->base; 15651 + 15652 + encoder = connector->encoder; 15653 + connector->base.encoder = &encoder->base; 15654 + 15655 + if (encoder->base.crtc && 15656 + encoder->base.crtc->state->active) { 15657 + /* 15658 + * This has to be done during hardware readout 15659 + * because anything calling .crtc_disable may 15660 + * rely on the connector_mask being accurate. 15661 + */ 15662 + encoder->base.crtc->state->connector_mask |= 15663 + 1 << drm_connector_index(&connector->base); 15664 + } 15665 + 15651 15666 } else { 15652 15667 connector->base.dpms = DRM_MODE_DPMS_OFF; 15653 15668 connector->base.encoder = NULL; ··· 15906 15893 mutex_lock(&dev->struct_mutex); 15907 15894 intel_cleanup_gt_powersave(dev); 15908 15895 mutex_unlock(&dev->struct_mutex); 15896 + 15897 + intel_teardown_gmbus(dev); 15909 15898 } 15910 15899 15911 15900 /*
+1 -1
drivers/gpu/drm/i915/intel_dp_mst.c
··· 534 534 drm_kms_helper_hotplug_event(dev); 535 535 } 536 536 537 - static struct drm_dp_mst_topology_cbs mst_cbs = { 537 + static const struct drm_dp_mst_topology_cbs mst_cbs = { 538 538 .add_connector = intel_dp_add_mst_connector, 539 539 .register_connector = intel_dp_register_mst_connector, 540 540 .destroy_connector = intel_dp_destroy_mst_connector,
+1
drivers/gpu/drm/imx/imx-drm-core.c
··· 305 305 dev_warn(drm->dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); 306 306 legacyfb_depth = 16; 307 307 } 308 + drm_helper_disable_unused_functions(drm); 308 309 imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth, 309 310 drm->mode_config.num_crtc, MAX_CRTC); 310 311 if (IS_ERR(imxdrm->fbhelper)) {
-2
drivers/gpu/drm/imx/parallel-display.c
··· 204 204 205 205 drm_mode_connector_attach_encoder(&imxpd->connector, &imxpd->encoder); 206 206 207 - imxpd->connector.encoder = &imxpd->encoder; 208 - 209 207 return 0; 210 208 } 211 209
+1 -1
drivers/gpu/drm/radeon/radeon_dp_mst.c
··· 329 329 drm_kms_helper_hotplug_event(dev); 330 330 } 331 331 332 - struct drm_dp_mst_topology_cbs mst_cbs = { 332 + const struct drm_dp_mst_topology_cbs mst_cbs = { 333 333 .add_connector = radeon_dp_add_mst_connector, 334 334 .register_connector = radeon_dp_register_mst_connector, 335 335 .destroy_connector = radeon_dp_destroy_mst_connector,
-2
drivers/gpu/drm/shmobile/shmob_drm_crtc.c
··· 739 739 if (ret < 0) 740 740 goto err_backlight; 741 741 742 - connector->encoder = encoder; 743 - 744 742 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 745 743 drm_object_property_set_value(&connector->base, 746 744 sdev->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
+1
drivers/gpu/drm/sti/sti_drv.c
··· 160 160 161 161 drm_mode_config_reset(dev); 162 162 163 + drm_helper_disable_unused_functions(dev); 163 164 drm_fbdev_cma_init(dev, 32, 164 165 dev->mode_config.num_crtc, 165 166 dev->mode_config.num_connector);
+6 -7
drivers/gpu/drm/tegra/dsi.c
··· 745 745 746 746 static void tegra_dsi_connector_reset(struct drm_connector *connector) 747 747 { 748 - struct tegra_dsi_state *state; 748 + struct tegra_dsi_state *state = 749 + kzalloc(sizeof(*state), GFP_KERNEL); 749 750 750 - kfree(connector->state); 751 - connector->state = NULL; 752 - 753 - state = kzalloc(sizeof(*state), GFP_KERNEL); 754 - if (state) 755 - connector->state = &state->base; 751 + if (state) { 752 + kfree(connector->state); 753 + __drm_atomic_helper_connector_reset(connector, &state->base); 754 + } 756 755 } 757 756 758 757 static struct drm_connector_state *
+1
drivers/gpu/drm/tilcdc/tilcdc_drv.c
··· 294 294 break; 295 295 } 296 296 297 + drm_helper_disable_unused_functions(dev); 297 298 priv->fbdev = drm_fbdev_cma_init(dev, bpp, 298 299 dev->mode_config.num_crtc, 299 300 dev->mode_config.num_connector);
+1 -1
drivers/gpu/drm/vc4/vc4_crtc.c
··· 328 328 /* The pixelvalve can only feed one encoder (and encoders are 329 329 * 1:1 with connectors.) 330 330 */ 331 - if (drm_atomic_connectors_for_crtc(state->state, crtc) > 1) 331 + if (hweight32(state->connector_mask) > 1) 332 332 return -EINVAL; 333 333 334 334 drm_atomic_crtc_state_for_each_plane(plane, state) {
+1 -1
drivers/gpu/vga/vga_switcheroo.c
··· 63 63 * for the inactive GPU.) Also, muxes are often used to cut power to the 64 64 * discrete GPU while it is not used. 65 65 * 66 - * DRM drivers register GPUs with vga_switcheroo, these are heretoforth called 66 + * DRM drivers register GPUs with vga_switcheroo, these are henceforth called 67 67 * clients. The mux is called the handler. Muxless machines also register a 68 68 * handler to control the power state of the discrete GPU, its ->switchto 69 69 * callback is a no-op for obvious reasons. The discrete GPU is often equipped
+113
drivers/platform/x86/apple-gmux.c
··· 3 3 * 4 4 * Copyright (C) Canonical Ltd. <seth.forshee@canonical.com> 5 5 * Copyright (C) 2010-2012 Andreas Heider <andreas@meetr.de> 6 + * Copyright (C) 2015 Lukas Wunner <lukas@wunner.de> 6 7 * 7 8 * This program is free software; you can redistribute it and/or modify 8 9 * it under the terms of the GNU General Public License version 2 as ··· 26 25 #include <linux/vgaarb.h> 27 26 #include <acpi/video.h> 28 27 #include <asm/io.h> 28 + 29 + /** 30 + * DOC: Overview 31 + * 32 + * :1: http://www.latticesemi.com/en/Products/FPGAandCPLD/LatticeXP2.aspx 33 + * :2: http://www.renesas.com/products/mpumcu/h8s/h8s2100/h8s2113/index.jsp 34 + * 35 + * gmux is a microcontroller built into the MacBook Pro to support dual GPUs: 36 + * A {1}[Lattice XP2] on pre-retinas, a {2}[Renesas R4F2113] on retinas. 37 + * 38 + * (The MacPro6,1 2013 also has a gmux, however it is unclear why since it has 39 + * dual GPUs but no built-in display.) 40 + * 41 + * gmux is connected to the LPC bus of the southbridge. Its I/O ports are 42 + * accessed differently depending on the microcontroller: Driver functions 43 + * to access a pre-retina gmux are infixed `_pio_`, those for a retina gmux 44 + * are infixed `_index_`. 45 + */ 29 46 30 47 struct apple_gmux_data { 31 48 unsigned long iostart; ··· 266 247 return false; 267 248 } 268 249 250 + /** 251 + * DOC: Backlight control 252 + * 253 + * :3: http://www.ti.com/lit/ds/symlink/lp8543.pdf 254 + * :4: http://www.ti.com/lit/ds/symlink/lp8545.pdf 255 + * 256 + * On single GPU MacBooks, the PWM signal for the backlight is generated by 257 + * the GPU. On dual GPU MacBook Pros by contrast, either GPU may be suspended 258 + * to conserve energy. Hence the PWM signal needs to be generated by a separate 259 + * backlight driver which is controlled by gmux. The earliest generation 260 + * MBP5 2008/09 uses a {3}[TI LP8543] backlight driver. All newer models 261 + * use a {4}[TI LP8545]. 262 + */ 263 + 269 264 static int gmux_get_brightness(struct backlight_device *bd) 270 265 { 271 266 struct apple_gmux_data *gmux_data = bl_get_data(bd); ··· 306 273 .update_status = gmux_update_status, 307 274 }; 308 275 276 + /** 277 + * DOC: Graphics mux 278 + * 279 + * :5: http://pimg-fpiw.uspto.gov/fdd/07/870/086/0.pdf 280 + * :6: http://www.nxp.com/documents/data_sheet/CBTL06141.pdf 281 + * :7: http://www.ti.com/lit/ds/symlink/hd3ss212.pdf 282 + * :8: https://www.pericom.com/assets/Datasheets/PI3VDP12412.pdf 283 + * :9: http://www.ti.com/lit/ds/symlink/sn74lv4066a.pdf 284 + * :10: http://pdf.datasheetarchive.com/indexerfiles/Datasheets-SW16/DSASW00308511.pdf 285 + * :11: http://www.ti.com/lit/ds/symlink/ts3ds10224.pdf 286 + * 287 + * On pre-retinas, the LVDS outputs of both GPUs feed into gmux which muxes 288 + * either of them to the panel. One of the tricks gmux has up its sleeve is 289 + * to lengthen the blanking interval of its output during a switch to 290 + * synchronize it with the GPU switched to. This allows for a flicker-free 291 + * switch that is imperceptible by the user ({5}[US 8,687,007 B2]). 292 + * 293 + * On retinas, muxing is no longer done by gmux itself, but by a separate 294 + * chip which is controlled by gmux. The chip is triple sourced, it is 295 + * either an {6}[NXP CBTL06142], {7}[TI HD3SS212] or {8}[Pericom PI3VDP12412]. 296 + * The panel is driven with eDP instead of LVDS since the pixel clock 297 + * required for retina resolution exceeds LVDS' limits. 298 + * 299 + * Pre-retinas are able to switch the panel's DDC pins separately. 300 + * This is handled by a {9}[TI SN74LV4066A] which is controlled by gmux. 301 + * The inactive GPU can thus probe the panel's EDID without switching over 302 + * the entire panel. Retinas lack this functionality as the chips used for 303 + * eDP muxing are incapable of switching the AUX channel separately (see 304 + * the linked data sheets, Pericom would be capable but this is unused). 305 + * However the retina panel has the NO_AUX_HANDSHAKE_LINK_TRAINING bit set 306 + * in its DPCD, allowing the inactive GPU to skip the AUX handshake and 307 + * set up the output with link parameters pre-calibrated by the active GPU. 308 + * 309 + * The external DP port is only fully switchable on the first two unibody 310 + * MacBook Pro generations, MBP5 2008/09 and MBP6 2010. This is done by an 311 + * {6}[NXP CBTL06141] which is controlled by gmux. It's the predecessor of the 312 + * eDP mux on retinas, the difference being support for 2.7 versus 5.4 Gbit/s. 313 + * 314 + * The following MacBook Pro generations replaced the external DP port with a 315 + * combined DP/Thunderbolt port and lost the ability to switch it between GPUs, 316 + * connecting it either to the discrete GPU or the Thunderbolt controller. 317 + * Oddly enough, while the full port is no longer switchable, AUX and HPD 318 + * are still switchable by way of an {10}[NXP CBTL03062] (on pre-retinas 319 + * MBP8 2011 and MBP9 2012) or two {11}[TI TS3DS10224] (on retinas) under the 320 + * control of gmux. Since the integrated GPU is missing the main link, 321 + * external displays appear to it as phantoms which fail to link-train. 322 + * 323 + * gmux receives the HPD signal of all display connectors and sends an 324 + * interrupt on hotplug. On generations which cannot switch external ports, 325 + * the discrete GPU can then be woken to drive the newly connected display. 326 + * The ability to switch AUX on these generations could be used to improve 327 + * reliability of hotplug detection by having the integrated GPU poll the 328 + * ports while the discrete GPU is asleep, but currently we do not make use 329 + * of this feature. 330 + * 331 + * gmux' initial switch state on bootup is user configurable via the EFI 332 + * variable `gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9` (5th byte, 333 + * 1 = IGD, 0 = DIS). Based on this setting, the EFI firmware tells gmux to 334 + * switch the panel and the external DP connector and allocates a framebuffer 335 + * for the selected GPU. 336 + */ 337 + 309 338 static int gmux_switchto(enum vga_switcheroo_client_id id) 310 339 { 311 340 if (id == VGA_SWITCHEROO_IGD) { ··· 382 287 383 288 return 0; 384 289 } 290 + 291 + /** 292 + * DOC: Power control 293 + * 294 + * gmux is able to cut power to the discrete GPU. It automatically takes care 295 + * of the correct sequence to tear down and bring up the power rails for 296 + * core voltage, VRAM and PCIe. 297 + */ 385 298 386 299 static int gmux_set_discrete_state(struct apple_gmux_data *gmux_data, 387 300 enum vga_switcheroo_state state) ··· 454 351 .power_state = gmux_set_power_state, 455 352 .get_client_id = gmux_get_client_id, 456 353 }; 354 + 355 + /** 356 + * DOC: Interrupt 357 + * 358 + * gmux is also connected to a GPIO pin of the southbridge and thereby is able 359 + * to trigger an ACPI GPE. On the MBP5 2008/09 it's GPIO pin 22 of the Nvidia 360 + * MCP79, on all following generations it's GPIO pin 6 of the Intel PCH. 361 + * The GPE merely signals that an interrupt occurred, the actual type of event 362 + * is identified by reading a gmux register. 363 + */ 457 364 458 365 static inline void gmux_disable_interrupts(struct apple_gmux_data *gmux_data) 459 366 {
-4
include/drm/drm_atomic.h
··· 130 130 drm_atomic_add_affected_planes(struct drm_atomic_state *state, 131 131 struct drm_crtc *crtc); 132 132 133 - int 134 - drm_atomic_connectors_for_crtc(struct drm_atomic_state *state, 135 - struct drm_crtc *crtc); 136 - 137 133 void drm_atomic_legacy_backoff(struct drm_atomic_state *state); 138 134 139 135 void
+2
include/drm/drm_atomic_helper.h
··· 126 126 void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane, 127 127 struct drm_plane_state *state); 128 128 129 + void __drm_atomic_helper_connector_reset(struct drm_connector *connector, 130 + struct drm_connector_state *conn_state); 129 131 void drm_atomic_helper_connector_reset(struct drm_connector *connector); 130 132 void 131 133 __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
+5 -1
include/drm/drm_crtc.h
··· 306 306 * @active_changed: crtc_state->active has been toggled. 307 307 * @connectors_changed: connectors to this crtc have been updated 308 308 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes 309 + * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors 309 310 * @last_vblank_count: for helpers and drivers to capture the vblank of the 310 311 * update to ensure framebuffer cleanup isn't done too early 311 312 * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings ··· 339 338 * on plane_mask being accurate! 340 339 */ 341 340 u32 plane_mask; 341 + 342 + u32 connector_mask; 342 343 343 344 /* last_vblank_count: for vblank waits before cleanup */ 344 345 u32 last_vblank_count; ··· 551 548 * ->page_flip() operation is already pending the callback should return 552 549 * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode 553 550 * or just runtime disabled through DPMS respectively the new atomic 554 - * "ACTIVE" state) should result in an -EINVAL error code. 551 + * "ACTIVE" state) should result in an -EINVAL error code. Note that 552 + * drm_atomic_helper_page_flip() checks this already for atomic drivers. 555 553 */ 556 554 int (*page_flip)(struct drm_crtc *crtc, 557 555 struct drm_framebuffer *fb,
+1 -1
include/drm/drm_dp_mst_helper.h
··· 421 421 struct drm_dp_mst_topology_mgr { 422 422 423 423 struct device *dev; 424 - struct drm_dp_mst_topology_cbs *cbs; 424 + const struct drm_dp_mst_topology_cbs *cbs; 425 425 int max_dpcd_transaction_bytes; 426 426 struct drm_dp_aux *aux; /* auxch for this topology mgr to use */ 427 427 int max_payloads;
+41 -3
include/drm/drm_modeset_helper_vtables.h
··· 131 131 * Atomic drivers which need to inspect and adjust more state should 132 132 * instead use the @atomic_check callback. 133 133 * 134 + * Also beware that neither core nor helpers filter modes before 135 + * passing them to the driver: While the list of modes that is 136 + * advertised to userspace is filtered using the connector's 137 + * ->mode_valid() callback, neither the core nor the helpers do any 138 + * filtering on modes passed in from userspace when setting a mode. It 139 + * is therefore possible for userspace to pass in a mode that was 140 + * previously filtered out using ->mode_valid() or add a custom mode 141 + * that wasn't probed from EDID or similar to begin with. Even though 142 + * this is an advanced feature and rarely used nowadays, some users rely 143 + * on being able to specify modes manually so drivers must be prepared 144 + * to deal with it. Specifically this means that all drivers need not 145 + * only validate modes in ->mode_valid() but also in ->mode_fixup() to 146 + * make sure invalid modes passed in from userspace are rejected. 147 + * 134 148 * RETURNS: 135 149 * 136 150 * True if an acceptable configuration is possible, false if the modeset ··· 202 188 * This callback is used by the legacy CRTC helpers to set a new 203 189 * framebuffer and scanout position. It is optional and used as an 204 190 * optimized fast-path instead of a full mode set operation with all the 205 - * resulting flickering. Since it can't update other planes it's 191 + * resulting flickering. If it is not present 192 + * drm_crtc_helper_set_config() will fall back to a full modeset, using 193 + * the ->mode_set() callback. Since it can't update other planes it's 206 194 * incompatible with atomic modeset support. 207 195 * 208 196 * This callback is only used by the CRTC helpers and deprecated. ··· 455 439 * Atomic drivers which need to inspect and adjust more state should 456 440 * instead use the @atomic_check callback. 457 441 * 442 + * Also beware that neither core nor helpers filter modes before 443 + * passing them to the driver: While the list of modes that is 444 + * advertised to userspace is filtered using the connector's 445 + * ->mode_valid() callback, neither the core nor the helpers do any 446 + * filtering on modes passed in from userspace when setting a mode. It 447 + * is therefore possible for userspace to pass in a mode that was 448 + * previously filtered out using ->mode_valid() or add a custom mode 449 + * that wasn't probed from EDID or similar to begin with. Even though 450 + * this is an advanced feature and rarely used nowadays, some users rely 451 + * on being able to specify modes manually so drivers must be prepared 452 + * to deal with it. Specifically this means that all drivers need not 453 + * only validate modes in ->mode_valid() but also in ->mode_fixup() to 454 + * make sure invalid modes passed in from userspace are rejected. 455 + * 458 456 * RETURNS: 459 457 * 460 458 * True if an acceptable configuration is possible, false if the modeset ··· 670 640 * In this function drivers then parse the modes in the EDID and add 671 641 * them by calling drm_add_edid_modes(). But connectors that driver a 672 642 * fixed panel can also manually add specific modes using 673 - * drm_mode_probed_add(). Finally drivers that support audio probably 674 - * want to update the ELD data, too, using drm_edid_to_eld(). 643 + * drm_mode_probed_add(). Drivers which manually add modes should also 644 + * make sure that the @display_info, @width_mm and @height_mm fields of the 645 + * struct #drm_connector are filled in. 646 + * 647 + * Virtual drivers that just want some standard VESA mode with a given 648 + * resolution can call drm_add_modes_noedid(), and mark the preferred 649 + * one using drm_set_preferred_mode(). 650 + * 651 + * Finally drivers that support audio probably want to update the ELD 652 + * data, too, using drm_edid_to_eld(). 675 653 * 676 654 * This function is only called after the ->detect() hook has indicated 677 655 * that a sink is connected and when the EDID isn't overridden through