diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-20 12:13:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-20 12:13:18 -0500 |
commit | a703f42d6caa724236521a5a7dcf4ab637483b66 (patch) | |
tree | 05c42c319ba9db5dfbb9bc9eec33c0edd5bedbde | |
parent | 59ceeaaf355fa0fb16558ef7c24413c804932ada (diff) | |
parent | 4fbbed46dca83bcba3a0170205110a06c116a8e6 (diff) |
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Pull more drm fixes from Dave Airlie:
"Some more fixes trickled in:
A bunch of VC4 ones since it's a pretty new driver not much chance of
regressions, and it fixes GPU resets.
Also one atomic fix, one set of fixes for a common bug in TTM cleanup,
and one i915 hotplug fix"
* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
drm/nouveau: use post-decrement in error handling
drm/atomic: Allow for holes in connector state, v2.
drm/i915: Fix hpd live status bits for g4x
drm/vc4: Use runtime PM to power cycle the device when the GPU hangs.
drm/vc4: Enable runtime PM.
drm/vc4: Fix spurious GPU resets due to BO reuse.
drm/vc4: Drop error message on seqno wait timeouts.
drm/vc4: Fix -ERESTARTSYS error return from BO waits.
drm/vc4: Return an ERR_PTR from BO creation instead of NULL.
drm/vc4: Fix the clear color for the first tile rendered.
drm/vc4: Validate that WAIT_BO padding is cleared.
drm/radeon: use post-decrement in error handling
drm/amdgpu: use post-decrement in error handling
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_atomic.c | 44 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_atomic_helper.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 49 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_reg.h | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_bo.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_drv.h | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_gem.c | 65 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_irq.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_render_cl.c | 22 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_v3d.c | 48 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_validate.c | 4 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 8 |
16 files changed, 184 insertions, 124 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 6442a06d6fdc..1cbb16e15307 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -712,7 +712,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm) | |||
712 | 0, PAGE_SIZE, | 712 | 0, PAGE_SIZE, |
713 | PCI_DMA_BIDIRECTIONAL); | 713 | PCI_DMA_BIDIRECTIONAL); |
714 | if (pci_dma_mapping_error(adev->pdev, gtt->ttm.dma_address[i])) { | 714 | if (pci_dma_mapping_error(adev->pdev, gtt->ttm.dma_address[i])) { |
715 | while (--i) { | 715 | while (i--) { |
716 | pci_unmap_page(adev->pdev, gtt->ttm.dma_address[i], | 716 | pci_unmap_page(adev->pdev, gtt->ttm.dma_address[i], |
717 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | 717 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); |
718 | gtt->ttm.dma_address[i] = 0; | 718 | gtt->ttm.dma_address[i] = 0; |
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3f74193885f1..9a7b44616b55 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c | |||
@@ -65,8 +65,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) | |||
65 | */ | 65 | */ |
66 | state->allow_modeset = true; | 66 | state->allow_modeset = true; |
67 | 67 | ||
68 | state->num_connector = ACCESS_ONCE(dev->mode_config.num_connector); | ||
69 | |||
70 | state->crtcs = kcalloc(dev->mode_config.num_crtc, | 68 | state->crtcs = kcalloc(dev->mode_config.num_crtc, |
71 | sizeof(*state->crtcs), GFP_KERNEL); | 69 | sizeof(*state->crtcs), GFP_KERNEL); |
72 | if (!state->crtcs) | 70 | if (!state->crtcs) |
@@ -83,16 +81,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) | |||
83 | sizeof(*state->plane_states), GFP_KERNEL); | 81 | sizeof(*state->plane_states), GFP_KERNEL); |
84 | if (!state->plane_states) | 82 | if (!state->plane_states) |
85 | goto fail; | 83 | goto fail; |
86 | state->connectors = kcalloc(state->num_connector, | ||
87 | sizeof(*state->connectors), | ||
88 | GFP_KERNEL); | ||
89 | if (!state->connectors) | ||
90 | goto fail; | ||
91 | state->connector_states = kcalloc(state->num_connector, | ||
92 | sizeof(*state->connector_states), | ||
93 | GFP_KERNEL); | ||
94 | if (!state->connector_states) | ||
95 | goto fail; | ||
96 | 84 | ||
97 | state->dev = dev; | 85 | state->dev = dev; |
98 | 86 | ||
@@ -823,19 +811,27 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state, | |||
823 | 811 | ||
824 | index = drm_connector_index(connector); | 812 | index = drm_connector_index(connector); |
825 | 813 | ||
826 | /* | ||
827 | * Construction of atomic state updates can race with a connector | ||
828 | * hot-add which might overflow. In this case flip the table and just | ||
829 | * restart the entire ioctl - no one is fast enough to livelock a cpu | ||
830 | * with physical hotplug events anyway. | ||
831 | * | ||
832 | * Note that we only grab the indexes once we have the right lock to | ||
833 | * prevent hotplug/unplugging of connectors. So removal is no problem, | ||
834 | * at most the array is a bit too large. | ||
835 | */ | ||
836 | if (index >= state->num_connector) { | 814 | if (index >= state->num_connector) { |
837 | DRM_DEBUG_ATOMIC("Hot-added connector would overflow state array, restarting\n"); | 815 | struct drm_connector **c; |
838 | return ERR_PTR(-EAGAIN); | 816 | struct drm_connector_state **cs; |
817 | int alloc = max(index + 1, config->num_connector); | ||
818 | |||
819 | c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL); | ||
820 | if (!c) | ||
821 | return ERR_PTR(-ENOMEM); | ||
822 | |||
823 | state->connectors = c; | ||
824 | memset(&state->connectors[state->num_connector], 0, | ||
825 | sizeof(*state->connectors) * (alloc - state->num_connector)); | ||
826 | |||
827 | cs = krealloc(state->connector_states, alloc * sizeof(*state->connector_states), GFP_KERNEL); | ||
828 | if (!cs) | ||
829 | return ERR_PTR(-ENOMEM); | ||
830 | |||
831 | state->connector_states = cs; | ||
832 | memset(&state->connector_states[state->num_connector], 0, | ||
833 | sizeof(*state->connector_states) * (alloc - state->num_connector)); | ||
834 | state->num_connector = alloc; | ||
839 | } | 835 | } |
840 | 836 | ||
841 | if (state->connector_states[index]) | 837 | if (state->connector_states[index]) |
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 7c523060a076..4f2d3e161593 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c | |||
@@ -1493,7 +1493,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev, | |||
1493 | { | 1493 | { |
1494 | int i; | 1494 | int i; |
1495 | 1495 | ||
1496 | for (i = 0; i < dev->mode_config.num_connector; i++) { | 1496 | for (i = 0; i < state->num_connector; i++) { |
1497 | struct drm_connector *connector = state->connectors[i]; | 1497 | struct drm_connector *connector = state->connectors[i]; |
1498 | 1498 | ||
1499 | if (!connector) | 1499 | if (!connector) |
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d40bab29747e..f6191215b2cb 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -918,12 +918,19 @@ int drm_connector_init(struct drm_device *dev, | |||
918 | connector->base.properties = &connector->properties; | 918 | connector->base.properties = &connector->properties; |
919 | connector->dev = dev; | 919 | connector->dev = dev; |
920 | connector->funcs = funcs; | 920 | connector->funcs = funcs; |
921 | |||
922 | connector->connector_id = ida_simple_get(&config->connector_ida, 0, 0, GFP_KERNEL); | ||
923 | if (connector->connector_id < 0) { | ||
924 | ret = connector->connector_id; | ||
925 | goto out_put; | ||
926 | } | ||
927 | |||
921 | connector->connector_type = connector_type; | 928 | connector->connector_type = connector_type; |
922 | connector->connector_type_id = | 929 | connector->connector_type_id = |
923 | ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); | 930 | ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); |
924 | if (connector->connector_type_id < 0) { | 931 | if (connector->connector_type_id < 0) { |
925 | ret = connector->connector_type_id; | 932 | ret = connector->connector_type_id; |
926 | goto out_put; | 933 | goto out_put_id; |
927 | } | 934 | } |
928 | connector->name = | 935 | connector->name = |
929 | kasprintf(GFP_KERNEL, "%s-%d", | 936 | kasprintf(GFP_KERNEL, "%s-%d", |
@@ -931,7 +938,7 @@ int drm_connector_init(struct drm_device *dev, | |||
931 | connector->connector_type_id); | 938 | connector->connector_type_id); |
932 | if (!connector->name) { | 939 | if (!connector->name) { |
933 | ret = -ENOMEM; | 940 | ret = -ENOMEM; |
934 | goto out_put; | 941 | goto out_put_type_id; |
935 | } | 942 | } |
936 | 943 | ||
937 | INIT_LIST_HEAD(&connector->probed_modes); | 944 | INIT_LIST_HEAD(&connector->probed_modes); |
@@ -959,7 +966,12 @@ int drm_connector_init(struct drm_device *dev, | |||
959 | } | 966 | } |
960 | 967 | ||
961 | connector->debugfs_entry = NULL; | 968 | connector->debugfs_entry = NULL; |
962 | 969 | out_put_type_id: | |
970 | if (ret) | ||
971 | ida_remove(connector_ida, connector->connector_type_id); | ||
972 | out_put_id: | ||
973 | if (ret) | ||
974 | ida_remove(&config->connector_ida, connector->connector_id); | ||
963 | out_put: | 975 | out_put: |
964 | if (ret) | 976 | if (ret) |
965 | drm_mode_object_put(dev, &connector->base); | 977 | drm_mode_object_put(dev, &connector->base); |
@@ -996,6 +1008,9 @@ void drm_connector_cleanup(struct drm_connector *connector) | |||
996 | ida_remove(&drm_connector_enum_list[connector->connector_type].ida, | 1008 | ida_remove(&drm_connector_enum_list[connector->connector_type].ida, |
997 | connector->connector_type_id); | 1009 | connector->connector_type_id); |
998 | 1010 | ||
1011 | ida_remove(&dev->mode_config.connector_ida, | ||
1012 | connector->connector_id); | ||
1013 | |||
999 | kfree(connector->display_info.bus_formats); | 1014 | kfree(connector->display_info.bus_formats); |
1000 | drm_mode_object_put(dev, &connector->base); | 1015 | drm_mode_object_put(dev, &connector->base); |
1001 | kfree(connector->name); | 1016 | kfree(connector->name); |
@@ -1013,32 +1028,6 @@ void drm_connector_cleanup(struct drm_connector *connector) | |||
1013 | EXPORT_SYMBOL(drm_connector_cleanup); | 1028 | EXPORT_SYMBOL(drm_connector_cleanup); |
1014 | 1029 | ||
1015 | /** | 1030 | /** |
1016 | * drm_connector_index - find the index of a registered connector | ||
1017 | * @connector: connector to find index for | ||
1018 | * | ||
1019 | * Given a registered connector, return the index of that connector within a DRM | ||
1020 | * device's list of connectors. | ||
1021 | */ | ||
1022 | unsigned int drm_connector_index(struct drm_connector *connector) | ||
1023 | { | ||
1024 | unsigned int index = 0; | ||
1025 | struct drm_connector *tmp; | ||
1026 | struct drm_mode_config *config = &connector->dev->mode_config; | ||
1027 | |||
1028 | WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); | ||
1029 | |||
1030 | drm_for_each_connector(tmp, connector->dev) { | ||
1031 | if (tmp == connector) | ||
1032 | return index; | ||
1033 | |||
1034 | index++; | ||
1035 | } | ||
1036 | |||
1037 | BUG(); | ||
1038 | } | ||
1039 | EXPORT_SYMBOL(drm_connector_index); | ||
1040 | |||
1041 | /** | ||
1042 | * drm_connector_register - register a connector | 1031 | * drm_connector_register - register a connector |
1043 | * @connector: the connector to register | 1032 | * @connector: the connector to register |
1044 | * | 1033 | * |
@@ -5789,6 +5778,7 @@ void drm_mode_config_init(struct drm_device *dev) | |||
5789 | INIT_LIST_HEAD(&dev->mode_config.plane_list); | 5778 | INIT_LIST_HEAD(&dev->mode_config.plane_list); |
5790 | idr_init(&dev->mode_config.crtc_idr); | 5779 | idr_init(&dev->mode_config.crtc_idr); |
5791 | idr_init(&dev->mode_config.tile_idr); | 5780 | idr_init(&dev->mode_config.tile_idr); |
5781 | ida_init(&dev->mode_config.connector_ida); | ||
5792 | 5782 | ||
5793 | drm_modeset_lock_all(dev); | 5783 | drm_modeset_lock_all(dev); |
5794 | drm_mode_create_standard_properties(dev); | 5784 | drm_mode_create_standard_properties(dev); |
@@ -5869,6 +5859,7 @@ void drm_mode_config_cleanup(struct drm_device *dev) | |||
5869 | crtc->funcs->destroy(crtc); | 5859 | crtc->funcs->destroy(crtc); |
5870 | } | 5860 | } |
5871 | 5861 | ||
5862 | ida_destroy(&dev->mode_config.connector_ida); | ||
5872 | idr_destroy(&dev->mode_config.tile_idr); | 5863 | idr_destroy(&dev->mode_config.tile_idr); |
5873 | idr_destroy(&dev->mode_config.crtc_idr); | 5864 | idr_destroy(&dev->mode_config.crtc_idr); |
5874 | drm_modeset_lock_fini(&dev->mode_config.connection_mutex); | 5865 | drm_modeset_lock_fini(&dev->mode_config.connection_mutex); |
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index b9a564b76528..4897728713f6 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
@@ -3287,19 +3287,20 @@ enum skl_disp_power_wells { | |||
3287 | 3287 | ||
3288 | #define PORT_HOTPLUG_STAT _MMIO(dev_priv->info.display_mmio_offset + 0x61114) | 3288 | #define PORT_HOTPLUG_STAT _MMIO(dev_priv->info.display_mmio_offset + 0x61114) |
3289 | /* | 3289 | /* |
3290 | * HDMI/DP bits are gen4+ | 3290 | * HDMI/DP bits are g4x+ |
3291 | * | 3291 | * |
3292 | * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused. | 3292 | * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused. |
3293 | * Please check the detailed lore in the commit message for for experimental | 3293 | * Please check the detailed lore in the commit message for for experimental |
3294 | * evidence. | 3294 | * evidence. |
3295 | */ | 3295 | */ |
3296 | #define PORTD_HOTPLUG_LIVE_STATUS_G4X (1 << 29) | 3296 | /* Bspec says GM45 should match G4X/VLV/CHV, but reality disagrees */ |
3297 | #define PORTD_HOTPLUG_LIVE_STATUS_GM45 (1 << 29) | ||
3298 | #define PORTC_HOTPLUG_LIVE_STATUS_GM45 (1 << 28) | ||
3299 | #define PORTB_HOTPLUG_LIVE_STATUS_GM45 (1 << 27) | ||
3300 | /* G4X/VLV/CHV DP/HDMI bits again match Bspec */ | ||
3301 | #define PORTD_HOTPLUG_LIVE_STATUS_G4X (1 << 27) | ||
3297 | #define PORTC_HOTPLUG_LIVE_STATUS_G4X (1 << 28) | 3302 | #define PORTC_HOTPLUG_LIVE_STATUS_G4X (1 << 28) |
3298 | #define PORTB_HOTPLUG_LIVE_STATUS_G4X (1 << 27) | 3303 | #define PORTB_HOTPLUG_LIVE_STATUS_G4X (1 << 29) |
3299 | /* VLV DP/HDMI bits again match Bspec */ | ||
3300 | #define PORTD_HOTPLUG_LIVE_STATUS_VLV (1 << 27) | ||
3301 | #define PORTC_HOTPLUG_LIVE_STATUS_VLV (1 << 28) | ||
3302 | #define PORTB_HOTPLUG_LIVE_STATUS_VLV (1 << 29) | ||
3303 | #define PORTD_HOTPLUG_INT_STATUS (3 << 21) | 3304 | #define PORTD_HOTPLUG_INT_STATUS (3 << 21) |
3304 | #define PORTD_HOTPLUG_INT_LONG_PULSE (2 << 21) | 3305 | #define PORTD_HOTPLUG_INT_LONG_PULSE (2 << 21) |
3305 | #define PORTD_HOTPLUG_INT_SHORT_PULSE (1 << 21) | 3306 | #define PORTD_HOTPLUG_INT_SHORT_PULSE (1 << 21) |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 796e3d313cb9..1bbd67b046da 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -4493,20 +4493,20 @@ static bool g4x_digital_port_connected(struct drm_i915_private *dev_priv, | |||
4493 | return I915_READ(PORT_HOTPLUG_STAT) & bit; | 4493 | return I915_READ(PORT_HOTPLUG_STAT) & bit; |
4494 | } | 4494 | } |
4495 | 4495 | ||
4496 | static bool vlv_digital_port_connected(struct drm_i915_private *dev_priv, | 4496 | static bool gm45_digital_port_connected(struct drm_i915_private *dev_priv, |
4497 | struct intel_digital_port *port) | 4497 | struct intel_digital_port *port) |
4498 | { | 4498 | { |
4499 | u32 bit; | 4499 | u32 bit; |
4500 | 4500 | ||
4501 | switch (port->port) { | 4501 | switch (port->port) { |
4502 | case PORT_B: | 4502 | case PORT_B: |
4503 | bit = PORTB_HOTPLUG_LIVE_STATUS_VLV; | 4503 | bit = PORTB_HOTPLUG_LIVE_STATUS_GM45; |
4504 | break; | 4504 | break; |
4505 | case PORT_C: | 4505 | case PORT_C: |
4506 | bit = PORTC_HOTPLUG_LIVE_STATUS_VLV; | 4506 | bit = PORTC_HOTPLUG_LIVE_STATUS_GM45; |
4507 | break; | 4507 | break; |
4508 | case PORT_D: | 4508 | case PORT_D: |
4509 | bit = PORTD_HOTPLUG_LIVE_STATUS_VLV; | 4509 | bit = PORTD_HOTPLUG_LIVE_STATUS_GM45; |
4510 | break; | 4510 | break; |
4511 | default: | 4511 | default: |
4512 | MISSING_CASE(port->port); | 4512 | MISSING_CASE(port->port); |
@@ -4558,8 +4558,8 @@ bool intel_digital_port_connected(struct drm_i915_private *dev_priv, | |||
4558 | return cpt_digital_port_connected(dev_priv, port); | 4558 | return cpt_digital_port_connected(dev_priv, port); |
4559 | else if (IS_BROXTON(dev_priv)) | 4559 | else if (IS_BROXTON(dev_priv)) |
4560 | return bxt_digital_port_connected(dev_priv, port); | 4560 | return bxt_digital_port_connected(dev_priv, port); |
4561 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) | 4561 | else if (IS_GM45(dev_priv)) |
4562 | return vlv_digital_port_connected(dev_priv, port); | 4562 | return gm45_digital_port_connected(dev_priv, port); |
4563 | else | 4563 | else |
4564 | return g4x_digital_port_connected(dev_priv, port); | 4564 | return g4x_digital_port_connected(dev_priv, port); |
4565 | } | 4565 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 78f520d05de9..e3acc35e3805 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -1520,7 +1520,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) | |||
1520 | DMA_BIDIRECTIONAL); | 1520 | DMA_BIDIRECTIONAL); |
1521 | 1521 | ||
1522 | if (dma_mapping_error(pdev, addr)) { | 1522 | if (dma_mapping_error(pdev, addr)) { |
1523 | while (--i) { | 1523 | while (i--) { |
1524 | dma_unmap_page(pdev, ttm_dma->dma_address[i], | 1524 | dma_unmap_page(pdev, ttm_dma->dma_address[i], |
1525 | PAGE_SIZE, DMA_BIDIRECTIONAL); | 1525 | PAGE_SIZE, DMA_BIDIRECTIONAL); |
1526 | ttm_dma->dma_address[i] = 0; | 1526 | ttm_dma->dma_address[i] = 0; |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index e34307459e50..e06ac546a90f 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -758,7 +758,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) | |||
758 | 0, PAGE_SIZE, | 758 | 0, PAGE_SIZE, |
759 | PCI_DMA_BIDIRECTIONAL); | 759 | PCI_DMA_BIDIRECTIONAL); |
760 | if (pci_dma_mapping_error(rdev->pdev, gtt->ttm.dma_address[i])) { | 760 | if (pci_dma_mapping_error(rdev->pdev, gtt->ttm.dma_address[i])) { |
761 | while (--i) { | 761 | while (i--) { |
762 | pci_unmap_page(rdev->pdev, gtt->ttm.dma_address[i], | 762 | pci_unmap_page(rdev->pdev, gtt->ttm.dma_address[i], |
763 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | 763 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); |
764 | gtt->ttm.dma_address[i] = 0; | 764 | gtt->ttm.dma_address[i] = 0; |
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 18dfe3ec9a62..22278bcfc60e 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c | |||
@@ -215,7 +215,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size, | |||
215 | struct drm_gem_cma_object *cma_obj; | 215 | struct drm_gem_cma_object *cma_obj; |
216 | 216 | ||
217 | if (size == 0) | 217 | if (size == 0) |
218 | return NULL; | 218 | return ERR_PTR(-EINVAL); |
219 | 219 | ||
220 | /* First, try to get a vc4_bo from the kernel BO cache. */ | 220 | /* First, try to get a vc4_bo from the kernel BO cache. */ |
221 | if (from_cache) { | 221 | if (from_cache) { |
@@ -237,7 +237,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size, | |||
237 | if (IS_ERR(cma_obj)) { | 237 | if (IS_ERR(cma_obj)) { |
238 | DRM_ERROR("Failed to allocate from CMA:\n"); | 238 | DRM_ERROR("Failed to allocate from CMA:\n"); |
239 | vc4_bo_stats_dump(vc4); | 239 | vc4_bo_stats_dump(vc4); |
240 | return NULL; | 240 | return ERR_PTR(-ENOMEM); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
@@ -259,8 +259,8 @@ int vc4_dumb_create(struct drm_file *file_priv, | |||
259 | args->size = args->pitch * args->height; | 259 | args->size = args->pitch * args->height; |
260 | 260 | ||
261 | bo = vc4_bo_create(dev, args->size, false); | 261 | bo = vc4_bo_create(dev, args->size, false); |
262 | if (!bo) | 262 | if (IS_ERR(bo)) |
263 | return -ENOMEM; | 263 | return PTR_ERR(bo); |
264 | 264 | ||
265 | ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle); | 265 | ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle); |
266 | drm_gem_object_unreference_unlocked(&bo->base.base); | 266 | drm_gem_object_unreference_unlocked(&bo->base.base); |
@@ -443,8 +443,8 @@ int vc4_create_bo_ioctl(struct drm_device *dev, void *data, | |||
443 | * get zeroed, and that might leak data between users. | 443 | * get zeroed, and that might leak data between users. |
444 | */ | 444 | */ |
445 | bo = vc4_bo_create(dev, args->size, false); | 445 | bo = vc4_bo_create(dev, args->size, false); |
446 | if (!bo) | 446 | if (IS_ERR(bo)) |
447 | return -ENOMEM; | 447 | return PTR_ERR(bo); |
448 | 448 | ||
449 | ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle); | 449 | ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle); |
450 | drm_gem_object_unreference_unlocked(&bo->base.base); | 450 | drm_gem_object_unreference_unlocked(&bo->base.base); |
@@ -496,8 +496,8 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data, | |||
496 | } | 496 | } |
497 | 497 | ||
498 | bo = vc4_bo_create(dev, args->size, true); | 498 | bo = vc4_bo_create(dev, args->size, true); |
499 | if (!bo) | 499 | if (IS_ERR(bo)) |
500 | return -ENOMEM; | 500 | return PTR_ERR(bo); |
501 | 501 | ||
502 | ret = copy_from_user(bo->base.vaddr, | 502 | ret = copy_from_user(bo->base.vaddr, |
503 | (void __user *)(uintptr_t)args->data, | 503 | (void __user *)(uintptr_t)args->data, |
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 080865ec2bae..51a63330d4f8 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h | |||
@@ -91,8 +91,12 @@ struct vc4_dev { | |||
91 | struct vc4_bo *overflow_mem; | 91 | struct vc4_bo *overflow_mem; |
92 | struct work_struct overflow_mem_work; | 92 | struct work_struct overflow_mem_work; |
93 | 93 | ||
94 | int power_refcount; | ||
95 | |||
96 | /* Mutex controlling the power refcount. */ | ||
97 | struct mutex power_lock; | ||
98 | |||
94 | struct { | 99 | struct { |
95 | uint32_t last_ct0ca, last_ct1ca; | ||
96 | struct timer_list timer; | 100 | struct timer_list timer; |
97 | struct work_struct reset_work; | 101 | struct work_struct reset_work; |
98 | } hangcheck; | 102 | } hangcheck; |
@@ -142,6 +146,7 @@ struct vc4_seqno_cb { | |||
142 | }; | 146 | }; |
143 | 147 | ||
144 | struct vc4_v3d { | 148 | struct vc4_v3d { |
149 | struct vc4_dev *vc4; | ||
145 | struct platform_device *pdev; | 150 | struct platform_device *pdev; |
146 | void __iomem *regs; | 151 | void __iomem *regs; |
147 | }; | 152 | }; |
@@ -192,6 +197,11 @@ struct vc4_exec_info { | |||
192 | /* Sequence number for this bin/render job. */ | 197 | /* Sequence number for this bin/render job. */ |
193 | uint64_t seqno; | 198 | uint64_t seqno; |
194 | 199 | ||
200 | /* Last current addresses the hardware was processing when the | ||
201 | * hangcheck timer checked on us. | ||
202 | */ | ||
203 | uint32_t last_ct0ca, last_ct1ca; | ||
204 | |||
195 | /* Kernel-space copy of the ioctl arguments */ | 205 | /* Kernel-space copy of the ioctl arguments */ |
196 | struct drm_vc4_submit_cl *args; | 206 | struct drm_vc4_submit_cl *args; |
197 | 207 | ||
@@ -434,7 +444,6 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, | |||
434 | extern struct platform_driver vc4_v3d_driver; | 444 | extern struct platform_driver vc4_v3d_driver; |
435 | int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused); | 445 | int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused); |
436 | int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused); | 446 | int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused); |
437 | int vc4_v3d_set_power(struct vc4_dev *vc4, bool on); | ||
438 | 447 | ||
439 | /* vc4_validate.c */ | 448 | /* vc4_validate.c */ |
440 | int | 449 | int |
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 48ce30a6f4b5..202aa1544acc 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/pm_runtime.h> | ||
26 | #include <linux/device.h> | 27 | #include <linux/device.h> |
27 | #include <linux/io.h> | 28 | #include <linux/io.h> |
28 | 29 | ||
@@ -228,8 +229,16 @@ vc4_reset(struct drm_device *dev) | |||
228 | struct vc4_dev *vc4 = to_vc4_dev(dev); | 229 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
229 | 230 | ||
230 | DRM_INFO("Resetting GPU.\n"); | 231 | DRM_INFO("Resetting GPU.\n"); |
231 | vc4_v3d_set_power(vc4, false); | 232 | |
232 | vc4_v3d_set_power(vc4, true); | 233 | mutex_lock(&vc4->power_lock); |
234 | if (vc4->power_refcount) { | ||
235 | /* Power the device off and back on the by dropping the | ||
236 | * reference on runtime PM. | ||
237 | */ | ||
238 | pm_runtime_put_sync_suspend(&vc4->v3d->pdev->dev); | ||
239 | pm_runtime_get_sync(&vc4->v3d->pdev->dev); | ||
240 | } | ||
241 | mutex_unlock(&vc4->power_lock); | ||
233 | 242 | ||
234 | vc4_irq_reset(dev); | 243 | vc4_irq_reset(dev); |
235 | 244 | ||
@@ -257,10 +266,17 @@ vc4_hangcheck_elapsed(unsigned long data) | |||
257 | struct drm_device *dev = (struct drm_device *)data; | 266 | struct drm_device *dev = (struct drm_device *)data; |
258 | struct vc4_dev *vc4 = to_vc4_dev(dev); | 267 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
259 | uint32_t ct0ca, ct1ca; | 268 | uint32_t ct0ca, ct1ca; |
269 | unsigned long irqflags; | ||
270 | struct vc4_exec_info *exec; | ||
271 | |||
272 | spin_lock_irqsave(&vc4->job_lock, irqflags); | ||
273 | exec = vc4_first_job(vc4); | ||
260 | 274 | ||
261 | /* If idle, we can stop watching for hangs. */ | 275 | /* If idle, we can stop watching for hangs. */ |
262 | if (list_empty(&vc4->job_list)) | 276 | if (!exec) { |
277 | spin_unlock_irqrestore(&vc4->job_lock, irqflags); | ||
263 | return; | 278 | return; |
279 | } | ||
264 | 280 | ||
265 | ct0ca = V3D_READ(V3D_CTNCA(0)); | 281 | ct0ca = V3D_READ(V3D_CTNCA(0)); |
266 | ct1ca = V3D_READ(V3D_CTNCA(1)); | 282 | ct1ca = V3D_READ(V3D_CTNCA(1)); |
@@ -268,14 +284,16 @@ vc4_hangcheck_elapsed(unsigned long data) | |||
268 | /* If we've made any progress in execution, rearm the timer | 284 | /* If we've made any progress in execution, rearm the timer |
269 | * and wait. | 285 | * and wait. |
270 | */ | 286 | */ |
271 | if (ct0ca != vc4->hangcheck.last_ct0ca || | 287 | if (ct0ca != exec->last_ct0ca || ct1ca != exec->last_ct1ca) { |
272 | ct1ca != vc4->hangcheck.last_ct1ca) { | 288 | exec->last_ct0ca = ct0ca; |
273 | vc4->hangcheck.last_ct0ca = ct0ca; | 289 | exec->last_ct1ca = ct1ca; |
274 | vc4->hangcheck.last_ct1ca = ct1ca; | 290 | spin_unlock_irqrestore(&vc4->job_lock, irqflags); |
275 | vc4_queue_hangcheck(dev); | 291 | vc4_queue_hangcheck(dev); |
276 | return; | 292 | return; |
277 | } | 293 | } |
278 | 294 | ||
295 | spin_unlock_irqrestore(&vc4->job_lock, irqflags); | ||
296 | |||
279 | /* We've gone too long with no progress, reset. This has to | 297 | /* We've gone too long with no progress, reset. This has to |
280 | * be done from a work struct, since resetting can sleep and | 298 | * be done from a work struct, since resetting can sleep and |
281 | * this timer hook isn't allowed to. | 299 | * this timer hook isn't allowed to. |
@@ -340,12 +358,7 @@ vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno, uint64_t timeout_ns, | |||
340 | finish_wait(&vc4->job_wait_queue, &wait); | 358 | finish_wait(&vc4->job_wait_queue, &wait); |
341 | trace_vc4_wait_for_seqno_end(dev, seqno); | 359 | trace_vc4_wait_for_seqno_end(dev, seqno); |
342 | 360 | ||
343 | if (ret && ret != -ERESTARTSYS) { | 361 | return ret; |
344 | DRM_ERROR("timeout waiting for render thread idle\n"); | ||
345 | return ret; | ||
346 | } | ||
347 | |||
348 | return 0; | ||
349 | } | 362 | } |
350 | 363 | ||
351 | static void | 364 | static void |
@@ -578,9 +591,9 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) | |||
578 | } | 591 | } |
579 | 592 | ||
580 | bo = vc4_bo_create(dev, exec_size, true); | 593 | bo = vc4_bo_create(dev, exec_size, true); |
581 | if (!bo) { | 594 | if (IS_ERR(bo)) { |
582 | DRM_ERROR("Couldn't allocate BO for binning\n"); | 595 | DRM_ERROR("Couldn't allocate BO for binning\n"); |
583 | ret = -ENOMEM; | 596 | ret = PTR_ERR(bo); |
584 | goto fail; | 597 | goto fail; |
585 | } | 598 | } |
586 | exec->exec_bo = &bo->base; | 599 | exec->exec_bo = &bo->base; |
@@ -617,6 +630,7 @@ fail: | |||
617 | static void | 630 | static void |
618 | vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) | 631 | vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) |
619 | { | 632 | { |
633 | struct vc4_dev *vc4 = to_vc4_dev(dev); | ||
620 | unsigned i; | 634 | unsigned i; |
621 | 635 | ||
622 | /* Need the struct lock for drm_gem_object_unreference(). */ | 636 | /* Need the struct lock for drm_gem_object_unreference(). */ |
@@ -635,6 +649,11 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) | |||
635 | } | 649 | } |
636 | mutex_unlock(&dev->struct_mutex); | 650 | mutex_unlock(&dev->struct_mutex); |
637 | 651 | ||
652 | mutex_lock(&vc4->power_lock); | ||
653 | if (--vc4->power_refcount == 0) | ||
654 | pm_runtime_put(&vc4->v3d->pdev->dev); | ||
655 | mutex_unlock(&vc4->power_lock); | ||
656 | |||
638 | kfree(exec); | 657 | kfree(exec); |
639 | } | 658 | } |
640 | 659 | ||
@@ -746,6 +765,9 @@ vc4_wait_bo_ioctl(struct drm_device *dev, void *data, | |||
746 | struct drm_gem_object *gem_obj; | 765 | struct drm_gem_object *gem_obj; |
747 | struct vc4_bo *bo; | 766 | struct vc4_bo *bo; |
748 | 767 | ||
768 | if (args->pad != 0) | ||
769 | return -EINVAL; | ||
770 | |||
749 | gem_obj = drm_gem_object_lookup(dev, file_priv, args->handle); | 771 | gem_obj = drm_gem_object_lookup(dev, file_priv, args->handle); |
750 | if (!gem_obj) { | 772 | if (!gem_obj) { |
751 | DRM_ERROR("Failed to look up GEM BO %d\n", args->handle); | 773 | DRM_ERROR("Failed to look up GEM BO %d\n", args->handle); |
@@ -772,7 +794,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, | |||
772 | struct vc4_dev *vc4 = to_vc4_dev(dev); | 794 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
773 | struct drm_vc4_submit_cl *args = data; | 795 | struct drm_vc4_submit_cl *args = data; |
774 | struct vc4_exec_info *exec; | 796 | struct vc4_exec_info *exec; |
775 | int ret; | 797 | int ret = 0; |
776 | 798 | ||
777 | if ((args->flags & ~VC4_SUBMIT_CL_USE_CLEAR_COLOR) != 0) { | 799 | if ((args->flags & ~VC4_SUBMIT_CL_USE_CLEAR_COLOR) != 0) { |
778 | DRM_ERROR("Unknown flags: 0x%02x\n", args->flags); | 800 | DRM_ERROR("Unknown flags: 0x%02x\n", args->flags); |
@@ -785,6 +807,15 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, | |||
785 | return -ENOMEM; | 807 | return -ENOMEM; |
786 | } | 808 | } |
787 | 809 | ||
810 | mutex_lock(&vc4->power_lock); | ||
811 | if (vc4->power_refcount++ == 0) | ||
812 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); | ||
813 | mutex_unlock(&vc4->power_lock); | ||
814 | if (ret < 0) { | ||
815 | kfree(exec); | ||
816 | return ret; | ||
817 | } | ||
818 | |||
788 | exec->args = args; | 819 | exec->args = args; |
789 | INIT_LIST_HEAD(&exec->unref_list); | 820 | INIT_LIST_HEAD(&exec->unref_list); |
790 | 821 | ||
@@ -839,6 +870,8 @@ vc4_gem_init(struct drm_device *dev) | |||
839 | (unsigned long)dev); | 870 | (unsigned long)dev); |
840 | 871 | ||
841 | INIT_WORK(&vc4->job_done_work, vc4_job_done_work); | 872 | INIT_WORK(&vc4->job_done_work, vc4_job_done_work); |
873 | |||
874 | mutex_init(&vc4->power_lock); | ||
842 | } | 875 | } |
843 | 876 | ||
844 | void | 877 | void |
diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c index b68060e758db..78a21357fb2d 100644 --- a/drivers/gpu/drm/vc4/vc4_irq.c +++ b/drivers/gpu/drm/vc4/vc4_irq.c | |||
@@ -57,7 +57,7 @@ vc4_overflow_mem_work(struct work_struct *work) | |||
57 | struct vc4_bo *bo; | 57 | struct vc4_bo *bo; |
58 | 58 | ||
59 | bo = vc4_bo_create(dev, 256 * 1024, true); | 59 | bo = vc4_bo_create(dev, 256 * 1024, true); |
60 | if (!bo) { | 60 | if (IS_ERR(bo)) { |
61 | DRM_ERROR("Couldn't allocate binner overflow mem\n"); | 61 | DRM_ERROR("Couldn't allocate binner overflow mem\n"); |
62 | return; | 62 | return; |
63 | } | 63 | } |
diff --git a/drivers/gpu/drm/vc4/vc4_render_cl.c b/drivers/gpu/drm/vc4/vc4_render_cl.c index 8a2a312e2c1b..0f12418725e5 100644 --- a/drivers/gpu/drm/vc4/vc4_render_cl.c +++ b/drivers/gpu/drm/vc4/vc4_render_cl.c | |||
@@ -316,20 +316,11 @@ static int vc4_create_rcl_bo(struct drm_device *dev, struct vc4_exec_info *exec, | |||
316 | size += xtiles * ytiles * loop_body_size; | 316 | size += xtiles * ytiles * loop_body_size; |
317 | 317 | ||
318 | setup->rcl = &vc4_bo_create(dev, size, true)->base; | 318 | setup->rcl = &vc4_bo_create(dev, size, true)->base; |
319 | if (!setup->rcl) | 319 | if (IS_ERR(setup->rcl)) |
320 | return -ENOMEM; | 320 | return PTR_ERR(setup->rcl); |
321 | list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head, | 321 | list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head, |
322 | &exec->unref_list); | 322 | &exec->unref_list); |
323 | 323 | ||
324 | rcl_u8(setup, VC4_PACKET_TILE_RENDERING_MODE_CONFIG); | ||
325 | rcl_u32(setup, | ||
326 | (setup->color_write ? (setup->color_write->paddr + | ||
327 | args->color_write.offset) : | ||
328 | 0)); | ||
329 | rcl_u16(setup, args->width); | ||
330 | rcl_u16(setup, args->height); | ||
331 | rcl_u16(setup, args->color_write.bits); | ||
332 | |||
333 | /* The tile buffer gets cleared when the previous tile is stored. If | 324 | /* The tile buffer gets cleared when the previous tile is stored. If |
334 | * the clear values changed between frames, then the tile buffer has | 325 | * the clear values changed between frames, then the tile buffer has |
335 | * stale clear values in it, so we have to do a store in None mode (no | 326 | * stale clear values in it, so we have to do a store in None mode (no |
@@ -349,6 +340,15 @@ static int vc4_create_rcl_bo(struct drm_device *dev, struct vc4_exec_info *exec, | |||
349 | rcl_u32(setup, 0); /* no address, since we're in None mode */ | 340 | rcl_u32(setup, 0); /* no address, since we're in None mode */ |
350 | } | 341 | } |
351 | 342 | ||
343 | rcl_u8(setup, VC4_PACKET_TILE_RENDERING_MODE_CONFIG); | ||
344 | rcl_u32(setup, | ||
345 | (setup->color_write ? (setup->color_write->paddr + | ||
346 | args->color_write.offset) : | ||
347 | 0)); | ||
348 | rcl_u16(setup, args->width); | ||
349 | rcl_u16(setup, args->height); | ||
350 | rcl_u16(setup, args->color_write.bits); | ||
351 | |||
352 | for (y = min_y_tile; y <= max_y_tile; y++) { | 352 | for (y = min_y_tile; y <= max_y_tile; y++) { |
353 | for (x = min_x_tile; x <= max_x_tile; x++) { | 353 | for (x = min_x_tile; x <= max_x_tile; x++) { |
354 | bool first = (x == min_x_tile && y == min_y_tile); | 354 | bool first = (x == min_x_tile && y == min_y_tile); |
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c index 314ff71db978..31de5d17bc85 100644 --- a/drivers/gpu/drm/vc4/vc4_v3d.c +++ b/drivers/gpu/drm/vc4/vc4_v3d.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "linux/component.h" | 19 | #include "linux/component.h" |
20 | #include "linux/pm_runtime.h" | ||
20 | #include "vc4_drv.h" | 21 | #include "vc4_drv.h" |
21 | #include "vc4_regs.h" | 22 | #include "vc4_regs.h" |
22 | 23 | ||
@@ -144,18 +145,6 @@ int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused) | |||
144 | } | 145 | } |
145 | #endif /* CONFIG_DEBUG_FS */ | 146 | #endif /* CONFIG_DEBUG_FS */ |
146 | 147 | ||
147 | int | ||
148 | vc4_v3d_set_power(struct vc4_dev *vc4, bool on) | ||
149 | { | ||
150 | /* XXX: This interface is needed for GPU reset, and the way to | ||
151 | * do it is to turn our power domain off and back on. We | ||
152 | * can't just reset from within the driver, because the reset | ||
153 | * bits are in the power domain's register area, and get set | ||
154 | * during the poweron process. | ||
155 | */ | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static void vc4_v3d_init_hw(struct drm_device *dev) | 148 | static void vc4_v3d_init_hw(struct drm_device *dev) |
160 | { | 149 | { |
161 | struct vc4_dev *vc4 = to_vc4_dev(dev); | 150 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
@@ -167,6 +156,29 @@ static void vc4_v3d_init_hw(struct drm_device *dev) | |||
167 | V3D_WRITE(V3D_VPMBASE, 0); | 156 | V3D_WRITE(V3D_VPMBASE, 0); |
168 | } | 157 | } |
169 | 158 | ||
159 | #ifdef CONFIG_PM | ||
160 | static int vc4_v3d_runtime_suspend(struct device *dev) | ||
161 | { | ||
162 | struct vc4_v3d *v3d = dev_get_drvdata(dev); | ||
163 | struct vc4_dev *vc4 = v3d->vc4; | ||
164 | |||
165 | vc4_irq_uninstall(vc4->dev); | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static int vc4_v3d_runtime_resume(struct device *dev) | ||
171 | { | ||
172 | struct vc4_v3d *v3d = dev_get_drvdata(dev); | ||
173 | struct vc4_dev *vc4 = v3d->vc4; | ||
174 | |||
175 | vc4_v3d_init_hw(vc4->dev); | ||
176 | vc4_irq_postinstall(vc4->dev); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | #endif | ||
181 | |||
170 | static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) | 182 | static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) |
171 | { | 183 | { |
172 | struct platform_device *pdev = to_platform_device(dev); | 184 | struct platform_device *pdev = to_platform_device(dev); |
@@ -179,6 +191,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) | |||
179 | if (!v3d) | 191 | if (!v3d) |
180 | return -ENOMEM; | 192 | return -ENOMEM; |
181 | 193 | ||
194 | dev_set_drvdata(dev, v3d); | ||
195 | |||
182 | v3d->pdev = pdev; | 196 | v3d->pdev = pdev; |
183 | 197 | ||
184 | v3d->regs = vc4_ioremap_regs(pdev, 0); | 198 | v3d->regs = vc4_ioremap_regs(pdev, 0); |
@@ -186,6 +200,7 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) | |||
186 | return PTR_ERR(v3d->regs); | 200 | return PTR_ERR(v3d->regs); |
187 | 201 | ||
188 | vc4->v3d = v3d; | 202 | vc4->v3d = v3d; |
203 | v3d->vc4 = vc4; | ||
189 | 204 | ||
190 | if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) { | 205 | if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) { |
191 | DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n", | 206 | DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n", |
@@ -207,6 +222,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) | |||
207 | return ret; | 222 | return ret; |
208 | } | 223 | } |
209 | 224 | ||
225 | pm_runtime_enable(dev); | ||
226 | |||
210 | return 0; | 227 | return 0; |
211 | } | 228 | } |
212 | 229 | ||
@@ -216,6 +233,8 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master, | |||
216 | struct drm_device *drm = dev_get_drvdata(master); | 233 | struct drm_device *drm = dev_get_drvdata(master); |
217 | struct vc4_dev *vc4 = to_vc4_dev(drm); | 234 | struct vc4_dev *vc4 = to_vc4_dev(drm); |
218 | 235 | ||
236 | pm_runtime_disable(dev); | ||
237 | |||
219 | drm_irq_uninstall(drm); | 238 | drm_irq_uninstall(drm); |
220 | 239 | ||
221 | /* Disable the binner's overflow memory address, so the next | 240 | /* Disable the binner's overflow memory address, so the next |
@@ -228,6 +247,10 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master, | |||
228 | vc4->v3d = NULL; | 247 | vc4->v3d = NULL; |
229 | } | 248 | } |
230 | 249 | ||
250 | static const struct dev_pm_ops vc4_v3d_pm_ops = { | ||
251 | SET_RUNTIME_PM_OPS(vc4_v3d_runtime_suspend, vc4_v3d_runtime_resume, NULL) | ||
252 | }; | ||
253 | |||
231 | static const struct component_ops vc4_v3d_ops = { | 254 | static const struct component_ops vc4_v3d_ops = { |
232 | .bind = vc4_v3d_bind, | 255 | .bind = vc4_v3d_bind, |
233 | .unbind = vc4_v3d_unbind, | 256 | .unbind = vc4_v3d_unbind, |
@@ -255,5 +278,6 @@ struct platform_driver vc4_v3d_driver = { | |||
255 | .driver = { | 278 | .driver = { |
256 | .name = "vc4_v3d", | 279 | .name = "vc4_v3d", |
257 | .of_match_table = vc4_v3d_dt_match, | 280 | .of_match_table = vc4_v3d_dt_match, |
281 | .pm = &vc4_v3d_pm_ops, | ||
258 | }, | 282 | }, |
259 | }; | 283 | }; |
diff --git a/drivers/gpu/drm/vc4/vc4_validate.c b/drivers/gpu/drm/vc4/vc4_validate.c index e26d9f6face3..24c2c746e8f3 100644 --- a/drivers/gpu/drm/vc4/vc4_validate.c +++ b/drivers/gpu/drm/vc4/vc4_validate.c | |||
@@ -401,8 +401,8 @@ validate_tile_binning_config(VALIDATE_ARGS) | |||
401 | tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size, | 401 | tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size, |
402 | true); | 402 | true); |
403 | exec->tile_bo = &tile_bo->base; | 403 | exec->tile_bo = &tile_bo->base; |
404 | if (!exec->tile_bo) | 404 | if (IS_ERR(exec->tile_bo)) |
405 | return -ENOMEM; | 405 | return PTR_ERR(exec->tile_bo); |
406 | list_add_tail(&tile_bo->unref_head, &exec->unref_list); | 406 | list_add_tail(&tile_bo->unref_head, &exec->unref_list); |
407 | 407 | ||
408 | /* tile alloc address. */ | 408 | /* tile alloc address. */ |
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index c65a212db77e..c5b4b81a831b 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -1166,6 +1166,7 @@ struct drm_connector { | |||
1166 | struct drm_mode_object base; | 1166 | struct drm_mode_object base; |
1167 | 1167 | ||
1168 | char *name; | 1168 | char *name; |
1169 | int connector_id; | ||
1169 | int connector_type; | 1170 | int connector_type; |
1170 | int connector_type_id; | 1171 | int connector_type_id; |
1171 | bool interlace_allowed; | 1172 | bool interlace_allowed; |
@@ -2047,6 +2048,7 @@ struct drm_mode_config { | |||
2047 | struct list_head fb_list; | 2048 | struct list_head fb_list; |
2048 | 2049 | ||
2049 | int num_connector; | 2050 | int num_connector; |
2051 | struct ida connector_ida; | ||
2050 | struct list_head connector_list; | 2052 | struct list_head connector_list; |
2051 | int num_encoder; | 2053 | int num_encoder; |
2052 | struct list_head encoder_list; | 2054 | struct list_head encoder_list; |
@@ -2200,7 +2202,11 @@ int drm_connector_register(struct drm_connector *connector); | |||
2200 | void drm_connector_unregister(struct drm_connector *connector); | 2202 | void drm_connector_unregister(struct drm_connector *connector); |
2201 | 2203 | ||
2202 | extern void drm_connector_cleanup(struct drm_connector *connector); | 2204 | extern void drm_connector_cleanup(struct drm_connector *connector); |
2203 | extern unsigned int drm_connector_index(struct drm_connector *connector); | 2205 | static inline unsigned drm_connector_index(struct drm_connector *connector) |
2206 | { | ||
2207 | return connector->connector_id; | ||
2208 | } | ||
2209 | |||
2204 | /* helper to unplug all connectors from sysfs for device */ | 2210 | /* helper to unplug all connectors from sysfs for device */ |
2205 | extern void drm_connector_unplug_all(struct drm_device *dev); | 2211 | extern void drm_connector_unplug_all(struct drm_device *dev); |
2206 | 2212 | ||