diff options
| author | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
| commit | bb799d3b980eb803ca2da4a4eefbd9308f8d988a (patch) | |
| tree | 69fbe0cd6d47b23a50f5e1d87bf7489532fae149 /drivers/gpu/drm | |
| parent | 919fc6e34831d1c2b58bfb5ae261dc3facc9b269 (diff) | |
| parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) | |
Merge tag 'v3.13-rc4' into core/locking
Merge Linux 3.13-rc4, to refresh this rather old tree with the latest fixes.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/gpu/drm')
95 files changed, 1836 insertions, 587 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index fb7cf0e796f6..0a1e4a5f4234 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c | |||
| @@ -2674,7 +2674,7 @@ static int add_3d_struct_modes(struct drm_connector *connector, u16 structure, | |||
| 2674 | int modes = 0; | 2674 | int modes = 0; |
| 2675 | u8 cea_mode; | 2675 | u8 cea_mode; |
| 2676 | 2676 | ||
| 2677 | if (video_db == NULL || video_index > video_len) | 2677 | if (video_db == NULL || video_index >= video_len) |
| 2678 | return 0; | 2678 | return 0; |
| 2679 | 2679 | ||
| 2680 | /* CEA modes are numbered 1..127 */ | 2680 | /* CEA modes are numbered 1..127 */ |
| @@ -2701,7 +2701,7 @@ static int add_3d_struct_modes(struct drm_connector *connector, u16 structure, | |||
| 2701 | if (structure & (1 << 8)) { | 2701 | if (structure & (1 << 8)) { |
| 2702 | newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); | 2702 | newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); |
| 2703 | if (newmode) { | 2703 | if (newmode) { |
| 2704 | newmode->flags = DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; | 2704 | newmode->flags |= DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; |
| 2705 | drm_mode_probed_add(connector, newmode); | 2705 | drm_mode_probed_add(connector, newmode); |
| 2706 | modes++; | 2706 | modes++; |
| 2707 | } | 2707 | } |
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 1a35ea53106b..c22c3097c3e8 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
| @@ -489,6 +489,11 @@ void drm_sysfs_hotplug_event(struct drm_device *dev) | |||
| 489 | } | 489 | } |
| 490 | EXPORT_SYMBOL(drm_sysfs_hotplug_event); | 490 | EXPORT_SYMBOL(drm_sysfs_hotplug_event); |
| 491 | 491 | ||
| 492 | static void drm_sysfs_release(struct device *dev) | ||
| 493 | { | ||
| 494 | kfree(dev); | ||
| 495 | } | ||
| 496 | |||
| 492 | /** | 497 | /** |
| 493 | * drm_sysfs_device_add - adds a class device to sysfs for a character driver | 498 | * drm_sysfs_device_add - adds a class device to sysfs for a character driver |
| 494 | * @dev: DRM device to be added | 499 | * @dev: DRM device to be added |
| @@ -501,6 +506,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event); | |||
| 501 | int drm_sysfs_device_add(struct drm_minor *minor) | 506 | int drm_sysfs_device_add(struct drm_minor *minor) |
| 502 | { | 507 | { |
| 503 | char *minor_str; | 508 | char *minor_str; |
| 509 | int r; | ||
| 504 | 510 | ||
| 505 | if (minor->type == DRM_MINOR_CONTROL) | 511 | if (minor->type == DRM_MINOR_CONTROL) |
| 506 | minor_str = "controlD%d"; | 512 | minor_str = "controlD%d"; |
| @@ -509,14 +515,34 @@ int drm_sysfs_device_add(struct drm_minor *minor) | |||
| 509 | else | 515 | else |
| 510 | minor_str = "card%d"; | 516 | minor_str = "card%d"; |
| 511 | 517 | ||
| 512 | minor->kdev = device_create(drm_class, minor->dev->dev, | 518 | minor->kdev = kzalloc(sizeof(*minor->kdev), GFP_KERNEL); |
| 513 | MKDEV(DRM_MAJOR, minor->index), | 519 | if (!minor->kdev) { |
| 514 | minor, minor_str, minor->index); | 520 | r = -ENOMEM; |
| 515 | if (IS_ERR(minor->kdev)) { | 521 | goto error; |
| 516 | DRM_ERROR("device create failed %ld\n", PTR_ERR(minor->kdev)); | ||
| 517 | return PTR_ERR(minor->kdev); | ||
| 518 | } | 522 | } |
| 523 | |||
| 524 | device_initialize(minor->kdev); | ||
| 525 | minor->kdev->devt = MKDEV(DRM_MAJOR, minor->index); | ||
| 526 | minor->kdev->class = drm_class; | ||
| 527 | minor->kdev->type = &drm_sysfs_device_minor; | ||
| 528 | minor->kdev->parent = minor->dev->dev; | ||
| 529 | minor->kdev->release = drm_sysfs_release; | ||
| 530 | dev_set_drvdata(minor->kdev, minor); | ||
| 531 | |||
| 532 | r = dev_set_name(minor->kdev, minor_str, minor->index); | ||
| 533 | if (r < 0) | ||
| 534 | goto error; | ||
| 535 | |||
| 536 | r = device_add(minor->kdev); | ||
| 537 | if (r < 0) | ||
| 538 | goto error; | ||
| 539 | |||
| 519 | return 0; | 540 | return 0; |
| 541 | |||
| 542 | error: | ||
| 543 | DRM_ERROR("device create failed %d\n", r); | ||
| 544 | put_device(minor->kdev); | ||
| 545 | return r; | ||
| 520 | } | 546 | } |
| 521 | 547 | ||
| 522 | /** | 548 | /** |
| @@ -529,7 +555,7 @@ int drm_sysfs_device_add(struct drm_minor *minor) | |||
| 529 | void drm_sysfs_device_remove(struct drm_minor *minor) | 555 | void drm_sysfs_device_remove(struct drm_minor *minor) |
| 530 | { | 556 | { |
| 531 | if (minor->kdev) | 557 | if (minor->kdev) |
| 532 | device_destroy(drm_class, MKDEV(DRM_MAJOR, minor->index)); | 558 | device_unregister(minor->kdev); |
| 533 | minor->kdev = NULL; | 559 | minor->kdev = NULL; |
| 534 | } | 560 | } |
| 535 | 561 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index b676006a95a0..22b8f5eced80 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c | |||
| @@ -173,28 +173,37 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) | |||
| 173 | static void exynos_drm_preclose(struct drm_device *dev, | 173 | static void exynos_drm_preclose(struct drm_device *dev, |
| 174 | struct drm_file *file) | 174 | struct drm_file *file) |
| 175 | { | 175 | { |
| 176 | exynos_drm_subdrv_close(dev, file); | ||
| 177 | } | ||
| 178 | |||
| 179 | static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file) | ||
| 180 | { | ||
| 176 | struct exynos_drm_private *private = dev->dev_private; | 181 | struct exynos_drm_private *private = dev->dev_private; |
| 177 | struct drm_pending_vblank_event *e, *t; | 182 | struct drm_pending_vblank_event *v, *vt; |
| 183 | struct drm_pending_event *e, *et; | ||
| 178 | unsigned long flags; | 184 | unsigned long flags; |
| 179 | 185 | ||
| 180 | /* release events of current file */ | 186 | if (!file->driver_priv) |
| 187 | return; | ||
| 188 | |||
| 189 | /* Release all events not unhandled by page flip handler. */ | ||
| 181 | spin_lock_irqsave(&dev->event_lock, flags); | 190 | spin_lock_irqsave(&dev->event_lock, flags); |
| 182 | list_for_each_entry_safe(e, t, &private->pageflip_event_list, | 191 | list_for_each_entry_safe(v, vt, &private->pageflip_event_list, |
| 183 | base.link) { | 192 | base.link) { |
| 184 | if (e->base.file_priv == file) { | 193 | if (v->base.file_priv == file) { |
| 185 | list_del(&e->base.link); | 194 | list_del(&v->base.link); |
| 186 | e->base.destroy(&e->base); | 195 | drm_vblank_put(dev, v->pipe); |
| 196 | v->base.destroy(&v->base); | ||
| 187 | } | 197 | } |
| 188 | } | 198 | } |
| 189 | spin_unlock_irqrestore(&dev->event_lock, flags); | ||
| 190 | 199 | ||
| 191 | exynos_drm_subdrv_close(dev, file); | 200 | /* Release all events handled by page flip handler but not freed. */ |
| 192 | } | 201 | list_for_each_entry_safe(e, et, &file->event_list, link) { |
| 202 | list_del(&e->link); | ||
| 203 | e->destroy(e); | ||
| 204 | } | ||
| 205 | spin_unlock_irqrestore(&dev->event_lock, flags); | ||
| 193 | 206 | ||
| 194 | static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file) | ||
| 195 | { | ||
| 196 | if (!file->driver_priv) | ||
| 197 | return; | ||
| 198 | 207 | ||
| 199 | kfree(file->driver_priv); | 208 | kfree(file->driver_priv); |
| 200 | file->driver_priv = NULL; | 209 | file->driver_priv = NULL; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 23da72b5eae9..a61878bf5dcd 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #include "exynos_drm_iommu.h" | 31 | #include "exynos_drm_iommu.h" |
| 32 | 32 | ||
| 33 | /* | 33 | /* |
| 34 | * FIMD is stand for Fully Interactive Mobile Display and | 34 | * FIMD stands for Fully Interactive Mobile Display and |
| 35 | * as a display controller, it transfers contents drawn on memory | 35 | * as a display controller, it transfers contents drawn on memory |
| 36 | * to a LCD Panel through Display Interfaces such as RGB or | 36 | * to a LCD Panel through Display Interfaces such as RGB or |
| 37 | * CPU Interface. | 37 | * CPU Interface. |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 3271fd4b1724..7bccedca487a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c | |||
| @@ -383,6 +383,8 @@ out: | |||
| 383 | g2d_userptr->npages, | 383 | g2d_userptr->npages, |
| 384 | g2d_userptr->vma); | 384 | g2d_userptr->vma); |
| 385 | 385 | ||
| 386 | exynos_gem_put_vma(g2d_userptr->vma); | ||
| 387 | |||
| 386 | if (!g2d_userptr->out_of_list) | 388 | if (!g2d_userptr->out_of_list) |
| 387 | list_del_init(&g2d_userptr->list); | 389 | list_del_init(&g2d_userptr->list); |
| 388 | 390 | ||
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 989be12cdd6e..2e367a1c6a64 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
| @@ -534,8 +534,10 @@ static int i915_drm_freeze(struct drm_device *dev) | |||
| 534 | * Disable CRTCs directly since we want to preserve sw state | 534 | * Disable CRTCs directly since we want to preserve sw state |
| 535 | * for _thaw. | 535 | * for _thaw. |
| 536 | */ | 536 | */ |
| 537 | mutex_lock(&dev->mode_config.mutex); | ||
| 537 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) | 538 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
| 538 | dev_priv->display.crtc_disable(crtc); | 539 | dev_priv->display.crtc_disable(crtc); |
| 540 | mutex_unlock(&dev->mode_config.mutex); | ||
| 539 | 541 | ||
| 540 | intel_modeset_suspend_hw(dev); | 542 | intel_modeset_suspend_hw(dev); |
| 541 | } | 543 | } |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 8600c315b4c4..ccdbecca070d 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -1816,6 +1816,7 @@ struct drm_i915_file_private { | |||
| 1816 | #define HAS_POWER_WELL(dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) | 1816 | #define HAS_POWER_WELL(dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
| 1817 | #define HAS_FPGA_DBG_UNCLAIMED(dev) (INTEL_INFO(dev)->has_fpga_dbg) | 1817 | #define HAS_FPGA_DBG_UNCLAIMED(dev) (INTEL_INFO(dev)->has_fpga_dbg) |
| 1818 | #define HAS_PSR(dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) | 1818 | #define HAS_PSR(dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
| 1819 | #define HAS_PC8(dev) (IS_HASWELL(dev)) /* XXX HSW:ULX */ | ||
| 1819 | 1820 | ||
| 1820 | #define INTEL_PCH_DEVICE_ID_MASK 0xff00 | 1821 | #define INTEL_PCH_DEVICE_ID_MASK 0xff00 |
| 1821 | #define INTEL_PCH_IBX_DEVICE_ID_TYPE 0x3b00 | 1822 | #define INTEL_PCH_IBX_DEVICE_ID_TYPE 0x3b00 |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 12bbd5eac70d..621c7c67a643 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
| @@ -4442,10 +4442,9 @@ i915_gem_init_hw(struct drm_device *dev) | |||
| 4442 | if (dev_priv->ellc_size) | 4442 | if (dev_priv->ellc_size) |
| 4443 | I915_WRITE(HSW_IDICR, I915_READ(HSW_IDICR) | IDIHASHMSK(0xf)); | 4443 | I915_WRITE(HSW_IDICR, I915_READ(HSW_IDICR) | IDIHASHMSK(0xf)); |
| 4444 | 4444 | ||
| 4445 | if (IS_HSW_GT3(dev)) | 4445 | if (IS_HASWELL(dev)) |
| 4446 | I915_WRITE(MI_PREDICATE_RESULT_2, LOWER_SLICE_ENABLED); | 4446 | I915_WRITE(MI_PREDICATE_RESULT_2, IS_HSW_GT3(dev) ? |
| 4447 | else | 4447 | LOWER_SLICE_ENABLED : LOWER_SLICE_DISABLED); |
| 4448 | I915_WRITE(MI_PREDICATE_RESULT_2, LOWER_SLICE_DISABLED); | ||
| 4449 | 4448 | ||
| 4450 | if (HAS_PCH_NOP(dev)) { | 4449 | if (HAS_PCH_NOP(dev)) { |
| 4451 | u32 temp = I915_READ(GEN7_MSG_CTL); | 4450 | u32 temp = I915_READ(GEN7_MSG_CTL); |
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c index 7d5752fda5f1..9bb533e0d762 100644 --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c | |||
| @@ -125,13 +125,15 @@ static void *i915_gem_dmabuf_vmap(struct dma_buf *dma_buf) | |||
| 125 | 125 | ||
| 126 | ret = i915_gem_object_get_pages(obj); | 126 | ret = i915_gem_object_get_pages(obj); |
| 127 | if (ret) | 127 | if (ret) |
| 128 | goto error; | 128 | goto err; |
| 129 | |||
| 130 | i915_gem_object_pin_pages(obj); | ||
| 129 | 131 | ||
| 130 | ret = -ENOMEM; | 132 | ret = -ENOMEM; |
| 131 | 133 | ||
| 132 | pages = drm_malloc_ab(obj->base.size >> PAGE_SHIFT, sizeof(*pages)); | 134 | pages = drm_malloc_ab(obj->base.size >> PAGE_SHIFT, sizeof(*pages)); |
| 133 | if (pages == NULL) | 135 | if (pages == NULL) |
| 134 | goto error; | 136 | goto err_unpin; |
| 135 | 137 | ||
| 136 | i = 0; | 138 | i = 0; |
| 137 | for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0) | 139 | for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0) |
| @@ -141,15 +143,16 @@ static void *i915_gem_dmabuf_vmap(struct dma_buf *dma_buf) | |||
| 141 | drm_free_large(pages); | 143 | drm_free_large(pages); |
| 142 | 144 | ||
| 143 | if (!obj->dma_buf_vmapping) | 145 | if (!obj->dma_buf_vmapping) |
| 144 | goto error; | 146 | goto err_unpin; |
| 145 | 147 | ||
| 146 | obj->vmapping_count = 1; | 148 | obj->vmapping_count = 1; |
| 147 | i915_gem_object_pin_pages(obj); | ||
| 148 | out_unlock: | 149 | out_unlock: |
| 149 | mutex_unlock(&dev->struct_mutex); | 150 | mutex_unlock(&dev->struct_mutex); |
| 150 | return obj->dma_buf_vmapping; | 151 | return obj->dma_buf_vmapping; |
| 151 | 152 | ||
| 152 | error: | 153 | err_unpin: |
| 154 | i915_gem_object_unpin_pages(obj); | ||
| 155 | err: | ||
| 153 | mutex_unlock(&dev->struct_mutex); | 156 | mutex_unlock(&dev->struct_mutex); |
| 154 | return ERR_PTR(ret); | 157 | return ERR_PTR(ret); |
| 155 | } | 158 | } |
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 885d595e0e02..b7e787fb4649 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
| @@ -33,6 +33,9 @@ | |||
| 33 | #include "intel_drv.h" | 33 | #include "intel_drv.h" |
| 34 | #include <linux/dma_remapping.h> | 34 | #include <linux/dma_remapping.h> |
| 35 | 35 | ||
| 36 | #define __EXEC_OBJECT_HAS_PIN (1<<31) | ||
| 37 | #define __EXEC_OBJECT_HAS_FENCE (1<<30) | ||
| 38 | |||
| 36 | struct eb_vmas { | 39 | struct eb_vmas { |
| 37 | struct list_head vmas; | 40 | struct list_head vmas; |
| 38 | int and; | 41 | int and; |
| @@ -187,7 +190,28 @@ static struct i915_vma *eb_get_vma(struct eb_vmas *eb, unsigned long handle) | |||
| 187 | } | 190 | } |
| 188 | } | 191 | } |
| 189 | 192 | ||
| 190 | static void eb_destroy(struct eb_vmas *eb) { | 193 | static void |
| 194 | i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma) | ||
| 195 | { | ||
| 196 | struct drm_i915_gem_exec_object2 *entry; | ||
| 197 | struct drm_i915_gem_object *obj = vma->obj; | ||
| 198 | |||
| 199 | if (!drm_mm_node_allocated(&vma->node)) | ||
| 200 | return; | ||
| 201 | |||
| 202 | entry = vma->exec_entry; | ||
| 203 | |||
| 204 | if (entry->flags & __EXEC_OBJECT_HAS_FENCE) | ||
| 205 | i915_gem_object_unpin_fence(obj); | ||
| 206 | |||
| 207 | if (entry->flags & __EXEC_OBJECT_HAS_PIN) | ||
| 208 | i915_gem_object_unpin(obj); | ||
| 209 | |||
| 210 | entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); | ||
| 211 | } | ||
| 212 | |||
| 213 | static void eb_destroy(struct eb_vmas *eb) | ||
| 214 | { | ||
| 191 | while (!list_empty(&eb->vmas)) { | 215 | while (!list_empty(&eb->vmas)) { |
| 192 | struct i915_vma *vma; | 216 | struct i915_vma *vma; |
| 193 | 217 | ||
| @@ -195,6 +219,7 @@ static void eb_destroy(struct eb_vmas *eb) { | |||
| 195 | struct i915_vma, | 219 | struct i915_vma, |
| 196 | exec_list); | 220 | exec_list); |
| 197 | list_del_init(&vma->exec_list); | 221 | list_del_init(&vma->exec_list); |
| 222 | i915_gem_execbuffer_unreserve_vma(vma); | ||
| 198 | drm_gem_object_unreference(&vma->obj->base); | 223 | drm_gem_object_unreference(&vma->obj->base); |
| 199 | } | 224 | } |
| 200 | kfree(eb); | 225 | kfree(eb); |
| @@ -478,9 +503,6 @@ i915_gem_execbuffer_relocate(struct eb_vmas *eb, | |||
| 478 | return ret; | 503 | return ret; |
| 479 | } | 504 | } |
| 480 | 505 | ||
| 481 | #define __EXEC_OBJECT_HAS_PIN (1<<31) | ||
| 482 | #define __EXEC_OBJECT_HAS_FENCE (1<<30) | ||
| 483 | |||
| 484 | static int | 506 | static int |
| 485 | need_reloc_mappable(struct i915_vma *vma) | 507 | need_reloc_mappable(struct i915_vma *vma) |
| 486 | { | 508 | { |
| @@ -552,26 +574,6 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma, | |||
| 552 | return 0; | 574 | return 0; |
| 553 | } | 575 | } |
| 554 | 576 | ||
| 555 | static void | ||
| 556 | i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma) | ||
| 557 | { | ||
| 558 | struct drm_i915_gem_exec_object2 *entry; | ||
| 559 | struct drm_i915_gem_object *obj = vma->obj; | ||
| 560 | |||
| 561 | if (!drm_mm_node_allocated(&vma->node)) | ||
| 562 | return; | ||
| 563 | |||
| 564 | entry = vma->exec_entry; | ||
| 565 | |||
| 566 | if (entry->flags & __EXEC_OBJECT_HAS_FENCE) | ||
| 567 | i915_gem_object_unpin_fence(obj); | ||
| 568 | |||
| 569 | if (entry->flags & __EXEC_OBJECT_HAS_PIN) | ||
| 570 | i915_gem_object_unpin(obj); | ||
| 571 | |||
| 572 | entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); | ||
| 573 | } | ||
| 574 | |||
| 575 | static int | 577 | static int |
| 576 | i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, | 578 | i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, |
| 577 | struct list_head *vmas, | 579 | struct list_head *vmas, |
| @@ -670,13 +672,14 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, | |||
| 670 | goto err; | 672 | goto err; |
| 671 | } | 673 | } |
| 672 | 674 | ||
| 673 | err: /* Decrement pin count for bound objects */ | 675 | err: |
| 674 | list_for_each_entry(vma, vmas, exec_list) | ||
| 675 | i915_gem_execbuffer_unreserve_vma(vma); | ||
| 676 | |||
| 677 | if (ret != -ENOSPC || retry++) | 676 | if (ret != -ENOSPC || retry++) |
| 678 | return ret; | 677 | return ret; |
| 679 | 678 | ||
| 679 | /* Decrement pin count for bound objects */ | ||
| 680 | list_for_each_entry(vma, vmas, exec_list) | ||
| 681 | i915_gem_execbuffer_unreserve_vma(vma); | ||
| 682 | |||
| 680 | ret = i915_gem_evict_vm(vm, true); | 683 | ret = i915_gem_evict_vm(vm, true); |
| 681 | if (ret) | 684 | if (ret) |
| 682 | return ret; | 685 | return ret; |
| @@ -708,6 +711,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, | |||
| 708 | while (!list_empty(&eb->vmas)) { | 711 | while (!list_empty(&eb->vmas)) { |
| 709 | vma = list_first_entry(&eb->vmas, struct i915_vma, exec_list); | 712 | vma = list_first_entry(&eb->vmas, struct i915_vma, exec_list); |
| 710 | list_del_init(&vma->exec_list); | 713 | list_del_init(&vma->exec_list); |
| 714 | i915_gem_execbuffer_unreserve_vma(vma); | ||
| 711 | drm_gem_object_unreference(&vma->obj->base); | 715 | drm_gem_object_unreference(&vma->obj->base); |
| 712 | } | 716 | } |
| 713 | 717 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 3620a1b0a73c..38cb8d44a013 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
| @@ -57,7 +57,9 @@ typedef gen8_gtt_pte_t gen8_ppgtt_pde_t; | |||
| 57 | #define HSW_WB_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x2) | 57 | #define HSW_WB_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x2) |
| 58 | #define HSW_WB_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x3) | 58 | #define HSW_WB_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x3) |
| 59 | #define HSW_WB_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0xb) | 59 | #define HSW_WB_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0xb) |
| 60 | #define HSW_WB_ELLC_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x8) | ||
| 60 | #define HSW_WT_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x6) | 61 | #define HSW_WT_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x6) |
| 62 | #define HSW_WT_ELLC_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x7) | ||
| 61 | 63 | ||
| 62 | #define GEN8_PTES_PER_PAGE (PAGE_SIZE / sizeof(gen8_gtt_pte_t)) | 64 | #define GEN8_PTES_PER_PAGE (PAGE_SIZE / sizeof(gen8_gtt_pte_t)) |
| 63 | #define GEN8_PDES_PER_PAGE (PAGE_SIZE / sizeof(gen8_ppgtt_pde_t)) | 65 | #define GEN8_PDES_PER_PAGE (PAGE_SIZE / sizeof(gen8_ppgtt_pde_t)) |
| @@ -185,10 +187,10 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr, | |||
| 185 | case I915_CACHE_NONE: | 187 | case I915_CACHE_NONE: |
| 186 | break; | 188 | break; |
| 187 | case I915_CACHE_WT: | 189 | case I915_CACHE_WT: |
| 188 | pte |= HSW_WT_ELLC_LLC_AGE0; | 190 | pte |= HSW_WT_ELLC_LLC_AGE3; |
| 189 | break; | 191 | break; |
| 190 | default: | 192 | default: |
| 191 | pte |= HSW_WB_ELLC_LLC_AGE0; | 193 | pte |= HSW_WB_ELLC_LLC_AGE3; |
| 192 | break; | 194 | break; |
| 193 | } | 195 | } |
| 194 | 196 | ||
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index f9eafb6ed523..ee2742122a02 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
| @@ -235,6 +235,7 @@ | |||
| 235 | */ | 235 | */ |
| 236 | #define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*x-1) | 236 | #define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*x-1) |
| 237 | #define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*x-1) | 237 | #define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*x-1) |
| 238 | #define MI_SRM_LRM_GLOBAL_GTT (1<<22) | ||
| 238 | #define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */ | 239 | #define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */ |
| 239 | #define MI_FLUSH_DW_STORE_INDEX (1<<21) | 240 | #define MI_FLUSH_DW_STORE_INDEX (1<<21) |
| 240 | #define MI_INVALIDATE_TLB (1<<18) | 241 | #define MI_INVALIDATE_TLB (1<<18) |
diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c index 43959edd4291..dfff0907f70e 100644 --- a/drivers/gpu/drm/i915/intel_acpi.c +++ b/drivers/gpu/drm/i915/intel_acpi.c | |||
| @@ -196,7 +196,7 @@ static bool intel_dsm_pci_probe(struct pci_dev *pdev) | |||
| 196 | acpi_handle dhandle; | 196 | acpi_handle dhandle; |
| 197 | int ret; | 197 | int ret; |
| 198 | 198 | ||
| 199 | dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); | 199 | dhandle = ACPI_HANDLE(&pdev->dev); |
| 200 | if (!dhandle) | 200 | if (!dhandle) |
| 201 | return false; | 201 | return false; |
| 202 | 202 | ||
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index 6dd622d733b9..e4fba39631a5 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c | |||
| @@ -790,7 +790,12 @@ init_vbt_defaults(struct drm_i915_private *dev_priv) | |||
| 790 | 790 | ||
| 791 | /* Default to using SSC */ | 791 | /* Default to using SSC */ |
| 792 | dev_priv->vbt.lvds_use_ssc = 1; | 792 | dev_priv->vbt.lvds_use_ssc = 1; |
| 793 | dev_priv->vbt.lvds_ssc_freq = intel_bios_ssc_frequency(dev, 1); | 793 | /* |
| 794 | * Core/SandyBridge/IvyBridge use alternative (120MHz) reference | ||
| 795 | * clock for LVDS. | ||
| 796 | */ | ||
| 797 | dev_priv->vbt.lvds_ssc_freq = intel_bios_ssc_frequency(dev, | ||
| 798 | !HAS_PCH_SPLIT(dev)); | ||
| 794 | DRM_DEBUG_KMS("Set default to SSC at %dMHz\n", dev_priv->vbt.lvds_ssc_freq); | 799 | DRM_DEBUG_KMS("Set default to SSC at %dMHz\n", dev_priv->vbt.lvds_ssc_freq); |
| 795 | 800 | ||
| 796 | for (port = PORT_A; port < I915_MAX_PORTS; port++) { | 801 | for (port = PORT_A; port < I915_MAX_PORTS; port++) { |
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index 1591576a6101..526c8ded16b0 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c | |||
| @@ -173,7 +173,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port) | |||
| 173 | ddi_translations = ddi_translations_dp; | 173 | ddi_translations = ddi_translations_dp; |
| 174 | break; | 174 | break; |
| 175 | case PORT_D: | 175 | case PORT_D: |
| 176 | if (intel_dpd_is_edp(dev)) | 176 | if (intel_dp_is_edp(dev, PORT_D)) |
| 177 | ddi_translations = ddi_translations_edp; | 177 | ddi_translations = ddi_translations_edp; |
| 178 | else | 178 | else |
| 179 | ddi_translations = ddi_translations_dp; | 179 | ddi_translations = ddi_translations_dp; |
| @@ -1158,9 +1158,10 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) | |||
| 1158 | if (wait) | 1158 | if (wait) |
| 1159 | intel_wait_ddi_buf_idle(dev_priv, port); | 1159 | intel_wait_ddi_buf_idle(dev_priv, port); |
| 1160 | 1160 | ||
| 1161 | if (type == INTEL_OUTPUT_EDP) { | 1161 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
| 1162 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); | 1162 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1163 | ironlake_edp_panel_vdd_on(intel_dp); | 1163 | ironlake_edp_panel_vdd_on(intel_dp); |
| 1164 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); | ||
| 1164 | ironlake_edp_panel_off(intel_dp); | 1165 | ironlake_edp_panel_off(intel_dp); |
| 1165 | } | 1166 | } |
| 1166 | 1167 | ||
| @@ -1406,6 +1407,26 @@ void intel_ddi_get_config(struct intel_encoder *encoder, | |||
| 1406 | default: | 1407 | default: |
| 1407 | break; | 1408 | break; |
| 1408 | } | 1409 | } |
| 1410 | |||
| 1411 | if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp_bpp && | ||
| 1412 | pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) { | ||
| 1413 | /* | ||
| 1414 | * This is a big fat ugly hack. | ||
| 1415 | * | ||
| 1416 | * Some machines in UEFI boot mode provide us a VBT that has 18 | ||
| 1417 | * bpp and 1.62 GHz link bandwidth for eDP, which for reasons | ||
| 1418 | * unknown we fail to light up. Yet the same BIOS boots up with | ||
| 1419 | * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as | ||
| 1420 | * max, not what it tells us to use. | ||
| 1421 | * | ||
| 1422 | * Note: This will still be broken if the eDP panel is not lit | ||
| 1423 | * up by the BIOS, and thus we can't get the mode at module | ||
| 1424 | * load. | ||
| 1425 | */ | ||
| 1426 | DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n", | ||
| 1427 | pipe_config->pipe_bpp, dev_priv->vbt.edp_bpp); | ||
| 1428 | dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp; | ||
| 1429 | } | ||
| 1409 | } | 1430 | } |
| 1410 | 1431 | ||
| 1411 | static void intel_ddi_destroy(struct drm_encoder *encoder) | 1432 | static void intel_ddi_destroy(struct drm_encoder *encoder) |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 3cddd508d110..080f6fd4e839 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
| @@ -5815,7 +5815,7 @@ static void intel_set_pipe_csc(struct drm_crtc *crtc) | |||
| 5815 | uint16_t postoff = 0; | 5815 | uint16_t postoff = 0; |
| 5816 | 5816 | ||
| 5817 | if (intel_crtc->config.limited_color_range) | 5817 | if (intel_crtc->config.limited_color_range) |
| 5818 | postoff = (16 * (1 << 13) / 255) & 0x1fff; | 5818 | postoff = (16 * (1 << 12) / 255) & 0x1fff; |
| 5819 | 5819 | ||
| 5820 | I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), postoff); | 5820 | I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), postoff); |
| 5821 | I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), postoff); | 5821 | I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), postoff); |
| @@ -6402,7 +6402,7 @@ static void hsw_restore_lcpll(struct drm_i915_private *dev_priv) | |||
| 6402 | 6402 | ||
| 6403 | /* Make sure we're not on PC8 state before disabling PC8, otherwise | 6403 | /* Make sure we're not on PC8 state before disabling PC8, otherwise |
| 6404 | * we'll hang the machine! */ | 6404 | * we'll hang the machine! */ |
| 6405 | dev_priv->uncore.funcs.force_wake_get(dev_priv); | 6405 | gen6_gt_force_wake_get(dev_priv); |
| 6406 | 6406 | ||
| 6407 | if (val & LCPLL_POWER_DOWN_ALLOW) { | 6407 | if (val & LCPLL_POWER_DOWN_ALLOW) { |
| 6408 | val &= ~LCPLL_POWER_DOWN_ALLOW; | 6408 | val &= ~LCPLL_POWER_DOWN_ALLOW; |
| @@ -6436,7 +6436,7 @@ static void hsw_restore_lcpll(struct drm_i915_private *dev_priv) | |||
| 6436 | DRM_ERROR("Switching back to LCPLL failed\n"); | 6436 | DRM_ERROR("Switching back to LCPLL failed\n"); |
| 6437 | } | 6437 | } |
| 6438 | 6438 | ||
| 6439 | dev_priv->uncore.funcs.force_wake_put(dev_priv); | 6439 | gen6_gt_force_wake_put(dev_priv); |
| 6440 | } | 6440 | } |
| 6441 | 6441 | ||
| 6442 | void hsw_enable_pc8_work(struct work_struct *__work) | 6442 | void hsw_enable_pc8_work(struct work_struct *__work) |
| @@ -6518,6 +6518,9 @@ static void __hsw_disable_package_c8(struct drm_i915_private *dev_priv) | |||
| 6518 | 6518 | ||
| 6519 | void hsw_enable_package_c8(struct drm_i915_private *dev_priv) | 6519 | void hsw_enable_package_c8(struct drm_i915_private *dev_priv) |
| 6520 | { | 6520 | { |
| 6521 | if (!HAS_PC8(dev_priv->dev)) | ||
| 6522 | return; | ||
| 6523 | |||
| 6521 | mutex_lock(&dev_priv->pc8.lock); | 6524 | mutex_lock(&dev_priv->pc8.lock); |
| 6522 | __hsw_enable_package_c8(dev_priv); | 6525 | __hsw_enable_package_c8(dev_priv); |
| 6523 | mutex_unlock(&dev_priv->pc8.lock); | 6526 | mutex_unlock(&dev_priv->pc8.lock); |
| @@ -6525,6 +6528,9 @@ void hsw_enable_package_c8(struct drm_i915_private *dev_priv) | |||
| 6525 | 6528 | ||
| 6526 | void hsw_disable_package_c8(struct drm_i915_private *dev_priv) | 6529 | void hsw_disable_package_c8(struct drm_i915_private *dev_priv) |
| 6527 | { | 6530 | { |
| 6531 | if (!HAS_PC8(dev_priv->dev)) | ||
| 6532 | return; | ||
| 6533 | |||
| 6528 | mutex_lock(&dev_priv->pc8.lock); | 6534 | mutex_lock(&dev_priv->pc8.lock); |
| 6529 | __hsw_disable_package_c8(dev_priv); | 6535 | __hsw_disable_package_c8(dev_priv); |
| 6530 | mutex_unlock(&dev_priv->pc8.lock); | 6536 | mutex_unlock(&dev_priv->pc8.lock); |
| @@ -6562,6 +6568,9 @@ static void hsw_update_package_c8(struct drm_device *dev) | |||
| 6562 | struct drm_i915_private *dev_priv = dev->dev_private; | 6568 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 6563 | bool allow; | 6569 | bool allow; |
| 6564 | 6570 | ||
| 6571 | if (!HAS_PC8(dev_priv->dev)) | ||
| 6572 | return; | ||
| 6573 | |||
| 6565 | if (!i915_enable_pc8) | 6574 | if (!i915_enable_pc8) |
| 6566 | return; | 6575 | return; |
| 6567 | 6576 | ||
| @@ -6585,18 +6594,28 @@ done: | |||
| 6585 | 6594 | ||
| 6586 | static void hsw_package_c8_gpu_idle(struct drm_i915_private *dev_priv) | 6595 | static void hsw_package_c8_gpu_idle(struct drm_i915_private *dev_priv) |
| 6587 | { | 6596 | { |
| 6597 | if (!HAS_PC8(dev_priv->dev)) | ||
| 6598 | return; | ||
| 6599 | |||
| 6600 | mutex_lock(&dev_priv->pc8.lock); | ||
| 6588 | if (!dev_priv->pc8.gpu_idle) { | 6601 | if (!dev_priv->pc8.gpu_idle) { |
| 6589 | dev_priv->pc8.gpu_idle = true; | 6602 | dev_priv->pc8.gpu_idle = true; |
| 6590 | hsw_enable_package_c8(dev_priv); | 6603 | __hsw_enable_package_c8(dev_priv); |
| 6591 | } | 6604 | } |
| 6605 | mutex_unlock(&dev_priv->pc8.lock); | ||
| 6592 | } | 6606 | } |
| 6593 | 6607 | ||
| 6594 | static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv) | 6608 | static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv) |
| 6595 | { | 6609 | { |
| 6610 | if (!HAS_PC8(dev_priv->dev)) | ||
| 6611 | return; | ||
| 6612 | |||
| 6613 | mutex_lock(&dev_priv->pc8.lock); | ||
| 6596 | if (dev_priv->pc8.gpu_idle) { | 6614 | if (dev_priv->pc8.gpu_idle) { |
| 6597 | dev_priv->pc8.gpu_idle = false; | 6615 | dev_priv->pc8.gpu_idle = false; |
| 6598 | hsw_disable_package_c8(dev_priv); | 6616 | __hsw_disable_package_c8(dev_priv); |
| 6599 | } | 6617 | } |
| 6618 | mutex_unlock(&dev_priv->pc8.lock); | ||
| 6600 | } | 6619 | } |
| 6601 | 6620 | ||
| 6602 | #define for_each_power_domain(domain, mask) \ | 6621 | #define for_each_power_domain(domain, mask) \ |
| @@ -7184,7 +7203,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) | |||
| 7184 | intel_crtc->cursor_visible = visible; | 7203 | intel_crtc->cursor_visible = visible; |
| 7185 | } | 7204 | } |
| 7186 | /* and commit changes on next vblank */ | 7205 | /* and commit changes on next vblank */ |
| 7206 | POSTING_READ(CURCNTR(pipe)); | ||
| 7187 | I915_WRITE(CURBASE(pipe), base); | 7207 | I915_WRITE(CURBASE(pipe), base); |
| 7208 | POSTING_READ(CURBASE(pipe)); | ||
| 7188 | } | 7209 | } |
| 7189 | 7210 | ||
| 7190 | static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) | 7211 | static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) |
| @@ -7213,7 +7234,9 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) | |||
| 7213 | intel_crtc->cursor_visible = visible; | 7234 | intel_crtc->cursor_visible = visible; |
| 7214 | } | 7235 | } |
| 7215 | /* and commit changes on next vblank */ | 7236 | /* and commit changes on next vblank */ |
| 7237 | POSTING_READ(CURCNTR_IVB(pipe)); | ||
| 7216 | I915_WRITE(CURBASE_IVB(pipe), base); | 7238 | I915_WRITE(CURBASE_IVB(pipe), base); |
| 7239 | POSTING_READ(CURBASE_IVB(pipe)); | ||
| 7217 | } | 7240 | } |
| 7218 | 7241 | ||
| 7219 | /* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ | 7242 | /* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ |
| @@ -8331,7 +8354,8 @@ static int intel_gen7_queue_flip(struct drm_device *dev, | |||
| 8331 | intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE | | 8354 | intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE | |
| 8332 | DERRMR_PIPEB_PRI_FLIP_DONE | | 8355 | DERRMR_PIPEB_PRI_FLIP_DONE | |
| 8333 | DERRMR_PIPEC_PRI_FLIP_DONE)); | 8356 | DERRMR_PIPEC_PRI_FLIP_DONE)); |
| 8334 | intel_ring_emit(ring, MI_STORE_REGISTER_MEM(1)); | 8357 | intel_ring_emit(ring, MI_STORE_REGISTER_MEM(1) | |
| 8358 | MI_SRM_LRM_GLOBAL_GTT); | ||
| 8335 | intel_ring_emit(ring, DERRMR); | 8359 | intel_ring_emit(ring, DERRMR); |
| 8336 | intel_ring_emit(ring, ring->scratch.gtt_offset + 256); | 8360 | intel_ring_emit(ring, ring->scratch.gtt_offset + 256); |
| 8337 | } | 8361 | } |
| @@ -9248,8 +9272,7 @@ check_crtc_state(struct drm_device *dev) | |||
| 9248 | enum pipe pipe; | 9272 | enum pipe pipe; |
| 9249 | if (encoder->base.crtc != &crtc->base) | 9273 | if (encoder->base.crtc != &crtc->base) |
| 9250 | continue; | 9274 | continue; |
| 9251 | if (encoder->get_config && | 9275 | if (encoder->get_hw_state(encoder, &pipe)) |
| 9252 | encoder->get_hw_state(encoder, &pipe)) | ||
| 9253 | encoder->get_config(encoder, &pipe_config); | 9276 | encoder->get_config(encoder, &pipe_config); |
| 9254 | } | 9277 | } |
| 9255 | 9278 | ||
| @@ -10027,7 +10050,7 @@ static void intel_setup_outputs(struct drm_device *dev) | |||
| 10027 | intel_ddi_init(dev, PORT_D); | 10050 | intel_ddi_init(dev, PORT_D); |
| 10028 | } else if (HAS_PCH_SPLIT(dev)) { | 10051 | } else if (HAS_PCH_SPLIT(dev)) { |
| 10029 | int found; | 10052 | int found; |
| 10030 | dpd_is_edp = intel_dpd_is_edp(dev); | 10053 | dpd_is_edp = intel_dp_is_edp(dev, PORT_D); |
| 10031 | 10054 | ||
| 10032 | if (has_edp_a(dev)) | 10055 | if (has_edp_a(dev)) |
| 10033 | intel_dp_init(dev, DP_A, PORT_A); | 10056 | intel_dp_init(dev, DP_A, PORT_A); |
| @@ -10064,8 +10087,7 @@ static void intel_setup_outputs(struct drm_device *dev) | |||
| 10064 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, | 10087 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, |
| 10065 | PORT_C); | 10088 | PORT_C); |
| 10066 | if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED) | 10089 | if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED) |
| 10067 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, | 10090 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C); |
| 10068 | PORT_C); | ||
| 10069 | } | 10091 | } |
| 10070 | 10092 | ||
| 10071 | intel_dsi_init(dev); | 10093 | intel_dsi_init(dev); |
| @@ -10909,8 +10931,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) | |||
| 10909 | if (encoder->get_hw_state(encoder, &pipe)) { | 10931 | if (encoder->get_hw_state(encoder, &pipe)) { |
| 10910 | crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); | 10932 | crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
| 10911 | encoder->base.crtc = &crtc->base; | 10933 | encoder->base.crtc = &crtc->base; |
| 10912 | if (encoder->get_config) | 10934 | encoder->get_config(encoder, &crtc->config); |
| 10913 | encoder->get_config(encoder, &crtc->config); | ||
| 10914 | } else { | 10935 | } else { |
| 10915 | encoder->base.crtc = NULL; | 10936 | encoder->base.crtc = NULL; |
| 10916 | } | 10937 | } |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index eb8139da9763..30c627c7b7ba 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
| @@ -1774,7 +1774,7 @@ static void intel_disable_dp(struct intel_encoder *encoder) | |||
| 1774 | * ensure that we have vdd while we switch off the panel. */ | 1774 | * ensure that we have vdd while we switch off the panel. */ |
| 1775 | ironlake_edp_panel_vdd_on(intel_dp); | 1775 | ironlake_edp_panel_vdd_on(intel_dp); |
| 1776 | ironlake_edp_backlight_off(intel_dp); | 1776 | ironlake_edp_backlight_off(intel_dp); |
| 1777 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); | 1777 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
| 1778 | ironlake_edp_panel_off(intel_dp); | 1778 | ironlake_edp_panel_off(intel_dp); |
| 1779 | 1779 | ||
| 1780 | /* cpu edp my only be disable _after_ the cpu pipe/plane is disabled. */ | 1780 | /* cpu edp my only be disable _after_ the cpu pipe/plane is disabled. */ |
| @@ -3326,11 +3326,19 @@ intel_trans_dp_port_sel(struct drm_crtc *crtc) | |||
| 3326 | } | 3326 | } |
| 3327 | 3327 | ||
| 3328 | /* check the VBT to see whether the eDP is on DP-D port */ | 3328 | /* check the VBT to see whether the eDP is on DP-D port */ |
| 3329 | bool intel_dpd_is_edp(struct drm_device *dev) | 3329 | bool intel_dp_is_edp(struct drm_device *dev, enum port port) |
| 3330 | { | 3330 | { |
| 3331 | struct drm_i915_private *dev_priv = dev->dev_private; | 3331 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3332 | union child_device_config *p_child; | 3332 | union child_device_config *p_child; |
| 3333 | int i; | 3333 | int i; |
| 3334 | static const short port_mapping[] = { | ||
| 3335 | [PORT_B] = PORT_IDPB, | ||
| 3336 | [PORT_C] = PORT_IDPC, | ||
| 3337 | [PORT_D] = PORT_IDPD, | ||
| 3338 | }; | ||
| 3339 | |||
| 3340 | if (port == PORT_A) | ||
| 3341 | return true; | ||
| 3334 | 3342 | ||
| 3335 | if (!dev_priv->vbt.child_dev_num) | 3343 | if (!dev_priv->vbt.child_dev_num) |
| 3336 | return false; | 3344 | return false; |
| @@ -3338,7 +3346,7 @@ bool intel_dpd_is_edp(struct drm_device *dev) | |||
| 3338 | for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { | 3346 | for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { |
| 3339 | p_child = dev_priv->vbt.child_dev + i; | 3347 | p_child = dev_priv->vbt.child_dev + i; |
| 3340 | 3348 | ||
| 3341 | if (p_child->common.dvo_port == PORT_IDPD && | 3349 | if (p_child->common.dvo_port == port_mapping[port] && |
| 3342 | (p_child->common.device_type & DEVICE_TYPE_eDP_BITS) == | 3350 | (p_child->common.device_type & DEVICE_TYPE_eDP_BITS) == |
| 3343 | (DEVICE_TYPE_eDP & DEVICE_TYPE_eDP_BITS)) | 3351 | (DEVICE_TYPE_eDP & DEVICE_TYPE_eDP_BITS)) |
| 3344 | return true; | 3352 | return true; |
| @@ -3616,26 +3624,10 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, | |||
| 3616 | intel_dp->DP = I915_READ(intel_dp->output_reg); | 3624 | intel_dp->DP = I915_READ(intel_dp->output_reg); |
| 3617 | intel_dp->attached_connector = intel_connector; | 3625 | intel_dp->attached_connector = intel_connector; |
| 3618 | 3626 | ||
| 3619 | type = DRM_MODE_CONNECTOR_DisplayPort; | 3627 | if (intel_dp_is_edp(dev, port)) |
| 3620 | /* | ||
| 3621 | * FIXME : We need to initialize built-in panels before external panels. | ||
| 3622 | * For X0, DP_C is fixed as eDP. Revisit this as part of VLV eDP cleanup | ||
| 3623 | */ | ||
| 3624 | switch (port) { | ||
| 3625 | case PORT_A: | ||
| 3626 | type = DRM_MODE_CONNECTOR_eDP; | 3628 | type = DRM_MODE_CONNECTOR_eDP; |
| 3627 | break; | 3629 | else |
| 3628 | case PORT_C: | 3630 | type = DRM_MODE_CONNECTOR_DisplayPort; |
| 3629 | if (IS_VALLEYVIEW(dev)) | ||
| 3630 | type = DRM_MODE_CONNECTOR_eDP; | ||
| 3631 | break; | ||
| 3632 | case PORT_D: | ||
| 3633 | if (HAS_PCH_SPLIT(dev) && intel_dpd_is_edp(dev)) | ||
| 3634 | type = DRM_MODE_CONNECTOR_eDP; | ||
| 3635 | break; | ||
| 3636 | default: /* silence GCC warning */ | ||
| 3637 | break; | ||
| 3638 | } | ||
| 3639 | 3631 | ||
| 3640 | /* | 3632 | /* |
| 3641 | * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but | 3633 | * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 1e49aa8f5377..a18e88b3e425 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
| @@ -708,7 +708,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder); | |||
| 708 | void intel_dp_check_link_status(struct intel_dp *intel_dp); | 708 | void intel_dp_check_link_status(struct intel_dp *intel_dp); |
| 709 | bool intel_dp_compute_config(struct intel_encoder *encoder, | 709 | bool intel_dp_compute_config(struct intel_encoder *encoder, |
| 710 | struct intel_crtc_config *pipe_config); | 710 | struct intel_crtc_config *pipe_config); |
| 711 | bool intel_dpd_is_edp(struct drm_device *dev); | 711 | bool intel_dp_is_edp(struct drm_device *dev, enum port port); |
| 712 | void ironlake_edp_backlight_on(struct intel_dp *intel_dp); | 712 | void ironlake_edp_backlight_on(struct intel_dp *intel_dp); |
| 713 | void ironlake_edp_backlight_off(struct intel_dp *intel_dp); | 713 | void ironlake_edp_backlight_off(struct intel_dp *intel_dp); |
| 714 | void ironlake_edp_panel_on(struct intel_dp *intel_dp); | 714 | void ironlake_edp_panel_on(struct intel_dp *intel_dp); |
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index 1b2f41c3f191..6d69a9bad865 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c | |||
| @@ -638,7 +638,7 @@ static void intel_didl_outputs(struct drm_device *dev) | |||
| 638 | u32 temp; | 638 | u32 temp; |
| 639 | int i = 0; | 639 | int i = 0; |
| 640 | 640 | ||
| 641 | handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev); | 641 | handle = ACPI_HANDLE(&dev->pdev->dev); |
| 642 | if (!handle || acpi_bus_get_device(handle, &acpi_dev)) | 642 | if (!handle || acpi_bus_get_device(handle, &acpi_dev)) |
| 643 | return; | 643 | return; |
| 644 | 644 | ||
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 0a07d7c9cafc..6e0d5e075b15 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
| @@ -1180,7 +1180,7 @@ static bool g4x_compute_wm0(struct drm_device *dev, | |||
| 1180 | 1180 | ||
| 1181 | adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; | 1181 | adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; |
| 1182 | clock = adjusted_mode->crtc_clock; | 1182 | clock = adjusted_mode->crtc_clock; |
| 1183 | htotal = adjusted_mode->htotal; | 1183 | htotal = adjusted_mode->crtc_htotal; |
| 1184 | hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; | 1184 | hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; |
| 1185 | pixel_size = crtc->fb->bits_per_pixel / 8; | 1185 | pixel_size = crtc->fb->bits_per_pixel / 8; |
| 1186 | 1186 | ||
| @@ -1267,7 +1267,7 @@ static bool g4x_compute_srwm(struct drm_device *dev, | |||
| 1267 | crtc = intel_get_crtc_for_plane(dev, plane); | 1267 | crtc = intel_get_crtc_for_plane(dev, plane); |
| 1268 | adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; | 1268 | adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; |
| 1269 | clock = adjusted_mode->crtc_clock; | 1269 | clock = adjusted_mode->crtc_clock; |
| 1270 | htotal = adjusted_mode->htotal; | 1270 | htotal = adjusted_mode->crtc_htotal; |
| 1271 | hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; | 1271 | hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; |
| 1272 | pixel_size = crtc->fb->bits_per_pixel / 8; | 1272 | pixel_size = crtc->fb->bits_per_pixel / 8; |
| 1273 | 1273 | ||
| @@ -1498,7 +1498,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc) | |||
| 1498 | const struct drm_display_mode *adjusted_mode = | 1498 | const struct drm_display_mode *adjusted_mode = |
| 1499 | &to_intel_crtc(crtc)->config.adjusted_mode; | 1499 | &to_intel_crtc(crtc)->config.adjusted_mode; |
| 1500 | int clock = adjusted_mode->crtc_clock; | 1500 | int clock = adjusted_mode->crtc_clock; |
| 1501 | int htotal = adjusted_mode->htotal; | 1501 | int htotal = adjusted_mode->crtc_htotal; |
| 1502 | int hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; | 1502 | int hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; |
| 1503 | int pixel_size = crtc->fb->bits_per_pixel / 8; | 1503 | int pixel_size = crtc->fb->bits_per_pixel / 8; |
| 1504 | unsigned long line_time_us; | 1504 | unsigned long line_time_us; |
| @@ -1624,8 +1624,8 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc) | |||
| 1624 | const struct drm_display_mode *adjusted_mode = | 1624 | const struct drm_display_mode *adjusted_mode = |
| 1625 | &to_intel_crtc(enabled)->config.adjusted_mode; | 1625 | &to_intel_crtc(enabled)->config.adjusted_mode; |
| 1626 | int clock = adjusted_mode->crtc_clock; | 1626 | int clock = adjusted_mode->crtc_clock; |
| 1627 | int htotal = adjusted_mode->htotal; | 1627 | int htotal = adjusted_mode->crtc_htotal; |
| 1628 | int hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; | 1628 | int hdisplay = to_intel_crtc(enabled)->config.pipe_src_w; |
| 1629 | int pixel_size = enabled->fb->bits_per_pixel / 8; | 1629 | int pixel_size = enabled->fb->bits_per_pixel / 8; |
| 1630 | unsigned long line_time_us; | 1630 | unsigned long line_time_us; |
| 1631 | int entries; | 1631 | int entries; |
| @@ -1776,7 +1776,7 @@ static bool ironlake_compute_srwm(struct drm_device *dev, int level, int plane, | |||
| 1776 | crtc = intel_get_crtc_for_plane(dev, plane); | 1776 | crtc = intel_get_crtc_for_plane(dev, plane); |
| 1777 | adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; | 1777 | adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; |
| 1778 | clock = adjusted_mode->crtc_clock; | 1778 | clock = adjusted_mode->crtc_clock; |
| 1779 | htotal = adjusted_mode->htotal; | 1779 | htotal = adjusted_mode->crtc_htotal; |
| 1780 | hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; | 1780 | hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; |
| 1781 | pixel_size = crtc->fb->bits_per_pixel / 8; | 1781 | pixel_size = crtc->fb->bits_per_pixel / 8; |
| 1782 | 1782 | ||
| @@ -2469,8 +2469,9 @@ hsw_compute_linetime_wm(struct drm_device *dev, struct drm_crtc *crtc) | |||
| 2469 | /* The WM are computed with base on how long it takes to fill a single | 2469 | /* The WM are computed with base on how long it takes to fill a single |
| 2470 | * row at the given clock rate, multiplied by 8. | 2470 | * row at the given clock rate, multiplied by 8. |
| 2471 | * */ | 2471 | * */ |
| 2472 | linetime = DIV_ROUND_CLOSEST(mode->htotal * 1000 * 8, mode->clock); | 2472 | linetime = DIV_ROUND_CLOSEST(mode->crtc_htotal * 1000 * 8, |
| 2473 | ips_linetime = DIV_ROUND_CLOSEST(mode->htotal * 1000 * 8, | 2473 | mode->crtc_clock); |
| 2474 | ips_linetime = DIV_ROUND_CLOSEST(mode->crtc_htotal * 1000 * 8, | ||
| 2474 | intel_ddi_get_cdclk_freq(dev_priv)); | 2475 | intel_ddi_get_cdclk_freq(dev_priv)); |
| 2475 | 2476 | ||
| 2476 | return PIPE_WM_LINETIME_IPS_LINETIME(ips_linetime) | | 2477 | return PIPE_WM_LINETIME_IPS_LINETIME(ips_linetime) | |
| @@ -3888,7 +3889,7 @@ static void gen6_enable_rps(struct drm_device *dev) | |||
| 3888 | 3889 | ||
| 3889 | I915_WRITE(GEN6_RC_SLEEP, 0); | 3890 | I915_WRITE(GEN6_RC_SLEEP, 0); |
| 3890 | I915_WRITE(GEN6_RC1e_THRESHOLD, 1000); | 3891 | I915_WRITE(GEN6_RC1e_THRESHOLD, 1000); |
| 3891 | if (INTEL_INFO(dev)->gen <= 6 || IS_IVYBRIDGE(dev)) | 3892 | if (IS_IVYBRIDGE(dev)) |
| 3892 | I915_WRITE(GEN6_RC6_THRESHOLD, 125000); | 3893 | I915_WRITE(GEN6_RC6_THRESHOLD, 125000); |
| 3893 | else | 3894 | else |
| 3894 | I915_WRITE(GEN6_RC6_THRESHOLD, 50000); | 3895 | I915_WRITE(GEN6_RC6_THRESHOLD, 50000); |
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c index 18c406246a2d..22cf0f4ba248 100644 --- a/drivers/gpu/drm/i915/intel_tv.c +++ b/drivers/gpu/drm/i915/intel_tv.c | |||
| @@ -902,6 +902,13 @@ intel_tv_mode_valid(struct drm_connector *connector, | |||
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | 904 | ||
| 905 | static void | ||
| 906 | intel_tv_get_config(struct intel_encoder *encoder, | ||
| 907 | struct intel_crtc_config *pipe_config) | ||
| 908 | { | ||
| 909 | pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock; | ||
| 910 | } | ||
| 911 | |||
| 905 | static bool | 912 | static bool |
| 906 | intel_tv_compute_config(struct intel_encoder *encoder, | 913 | intel_tv_compute_config(struct intel_encoder *encoder, |
| 907 | struct intel_crtc_config *pipe_config) | 914 | struct intel_crtc_config *pipe_config) |
| @@ -1621,6 +1628,7 @@ intel_tv_init(struct drm_device *dev) | |||
| 1621 | DRM_MODE_ENCODER_TVDAC); | 1628 | DRM_MODE_ENCODER_TVDAC); |
| 1622 | 1629 | ||
| 1623 | intel_encoder->compute_config = intel_tv_compute_config; | 1630 | intel_encoder->compute_config = intel_tv_compute_config; |
| 1631 | intel_encoder->get_config = intel_tv_get_config; | ||
| 1624 | intel_encoder->mode_set = intel_tv_mode_set; | 1632 | intel_encoder->mode_set = intel_tv_mode_set; |
| 1625 | intel_encoder->enable = intel_enable_tv; | 1633 | intel_encoder->enable = intel_enable_tv; |
| 1626 | intel_encoder->disable = intel_disable_tv; | 1634 | intel_encoder->disable = intel_disable_tv; |
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index f9883ceff946..0b02078a0b84 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c | |||
| @@ -217,6 +217,19 @@ static void gen6_force_wake_work(struct work_struct *work) | |||
| 217 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); | 217 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | static void intel_uncore_forcewake_reset(struct drm_device *dev) | ||
| 221 | { | ||
| 222 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
| 223 | |||
| 224 | if (IS_VALLEYVIEW(dev)) { | ||
| 225 | vlv_force_wake_reset(dev_priv); | ||
| 226 | } else if (INTEL_INFO(dev)->gen >= 6) { | ||
| 227 | __gen6_gt_force_wake_reset(dev_priv); | ||
| 228 | if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) | ||
| 229 | __gen6_gt_force_wake_mt_reset(dev_priv); | ||
| 230 | } | ||
| 231 | } | ||
| 232 | |||
| 220 | void intel_uncore_early_sanitize(struct drm_device *dev) | 233 | void intel_uncore_early_sanitize(struct drm_device *dev) |
| 221 | { | 234 | { |
| 222 | struct drm_i915_private *dev_priv = dev->dev_private; | 235 | struct drm_i915_private *dev_priv = dev->dev_private; |
| @@ -234,19 +247,8 @@ void intel_uncore_early_sanitize(struct drm_device *dev) | |||
| 234 | dev_priv->ellc_size = 128; | 247 | dev_priv->ellc_size = 128; |
| 235 | DRM_INFO("Found %zuMB of eLLC\n", dev_priv->ellc_size); | 248 | DRM_INFO("Found %zuMB of eLLC\n", dev_priv->ellc_size); |
| 236 | } | 249 | } |
| 237 | } | ||
| 238 | 250 | ||
| 239 | static void intel_uncore_forcewake_reset(struct drm_device *dev) | 251 | intel_uncore_forcewake_reset(dev); |
| 240 | { | ||
| 241 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
| 242 | |||
| 243 | if (IS_VALLEYVIEW(dev)) { | ||
| 244 | vlv_force_wake_reset(dev_priv); | ||
| 245 | } else if (INTEL_INFO(dev)->gen >= 6) { | ||
| 246 | __gen6_gt_force_wake_reset(dev_priv); | ||
| 247 | if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) | ||
| 248 | __gen6_gt_force_wake_mt_reset(dev_priv); | ||
| 249 | } | ||
| 250 | } | 252 | } |
| 251 | 253 | ||
| 252 | void intel_uncore_sanitize(struct drm_device *dev) | 254 | void intel_uncore_sanitize(struct drm_device *dev) |
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile index edcf801613e6..b3fa1ba191b7 100644 --- a/drivers/gpu/drm/nouveau/Makefile +++ b/drivers/gpu/drm/nouveau/Makefile | |||
| @@ -59,6 +59,7 @@ nouveau-y += core/subdev/clock/nv40.o | |||
| 59 | nouveau-y += core/subdev/clock/nv50.o | 59 | nouveau-y += core/subdev/clock/nv50.o |
| 60 | nouveau-y += core/subdev/clock/nv84.o | 60 | nouveau-y += core/subdev/clock/nv84.o |
| 61 | nouveau-y += core/subdev/clock/nva3.o | 61 | nouveau-y += core/subdev/clock/nva3.o |
| 62 | nouveau-y += core/subdev/clock/nvaa.o | ||
| 62 | nouveau-y += core/subdev/clock/nvc0.o | 63 | nouveau-y += core/subdev/clock/nvc0.o |
| 63 | nouveau-y += core/subdev/clock/nve0.o | 64 | nouveau-y += core/subdev/clock/nve0.o |
| 64 | nouveau-y += core/subdev/clock/pllnv04.o | 65 | nouveau-y += core/subdev/clock/pllnv04.o |
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nv50.c b/drivers/gpu/drm/nouveau/core/engine/device/nv50.c index db139827047c..db3fc7be856a 100644 --- a/drivers/gpu/drm/nouveau/core/engine/device/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/device/nv50.c | |||
| @@ -283,7 +283,7 @@ nv50_identify(struct nouveau_device *device) | |||
| 283 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; | 283 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; |
| 284 | device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass; | 284 | device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass; |
| 285 | device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass; | 285 | device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass; |
| 286 | device->oclass[NVDEV_SUBDEV_CLOCK ] = nv84_clock_oclass; | 286 | device->oclass[NVDEV_SUBDEV_CLOCK ] = nvaa_clock_oclass; |
| 287 | device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass; | 287 | device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass; |
| 288 | device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; | 288 | device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; |
| 289 | device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; | 289 | device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; |
| @@ -311,7 +311,7 @@ nv50_identify(struct nouveau_device *device) | |||
| 311 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; | 311 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; |
| 312 | device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass; | 312 | device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass; |
| 313 | device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass; | 313 | device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass; |
| 314 | device->oclass[NVDEV_SUBDEV_CLOCK ] = nv84_clock_oclass; | 314 | device->oclass[NVDEV_SUBDEV_CLOCK ] = nvaa_clock_oclass; |
| 315 | device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass; | 315 | device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass; |
| 316 | device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; | 316 | device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; |
| 317 | device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; | 317 | device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; |
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c index 5f555788121c..e6352bd5b4ff 100644 --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include <engine/dmaobj.h> | 33 | #include <engine/dmaobj.h> |
| 34 | #include <engine/fifo.h> | 34 | #include <engine/fifo.h> |
| 35 | 35 | ||
| 36 | #include "nv04.h" | ||
| 36 | #include "nv50.h" | 37 | #include "nv50.h" |
| 37 | 38 | ||
| 38 | /******************************************************************************* | 39 | /******************************************************************************* |
| @@ -460,6 +461,8 @@ nv50_fifo_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
| 460 | nv_subdev(priv)->intr = nv04_fifo_intr; | 461 | nv_subdev(priv)->intr = nv04_fifo_intr; |
| 461 | nv_engine(priv)->cclass = &nv50_fifo_cclass; | 462 | nv_engine(priv)->cclass = &nv50_fifo_cclass; |
| 462 | nv_engine(priv)->sclass = nv50_fifo_sclass; | 463 | nv_engine(priv)->sclass = nv50_fifo_sclass; |
| 464 | priv->base.pause = nv04_fifo_pause; | ||
| 465 | priv->base.start = nv04_fifo_start; | ||
| 463 | return 0; | 466 | return 0; |
| 464 | } | 467 | } |
| 465 | 468 | ||
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c index 0908dc834c84..fe0f41e65d9b 100644 --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <engine/dmaobj.h> | 35 | #include <engine/dmaobj.h> |
| 36 | #include <engine/fifo.h> | 36 | #include <engine/fifo.h> |
| 37 | 37 | ||
| 38 | #include "nv04.h" | ||
| 38 | #include "nv50.h" | 39 | #include "nv50.h" |
| 39 | 40 | ||
| 40 | /******************************************************************************* | 41 | /******************************************************************************* |
| @@ -432,6 +433,8 @@ nv84_fifo_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
| 432 | nv_subdev(priv)->intr = nv04_fifo_intr; | 433 | nv_subdev(priv)->intr = nv04_fifo_intr; |
| 433 | nv_engine(priv)->cclass = &nv84_fifo_cclass; | 434 | nv_engine(priv)->cclass = &nv84_fifo_cclass; |
| 434 | nv_engine(priv)->sclass = nv84_fifo_sclass; | 435 | nv_engine(priv)->sclass = nv84_fifo_sclass; |
| 436 | priv->base.pause = nv04_fifo_pause; | ||
| 437 | priv->base.start = nv04_fifo_start; | ||
| 435 | return 0; | 438 | return 0; |
| 436 | } | 439 | } |
| 437 | 440 | ||
diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c index b574dd4bb828..5ce686ee729e 100644 --- a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c | |||
| @@ -176,7 +176,7 @@ nv50_software_context_ctor(struct nouveau_object *parent, | |||
| 176 | if (ret) | 176 | if (ret) |
| 177 | return ret; | 177 | return ret; |
| 178 | 178 | ||
| 179 | chan->vblank.nr_event = pdisp->vblank->index_nr; | 179 | chan->vblank.nr_event = pdisp ? pdisp->vblank->index_nr : 0; |
| 180 | chan->vblank.event = kzalloc(chan->vblank.nr_event * | 180 | chan->vblank.event = kzalloc(chan->vblank.nr_event * |
| 181 | sizeof(*chan->vblank.event), GFP_KERNEL); | 181 | sizeof(*chan->vblank.event), GFP_KERNEL); |
| 182 | if (!chan->vblank.event) | 182 | if (!chan->vblank.event) |
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h index e2675bc0edba..8f4ced75444a 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h | |||
| @@ -14,6 +14,9 @@ enum nv_clk_src { | |||
| 14 | nv_clk_src_hclk, | 14 | nv_clk_src_hclk, |
| 15 | nv_clk_src_hclkm3, | 15 | nv_clk_src_hclkm3, |
| 16 | nv_clk_src_hclkm3d2, | 16 | nv_clk_src_hclkm3d2, |
| 17 | nv_clk_src_hclkm2d3, /* NVAA */ | ||
| 18 | nv_clk_src_hclkm4, /* NVAA */ | ||
| 19 | nv_clk_src_cclk, /* NVAA */ | ||
| 17 | 20 | ||
| 18 | nv_clk_src_host, | 21 | nv_clk_src_host, |
| 19 | 22 | ||
| @@ -127,6 +130,7 @@ extern struct nouveau_oclass nv04_clock_oclass; | |||
| 127 | extern struct nouveau_oclass nv40_clock_oclass; | 130 | extern struct nouveau_oclass nv40_clock_oclass; |
| 128 | extern struct nouveau_oclass *nv50_clock_oclass; | 131 | extern struct nouveau_oclass *nv50_clock_oclass; |
| 129 | extern struct nouveau_oclass *nv84_clock_oclass; | 132 | extern struct nouveau_oclass *nv84_clock_oclass; |
| 133 | extern struct nouveau_oclass *nvaa_clock_oclass; | ||
| 130 | extern struct nouveau_oclass nva3_clock_oclass; | 134 | extern struct nouveau_oclass nva3_clock_oclass; |
| 131 | extern struct nouveau_oclass nvc0_clock_oclass; | 135 | extern struct nouveau_oclass nvc0_clock_oclass; |
| 132 | extern struct nouveau_oclass nve0_clock_oclass; | 136 | extern struct nouveau_oclass nve0_clock_oclass; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c index da50c1b12928..30c1f3a4158e 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c | |||
| @@ -69,6 +69,11 @@ nv04_clock_pll_prog(struct nouveau_clock *clk, u32 reg1, | |||
| 69 | return 0; | 69 | return 0; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static struct nouveau_clocks | ||
| 73 | nv04_domain[] = { | ||
| 74 | { nv_clk_src_max } | ||
| 75 | }; | ||
| 76 | |||
| 72 | static int | 77 | static int |
| 73 | nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 78 | nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
| 74 | struct nouveau_oclass *oclass, void *data, u32 size, | 79 | struct nouveau_oclass *oclass, void *data, u32 size, |
| @@ -77,7 +82,7 @@ nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
| 77 | struct nv04_clock_priv *priv; | 82 | struct nv04_clock_priv *priv; |
| 78 | int ret; | 83 | int ret; |
| 79 | 84 | ||
| 80 | ret = nouveau_clock_create(parent, engine, oclass, NULL, &priv); | 85 | ret = nouveau_clock_create(parent, engine, oclass, nv04_domain, &priv); |
| 81 | *pobject = nv_object(priv); | 86 | *pobject = nv_object(priv); |
| 82 | if (ret) | 87 | if (ret) |
| 83 | return ret; | 88 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c new file mode 100644 index 000000000000..7a723b4f564d --- /dev/null +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c | |||
| @@ -0,0 +1,445 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2012 Red Hat Inc. | ||
| 3 | * | ||
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | * copy of this software and associated documentation files (the "Software"), | ||
| 6 | * to deal in the Software without restriction, including without limitation | ||
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | * Software is furnished to do so, subject to the following conditions: | ||
| 10 | * | ||
| 11 | * The above copyright notice and this permission notice shall be included in | ||
| 12 | * all copies or substantial portions of the Software. | ||
| 13 | * | ||
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
| 21 | * | ||
| 22 | * Authors: Ben Skeggs | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include <engine/fifo.h> | ||
| 26 | #include <subdev/bios.h> | ||
| 27 | #include <subdev/bios/pll.h> | ||
| 28 | #include <subdev/timer.h> | ||
| 29 | #include <subdev/clock.h> | ||
| 30 | |||
| 31 | #include "pll.h" | ||
| 32 | |||
| 33 | struct nvaa_clock_priv { | ||
| 34 | struct nouveau_clock base; | ||
| 35 | enum nv_clk_src csrc, ssrc, vsrc; | ||
| 36 | u32 cctrl, sctrl; | ||
| 37 | u32 ccoef, scoef; | ||
| 38 | u32 cpost, spost; | ||
| 39 | u32 vdiv; | ||
| 40 | }; | ||
| 41 | |||
| 42 | static u32 | ||
| 43 | read_div(struct nouveau_clock *clk) | ||
| 44 | { | ||
| 45 | return nv_rd32(clk, 0x004600); | ||
| 46 | } | ||
| 47 | |||
| 48 | static u32 | ||
| 49 | read_pll(struct nouveau_clock *clk, u32 base) | ||
| 50 | { | ||
| 51 | u32 ctrl = nv_rd32(clk, base + 0); | ||
| 52 | u32 coef = nv_rd32(clk, base + 4); | ||
| 53 | u32 ref = clk->read(clk, nv_clk_src_href); | ||
| 54 | u32 post_div = 0; | ||
| 55 | u32 clock = 0; | ||
| 56 | int N1, M1; | ||
| 57 | |||
| 58 | switch (base){ | ||
| 59 | case 0x4020: | ||
| 60 | post_div = 1 << ((nv_rd32(clk, 0x4070) & 0x000f0000) >> 16); | ||
| 61 | break; | ||
| 62 | case 0x4028: | ||
| 63 | post_div = (nv_rd32(clk, 0x4040) & 0x000f0000) >> 16; | ||
| 64 | break; | ||
| 65 | default: | ||
| 66 | break; | ||
| 67 | } | ||
| 68 | |||
| 69 | N1 = (coef & 0x0000ff00) >> 8; | ||
| 70 | M1 = (coef & 0x000000ff); | ||
| 71 | if ((ctrl & 0x80000000) && M1) { | ||
| 72 | clock = ref * N1 / M1; | ||
| 73 | clock = clock / post_div; | ||
| 74 | } | ||
| 75 | |||
| 76 | return clock; | ||
| 77 | } | ||
| 78 | |||
| 79 | static int | ||
| 80 | nvaa_clock_read(struct nouveau_clock *clk, enum nv_clk_src src) | ||
| 81 | { | ||
| 82 | struct nvaa_clock_priv *priv = (void *)clk; | ||
| 83 | u32 mast = nv_rd32(clk, 0x00c054); | ||
| 84 | u32 P = 0; | ||
| 85 | |||
| 86 | switch (src) { | ||
| 87 | case nv_clk_src_crystal: | ||
| 88 | return nv_device(priv)->crystal; | ||
| 89 | case nv_clk_src_href: | ||
| 90 | return 100000; /* PCIE reference clock */ | ||
| 91 | case nv_clk_src_hclkm4: | ||
| 92 | return clk->read(clk, nv_clk_src_href) * 4; | ||
| 93 | case nv_clk_src_hclkm2d3: | ||
| 94 | return clk->read(clk, nv_clk_src_href) * 2 / 3; | ||
| 95 | case nv_clk_src_host: | ||
| 96 | switch (mast & 0x000c0000) { | ||
| 97 | case 0x00000000: return clk->read(clk, nv_clk_src_hclkm2d3); | ||
| 98 | case 0x00040000: break; | ||
| 99 | case 0x00080000: return clk->read(clk, nv_clk_src_hclkm4); | ||
| 100 | case 0x000c0000: return clk->read(clk, nv_clk_src_cclk); | ||
| 101 | } | ||
| 102 | break; | ||
| 103 | case nv_clk_src_core: | ||
| 104 | P = (nv_rd32(clk, 0x004028) & 0x00070000) >> 16; | ||
| 105 | |||
| 106 | switch (mast & 0x00000003) { | ||
| 107 | case 0x00000000: return clk->read(clk, nv_clk_src_crystal) >> P; | ||
| 108 | case 0x00000001: return 0; | ||
| 109 | case 0x00000002: return clk->read(clk, nv_clk_src_hclkm4) >> P; | ||
| 110 | case 0x00000003: return read_pll(clk, 0x004028) >> P; | ||
| 111 | } | ||
| 112 | break; | ||
| 113 | case nv_clk_src_cclk: | ||
| 114 | if ((mast & 0x03000000) != 0x03000000) | ||
| 115 | return clk->read(clk, nv_clk_src_core); | ||
| 116 | |||
| 117 | if ((mast & 0x00000200) == 0x00000000) | ||
| 118 | return clk->read(clk, nv_clk_src_core); | ||
| 119 | |||
| 120 | switch (mast & 0x00000c00) { | ||
| 121 | case 0x00000000: return clk->read(clk, nv_clk_src_href); | ||
| 122 | case 0x00000400: return clk->read(clk, nv_clk_src_hclkm4); | ||
| 123 | case 0x00000800: return clk->read(clk, nv_clk_src_hclkm2d3); | ||
| 124 | default: return 0; | ||
| 125 | } | ||
| 126 | case nv_clk_src_shader: | ||
| 127 | P = (nv_rd32(clk, 0x004020) & 0x00070000) >> 16; | ||
| 128 | switch (mast & 0x00000030) { | ||
| 129 | case 0x00000000: | ||
| 130 | if (mast & 0x00000040) | ||
| 131 | return clk->read(clk, nv_clk_src_href) >> P; | ||
| 132 | return clk->read(clk, nv_clk_src_crystal) >> P; | ||
| 133 | case 0x00000010: break; | ||
| 134 | case 0x00000020: return read_pll(clk, 0x004028) >> P; | ||
| 135 | case 0x00000030: return read_pll(clk, 0x004020) >> P; | ||
| 136 | } | ||
| 137 | break; | ||
| 138 | case nv_clk_src_mem: | ||
| 139 | return 0; | ||
| 140 | break; | ||
| 141 | case nv_clk_src_vdec: | ||
| 142 | P = (read_div(clk) & 0x00000700) >> 8; | ||
| 143 | |||
| 144 | switch (mast & 0x00400000) { | ||
| 145 | case 0x00400000: | ||
| 146 | return clk->read(clk, nv_clk_src_core) >> P; | ||
| 147 | break; | ||
| 148 | default: | ||
| 149 | return 500000 >> P; | ||
| 150 | break; | ||
| 151 | } | ||
| 152 | break; | ||
| 153 | default: | ||
| 154 | break; | ||
| 155 | } | ||
| 156 | |||
| 157 | nv_debug(priv, "unknown clock source %d 0x%08x\n", src, mast); | ||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | static u32 | ||
| 162 | calc_pll(struct nvaa_clock_priv *priv, u32 reg, | ||
| 163 | u32 clock, int *N, int *M, int *P) | ||
| 164 | { | ||
| 165 | struct nouveau_bios *bios = nouveau_bios(priv); | ||
| 166 | struct nvbios_pll pll; | ||
| 167 | struct nouveau_clock *clk = &priv->base; | ||
| 168 | int ret; | ||
| 169 | |||
| 170 | ret = nvbios_pll_parse(bios, reg, &pll); | ||
| 171 | if (ret) | ||
| 172 | return 0; | ||
| 173 | |||
| 174 | pll.vco2.max_freq = 0; | ||
| 175 | pll.refclk = clk->read(clk, nv_clk_src_href); | ||
| 176 | if (!pll.refclk) | ||
| 177 | return 0; | ||
| 178 | |||
| 179 | return nv04_pll_calc(nv_subdev(priv), &pll, clock, N, M, NULL, NULL, P); | ||
| 180 | } | ||
| 181 | |||
| 182 | static inline u32 | ||
| 183 | calc_P(u32 src, u32 target, int *div) | ||
| 184 | { | ||
| 185 | u32 clk0 = src, clk1 = src; | ||
| 186 | for (*div = 0; *div <= 7; (*div)++) { | ||
| 187 | if (clk0 <= target) { | ||
| 188 | clk1 = clk0 << (*div ? 1 : 0); | ||
| 189 | break; | ||
| 190 | } | ||
| 191 | clk0 >>= 1; | ||
| 192 | } | ||
| 193 | |||
| 194 | if (target - clk0 <= clk1 - target) | ||
| 195 | return clk0; | ||
| 196 | (*div)--; | ||
| 197 | return clk1; | ||
| 198 | } | ||
| 199 | |||
| 200 | static int | ||
| 201 | nvaa_clock_calc(struct nouveau_clock *clk, struct nouveau_cstate *cstate) | ||
| 202 | { | ||
| 203 | struct nvaa_clock_priv *priv = (void *)clk; | ||
| 204 | const int shader = cstate->domain[nv_clk_src_shader]; | ||
| 205 | const int core = cstate->domain[nv_clk_src_core]; | ||
| 206 | const int vdec = cstate->domain[nv_clk_src_vdec]; | ||
| 207 | u32 out = 0, clock = 0; | ||
| 208 | int N, M, P1, P2 = 0; | ||
| 209 | int divs = 0; | ||
| 210 | |||
| 211 | /* cclk: find suitable source, disable PLL if we can */ | ||
| 212 | if (core < clk->read(clk, nv_clk_src_hclkm4)) | ||
| 213 | out = calc_P(clk->read(clk, nv_clk_src_hclkm4), core, &divs); | ||
| 214 | |||
| 215 | /* Calculate clock * 2, so shader clock can use it too */ | ||
| 216 | clock = calc_pll(priv, 0x4028, (core << 1), &N, &M, &P1); | ||
| 217 | |||
| 218 | if (abs(core - out) <= | ||
| 219 | abs(core - (clock >> 1))) { | ||
| 220 | priv->csrc = nv_clk_src_hclkm4; | ||
| 221 | priv->cctrl = divs << 16; | ||
| 222 | } else { | ||
| 223 | /* NVCTRL is actually used _after_ NVPOST, and after what we | ||
| 224 | * call NVPLL. To make matters worse, NVPOST is an integer | ||
| 225 | * divider instead of a right-shift number. */ | ||
| 226 | if(P1 > 2) { | ||
| 227 | P2 = P1 - 2; | ||
| 228 | P1 = 2; | ||
| 229 | } | ||
| 230 | |||
| 231 | priv->csrc = nv_clk_src_core; | ||
| 232 | priv->ccoef = (N << 8) | M; | ||
| 233 | |||
| 234 | priv->cctrl = (P2 + 1) << 16; | ||
| 235 | priv->cpost = (1 << P1) << 16; | ||
| 236 | } | ||
| 237 | |||
| 238 | /* sclk: nvpll + divisor, href or spll */ | ||
| 239 | out = 0; | ||
| 240 | if (shader == clk->read(clk, nv_clk_src_href)) { | ||
| 241 | priv->ssrc = nv_clk_src_href; | ||
| 242 | } else { | ||
| 243 | clock = calc_pll(priv, 0x4020, shader, &N, &M, &P1); | ||
| 244 | if (priv->csrc == nv_clk_src_core) { | ||
| 245 | out = calc_P((core << 1), shader, &divs); | ||
| 246 | } | ||
| 247 | |||
| 248 | if (abs(shader - out) <= | ||
| 249 | abs(shader - clock) && | ||
| 250 | (divs + P2) <= 7) { | ||
| 251 | priv->ssrc = nv_clk_src_core; | ||
| 252 | priv->sctrl = (divs + P2) << 16; | ||
| 253 | } else { | ||
| 254 | priv->ssrc = nv_clk_src_shader; | ||
| 255 | priv->scoef = (N << 8) | M; | ||
| 256 | priv->sctrl = P1 << 16; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 260 | /* vclk */ | ||
| 261 | out = calc_P(core, vdec, &divs); | ||
| 262 | clock = calc_P(500000, vdec, &P1); | ||
| 263 | if(abs(vdec - out) <= | ||
| 264 | abs(vdec - clock)) { | ||
| 265 | priv->vsrc = nv_clk_src_cclk; | ||
| 266 | priv->vdiv = divs << 16; | ||
| 267 | } else { | ||
| 268 | priv->vsrc = nv_clk_src_vdec; | ||
| 269 | priv->vdiv = P1 << 16; | ||
| 270 | } | ||
| 271 | |||
| 272 | /* Print strategy! */ | ||
| 273 | nv_debug(priv, "nvpll: %08x %08x %08x\n", | ||
| 274 | priv->ccoef, priv->cpost, priv->cctrl); | ||
| 275 | nv_debug(priv, " spll: %08x %08x %08x\n", | ||
| 276 | priv->scoef, priv->spost, priv->sctrl); | ||
| 277 | nv_debug(priv, " vdiv: %08x\n", priv->vdiv); | ||
| 278 | if (priv->csrc == nv_clk_src_hclkm4) | ||
| 279 | nv_debug(priv, "core: hrefm4\n"); | ||
| 280 | else | ||
| 281 | nv_debug(priv, "core: nvpll\n"); | ||
| 282 | |||
| 283 | if (priv->ssrc == nv_clk_src_hclkm4) | ||
| 284 | nv_debug(priv, "shader: hrefm4\n"); | ||
| 285 | else if (priv->ssrc == nv_clk_src_core) | ||
| 286 | nv_debug(priv, "shader: nvpll\n"); | ||
| 287 | else | ||
| 288 | nv_debug(priv, "shader: spll\n"); | ||
| 289 | |||
| 290 | if (priv->vsrc == nv_clk_src_hclkm4) | ||
| 291 | nv_debug(priv, "vdec: 500MHz\n"); | ||
| 292 | else | ||
| 293 | nv_debug(priv, "vdec: core\n"); | ||
| 294 | |||
| 295 | return 0; | ||
| 296 | } | ||
| 297 | |||
| 298 | static int | ||
| 299 | nvaa_clock_prog(struct nouveau_clock *clk) | ||
| 300 | { | ||
| 301 | struct nvaa_clock_priv *priv = (void *)clk; | ||
| 302 | struct nouveau_fifo *pfifo = nouveau_fifo(clk); | ||
| 303 | unsigned long flags; | ||
| 304 | u32 pllmask = 0, mast, ptherm_gate; | ||
| 305 | int ret = -EBUSY; | ||
| 306 | |||
| 307 | /* halt and idle execution engines */ | ||
| 308 | ptherm_gate = nv_mask(clk, 0x020060, 0x00070000, 0x00000000); | ||
| 309 | nv_mask(clk, 0x002504, 0x00000001, 0x00000001); | ||
| 310 | /* Wait until the interrupt handler is finished */ | ||
| 311 | if (!nv_wait(clk, 0x000100, 0xffffffff, 0x00000000)) | ||
| 312 | goto resume; | ||
| 313 | |||
| 314 | if (pfifo) | ||
| 315 | pfifo->pause(pfifo, &flags); | ||
| 316 | |||
| 317 | if (!nv_wait(clk, 0x002504, 0x00000010, 0x00000010)) | ||
| 318 | goto resume; | ||
| 319 | if (!nv_wait(clk, 0x00251c, 0x0000003f, 0x0000003f)) | ||
| 320 | goto resume; | ||
| 321 | |||
| 322 | /* First switch to safe clocks: href */ | ||
| 323 | mast = nv_mask(clk, 0xc054, 0x03400e70, 0x03400640); | ||
| 324 | mast &= ~0x00400e73; | ||
| 325 | mast |= 0x03000000; | ||
| 326 | |||
| 327 | switch (priv->csrc) { | ||
| 328 | case nv_clk_src_hclkm4: | ||
| 329 | nv_mask(clk, 0x4028, 0x00070000, priv->cctrl); | ||
| 330 | mast |= 0x00000002; | ||
| 331 | break; | ||
| 332 | case nv_clk_src_core: | ||
| 333 | nv_wr32(clk, 0x402c, priv->ccoef); | ||
| 334 | nv_wr32(clk, 0x4028, 0x80000000 | priv->cctrl); | ||
| 335 | nv_wr32(clk, 0x4040, priv->cpost); | ||
| 336 | pllmask |= (0x3 << 8); | ||
| 337 | mast |= 0x00000003; | ||
| 338 | break; | ||
| 339 | default: | ||
| 340 | nv_warn(priv,"Reclocking failed: unknown core clock\n"); | ||
| 341 | goto resume; | ||
| 342 | } | ||
| 343 | |||
| 344 | switch (priv->ssrc) { | ||
| 345 | case nv_clk_src_href: | ||
| 346 | nv_mask(clk, 0x4020, 0x00070000, 0x00000000); | ||
| 347 | /* mast |= 0x00000000; */ | ||
| 348 | break; | ||
| 349 | case nv_clk_src_core: | ||
| 350 | nv_mask(clk, 0x4020, 0x00070000, priv->sctrl); | ||
| 351 | mast |= 0x00000020; | ||
| 352 | break; | ||
| 353 | case nv_clk_src_shader: | ||
| 354 | nv_wr32(clk, 0x4024, priv->scoef); | ||
| 355 | nv_wr32(clk, 0x4020, 0x80000000 | priv->sctrl); | ||
| 356 | nv_wr32(clk, 0x4070, priv->spost); | ||
| 357 | pllmask |= (0x3 << 12); | ||
| 358 | mast |= 0x00000030; | ||
| 359 | break; | ||
| 360 | default: | ||
| 361 | nv_warn(priv,"Reclocking failed: unknown sclk clock\n"); | ||
| 362 | goto resume; | ||
| 363 | } | ||
| 364 | |||
| 365 | if (!nv_wait(clk, 0x004080, pllmask, pllmask)) { | ||
| 366 | nv_warn(priv,"Reclocking failed: unstable PLLs\n"); | ||
| 367 | goto resume; | ||
| 368 | } | ||
| 369 | |||
| 370 | switch (priv->vsrc) { | ||
| 371 | case nv_clk_src_cclk: | ||
| 372 | mast |= 0x00400000; | ||
| 373 | default: | ||
| 374 | nv_wr32(clk, 0x4600, priv->vdiv); | ||
| 375 | } | ||
| 376 | |||
| 377 | nv_wr32(clk, 0xc054, mast); | ||
| 378 | ret = 0; | ||
| 379 | |||
| 380 | resume: | ||
| 381 | if (pfifo) | ||
| 382 | pfifo->start(pfifo, &flags); | ||
| 383 | |||
| 384 | nv_mask(clk, 0x002504, 0x00000001, 0x00000000); | ||
| 385 | nv_wr32(clk, 0x020060, ptherm_gate); | ||
| 386 | |||
| 387 | /* Disable some PLLs and dividers when unused */ | ||
| 388 | if (priv->csrc != nv_clk_src_core) { | ||
| 389 | nv_wr32(clk, 0x4040, 0x00000000); | ||
| 390 | nv_mask(clk, 0x4028, 0x80000000, 0x00000000); | ||
| 391 | } | ||
| 392 | |||
| 393 | if (priv->ssrc != nv_clk_src_shader) { | ||
| 394 | nv_wr32(clk, 0x4070, 0x00000000); | ||
| 395 | nv_mask(clk, 0x4020, 0x80000000, 0x00000000); | ||
| 396 | } | ||
| 397 | |||
| 398 | return ret; | ||
| 399 | } | ||
| 400 | |||
| 401 | static void | ||
| 402 | nvaa_clock_tidy(struct nouveau_clock *clk) | ||
| 403 | { | ||
| 404 | } | ||
| 405 | |||
| 406 | static struct nouveau_clocks | ||
| 407 | nvaa_domains[] = { | ||
| 408 | { nv_clk_src_crystal, 0xff }, | ||
| 409 | { nv_clk_src_href , 0xff }, | ||
| 410 | { nv_clk_src_core , 0xff, 0, "core", 1000 }, | ||
| 411 | { nv_clk_src_shader , 0xff, 0, "shader", 1000 }, | ||
| 412 | { nv_clk_src_vdec , 0xff, 0, "vdec", 1000 }, | ||
| 413 | { nv_clk_src_max } | ||
| 414 | }; | ||
| 415 | |||
| 416 | static int | ||
| 417 | nvaa_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | ||
| 418 | struct nouveau_oclass *oclass, void *data, u32 size, | ||
| 419 | struct nouveau_object **pobject) | ||
| 420 | { | ||
| 421 | struct nvaa_clock_priv *priv; | ||
| 422 | int ret; | ||
| 423 | |||
| 424 | ret = nouveau_clock_create(parent, engine, oclass, nvaa_domains, &priv); | ||
| 425 | *pobject = nv_object(priv); | ||
| 426 | if (ret) | ||
| 427 | return ret; | ||
| 428 | |||
| 429 | priv->base.read = nvaa_clock_read; | ||
| 430 | priv->base.calc = nvaa_clock_calc; | ||
| 431 | priv->base.prog = nvaa_clock_prog; | ||
| 432 | priv->base.tidy = nvaa_clock_tidy; | ||
| 433 | return 0; | ||
| 434 | } | ||
| 435 | |||
| 436 | struct nouveau_oclass * | ||
| 437 | nvaa_clock_oclass = &(struct nouveau_oclass) { | ||
| 438 | .handle = NV_SUBDEV(CLOCK, 0xaa), | ||
| 439 | .ofuncs = &(struct nouveau_ofuncs) { | ||
| 440 | .ctor = nvaa_clock_ctor, | ||
| 441 | .dtor = _nouveau_clock_dtor, | ||
| 442 | .init = _nouveau_clock_init, | ||
| 443 | .fini = _nouveau_clock_fini, | ||
| 444 | }, | ||
| 445 | }; | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c b/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c index e286e132c7e7..129120473f6c 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | |||
| @@ -116,7 +116,7 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version) | |||
| 116 | acpi_handle handle; | 116 | acpi_handle handle; |
| 117 | int ret; | 117 | int ret; |
| 118 | 118 | ||
| 119 | handle = DEVICE_ACPI_HANDLE(&device->pdev->dev); | 119 | handle = ACPI_HANDLE(&device->pdev->dev); |
| 120 | if (!handle) | 120 | if (!handle) |
| 121 | return false; | 121 | return false; |
| 122 | 122 | ||
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c index 3618ac6b6316..32e7064b819b 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c +++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c | |||
| @@ -58,8 +58,8 @@ struct nouveau_plane { | |||
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | static uint32_t formats[] = { | 60 | static uint32_t formats[] = { |
| 61 | DRM_FORMAT_NV12, | ||
| 62 | DRM_FORMAT_UYVY, | 61 | DRM_FORMAT_UYVY, |
| 62 | DRM_FORMAT_NV12, | ||
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | /* Sine can be approximated with | 65 | /* Sine can be approximated with |
| @@ -99,13 +99,28 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
| 99 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 99 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 100 | struct nouveau_bo *cur = nv_plane->cur; | 100 | struct nouveau_bo *cur = nv_plane->cur; |
| 101 | bool flip = nv_plane->flip; | 101 | bool flip = nv_plane->flip; |
| 102 | int format = ALIGN(src_w * 4, 0x100); | ||
| 103 | int soff = NV_PCRTC0_SIZE * nv_crtc->index; | 102 | int soff = NV_PCRTC0_SIZE * nv_crtc->index; |
| 104 | int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index; | 103 | int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index; |
| 105 | int ret; | 104 | int format, ret; |
| 105 | |||
| 106 | /* Source parameters given in 16.16 fixed point, ignore fractional. */ | ||
| 107 | src_x >>= 16; | ||
| 108 | src_y >>= 16; | ||
| 109 | src_w >>= 16; | ||
| 110 | src_h >>= 16; | ||
| 111 | |||
| 112 | format = ALIGN(src_w * 4, 0x100); | ||
| 106 | 113 | ||
| 107 | if (format > 0xffff) | 114 | if (format > 0xffff) |
| 108 | return -EINVAL; | 115 | return -ERANGE; |
| 116 | |||
| 117 | if (dev->chipset >= 0x30) { | ||
| 118 | if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1)) | ||
| 119 | return -ERANGE; | ||
| 120 | } else { | ||
| 121 | if (crtc_w < (src_w >> 3) || crtc_h < (src_h >> 3)) | ||
| 122 | return -ERANGE; | ||
| 123 | } | ||
| 109 | 124 | ||
| 110 | ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM); | 125 | ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM); |
| 111 | if (ret) | 126 | if (ret) |
| @@ -113,12 +128,6 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
| 113 | 128 | ||
| 114 | nv_plane->cur = nv_fb->nvbo; | 129 | nv_plane->cur = nv_fb->nvbo; |
| 115 | 130 | ||
| 116 | /* Source parameters given in 16.16 fixed point, ignore fractional. */ | ||
| 117 | src_x = src_x >> 16; | ||
| 118 | src_y = src_y >> 16; | ||
| 119 | src_w = src_w >> 16; | ||
| 120 | src_h = src_h >> 16; | ||
| 121 | |||
| 122 | nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY); | 131 | nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY); |
| 123 | nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0); | 132 | nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0); |
| 124 | 133 | ||
| @@ -245,14 +254,25 @@ nv10_overlay_init(struct drm_device *device) | |||
| 245 | { | 254 | { |
| 246 | struct nouveau_device *dev = nouveau_dev(device); | 255 | struct nouveau_device *dev = nouveau_dev(device); |
| 247 | struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL); | 256 | struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL); |
| 257 | int num_formats = ARRAY_SIZE(formats); | ||
| 248 | int ret; | 258 | int ret; |
| 249 | 259 | ||
| 250 | if (!plane) | 260 | if (!plane) |
| 251 | return; | 261 | return; |
| 252 | 262 | ||
| 263 | switch (dev->chipset) { | ||
| 264 | case 0x10: | ||
| 265 | case 0x11: | ||
| 266 | case 0x15: | ||
| 267 | case 0x1a: | ||
| 268 | case 0x20: | ||
| 269 | num_formats = 1; | ||
| 270 | break; | ||
| 271 | } | ||
| 272 | |||
| 253 | ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */, | 273 | ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */, |
| 254 | &nv10_plane_funcs, | 274 | &nv10_plane_funcs, |
| 255 | formats, ARRAY_SIZE(formats), false); | 275 | formats, num_formats, false); |
| 256 | if (ret) | 276 | if (ret) |
| 257 | goto err; | 277 | goto err; |
| 258 | 278 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index 07273a2ae62f..95c740454049 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c | |||
| @@ -256,7 +256,7 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev) | |||
| 256 | acpi_handle dhandle; | 256 | acpi_handle dhandle; |
| 257 | int retval = 0; | 257 | int retval = 0; |
| 258 | 258 | ||
| 259 | dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); | 259 | dhandle = ACPI_HANDLE(&pdev->dev); |
| 260 | if (!dhandle) | 260 | if (!dhandle) |
| 261 | return false; | 261 | return false; |
| 262 | 262 | ||
| @@ -414,7 +414,7 @@ bool nouveau_acpi_rom_supported(struct pci_dev *pdev) | |||
| 414 | if (!nouveau_dsm_priv.dsm_detected && !nouveau_dsm_priv.optimus_detected) | 414 | if (!nouveau_dsm_priv.dsm_detected && !nouveau_dsm_priv.optimus_detected) |
| 415 | return false; | 415 | return false; |
| 416 | 416 | ||
| 417 | dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); | 417 | dhandle = ACPI_HANDLE(&pdev->dev); |
| 418 | if (!dhandle) | 418 | if (!dhandle) |
| 419 | return false; | 419 | return false; |
| 420 | 420 | ||
| @@ -448,7 +448,7 @@ nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) | |||
| 448 | return NULL; | 448 | return NULL; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev); | 451 | handle = ACPI_HANDLE(&dev->pdev->dev); |
| 452 | if (!handle) | 452 | if (!handle) |
| 453 | return NULL; | 453 | return NULL; |
| 454 | 454 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index 7809d92183c4..29c3efdfc7dd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c | |||
| @@ -608,6 +608,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
| 608 | fence = nouveau_fence_ref(new_bo->bo.sync_obj); | 608 | fence = nouveau_fence_ref(new_bo->bo.sync_obj); |
| 609 | spin_unlock(&new_bo->bo.bdev->fence_lock); | 609 | spin_unlock(&new_bo->bo.bdev->fence_lock); |
| 610 | ret = nouveau_fence_sync(fence, chan); | 610 | ret = nouveau_fence_sync(fence, chan); |
| 611 | nouveau_fence_unref(&fence); | ||
| 611 | if (ret) | 612 | if (ret) |
| 612 | return ret; | 613 | return ret; |
| 613 | 614 | ||
| @@ -701,7 +702,7 @@ nouveau_finish_page_flip(struct nouveau_channel *chan, | |||
| 701 | 702 | ||
| 702 | s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head); | 703 | s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head); |
| 703 | if (s->event) | 704 | if (s->event) |
| 704 | drm_send_vblank_event(dev, -1, s->event); | 705 | drm_send_vblank_event(dev, s->crtc, s->event); |
| 705 | 706 | ||
| 706 | list_del(&s->head); | 707 | list_del(&s->head); |
| 707 | if (ps) | 708 | if (ps) |
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c index 38a4db5bfe21..4aff04fa483c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c | |||
| @@ -630,7 +630,6 @@ error: | |||
| 630 | hwmon->hwmon = NULL; | 630 | hwmon->hwmon = NULL; |
| 631 | return ret; | 631 | return ret; |
| 632 | #else | 632 | #else |
| 633 | hwmon->hwmon = NULL; | ||
| 634 | return 0; | 633 | return 0; |
| 635 | #endif | 634 | #endif |
| 636 | } | 635 | } |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index f8e66c08b11a..4e384a2f99c3 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
| @@ -1265,7 +1265,7 @@ nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, | |||
| 1265 | uint32_t start, uint32_t size) | 1265 | uint32_t start, uint32_t size) |
| 1266 | { | 1266 | { |
| 1267 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 1267 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 1268 | u32 end = max(start + size, (u32)256); | 1268 | u32 end = min_t(u32, start + size, 256); |
| 1269 | u32 i; | 1269 | u32 i; |
| 1270 | 1270 | ||
| 1271 | for (i = start; i < end; i++) { | 1271 | for (i = start; i < end; i++) { |
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c index 0109a9644cb2..821ab7b9409b 100644 --- a/drivers/gpu/drm/qxl/qxl_release.c +++ b/drivers/gpu/drm/qxl/qxl_release.c | |||
| @@ -92,6 +92,7 @@ qxl_release_free(struct qxl_device *qdev, | |||
| 92 | - DRM_FILE_OFFSET); | 92 | - DRM_FILE_OFFSET); |
| 93 | qxl_fence_remove_release(&bo->fence, release->id); | 93 | qxl_fence_remove_release(&bo->fence, release->id); |
| 94 | qxl_bo_unref(&bo); | 94 | qxl_bo_unref(&bo); |
| 95 | kfree(entry); | ||
| 95 | } | 96 | } |
| 96 | spin_lock(&qdev->release_idr_lock); | 97 | spin_lock(&qdev->release_idr_lock); |
| 97 | idr_remove(&qdev->release_idr, release->id); | 98 | idr_remove(&qdev->release_idr, release->id); |
diff --git a/drivers/gpu/drm/radeon/atombios_i2c.c b/drivers/gpu/drm/radeon/atombios_i2c.c index deaf98cdca3a..f685035dbe39 100644 --- a/drivers/gpu/drm/radeon/atombios_i2c.c +++ b/drivers/gpu/drm/radeon/atombios_i2c.c | |||
| @@ -44,7 +44,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, | |||
| 44 | PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args; | 44 | PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args; |
| 45 | int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction); | 45 | int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction); |
| 46 | unsigned char *base; | 46 | unsigned char *base; |
| 47 | u16 out; | 47 | u16 out = cpu_to_le16(0); |
| 48 | 48 | ||
| 49 | memset(&args, 0, sizeof(args)); | 49 | memset(&args, 0, sizeof(args)); |
| 50 | 50 | ||
| @@ -55,9 +55,14 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, | |||
| 55 | DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num); | 55 | DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num); |
| 56 | return -EINVAL; | 56 | return -EINVAL; |
| 57 | } | 57 | } |
| 58 | args.ucRegIndex = buf[0]; | 58 | if (buf == NULL) |
| 59 | if (num > 1) | 59 | args.ucRegIndex = 0; |
| 60 | memcpy(&out, &buf[1], num - 1); | 60 | else |
| 61 | args.ucRegIndex = buf[0]; | ||
| 62 | if (num) | ||
| 63 | num--; | ||
| 64 | if (num) | ||
| 65 | memcpy(&out, &buf[1], num); | ||
| 61 | args.lpI2CDataOut = cpu_to_le16(out); | 66 | args.lpI2CDataOut = cpu_to_le16(out); |
| 62 | } else { | 67 | } else { |
| 63 | if (num > ATOM_MAX_HW_I2C_READ) { | 68 | if (num > ATOM_MAX_HW_I2C_READ) { |
| @@ -94,14 +99,14 @@ int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
| 94 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); | 99 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
| 95 | struct i2c_msg *p; | 100 | struct i2c_msg *p; |
| 96 | int i, remaining, current_count, buffer_offset, max_bytes, ret; | 101 | int i, remaining, current_count, buffer_offset, max_bytes, ret; |
| 97 | u8 buf = 0, flags; | 102 | u8 flags; |
| 98 | 103 | ||
| 99 | /* check for bus probe */ | 104 | /* check for bus probe */ |
| 100 | p = &msgs[0]; | 105 | p = &msgs[0]; |
| 101 | if ((num == 1) && (p->len == 0)) { | 106 | if ((num == 1) && (p->len == 0)) { |
| 102 | ret = radeon_process_i2c_ch(i2c, | 107 | ret = radeon_process_i2c_ch(i2c, |
| 103 | p->addr, HW_I2C_WRITE, | 108 | p->addr, HW_I2C_WRITE, |
| 104 | &buf, 1); | 109 | NULL, 0); |
| 105 | if (ret) | 110 | if (ret) |
| 106 | return ret; | 111 | return ret; |
| 107 | else | 112 | else |
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index ae92aa041c6a..b43a3a3c9067 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c | |||
| @@ -1560,17 +1560,17 @@ u32 cik_get_xclk(struct radeon_device *rdev) | |||
| 1560 | * cik_mm_rdoorbell - read a doorbell dword | 1560 | * cik_mm_rdoorbell - read a doorbell dword |
| 1561 | * | 1561 | * |
| 1562 | * @rdev: radeon_device pointer | 1562 | * @rdev: radeon_device pointer |
| 1563 | * @offset: byte offset into the aperture | 1563 | * @index: doorbell index |
| 1564 | * | 1564 | * |
| 1565 | * Returns the value in the doorbell aperture at the | 1565 | * Returns the value in the doorbell aperture at the |
| 1566 | * requested offset (CIK). | 1566 | * requested doorbell index (CIK). |
| 1567 | */ | 1567 | */ |
| 1568 | u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset) | 1568 | u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 index) |
| 1569 | { | 1569 | { |
| 1570 | if (offset < rdev->doorbell.size) { | 1570 | if (index < rdev->doorbell.num_doorbells) { |
| 1571 | return readl(((void __iomem *)rdev->doorbell.ptr) + offset); | 1571 | return readl(rdev->doorbell.ptr + index); |
| 1572 | } else { | 1572 | } else { |
| 1573 | DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", offset); | 1573 | DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index); |
| 1574 | return 0; | 1574 | return 0; |
| 1575 | } | 1575 | } |
| 1576 | } | 1576 | } |
| @@ -1579,18 +1579,18 @@ u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset) | |||
| 1579 | * cik_mm_wdoorbell - write a doorbell dword | 1579 | * cik_mm_wdoorbell - write a doorbell dword |
| 1580 | * | 1580 | * |
| 1581 | * @rdev: radeon_device pointer | 1581 | * @rdev: radeon_device pointer |
| 1582 | * @offset: byte offset into the aperture | 1582 | * @index: doorbell index |
| 1583 | * @v: value to write | 1583 | * @v: value to write |
| 1584 | * | 1584 | * |
| 1585 | * Writes @v to the doorbell aperture at the | 1585 | * Writes @v to the doorbell aperture at the |
| 1586 | * requested offset (CIK). | 1586 | * requested doorbell index (CIK). |
| 1587 | */ | 1587 | */ |
| 1588 | void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v) | 1588 | void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v) |
| 1589 | { | 1589 | { |
| 1590 | if (offset < rdev->doorbell.size) { | 1590 | if (index < rdev->doorbell.num_doorbells) { |
| 1591 | writel(v, ((void __iomem *)rdev->doorbell.ptr) + offset); | 1591 | writel(v, rdev->doorbell.ptr + index); |
| 1592 | } else { | 1592 | } else { |
| 1593 | DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", offset); | 1593 | DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index); |
| 1594 | } | 1594 | } |
| 1595 | } | 1595 | } |
| 1596 | 1596 | ||
| @@ -2427,6 +2427,7 @@ static void cik_tiling_mode_table_init(struct radeon_device *rdev) | |||
| 2427 | gb_tile_moden = 0; | 2427 | gb_tile_moden = 0; |
| 2428 | break; | 2428 | break; |
| 2429 | } | 2429 | } |
| 2430 | rdev->config.cik.macrotile_mode_array[reg_offset] = gb_tile_moden; | ||
| 2430 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); | 2431 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2431 | } | 2432 | } |
| 2432 | } else if (num_pipe_configs == 4) { | 2433 | } else if (num_pipe_configs == 4) { |
| @@ -2773,6 +2774,7 @@ static void cik_tiling_mode_table_init(struct radeon_device *rdev) | |||
| 2773 | gb_tile_moden = 0; | 2774 | gb_tile_moden = 0; |
| 2774 | break; | 2775 | break; |
| 2775 | } | 2776 | } |
| 2777 | rdev->config.cik.macrotile_mode_array[reg_offset] = gb_tile_moden; | ||
| 2776 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); | 2778 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2777 | } | 2779 | } |
| 2778 | } else if (num_pipe_configs == 2) { | 2780 | } else if (num_pipe_configs == 2) { |
| @@ -2990,6 +2992,7 @@ static void cik_tiling_mode_table_init(struct radeon_device *rdev) | |||
| 2990 | gb_tile_moden = 0; | 2992 | gb_tile_moden = 0; |
| 2991 | break; | 2993 | break; |
| 2992 | } | 2994 | } |
| 2995 | rdev->config.cik.macrotile_mode_array[reg_offset] = gb_tile_moden; | ||
| 2993 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); | 2996 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2994 | } | 2997 | } |
| 2995 | } else | 2998 | } else |
| @@ -3556,17 +3559,24 @@ void cik_fence_compute_ring_emit(struct radeon_device *rdev, | |||
| 3556 | radeon_ring_write(ring, 0); | 3559 | radeon_ring_write(ring, 0); |
| 3557 | } | 3560 | } |
| 3558 | 3561 | ||
| 3559 | void cik_semaphore_ring_emit(struct radeon_device *rdev, | 3562 | bool cik_semaphore_ring_emit(struct radeon_device *rdev, |
| 3560 | struct radeon_ring *ring, | 3563 | struct radeon_ring *ring, |
| 3561 | struct radeon_semaphore *semaphore, | 3564 | struct radeon_semaphore *semaphore, |
| 3562 | bool emit_wait) | 3565 | bool emit_wait) |
| 3563 | { | 3566 | { |
| 3567 | /* TODO: figure out why semaphore cause lockups */ | ||
| 3568 | #if 0 | ||
| 3564 | uint64_t addr = semaphore->gpu_addr; | 3569 | uint64_t addr = semaphore->gpu_addr; |
| 3565 | unsigned sel = emit_wait ? PACKET3_SEM_SEL_WAIT : PACKET3_SEM_SEL_SIGNAL; | 3570 | unsigned sel = emit_wait ? PACKET3_SEM_SEL_WAIT : PACKET3_SEM_SEL_SIGNAL; |
| 3566 | 3571 | ||
| 3567 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); | 3572 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); |
| 3568 | radeon_ring_write(ring, addr & 0xffffffff); | 3573 | radeon_ring_write(ring, addr & 0xffffffff); |
| 3569 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xffff) | sel); | 3574 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xffff) | sel); |
| 3575 | |||
| 3576 | return true; | ||
| 3577 | #else | ||
| 3578 | return false; | ||
| 3579 | #endif | ||
| 3570 | } | 3580 | } |
| 3571 | 3581 | ||
| 3572 | /** | 3582 | /** |
| @@ -3609,13 +3619,8 @@ int cik_copy_cpdma(struct radeon_device *rdev, | |||
| 3609 | return r; | 3619 | return r; |
| 3610 | } | 3620 | } |
| 3611 | 3621 | ||
| 3612 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 3622 | radeon_semaphore_sync_to(sem, *fence); |
| 3613 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 3623 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 3614 | ring->idx); | ||
| 3615 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 3616 | } else { | ||
| 3617 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 3618 | } | ||
| 3619 | 3624 | ||
| 3620 | for (i = 0; i < num_loops; i++) { | 3625 | for (i = 0; i < num_loops; i++) { |
| 3621 | cur_size_in_bytes = size_in_bytes; | 3626 | cur_size_in_bytes = size_in_bytes; |
| @@ -4052,7 +4057,7 @@ void cik_compute_ring_set_wptr(struct radeon_device *rdev, | |||
| 4052 | struct radeon_ring *ring) | 4057 | struct radeon_ring *ring) |
| 4053 | { | 4058 | { |
| 4054 | rdev->wb.wb[ring->wptr_offs/4] = cpu_to_le32(ring->wptr); | 4059 | rdev->wb.wb[ring->wptr_offs/4] = cpu_to_le32(ring->wptr); |
| 4055 | WDOORBELL32(ring->doorbell_offset, ring->wptr); | 4060 | WDOORBELL32(ring->doorbell_index, ring->wptr); |
| 4056 | } | 4061 | } |
| 4057 | 4062 | ||
| 4058 | /** | 4063 | /** |
| @@ -4393,10 +4398,6 @@ static int cik_cp_compute_resume(struct radeon_device *rdev) | |||
| 4393 | return r; | 4398 | return r; |
| 4394 | } | 4399 | } |
| 4395 | 4400 | ||
| 4396 | /* doorbell offset */ | ||
| 4397 | rdev->ring[idx].doorbell_offset = | ||
| 4398 | (rdev->ring[idx].doorbell_page_num * PAGE_SIZE) + 0; | ||
| 4399 | |||
| 4400 | /* init the mqd struct */ | 4401 | /* init the mqd struct */ |
| 4401 | memset(buf, 0, sizeof(struct bonaire_mqd)); | 4402 | memset(buf, 0, sizeof(struct bonaire_mqd)); |
| 4402 | 4403 | ||
| @@ -4508,7 +4509,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev) | |||
| 4508 | RREG32(CP_HQD_PQ_DOORBELL_CONTROL); | 4509 | RREG32(CP_HQD_PQ_DOORBELL_CONTROL); |
| 4509 | mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_OFFSET_MASK; | 4510 | mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_OFFSET_MASK; |
| 4510 | mqd->queue_state.cp_hqd_pq_doorbell_control |= | 4511 | mqd->queue_state.cp_hqd_pq_doorbell_control |= |
| 4511 | DOORBELL_OFFSET(rdev->ring[idx].doorbell_offset / 4); | 4512 | DOORBELL_OFFSET(rdev->ring[idx].doorbell_index); |
| 4512 | mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN; | 4513 | mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN; |
| 4513 | mqd->queue_state.cp_hqd_pq_doorbell_control &= | 4514 | mqd->queue_state.cp_hqd_pq_doorbell_control &= |
| 4514 | ~(DOORBELL_SOURCE | DOORBELL_HIT); | 4515 | ~(DOORBELL_SOURCE | DOORBELL_HIT); |
| @@ -7839,14 +7840,14 @@ int cik_init(struct radeon_device *rdev) | |||
| 7839 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; | 7840 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 7840 | ring->ring_obj = NULL; | 7841 | ring->ring_obj = NULL; |
| 7841 | r600_ring_init(rdev, ring, 1024 * 1024); | 7842 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7842 | r = radeon_doorbell_get(rdev, &ring->doorbell_page_num); | 7843 | r = radeon_doorbell_get(rdev, &ring->doorbell_index); |
| 7843 | if (r) | 7844 | if (r) |
| 7844 | return r; | 7845 | return r; |
| 7845 | 7846 | ||
| 7846 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; | 7847 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 7847 | ring->ring_obj = NULL; | 7848 | ring->ring_obj = NULL; |
| 7848 | r600_ring_init(rdev, ring, 1024 * 1024); | 7849 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7849 | r = radeon_doorbell_get(rdev, &ring->doorbell_page_num); | 7850 | r = radeon_doorbell_get(rdev, &ring->doorbell_index); |
| 7850 | if (r) | 7851 | if (r) |
| 7851 | return r; | 7852 | return r; |
| 7852 | 7853 | ||
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c index 9c9529de20ee..0300727a4f70 100644 --- a/drivers/gpu/drm/radeon/cik_sdma.c +++ b/drivers/gpu/drm/radeon/cik_sdma.c | |||
| @@ -130,7 +130,7 @@ void cik_sdma_fence_ring_emit(struct radeon_device *rdev, | |||
| 130 | * Add a DMA semaphore packet to the ring wait on or signal | 130 | * Add a DMA semaphore packet to the ring wait on or signal |
| 131 | * other rings (CIK). | 131 | * other rings (CIK). |
| 132 | */ | 132 | */ |
| 133 | void cik_sdma_semaphore_ring_emit(struct radeon_device *rdev, | 133 | bool cik_sdma_semaphore_ring_emit(struct radeon_device *rdev, |
| 134 | struct radeon_ring *ring, | 134 | struct radeon_ring *ring, |
| 135 | struct radeon_semaphore *semaphore, | 135 | struct radeon_semaphore *semaphore, |
| 136 | bool emit_wait) | 136 | bool emit_wait) |
| @@ -141,6 +141,8 @@ void cik_sdma_semaphore_ring_emit(struct radeon_device *rdev, | |||
| 141 | radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_SEMAPHORE, 0, extra_bits)); | 141 | radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_SEMAPHORE, 0, extra_bits)); |
| 142 | radeon_ring_write(ring, addr & 0xfffffff8); | 142 | radeon_ring_write(ring, addr & 0xfffffff8); |
| 143 | radeon_ring_write(ring, upper_32_bits(addr) & 0xffffffff); | 143 | radeon_ring_write(ring, upper_32_bits(addr) & 0xffffffff); |
| 144 | |||
| 145 | return true; | ||
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | /** | 148 | /** |
| @@ -443,13 +445,8 @@ int cik_copy_dma(struct radeon_device *rdev, | |||
| 443 | return r; | 445 | return r; |
| 444 | } | 446 | } |
| 445 | 447 | ||
| 446 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 448 | radeon_semaphore_sync_to(sem, *fence); |
| 447 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 449 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 448 | ring->idx); | ||
| 449 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 450 | } else { | ||
| 451 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 452 | } | ||
| 453 | 450 | ||
| 454 | for (i = 0; i < num_loops; i++) { | 451 | for (i = 0; i < num_loops; i++) { |
| 455 | cur_size_in_bytes = size_in_bytes; | 452 | cur_size_in_bytes = size_in_bytes; |
diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c index 91bb470de0a3..920e1e4a52c5 100644 --- a/drivers/gpu/drm/radeon/cypress_dpm.c +++ b/drivers/gpu/drm/radeon/cypress_dpm.c | |||
| @@ -299,7 +299,9 @@ void cypress_program_response_times(struct radeon_device *rdev) | |||
| 299 | static int cypress_pcie_performance_request(struct radeon_device *rdev, | 299 | static int cypress_pcie_performance_request(struct radeon_device *rdev, |
| 300 | u8 perf_req, bool advertise) | 300 | u8 perf_req, bool advertise) |
| 301 | { | 301 | { |
| 302 | #if defined(CONFIG_ACPI) | ||
| 302 | struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); | 303 | struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); |
| 304 | #endif | ||
| 303 | u32 tmp; | 305 | u32 tmp; |
| 304 | 306 | ||
| 305 | udelay(10); | 307 | udelay(10); |
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c index 009f46e0ce72..de86493cbc44 100644 --- a/drivers/gpu/drm/radeon/dce6_afmt.c +++ b/drivers/gpu/drm/radeon/dce6_afmt.c | |||
| @@ -93,11 +93,13 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder) | |||
| 93 | struct radeon_device *rdev = encoder->dev->dev_private; | 93 | struct radeon_device *rdev = encoder->dev->dev_private; |
| 94 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 94 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 95 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | 95 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 96 | u32 offset = dig->afmt->offset; | 96 | u32 offset; |
| 97 | 97 | ||
| 98 | if (!dig->afmt->pin) | 98 | if (!dig || !dig->afmt || !dig->afmt->pin) |
| 99 | return; | 99 | return; |
| 100 | 100 | ||
| 101 | offset = dig->afmt->offset; | ||
| 102 | |||
| 101 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, | 103 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, |
| 102 | AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); | 104 | AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); |
| 103 | } | 105 | } |
| @@ -112,7 +114,7 @@ void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, | |||
| 112 | struct radeon_connector *radeon_connector = NULL; | 114 | struct radeon_connector *radeon_connector = NULL; |
| 113 | u32 tmp = 0, offset; | 115 | u32 tmp = 0, offset; |
| 114 | 116 | ||
| 115 | if (!dig->afmt->pin) | 117 | if (!dig || !dig->afmt || !dig->afmt->pin) |
| 116 | return; | 118 | return; |
| 117 | 119 | ||
| 118 | offset = dig->afmt->pin->offset; | 120 | offset = dig->afmt->pin->offset; |
| @@ -156,7 +158,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) | |||
| 156 | u8 *sadb; | 158 | u8 *sadb; |
| 157 | int sad_count; | 159 | int sad_count; |
| 158 | 160 | ||
| 159 | if (!dig->afmt->pin) | 161 | if (!dig || !dig->afmt || !dig->afmt->pin) |
| 160 | return; | 162 | return; |
| 161 | 163 | ||
| 162 | offset = dig->afmt->pin->offset; | 164 | offset = dig->afmt->pin->offset; |
| @@ -217,7 +219,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder) | |||
| 217 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, | 219 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, |
| 218 | }; | 220 | }; |
| 219 | 221 | ||
| 220 | if (!dig->afmt->pin) | 222 | if (!dig || !dig->afmt || !dig->afmt->pin) |
| 221 | return; | 223 | return; |
| 222 | 224 | ||
| 223 | offset = dig->afmt->pin->offset; | 225 | offset = dig->afmt->pin->offset; |
diff --git a/drivers/gpu/drm/radeon/evergreen_dma.c b/drivers/gpu/drm/radeon/evergreen_dma.c index 6a0656d00ed0..a37b54436382 100644 --- a/drivers/gpu/drm/radeon/evergreen_dma.c +++ b/drivers/gpu/drm/radeon/evergreen_dma.c | |||
| @@ -131,13 +131,8 @@ int evergreen_copy_dma(struct radeon_device *rdev, | |||
| 131 | return r; | 131 | return r; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 134 | radeon_semaphore_sync_to(sem, *fence); |
| 135 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 135 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 136 | ring->idx); | ||
| 137 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 138 | } else { | ||
| 139 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 140 | } | ||
| 141 | 136 | ||
| 142 | for (i = 0; i < num_loops; i++) { | 137 | for (i = 0; i < num_loops; i++) { |
| 143 | cur_size_in_dw = size_in_dw; | 138 | cur_size_in_dw = size_in_dw; |
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c index f26339028154..49c4d48f54d6 100644 --- a/drivers/gpu/drm/radeon/ni_dpm.c +++ b/drivers/gpu/drm/radeon/ni_dpm.c | |||
| @@ -785,8 +785,8 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev, | |||
| 785 | struct ni_ps *ps = ni_get_ps(rps); | 785 | struct ni_ps *ps = ni_get_ps(rps); |
| 786 | struct radeon_clock_and_voltage_limits *max_limits; | 786 | struct radeon_clock_and_voltage_limits *max_limits; |
| 787 | bool disable_mclk_switching; | 787 | bool disable_mclk_switching; |
| 788 | u32 mclk, sclk; | 788 | u32 mclk; |
| 789 | u16 vddc, vddci; | 789 | u16 vddci; |
| 790 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; | 790 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; |
| 791 | int i; | 791 | int i; |
| 792 | 792 | ||
| @@ -839,24 +839,14 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev, | |||
| 839 | 839 | ||
| 840 | /* XXX validate the min clocks required for display */ | 840 | /* XXX validate the min clocks required for display */ |
| 841 | 841 | ||
| 842 | /* adjust low state */ | ||
| 842 | if (disable_mclk_switching) { | 843 | if (disable_mclk_switching) { |
| 843 | mclk = ps->performance_levels[ps->performance_level_count - 1].mclk; | 844 | ps->performance_levels[0].mclk = |
| 844 | sclk = ps->performance_levels[0].sclk; | 845 | ps->performance_levels[ps->performance_level_count - 1].mclk; |
| 845 | vddc = ps->performance_levels[0].vddc; | 846 | ps->performance_levels[0].vddci = |
| 846 | vddci = ps->performance_levels[ps->performance_level_count - 1].vddci; | 847 | ps->performance_levels[ps->performance_level_count - 1].vddci; |
| 847 | } else { | ||
| 848 | sclk = ps->performance_levels[0].sclk; | ||
| 849 | mclk = ps->performance_levels[0].mclk; | ||
| 850 | vddc = ps->performance_levels[0].vddc; | ||
| 851 | vddci = ps->performance_levels[0].vddci; | ||
| 852 | } | 848 | } |
| 853 | 849 | ||
| 854 | /* adjusted low state */ | ||
| 855 | ps->performance_levels[0].sclk = sclk; | ||
| 856 | ps->performance_levels[0].mclk = mclk; | ||
| 857 | ps->performance_levels[0].vddc = vddc; | ||
| 858 | ps->performance_levels[0].vddci = vddci; | ||
| 859 | |||
| 860 | btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk, | 850 | btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk, |
| 861 | &ps->performance_levels[0].sclk, | 851 | &ps->performance_levels[0].sclk, |
| 862 | &ps->performance_levels[0].mclk); | 852 | &ps->performance_levels[0].mclk); |
| @@ -868,11 +858,15 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev, | |||
| 868 | ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc; | 858 | ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc; |
| 869 | } | 859 | } |
| 870 | 860 | ||
| 861 | /* adjust remaining states */ | ||
| 871 | if (disable_mclk_switching) { | 862 | if (disable_mclk_switching) { |
| 872 | mclk = ps->performance_levels[0].mclk; | 863 | mclk = ps->performance_levels[0].mclk; |
| 864 | vddci = ps->performance_levels[0].vddci; | ||
| 873 | for (i = 1; i < ps->performance_level_count; i++) { | 865 | for (i = 1; i < ps->performance_level_count; i++) { |
| 874 | if (mclk < ps->performance_levels[i].mclk) | 866 | if (mclk < ps->performance_levels[i].mclk) |
| 875 | mclk = ps->performance_levels[i].mclk; | 867 | mclk = ps->performance_levels[i].mclk; |
| 868 | if (vddci < ps->performance_levels[i].vddci) | ||
| 869 | vddci = ps->performance_levels[i].vddci; | ||
| 876 | } | 870 | } |
| 877 | for (i = 0; i < ps->performance_level_count; i++) { | 871 | for (i = 0; i < ps->performance_level_count; i++) { |
| 878 | ps->performance_levels[i].mclk = mclk; | 872 | ps->performance_levels[i].mclk = mclk; |
| @@ -3445,9 +3439,9 @@ static int ni_enable_smc_cac(struct radeon_device *rdev, | |||
| 3445 | static int ni_pcie_performance_request(struct radeon_device *rdev, | 3439 | static int ni_pcie_performance_request(struct radeon_device *rdev, |
| 3446 | u8 perf_req, bool advertise) | 3440 | u8 perf_req, bool advertise) |
| 3447 | { | 3441 | { |
| 3442 | #if defined(CONFIG_ACPI) | ||
| 3448 | struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); | 3443 | struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); |
| 3449 | 3444 | ||
| 3450 | #if defined(CONFIG_ACPI) | ||
| 3451 | if ((perf_req == PCIE_PERF_REQ_PECI_GEN1) || | 3445 | if ((perf_req == PCIE_PERF_REQ_PECI_GEN1) || |
| 3452 | (perf_req == PCIE_PERF_REQ_PECI_GEN2)) { | 3446 | (perf_req == PCIE_PERF_REQ_PECI_GEN2)) { |
| 3453 | if (eg_pi->pcie_performance_request_registered == false) | 3447 | if (eg_pi->pcie_performance_request_registered == false) |
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index 784983d78158..10abc4d5a6cc 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
| @@ -869,13 +869,14 @@ void r100_fence_ring_emit(struct radeon_device *rdev, | |||
| 869 | radeon_ring_write(ring, RADEON_SW_INT_FIRE); | 869 | radeon_ring_write(ring, RADEON_SW_INT_FIRE); |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | void r100_semaphore_ring_emit(struct radeon_device *rdev, | 872 | bool r100_semaphore_ring_emit(struct radeon_device *rdev, |
| 873 | struct radeon_ring *ring, | 873 | struct radeon_ring *ring, |
| 874 | struct radeon_semaphore *semaphore, | 874 | struct radeon_semaphore *semaphore, |
| 875 | bool emit_wait) | 875 | bool emit_wait) |
| 876 | { | 876 | { |
| 877 | /* Unused on older asics, since we don't have semaphores or multiple rings */ | 877 | /* Unused on older asics, since we don't have semaphores or multiple rings */ |
| 878 | BUG(); | 878 | BUG(); |
| 879 | return false; | ||
| 879 | } | 880 | } |
| 880 | 881 | ||
| 881 | int r100_copy_blit(struct radeon_device *rdev, | 882 | int r100_copy_blit(struct radeon_device *rdev, |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 4e609e8a8d2b..9ad06732a78b 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
| @@ -2650,7 +2650,7 @@ void r600_fence_ring_emit(struct radeon_device *rdev, | |||
| 2650 | } | 2650 | } |
| 2651 | } | 2651 | } |
| 2652 | 2652 | ||
| 2653 | void r600_semaphore_ring_emit(struct radeon_device *rdev, | 2653 | bool r600_semaphore_ring_emit(struct radeon_device *rdev, |
| 2654 | struct radeon_ring *ring, | 2654 | struct radeon_ring *ring, |
| 2655 | struct radeon_semaphore *semaphore, | 2655 | struct radeon_semaphore *semaphore, |
| 2656 | bool emit_wait) | 2656 | bool emit_wait) |
| @@ -2664,6 +2664,8 @@ void r600_semaphore_ring_emit(struct radeon_device *rdev, | |||
| 2664 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); | 2664 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); |
| 2665 | radeon_ring_write(ring, addr & 0xffffffff); | 2665 | radeon_ring_write(ring, addr & 0xffffffff); |
| 2666 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xff) | sel); | 2666 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xff) | sel); |
| 2667 | |||
| 2668 | return true; | ||
| 2667 | } | 2669 | } |
| 2668 | 2670 | ||
| 2669 | /** | 2671 | /** |
| @@ -2706,13 +2708,8 @@ int r600_copy_cpdma(struct radeon_device *rdev, | |||
| 2706 | return r; | 2708 | return r; |
| 2707 | } | 2709 | } |
| 2708 | 2710 | ||
| 2709 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 2711 | radeon_semaphore_sync_to(sem, *fence); |
| 2710 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 2712 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 2711 | ring->idx); | ||
| 2712 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 2713 | } else { | ||
| 2714 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 2715 | } | ||
| 2716 | 2713 | ||
| 2717 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | 2714 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2718 | radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); | 2715 | radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); |
diff --git a/drivers/gpu/drm/radeon/r600_dma.c b/drivers/gpu/drm/radeon/r600_dma.c index 3b317456512a..7844d15c139f 100644 --- a/drivers/gpu/drm/radeon/r600_dma.c +++ b/drivers/gpu/drm/radeon/r600_dma.c | |||
| @@ -311,7 +311,7 @@ void r600_dma_fence_ring_emit(struct radeon_device *rdev, | |||
| 311 | * Add a DMA semaphore packet to the ring wait on or signal | 311 | * Add a DMA semaphore packet to the ring wait on or signal |
| 312 | * other rings (r6xx-SI). | 312 | * other rings (r6xx-SI). |
| 313 | */ | 313 | */ |
| 314 | void r600_dma_semaphore_ring_emit(struct radeon_device *rdev, | 314 | bool r600_dma_semaphore_ring_emit(struct radeon_device *rdev, |
| 315 | struct radeon_ring *ring, | 315 | struct radeon_ring *ring, |
| 316 | struct radeon_semaphore *semaphore, | 316 | struct radeon_semaphore *semaphore, |
| 317 | bool emit_wait) | 317 | bool emit_wait) |
| @@ -322,6 +322,8 @@ void r600_dma_semaphore_ring_emit(struct radeon_device *rdev, | |||
| 322 | radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_SEMAPHORE, 0, s, 0)); | 322 | radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_SEMAPHORE, 0, s, 0)); |
| 323 | radeon_ring_write(ring, addr & 0xfffffffc); | 323 | radeon_ring_write(ring, addr & 0xfffffffc); |
| 324 | radeon_ring_write(ring, upper_32_bits(addr) & 0xff); | 324 | radeon_ring_write(ring, upper_32_bits(addr) & 0xff); |
| 325 | |||
| 326 | return true; | ||
| 325 | } | 327 | } |
| 326 | 328 | ||
| 327 | /** | 329 | /** |
| @@ -462,13 +464,8 @@ int r600_copy_dma(struct radeon_device *rdev, | |||
| 462 | return r; | 464 | return r; |
| 463 | } | 465 | } |
| 464 | 466 | ||
| 465 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 467 | radeon_semaphore_sync_to(sem, *fence); |
| 466 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 468 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 467 | ring->idx); | ||
| 468 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 469 | } else { | ||
| 470 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 471 | } | ||
| 472 | 469 | ||
| 473 | for (i = 0; i < num_loops; i++) { | 470 | for (i = 0; i < num_loops; i++) { |
| 474 | cur_size_in_dw = size_in_dw; | 471 | cur_size_in_dw = size_in_dw; |
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c index 4b89262f3f0e..b7d3ecba43e3 100644 --- a/drivers/gpu/drm/radeon/r600_hdmi.c +++ b/drivers/gpu/drm/radeon/r600_hdmi.c | |||
| @@ -304,9 +304,9 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock) | |||
| 304 | WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo); | 304 | WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo); |
| 305 | WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ | 305 | WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ |
| 306 | } | 306 | } |
| 307 | } else if (ASIC_IS_DCE3(rdev)) { | 307 | } else { |
| 308 | /* according to the reg specs, this should DCE3.2 only, but in | 308 | /* according to the reg specs, this should DCE3.2 only, but in |
| 309 | * practice it seems to cover DCE3.0/3.1 as well. | 309 | * practice it seems to cover DCE2.0/3.0/3.1 as well. |
| 310 | */ | 310 | */ |
| 311 | if (dig->dig_encoder == 0) { | 311 | if (dig->dig_encoder == 0) { |
| 312 | WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); | 312 | WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); |
| @@ -317,10 +317,6 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock) | |||
| 317 | WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100); | 317 | WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100); |
| 318 | WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ | 318 | WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ |
| 319 | } | 319 | } |
| 320 | } else { | ||
| 321 | /* according to the reg specs, this should be DCE2.0 and DCE3.0/3.1 */ | ||
| 322 | WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) | | ||
| 323 | AUDIO_DTO_MODULE(clock / 10)); | ||
| 324 | } | 320 | } |
| 325 | } | 321 | } |
| 326 | 322 | ||
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index b9ee99258602..b1f990d0eaa1 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
| @@ -348,6 +348,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, i | |||
| 348 | void radeon_fence_process(struct radeon_device *rdev, int ring); | 348 | void radeon_fence_process(struct radeon_device *rdev, int ring); |
| 349 | bool radeon_fence_signaled(struct radeon_fence *fence); | 349 | bool radeon_fence_signaled(struct radeon_fence *fence); |
| 350 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); | 350 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); |
| 351 | int radeon_fence_wait_locked(struct radeon_fence *fence); | ||
| 351 | int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring); | 352 | int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring); |
| 352 | int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring); | 353 | int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring); |
| 353 | int radeon_fence_wait_any(struct radeon_device *rdev, | 354 | int radeon_fence_wait_any(struct radeon_device *rdev, |
| @@ -548,17 +549,20 @@ struct radeon_semaphore { | |||
| 548 | struct radeon_sa_bo *sa_bo; | 549 | struct radeon_sa_bo *sa_bo; |
| 549 | signed waiters; | 550 | signed waiters; |
| 550 | uint64_t gpu_addr; | 551 | uint64_t gpu_addr; |
| 552 | struct radeon_fence *sync_to[RADEON_NUM_RINGS]; | ||
| 551 | }; | 553 | }; |
| 552 | 554 | ||
| 553 | int radeon_semaphore_create(struct radeon_device *rdev, | 555 | int radeon_semaphore_create(struct radeon_device *rdev, |
| 554 | struct radeon_semaphore **semaphore); | 556 | struct radeon_semaphore **semaphore); |
| 555 | void radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring, | 557 | bool radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring, |
| 556 | struct radeon_semaphore *semaphore); | 558 | struct radeon_semaphore *semaphore); |
| 557 | void radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring, | 559 | bool radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring, |
| 558 | struct radeon_semaphore *semaphore); | 560 | struct radeon_semaphore *semaphore); |
| 561 | void radeon_semaphore_sync_to(struct radeon_semaphore *semaphore, | ||
| 562 | struct radeon_fence *fence); | ||
| 559 | int radeon_semaphore_sync_rings(struct radeon_device *rdev, | 563 | int radeon_semaphore_sync_rings(struct radeon_device *rdev, |
| 560 | struct radeon_semaphore *semaphore, | 564 | struct radeon_semaphore *semaphore, |
| 561 | int signaler, int waiter); | 565 | int waiting_ring); |
| 562 | void radeon_semaphore_free(struct radeon_device *rdev, | 566 | void radeon_semaphore_free(struct radeon_device *rdev, |
| 563 | struct radeon_semaphore **semaphore, | 567 | struct radeon_semaphore **semaphore, |
| 564 | struct radeon_fence *fence); | 568 | struct radeon_fence *fence); |
| @@ -645,13 +649,15 @@ void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg); | |||
| 645 | /* | 649 | /* |
| 646 | * GPU doorbell structures, functions & helpers | 650 | * GPU doorbell structures, functions & helpers |
| 647 | */ | 651 | */ |
| 652 | #define RADEON_MAX_DOORBELLS 1024 /* Reserve at most 1024 doorbell slots for radeon-owned rings. */ | ||
| 653 | |||
| 648 | struct radeon_doorbell { | 654 | struct radeon_doorbell { |
| 649 | u32 num_pages; | ||
| 650 | bool free[1024]; | ||
| 651 | /* doorbell mmio */ | 655 | /* doorbell mmio */ |
| 652 | resource_size_t base; | 656 | resource_size_t base; |
| 653 | resource_size_t size; | 657 | resource_size_t size; |
| 654 | void __iomem *ptr; | 658 | u32 __iomem *ptr; |
| 659 | u32 num_doorbells; /* Number of doorbells actually reserved for radeon. */ | ||
| 660 | unsigned long used[DIV_ROUND_UP(RADEON_MAX_DOORBELLS, BITS_PER_LONG)]; | ||
| 655 | }; | 661 | }; |
| 656 | 662 | ||
| 657 | int radeon_doorbell_get(struct radeon_device *rdev, u32 *page); | 663 | int radeon_doorbell_get(struct radeon_device *rdev, u32 *page); |
| @@ -765,7 +771,6 @@ struct radeon_ib { | |||
| 765 | struct radeon_fence *fence; | 771 | struct radeon_fence *fence; |
| 766 | struct radeon_vm *vm; | 772 | struct radeon_vm *vm; |
| 767 | bool is_const_ib; | 773 | bool is_const_ib; |
| 768 | struct radeon_fence *sync_to[RADEON_NUM_RINGS]; | ||
| 769 | struct radeon_semaphore *semaphore; | 774 | struct radeon_semaphore *semaphore; |
| 770 | }; | 775 | }; |
| 771 | 776 | ||
| @@ -799,8 +804,7 @@ struct radeon_ring { | |||
| 799 | u32 pipe; | 804 | u32 pipe; |
| 800 | u32 queue; | 805 | u32 queue; |
| 801 | struct radeon_bo *mqd_obj; | 806 | struct radeon_bo *mqd_obj; |
| 802 | u32 doorbell_page_num; | 807 | u32 doorbell_index; |
| 803 | u32 doorbell_offset; | ||
| 804 | unsigned wptr_offs; | 808 | unsigned wptr_offs; |
| 805 | }; | 809 | }; |
| 806 | 810 | ||
| @@ -921,7 +925,6 @@ int radeon_ib_get(struct radeon_device *rdev, int ring, | |||
| 921 | struct radeon_ib *ib, struct radeon_vm *vm, | 925 | struct radeon_ib *ib, struct radeon_vm *vm, |
| 922 | unsigned size); | 926 | unsigned size); |
| 923 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib); | 927 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib); |
| 924 | void radeon_ib_sync_to(struct radeon_ib *ib, struct radeon_fence *fence); | ||
| 925 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib, | 928 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib, |
| 926 | struct radeon_ib *const_ib); | 929 | struct radeon_ib *const_ib); |
| 927 | int radeon_ib_pool_init(struct radeon_device *rdev); | 930 | int radeon_ib_pool_init(struct radeon_device *rdev); |
| @@ -1638,7 +1641,7 @@ struct radeon_asic_ring { | |||
| 1638 | /* command emmit functions */ | 1641 | /* command emmit functions */ |
| 1639 | void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib); | 1642 | void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib); |
| 1640 | void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence); | 1643 | void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence); |
| 1641 | void (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp, | 1644 | bool (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp, |
| 1642 | struct radeon_semaphore *semaphore, bool emit_wait); | 1645 | struct radeon_semaphore *semaphore, bool emit_wait); |
| 1643 | void (*vm_flush)(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); | 1646 | void (*vm_flush)(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); |
| 1644 | 1647 | ||
| @@ -1979,6 +1982,7 @@ struct cik_asic { | |||
| 1979 | 1982 | ||
| 1980 | unsigned tile_config; | 1983 | unsigned tile_config; |
| 1981 | uint32_t tile_mode_array[32]; | 1984 | uint32_t tile_mode_array[32]; |
| 1985 | uint32_t macrotile_mode_array[16]; | ||
| 1982 | }; | 1986 | }; |
| 1983 | 1987 | ||
| 1984 | union radeon_asic_config { | 1988 | union radeon_asic_config { |
| @@ -2239,8 +2243,8 @@ void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v, | |||
| 2239 | u32 r100_io_rreg(struct radeon_device *rdev, u32 reg); | 2243 | u32 r100_io_rreg(struct radeon_device *rdev, u32 reg); |
| 2240 | void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v); | 2244 | void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v); |
| 2241 | 2245 | ||
| 2242 | u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset); | 2246 | u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 index); |
| 2243 | void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v); | 2247 | void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v); |
| 2244 | 2248 | ||
| 2245 | /* | 2249 | /* |
| 2246 | * Cast helper | 2250 | * Cast helper |
| @@ -2303,8 +2307,8 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v); | |||
| 2303 | #define RREG32_IO(reg) r100_io_rreg(rdev, (reg)) | 2307 | #define RREG32_IO(reg) r100_io_rreg(rdev, (reg)) |
| 2304 | #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v)) | 2308 | #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v)) |
| 2305 | 2309 | ||
| 2306 | #define RDOORBELL32(offset) cik_mm_rdoorbell(rdev, (offset)) | 2310 | #define RDOORBELL32(index) cik_mm_rdoorbell(rdev, (index)) |
| 2307 | #define WDOORBELL32(offset, v) cik_mm_wdoorbell(rdev, (offset), (v)) | 2311 | #define WDOORBELL32(index, v) cik_mm_wdoorbell(rdev, (index), (v)) |
| 2308 | 2312 | ||
| 2309 | /* | 2313 | /* |
| 2310 | * Indirect registers accessor | 2314 | * Indirect registers accessor |
| @@ -2706,10 +2710,10 @@ void radeon_vm_fence(struct radeon_device *rdev, | |||
| 2706 | struct radeon_vm *vm, | 2710 | struct radeon_vm *vm, |
| 2707 | struct radeon_fence *fence); | 2711 | struct radeon_fence *fence); |
| 2708 | uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); | 2712 | uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); |
| 2709 | int radeon_vm_bo_update_pte(struct radeon_device *rdev, | 2713 | int radeon_vm_bo_update(struct radeon_device *rdev, |
| 2710 | struct radeon_vm *vm, | 2714 | struct radeon_vm *vm, |
| 2711 | struct radeon_bo *bo, | 2715 | struct radeon_bo *bo, |
| 2712 | struct ttm_mem_reg *mem); | 2716 | struct ttm_mem_reg *mem); |
| 2713 | void radeon_vm_bo_invalidate(struct radeon_device *rdev, | 2717 | void radeon_vm_bo_invalidate(struct radeon_device *rdev, |
| 2714 | struct radeon_bo *bo); | 2718 | struct radeon_bo *bo); |
| 2715 | struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm, | 2719 | struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm, |
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c index 10f98c7742d8..98a9074b306b 100644 --- a/drivers/gpu/drm/radeon/radeon_acpi.c +++ b/drivers/gpu/drm/radeon/radeon_acpi.c | |||
| @@ -369,7 +369,7 @@ int radeon_atif_handler(struct radeon_device *rdev, | |||
| 369 | return NOTIFY_DONE; | 369 | return NOTIFY_DONE; |
| 370 | 370 | ||
| 371 | /* Check pending SBIOS requests */ | 371 | /* Check pending SBIOS requests */ |
| 372 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); | 372 | handle = ACPI_HANDLE(&rdev->pdev->dev); |
| 373 | count = radeon_atif_get_sbios_requests(handle, &req); | 373 | count = radeon_atif_get_sbios_requests(handle, &req); |
| 374 | 374 | ||
| 375 | if (count <= 0) | 375 | if (count <= 0) |
| @@ -556,7 +556,7 @@ int radeon_acpi_pcie_notify_device_ready(struct radeon_device *rdev) | |||
| 556 | struct radeon_atcs *atcs = &rdev->atcs; | 556 | struct radeon_atcs *atcs = &rdev->atcs; |
| 557 | 557 | ||
| 558 | /* Get the device handle */ | 558 | /* Get the device handle */ |
| 559 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); | 559 | handle = ACPI_HANDLE(&rdev->pdev->dev); |
| 560 | if (!handle) | 560 | if (!handle) |
| 561 | return -EINVAL; | 561 | return -EINVAL; |
| 562 | 562 | ||
| @@ -596,7 +596,7 @@ int radeon_acpi_pcie_performance_request(struct radeon_device *rdev, | |||
| 596 | u32 retry = 3; | 596 | u32 retry = 3; |
| 597 | 597 | ||
| 598 | /* Get the device handle */ | 598 | /* Get the device handle */ |
| 599 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); | 599 | handle = ACPI_HANDLE(&rdev->pdev->dev); |
| 600 | if (!handle) | 600 | if (!handle) |
| 601 | return -EINVAL; | 601 | return -EINVAL; |
| 602 | 602 | ||
| @@ -699,7 +699,7 @@ int radeon_acpi_init(struct radeon_device *rdev) | |||
| 699 | int ret; | 699 | int ret; |
| 700 | 700 | ||
| 701 | /* Get the device handle */ | 701 | /* Get the device handle */ |
| 702 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); | 702 | handle = ACPI_HANDLE(&rdev->pdev->dev); |
| 703 | 703 | ||
| 704 | /* No need to proceed if we're sure that ATIF is not supported */ | 704 | /* No need to proceed if we're sure that ATIF is not supported */ |
| 705 | if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle) | 705 | if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle) |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index 50853c0cb49d..e354ce94cdd1 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c | |||
| @@ -2015,6 +2015,8 @@ static struct radeon_asic ci_asic = { | |||
| 2015 | .bandwidth_update = &dce8_bandwidth_update, | 2015 | .bandwidth_update = &dce8_bandwidth_update, |
| 2016 | .get_vblank_counter = &evergreen_get_vblank_counter, | 2016 | .get_vblank_counter = &evergreen_get_vblank_counter, |
| 2017 | .wait_for_vblank = &dce4_wait_for_vblank, | 2017 | .wait_for_vblank = &dce4_wait_for_vblank, |
| 2018 | .set_backlight_level = &atombios_set_backlight_level, | ||
| 2019 | .get_backlight_level = &atombios_get_backlight_level, | ||
| 2018 | .hdmi_enable = &evergreen_hdmi_enable, | 2020 | .hdmi_enable = &evergreen_hdmi_enable, |
| 2019 | .hdmi_setmode = &evergreen_hdmi_setmode, | 2021 | .hdmi_setmode = &evergreen_hdmi_setmode, |
| 2020 | }, | 2022 | }, |
| @@ -2114,6 +2116,8 @@ static struct radeon_asic kv_asic = { | |||
| 2114 | .bandwidth_update = &dce8_bandwidth_update, | 2116 | .bandwidth_update = &dce8_bandwidth_update, |
| 2115 | .get_vblank_counter = &evergreen_get_vblank_counter, | 2117 | .get_vblank_counter = &evergreen_get_vblank_counter, |
| 2116 | .wait_for_vblank = &dce4_wait_for_vblank, | 2118 | .wait_for_vblank = &dce4_wait_for_vblank, |
| 2119 | .set_backlight_level = &atombios_set_backlight_level, | ||
| 2120 | .get_backlight_level = &atombios_get_backlight_level, | ||
| 2117 | .hdmi_enable = &evergreen_hdmi_enable, | 2121 | .hdmi_enable = &evergreen_hdmi_enable, |
| 2118 | .hdmi_setmode = &evergreen_hdmi_setmode, | 2122 | .hdmi_setmode = &evergreen_hdmi_setmode, |
| 2119 | }, | 2123 | }, |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index f2833ee3a613..c9fd97b58076 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h | |||
| @@ -80,7 +80,7 @@ int r100_irq_set(struct radeon_device *rdev); | |||
| 80 | int r100_irq_process(struct radeon_device *rdev); | 80 | int r100_irq_process(struct radeon_device *rdev); |
| 81 | void r100_fence_ring_emit(struct radeon_device *rdev, | 81 | void r100_fence_ring_emit(struct radeon_device *rdev, |
| 82 | struct radeon_fence *fence); | 82 | struct radeon_fence *fence); |
| 83 | void r100_semaphore_ring_emit(struct radeon_device *rdev, | 83 | bool r100_semaphore_ring_emit(struct radeon_device *rdev, |
| 84 | struct radeon_ring *cp, | 84 | struct radeon_ring *cp, |
| 85 | struct radeon_semaphore *semaphore, | 85 | struct radeon_semaphore *semaphore, |
| 86 | bool emit_wait); | 86 | bool emit_wait); |
| @@ -313,13 +313,13 @@ int r600_cs_parse(struct radeon_cs_parser *p); | |||
| 313 | int r600_dma_cs_parse(struct radeon_cs_parser *p); | 313 | int r600_dma_cs_parse(struct radeon_cs_parser *p); |
| 314 | void r600_fence_ring_emit(struct radeon_device *rdev, | 314 | void r600_fence_ring_emit(struct radeon_device *rdev, |
| 315 | struct radeon_fence *fence); | 315 | struct radeon_fence *fence); |
| 316 | void r600_semaphore_ring_emit(struct radeon_device *rdev, | 316 | bool r600_semaphore_ring_emit(struct radeon_device *rdev, |
| 317 | struct radeon_ring *cp, | 317 | struct radeon_ring *cp, |
| 318 | struct radeon_semaphore *semaphore, | 318 | struct radeon_semaphore *semaphore, |
| 319 | bool emit_wait); | 319 | bool emit_wait); |
| 320 | void r600_dma_fence_ring_emit(struct radeon_device *rdev, | 320 | void r600_dma_fence_ring_emit(struct radeon_device *rdev, |
| 321 | struct radeon_fence *fence); | 321 | struct radeon_fence *fence); |
| 322 | void r600_dma_semaphore_ring_emit(struct radeon_device *rdev, | 322 | bool r600_dma_semaphore_ring_emit(struct radeon_device *rdev, |
| 323 | struct radeon_ring *ring, | 323 | struct radeon_ring *ring, |
| 324 | struct radeon_semaphore *semaphore, | 324 | struct radeon_semaphore *semaphore, |
| 325 | bool emit_wait); | 325 | bool emit_wait); |
| @@ -566,10 +566,6 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev, | |||
| 566 | */ | 566 | */ |
| 567 | void cayman_fence_ring_emit(struct radeon_device *rdev, | 567 | void cayman_fence_ring_emit(struct radeon_device *rdev, |
| 568 | struct radeon_fence *fence); | 568 | struct radeon_fence *fence); |
| 569 | void cayman_uvd_semaphore_emit(struct radeon_device *rdev, | ||
| 570 | struct radeon_ring *ring, | ||
| 571 | struct radeon_semaphore *semaphore, | ||
| 572 | bool emit_wait); | ||
| 573 | void cayman_pcie_gart_tlb_flush(struct radeon_device *rdev); | 569 | void cayman_pcie_gart_tlb_flush(struct radeon_device *rdev); |
| 574 | int cayman_init(struct radeon_device *rdev); | 570 | int cayman_init(struct radeon_device *rdev); |
| 575 | void cayman_fini(struct radeon_device *rdev); | 571 | void cayman_fini(struct radeon_device *rdev); |
| @@ -697,7 +693,7 @@ void cik_pciep_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); | |||
| 697 | int cik_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk); | 693 | int cik_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk); |
| 698 | void cik_sdma_fence_ring_emit(struct radeon_device *rdev, | 694 | void cik_sdma_fence_ring_emit(struct radeon_device *rdev, |
| 699 | struct radeon_fence *fence); | 695 | struct radeon_fence *fence); |
| 700 | void cik_sdma_semaphore_ring_emit(struct radeon_device *rdev, | 696 | bool cik_sdma_semaphore_ring_emit(struct radeon_device *rdev, |
| 701 | struct radeon_ring *ring, | 697 | struct radeon_ring *ring, |
| 702 | struct radeon_semaphore *semaphore, | 698 | struct radeon_semaphore *semaphore, |
| 703 | bool emit_wait); | 699 | bool emit_wait); |
| @@ -717,7 +713,7 @@ void cik_fence_gfx_ring_emit(struct radeon_device *rdev, | |||
| 717 | struct radeon_fence *fence); | 713 | struct radeon_fence *fence); |
| 718 | void cik_fence_compute_ring_emit(struct radeon_device *rdev, | 714 | void cik_fence_compute_ring_emit(struct radeon_device *rdev, |
| 719 | struct radeon_fence *fence); | 715 | struct radeon_fence *fence); |
| 720 | void cik_semaphore_ring_emit(struct radeon_device *rdev, | 716 | bool cik_semaphore_ring_emit(struct radeon_device *rdev, |
| 721 | struct radeon_ring *cp, | 717 | struct radeon_ring *cp, |
| 722 | struct radeon_semaphore *semaphore, | 718 | struct radeon_semaphore *semaphore, |
| 723 | bool emit_wait); | 719 | bool emit_wait); |
| @@ -807,7 +803,7 @@ void uvd_v1_0_stop(struct radeon_device *rdev); | |||
| 807 | 803 | ||
| 808 | int uvd_v1_0_ring_test(struct radeon_device *rdev, struct radeon_ring *ring); | 804 | int uvd_v1_0_ring_test(struct radeon_device *rdev, struct radeon_ring *ring); |
| 809 | int uvd_v1_0_ib_test(struct radeon_device *rdev, struct radeon_ring *ring); | 805 | int uvd_v1_0_ib_test(struct radeon_device *rdev, struct radeon_ring *ring); |
| 810 | void uvd_v1_0_semaphore_emit(struct radeon_device *rdev, | 806 | bool uvd_v1_0_semaphore_emit(struct radeon_device *rdev, |
| 811 | struct radeon_ring *ring, | 807 | struct radeon_ring *ring, |
| 812 | struct radeon_semaphore *semaphore, | 808 | struct radeon_semaphore *semaphore, |
| 813 | bool emit_wait); | 809 | bool emit_wait); |
| @@ -819,7 +815,7 @@ void uvd_v2_2_fence_emit(struct radeon_device *rdev, | |||
| 819 | struct radeon_fence *fence); | 815 | struct radeon_fence *fence); |
| 820 | 816 | ||
| 821 | /* uvd v3.1 */ | 817 | /* uvd v3.1 */ |
| 822 | void uvd_v3_1_semaphore_emit(struct radeon_device *rdev, | 818 | bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev, |
| 823 | struct radeon_ring *ring, | 819 | struct radeon_ring *ring, |
| 824 | struct radeon_semaphore *semaphore, | 820 | struct radeon_semaphore *semaphore, |
| 825 | bool emit_wait); | 821 | bool emit_wait); |
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index f79ee184ffd5..5c39bf7c3d88 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c | |||
| @@ -2918,7 +2918,7 @@ int radeon_atom_get_memory_pll_dividers(struct radeon_device *rdev, | |||
| 2918 | mpll_param->dll_speed = args.ucDllSpeed; | 2918 | mpll_param->dll_speed = args.ucDllSpeed; |
| 2919 | mpll_param->bwcntl = args.ucBWCntl; | 2919 | mpll_param->bwcntl = args.ucBWCntl; |
| 2920 | mpll_param->vco_mode = | 2920 | mpll_param->vco_mode = |
| 2921 | (args.ucPllCntlFlag & MPLL_CNTL_FLAG_VCO_MODE_MASK) ? 1 : 0; | 2921 | (args.ucPllCntlFlag & MPLL_CNTL_FLAG_VCO_MODE_MASK); |
| 2922 | mpll_param->yclk_sel = | 2922 | mpll_param->yclk_sel = |
| 2923 | (args.ucPllCntlFlag & MPLL_CNTL_FLAG_BYPASS_DQ_PLL) ? 1 : 0; | 2923 | (args.ucPllCntlFlag & MPLL_CNTL_FLAG_BYPASS_DQ_PLL) ? 1 : 0; |
| 2924 | mpll_param->qdr = | 2924 | mpll_param->qdr = |
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c index 6153ec18943a..9d302eaeea15 100644 --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c | |||
| @@ -8,8 +8,7 @@ | |||
| 8 | */ | 8 | */ |
| 9 | #include <linux/vga_switcheroo.h> | 9 | #include <linux/vga_switcheroo.h> |
| 10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
| 11 | #include <acpi/acpi.h> | 11 | #include <linux/acpi.h> |
| 12 | #include <acpi/acpi_bus.h> | ||
| 13 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
| 14 | 13 | ||
| 15 | #include "radeon_acpi.h" | 14 | #include "radeon_acpi.h" |
| @@ -447,7 +446,7 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) | |||
| 447 | acpi_handle dhandle, atpx_handle; | 446 | acpi_handle dhandle, atpx_handle; |
| 448 | acpi_status status; | 447 | acpi_status status; |
| 449 | 448 | ||
| 450 | dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); | 449 | dhandle = ACPI_HANDLE(&pdev->dev); |
| 451 | if (!dhandle) | 450 | if (!dhandle) |
| 452 | return false; | 451 | return false; |
| 453 | 452 | ||
| @@ -493,7 +492,7 @@ static int radeon_atpx_init(void) | |||
| 493 | */ | 492 | */ |
| 494 | static int radeon_atpx_get_client_id(struct pci_dev *pdev) | 493 | static int radeon_atpx_get_client_id(struct pci_dev *pdev) |
| 495 | { | 494 | { |
| 496 | if (radeon_atpx_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev)) | 495 | if (radeon_atpx_priv.dhandle == ACPI_HANDLE(&pdev->dev)) |
| 497 | return VGA_SWITCHEROO_IGD; | 496 | return VGA_SWITCHEROO_IGD; |
| 498 | else | 497 | else |
| 499 | return VGA_SWITCHEROO_DIS; | 498 | return VGA_SWITCHEROO_DIS; |
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c index c155d6f3fa68..b3633d9a5317 100644 --- a/drivers/gpu/drm/radeon/radeon_bios.c +++ b/drivers/gpu/drm/radeon/radeon_bios.c | |||
| @@ -185,7 +185,7 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev) | |||
| 185 | return false; | 185 | return false; |
| 186 | 186 | ||
| 187 | while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { | 187 | while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { |
| 188 | dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); | 188 | dhandle = ACPI_HANDLE(&pdev->dev); |
| 189 | if (!dhandle) | 189 | if (!dhandle) |
| 190 | continue; | 190 | continue; |
| 191 | 191 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 26ca223d12d6..0b366169d64d 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
| @@ -159,7 +159,8 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p) | |||
| 159 | if (!p->relocs[i].robj) | 159 | if (!p->relocs[i].robj) |
| 160 | continue; | 160 | continue; |
| 161 | 161 | ||
| 162 | radeon_ib_sync_to(&p->ib, p->relocs[i].robj->tbo.sync_obj); | 162 | radeon_semaphore_sync_to(p->ib.semaphore, |
| 163 | p->relocs[i].robj->tbo.sync_obj); | ||
| 163 | } | 164 | } |
| 164 | } | 165 | } |
| 165 | 166 | ||
| @@ -359,13 +360,13 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *parser, | |||
| 359 | struct radeon_bo *bo; | 360 | struct radeon_bo *bo; |
| 360 | int r; | 361 | int r; |
| 361 | 362 | ||
| 362 | r = radeon_vm_bo_update_pte(rdev, vm, rdev->ring_tmp_bo.bo, &rdev->ring_tmp_bo.bo->tbo.mem); | 363 | r = radeon_vm_bo_update(rdev, vm, rdev->ring_tmp_bo.bo, &rdev->ring_tmp_bo.bo->tbo.mem); |
| 363 | if (r) { | 364 | if (r) { |
| 364 | return r; | 365 | return r; |
| 365 | } | 366 | } |
| 366 | list_for_each_entry(lobj, &parser->validated, tv.head) { | 367 | list_for_each_entry(lobj, &parser->validated, tv.head) { |
| 367 | bo = lobj->bo; | 368 | bo = lobj->bo; |
| 368 | r = radeon_vm_bo_update_pte(parser->rdev, vm, bo, &bo->tbo.mem); | 369 | r = radeon_vm_bo_update(parser->rdev, vm, bo, &bo->tbo.mem); |
| 369 | if (r) { | 370 | if (r) { |
| 370 | return r; | 371 | return r; |
| 371 | } | 372 | } |
| @@ -411,9 +412,9 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, | |||
| 411 | goto out; | 412 | goto out; |
| 412 | } | 413 | } |
| 413 | radeon_cs_sync_rings(parser); | 414 | radeon_cs_sync_rings(parser); |
| 414 | radeon_ib_sync_to(&parser->ib, vm->fence); | 415 | radeon_semaphore_sync_to(parser->ib.semaphore, vm->fence); |
| 415 | radeon_ib_sync_to(&parser->ib, radeon_vm_grab_id( | 416 | radeon_semaphore_sync_to(parser->ib.semaphore, |
| 416 | rdev, vm, parser->ring)); | 417 | radeon_vm_grab_id(rdev, vm, parser->ring)); |
| 417 | 418 | ||
| 418 | if ((rdev->family >= CHIP_TAHITI) && | 419 | if ((rdev->family >= CHIP_TAHITI) && |
| 419 | (parser->chunk_const_ib_idx != -1)) { | 420 | (parser->chunk_const_ib_idx != -1)) { |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index b9234c43f43d..39b033b441d2 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
| @@ -251,28 +251,23 @@ void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg) | |||
| 251 | */ | 251 | */ |
| 252 | int radeon_doorbell_init(struct radeon_device *rdev) | 252 | int radeon_doorbell_init(struct radeon_device *rdev) |
| 253 | { | 253 | { |
| 254 | int i; | ||
| 255 | |||
| 256 | /* doorbell bar mapping */ | 254 | /* doorbell bar mapping */ |
| 257 | rdev->doorbell.base = pci_resource_start(rdev->pdev, 2); | 255 | rdev->doorbell.base = pci_resource_start(rdev->pdev, 2); |
| 258 | rdev->doorbell.size = pci_resource_len(rdev->pdev, 2); | 256 | rdev->doorbell.size = pci_resource_len(rdev->pdev, 2); |
| 259 | 257 | ||
| 260 | /* limit to 4 MB for now */ | 258 | rdev->doorbell.num_doorbells = min_t(u32, rdev->doorbell.size / sizeof(u32), RADEON_MAX_DOORBELLS); |
| 261 | if (rdev->doorbell.size > (4 * 1024 * 1024)) | 259 | if (rdev->doorbell.num_doorbells == 0) |
| 262 | rdev->doorbell.size = 4 * 1024 * 1024; | 260 | return -EINVAL; |
| 263 | 261 | ||
| 264 | rdev->doorbell.ptr = ioremap(rdev->doorbell.base, rdev->doorbell.size); | 262 | rdev->doorbell.ptr = ioremap(rdev->doorbell.base, rdev->doorbell.num_doorbells * sizeof(u32)); |
| 265 | if (rdev->doorbell.ptr == NULL) { | 263 | if (rdev->doorbell.ptr == NULL) { |
| 266 | return -ENOMEM; | 264 | return -ENOMEM; |
| 267 | } | 265 | } |
| 268 | DRM_INFO("doorbell mmio base: 0x%08X\n", (uint32_t)rdev->doorbell.base); | 266 | DRM_INFO("doorbell mmio base: 0x%08X\n", (uint32_t)rdev->doorbell.base); |
| 269 | DRM_INFO("doorbell mmio size: %u\n", (unsigned)rdev->doorbell.size); | 267 | DRM_INFO("doorbell mmio size: %u\n", (unsigned)rdev->doorbell.size); |
| 270 | 268 | ||
| 271 | rdev->doorbell.num_pages = rdev->doorbell.size / PAGE_SIZE; | 269 | memset(&rdev->doorbell.used, 0, sizeof(rdev->doorbell.used)); |
| 272 | 270 | ||
| 273 | for (i = 0; i < rdev->doorbell.num_pages; i++) { | ||
| 274 | rdev->doorbell.free[i] = true; | ||
| 275 | } | ||
| 276 | return 0; | 271 | return 0; |
| 277 | } | 272 | } |
| 278 | 273 | ||
| @@ -290,40 +285,38 @@ void radeon_doorbell_fini(struct radeon_device *rdev) | |||
| 290 | } | 285 | } |
| 291 | 286 | ||
| 292 | /** | 287 | /** |
| 293 | * radeon_doorbell_get - Allocate a doorbell page | 288 | * radeon_doorbell_get - Allocate a doorbell entry |
| 294 | * | 289 | * |
| 295 | * @rdev: radeon_device pointer | 290 | * @rdev: radeon_device pointer |
| 296 | * @doorbell: doorbell page number | 291 | * @doorbell: doorbell index |
| 297 | * | 292 | * |
| 298 | * Allocate a doorbell page for use by the driver (all asics). | 293 | * Allocate a doorbell for use by the driver (all asics). |
| 299 | * Returns 0 on success or -EINVAL on failure. | 294 | * Returns 0 on success or -EINVAL on failure. |
| 300 | */ | 295 | */ |
| 301 | int radeon_doorbell_get(struct radeon_device *rdev, u32 *doorbell) | 296 | int radeon_doorbell_get(struct radeon_device *rdev, u32 *doorbell) |
| 302 | { | 297 | { |
| 303 | int i; | 298 | unsigned long offset = find_first_zero_bit(rdev->doorbell.used, rdev->doorbell.num_doorbells); |
| 304 | 299 | if (offset < rdev->doorbell.num_doorbells) { | |
| 305 | for (i = 0; i < rdev->doorbell.num_pages; i++) { | 300 | __set_bit(offset, rdev->doorbell.used); |
| 306 | if (rdev->doorbell.free[i]) { | 301 | *doorbell = offset; |
| 307 | rdev->doorbell.free[i] = false; | 302 | return 0; |
| 308 | *doorbell = i; | 303 | } else { |
| 309 | return 0; | 304 | return -EINVAL; |
| 310 | } | ||
| 311 | } | 305 | } |
| 312 | return -EINVAL; | ||
| 313 | } | 306 | } |
| 314 | 307 | ||
| 315 | /** | 308 | /** |
| 316 | * radeon_doorbell_free - Free a doorbell page | 309 | * radeon_doorbell_free - Free a doorbell entry |
| 317 | * | 310 | * |
| 318 | * @rdev: radeon_device pointer | 311 | * @rdev: radeon_device pointer |
| 319 | * @doorbell: doorbell page number | 312 | * @doorbell: doorbell index |
| 320 | * | 313 | * |
| 321 | * Free a doorbell page allocated for use by the driver (all asics) | 314 | * Free a doorbell allocated for use by the driver (all asics) |
| 322 | */ | 315 | */ |
| 323 | void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell) | 316 | void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell) |
| 324 | { | 317 | { |
| 325 | if (doorbell < rdev->doorbell.num_pages) | 318 | if (doorbell < rdev->doorbell.num_doorbells) |
| 326 | rdev->doorbell.free[doorbell] = true; | 319 | __clear_bit(doorbell, rdev->doorbell.used); |
| 327 | } | 320 | } |
| 328 | 321 | ||
| 329 | /* | 322 | /* |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 1aee32213f66..9f5ff28864f6 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
| @@ -76,9 +76,10 @@ | |||
| 76 | * 2.32.0 - new info request for rings working | 76 | * 2.32.0 - new info request for rings working |
| 77 | * 2.33.0 - Add SI tiling mode array query | 77 | * 2.33.0 - Add SI tiling mode array query |
| 78 | * 2.34.0 - Add CIK tiling mode array query | 78 | * 2.34.0 - Add CIK tiling mode array query |
| 79 | * 2.35.0 - Add CIK macrotile mode array query | ||
| 79 | */ | 80 | */ |
| 80 | #define KMS_DRIVER_MAJOR 2 | 81 | #define KMS_DRIVER_MAJOR 2 |
| 81 | #define KMS_DRIVER_MINOR 34 | 82 | #define KMS_DRIVER_MINOR 35 |
| 82 | #define KMS_DRIVER_PATCHLEVEL 0 | 83 | #define KMS_DRIVER_PATCHLEVEL 0 |
| 83 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags); | 84 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags); |
| 84 | int radeon_driver_unload_kms(struct drm_device *dev); | 85 | int radeon_driver_unload_kms(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h index 543dcfae7e6f..00e0d449021c 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.h +++ b/drivers/gpu/drm/radeon/radeon_drv.h | |||
| @@ -108,9 +108,10 @@ | |||
| 108 | * 1.31- Add support for num Z pipes from GET_PARAM | 108 | * 1.31- Add support for num Z pipes from GET_PARAM |
| 109 | * 1.32- fixes for rv740 setup | 109 | * 1.32- fixes for rv740 setup |
| 110 | * 1.33- Add r6xx/r7xx const buffer support | 110 | * 1.33- Add r6xx/r7xx const buffer support |
| 111 | * 1.34- fix evergreen/cayman GS register | ||
| 111 | */ | 112 | */ |
| 112 | #define DRIVER_MAJOR 1 | 113 | #define DRIVER_MAJOR 1 |
| 113 | #define DRIVER_MINOR 33 | 114 | #define DRIVER_MINOR 34 |
| 114 | #define DRIVER_PATCHLEVEL 0 | 115 | #define DRIVER_PATCHLEVEL 0 |
| 115 | 116 | ||
| 116 | long radeon_drm_ioctl(struct file *filp, | 117 | long radeon_drm_ioctl(struct file *filp, |
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c index 281d14c22a47..d3a86e43c012 100644 --- a/drivers/gpu/drm/radeon/radeon_fence.c +++ b/drivers/gpu/drm/radeon/radeon_fence.c | |||
| @@ -472,6 +472,36 @@ int radeon_fence_wait_any(struct radeon_device *rdev, | |||
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | /** | 474 | /** |
| 475 | * radeon_fence_wait_locked - wait for a fence to signal | ||
| 476 | * | ||
| 477 | * @fence: radeon fence object | ||
| 478 | * | ||
| 479 | * Wait for the requested fence to signal (all asics). | ||
| 480 | * Returns 0 if the fence has passed, error for all other cases. | ||
| 481 | */ | ||
| 482 | int radeon_fence_wait_locked(struct radeon_fence *fence) | ||
| 483 | { | ||
| 484 | uint64_t seq[RADEON_NUM_RINGS] = {}; | ||
| 485 | int r; | ||
| 486 | |||
| 487 | if (fence == NULL) { | ||
| 488 | WARN(1, "Querying an invalid fence : %p !\n", fence); | ||
| 489 | return -EINVAL; | ||
| 490 | } | ||
| 491 | |||
| 492 | seq[fence->ring] = fence->seq; | ||
| 493 | if (seq[fence->ring] == RADEON_FENCE_SIGNALED_SEQ) | ||
| 494 | return 0; | ||
| 495 | |||
| 496 | r = radeon_fence_wait_seq(fence->rdev, seq, false, false); | ||
| 497 | if (r) | ||
| 498 | return r; | ||
| 499 | |||
| 500 | fence->seq = RADEON_FENCE_SIGNALED_SEQ; | ||
| 501 | return 0; | ||
| 502 | } | ||
| 503 | |||
| 504 | /** | ||
| 475 | * radeon_fence_wait_next_locked - wait for the next fence to signal | 505 | * radeon_fence_wait_next_locked - wait for the next fence to signal |
| 476 | * | 506 | * |
| 477 | * @rdev: radeon device pointer | 507 | * @rdev: radeon device pointer |
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 8a83b89d4709..96e440061bdb 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <drm/radeon_drm.h> | 29 | #include <drm/radeon_drm.h> |
| 30 | #include "radeon.h" | 30 | #include "radeon.h" |
| 31 | #include "radeon_reg.h" | 31 | #include "radeon_reg.h" |
| 32 | #include "radeon_trace.h" | ||
| 32 | 33 | ||
| 33 | /* | 34 | /* |
| 34 | * GART | 35 | * GART |
| @@ -651,7 +652,7 @@ retry: | |||
| 651 | radeon_asic_vm_set_page(rdev, &ib, vm->pd_gpu_addr, | 652 | radeon_asic_vm_set_page(rdev, &ib, vm->pd_gpu_addr, |
| 652 | 0, pd_entries, 0, 0); | 653 | 0, pd_entries, 0, 0); |
| 653 | 654 | ||
| 654 | radeon_ib_sync_to(&ib, vm->fence); | 655 | radeon_semaphore_sync_to(ib.semaphore, vm->fence); |
| 655 | r = radeon_ib_schedule(rdev, &ib, NULL); | 656 | r = radeon_ib_schedule(rdev, &ib, NULL); |
| 656 | if (r) { | 657 | if (r) { |
| 657 | radeon_ib_free(rdev, &ib); | 658 | radeon_ib_free(rdev, &ib); |
| @@ -737,6 +738,7 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev, | |||
| 737 | for (i = 0; i < 2; ++i) { | 738 | for (i = 0; i < 2; ++i) { |
| 738 | if (choices[i]) { | 739 | if (choices[i]) { |
| 739 | vm->id = choices[i]; | 740 | vm->id = choices[i]; |
| 741 | trace_radeon_vm_grab_id(vm->id, ring); | ||
| 740 | return rdev->vm_manager.active[choices[i]]; | 742 | return rdev->vm_manager.active[choices[i]]; |
| 741 | } | 743 | } |
| 742 | } | 744 | } |
| @@ -1116,7 +1118,7 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev, | |||
| 1116 | } | 1118 | } |
| 1117 | 1119 | ||
| 1118 | /** | 1120 | /** |
| 1119 | * radeon_vm_bo_update_pte - map a bo into the vm page table | 1121 | * radeon_vm_bo_update - map a bo into the vm page table |
| 1120 | * | 1122 | * |
| 1121 | * @rdev: radeon_device pointer | 1123 | * @rdev: radeon_device pointer |
| 1122 | * @vm: requested vm | 1124 | * @vm: requested vm |
| @@ -1128,10 +1130,10 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev, | |||
| 1128 | * | 1130 | * |
| 1129 | * Object have to be reserved & global and local mutex must be locked! | 1131 | * Object have to be reserved & global and local mutex must be locked! |
| 1130 | */ | 1132 | */ |
| 1131 | int radeon_vm_bo_update_pte(struct radeon_device *rdev, | 1133 | int radeon_vm_bo_update(struct radeon_device *rdev, |
| 1132 | struct radeon_vm *vm, | 1134 | struct radeon_vm *vm, |
| 1133 | struct radeon_bo *bo, | 1135 | struct radeon_bo *bo, |
| 1134 | struct ttm_mem_reg *mem) | 1136 | struct ttm_mem_reg *mem) |
| 1135 | { | 1137 | { |
| 1136 | struct radeon_ib ib; | 1138 | struct radeon_ib ib; |
| 1137 | struct radeon_bo_va *bo_va; | 1139 | struct radeon_bo_va *bo_va; |
| @@ -1176,6 +1178,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev, | |||
| 1176 | bo_va->valid = false; | 1178 | bo_va->valid = false; |
| 1177 | } | 1179 | } |
| 1178 | 1180 | ||
| 1181 | trace_radeon_vm_bo_update(bo_va); | ||
| 1182 | |||
| 1179 | nptes = radeon_bo_ngpu_pages(bo); | 1183 | nptes = radeon_bo_ngpu_pages(bo); |
| 1180 | 1184 | ||
| 1181 | /* assume two extra pdes in case the mapping overlaps the borders */ | 1185 | /* assume two extra pdes in case the mapping overlaps the borders */ |
| @@ -1209,6 +1213,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev, | |||
| 1209 | return -ENOMEM; | 1213 | return -ENOMEM; |
| 1210 | 1214 | ||
| 1211 | r = radeon_ib_get(rdev, R600_RING_TYPE_DMA_INDEX, &ib, NULL, ndw * 4); | 1215 | r = radeon_ib_get(rdev, R600_RING_TYPE_DMA_INDEX, &ib, NULL, ndw * 4); |
| 1216 | if (r) | ||
| 1217 | return r; | ||
| 1212 | ib.length_dw = 0; | 1218 | ib.length_dw = 0; |
| 1213 | 1219 | ||
| 1214 | r = radeon_vm_update_pdes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset); | 1220 | r = radeon_vm_update_pdes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset); |
| @@ -1220,7 +1226,7 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev, | |||
| 1220 | radeon_vm_update_ptes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset, | 1226 | radeon_vm_update_ptes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset, |
| 1221 | addr, radeon_vm_page_flags(bo_va->flags)); | 1227 | addr, radeon_vm_page_flags(bo_va->flags)); |
| 1222 | 1228 | ||
| 1223 | radeon_ib_sync_to(&ib, vm->fence); | 1229 | radeon_semaphore_sync_to(ib.semaphore, vm->fence); |
| 1224 | r = radeon_ib_schedule(rdev, &ib, NULL); | 1230 | r = radeon_ib_schedule(rdev, &ib, NULL); |
| 1225 | if (r) { | 1231 | if (r) { |
| 1226 | radeon_ib_free(rdev, &ib); | 1232 | radeon_ib_free(rdev, &ib); |
| @@ -1255,7 +1261,7 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev, | |||
| 1255 | mutex_lock(&rdev->vm_manager.lock); | 1261 | mutex_lock(&rdev->vm_manager.lock); |
| 1256 | mutex_lock(&bo_va->vm->mutex); | 1262 | mutex_lock(&bo_va->vm->mutex); |
| 1257 | if (bo_va->soffset) { | 1263 | if (bo_va->soffset) { |
| 1258 | r = radeon_vm_bo_update_pte(rdev, bo_va->vm, bo_va->bo, NULL); | 1264 | r = radeon_vm_bo_update(rdev, bo_va->vm, bo_va->bo, NULL); |
| 1259 | } | 1265 | } |
| 1260 | mutex_unlock(&rdev->vm_manager.lock); | 1266 | mutex_unlock(&rdev->vm_manager.lock); |
| 1261 | list_del(&bo_va->vm_list); | 1267 | list_del(&bo_va->vm_list); |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index bb8710531a1b..55d0b474bd37 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
| @@ -340,7 +340,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
| 340 | break; | 340 | break; |
| 341 | case RADEON_INFO_BACKEND_MAP: | 341 | case RADEON_INFO_BACKEND_MAP: |
| 342 | if (rdev->family >= CHIP_BONAIRE) | 342 | if (rdev->family >= CHIP_BONAIRE) |
| 343 | return -EINVAL; | 343 | *value = rdev->config.cik.backend_map; |
| 344 | else if (rdev->family >= CHIP_TAHITI) | 344 | else if (rdev->family >= CHIP_TAHITI) |
| 345 | *value = rdev->config.si.backend_map; | 345 | *value = rdev->config.si.backend_map; |
| 346 | else if (rdev->family >= CHIP_CAYMAN) | 346 | else if (rdev->family >= CHIP_CAYMAN) |
| @@ -449,6 +449,15 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
| 449 | return -EINVAL; | 449 | return -EINVAL; |
| 450 | } | 450 | } |
| 451 | break; | 451 | break; |
| 452 | case RADEON_INFO_CIK_MACROTILE_MODE_ARRAY: | ||
| 453 | if (rdev->family >= CHIP_BONAIRE) { | ||
| 454 | value = rdev->config.cik.macrotile_mode_array; | ||
| 455 | value_size = sizeof(uint32_t)*16; | ||
| 456 | } else { | ||
| 457 | DRM_DEBUG_KMS("macrotile mode array is cik+ only!\n"); | ||
| 458 | return -EINVAL; | ||
| 459 | } | ||
| 460 | break; | ||
| 452 | case RADEON_INFO_SI_CP_DMA_COMPUTE: | 461 | case RADEON_INFO_SI_CP_DMA_COMPUTE: |
| 453 | *value = 1; | 462 | *value = 1; |
| 454 | break; | 463 | break; |
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c index 0c7b8c66301b..0b158f98d287 100644 --- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c +++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c | |||
| @@ -422,6 +422,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc, | |||
| 422 | /* Pin framebuffer & get tilling informations */ | 422 | /* Pin framebuffer & get tilling informations */ |
| 423 | obj = radeon_fb->obj; | 423 | obj = radeon_fb->obj; |
| 424 | rbo = gem_to_radeon_bo(obj); | 424 | rbo = gem_to_radeon_bo(obj); |
| 425 | retry: | ||
| 425 | r = radeon_bo_reserve(rbo, false); | 426 | r = radeon_bo_reserve(rbo, false); |
| 426 | if (unlikely(r != 0)) | 427 | if (unlikely(r != 0)) |
| 427 | return r; | 428 | return r; |
| @@ -430,6 +431,33 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc, | |||
| 430 | &base); | 431 | &base); |
| 431 | if (unlikely(r != 0)) { | 432 | if (unlikely(r != 0)) { |
| 432 | radeon_bo_unreserve(rbo); | 433 | radeon_bo_unreserve(rbo); |
| 434 | |||
| 435 | /* On old GPU like RN50 with little vram pining can fails because | ||
| 436 | * current fb is taking all space needed. So instead of unpining | ||
| 437 | * the old buffer after pining the new one, first unpin old one | ||
| 438 | * and then retry pining new one. | ||
| 439 | * | ||
| 440 | * As only master can set mode only master can pin and it is | ||
| 441 | * unlikely the master client will race with itself especialy | ||
| 442 | * on those old gpu with single crtc. | ||
| 443 | * | ||
| 444 | * We don't shutdown the display controller because new buffer | ||
| 445 | * will end up in same spot. | ||
| 446 | */ | ||
| 447 | if (!atomic && fb && fb != crtc->fb) { | ||
| 448 | struct radeon_bo *old_rbo; | ||
| 449 | unsigned long nsize, osize; | ||
| 450 | |||
| 451 | old_rbo = gem_to_radeon_bo(to_radeon_framebuffer(fb)->obj); | ||
| 452 | osize = radeon_bo_size(old_rbo); | ||
| 453 | nsize = radeon_bo_size(rbo); | ||
| 454 | if (nsize <= osize && !radeon_bo_reserve(old_rbo, false)) { | ||
| 455 | radeon_bo_unpin(old_rbo); | ||
| 456 | radeon_bo_unreserve(old_rbo); | ||
| 457 | fb = NULL; | ||
| 458 | goto retry; | ||
| 459 | } | ||
| 460 | } | ||
| 433 | return -EINVAL; | 461 | return -EINVAL; |
| 434 | } | 462 | } |
| 435 | radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); | 463 | radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); |
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index 866ace070b91..984097b907ef 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
| @@ -537,8 +537,7 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, | |||
| 537 | struct device_attribute *attr, | 537 | struct device_attribute *attr, |
| 538 | char *buf) | 538 | char *buf) |
| 539 | { | 539 | { |
| 540 | struct drm_device *ddev = dev_get_drvdata(dev); | 540 | struct radeon_device *rdev = dev_get_drvdata(dev); |
| 541 | struct radeon_device *rdev = ddev->dev_private; | ||
| 542 | int temp; | 541 | int temp; |
| 543 | 542 | ||
| 544 | if (rdev->asic->pm.get_temperature) | 543 | if (rdev->asic->pm.get_temperature) |
| @@ -553,8 +552,7 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev, | |||
| 553 | struct device_attribute *attr, | 552 | struct device_attribute *attr, |
| 554 | char *buf) | 553 | char *buf) |
| 555 | { | 554 | { |
| 556 | struct drm_device *ddev = dev_get_drvdata(dev); | 555 | struct radeon_device *rdev = dev_get_drvdata(dev); |
| 557 | struct radeon_device *rdev = ddev->dev_private; | ||
| 558 | int hyst = to_sensor_dev_attr(attr)->index; | 556 | int hyst = to_sensor_dev_attr(attr)->index; |
| 559 | int temp; | 557 | int temp; |
| 560 | 558 | ||
| @@ -566,23 +564,14 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev, | |||
| 566 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); | 564 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); |
| 567 | } | 565 | } |
| 568 | 566 | ||
| 569 | static ssize_t radeon_hwmon_show_name(struct device *dev, | ||
| 570 | struct device_attribute *attr, | ||
| 571 | char *buf) | ||
| 572 | { | ||
| 573 | return sprintf(buf, "radeon\n"); | ||
| 574 | } | ||
| 575 | |||
| 576 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); | 567 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); |
| 577 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); | 568 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); |
| 578 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); | 569 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); |
| 579 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); | ||
| 580 | 570 | ||
| 581 | static struct attribute *hwmon_attributes[] = { | 571 | static struct attribute *hwmon_attributes[] = { |
| 582 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 572 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 583 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | 573 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
| 584 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | 574 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, |
| 585 | &sensor_dev_attr_name.dev_attr.attr, | ||
| 586 | NULL | 575 | NULL |
| 587 | }; | 576 | }; |
| 588 | 577 | ||
| @@ -590,8 +579,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
| 590 | struct attribute *attr, int index) | 579 | struct attribute *attr, int index) |
| 591 | { | 580 | { |
| 592 | struct device *dev = container_of(kobj, struct device, kobj); | 581 | struct device *dev = container_of(kobj, struct device, kobj); |
| 593 | struct drm_device *ddev = dev_get_drvdata(dev); | 582 | struct radeon_device *rdev = dev_get_drvdata(dev); |
| 594 | struct radeon_device *rdev = ddev->dev_private; | ||
| 595 | 583 | ||
| 596 | /* Skip limit attributes if DPM is not enabled */ | 584 | /* Skip limit attributes if DPM is not enabled */ |
| 597 | if (rdev->pm.pm_method != PM_METHOD_DPM && | 585 | if (rdev->pm.pm_method != PM_METHOD_DPM && |
| @@ -607,11 +595,15 @@ static const struct attribute_group hwmon_attrgroup = { | |||
| 607 | .is_visible = hwmon_attributes_visible, | 595 | .is_visible = hwmon_attributes_visible, |
| 608 | }; | 596 | }; |
| 609 | 597 | ||
| 598 | static const struct attribute_group *hwmon_groups[] = { | ||
| 599 | &hwmon_attrgroup, | ||
| 600 | NULL | ||
| 601 | }; | ||
| 602 | |||
| 610 | static int radeon_hwmon_init(struct radeon_device *rdev) | 603 | static int radeon_hwmon_init(struct radeon_device *rdev) |
| 611 | { | 604 | { |
| 612 | int err = 0; | 605 | int err = 0; |
| 613 | 606 | struct device *hwmon_dev; | |
| 614 | rdev->pm.int_hwmon_dev = NULL; | ||
| 615 | 607 | ||
| 616 | switch (rdev->pm.int_thermal_type) { | 608 | switch (rdev->pm.int_thermal_type) { |
| 617 | case THERMAL_TYPE_RV6XX: | 609 | case THERMAL_TYPE_RV6XX: |
| @@ -624,20 +616,13 @@ static int radeon_hwmon_init(struct radeon_device *rdev) | |||
| 624 | case THERMAL_TYPE_KV: | 616 | case THERMAL_TYPE_KV: |
| 625 | if (rdev->asic->pm.get_temperature == NULL) | 617 | if (rdev->asic->pm.get_temperature == NULL) |
| 626 | return err; | 618 | return err; |
| 627 | rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev); | 619 | hwmon_dev = hwmon_device_register_with_groups(rdev->dev, |
| 628 | if (IS_ERR(rdev->pm.int_hwmon_dev)) { | 620 | "radeon", rdev, |
| 629 | err = PTR_ERR(rdev->pm.int_hwmon_dev); | 621 | hwmon_groups); |
| 622 | if (IS_ERR(hwmon_dev)) { | ||
| 623 | err = PTR_ERR(hwmon_dev); | ||
| 630 | dev_err(rdev->dev, | 624 | dev_err(rdev->dev, |
| 631 | "Unable to register hwmon device: %d\n", err); | 625 | "Unable to register hwmon device: %d\n", err); |
| 632 | break; | ||
| 633 | } | ||
| 634 | dev_set_drvdata(rdev->pm.int_hwmon_dev, rdev->ddev); | ||
| 635 | err = sysfs_create_group(&rdev->pm.int_hwmon_dev->kobj, | ||
| 636 | &hwmon_attrgroup); | ||
| 637 | if (err) { | ||
| 638 | dev_err(rdev->dev, | ||
| 639 | "Unable to create hwmon sysfs file: %d\n", err); | ||
| 640 | hwmon_device_unregister(rdev->dev); | ||
| 641 | } | 626 | } |
| 642 | break; | 627 | break; |
| 643 | default: | 628 | default: |
| @@ -647,14 +632,6 @@ static int radeon_hwmon_init(struct radeon_device *rdev) | |||
| 647 | return err; | 632 | return err; |
| 648 | } | 633 | } |
| 649 | 634 | ||
| 650 | static void radeon_hwmon_fini(struct radeon_device *rdev) | ||
| 651 | { | ||
| 652 | if (rdev->pm.int_hwmon_dev) { | ||
| 653 | sysfs_remove_group(&rdev->pm.int_hwmon_dev->kobj, &hwmon_attrgroup); | ||
| 654 | hwmon_device_unregister(rdev->pm.int_hwmon_dev); | ||
| 655 | } | ||
| 656 | } | ||
| 657 | |||
| 658 | static void radeon_dpm_thermal_work_handler(struct work_struct *work) | 635 | static void radeon_dpm_thermal_work_handler(struct work_struct *work) |
| 659 | { | 636 | { |
| 660 | struct radeon_device *rdev = | 637 | struct radeon_device *rdev = |
| @@ -1252,7 +1229,6 @@ int radeon_pm_init(struct radeon_device *rdev) | |||
| 1252 | case CHIP_RS780: | 1229 | case CHIP_RS780: |
| 1253 | case CHIP_RS880: | 1230 | case CHIP_RS880: |
| 1254 | case CHIP_CAYMAN: | 1231 | case CHIP_CAYMAN: |
| 1255 | case CHIP_ARUBA: | ||
| 1256 | case CHIP_BONAIRE: | 1232 | case CHIP_BONAIRE: |
| 1257 | case CHIP_KABINI: | 1233 | case CHIP_KABINI: |
| 1258 | case CHIP_KAVERI: | 1234 | case CHIP_KAVERI: |
| @@ -1284,6 +1260,7 @@ int radeon_pm_init(struct radeon_device *rdev) | |||
| 1284 | case CHIP_BARTS: | 1260 | case CHIP_BARTS: |
| 1285 | case CHIP_TURKS: | 1261 | case CHIP_TURKS: |
| 1286 | case CHIP_CAICOS: | 1262 | case CHIP_CAICOS: |
| 1263 | case CHIP_ARUBA: | ||
| 1287 | case CHIP_TAHITI: | 1264 | case CHIP_TAHITI: |
| 1288 | case CHIP_PITCAIRN: | 1265 | case CHIP_PITCAIRN: |
| 1289 | case CHIP_VERDE: | 1266 | case CHIP_VERDE: |
| @@ -1337,8 +1314,6 @@ static void radeon_pm_fini_old(struct radeon_device *rdev) | |||
| 1337 | 1314 | ||
| 1338 | if (rdev->pm.power_state) | 1315 | if (rdev->pm.power_state) |
| 1339 | kfree(rdev->pm.power_state); | 1316 | kfree(rdev->pm.power_state); |
| 1340 | |||
| 1341 | radeon_hwmon_fini(rdev); | ||
| 1342 | } | 1317 | } |
| 1343 | 1318 | ||
| 1344 | static void radeon_pm_fini_dpm(struct radeon_device *rdev) | 1319 | static void radeon_pm_fini_dpm(struct radeon_device *rdev) |
| @@ -1358,8 +1333,6 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev) | |||
| 1358 | 1333 | ||
| 1359 | if (rdev->pm.power_state) | 1334 | if (rdev->pm.power_state) |
| 1360 | kfree(rdev->pm.power_state); | 1335 | kfree(rdev->pm.power_state); |
| 1361 | |||
| 1362 | radeon_hwmon_fini(rdev); | ||
| 1363 | } | 1336 | } |
| 1364 | 1337 | ||
| 1365 | void radeon_pm_fini(struct radeon_device *rdev) | 1338 | void radeon_pm_fini(struct radeon_device *rdev) |
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index 18254e1c3e71..9214403ae173 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c | |||
| @@ -61,7 +61,7 @@ int radeon_ib_get(struct radeon_device *rdev, int ring, | |||
| 61 | struct radeon_ib *ib, struct radeon_vm *vm, | 61 | struct radeon_ib *ib, struct radeon_vm *vm, |
| 62 | unsigned size) | 62 | unsigned size) |
| 63 | { | 63 | { |
| 64 | int i, r; | 64 | int r; |
| 65 | 65 | ||
| 66 | r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo, &ib->sa_bo, size, 256, true); | 66 | r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo, &ib->sa_bo, size, 256, true); |
| 67 | if (r) { | 67 | if (r) { |
| @@ -87,8 +87,6 @@ int radeon_ib_get(struct radeon_device *rdev, int ring, | |||
| 87 | ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo); | 87 | ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo); |
| 88 | } | 88 | } |
| 89 | ib->is_const_ib = false; | 89 | ib->is_const_ib = false; |
| 90 | for (i = 0; i < RADEON_NUM_RINGS; ++i) | ||
| 91 | ib->sync_to[i] = NULL; | ||
| 92 | 90 | ||
| 93 | return 0; | 91 | return 0; |
| 94 | } | 92 | } |
| @@ -109,25 +107,6 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib) | |||
| 109 | } | 107 | } |
| 110 | 108 | ||
| 111 | /** | 109 | /** |
| 112 | * radeon_ib_sync_to - sync to fence before executing the IB | ||
| 113 | * | ||
| 114 | * @ib: IB object to add fence to | ||
| 115 | * @fence: fence to sync to | ||
| 116 | * | ||
| 117 | * Sync to the fence before executing the IB | ||
| 118 | */ | ||
| 119 | void radeon_ib_sync_to(struct radeon_ib *ib, struct radeon_fence *fence) | ||
| 120 | { | ||
| 121 | struct radeon_fence *other; | ||
| 122 | |||
| 123 | if (!fence) | ||
| 124 | return; | ||
| 125 | |||
| 126 | other = ib->sync_to[fence->ring]; | ||
| 127 | ib->sync_to[fence->ring] = radeon_fence_later(fence, other); | ||
| 128 | } | ||
| 129 | |||
| 130 | /** | ||
| 131 | * radeon_ib_schedule - schedule an IB (Indirect Buffer) on the ring | 110 | * radeon_ib_schedule - schedule an IB (Indirect Buffer) on the ring |
| 132 | * | 111 | * |
| 133 | * @rdev: radeon_device pointer | 112 | * @rdev: radeon_device pointer |
| @@ -151,8 +130,7 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib, | |||
| 151 | struct radeon_ib *const_ib) | 130 | struct radeon_ib *const_ib) |
| 152 | { | 131 | { |
| 153 | struct radeon_ring *ring = &rdev->ring[ib->ring]; | 132 | struct radeon_ring *ring = &rdev->ring[ib->ring]; |
| 154 | bool need_sync = false; | 133 | int r = 0; |
| 155 | int i, r = 0; | ||
| 156 | 134 | ||
| 157 | if (!ib->length_dw || !ring->ready) { | 135 | if (!ib->length_dw || !ring->ready) { |
| 158 | /* TODO: Nothings in the ib we should report. */ | 136 | /* TODO: Nothings in the ib we should report. */ |
| @@ -166,19 +144,15 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib, | |||
| 166 | dev_err(rdev->dev, "scheduling IB failed (%d).\n", r); | 144 | dev_err(rdev->dev, "scheduling IB failed (%d).\n", r); |
| 167 | return r; | 145 | return r; |
| 168 | } | 146 | } |
| 169 | for (i = 0; i < RADEON_NUM_RINGS; ++i) { | 147 | |
| 170 | struct radeon_fence *fence = ib->sync_to[i]; | 148 | /* sync with other rings */ |
| 171 | if (radeon_fence_need_sync(fence, ib->ring)) { | 149 | r = radeon_semaphore_sync_rings(rdev, ib->semaphore, ib->ring); |
| 172 | need_sync = true; | 150 | if (r) { |
| 173 | radeon_semaphore_sync_rings(rdev, ib->semaphore, | 151 | dev_err(rdev->dev, "failed to sync rings (%d)\n", r); |
| 174 | fence->ring, ib->ring); | 152 | radeon_ring_unlock_undo(rdev, ring); |
| 175 | radeon_fence_note_sync(fence, ib->ring); | 153 | return r; |
| 176 | } | ||
| 177 | } | ||
| 178 | /* immediately free semaphore when we don't need to sync */ | ||
| 179 | if (!need_sync) { | ||
| 180 | radeon_semaphore_free(rdev, &ib->semaphore, NULL); | ||
| 181 | } | 154 | } |
| 155 | |||
| 182 | /* if we can't remember our last VM flush then flush now! */ | 156 | /* if we can't remember our last VM flush then flush now! */ |
| 183 | /* XXX figure out why we have to flush for every IB */ | 157 | /* XXX figure out why we have to flush for every IB */ |
| 184 | if (ib->vm /*&& !ib->vm->last_flush*/) { | 158 | if (ib->vm /*&& !ib->vm->last_flush*/) { |
diff --git a/drivers/gpu/drm/radeon/radeon_semaphore.c b/drivers/gpu/drm/radeon/radeon_semaphore.c index 8dcc20f53d73..2b42aa1914f2 100644 --- a/drivers/gpu/drm/radeon/radeon_semaphore.c +++ b/drivers/gpu/drm/radeon/radeon_semaphore.c | |||
| @@ -29,12 +29,12 @@ | |||
| 29 | */ | 29 | */ |
| 30 | #include <drm/drmP.h> | 30 | #include <drm/drmP.h> |
| 31 | #include "radeon.h" | 31 | #include "radeon.h" |
| 32 | 32 | #include "radeon_trace.h" | |
| 33 | 33 | ||
| 34 | int radeon_semaphore_create(struct radeon_device *rdev, | 34 | int radeon_semaphore_create(struct radeon_device *rdev, |
| 35 | struct radeon_semaphore **semaphore) | 35 | struct radeon_semaphore **semaphore) |
| 36 | { | 36 | { |
| 37 | int r; | 37 | int i, r; |
| 38 | 38 | ||
| 39 | *semaphore = kmalloc(sizeof(struct radeon_semaphore), GFP_KERNEL); | 39 | *semaphore = kmalloc(sizeof(struct radeon_semaphore), GFP_KERNEL); |
| 40 | if (*semaphore == NULL) { | 40 | if (*semaphore == NULL) { |
| @@ -50,54 +50,121 @@ int radeon_semaphore_create(struct radeon_device *rdev, | |||
| 50 | (*semaphore)->waiters = 0; | 50 | (*semaphore)->waiters = 0; |
| 51 | (*semaphore)->gpu_addr = radeon_sa_bo_gpu_addr((*semaphore)->sa_bo); | 51 | (*semaphore)->gpu_addr = radeon_sa_bo_gpu_addr((*semaphore)->sa_bo); |
| 52 | *((uint64_t*)radeon_sa_bo_cpu_addr((*semaphore)->sa_bo)) = 0; | 52 | *((uint64_t*)radeon_sa_bo_cpu_addr((*semaphore)->sa_bo)) = 0; |
| 53 | |||
| 54 | for (i = 0; i < RADEON_NUM_RINGS; ++i) | ||
| 55 | (*semaphore)->sync_to[i] = NULL; | ||
| 56 | |||
| 53 | return 0; | 57 | return 0; |
| 54 | } | 58 | } |
| 55 | 59 | ||
| 56 | void radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring, | 60 | bool radeon_semaphore_emit_signal(struct radeon_device *rdev, int ridx, |
| 57 | struct radeon_semaphore *semaphore) | 61 | struct radeon_semaphore *semaphore) |
| 58 | { | 62 | { |
| 59 | --semaphore->waiters; | 63 | struct radeon_ring *ring = &rdev->ring[ridx]; |
| 60 | radeon_semaphore_ring_emit(rdev, ring, &rdev->ring[ring], semaphore, false); | 64 | |
| 65 | trace_radeon_semaphore_signale(ridx, semaphore); | ||
| 66 | |||
| 67 | if (radeon_semaphore_ring_emit(rdev, ridx, ring, semaphore, false)) { | ||
| 68 | --semaphore->waiters; | ||
| 69 | |||
| 70 | /* for debugging lockup only, used by sysfs debug files */ | ||
| 71 | ring->last_semaphore_signal_addr = semaphore->gpu_addr; | ||
| 72 | return true; | ||
| 73 | } | ||
| 74 | return false; | ||
| 61 | } | 75 | } |
| 62 | 76 | ||
| 63 | void radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring, | 77 | bool radeon_semaphore_emit_wait(struct radeon_device *rdev, int ridx, |
| 64 | struct radeon_semaphore *semaphore) | 78 | struct radeon_semaphore *semaphore) |
| 65 | { | 79 | { |
| 66 | ++semaphore->waiters; | 80 | struct radeon_ring *ring = &rdev->ring[ridx]; |
| 67 | radeon_semaphore_ring_emit(rdev, ring, &rdev->ring[ring], semaphore, true); | 81 | |
| 82 | trace_radeon_semaphore_wait(ridx, semaphore); | ||
| 83 | |||
| 84 | if (radeon_semaphore_ring_emit(rdev, ridx, ring, semaphore, true)) { | ||
| 85 | ++semaphore->waiters; | ||
| 86 | |||
| 87 | /* for debugging lockup only, used by sysfs debug files */ | ||
| 88 | ring->last_semaphore_wait_addr = semaphore->gpu_addr; | ||
| 89 | return true; | ||
| 90 | } | ||
| 91 | return false; | ||
| 92 | } | ||
| 93 | |||
| 94 | /** | ||
| 95 | * radeon_semaphore_sync_to - use the semaphore to sync to a fence | ||
| 96 | * | ||
| 97 | * @semaphore: semaphore object to add fence to | ||
| 98 | * @fence: fence to sync to | ||
| 99 | * | ||
| 100 | * Sync to the fence using this semaphore object | ||
| 101 | */ | ||
| 102 | void radeon_semaphore_sync_to(struct radeon_semaphore *semaphore, | ||
| 103 | struct radeon_fence *fence) | ||
| 104 | { | ||
| 105 | struct radeon_fence *other; | ||
| 106 | |||
| 107 | if (!fence) | ||
| 108 | return; | ||
| 109 | |||
| 110 | other = semaphore->sync_to[fence->ring]; | ||
| 111 | semaphore->sync_to[fence->ring] = radeon_fence_later(fence, other); | ||
| 68 | } | 112 | } |
| 69 | 113 | ||
| 70 | /* caller must hold ring lock */ | 114 | /** |
| 115 | * radeon_semaphore_sync_rings - sync ring to all registered fences | ||
| 116 | * | ||
| 117 | * @rdev: radeon_device pointer | ||
| 118 | * @semaphore: semaphore object to use for sync | ||
| 119 | * @ring: ring that needs sync | ||
| 120 | * | ||
| 121 | * Ensure that all registered fences are signaled before letting | ||
| 122 | * the ring continue. The caller must hold the ring lock. | ||
| 123 | */ | ||
| 71 | int radeon_semaphore_sync_rings(struct radeon_device *rdev, | 124 | int radeon_semaphore_sync_rings(struct radeon_device *rdev, |
| 72 | struct radeon_semaphore *semaphore, | 125 | struct radeon_semaphore *semaphore, |
| 73 | int signaler, int waiter) | 126 | int ring) |
| 74 | { | 127 | { |
| 75 | int r; | 128 | int i, r; |
| 76 | 129 | ||
| 77 | /* no need to signal and wait on the same ring */ | 130 | for (i = 0; i < RADEON_NUM_RINGS; ++i) { |
| 78 | if (signaler == waiter) { | 131 | struct radeon_fence *fence = semaphore->sync_to[i]; |
| 79 | return 0; | ||
| 80 | } | ||
| 81 | 132 | ||
| 82 | /* prevent GPU deadlocks */ | 133 | /* check if we really need to sync */ |
| 83 | if (!rdev->ring[signaler].ready) { | 134 | if (!radeon_fence_need_sync(fence, ring)) |
| 84 | dev_err(rdev->dev, "Trying to sync to a disabled ring!"); | 135 | continue; |
| 85 | return -EINVAL; | ||
| 86 | } | ||
| 87 | 136 | ||
| 88 | r = radeon_ring_alloc(rdev, &rdev->ring[signaler], 8); | 137 | /* prevent GPU deadlocks */ |
| 89 | if (r) { | 138 | if (!rdev->ring[i].ready) { |
| 90 | return r; | 139 | dev_err(rdev->dev, "Syncing to a disabled ring!"); |
| 91 | } | 140 | return -EINVAL; |
| 92 | radeon_semaphore_emit_signal(rdev, signaler, semaphore); | 141 | } |
| 93 | radeon_ring_commit(rdev, &rdev->ring[signaler]); | ||
| 94 | 142 | ||
| 95 | /* we assume caller has already allocated space on waiters ring */ | 143 | /* allocate enough space for sync command */ |
| 96 | radeon_semaphore_emit_wait(rdev, waiter, semaphore); | 144 | r = radeon_ring_alloc(rdev, &rdev->ring[i], 16); |
| 145 | if (r) { | ||
| 146 | return r; | ||
| 147 | } | ||
| 97 | 148 | ||
| 98 | /* for debugging lockup only, used by sysfs debug files */ | 149 | /* emit the signal semaphore */ |
| 99 | rdev->ring[signaler].last_semaphore_signal_addr = semaphore->gpu_addr; | 150 | if (!radeon_semaphore_emit_signal(rdev, i, semaphore)) { |
| 100 | rdev->ring[waiter].last_semaphore_wait_addr = semaphore->gpu_addr; | 151 | /* signaling wasn't successful wait manually */ |
| 152 | radeon_ring_undo(&rdev->ring[i]); | ||
| 153 | radeon_fence_wait_locked(fence); | ||
| 154 | continue; | ||
| 155 | } | ||
| 156 | |||
| 157 | /* we assume caller has already allocated space on waiters ring */ | ||
| 158 | if (!radeon_semaphore_emit_wait(rdev, ring, semaphore)) { | ||
| 159 | /* waiting wasn't successful wait manually */ | ||
| 160 | radeon_ring_undo(&rdev->ring[i]); | ||
| 161 | radeon_fence_wait_locked(fence); | ||
| 162 | continue; | ||
| 163 | } | ||
| 164 | |||
| 165 | radeon_ring_commit(rdev, &rdev->ring[i]); | ||
| 166 | radeon_fence_note_sync(fence, ring); | ||
| 167 | } | ||
| 101 | 168 | ||
| 102 | return 0; | 169 | return 0; |
| 103 | } | 170 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_trace.h b/drivers/gpu/drm/radeon/radeon_trace.h index 811bca691b36..0473257d4078 100644 --- a/drivers/gpu/drm/radeon/radeon_trace.h +++ b/drivers/gpu/drm/radeon/radeon_trace.h | |||
| @@ -47,6 +47,39 @@ TRACE_EVENT(radeon_cs, | |||
| 47 | __entry->fences) | 47 | __entry->fences) |
| 48 | ); | 48 | ); |
| 49 | 49 | ||
| 50 | TRACE_EVENT(radeon_vm_grab_id, | ||
| 51 | TP_PROTO(unsigned vmid, int ring), | ||
| 52 | TP_ARGS(vmid, ring), | ||
| 53 | TP_STRUCT__entry( | ||
| 54 | __field(u32, vmid) | ||
| 55 | __field(u32, ring) | ||
| 56 | ), | ||
| 57 | |||
| 58 | TP_fast_assign( | ||
| 59 | __entry->vmid = vmid; | ||
| 60 | __entry->ring = ring; | ||
| 61 | ), | ||
| 62 | TP_printk("vmid=%u, ring=%u", __entry->vmid, __entry->ring) | ||
| 63 | ); | ||
| 64 | |||
| 65 | TRACE_EVENT(radeon_vm_bo_update, | ||
| 66 | TP_PROTO(struct radeon_bo_va *bo_va), | ||
| 67 | TP_ARGS(bo_va), | ||
| 68 | TP_STRUCT__entry( | ||
| 69 | __field(u64, soffset) | ||
| 70 | __field(u64, eoffset) | ||
| 71 | __field(u32, flags) | ||
| 72 | ), | ||
| 73 | |||
| 74 | TP_fast_assign( | ||
| 75 | __entry->soffset = bo_va->soffset; | ||
| 76 | __entry->eoffset = bo_va->eoffset; | ||
| 77 | __entry->flags = bo_va->flags; | ||
| 78 | ), | ||
| 79 | TP_printk("soffs=%010llx, eoffs=%010llx, flags=%08x", | ||
| 80 | __entry->soffset, __entry->eoffset, __entry->flags) | ||
| 81 | ); | ||
| 82 | |||
| 50 | TRACE_EVENT(radeon_vm_set_page, | 83 | TRACE_EVENT(radeon_vm_set_page, |
| 51 | TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, | 84 | TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, |
| 52 | uint32_t incr, uint32_t flags), | 85 | uint32_t incr, uint32_t flags), |
| @@ -111,6 +144,42 @@ DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_end, | |||
| 111 | TP_ARGS(dev, seqno) | 144 | TP_ARGS(dev, seqno) |
| 112 | ); | 145 | ); |
| 113 | 146 | ||
| 147 | DECLARE_EVENT_CLASS(radeon_semaphore_request, | ||
| 148 | |||
| 149 | TP_PROTO(int ring, struct radeon_semaphore *sem), | ||
| 150 | |||
| 151 | TP_ARGS(ring, sem), | ||
| 152 | |||
| 153 | TP_STRUCT__entry( | ||
| 154 | __field(int, ring) | ||
| 155 | __field(signed, waiters) | ||
| 156 | __field(uint64_t, gpu_addr) | ||
| 157 | ), | ||
| 158 | |||
| 159 | TP_fast_assign( | ||
| 160 | __entry->ring = ring; | ||
| 161 | __entry->waiters = sem->waiters; | ||
| 162 | __entry->gpu_addr = sem->gpu_addr; | ||
| 163 | ), | ||
| 164 | |||
| 165 | TP_printk("ring=%u, waiters=%d, addr=%010Lx", __entry->ring, | ||
| 166 | __entry->waiters, __entry->gpu_addr) | ||
| 167 | ); | ||
| 168 | |||
| 169 | DEFINE_EVENT(radeon_semaphore_request, radeon_semaphore_signale, | ||
| 170 | |||
| 171 | TP_PROTO(int ring, struct radeon_semaphore *sem), | ||
| 172 | |||
| 173 | TP_ARGS(ring, sem) | ||
| 174 | ); | ||
| 175 | |||
| 176 | DEFINE_EVENT(radeon_semaphore_request, radeon_semaphore_wait, | ||
| 177 | |||
| 178 | TP_PROTO(int ring, struct radeon_semaphore *sem), | ||
| 179 | |||
| 180 | TP_ARGS(ring, sem) | ||
| 181 | ); | ||
| 182 | |||
| 114 | #endif | 183 | #endif |
| 115 | 184 | ||
| 116 | /* This part must be outside protection */ | 185 | /* This part must be outside protection */ |
diff --git a/drivers/gpu/drm/radeon/reg_srcs/cayman b/drivers/gpu/drm/radeon/reg_srcs/cayman index a072fa8c46b0..d46b58d078aa 100644 --- a/drivers/gpu/drm/radeon/reg_srcs/cayman +++ b/drivers/gpu/drm/radeon/reg_srcs/cayman | |||
| @@ -21,7 +21,7 @@ cayman 0x9400 | |||
| 21 | 0x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE | 21 | 0x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE |
| 22 | 0x000089B0 VGT_HS_OFFCHIP_PARAM | 22 | 0x000089B0 VGT_HS_OFFCHIP_PARAM |
| 23 | 0x00008A14 PA_CL_ENHANCE | 23 | 0x00008A14 PA_CL_ENHANCE |
| 24 | 0x00008A60 PA_SC_LINE_STIPPLE_VALUE | 24 | 0x00008A60 PA_SU_LINE_STIPPLE_VALUE |
| 25 | 0x00008B10 PA_SC_LINE_STIPPLE_STATE | 25 | 0x00008B10 PA_SC_LINE_STIPPLE_STATE |
| 26 | 0x00008BF0 PA_SC_ENHANCE | 26 | 0x00008BF0 PA_SC_ENHANCE |
| 27 | 0x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ | 27 | 0x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ |
| @@ -532,7 +532,7 @@ cayman 0x9400 | |||
| 532 | 0x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET | 532 | 0x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET |
| 533 | 0x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE | 533 | 0x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE |
| 534 | 0x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET | 534 | 0x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET |
| 535 | 0x00028B74 VGT_GS_INSTANCE_CNT | 535 | 0x00028B90 VGT_GS_INSTANCE_CNT |
| 536 | 0x00028BD4 PA_SC_CENTROID_PRIORITY_0 | 536 | 0x00028BD4 PA_SC_CENTROID_PRIORITY_0 |
| 537 | 0x00028BD8 PA_SC_CENTROID_PRIORITY_1 | 537 | 0x00028BD8 PA_SC_CENTROID_PRIORITY_1 |
| 538 | 0x00028BDC PA_SC_LINE_CNTL | 538 | 0x00028BDC PA_SC_LINE_CNTL |
diff --git a/drivers/gpu/drm/radeon/reg_srcs/evergreen b/drivers/gpu/drm/radeon/reg_srcs/evergreen index b912a37689bf..57745c8761c8 100644 --- a/drivers/gpu/drm/radeon/reg_srcs/evergreen +++ b/drivers/gpu/drm/radeon/reg_srcs/evergreen | |||
| @@ -22,7 +22,7 @@ evergreen 0x9400 | |||
| 22 | 0x000089A4 VGT_COMPUTE_START_Z | 22 | 0x000089A4 VGT_COMPUTE_START_Z |
| 23 | 0x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE | 23 | 0x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE |
| 24 | 0x00008A14 PA_CL_ENHANCE | 24 | 0x00008A14 PA_CL_ENHANCE |
| 25 | 0x00008A60 PA_SC_LINE_STIPPLE_VALUE | 25 | 0x00008A60 PA_SU_LINE_STIPPLE_VALUE |
| 26 | 0x00008B10 PA_SC_LINE_STIPPLE_STATE | 26 | 0x00008B10 PA_SC_LINE_STIPPLE_STATE |
| 27 | 0x00008BF0 PA_SC_ENHANCE | 27 | 0x00008BF0 PA_SC_ENHANCE |
| 28 | 0x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ | 28 | 0x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ |
| @@ -545,7 +545,7 @@ evergreen 0x9400 | |||
| 545 | 0x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET | 545 | 0x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET |
| 546 | 0x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE | 546 | 0x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE |
| 547 | 0x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET | 547 | 0x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET |
| 548 | 0x00028B74 VGT_GS_INSTANCE_CNT | 548 | 0x00028B90 VGT_GS_INSTANCE_CNT |
| 549 | 0x00028C00 PA_SC_LINE_CNTL | 549 | 0x00028C00 PA_SC_LINE_CNTL |
| 550 | 0x00028C08 PA_SU_VTX_CNTL | 550 | 0x00028C08 PA_SU_VTX_CNTL |
| 551 | 0x00028C0C PA_CL_GB_VERT_CLIP_ADJ | 551 | 0x00028C0C PA_CL_GB_VERT_CLIP_ADJ |
diff --git a/drivers/gpu/drm/radeon/rv770_dma.c b/drivers/gpu/drm/radeon/rv770_dma.c index f9b02e3d6830..aca8cbe8a335 100644 --- a/drivers/gpu/drm/radeon/rv770_dma.c +++ b/drivers/gpu/drm/radeon/rv770_dma.c | |||
| @@ -66,13 +66,8 @@ int rv770_copy_dma(struct radeon_device *rdev, | |||
| 66 | return r; | 66 | return r; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 69 | radeon_semaphore_sync_to(sem, *fence); |
| 70 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 70 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 71 | ring->idx); | ||
| 72 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 73 | } else { | ||
| 74 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 75 | } | ||
| 76 | 71 | ||
| 77 | for (i = 0; i < num_loops; i++) { | 72 | for (i = 0; i < num_loops; i++) { |
| 78 | cur_size_in_dw = size_in_dw; | 73 | cur_size_in_dw = size_in_dw; |
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index 6a64ccaa0695..a36736dab5e0 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c | |||
| @@ -3882,8 +3882,15 @@ static int si_mc_init(struct radeon_device *rdev) | |||
| 3882 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); | 3882 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
| 3883 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); | 3883 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
| 3884 | /* size in MB on si */ | 3884 | /* size in MB on si */ |
| 3885 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; | 3885 | tmp = RREG32(CONFIG_MEMSIZE); |
| 3886 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; | 3886 | /* some boards may have garbage in the upper 16 bits */ |
| 3887 | if (tmp & 0xffff0000) { | ||
| 3888 | DRM_INFO("Probable bad vram size: 0x%08x\n", tmp); | ||
| 3889 | if (tmp & 0xffff) | ||
| 3890 | tmp &= 0xffff; | ||
| 3891 | } | ||
| 3892 | rdev->mc.mc_vram_size = tmp * 1024ULL * 1024ULL; | ||
| 3893 | rdev->mc.real_vram_size = rdev->mc.mc_vram_size; | ||
| 3887 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 3894 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
| 3888 | si_vram_gtt_location(rdev, &rdev->mc); | 3895 | si_vram_gtt_location(rdev, &rdev->mc); |
| 3889 | radeon_update_bandwidth_info(rdev); | 3896 | radeon_update_bandwidth_info(rdev); |
diff --git a/drivers/gpu/drm/radeon/si_dma.c b/drivers/gpu/drm/radeon/si_dma.c index 8e8f46133532..59be2cfcbb47 100644 --- a/drivers/gpu/drm/radeon/si_dma.c +++ b/drivers/gpu/drm/radeon/si_dma.c | |||
| @@ -195,13 +195,8 @@ int si_copy_dma(struct radeon_device *rdev, | |||
| 195 | return r; | 195 | return r; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | if (radeon_fence_need_sync(*fence, ring->idx)) { | 198 | radeon_semaphore_sync_to(sem, *fence); |
| 199 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, | 199 | radeon_semaphore_sync_rings(rdev, sem, ring->idx); |
| 200 | ring->idx); | ||
| 201 | radeon_fence_note_sync(*fence, ring->idx); | ||
| 202 | } else { | ||
| 203 | radeon_semaphore_free(rdev, &sem, NULL); | ||
| 204 | } | ||
| 205 | 200 | ||
| 206 | for (i = 0; i < num_loops; i++) { | 201 | for (i = 0; i < num_loops; i++) { |
| 207 | cur_size_in_bytes = size_in_bytes; | 202 | cur_size_in_bytes = size_in_bytes; |
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c index 9364129ba292..d700698a1f22 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.c +++ b/drivers/gpu/drm/radeon/trinity_dpm.c | |||
| @@ -1873,9 +1873,9 @@ int trinity_dpm_init(struct radeon_device *rdev) | |||
| 1873 | pi->enable_sclk_ds = true; | 1873 | pi->enable_sclk_ds = true; |
| 1874 | pi->enable_gfx_power_gating = true; | 1874 | pi->enable_gfx_power_gating = true; |
| 1875 | pi->enable_gfx_clock_gating = true; | 1875 | pi->enable_gfx_clock_gating = true; |
| 1876 | pi->enable_mg_clock_gating = true; | 1876 | pi->enable_mg_clock_gating = false; |
| 1877 | pi->enable_gfx_dynamic_mgpg = true; /* ??? */ | 1877 | pi->enable_gfx_dynamic_mgpg = false; |
| 1878 | pi->override_dynamic_mgpg = true; | 1878 | pi->override_dynamic_mgpg = false; |
| 1879 | pi->enable_auto_thermal_throttling = true; | 1879 | pi->enable_auto_thermal_throttling = true; |
| 1880 | pi->voltage_drop_in_dce = false; /* need to restructure dpm/modeset interaction */ | 1880 | pi->voltage_drop_in_dce = false; /* need to restructure dpm/modeset interaction */ |
| 1881 | pi->uvd_dpm = true; /* ??? */ | 1881 | pi->uvd_dpm = true; /* ??? */ |
diff --git a/drivers/gpu/drm/radeon/uvd_v1_0.c b/drivers/gpu/drm/radeon/uvd_v1_0.c index 7266805d9786..d4a68af1a279 100644 --- a/drivers/gpu/drm/radeon/uvd_v1_0.c +++ b/drivers/gpu/drm/radeon/uvd_v1_0.c | |||
| @@ -357,7 +357,7 @@ int uvd_v1_0_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) | |||
| 357 | * | 357 | * |
| 358 | * Emit a semaphore command (either wait or signal) to the UVD ring. | 358 | * Emit a semaphore command (either wait or signal) to the UVD ring. |
| 359 | */ | 359 | */ |
| 360 | void uvd_v1_0_semaphore_emit(struct radeon_device *rdev, | 360 | bool uvd_v1_0_semaphore_emit(struct radeon_device *rdev, |
| 361 | struct radeon_ring *ring, | 361 | struct radeon_ring *ring, |
| 362 | struct radeon_semaphore *semaphore, | 362 | struct radeon_semaphore *semaphore, |
| 363 | bool emit_wait) | 363 | bool emit_wait) |
| @@ -372,6 +372,8 @@ void uvd_v1_0_semaphore_emit(struct radeon_device *rdev, | |||
| 372 | 372 | ||
| 373 | radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0)); | 373 | radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0)); |
| 374 | radeon_ring_write(ring, emit_wait ? 1 : 0); | 374 | radeon_ring_write(ring, emit_wait ? 1 : 0); |
| 375 | |||
| 376 | return true; | ||
| 375 | } | 377 | } |
| 376 | 378 | ||
| 377 | /** | 379 | /** |
diff --git a/drivers/gpu/drm/radeon/uvd_v3_1.c b/drivers/gpu/drm/radeon/uvd_v3_1.c index 5b6fa1f62d4e..d722db2cf340 100644 --- a/drivers/gpu/drm/radeon/uvd_v3_1.c +++ b/drivers/gpu/drm/radeon/uvd_v3_1.c | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | * | 37 | * |
| 38 | * Emit a semaphore command (either wait or signal) to the UVD ring. | 38 | * Emit a semaphore command (either wait or signal) to the UVD ring. |
| 39 | */ | 39 | */ |
| 40 | void uvd_v3_1_semaphore_emit(struct radeon_device *rdev, | 40 | bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev, |
| 41 | struct radeon_ring *ring, | 41 | struct radeon_ring *ring, |
| 42 | struct radeon_semaphore *semaphore, | 42 | struct radeon_semaphore *semaphore, |
| 43 | bool emit_wait) | 43 | bool emit_wait) |
| @@ -52,4 +52,6 @@ void uvd_v3_1_semaphore_emit(struct radeon_device *rdev, | |||
| 52 | 52 | ||
| 53 | radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0)); | 53 | radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0)); |
| 54 | radeon_ring_write(ring, 0x80 | (emit_wait ? 1 : 0)); | 54 | radeon_ring_write(ring, 0x80 | (emit_wait ? 1 : 0)); |
| 55 | |||
| 56 | return true; | ||
| 55 | } | 57 | } |
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 28e178137718..07eba596d458 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c | |||
| @@ -135,11 +135,11 @@ int tegra_drm_submit(struct tegra_drm_context *context, | |||
| 135 | unsigned int num_relocs = args->num_relocs; | 135 | unsigned int num_relocs = args->num_relocs; |
| 136 | unsigned int num_waitchks = args->num_waitchks; | 136 | unsigned int num_waitchks = args->num_waitchks; |
| 137 | struct drm_tegra_cmdbuf __user *cmdbufs = | 137 | struct drm_tegra_cmdbuf __user *cmdbufs = |
| 138 | (void * __user)(uintptr_t)args->cmdbufs; | 138 | (void __user *)(uintptr_t)args->cmdbufs; |
| 139 | struct drm_tegra_reloc __user *relocs = | 139 | struct drm_tegra_reloc __user *relocs = |
| 140 | (void * __user)(uintptr_t)args->relocs; | 140 | (void __user *)(uintptr_t)args->relocs; |
| 141 | struct drm_tegra_waitchk __user *waitchks = | 141 | struct drm_tegra_waitchk __user *waitchks = |
| 142 | (void * __user)(uintptr_t)args->waitchks; | 142 | (void __user *)(uintptr_t)args->waitchks; |
| 143 | struct drm_tegra_syncpt syncpt; | 143 | struct drm_tegra_syncpt syncpt; |
| 144 | struct host1x_job *job; | 144 | struct host1x_job *job; |
| 145 | int err; | 145 | int err; |
| @@ -163,9 +163,10 @@ int tegra_drm_submit(struct tegra_drm_context *context, | |||
| 163 | struct drm_tegra_cmdbuf cmdbuf; | 163 | struct drm_tegra_cmdbuf cmdbuf; |
| 164 | struct host1x_bo *bo; | 164 | struct host1x_bo *bo; |
| 165 | 165 | ||
| 166 | err = copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf)); | 166 | if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) { |
| 167 | if (err) | 167 | err = -EFAULT; |
| 168 | goto fail; | 168 | goto fail; |
| 169 | } | ||
| 169 | 170 | ||
| 170 | bo = host1x_bo_lookup(drm, file, cmdbuf.handle); | 171 | bo = host1x_bo_lookup(drm, file, cmdbuf.handle); |
| 171 | if (!bo) { | 172 | if (!bo) { |
| @@ -178,10 +179,11 @@ int tegra_drm_submit(struct tegra_drm_context *context, | |||
| 178 | cmdbufs++; | 179 | cmdbufs++; |
| 179 | } | 180 | } |
| 180 | 181 | ||
| 181 | err = copy_from_user(job->relocarray, relocs, | 182 | if (copy_from_user(job->relocarray, relocs, |
| 182 | sizeof(*relocs) * num_relocs); | 183 | sizeof(*relocs) * num_relocs)) { |
| 183 | if (err) | 184 | err = -EFAULT; |
| 184 | goto fail; | 185 | goto fail; |
| 186 | } | ||
| 185 | 187 | ||
| 186 | while (num_relocs--) { | 188 | while (num_relocs--) { |
| 187 | struct host1x_reloc *reloc = &job->relocarray[num_relocs]; | 189 | struct host1x_reloc *reloc = &job->relocarray[num_relocs]; |
| @@ -199,15 +201,17 @@ int tegra_drm_submit(struct tegra_drm_context *context, | |||
| 199 | } | 201 | } |
| 200 | } | 202 | } |
| 201 | 203 | ||
| 202 | err = copy_from_user(job->waitchk, waitchks, | 204 | if (copy_from_user(job->waitchk, waitchks, |
| 203 | sizeof(*waitchks) * num_waitchks); | 205 | sizeof(*waitchks) * num_waitchks)) { |
| 204 | if (err) | 206 | err = -EFAULT; |
| 205 | goto fail; | 207 | goto fail; |
| 208 | } | ||
| 206 | 209 | ||
| 207 | err = copy_from_user(&syncpt, (void * __user)(uintptr_t)args->syncpts, | 210 | if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts, |
| 208 | sizeof(syncpt)); | 211 | sizeof(syncpt))) { |
| 209 | if (err) | 212 | err = -EFAULT; |
| 210 | goto fail; | 213 | goto fail; |
| 214 | } | ||
| 211 | 215 | ||
| 212 | job->is_addr_reg = context->client->ops->is_addr_reg; | 216 | job->is_addr_reg = context->client->ops->is_addr_reg; |
| 213 | job->syncpt_incrs = syncpt.incrs; | 217 | job->syncpt_incrs = syncpt.incrs; |
| @@ -573,7 +577,7 @@ static void tegra_debugfs_cleanup(struct drm_minor *minor) | |||
| 573 | } | 577 | } |
| 574 | #endif | 578 | #endif |
| 575 | 579 | ||
| 576 | struct drm_driver tegra_drm_driver = { | 580 | static struct drm_driver tegra_drm_driver = { |
| 577 | .driver_features = DRIVER_MODESET | DRIVER_GEM, | 581 | .driver_features = DRIVER_MODESET | DRIVER_GEM, |
| 578 | .load = tegra_drm_load, | 582 | .load = tegra_drm_load, |
| 579 | .unload = tegra_drm_unload, | 583 | .unload = tegra_drm_unload, |
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index fdfe259ed7f8..7da0b923131f 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h | |||
| @@ -116,7 +116,7 @@ host1x_client_to_dc(struct host1x_client *client) | |||
| 116 | 116 | ||
| 117 | static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc) | 117 | static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc) |
| 118 | { | 118 | { |
| 119 | return container_of(crtc, struct tegra_dc, base); | 119 | return crtc ? container_of(crtc, struct tegra_dc, base) : NULL; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long value, | 122 | static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long value, |
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 490f7719e317..a3835e7de184 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c | |||
| @@ -247,7 +247,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper, | |||
| 247 | info->var.yoffset * fb->pitches[0]; | 247 | info->var.yoffset * fb->pitches[0]; |
| 248 | 248 | ||
| 249 | drm->mode_config.fb_base = (resource_size_t)bo->paddr; | 249 | drm->mode_config.fb_base = (resource_size_t)bo->paddr; |
| 250 | info->screen_base = bo->vaddr + offset; | 250 | info->screen_base = (void __iomem *)bo->vaddr + offset; |
| 251 | info->screen_size = size; | 251 | info->screen_size = size; |
| 252 | info->fix.smem_start = (unsigned long)(bo->paddr + offset); | 252 | info->fix.smem_start = (unsigned long)(bo->paddr + offset); |
| 253 | info->fix.smem_len = size; | 253 | info->fix.smem_len = size; |
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c index ba47ca4fb880..3b29018913a5 100644 --- a/drivers/gpu/drm/tegra/rgb.c +++ b/drivers/gpu/drm/tegra/rgb.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | 14 | ||
| 15 | struct tegra_rgb { | 15 | struct tegra_rgb { |
| 16 | struct tegra_output output; | 16 | struct tegra_output output; |
| 17 | struct tegra_dc *dc; | ||
| 18 | |||
| 17 | struct clk *clk_parent; | 19 | struct clk *clk_parent; |
| 18 | struct clk *clk; | 20 | struct clk *clk; |
| 19 | }; | 21 | }; |
| @@ -84,18 +86,18 @@ static void tegra_dc_write_regs(struct tegra_dc *dc, | |||
| 84 | 86 | ||
| 85 | static int tegra_output_rgb_enable(struct tegra_output *output) | 87 | static int tegra_output_rgb_enable(struct tegra_output *output) |
| 86 | { | 88 | { |
| 87 | struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc); | 89 | struct tegra_rgb *rgb = to_rgb(output); |
| 88 | 90 | ||
| 89 | tegra_dc_write_regs(dc, rgb_enable, ARRAY_SIZE(rgb_enable)); | 91 | tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable)); |
| 90 | 92 | ||
| 91 | return 0; | 93 | return 0; |
| 92 | } | 94 | } |
| 93 | 95 | ||
| 94 | static int tegra_output_rgb_disable(struct tegra_output *output) | 96 | static int tegra_output_rgb_disable(struct tegra_output *output) |
| 95 | { | 97 | { |
| 96 | struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc); | 98 | struct tegra_rgb *rgb = to_rgb(output); |
| 97 | 99 | ||
| 98 | tegra_dc_write_regs(dc, rgb_disable, ARRAY_SIZE(rgb_disable)); | 100 | tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable)); |
| 99 | 101 | ||
| 100 | return 0; | 102 | return 0; |
| 101 | } | 103 | } |
| @@ -146,6 +148,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) | |||
| 146 | 148 | ||
| 147 | rgb->output.dev = dc->dev; | 149 | rgb->output.dev = dc->dev; |
| 148 | rgb->output.of_node = np; | 150 | rgb->output.of_node = np; |
| 151 | rgb->dc = dc; | ||
| 149 | 152 | ||
| 150 | err = tegra_output_probe(&rgb->output); | 153 | err = tegra_output_probe(&rgb->output); |
| 151 | if (err < 0) | 154 | if (err < 0) |
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 8d5a646ebe6a..07e02c4bf5a8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
| @@ -151,7 +151,7 @@ static void ttm_bo_release_list(struct kref *list_kref) | |||
| 151 | atomic_dec(&bo->glob->bo_count); | 151 | atomic_dec(&bo->glob->bo_count); |
| 152 | if (bo->resv == &bo->ttm_resv) | 152 | if (bo->resv == &bo->ttm_resv) |
| 153 | reservation_object_fini(&bo->ttm_resv); | 153 | reservation_object_fini(&bo->ttm_resv); |
| 154 | 154 | mutex_destroy(&bo->wu_mutex); | |
| 155 | if (bo->destroy) | 155 | if (bo->destroy) |
| 156 | bo->destroy(bo); | 156 | bo->destroy(bo); |
| 157 | else { | 157 | else { |
| @@ -1123,6 +1123,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev, | |||
| 1123 | INIT_LIST_HEAD(&bo->ddestroy); | 1123 | INIT_LIST_HEAD(&bo->ddestroy); |
| 1124 | INIT_LIST_HEAD(&bo->swap); | 1124 | INIT_LIST_HEAD(&bo->swap); |
| 1125 | INIT_LIST_HEAD(&bo->io_reserve_lru); | 1125 | INIT_LIST_HEAD(&bo->io_reserve_lru); |
| 1126 | mutex_init(&bo->wu_mutex); | ||
| 1126 | bo->bdev = bdev; | 1127 | bo->bdev = bdev; |
| 1127 | bo->glob = bdev->glob; | 1128 | bo->glob = bdev->glob; |
| 1128 | bo->type = type; | 1129 | bo->type = type; |
| @@ -1704,3 +1705,35 @@ void ttm_bo_swapout_all(struct ttm_bo_device *bdev) | |||
| 1704 | ; | 1705 | ; |
| 1705 | } | 1706 | } |
| 1706 | EXPORT_SYMBOL(ttm_bo_swapout_all); | 1707 | EXPORT_SYMBOL(ttm_bo_swapout_all); |
| 1708 | |||
| 1709 | /** | ||
| 1710 | * ttm_bo_wait_unreserved - interruptible wait for a buffer object to become | ||
| 1711 | * unreserved | ||
| 1712 | * | ||
| 1713 | * @bo: Pointer to buffer | ||
| 1714 | */ | ||
| 1715 | int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) | ||
| 1716 | { | ||
| 1717 | int ret; | ||
| 1718 | |||
| 1719 | /* | ||
| 1720 | * In the absense of a wait_unlocked API, | ||
| 1721 | * Use the bo::wu_mutex to avoid triggering livelocks due to | ||
| 1722 | * concurrent use of this function. Note that this use of | ||
| 1723 | * bo::wu_mutex can go away if we change locking order to | ||
| 1724 | * mmap_sem -> bo::reserve. | ||
| 1725 | */ | ||
| 1726 | ret = mutex_lock_interruptible(&bo->wu_mutex); | ||
| 1727 | if (unlikely(ret != 0)) | ||
| 1728 | return -ERESTARTSYS; | ||
| 1729 | if (!ww_mutex_is_locked(&bo->resv->lock)) | ||
| 1730 | goto out_unlock; | ||
| 1731 | ret = ttm_bo_reserve_nolru(bo, true, false, false, NULL); | ||
| 1732 | if (unlikely(ret != 0)) | ||
| 1733 | goto out_unlock; | ||
| 1734 | ww_mutex_unlock(&bo->resv->lock); | ||
| 1735 | |||
| 1736 | out_unlock: | ||
| 1737 | mutex_unlock(&bo->wu_mutex); | ||
| 1738 | return ret; | ||
| 1739 | } | ||
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 4834c463c38b..15b86a94949d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c | |||
| @@ -350,10 +350,13 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, | |||
| 350 | goto out2; | 350 | goto out2; |
| 351 | 351 | ||
| 352 | /* | 352 | /* |
| 353 | * Move nonexistent data. NOP. | 353 | * Don't move nonexistent data. Clear destination instead. |
| 354 | */ | 354 | */ |
| 355 | if (old_iomap == NULL && ttm == NULL) | 355 | if (old_iomap == NULL && |
| 356 | (ttm == NULL || ttm->state == tt_unpopulated)) { | ||
| 357 | memset_io(new_iomap, 0, new_mem->num_pages*PAGE_SIZE); | ||
| 356 | goto out2; | 358 | goto out2; |
| 359 | } | ||
| 357 | 360 | ||
| 358 | /* | 361 | /* |
| 359 | * TTM might be null for moves within the same region. | 362 | * TTM might be null for moves within the same region. |
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index ac617f3ecd0c..b249ab9b1eb2 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c | |||
| @@ -107,13 +107,28 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 107 | /* | 107 | /* |
| 108 | * Work around locking order reversal in fault / nopfn | 108 | * Work around locking order reversal in fault / nopfn |
| 109 | * between mmap_sem and bo_reserve: Perform a trylock operation | 109 | * between mmap_sem and bo_reserve: Perform a trylock operation |
| 110 | * for reserve, and if it fails, retry the fault after scheduling. | 110 | * for reserve, and if it fails, retry the fault after waiting |
| 111 | * for the buffer to become unreserved. | ||
| 111 | */ | 112 | */ |
| 112 | 113 | ret = ttm_bo_reserve(bo, true, true, false, NULL); | |
| 113 | ret = ttm_bo_reserve(bo, true, true, false, 0); | ||
| 114 | if (unlikely(ret != 0)) { | 114 | if (unlikely(ret != 0)) { |
| 115 | if (ret == -EBUSY) | 115 | if (ret != -EBUSY) |
| 116 | set_need_resched(); | 116 | return VM_FAULT_NOPAGE; |
| 117 | |||
| 118 | if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) { | ||
| 119 | if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) { | ||
| 120 | up_read(&vma->vm_mm->mmap_sem); | ||
| 121 | (void) ttm_bo_wait_unreserved(bo); | ||
| 122 | } | ||
| 123 | |||
| 124 | return VM_FAULT_RETRY; | ||
| 125 | } | ||
| 126 | |||
| 127 | /* | ||
| 128 | * If we'd want to change locking order to | ||
| 129 | * mmap_sem -> bo::reserve, we'd use a blocking reserve here | ||
| 130 | * instead of retrying the fault... | ||
| 131 | */ | ||
| 117 | return VM_FAULT_NOPAGE; | 132 | return VM_FAULT_NOPAGE; |
| 118 | } | 133 | } |
| 119 | 134 | ||
| @@ -123,7 +138,6 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 123 | case 0: | 138 | case 0: |
| 124 | break; | 139 | break; |
| 125 | case -EBUSY: | 140 | case -EBUSY: |
| 126 | set_need_resched(); | ||
| 127 | case -ERESTARTSYS: | 141 | case -ERESTARTSYS: |
| 128 | retval = VM_FAULT_NOPAGE; | 142 | retval = VM_FAULT_NOPAGE; |
| 129 | goto out_unlock; | 143 | goto out_unlock; |
diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c index 6c911789ae5c..479e9418e3d7 100644 --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c | |||
| @@ -32,8 +32,7 @@ | |||
| 32 | #include <linux/sched.h> | 32 | #include <linux/sched.h> |
| 33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
| 34 | 34 | ||
| 35 | static void ttm_eu_backoff_reservation_locked(struct list_head *list, | 35 | static void ttm_eu_backoff_reservation_locked(struct list_head *list) |
| 36 | struct ww_acquire_ctx *ticket) | ||
| 37 | { | 36 | { |
| 38 | struct ttm_validate_buffer *entry; | 37 | struct ttm_validate_buffer *entry; |
| 39 | 38 | ||
| @@ -93,8 +92,9 @@ void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket, | |||
| 93 | entry = list_first_entry(list, struct ttm_validate_buffer, head); | 92 | entry = list_first_entry(list, struct ttm_validate_buffer, head); |
| 94 | glob = entry->bo->glob; | 93 | glob = entry->bo->glob; |
| 95 | spin_lock(&glob->lru_lock); | 94 | spin_lock(&glob->lru_lock); |
| 96 | ttm_eu_backoff_reservation_locked(list, ticket); | 95 | ttm_eu_backoff_reservation_locked(list); |
| 97 | ww_acquire_fini(ticket); | 96 | if (ticket) |
| 97 | ww_acquire_fini(ticket); | ||
| 98 | spin_unlock(&glob->lru_lock); | 98 | spin_unlock(&glob->lru_lock); |
| 99 | } | 99 | } |
| 100 | EXPORT_SYMBOL(ttm_eu_backoff_reservation); | 100 | EXPORT_SYMBOL(ttm_eu_backoff_reservation); |
| @@ -130,7 +130,8 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, | |||
| 130 | entry = list_first_entry(list, struct ttm_validate_buffer, head); | 130 | entry = list_first_entry(list, struct ttm_validate_buffer, head); |
| 131 | glob = entry->bo->glob; | 131 | glob = entry->bo->glob; |
| 132 | 132 | ||
| 133 | ww_acquire_init(ticket, &reservation_ww_class); | 133 | if (ticket) |
| 134 | ww_acquire_init(ticket, &reservation_ww_class); | ||
| 134 | retry: | 135 | retry: |
| 135 | list_for_each_entry(entry, list, head) { | 136 | list_for_each_entry(entry, list, head) { |
| 136 | struct ttm_buffer_object *bo = entry->bo; | 137 | struct ttm_buffer_object *bo = entry->bo; |
| @@ -139,16 +140,17 @@ retry: | |||
| 139 | if (entry->reserved) | 140 | if (entry->reserved) |
| 140 | continue; | 141 | continue; |
| 141 | 142 | ||
| 142 | 143 | ret = ttm_bo_reserve_nolru(bo, true, (ticket == NULL), true, | |
| 143 | ret = ttm_bo_reserve_nolru(bo, true, false, true, ticket); | 144 | ticket); |
| 144 | 145 | ||
| 145 | if (ret == -EDEADLK) { | 146 | if (ret == -EDEADLK) { |
| 146 | /* uh oh, we lost out, drop every reservation and try | 147 | /* uh oh, we lost out, drop every reservation and try |
| 147 | * to only reserve this buffer, then start over if | 148 | * to only reserve this buffer, then start over if |
| 148 | * this succeeds. | 149 | * this succeeds. |
| 149 | */ | 150 | */ |
| 151 | BUG_ON(ticket == NULL); | ||
| 150 | spin_lock(&glob->lru_lock); | 152 | spin_lock(&glob->lru_lock); |
| 151 | ttm_eu_backoff_reservation_locked(list, ticket); | 153 | ttm_eu_backoff_reservation_locked(list); |
| 152 | spin_unlock(&glob->lru_lock); | 154 | spin_unlock(&glob->lru_lock); |
| 153 | ttm_eu_list_ref_sub(list); | 155 | ttm_eu_list_ref_sub(list); |
| 154 | ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, | 156 | ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, |
| @@ -175,7 +177,8 @@ retry: | |||
| 175 | } | 177 | } |
| 176 | } | 178 | } |
| 177 | 179 | ||
| 178 | ww_acquire_done(ticket); | 180 | if (ticket) |
| 181 | ww_acquire_done(ticket); | ||
| 179 | spin_lock(&glob->lru_lock); | 182 | spin_lock(&glob->lru_lock); |
| 180 | ttm_eu_del_from_lru_locked(list); | 183 | ttm_eu_del_from_lru_locked(list); |
| 181 | spin_unlock(&glob->lru_lock); | 184 | spin_unlock(&glob->lru_lock); |
| @@ -184,12 +187,14 @@ retry: | |||
| 184 | 187 | ||
| 185 | err: | 188 | err: |
| 186 | spin_lock(&glob->lru_lock); | 189 | spin_lock(&glob->lru_lock); |
| 187 | ttm_eu_backoff_reservation_locked(list, ticket); | 190 | ttm_eu_backoff_reservation_locked(list); |
| 188 | spin_unlock(&glob->lru_lock); | 191 | spin_unlock(&glob->lru_lock); |
| 189 | ttm_eu_list_ref_sub(list); | 192 | ttm_eu_list_ref_sub(list); |
| 190 | err_fini: | 193 | err_fini: |
| 191 | ww_acquire_done(ticket); | 194 | if (ticket) { |
| 192 | ww_acquire_fini(ticket); | 195 | ww_acquire_done(ticket); |
| 196 | ww_acquire_fini(ticket); | ||
| 197 | } | ||
| 193 | return ret; | 198 | return ret; |
| 194 | } | 199 | } |
| 195 | EXPORT_SYMBOL(ttm_eu_reserve_buffers); | 200 | EXPORT_SYMBOL(ttm_eu_reserve_buffers); |
| @@ -224,7 +229,8 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, | |||
| 224 | } | 229 | } |
| 225 | spin_unlock(&bdev->fence_lock); | 230 | spin_unlock(&bdev->fence_lock); |
| 226 | spin_unlock(&glob->lru_lock); | 231 | spin_unlock(&glob->lru_lock); |
| 227 | ww_acquire_fini(ticket); | 232 | if (ticket) |
| 233 | ww_acquire_fini(ticket); | ||
| 228 | 234 | ||
| 229 | list_for_each_entry(entry, list, head) { | 235 | list_for_each_entry(entry, list, head) { |
| 230 | if (entry->old_sync_obj) | 236 | if (entry->old_sync_obj) |
diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c index a868176c258a..6fe7b92a82d1 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /************************************************************************** | 1 | /************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA | 3 | * Copyright (c) 2009-2013 VMware, Inc., Palo Alto, CA., USA |
| 4 | * All Rights Reserved. | 4 | * All Rights Reserved. |
| 5 | * | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| @@ -26,6 +26,12 @@ | |||
| 26 | **************************************************************************/ | 26 | **************************************************************************/ |
| 27 | /* | 27 | /* |
| 28 | * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 28 | * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> |
| 29 | * | ||
| 30 | * While no substantial code is shared, the prime code is inspired by | ||
| 31 | * drm_prime.c, with | ||
| 32 | * Authors: | ||
| 33 | * Dave Airlie <airlied@redhat.com> | ||
| 34 | * Rob Clark <rob.clark@linaro.org> | ||
| 29 | */ | 35 | */ |
| 30 | /** @file ttm_ref_object.c | 36 | /** @file ttm_ref_object.c |
| 31 | * | 37 | * |
| @@ -34,6 +40,7 @@ | |||
| 34 | * and release on file close. | 40 | * and release on file close. |
| 35 | */ | 41 | */ |
| 36 | 42 | ||
| 43 | |||
| 37 | /** | 44 | /** |
| 38 | * struct ttm_object_file | 45 | * struct ttm_object_file |
| 39 | * | 46 | * |
| @@ -84,6 +91,9 @@ struct ttm_object_device { | |||
| 84 | struct drm_open_hash object_hash; | 91 | struct drm_open_hash object_hash; |
| 85 | atomic_t object_count; | 92 | atomic_t object_count; |
| 86 | struct ttm_mem_global *mem_glob; | 93 | struct ttm_mem_global *mem_glob; |
| 94 | struct dma_buf_ops ops; | ||
| 95 | void (*dmabuf_release)(struct dma_buf *dma_buf); | ||
| 96 | size_t dma_buf_size; | ||
| 87 | }; | 97 | }; |
| 88 | 98 | ||
| 89 | /** | 99 | /** |
| @@ -116,6 +126,8 @@ struct ttm_ref_object { | |||
| 116 | struct ttm_object_file *tfile; | 126 | struct ttm_object_file *tfile; |
| 117 | }; | 127 | }; |
| 118 | 128 | ||
| 129 | static void ttm_prime_dmabuf_release(struct dma_buf *dma_buf); | ||
| 130 | |||
| 119 | static inline struct ttm_object_file * | 131 | static inline struct ttm_object_file * |
| 120 | ttm_object_file_ref(struct ttm_object_file *tfile) | 132 | ttm_object_file_ref(struct ttm_object_file *tfile) |
| 121 | { | 133 | { |
| @@ -416,9 +428,10 @@ out_err: | |||
| 416 | } | 428 | } |
| 417 | EXPORT_SYMBOL(ttm_object_file_init); | 429 | EXPORT_SYMBOL(ttm_object_file_init); |
| 418 | 430 | ||
| 419 | struct ttm_object_device *ttm_object_device_init(struct ttm_mem_global | 431 | struct ttm_object_device * |
| 420 | *mem_glob, | 432 | ttm_object_device_init(struct ttm_mem_global *mem_glob, |
| 421 | unsigned int hash_order) | 433 | unsigned int hash_order, |
| 434 | const struct dma_buf_ops *ops) | ||
| 422 | { | 435 | { |
| 423 | struct ttm_object_device *tdev = kmalloc(sizeof(*tdev), GFP_KERNEL); | 436 | struct ttm_object_device *tdev = kmalloc(sizeof(*tdev), GFP_KERNEL); |
| 424 | int ret; | 437 | int ret; |
| @@ -430,10 +443,17 @@ struct ttm_object_device *ttm_object_device_init(struct ttm_mem_global | |||
| 430 | spin_lock_init(&tdev->object_lock); | 443 | spin_lock_init(&tdev->object_lock); |
| 431 | atomic_set(&tdev->object_count, 0); | 444 | atomic_set(&tdev->object_count, 0); |
| 432 | ret = drm_ht_create(&tdev->object_hash, hash_order); | 445 | ret = drm_ht_create(&tdev->object_hash, hash_order); |
| 446 | if (ret != 0) | ||
| 447 | goto out_no_object_hash; | ||
| 433 | 448 | ||
| 434 | if (likely(ret == 0)) | 449 | tdev->ops = *ops; |
| 435 | return tdev; | 450 | tdev->dmabuf_release = tdev->ops.release; |
| 451 | tdev->ops.release = ttm_prime_dmabuf_release; | ||
| 452 | tdev->dma_buf_size = ttm_round_pot(sizeof(struct dma_buf)) + | ||
| 453 | ttm_round_pot(sizeof(struct file)); | ||
| 454 | return tdev; | ||
| 436 | 455 | ||
| 456 | out_no_object_hash: | ||
| 437 | kfree(tdev); | 457 | kfree(tdev); |
| 438 | return NULL; | 458 | return NULL; |
| 439 | } | 459 | } |
| @@ -452,3 +472,225 @@ void ttm_object_device_release(struct ttm_object_device **p_tdev) | |||
| 452 | kfree(tdev); | 472 | kfree(tdev); |
| 453 | } | 473 | } |
| 454 | EXPORT_SYMBOL(ttm_object_device_release); | 474 | EXPORT_SYMBOL(ttm_object_device_release); |
| 475 | |||
| 476 | /** | ||
| 477 | * get_dma_buf_unless_doomed - get a dma_buf reference if possible. | ||
| 478 | * | ||
| 479 | * @dma_buf: Non-refcounted pointer to a struct dma-buf. | ||
| 480 | * | ||
| 481 | * Obtain a file reference from a lookup structure that doesn't refcount | ||
| 482 | * the file, but synchronizes with its release method to make sure it has | ||
| 483 | * not been freed yet. See for example kref_get_unless_zero documentation. | ||
| 484 | * Returns true if refcounting succeeds, false otherwise. | ||
| 485 | * | ||
| 486 | * Nobody really wants this as a public API yet, so let it mature here | ||
| 487 | * for some time... | ||
| 488 | */ | ||
| 489 | static bool __must_check get_dma_buf_unless_doomed(struct dma_buf *dmabuf) | ||
| 490 | { | ||
| 491 | return atomic_long_inc_not_zero(&dmabuf->file->f_count) != 0L; | ||
| 492 | } | ||
| 493 | |||
| 494 | /** | ||
| 495 | * ttm_prime_refcount_release - refcount release method for a prime object. | ||
| 496 | * | ||
| 497 | * @p_base: Pointer to ttm_base_object pointer. | ||
| 498 | * | ||
| 499 | * This is a wrapper that calls the refcount_release founction of the | ||
| 500 | * underlying object. At the same time it cleans up the prime object. | ||
| 501 | * This function is called when all references to the base object we | ||
| 502 | * derive from are gone. | ||
| 503 | */ | ||
| 504 | static void ttm_prime_refcount_release(struct ttm_base_object **p_base) | ||
| 505 | { | ||
| 506 | struct ttm_base_object *base = *p_base; | ||
| 507 | struct ttm_prime_object *prime; | ||
| 508 | |||
| 509 | *p_base = NULL; | ||
| 510 | prime = container_of(base, struct ttm_prime_object, base); | ||
| 511 | BUG_ON(prime->dma_buf != NULL); | ||
| 512 | mutex_destroy(&prime->mutex); | ||
| 513 | if (prime->refcount_release) | ||
| 514 | prime->refcount_release(&base); | ||
| 515 | } | ||
| 516 | |||
| 517 | /** | ||
| 518 | * ttm_prime_dmabuf_release - Release method for the dma-bufs we export | ||
| 519 | * | ||
| 520 | * @dma_buf: | ||
| 521 | * | ||
| 522 | * This function first calls the dma_buf release method the driver | ||
| 523 | * provides. Then it cleans up our dma_buf pointer used for lookup, | ||
| 524 | * and finally releases the reference the dma_buf has on our base | ||
| 525 | * object. | ||
| 526 | */ | ||
| 527 | static void ttm_prime_dmabuf_release(struct dma_buf *dma_buf) | ||
| 528 | { | ||
| 529 | struct ttm_prime_object *prime = | ||
| 530 | (struct ttm_prime_object *) dma_buf->priv; | ||
| 531 | struct ttm_base_object *base = &prime->base; | ||
| 532 | struct ttm_object_device *tdev = base->tfile->tdev; | ||
| 533 | |||
| 534 | if (tdev->dmabuf_release) | ||
| 535 | tdev->dmabuf_release(dma_buf); | ||
| 536 | mutex_lock(&prime->mutex); | ||
| 537 | if (prime->dma_buf == dma_buf) | ||
| 538 | prime->dma_buf = NULL; | ||
| 539 | mutex_unlock(&prime->mutex); | ||
| 540 | ttm_mem_global_free(tdev->mem_glob, tdev->dma_buf_size); | ||
| 541 | ttm_base_object_unref(&base); | ||
| 542 | } | ||
| 543 | |||
| 544 | /** | ||
| 545 | * ttm_prime_fd_to_handle - Get a base object handle from a prime fd | ||
| 546 | * | ||
| 547 | * @tfile: A struct ttm_object_file identifying the caller. | ||
| 548 | * @fd: The prime / dmabuf fd. | ||
| 549 | * @handle: The returned handle. | ||
| 550 | * | ||
| 551 | * This function returns a handle to an object that previously exported | ||
| 552 | * a dma-buf. Note that we don't handle imports yet, because we simply | ||
| 553 | * have no consumers of that implementation. | ||
| 554 | */ | ||
| 555 | int ttm_prime_fd_to_handle(struct ttm_object_file *tfile, | ||
| 556 | int fd, u32 *handle) | ||
| 557 | { | ||
| 558 | struct ttm_object_device *tdev = tfile->tdev; | ||
| 559 | struct dma_buf *dma_buf; | ||
| 560 | struct ttm_prime_object *prime; | ||
| 561 | struct ttm_base_object *base; | ||
| 562 | int ret; | ||
| 563 | |||
| 564 | dma_buf = dma_buf_get(fd); | ||
| 565 | if (IS_ERR(dma_buf)) | ||
| 566 | return PTR_ERR(dma_buf); | ||
| 567 | |||
| 568 | if (dma_buf->ops != &tdev->ops) | ||
| 569 | return -ENOSYS; | ||
| 570 | |||
| 571 | prime = (struct ttm_prime_object *) dma_buf->priv; | ||
| 572 | base = &prime->base; | ||
| 573 | *handle = base->hash.key; | ||
| 574 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL); | ||
| 575 | |||
| 576 | dma_buf_put(dma_buf); | ||
| 577 | |||
| 578 | return ret; | ||
| 579 | } | ||
| 580 | EXPORT_SYMBOL_GPL(ttm_prime_fd_to_handle); | ||
| 581 | |||
| 582 | /** | ||
| 583 | * ttm_prime_handle_to_fd - Return a dma_buf fd from a ttm prime object | ||
| 584 | * | ||
| 585 | * @tfile: Struct ttm_object_file identifying the caller. | ||
| 586 | * @handle: Handle to the object we're exporting from. | ||
| 587 | * @flags: flags for dma-buf creation. We just pass them on. | ||
| 588 | * @prime_fd: The returned file descriptor. | ||
| 589 | * | ||
| 590 | */ | ||
| 591 | int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, | ||
| 592 | uint32_t handle, uint32_t flags, | ||
| 593 | int *prime_fd) | ||
| 594 | { | ||
| 595 | struct ttm_object_device *tdev = tfile->tdev; | ||
| 596 | struct ttm_base_object *base; | ||
| 597 | struct dma_buf *dma_buf; | ||
| 598 | struct ttm_prime_object *prime; | ||
| 599 | int ret; | ||
| 600 | |||
| 601 | base = ttm_base_object_lookup(tfile, handle); | ||
| 602 | if (unlikely(base == NULL || | ||
| 603 | base->object_type != ttm_prime_type)) { | ||
| 604 | ret = -ENOENT; | ||
| 605 | goto out_unref; | ||
| 606 | } | ||
| 607 | |||
| 608 | prime = container_of(base, struct ttm_prime_object, base); | ||
| 609 | if (unlikely(!base->shareable)) { | ||
| 610 | ret = -EPERM; | ||
| 611 | goto out_unref; | ||
| 612 | } | ||
| 613 | |||
| 614 | ret = mutex_lock_interruptible(&prime->mutex); | ||
| 615 | if (unlikely(ret != 0)) { | ||
| 616 | ret = -ERESTARTSYS; | ||
| 617 | goto out_unref; | ||
| 618 | } | ||
| 619 | |||
| 620 | dma_buf = prime->dma_buf; | ||
| 621 | if (!dma_buf || !get_dma_buf_unless_doomed(dma_buf)) { | ||
| 622 | |||
| 623 | /* | ||
| 624 | * Need to create a new dma_buf, with memory accounting. | ||
| 625 | */ | ||
| 626 | ret = ttm_mem_global_alloc(tdev->mem_glob, tdev->dma_buf_size, | ||
| 627 | false, true); | ||
| 628 | if (unlikely(ret != 0)) { | ||
| 629 | mutex_unlock(&prime->mutex); | ||
| 630 | goto out_unref; | ||
| 631 | } | ||
| 632 | |||
| 633 | dma_buf = dma_buf_export(prime, &tdev->ops, | ||
| 634 | prime->size, flags); | ||
| 635 | if (IS_ERR(dma_buf)) { | ||
| 636 | ret = PTR_ERR(dma_buf); | ||
| 637 | ttm_mem_global_free(tdev->mem_glob, | ||
| 638 | tdev->dma_buf_size); | ||
| 639 | mutex_unlock(&prime->mutex); | ||
| 640 | goto out_unref; | ||
| 641 | } | ||
| 642 | |||
| 643 | /* | ||
| 644 | * dma_buf has taken the base object reference | ||
| 645 | */ | ||
| 646 | base = NULL; | ||
| 647 | prime->dma_buf = dma_buf; | ||
| 648 | } | ||
| 649 | mutex_unlock(&prime->mutex); | ||
| 650 | |||
| 651 | ret = dma_buf_fd(dma_buf, flags); | ||
| 652 | if (ret >= 0) { | ||
| 653 | *prime_fd = ret; | ||
| 654 | ret = 0; | ||
| 655 | } else | ||
| 656 | dma_buf_put(dma_buf); | ||
| 657 | |||
| 658 | out_unref: | ||
| 659 | if (base) | ||
| 660 | ttm_base_object_unref(&base); | ||
| 661 | return ret; | ||
| 662 | } | ||
| 663 | EXPORT_SYMBOL_GPL(ttm_prime_handle_to_fd); | ||
| 664 | |||
| 665 | /** | ||
| 666 | * ttm_prime_object_init - Initialize a ttm_prime_object | ||
| 667 | * | ||
| 668 | * @tfile: struct ttm_object_file identifying the caller | ||
| 669 | * @size: The size of the dma_bufs we export. | ||
| 670 | * @prime: The object to be initialized. | ||
| 671 | * @shareable: See ttm_base_object_init | ||
| 672 | * @type: See ttm_base_object_init | ||
| 673 | * @refcount_release: See ttm_base_object_init | ||
| 674 | * @ref_obj_release: See ttm_base_object_init | ||
| 675 | * | ||
| 676 | * Initializes an object which is compatible with the drm_prime model | ||
| 677 | * for data sharing between processes and devices. | ||
| 678 | */ | ||
| 679 | int ttm_prime_object_init(struct ttm_object_file *tfile, size_t size, | ||
| 680 | struct ttm_prime_object *prime, bool shareable, | ||
| 681 | enum ttm_object_type type, | ||
| 682 | void (*refcount_release) (struct ttm_base_object **), | ||
| 683 | void (*ref_obj_release) (struct ttm_base_object *, | ||
| 684 | enum ttm_ref_type ref_type)) | ||
| 685 | { | ||
| 686 | mutex_init(&prime->mutex); | ||
| 687 | prime->size = PAGE_ALIGN(size); | ||
| 688 | prime->real_type = type; | ||
| 689 | prime->dma_buf = NULL; | ||
| 690 | prime->refcount_release = refcount_release; | ||
| 691 | return ttm_base_object_init(tfile, &prime->base, shareable, | ||
| 692 | ttm_prime_type, | ||
| 693 | ttm_prime_refcount_release, | ||
| 694 | ref_obj_release); | ||
| 695 | } | ||
| 696 | EXPORT_SYMBOL(ttm_prime_object_init); | ||
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 24ffbe990736..8d67b943ac05 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c | |||
| @@ -125,6 +125,12 @@ static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask) | |||
| 125 | 125 | ||
| 126 | static void udl_gem_put_pages(struct udl_gem_object *obj) | 126 | static void udl_gem_put_pages(struct udl_gem_object *obj) |
| 127 | { | 127 | { |
| 128 | if (obj->base.import_attach) { | ||
| 129 | drm_free_large(obj->pages); | ||
| 130 | obj->pages = NULL; | ||
| 131 | return; | ||
| 132 | } | ||
| 133 | |||
| 128 | drm_gem_put_pages(&obj->base, obj->pages, false, false); | 134 | drm_gem_put_pages(&obj->base, obj->pages, false, false); |
| 129 | obj->pages = NULL; | 135 | obj->pages = NULL; |
| 130 | } | 136 | } |
diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile index 2cc6cd91ac11..9f8b690bcf52 100644 --- a/drivers/gpu/drm/vmwgfx/Makefile +++ b/drivers/gpu/drm/vmwgfx/Makefile | |||
| @@ -6,6 +6,6 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ | |||
| 6 | vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ | 6 | vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ |
| 7 | vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ | 7 | vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ |
| 8 | vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ | 8 | vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ |
| 9 | vmwgfx_surface.o | 9 | vmwgfx_surface.o vmwgfx_prime.o |
| 10 | 10 | ||
| 11 | obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o | 11 | obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index 7776e6f0aef6..0489c6152482 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | |||
| @@ -150,6 +150,8 @@ struct vmw_ttm_tt { | |||
| 150 | bool mapped; | 150 | bool mapped; |
| 151 | }; | 151 | }; |
| 152 | 152 | ||
| 153 | const size_t vmw_tt_size = sizeof(struct vmw_ttm_tt); | ||
| 154 | |||
| 153 | /** | 155 | /** |
| 154 | * Helper functions to advance a struct vmw_piter iterator. | 156 | * Helper functions to advance a struct vmw_piter iterator. |
| 155 | * | 157 | * |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 20d5485eaf98..c7a549694e59 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |||
| @@ -677,7 +677,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
| 677 | } | 677 | } |
| 678 | 678 | ||
| 679 | dev_priv->tdev = ttm_object_device_init | 679 | dev_priv->tdev = ttm_object_device_init |
| 680 | (dev_priv->mem_global_ref.object, 12); | 680 | (dev_priv->mem_global_ref.object, 12, &vmw_prime_dmabuf_ops); |
| 681 | 681 | ||
| 682 | if (unlikely(dev_priv->tdev == NULL)) { | 682 | if (unlikely(dev_priv->tdev == NULL)) { |
| 683 | DRM_ERROR("Unable to initialize TTM object management.\n"); | 683 | DRM_ERROR("Unable to initialize TTM object management.\n"); |
| @@ -1210,7 +1210,7 @@ static const struct file_operations vmwgfx_driver_fops = { | |||
| 1210 | 1210 | ||
| 1211 | static struct drm_driver driver = { | 1211 | static struct drm_driver driver = { |
| 1212 | .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | | 1212 | .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | |
| 1213 | DRIVER_MODESET, | 1213 | DRIVER_MODESET | DRIVER_PRIME, |
| 1214 | .load = vmw_driver_load, | 1214 | .load = vmw_driver_load, |
| 1215 | .unload = vmw_driver_unload, | 1215 | .unload = vmw_driver_unload, |
| 1216 | .lastclose = vmw_lastclose, | 1216 | .lastclose = vmw_lastclose, |
| @@ -1235,6 +1235,9 @@ static struct drm_driver driver = { | |||
| 1235 | .dumb_map_offset = vmw_dumb_map_offset, | 1235 | .dumb_map_offset = vmw_dumb_map_offset, |
| 1236 | .dumb_destroy = vmw_dumb_destroy, | 1236 | .dumb_destroy = vmw_dumb_destroy, |
| 1237 | 1237 | ||
| 1238 | .prime_fd_to_handle = vmw_prime_fd_to_handle, | ||
| 1239 | .prime_handle_to_fd = vmw_prime_handle_to_fd, | ||
| 1240 | |||
| 1238 | .fops = &vmwgfx_driver_fops, | 1241 | .fops = &vmwgfx_driver_fops, |
| 1239 | .name = VMWGFX_DRIVER_NAME, | 1242 | .name = VMWGFX_DRIVER_NAME, |
| 1240 | .desc = VMWGFX_DRIVER_DESC, | 1243 | .desc = VMWGFX_DRIVER_DESC, |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index e401d5dbcb96..20890ad8408b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | |||
| @@ -615,6 +615,7 @@ extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); | |||
| 615 | * TTM buffer object driver - vmwgfx_buffer.c | 615 | * TTM buffer object driver - vmwgfx_buffer.c |
| 616 | */ | 616 | */ |
| 617 | 617 | ||
| 618 | extern const size_t vmw_tt_size; | ||
| 618 | extern struct ttm_placement vmw_vram_placement; | 619 | extern struct ttm_placement vmw_vram_placement; |
| 619 | extern struct ttm_placement vmw_vram_ne_placement; | 620 | extern struct ttm_placement vmw_vram_ne_placement; |
| 620 | extern struct ttm_placement vmw_vram_sys_placement; | 621 | extern struct ttm_placement vmw_vram_sys_placement; |
| @@ -819,6 +820,20 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); | |||
| 819 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; | 820 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
| 820 | 821 | ||
| 821 | /** | 822 | /** |
| 823 | * Prime - vmwgfx_prime.c | ||
| 824 | */ | ||
| 825 | |||
| 826 | extern const struct dma_buf_ops vmw_prime_dmabuf_ops; | ||
| 827 | extern int vmw_prime_fd_to_handle(struct drm_device *dev, | ||
| 828 | struct drm_file *file_priv, | ||
| 829 | int fd, u32 *handle); | ||
| 830 | extern int vmw_prime_handle_to_fd(struct drm_device *dev, | ||
| 831 | struct drm_file *file_priv, | ||
| 832 | uint32_t handle, uint32_t flags, | ||
| 833 | int *prime_fd); | ||
| 834 | |||
| 835 | |||
| 836 | /** | ||
| 822 | * Inline helper functions | 837 | * Inline helper functions |
| 823 | */ | 838 | */ |
| 824 | 839 | ||
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index ecb3d867b426..03f1c2038631 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | |||
| @@ -75,6 +75,7 @@ void vmw_display_unit_cleanup(struct vmw_display_unit *du) | |||
| 75 | vmw_surface_unreference(&du->cursor_surface); | 75 | vmw_surface_unreference(&du->cursor_surface); |
| 76 | if (du->cursor_dmabuf) | 76 | if (du->cursor_dmabuf) |
| 77 | vmw_dmabuf_unreference(&du->cursor_dmabuf); | 77 | vmw_dmabuf_unreference(&du->cursor_dmabuf); |
| 78 | drm_sysfs_connector_remove(&du->connector); | ||
| 78 | drm_crtc_cleanup(&du->crtc); | 79 | drm_crtc_cleanup(&du->crtc); |
| 79 | drm_encoder_cleanup(&du->encoder); | 80 | drm_encoder_cleanup(&du->encoder); |
| 80 | drm_connector_cleanup(&du->connector); | 81 | drm_connector_cleanup(&du->connector); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c index 79f7e8e60529..a055a26819c2 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | |||
| @@ -260,6 +260,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) | |||
| 260 | connector->encoder = NULL; | 260 | connector->encoder = NULL; |
| 261 | encoder->crtc = NULL; | 261 | encoder->crtc = NULL; |
| 262 | crtc->fb = NULL; | 262 | crtc->fb = NULL; |
| 263 | crtc->enabled = false; | ||
| 263 | 264 | ||
| 264 | vmw_ldu_del_active(dev_priv, ldu); | 265 | vmw_ldu_del_active(dev_priv, ldu); |
| 265 | 266 | ||
| @@ -285,6 +286,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) | |||
| 285 | crtc->x = set->x; | 286 | crtc->x = set->x; |
| 286 | crtc->y = set->y; | 287 | crtc->y = set->y; |
| 287 | crtc->mode = *mode; | 288 | crtc->mode = *mode; |
| 289 | crtc->enabled = true; | ||
| 288 | 290 | ||
| 289 | vmw_ldu_add_active(dev_priv, ldu, vfb); | 291 | vmw_ldu_add_active(dev_priv, ldu, vfb); |
| 290 | 292 | ||
| @@ -369,6 +371,8 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit) | |||
| 369 | encoder->possible_crtcs = (1 << unit); | 371 | encoder->possible_crtcs = (1 << unit); |
| 370 | encoder->possible_clones = 0; | 372 | encoder->possible_clones = 0; |
| 371 | 373 | ||
| 374 | (void) drm_sysfs_connector_add(connector); | ||
| 375 | |||
| 372 | drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs); | 376 | drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs); |
| 373 | 377 | ||
| 374 | drm_mode_crtc_set_gamma_size(crtc, 256); | 378 | drm_mode_crtc_set_gamma_size(crtc, 256); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c new file mode 100644 index 000000000000..31fe32d8d65a --- /dev/null +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /************************************************************************** | ||
| 2 | * | ||
| 3 | * Copyright © 2013 VMware, Inc., Palo Alto, CA., USA | ||
| 4 | * All Rights Reserved. | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the | ||
| 8 | * "Software"), to deal in the Software without restriction, including | ||
| 9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
| 10 | * distribute, sub license, and/or sell copies of the Software, and to | ||
| 11 | * permit persons to whom the Software is furnished to do so, subject to | ||
| 12 | * the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice (including the | ||
| 15 | * next paragraph) shall be included in all copies or substantial portions | ||
| 16 | * of the Software. | ||
| 17 | * | ||
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
| 21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | * | ||
| 26 | **************************************************************************/ | ||
| 27 | /* | ||
| 28 | * Authors: | ||
| 29 | * Thomas Hellstrom <thellstrom@vmware.com> | ||
| 30 | * | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include "vmwgfx_drv.h" | ||
| 34 | #include <linux/dma-buf.h> | ||
| 35 | #include <drm/ttm/ttm_object.h> | ||
| 36 | |||
| 37 | /* | ||
| 38 | * DMA-BUF attach- and mapping methods. No need to implement | ||
| 39 | * these until we have other virtual devices use them. | ||
| 40 | */ | ||
| 41 | |||
| 42 | static int vmw_prime_map_attach(struct dma_buf *dma_buf, | ||
| 43 | struct device *target_dev, | ||
| 44 | struct dma_buf_attachment *attach) | ||
| 45 | { | ||
| 46 | return -ENOSYS; | ||
| 47 | } | ||
| 48 | |||
| 49 | static void vmw_prime_map_detach(struct dma_buf *dma_buf, | ||
| 50 | struct dma_buf_attachment *attach) | ||
| 51 | { | ||
| 52 | } | ||
| 53 | |||
| 54 | static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach, | ||
| 55 | enum dma_data_direction dir) | ||
| 56 | { | ||
| 57 | return ERR_PTR(-ENOSYS); | ||
| 58 | } | ||
| 59 | |||
| 60 | static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach, | ||
| 61 | struct sg_table *sgb, | ||
| 62 | enum dma_data_direction dir) | ||
| 63 | { | ||
| 64 | } | ||
| 65 | |||
| 66 | static void *vmw_prime_dmabuf_vmap(struct dma_buf *dma_buf) | ||
| 67 | { | ||
| 68 | return NULL; | ||
| 69 | } | ||
| 70 | |||
| 71 | static void vmw_prime_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr) | ||
| 72 | { | ||
| 73 | } | ||
| 74 | |||
| 75 | static void *vmw_prime_dmabuf_kmap_atomic(struct dma_buf *dma_buf, | ||
| 76 | unsigned long page_num) | ||
| 77 | { | ||
| 78 | return NULL; | ||
| 79 | } | ||
| 80 | |||
| 81 | static void vmw_prime_dmabuf_kunmap_atomic(struct dma_buf *dma_buf, | ||
| 82 | unsigned long page_num, void *addr) | ||
| 83 | { | ||
| 84 | |||
| 85 | } | ||
| 86 | static void *vmw_prime_dmabuf_kmap(struct dma_buf *dma_buf, | ||
| 87 | unsigned long page_num) | ||
| 88 | { | ||
| 89 | return NULL; | ||
| 90 | } | ||
| 91 | |||
| 92 | static void vmw_prime_dmabuf_kunmap(struct dma_buf *dma_buf, | ||
| 93 | unsigned long page_num, void *addr) | ||
| 94 | { | ||
| 95 | |||
| 96 | } | ||
| 97 | |||
| 98 | static int vmw_prime_dmabuf_mmap(struct dma_buf *dma_buf, | ||
| 99 | struct vm_area_struct *vma) | ||
| 100 | { | ||
| 101 | WARN_ONCE(true, "Attempted use of dmabuf mmap. Bad.\n"); | ||
| 102 | return -ENOSYS; | ||
| 103 | } | ||
| 104 | |||
| 105 | const struct dma_buf_ops vmw_prime_dmabuf_ops = { | ||
| 106 | .attach = vmw_prime_map_attach, | ||
| 107 | .detach = vmw_prime_map_detach, | ||
| 108 | .map_dma_buf = vmw_prime_map_dma_buf, | ||
| 109 | .unmap_dma_buf = vmw_prime_unmap_dma_buf, | ||
| 110 | .release = NULL, | ||
| 111 | .kmap = vmw_prime_dmabuf_kmap, | ||
| 112 | .kmap_atomic = vmw_prime_dmabuf_kmap_atomic, | ||
| 113 | .kunmap = vmw_prime_dmabuf_kunmap, | ||
| 114 | .kunmap_atomic = vmw_prime_dmabuf_kunmap_atomic, | ||
| 115 | .mmap = vmw_prime_dmabuf_mmap, | ||
| 116 | .vmap = vmw_prime_dmabuf_vmap, | ||
| 117 | .vunmap = vmw_prime_dmabuf_vunmap, | ||
| 118 | }; | ||
| 119 | |||
| 120 | int vmw_prime_fd_to_handle(struct drm_device *dev, | ||
| 121 | struct drm_file *file_priv, | ||
| 122 | int fd, u32 *handle) | ||
| 123 | { | ||
| 124 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; | ||
| 125 | |||
| 126 | return ttm_prime_fd_to_handle(tfile, fd, handle); | ||
| 127 | } | ||
| 128 | |||
| 129 | int vmw_prime_handle_to_fd(struct drm_device *dev, | ||
| 130 | struct drm_file *file_priv, | ||
| 131 | uint32_t handle, uint32_t flags, | ||
| 132 | int *prime_fd) | ||
| 133 | { | ||
| 134 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; | ||
| 135 | |||
| 136 | return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd); | ||
| 137 | } | ||
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 252501a54def..9b5ea2ac7ddf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | #define VMW_RES_EVICT_ERR_COUNT 10 | 35 | #define VMW_RES_EVICT_ERR_COUNT 10 |
| 36 | 36 | ||
| 37 | struct vmw_user_dma_buffer { | 37 | struct vmw_user_dma_buffer { |
| 38 | struct ttm_base_object base; | 38 | struct ttm_prime_object prime; |
| 39 | struct vmw_dma_buffer dma; | 39 | struct vmw_dma_buffer dma; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| @@ -297,7 +297,7 @@ int vmw_user_resource_lookup_handle(struct vmw_private *dev_priv, | |||
| 297 | if (unlikely(base == NULL)) | 297 | if (unlikely(base == NULL)) |
| 298 | return -EINVAL; | 298 | return -EINVAL; |
| 299 | 299 | ||
| 300 | if (unlikely(base->object_type != converter->object_type)) | 300 | if (unlikely(ttm_base_object_type(base) != converter->object_type)) |
| 301 | goto out_bad_resource; | 301 | goto out_bad_resource; |
| 302 | 302 | ||
| 303 | res = converter->base_obj_to_res(base); | 303 | res = converter->base_obj_to_res(base); |
| @@ -352,6 +352,38 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv, | |||
| 352 | /** | 352 | /** |
| 353 | * Buffer management. | 353 | * Buffer management. |
| 354 | */ | 354 | */ |
| 355 | |||
| 356 | /** | ||
| 357 | * vmw_dmabuf_acc_size - Calculate the pinned memory usage of buffers | ||
| 358 | * | ||
| 359 | * @dev_priv: Pointer to a struct vmw_private identifying the device. | ||
| 360 | * @size: The requested buffer size. | ||
| 361 | * @user: Whether this is an ordinary dma buffer or a user dma buffer. | ||
| 362 | */ | ||
| 363 | static size_t vmw_dmabuf_acc_size(struct vmw_private *dev_priv, size_t size, | ||
| 364 | bool user) | ||
| 365 | { | ||
| 366 | static size_t struct_size, user_struct_size; | ||
| 367 | size_t num_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; | ||
| 368 | size_t page_array_size = ttm_round_pot(num_pages * sizeof(void *)); | ||
| 369 | |||
| 370 | if (unlikely(struct_size == 0)) { | ||
| 371 | size_t backend_size = ttm_round_pot(vmw_tt_size); | ||
| 372 | |||
| 373 | struct_size = backend_size + | ||
| 374 | ttm_round_pot(sizeof(struct vmw_dma_buffer)); | ||
| 375 | user_struct_size = backend_size + | ||
| 376 | ttm_round_pot(sizeof(struct vmw_user_dma_buffer)); | ||
| 377 | } | ||
| 378 | |||
| 379 | if (dev_priv->map_mode == vmw_dma_alloc_coherent) | ||
| 380 | page_array_size += | ||
| 381 | ttm_round_pot(num_pages * sizeof(dma_addr_t)); | ||
| 382 | |||
| 383 | return ((user) ? user_struct_size : struct_size) + | ||
| 384 | page_array_size; | ||
| 385 | } | ||
| 386 | |||
| 355 | void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) | 387 | void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) |
| 356 | { | 388 | { |
| 357 | struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); | 389 | struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); |
| @@ -359,6 +391,13 @@ void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) | |||
| 359 | kfree(vmw_bo); | 391 | kfree(vmw_bo); |
| 360 | } | 392 | } |
| 361 | 393 | ||
| 394 | static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo) | ||
| 395 | { | ||
| 396 | struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); | ||
| 397 | |||
| 398 | ttm_prime_object_kfree(vmw_user_bo, prime); | ||
| 399 | } | ||
| 400 | |||
| 362 | int vmw_dmabuf_init(struct vmw_private *dev_priv, | 401 | int vmw_dmabuf_init(struct vmw_private *dev_priv, |
| 363 | struct vmw_dma_buffer *vmw_bo, | 402 | struct vmw_dma_buffer *vmw_bo, |
| 364 | size_t size, struct ttm_placement *placement, | 403 | size_t size, struct ttm_placement *placement, |
| @@ -368,28 +407,23 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv, | |||
| 368 | struct ttm_bo_device *bdev = &dev_priv->bdev; | 407 | struct ttm_bo_device *bdev = &dev_priv->bdev; |
| 369 | size_t acc_size; | 408 | size_t acc_size; |
| 370 | int ret; | 409 | int ret; |
| 410 | bool user = (bo_free == &vmw_user_dmabuf_destroy); | ||
| 371 | 411 | ||
| 372 | BUG_ON(!bo_free); | 412 | BUG_ON(!bo_free && (!user && (bo_free != vmw_dmabuf_bo_free))); |
| 373 | 413 | ||
| 374 | acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct vmw_dma_buffer)); | 414 | acc_size = vmw_dmabuf_acc_size(dev_priv, size, user); |
| 375 | memset(vmw_bo, 0, sizeof(*vmw_bo)); | 415 | memset(vmw_bo, 0, sizeof(*vmw_bo)); |
| 376 | 416 | ||
| 377 | INIT_LIST_HEAD(&vmw_bo->res_list); | 417 | INIT_LIST_HEAD(&vmw_bo->res_list); |
| 378 | 418 | ||
| 379 | ret = ttm_bo_init(bdev, &vmw_bo->base, size, | 419 | ret = ttm_bo_init(bdev, &vmw_bo->base, size, |
| 380 | ttm_bo_type_device, placement, | 420 | (user) ? ttm_bo_type_device : |
| 421 | ttm_bo_type_kernel, placement, | ||
| 381 | 0, interruptible, | 422 | 0, interruptible, |
| 382 | NULL, acc_size, NULL, bo_free); | 423 | NULL, acc_size, NULL, bo_free); |
| 383 | return ret; | 424 | return ret; |
| 384 | } | 425 | } |
| 385 | 426 | ||
| 386 | static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo) | ||
| 387 | { | ||
| 388 | struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); | ||
| 389 | |||
| 390 | ttm_base_object_kfree(vmw_user_bo, base); | ||
| 391 | } | ||
| 392 | |||
| 393 | static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) | 427 | static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) |
| 394 | { | 428 | { |
| 395 | struct vmw_user_dma_buffer *vmw_user_bo; | 429 | struct vmw_user_dma_buffer *vmw_user_bo; |
| @@ -401,7 +435,8 @@ static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) | |||
| 401 | if (unlikely(base == NULL)) | 435 | if (unlikely(base == NULL)) |
| 402 | return; | 436 | return; |
| 403 | 437 | ||
| 404 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, base); | 438 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, |
| 439 | prime.base); | ||
| 405 | bo = &vmw_user_bo->dma.base; | 440 | bo = &vmw_user_bo->dma.base; |
| 406 | ttm_bo_unref(&bo); | 441 | ttm_bo_unref(&bo); |
| 407 | } | 442 | } |
| @@ -442,18 +477,19 @@ int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv, | |||
| 442 | return ret; | 477 | return ret; |
| 443 | 478 | ||
| 444 | tmp = ttm_bo_reference(&user_bo->dma.base); | 479 | tmp = ttm_bo_reference(&user_bo->dma.base); |
| 445 | ret = ttm_base_object_init(tfile, | 480 | ret = ttm_prime_object_init(tfile, |
| 446 | &user_bo->base, | 481 | size, |
| 447 | shareable, | 482 | &user_bo->prime, |
| 448 | ttm_buffer_type, | 483 | shareable, |
| 449 | &vmw_user_dmabuf_release, NULL); | 484 | ttm_buffer_type, |
| 485 | &vmw_user_dmabuf_release, NULL); | ||
| 450 | if (unlikely(ret != 0)) { | 486 | if (unlikely(ret != 0)) { |
| 451 | ttm_bo_unref(&tmp); | 487 | ttm_bo_unref(&tmp); |
| 452 | goto out_no_base_object; | 488 | goto out_no_base_object; |
| 453 | } | 489 | } |
| 454 | 490 | ||
| 455 | *p_dma_buf = &user_bo->dma; | 491 | *p_dma_buf = &user_bo->dma; |
| 456 | *handle = user_bo->base.hash.key; | 492 | *handle = user_bo->prime.base.hash.key; |
| 457 | 493 | ||
| 458 | out_no_base_object: | 494 | out_no_base_object: |
| 459 | return ret; | 495 | return ret; |
| @@ -475,8 +511,8 @@ int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, | |||
| 475 | return -EPERM; | 511 | return -EPERM; |
| 476 | 512 | ||
| 477 | vmw_user_bo = vmw_user_dma_buffer(bo); | 513 | vmw_user_bo = vmw_user_dma_buffer(bo); |
| 478 | return (vmw_user_bo->base.tfile == tfile || | 514 | return (vmw_user_bo->prime.base.tfile == tfile || |
| 479 | vmw_user_bo->base.shareable) ? 0 : -EPERM; | 515 | vmw_user_bo->prime.base.shareable) ? 0 : -EPERM; |
| 480 | } | 516 | } |
| 481 | 517 | ||
| 482 | int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | 518 | int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
| @@ -538,14 +574,15 @@ int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, | |||
| 538 | return -ESRCH; | 574 | return -ESRCH; |
| 539 | } | 575 | } |
| 540 | 576 | ||
| 541 | if (unlikely(base->object_type != ttm_buffer_type)) { | 577 | if (unlikely(ttm_base_object_type(base) != ttm_buffer_type)) { |
| 542 | ttm_base_object_unref(&base); | 578 | ttm_base_object_unref(&base); |
| 543 | printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n", | 579 | printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n", |
| 544 | (unsigned long)handle); | 580 | (unsigned long)handle); |
| 545 | return -EINVAL; | 581 | return -EINVAL; |
| 546 | } | 582 | } |
| 547 | 583 | ||
| 548 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, base); | 584 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, |
| 585 | prime.base); | ||
| 549 | (void)ttm_bo_reference(&vmw_user_bo->dma.base); | 586 | (void)ttm_bo_reference(&vmw_user_bo->dma.base); |
| 550 | ttm_base_object_unref(&base); | 587 | ttm_base_object_unref(&base); |
| 551 | *out = &vmw_user_bo->dma; | 588 | *out = &vmw_user_bo->dma; |
| @@ -562,7 +599,8 @@ int vmw_user_dmabuf_reference(struct ttm_object_file *tfile, | |||
| 562 | return -EINVAL; | 599 | return -EINVAL; |
| 563 | 600 | ||
| 564 | user_bo = container_of(dma_buf, struct vmw_user_dma_buffer, dma); | 601 | user_bo = container_of(dma_buf, struct vmw_user_dma_buffer, dma); |
| 565 | return ttm_ref_object_add(tfile, &user_bo->base, TTM_REF_USAGE, NULL); | 602 | return ttm_ref_object_add(tfile, &user_bo->prime.base, |
| 603 | TTM_REF_USAGE, NULL); | ||
| 566 | } | 604 | } |
| 567 | 605 | ||
| 568 | /* | 606 | /* |
| @@ -777,53 +815,55 @@ err_ref: | |||
| 777 | } | 815 | } |
| 778 | 816 | ||
| 779 | 817 | ||
| 818 | /** | ||
| 819 | * vmw_dumb_create - Create a dumb kms buffer | ||
| 820 | * | ||
| 821 | * @file_priv: Pointer to a struct drm_file identifying the caller. | ||
| 822 | * @dev: Pointer to the drm device. | ||
| 823 | * @args: Pointer to a struct drm_mode_create_dumb structure | ||
| 824 | * | ||
| 825 | * This is a driver callback for the core drm create_dumb functionality. | ||
| 826 | * Note that this is very similar to the vmw_dmabuf_alloc ioctl, except | ||
| 827 | * that the arguments have a different format. | ||
| 828 | */ | ||
| 780 | int vmw_dumb_create(struct drm_file *file_priv, | 829 | int vmw_dumb_create(struct drm_file *file_priv, |
| 781 | struct drm_device *dev, | 830 | struct drm_device *dev, |
| 782 | struct drm_mode_create_dumb *args) | 831 | struct drm_mode_create_dumb *args) |
| 783 | { | 832 | { |
| 784 | struct vmw_private *dev_priv = vmw_priv(dev); | 833 | struct vmw_private *dev_priv = vmw_priv(dev); |
| 785 | struct vmw_master *vmaster = vmw_master(file_priv->master); | 834 | struct vmw_master *vmaster = vmw_master(file_priv->master); |
| 786 | struct vmw_user_dma_buffer *vmw_user_bo; | 835 | struct vmw_dma_buffer *dma_buf; |
| 787 | struct ttm_buffer_object *tmp; | ||
| 788 | int ret; | 836 | int ret; |
| 789 | 837 | ||
| 790 | args->pitch = args->width * ((args->bpp + 7) / 8); | 838 | args->pitch = args->width * ((args->bpp + 7) / 8); |
| 791 | args->size = args->pitch * args->height; | 839 | args->size = args->pitch * args->height; |
| 792 | 840 | ||
| 793 | vmw_user_bo = kzalloc(sizeof(*vmw_user_bo), GFP_KERNEL); | ||
| 794 | if (vmw_user_bo == NULL) | ||
| 795 | return -ENOMEM; | ||
| 796 | |||
| 797 | ret = ttm_read_lock(&vmaster->lock, true); | 841 | ret = ttm_read_lock(&vmaster->lock, true); |
| 798 | if (ret != 0) { | 842 | if (unlikely(ret != 0)) |
| 799 | kfree(vmw_user_bo); | ||
| 800 | return ret; | 843 | return ret; |
| 801 | } | ||
| 802 | 844 | ||
| 803 | ret = vmw_dmabuf_init(dev_priv, &vmw_user_bo->dma, args->size, | 845 | ret = vmw_user_dmabuf_alloc(dev_priv, vmw_fpriv(file_priv)->tfile, |
| 804 | &vmw_vram_sys_placement, true, | 846 | args->size, false, &args->handle, |
| 805 | &vmw_user_dmabuf_destroy); | 847 | &dma_buf); |
| 806 | if (ret != 0) | ||
| 807 | goto out_no_dmabuf; | ||
| 808 | |||
| 809 | tmp = ttm_bo_reference(&vmw_user_bo->dma.base); | ||
| 810 | ret = ttm_base_object_init(vmw_fpriv(file_priv)->tfile, | ||
| 811 | &vmw_user_bo->base, | ||
| 812 | false, | ||
| 813 | ttm_buffer_type, | ||
| 814 | &vmw_user_dmabuf_release, NULL); | ||
| 815 | if (unlikely(ret != 0)) | 848 | if (unlikely(ret != 0)) |
| 816 | goto out_no_base_object; | 849 | goto out_no_dmabuf; |
| 817 | |||
| 818 | args->handle = vmw_user_bo->base.hash.key; | ||
| 819 | 850 | ||
| 820 | out_no_base_object: | 851 | vmw_dmabuf_unreference(&dma_buf); |
| 821 | ttm_bo_unref(&tmp); | ||
| 822 | out_no_dmabuf: | 852 | out_no_dmabuf: |
| 823 | ttm_read_unlock(&vmaster->lock); | 853 | ttm_read_unlock(&vmaster->lock); |
| 824 | return ret; | 854 | return ret; |
| 825 | } | 855 | } |
| 826 | 856 | ||
| 857 | /** | ||
| 858 | * vmw_dumb_map_offset - Return the address space offset of a dumb buffer | ||
| 859 | * | ||
| 860 | * @file_priv: Pointer to a struct drm_file identifying the caller. | ||
| 861 | * @dev: Pointer to the drm device. | ||
| 862 | * @handle: Handle identifying the dumb buffer. | ||
| 863 | * @offset: The address space offset returned. | ||
| 864 | * | ||
| 865 | * This is a driver callback for the core drm dumb_map_offset functionality. | ||
| 866 | */ | ||
| 827 | int vmw_dumb_map_offset(struct drm_file *file_priv, | 867 | int vmw_dumb_map_offset(struct drm_file *file_priv, |
| 828 | struct drm_device *dev, uint32_t handle, | 868 | struct drm_device *dev, uint32_t handle, |
| 829 | uint64_t *offset) | 869 | uint64_t *offset) |
| @@ -841,6 +881,15 @@ int vmw_dumb_map_offset(struct drm_file *file_priv, | |||
| 841 | return 0; | 881 | return 0; |
| 842 | } | 882 | } |
| 843 | 883 | ||
| 884 | /** | ||
| 885 | * vmw_dumb_destroy - Destroy a dumb boffer | ||
| 886 | * | ||
| 887 | * @file_priv: Pointer to a struct drm_file identifying the caller. | ||
| 888 | * @dev: Pointer to the drm device. | ||
| 889 | * @handle: Handle identifying the dumb buffer. | ||
| 890 | * | ||
| 891 | * This is a driver callback for the core drm dumb_destroy functionality. | ||
| 892 | */ | ||
| 844 | int vmw_dumb_destroy(struct drm_file *file_priv, | 893 | int vmw_dumb_destroy(struct drm_file *file_priv, |
| 845 | struct drm_device *dev, | 894 | struct drm_device *dev, |
| 846 | uint32_t handle) | 895 | uint32_t handle) |
| @@ -994,7 +1043,6 @@ void vmw_resource_unreserve(struct vmw_resource *res, | |||
| 994 | */ | 1043 | */ |
| 995 | static int | 1044 | static int |
| 996 | vmw_resource_check_buffer(struct vmw_resource *res, | 1045 | vmw_resource_check_buffer(struct vmw_resource *res, |
| 997 | struct ww_acquire_ctx *ticket, | ||
| 998 | bool interruptible, | 1046 | bool interruptible, |
| 999 | struct ttm_validate_buffer *val_buf) | 1047 | struct ttm_validate_buffer *val_buf) |
| 1000 | { | 1048 | { |
| @@ -1011,7 +1059,7 @@ vmw_resource_check_buffer(struct vmw_resource *res, | |||
| 1011 | INIT_LIST_HEAD(&val_list); | 1059 | INIT_LIST_HEAD(&val_list); |
| 1012 | val_buf->bo = ttm_bo_reference(&res->backup->base); | 1060 | val_buf->bo = ttm_bo_reference(&res->backup->base); |
| 1013 | list_add_tail(&val_buf->head, &val_list); | 1061 | list_add_tail(&val_buf->head, &val_list); |
| 1014 | ret = ttm_eu_reserve_buffers(ticket, &val_list); | 1062 | ret = ttm_eu_reserve_buffers(NULL, &val_list); |
| 1015 | if (unlikely(ret != 0)) | 1063 | if (unlikely(ret != 0)) |
| 1016 | goto out_no_reserve; | 1064 | goto out_no_reserve; |
| 1017 | 1065 | ||
| @@ -1029,7 +1077,7 @@ vmw_resource_check_buffer(struct vmw_resource *res, | |||
| 1029 | return 0; | 1077 | return 0; |
| 1030 | 1078 | ||
| 1031 | out_no_validate: | 1079 | out_no_validate: |
| 1032 | ttm_eu_backoff_reservation(ticket, &val_list); | 1080 | ttm_eu_backoff_reservation(NULL, &val_list); |
| 1033 | out_no_reserve: | 1081 | out_no_reserve: |
| 1034 | ttm_bo_unref(&val_buf->bo); | 1082 | ttm_bo_unref(&val_buf->bo); |
| 1035 | if (backup_dirty) | 1083 | if (backup_dirty) |
| @@ -1074,8 +1122,7 @@ int vmw_resource_reserve(struct vmw_resource *res, bool no_backup) | |||
| 1074 | * @val_buf: Backup buffer information. | 1122 | * @val_buf: Backup buffer information. |
| 1075 | */ | 1123 | */ |
| 1076 | static void | 1124 | static void |
| 1077 | vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket, | 1125 | vmw_resource_backoff_reservation(struct ttm_validate_buffer *val_buf) |
| 1078 | struct ttm_validate_buffer *val_buf) | ||
| 1079 | { | 1126 | { |
| 1080 | struct list_head val_list; | 1127 | struct list_head val_list; |
| 1081 | 1128 | ||
| @@ -1084,7 +1131,7 @@ vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket, | |||
| 1084 | 1131 | ||
| 1085 | INIT_LIST_HEAD(&val_list); | 1132 | INIT_LIST_HEAD(&val_list); |
| 1086 | list_add_tail(&val_buf->head, &val_list); | 1133 | list_add_tail(&val_buf->head, &val_list); |
| 1087 | ttm_eu_backoff_reservation(ticket, &val_list); | 1134 | ttm_eu_backoff_reservation(NULL, &val_list); |
| 1088 | ttm_bo_unref(&val_buf->bo); | 1135 | ttm_bo_unref(&val_buf->bo); |
| 1089 | } | 1136 | } |
| 1090 | 1137 | ||
| @@ -1099,14 +1146,12 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible) | |||
| 1099 | { | 1146 | { |
| 1100 | struct ttm_validate_buffer val_buf; | 1147 | struct ttm_validate_buffer val_buf; |
| 1101 | const struct vmw_res_func *func = res->func; | 1148 | const struct vmw_res_func *func = res->func; |
| 1102 | struct ww_acquire_ctx ticket; | ||
| 1103 | int ret; | 1149 | int ret; |
| 1104 | 1150 | ||
| 1105 | BUG_ON(!func->may_evict); | 1151 | BUG_ON(!func->may_evict); |
| 1106 | 1152 | ||
| 1107 | val_buf.bo = NULL; | 1153 | val_buf.bo = NULL; |
| 1108 | ret = vmw_resource_check_buffer(res, &ticket, interruptible, | 1154 | ret = vmw_resource_check_buffer(res, interruptible, &val_buf); |
| 1109 | &val_buf); | ||
| 1110 | if (unlikely(ret != 0)) | 1155 | if (unlikely(ret != 0)) |
| 1111 | return ret; | 1156 | return ret; |
| 1112 | 1157 | ||
| @@ -1121,7 +1166,7 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible) | |||
| 1121 | res->backup_dirty = true; | 1166 | res->backup_dirty = true; |
| 1122 | res->res_dirty = false; | 1167 | res->res_dirty = false; |
| 1123 | out_no_unbind: | 1168 | out_no_unbind: |
| 1124 | vmw_resource_backoff_reservation(&ticket, &val_buf); | 1169 | vmw_resource_backoff_reservation(&val_buf); |
| 1125 | 1170 | ||
| 1126 | return ret; | 1171 | return ret; |
| 1127 | } | 1172 | } |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c index 26387c3d5a21..22406c8651ea 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | |||
| @@ -310,6 +310,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) | |||
| 310 | crtc->fb = NULL; | 310 | crtc->fb = NULL; |
| 311 | crtc->x = 0; | 311 | crtc->x = 0; |
| 312 | crtc->y = 0; | 312 | crtc->y = 0; |
| 313 | crtc->enabled = false; | ||
| 313 | 314 | ||
| 314 | vmw_sou_del_active(dev_priv, sou); | 315 | vmw_sou_del_active(dev_priv, sou); |
| 315 | 316 | ||
| @@ -370,6 +371,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) | |||
| 370 | crtc->fb = NULL; | 371 | crtc->fb = NULL; |
| 371 | crtc->x = 0; | 372 | crtc->x = 0; |
| 372 | crtc->y = 0; | 373 | crtc->y = 0; |
| 374 | crtc->enabled = false; | ||
| 373 | 375 | ||
| 374 | return ret; | 376 | return ret; |
| 375 | } | 377 | } |
| @@ -382,6 +384,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) | |||
| 382 | crtc->fb = fb; | 384 | crtc->fb = fb; |
| 383 | crtc->x = set->x; | 385 | crtc->x = set->x; |
| 384 | crtc->y = set->y; | 386 | crtc->y = set->y; |
| 387 | crtc->enabled = true; | ||
| 385 | 388 | ||
| 386 | return 0; | 389 | return 0; |
| 387 | } | 390 | } |
| @@ -464,6 +467,8 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit) | |||
| 464 | encoder->possible_crtcs = (1 << unit); | 467 | encoder->possible_crtcs = (1 << unit); |
| 465 | encoder->possible_clones = 0; | 468 | encoder->possible_clones = 0; |
| 466 | 469 | ||
| 470 | (void) drm_sysfs_connector_add(connector); | ||
| 471 | |||
| 467 | drm_crtc_init(dev, crtc, &vmw_screen_object_crtc_funcs); | 472 | drm_crtc_init(dev, crtc, &vmw_screen_object_crtc_funcs); |
| 468 | 473 | ||
| 469 | drm_mode_crtc_set_gamma_size(crtc, 256); | 474 | drm_mode_crtc_set_gamma_size(crtc, 256); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 582814339748..7de2ea8bd553 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | * @size: TTM accounting size for the surface. | 38 | * @size: TTM accounting size for the surface. |
| 39 | */ | 39 | */ |
| 40 | struct vmw_user_surface { | 40 | struct vmw_user_surface { |
| 41 | struct ttm_base_object base; | 41 | struct ttm_prime_object prime; |
| 42 | struct vmw_surface srf; | 42 | struct vmw_surface srf; |
| 43 | uint32_t size; | 43 | uint32_t size; |
| 44 | uint32_t backup_handle; | 44 | uint32_t backup_handle; |
| @@ -580,7 +580,8 @@ static int vmw_surface_init(struct vmw_private *dev_priv, | |||
| 580 | static struct vmw_resource * | 580 | static struct vmw_resource * |
| 581 | vmw_user_surface_base_to_res(struct ttm_base_object *base) | 581 | vmw_user_surface_base_to_res(struct ttm_base_object *base) |
| 582 | { | 582 | { |
| 583 | return &(container_of(base, struct vmw_user_surface, base)->srf.res); | 583 | return &(container_of(base, struct vmw_user_surface, |
| 584 | prime.base)->srf.res); | ||
| 584 | } | 585 | } |
| 585 | 586 | ||
| 586 | /** | 587 | /** |
| @@ -599,7 +600,7 @@ static void vmw_user_surface_free(struct vmw_resource *res) | |||
| 599 | kfree(srf->offsets); | 600 | kfree(srf->offsets); |
| 600 | kfree(srf->sizes); | 601 | kfree(srf->sizes); |
| 601 | kfree(srf->snooper.image); | 602 | kfree(srf->snooper.image); |
| 602 | ttm_base_object_kfree(user_srf, base); | 603 | ttm_prime_object_kfree(user_srf, prime); |
| 603 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); | 604 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); |
| 604 | } | 605 | } |
| 605 | 606 | ||
| @@ -616,7 +617,7 @@ static void vmw_user_surface_base_release(struct ttm_base_object **p_base) | |||
| 616 | { | 617 | { |
| 617 | struct ttm_base_object *base = *p_base; | 618 | struct ttm_base_object *base = *p_base; |
| 618 | struct vmw_user_surface *user_srf = | 619 | struct vmw_user_surface *user_srf = |
| 619 | container_of(base, struct vmw_user_surface, base); | 620 | container_of(base, struct vmw_user_surface, prime.base); |
| 620 | struct vmw_resource *res = &user_srf->srf.res; | 621 | struct vmw_resource *res = &user_srf->srf.res; |
| 621 | 622 | ||
| 622 | *p_base = NULL; | 623 | *p_base = NULL; |
| @@ -790,8 +791,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
| 790 | } | 791 | } |
| 791 | srf->snooper.crtc = NULL; | 792 | srf->snooper.crtc = NULL; |
| 792 | 793 | ||
| 793 | user_srf->base.shareable = false; | 794 | user_srf->prime.base.shareable = false; |
| 794 | user_srf->base.tfile = NULL; | 795 | user_srf->prime.base.tfile = NULL; |
| 795 | 796 | ||
| 796 | /** | 797 | /** |
| 797 | * From this point, the generic resource management functions | 798 | * From this point, the generic resource management functions |
| @@ -803,9 +804,9 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
| 803 | goto out_unlock; | 804 | goto out_unlock; |
| 804 | 805 | ||
| 805 | tmp = vmw_resource_reference(&srf->res); | 806 | tmp = vmw_resource_reference(&srf->res); |
| 806 | ret = ttm_base_object_init(tfile, &user_srf->base, | 807 | ret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime, |
| 807 | req->shareable, VMW_RES_SURFACE, | 808 | req->shareable, VMW_RES_SURFACE, |
| 808 | &vmw_user_surface_base_release, NULL); | 809 | &vmw_user_surface_base_release, NULL); |
| 809 | 810 | ||
| 810 | if (unlikely(ret != 0)) { | 811 | if (unlikely(ret != 0)) { |
| 811 | vmw_resource_unreference(&tmp); | 812 | vmw_resource_unreference(&tmp); |
| @@ -813,7 +814,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
| 813 | goto out_unlock; | 814 | goto out_unlock; |
| 814 | } | 815 | } |
| 815 | 816 | ||
| 816 | rep->sid = user_srf->base.hash.key; | 817 | rep->sid = user_srf->prime.base.hash.key; |
| 817 | vmw_resource_unreference(&res); | 818 | vmw_resource_unreference(&res); |
| 818 | 819 | ||
| 819 | ttm_read_unlock(&vmaster->lock); | 820 | ttm_read_unlock(&vmaster->lock); |
| @@ -823,7 +824,7 @@ out_no_copy: | |||
| 823 | out_no_offsets: | 824 | out_no_offsets: |
| 824 | kfree(srf->sizes); | 825 | kfree(srf->sizes); |
| 825 | out_no_sizes: | 826 | out_no_sizes: |
| 826 | ttm_base_object_kfree(user_srf, base); | 827 | ttm_prime_object_kfree(user_srf, prime); |
| 827 | out_no_user_srf: | 828 | out_no_user_srf: |
| 828 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); | 829 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); |
| 829 | out_unlock: | 830 | out_unlock: |
| @@ -859,13 +860,14 @@ int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, | |||
| 859 | return -EINVAL; | 860 | return -EINVAL; |
| 860 | } | 861 | } |
| 861 | 862 | ||
| 862 | if (unlikely(base->object_type != VMW_RES_SURFACE)) | 863 | if (unlikely(ttm_base_object_type(base) != VMW_RES_SURFACE)) |
| 863 | goto out_bad_resource; | 864 | goto out_bad_resource; |
| 864 | 865 | ||
| 865 | user_srf = container_of(base, struct vmw_user_surface, base); | 866 | user_srf = container_of(base, struct vmw_user_surface, prime.base); |
| 866 | srf = &user_srf->srf; | 867 | srf = &user_srf->srf; |
| 867 | 868 | ||
| 868 | ret = ttm_ref_object_add(tfile, &user_srf->base, TTM_REF_USAGE, NULL); | 869 | ret = ttm_ref_object_add(tfile, &user_srf->prime.base, |
| 870 | TTM_REF_USAGE, NULL); | ||
| 869 | if (unlikely(ret != 0)) { | 871 | if (unlikely(ret != 0)) { |
| 870 | DRM_ERROR("Could not add a reference to a surface.\n"); | 872 | DRM_ERROR("Could not add a reference to a surface.\n"); |
| 871 | goto out_no_reference; | 873 | goto out_no_reference; |
