diff options
Diffstat (limited to 'drivers/gpu')
124 files changed, 1556 insertions, 890 deletions
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 796dbb212a41..8492b68e873c 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h | |||
@@ -177,7 +177,7 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast, | |||
177 | 177 | ||
178 | static inline void ast_open_key(struct ast_private *ast) | 178 | static inline void ast_open_key(struct ast_private *ast) |
179 | { | 179 | { |
180 | ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xA1, 0xFF, 0x04); | 180 | ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x80, 0xA8); |
181 | } | 181 | } |
182 | 182 | ||
183 | #define AST_VIDMEM_SIZE_8M 0x00800000 | 183 | #define AST_VIDMEM_SIZE_8M 0x00800000 |
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c index b4fb86d89850..224ff965bcf7 100644 --- a/drivers/gpu/drm/drm_context.c +++ b/drivers/gpu/drm/drm_context.c | |||
@@ -42,6 +42,10 @@ | |||
42 | 42 | ||
43 | #include <drm/drmP.h> | 43 | #include <drm/drmP.h> |
44 | 44 | ||
45 | /******************************************************************/ | ||
46 | /** \name Context bitmap support */ | ||
47 | /*@{*/ | ||
48 | |||
45 | /** | 49 | /** |
46 | * Free a handle from the context bitmap. | 50 | * Free a handle from the context bitmap. |
47 | * | 51 | * |
@@ -52,48 +56,13 @@ | |||
52 | * in drm_device::ctx_idr, while holding the drm_device::struct_mutex | 56 | * in drm_device::ctx_idr, while holding the drm_device::struct_mutex |
53 | * lock. | 57 | * lock. |
54 | */ | 58 | */ |
55 | static void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle) | 59 | void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle) |
56 | { | 60 | { |
57 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
58 | return; | ||
59 | |||
60 | mutex_lock(&dev->struct_mutex); | 61 | mutex_lock(&dev->struct_mutex); |
61 | idr_remove(&dev->ctx_idr, ctx_handle); | 62 | idr_remove(&dev->ctx_idr, ctx_handle); |
62 | mutex_unlock(&dev->struct_mutex); | 63 | mutex_unlock(&dev->struct_mutex); |
63 | } | 64 | } |
64 | 65 | ||
65 | /******************************************************************/ | ||
66 | /** \name Context bitmap support */ | ||
67 | /*@{*/ | ||
68 | |||
69 | void drm_legacy_ctxbitmap_release(struct drm_device *dev, | ||
70 | struct drm_file *file_priv) | ||
71 | { | ||
72 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
73 | return; | ||
74 | |||
75 | mutex_lock(&dev->ctxlist_mutex); | ||
76 | if (!list_empty(&dev->ctxlist)) { | ||
77 | struct drm_ctx_list *pos, *n; | ||
78 | |||
79 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { | ||
80 | if (pos->tag == file_priv && | ||
81 | pos->handle != DRM_KERNEL_CONTEXT) { | ||
82 | if (dev->driver->context_dtor) | ||
83 | dev->driver->context_dtor(dev, | ||
84 | pos->handle); | ||
85 | |||
86 | drm_ctxbitmap_free(dev, pos->handle); | ||
87 | |||
88 | list_del(&pos->head); | ||
89 | kfree(pos); | ||
90 | --dev->ctx_count; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | mutex_unlock(&dev->ctxlist_mutex); | ||
95 | } | ||
96 | |||
97 | /** | 66 | /** |
98 | * Context bitmap allocation. | 67 | * Context bitmap allocation. |
99 | * | 68 | * |
@@ -121,12 +90,10 @@ static int drm_ctxbitmap_next(struct drm_device * dev) | |||
121 | * | 90 | * |
122 | * Initialise the drm_device::ctx_idr | 91 | * Initialise the drm_device::ctx_idr |
123 | */ | 92 | */ |
124 | void drm_legacy_ctxbitmap_init(struct drm_device * dev) | 93 | int drm_ctxbitmap_init(struct drm_device * dev) |
125 | { | 94 | { |
126 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
127 | return; | ||
128 | |||
129 | idr_init(&dev->ctx_idr); | 95 | idr_init(&dev->ctx_idr); |
96 | return 0; | ||
130 | } | 97 | } |
131 | 98 | ||
132 | /** | 99 | /** |
@@ -137,7 +104,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev) | |||
137 | * Free all idr members using drm_ctx_sarea_free helper function | 104 | * Free all idr members using drm_ctx_sarea_free helper function |
138 | * while holding the drm_device::struct_mutex lock. | 105 | * while holding the drm_device::struct_mutex lock. |
139 | */ | 106 | */ |
140 | void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) | 107 | void drm_ctxbitmap_cleanup(struct drm_device * dev) |
141 | { | 108 | { |
142 | mutex_lock(&dev->struct_mutex); | 109 | mutex_lock(&dev->struct_mutex); |
143 | idr_destroy(&dev->ctx_idr); | 110 | idr_destroy(&dev->ctx_idr); |
@@ -169,9 +136,6 @@ int drm_getsareactx(struct drm_device *dev, void *data, | |||
169 | struct drm_local_map *map; | 136 | struct drm_local_map *map; |
170 | struct drm_map_list *_entry; | 137 | struct drm_map_list *_entry; |
171 | 138 | ||
172 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
173 | return -EINVAL; | ||
174 | |||
175 | mutex_lock(&dev->struct_mutex); | 139 | mutex_lock(&dev->struct_mutex); |
176 | 140 | ||
177 | map = idr_find(&dev->ctx_idr, request->ctx_id); | 141 | map = idr_find(&dev->ctx_idr, request->ctx_id); |
@@ -216,9 +180,6 @@ int drm_setsareactx(struct drm_device *dev, void *data, | |||
216 | struct drm_local_map *map = NULL; | 180 | struct drm_local_map *map = NULL; |
217 | struct drm_map_list *r_list = NULL; | 181 | struct drm_map_list *r_list = NULL; |
218 | 182 | ||
219 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
220 | return -EINVAL; | ||
221 | |||
222 | mutex_lock(&dev->struct_mutex); | 183 | mutex_lock(&dev->struct_mutex); |
223 | list_for_each_entry(r_list, &dev->maplist, head) { | 184 | list_for_each_entry(r_list, &dev->maplist, head) { |
224 | if (r_list->map | 185 | if (r_list->map |
@@ -319,9 +280,6 @@ int drm_resctx(struct drm_device *dev, void *data, | |||
319 | struct drm_ctx ctx; | 280 | struct drm_ctx ctx; |
320 | int i; | 281 | int i; |
321 | 282 | ||
322 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
323 | return -EINVAL; | ||
324 | |||
325 | if (res->count >= DRM_RESERVED_CONTEXTS) { | 283 | if (res->count >= DRM_RESERVED_CONTEXTS) { |
326 | memset(&ctx, 0, sizeof(ctx)); | 284 | memset(&ctx, 0, sizeof(ctx)); |
327 | for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { | 285 | for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { |
@@ -352,9 +310,6 @@ int drm_addctx(struct drm_device *dev, void *data, | |||
352 | struct drm_ctx_list *ctx_entry; | 310 | struct drm_ctx_list *ctx_entry; |
353 | struct drm_ctx *ctx = data; | 311 | struct drm_ctx *ctx = data; |
354 | 312 | ||
355 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
356 | return -EINVAL; | ||
357 | |||
358 | ctx->handle = drm_ctxbitmap_next(dev); | 313 | ctx->handle = drm_ctxbitmap_next(dev); |
359 | if (ctx->handle == DRM_KERNEL_CONTEXT) { | 314 | if (ctx->handle == DRM_KERNEL_CONTEXT) { |
360 | /* Skip kernel's context and get a new one. */ | 315 | /* Skip kernel's context and get a new one. */ |
@@ -398,9 +353,6 @@ int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
398 | { | 353 | { |
399 | struct drm_ctx *ctx = data; | 354 | struct drm_ctx *ctx = data; |
400 | 355 | ||
401 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
402 | return -EINVAL; | ||
403 | |||
404 | /* This is 0, because we don't handle any context flags */ | 356 | /* This is 0, because we don't handle any context flags */ |
405 | ctx->flags = 0; | 357 | ctx->flags = 0; |
406 | 358 | ||
@@ -423,9 +375,6 @@ int drm_switchctx(struct drm_device *dev, void *data, | |||
423 | { | 375 | { |
424 | struct drm_ctx *ctx = data; | 376 | struct drm_ctx *ctx = data; |
425 | 377 | ||
426 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
427 | return -EINVAL; | ||
428 | |||
429 | DRM_DEBUG("%d\n", ctx->handle); | 378 | DRM_DEBUG("%d\n", ctx->handle); |
430 | return drm_context_switch(dev, dev->last_context, ctx->handle); | 379 | return drm_context_switch(dev, dev->last_context, ctx->handle); |
431 | } | 380 | } |
@@ -446,9 +395,6 @@ int drm_newctx(struct drm_device *dev, void *data, | |||
446 | { | 395 | { |
447 | struct drm_ctx *ctx = data; | 396 | struct drm_ctx *ctx = data; |
448 | 397 | ||
449 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
450 | return -EINVAL; | ||
451 | |||
452 | DRM_DEBUG("%d\n", ctx->handle); | 398 | DRM_DEBUG("%d\n", ctx->handle); |
453 | drm_context_switch_complete(dev, file_priv, ctx->handle); | 399 | drm_context_switch_complete(dev, file_priv, ctx->handle); |
454 | 400 | ||
@@ -471,9 +417,6 @@ int drm_rmctx(struct drm_device *dev, void *data, | |||
471 | { | 417 | { |
472 | struct drm_ctx *ctx = data; | 418 | struct drm_ctx *ctx = data; |
473 | 419 | ||
474 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
475 | return -EINVAL; | ||
476 | |||
477 | DRM_DEBUG("%d\n", ctx->handle); | 420 | DRM_DEBUG("%d\n", ctx->handle); |
478 | if (ctx->handle != DRM_KERNEL_CONTEXT) { | 421 | if (ctx->handle != DRM_KERNEL_CONTEXT) { |
479 | if (dev->driver->context_dtor) | 422 | if (dev->driver->context_dtor) |
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 3d13ca6e257f..f6f6cc7fc133 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -416,6 +416,14 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) | |||
416 | return; | 416 | return; |
417 | 417 | ||
418 | /* | 418 | /* |
419 | * fbdev->blank can be called from irq context in case of a panic. | ||
420 | * Since we already have our own special panic handler which will | ||
421 | * restore the fbdev console mode completely, just bail out early. | ||
422 | */ | ||
423 | if (oops_in_progress) | ||
424 | return; | ||
425 | |||
426 | /* | ||
419 | * For each CRTC in this fb, turn the connectors on/off. | 427 | * For each CRTC in this fb, turn the connectors on/off. |
420 | */ | 428 | */ |
421 | drm_modeset_lock_all(dev); | 429 | drm_modeset_lock_all(dev); |
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 4be8e09a32ef..3f84277d7036 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
@@ -439,7 +439,26 @@ int drm_release(struct inode *inode, struct file *filp) | |||
439 | if (dev->driver->driver_features & DRIVER_GEM) | 439 | if (dev->driver->driver_features & DRIVER_GEM) |
440 | drm_gem_release(dev, file_priv); | 440 | drm_gem_release(dev, file_priv); |
441 | 441 | ||
442 | drm_legacy_ctxbitmap_release(dev, file_priv); | 442 | mutex_lock(&dev->ctxlist_mutex); |
443 | if (!list_empty(&dev->ctxlist)) { | ||
444 | struct drm_ctx_list *pos, *n; | ||
445 | |||
446 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { | ||
447 | if (pos->tag == file_priv && | ||
448 | pos->handle != DRM_KERNEL_CONTEXT) { | ||
449 | if (dev->driver->context_dtor) | ||
450 | dev->driver->context_dtor(dev, | ||
451 | pos->handle); | ||
452 | |||
453 | drm_ctxbitmap_free(dev, pos->handle); | ||
454 | |||
455 | list_del(&pos->head); | ||
456 | kfree(pos); | ||
457 | --dev->ctx_count; | ||
458 | } | ||
459 | } | ||
460 | } | ||
461 | mutex_unlock(&dev->ctxlist_mutex); | ||
443 | 462 | ||
444 | mutex_lock(&dev->struct_mutex); | 463 | mutex_lock(&dev->struct_mutex); |
445 | 464 | ||
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index e7eb0276f7f1..39d864576be4 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -292,7 +292,13 @@ int drm_fill_in_dev(struct drm_device *dev, | |||
292 | goto error_out_unreg; | 292 | goto error_out_unreg; |
293 | } | 293 | } |
294 | 294 | ||
295 | drm_legacy_ctxbitmap_init(dev); | 295 | |
296 | |||
297 | retcode = drm_ctxbitmap_init(dev); | ||
298 | if (retcode) { | ||
299 | DRM_ERROR("Cannot allocate memory for context bitmap.\n"); | ||
300 | goto error_out_unreg; | ||
301 | } | ||
296 | 302 | ||
297 | if (driver->driver_features & DRIVER_GEM) { | 303 | if (driver->driver_features & DRIVER_GEM) { |
298 | retcode = drm_gem_init(dev); | 304 | retcode = drm_gem_init(dev); |
@@ -446,7 +452,7 @@ void drm_put_dev(struct drm_device *dev) | |||
446 | drm_rmmap(dev, r_list->map); | 452 | drm_rmmap(dev, r_list->map); |
447 | drm_ht_remove(&dev->map_hash); | 453 | drm_ht_remove(&dev->map_hash); |
448 | 454 | ||
449 | drm_legacy_ctxbitmap_cleanup(dev); | 455 | drm_ctxbitmap_cleanup(dev); |
450 | 456 | ||
451 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | 457 | if (drm_core_check_feature(dev, DRIVER_MODESET)) |
452 | drm_put_minor(&dev->control); | 458 | drm_put_minor(&dev->control); |
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig index 772c62a6e2ac..4752f223e5b2 100644 --- a/drivers/gpu/drm/exynos/Kconfig +++ b/drivers/gpu/drm/exynos/Kconfig | |||
@@ -1,11 +1,12 @@ | |||
1 | config DRM_EXYNOS | 1 | config DRM_EXYNOS |
2 | tristate "DRM Support for Samsung SoC EXYNOS Series" | 2 | tristate "DRM Support for Samsung SoC EXYNOS Series" |
3 | depends on DRM && (PLAT_SAMSUNG || ARCH_MULTIPLATFORM) | 3 | depends on OF && DRM && (PLAT_SAMSUNG || ARCH_MULTIPLATFORM) |
4 | select DRM_KMS_HELPER | 4 | select DRM_KMS_HELPER |
5 | select FB_CFB_FILLRECT | 5 | select FB_CFB_FILLRECT |
6 | select FB_CFB_COPYAREA | 6 | select FB_CFB_COPYAREA |
7 | select FB_CFB_IMAGEBLIT | 7 | select FB_CFB_IMAGEBLIT |
8 | select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE | 8 | select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE |
9 | select VIDEOMODE_HELPERS | ||
9 | help | 10 | help |
10 | Choose this option if you have a Samsung SoC EXYNOS chipset. | 11 | Choose this option if you have a Samsung SoC EXYNOS chipset. |
11 | If M is selected the module will be called exynosdrm. | 12 | If M is selected the module will be called exynosdrm. |
@@ -24,9 +25,8 @@ config DRM_EXYNOS_DMABUF | |||
24 | 25 | ||
25 | config DRM_EXYNOS_FIMD | 26 | config DRM_EXYNOS_FIMD |
26 | bool "Exynos DRM FIMD" | 27 | bool "Exynos DRM FIMD" |
27 | depends on OF && DRM_EXYNOS && !FB_S3C && !ARCH_MULTIPLATFORM | 28 | depends on DRM_EXYNOS && !FB_S3C && !ARCH_MULTIPLATFORM |
28 | select FB_MODE_HELPERS | 29 | select FB_MODE_HELPERS |
29 | select VIDEOMODE_HELPERS | ||
30 | help | 30 | help |
31 | Choose this option if you want to use Exynos FIMD for DRM. | 31 | Choose this option if you want to use Exynos FIMD for DRM. |
32 | 32 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_ddc.c b/drivers/gpu/drm/exynos/exynos_ddc.c index 30ef41bcd7b8..6a8c84e7c839 100644 --- a/drivers/gpu/drm/exynos/exynos_ddc.c +++ b/drivers/gpu/drm/exynos/exynos_ddc.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | 18 | #include <linux/of.h> | |
19 | 19 | ||
20 | #include "exynos_drm_drv.h" | 20 | #include "exynos_drm_drv.h" |
21 | #include "exynos_hdmi.h" | 21 | #include "exynos_hdmi.h" |
@@ -41,13 +41,6 @@ static int s5p_ddc_remove(struct i2c_client *client) | |||
41 | return 0; | 41 | return 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | static struct i2c_device_id ddc_idtable[] = { | ||
45 | {"s5p_ddc", 0}, | ||
46 | {"exynos5-hdmiddc", 0}, | ||
47 | { }, | ||
48 | }; | ||
49 | |||
50 | #ifdef CONFIG_OF | ||
51 | static struct of_device_id hdmiddc_match_types[] = { | 44 | static struct of_device_id hdmiddc_match_types[] = { |
52 | { | 45 | { |
53 | .compatible = "samsung,exynos5-hdmiddc", | 46 | .compatible = "samsung,exynos5-hdmiddc", |
@@ -57,15 +50,13 @@ static struct of_device_id hdmiddc_match_types[] = { | |||
57 | /* end node */ | 50 | /* end node */ |
58 | } | 51 | } |
59 | }; | 52 | }; |
60 | #endif | ||
61 | 53 | ||
62 | struct i2c_driver ddc_driver = { | 54 | struct i2c_driver ddc_driver = { |
63 | .driver = { | 55 | .driver = { |
64 | .name = "exynos-hdmiddc", | 56 | .name = "exynos-hdmiddc", |
65 | .owner = THIS_MODULE, | 57 | .owner = THIS_MODULE, |
66 | .of_match_table = of_match_ptr(hdmiddc_match_types), | 58 | .of_match_table = hdmiddc_match_types, |
67 | }, | 59 | }, |
68 | .id_table = ddc_idtable, | ||
69 | .probe = s5p_ddc_probe, | 60 | .probe = s5p_ddc_probe, |
70 | .remove = s5p_ddc_remove, | 61 | .remove = s5p_ddc_remove, |
71 | .command = NULL, | 62 | .command = NULL, |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c index b8ac06d92fbf..3445a0f3a6b2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_buf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c | |||
@@ -149,10 +149,8 @@ struct exynos_drm_gem_buf *exynos_drm_init_buf(struct drm_device *dev, | |||
149 | DRM_DEBUG_KMS("desired size = 0x%x\n", size); | 149 | DRM_DEBUG_KMS("desired size = 0x%x\n", size); |
150 | 150 | ||
151 | buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); | 151 | buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); |
152 | if (!buffer) { | 152 | if (!buffer) |
153 | DRM_ERROR("failed to allocate exynos_drm_gem_buf.\n"); | ||
154 | return NULL; | 153 | return NULL; |
155 | } | ||
156 | 154 | ||
157 | buffer->size = size; | 155 | buffer->size = size; |
158 | return buffer; | 156 | return buffer; |
@@ -161,11 +159,6 @@ struct exynos_drm_gem_buf *exynos_drm_init_buf(struct drm_device *dev, | |||
161 | void exynos_drm_fini_buf(struct drm_device *dev, | 159 | void exynos_drm_fini_buf(struct drm_device *dev, |
162 | struct exynos_drm_gem_buf *buffer) | 160 | struct exynos_drm_gem_buf *buffer) |
163 | { | 161 | { |
164 | if (!buffer) { | ||
165 | DRM_DEBUG_KMS("buffer is null.\n"); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | kfree(buffer); | 162 | kfree(buffer); |
170 | buffer = NULL; | 163 | buffer = NULL; |
171 | } | 164 | } |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c index 02a8bc5226ca..e082efb2fece 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_connector.c +++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <drm/exynos_drm.h> | 17 | #include <drm/exynos_drm.h> |
18 | #include "exynos_drm_drv.h" | 18 | #include "exynos_drm_drv.h" |
19 | #include "exynos_drm_encoder.h" | 19 | #include "exynos_drm_encoder.h" |
20 | #include "exynos_drm_connector.h" | ||
20 | 21 | ||
21 | #define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\ | 22 | #define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\ |
22 | drm_connector) | 23 | drm_connector) |
@@ -28,35 +29,6 @@ struct exynos_drm_connector { | |||
28 | uint32_t dpms; | 29 | uint32_t dpms; |
29 | }; | 30 | }; |
30 | 31 | ||
31 | /* convert exynos_video_timings to drm_display_mode */ | ||
32 | static inline void | ||
33 | convert_to_display_mode(struct drm_display_mode *mode, | ||
34 | struct exynos_drm_panel_info *panel) | ||
35 | { | ||
36 | struct fb_videomode *timing = &panel->timing; | ||
37 | |||
38 | mode->clock = timing->pixclock / 1000; | ||
39 | mode->vrefresh = timing->refresh; | ||
40 | |||
41 | mode->hdisplay = timing->xres; | ||
42 | mode->hsync_start = mode->hdisplay + timing->right_margin; | ||
43 | mode->hsync_end = mode->hsync_start + timing->hsync_len; | ||
44 | mode->htotal = mode->hsync_end + timing->left_margin; | ||
45 | |||
46 | mode->vdisplay = timing->yres; | ||
47 | mode->vsync_start = mode->vdisplay + timing->lower_margin; | ||
48 | mode->vsync_end = mode->vsync_start + timing->vsync_len; | ||
49 | mode->vtotal = mode->vsync_end + timing->upper_margin; | ||
50 | mode->width_mm = panel->width_mm; | ||
51 | mode->height_mm = panel->height_mm; | ||
52 | |||
53 | if (timing->vmode & FB_VMODE_INTERLACED) | ||
54 | mode->flags |= DRM_MODE_FLAG_INTERLACE; | ||
55 | |||
56 | if (timing->vmode & FB_VMODE_DOUBLE) | ||
57 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; | ||
58 | } | ||
59 | |||
60 | static int exynos_drm_connector_get_modes(struct drm_connector *connector) | 32 | static int exynos_drm_connector_get_modes(struct drm_connector *connector) |
61 | { | 33 | { |
62 | struct exynos_drm_connector *exynos_connector = | 34 | struct exynos_drm_connector *exynos_connector = |
@@ -111,7 +83,9 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector) | |||
111 | return 0; | 83 | return 0; |
112 | } | 84 | } |
113 | 85 | ||
114 | convert_to_display_mode(mode, panel); | 86 | drm_display_mode_from_videomode(&panel->vm, mode); |
87 | mode->width_mm = panel->width_mm; | ||
88 | mode->height_mm = panel->height_mm; | ||
115 | connector->display_info.width_mm = mode->width_mm; | 89 | connector->display_info.width_mm = mode->width_mm; |
116 | connector->display_info.height_mm = mode->height_mm; | 90 | connector->display_info.height_mm = mode->height_mm; |
117 | 91 | ||
@@ -278,10 +252,8 @@ struct drm_connector *exynos_drm_connector_create(struct drm_device *dev, | |||
278 | int err; | 252 | int err; |
279 | 253 | ||
280 | exynos_connector = kzalloc(sizeof(*exynos_connector), GFP_KERNEL); | 254 | exynos_connector = kzalloc(sizeof(*exynos_connector), GFP_KERNEL); |
281 | if (!exynos_connector) { | 255 | if (!exynos_connector) |
282 | DRM_ERROR("failed to allocate connector\n"); | ||
283 | return NULL; | 256 | return NULL; |
284 | } | ||
285 | 257 | ||
286 | connector = &exynos_connector->drm_connector; | 258 | connector = &exynos_connector->drm_connector; |
287 | 259 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 14f5c1d34028..ebc01503d50e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <drm/drmP.h> | 15 | #include <drm/drmP.h> |
16 | #include <drm/drm_crtc_helper.h> | 16 | #include <drm/drm_crtc_helper.h> |
17 | 17 | ||
18 | #include "exynos_drm_crtc.h" | ||
18 | #include "exynos_drm_drv.h" | 19 | #include "exynos_drm_drv.h" |
19 | #include "exynos_drm_encoder.h" | 20 | #include "exynos_drm_encoder.h" |
20 | #include "exynos_drm_plane.h" | 21 | #include "exynos_drm_plane.h" |
@@ -324,10 +325,8 @@ int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr) | |||
324 | struct drm_crtc *crtc; | 325 | struct drm_crtc *crtc; |
325 | 326 | ||
326 | exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL); | 327 | exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL); |
327 | if (!exynos_crtc) { | 328 | if (!exynos_crtc) |
328 | DRM_ERROR("failed to allocate exynos crtc\n"); | ||
329 | return -ENOMEM; | 329 | return -ENOMEM; |
330 | } | ||
331 | 330 | ||
332 | exynos_crtc->pipe = nr; | 331 | exynos_crtc->pipe = nr; |
333 | exynos_crtc->dpms = DRM_MODE_DPMS_OFF; | 332 | exynos_crtc->dpms = DRM_MODE_DPMS_OFF; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index fd76449cf452..59827cc5e770 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <drm/drmP.h> | 12 | #include <drm/drmP.h> |
13 | #include <drm/exynos_drm.h> | 13 | #include <drm/exynos_drm.h> |
14 | #include "exynos_drm_dmabuf.h" | ||
14 | #include "exynos_drm_drv.h" | 15 | #include "exynos_drm_drv.h" |
15 | #include "exynos_drm_gem.h" | 16 | #include "exynos_drm_gem.h" |
16 | 17 | ||
@@ -230,7 +231,6 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, | |||
230 | 231 | ||
231 | buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); | 232 | buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); |
232 | if (!buffer) { | 233 | if (!buffer) { |
233 | DRM_ERROR("failed to allocate exynos_drm_gem_buf.\n"); | ||
234 | ret = -ENOMEM; | 234 | ret = -ENOMEM; |
235 | goto err_unmap_attach; | 235 | goto err_unmap_attach; |
236 | } | 236 | } |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index df81d3c959b4..bb82ef78ca85 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c | |||
@@ -47,10 +47,8 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags) | |||
47 | int nr; | 47 | int nr; |
48 | 48 | ||
49 | private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL); | 49 | private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL); |
50 | if (!private) { | 50 | if (!private) |
51 | DRM_ERROR("failed to allocate private\n"); | ||
52 | return -ENOMEM; | 51 | return -ENOMEM; |
53 | } | ||
54 | 52 | ||
55 | INIT_LIST_HEAD(&private->pageflip_event_list); | 53 | INIT_LIST_HEAD(&private->pageflip_event_list); |
56 | dev->dev_private = (void *)private; | 54 | dev->dev_private = (void *)private; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c index a99a033793bc..06f1b2a09da7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c +++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c | |||
@@ -324,10 +324,8 @@ exynos_drm_encoder_create(struct drm_device *dev, | |||
324 | return NULL; | 324 | return NULL; |
325 | 325 | ||
326 | exynos_encoder = kzalloc(sizeof(*exynos_encoder), GFP_KERNEL); | 326 | exynos_encoder = kzalloc(sizeof(*exynos_encoder), GFP_KERNEL); |
327 | if (!exynos_encoder) { | 327 | if (!exynos_encoder) |
328 | DRM_ERROR("failed to allocate encoder\n"); | ||
329 | return NULL; | 328 | return NULL; |
330 | } | ||
331 | 329 | ||
332 | exynos_encoder->dpms = DRM_MODE_DPMS_OFF; | 330 | exynos_encoder->dpms = DRM_MODE_DPMS_OFF; |
333 | exynos_encoder->manager = manager; | 331 | exynos_encoder->manager = manager; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index c2d149f0408a..ea39e0ef2ae4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c | |||
@@ -156,10 +156,8 @@ exynos_drm_framebuffer_init(struct drm_device *dev, | |||
156 | } | 156 | } |
157 | 157 | ||
158 | exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); | 158 | exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); |
159 | if (!exynos_fb) { | 159 | if (!exynos_fb) |
160 | DRM_ERROR("failed to allocate exynos drm framebuffer\n"); | ||
161 | return ERR_PTR(-ENOMEM); | 160 | return ERR_PTR(-ENOMEM); |
162 | } | ||
163 | 161 | ||
164 | drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); | 162 | drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); |
165 | exynos_fb->exynos_gem_obj[0] = exynos_gem_obj; | 163 | exynos_fb->exynos_gem_obj[0] = exynos_gem_obj; |
@@ -220,10 +218,8 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, | |||
220 | int i, ret; | 218 | int i, ret; |
221 | 219 | ||
222 | exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); | 220 | exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); |
223 | if (!exynos_fb) { | 221 | if (!exynos_fb) |
224 | DRM_ERROR("failed to allocate exynos drm framebuffer\n"); | ||
225 | return ERR_PTR(-ENOMEM); | 222 | return ERR_PTR(-ENOMEM); |
226 | } | ||
227 | 223 | ||
228 | obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]); | 224 | obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]); |
229 | if (!obj) { | 225 | if (!obj) { |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index 8e60bd61137f..78e868bcf1ec 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c | |||
@@ -16,9 +16,11 @@ | |||
16 | #include <drm/drm_crtc.h> | 16 | #include <drm/drm_crtc.h> |
17 | #include <drm/drm_fb_helper.h> | 17 | #include <drm/drm_fb_helper.h> |
18 | #include <drm/drm_crtc_helper.h> | 18 | #include <drm/drm_crtc_helper.h> |
19 | #include <drm/exynos_drm.h> | ||
19 | 20 | ||
20 | #include "exynos_drm_drv.h" | 21 | #include "exynos_drm_drv.h" |
21 | #include "exynos_drm_fb.h" | 22 | #include "exynos_drm_fb.h" |
23 | #include "exynos_drm_fbdev.h" | ||
22 | #include "exynos_drm_gem.h" | 24 | #include "exynos_drm_gem.h" |
23 | #include "exynos_drm_iommu.h" | 25 | #include "exynos_drm_iommu.h" |
24 | 26 | ||
@@ -165,8 +167,18 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, | |||
165 | 167 | ||
166 | size = mode_cmd.pitches[0] * mode_cmd.height; | 168 | size = mode_cmd.pitches[0] * mode_cmd.height; |
167 | 169 | ||
168 | /* 0 means to allocate physically continuous memory */ | 170 | exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG, size); |
169 | exynos_gem_obj = exynos_drm_gem_create(dev, 0, size); | 171 | /* |
172 | * If physically contiguous memory allocation fails and if IOMMU is | ||
173 | * supported then try to get buffer from non physically contiguous | ||
174 | * memory area. | ||
175 | */ | ||
176 | if (IS_ERR(exynos_gem_obj) && is_drm_iommu_supported(dev)) { | ||
177 | dev_warn(&pdev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n"); | ||
178 | exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_NONCONTIG, | ||
179 | size); | ||
180 | } | ||
181 | |||
170 | if (IS_ERR(exynos_gem_obj)) { | 182 | if (IS_ERR(exynos_gem_obj)) { |
171 | ret = PTR_ERR(exynos_gem_obj); | 183 | ret = PTR_ERR(exynos_gem_obj); |
172 | goto err_release_framebuffer; | 184 | goto err_release_framebuffer; |
@@ -236,10 +248,8 @@ int exynos_drm_fbdev_init(struct drm_device *dev) | |||
236 | return 0; | 248 | return 0; |
237 | 249 | ||
238 | fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); | 250 | fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); |
239 | if (!fbdev) { | 251 | if (!fbdev) |
240 | DRM_ERROR("failed to allocate drm fbdev.\n"); | ||
241 | return -ENOMEM; | 252 | return -ENOMEM; |
242 | } | ||
243 | 253 | ||
244 | private->fb_helper = helper = &fbdev->drm_fb_helper; | 254 | private->fb_helper = helper = &fbdev->drm_fb_helper; |
245 | helper->funcs = &exynos_drm_fb_helper_funcs; | 255 | helper->funcs = &exynos_drm_fb_helper_funcs; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c index 6e047bd53e2f..8adfc8f1e08f 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c | |||
@@ -17,10 +17,12 @@ | |||
17 | #include <linux/regmap.h> | 17 | #include <linux/regmap.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/pm_runtime.h> | 19 | #include <linux/pm_runtime.h> |
20 | #include <linux/of.h> | ||
20 | 21 | ||
21 | #include <drm/drmP.h> | 22 | #include <drm/drmP.h> |
22 | #include <drm/exynos_drm.h> | 23 | #include <drm/exynos_drm.h> |
23 | #include "regs-fimc.h" | 24 | #include "regs-fimc.h" |
25 | #include "exynos_drm_drv.h" | ||
24 | #include "exynos_drm_ipp.h" | 26 | #include "exynos_drm_ipp.h" |
25 | #include "exynos_drm_fimc.h" | 27 | #include "exynos_drm_fimc.h" |
26 | 28 | ||
@@ -1343,10 +1345,8 @@ static int fimc_init_prop_list(struct exynos_drm_ippdrv *ippdrv) | |||
1343 | struct drm_exynos_ipp_prop_list *prop_list; | 1345 | struct drm_exynos_ipp_prop_list *prop_list; |
1344 | 1346 | ||
1345 | prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); | 1347 | prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); |
1346 | if (!prop_list) { | 1348 | if (!prop_list) |
1347 | DRM_ERROR("failed to alloc property list.\n"); | ||
1348 | return -ENOMEM; | 1349 | return -ENOMEM; |
1349 | } | ||
1350 | 1350 | ||
1351 | prop_list->version = 1; | 1351 | prop_list->version = 1; |
1352 | prop_list->writeback = 1; | 1352 | prop_list->writeback = 1; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 1c263dac3c1c..868a14d52995 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c | |||
@@ -16,10 +16,12 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/of.h> | ||
19 | #include <linux/of_device.h> | 20 | #include <linux/of_device.h> |
20 | #include <linux/pm_runtime.h> | 21 | #include <linux/pm_runtime.h> |
21 | 22 | ||
22 | #include <video/of_display_timing.h> | 23 | #include <video/of_display_timing.h> |
24 | #include <video/of_videomode.h> | ||
23 | #include <video/samsung_fimd.h> | 25 | #include <video/samsung_fimd.h> |
24 | #include <drm/exynos_drm.h> | 26 | #include <drm/exynos_drm.h> |
25 | 27 | ||
@@ -35,6 +37,8 @@ | |||
35 | * CPU Interface. | 37 | * CPU Interface. |
36 | */ | 38 | */ |
37 | 39 | ||
40 | #define FIMD_DEFAULT_FRAMERATE 60 | ||
41 | |||
38 | /* position control register for hardware window 0, 2 ~ 4.*/ | 42 | /* position control register for hardware window 0, 2 ~ 4.*/ |
39 | #define VIDOSD_A(win) (VIDOSD_BASE + 0x00 + (win) * 16) | 43 | #define VIDOSD_A(win) (VIDOSD_BASE + 0x00 + (win) * 16) |
40 | #define VIDOSD_B(win) (VIDOSD_BASE + 0x04 + (win) * 16) | 44 | #define VIDOSD_B(win) (VIDOSD_BASE + 0x04 + (win) * 16) |
@@ -65,11 +69,13 @@ struct fimd_driver_data { | |||
65 | 69 | ||
66 | unsigned int has_shadowcon:1; | 70 | unsigned int has_shadowcon:1; |
67 | unsigned int has_clksel:1; | 71 | unsigned int has_clksel:1; |
72 | unsigned int has_limited_fmt:1; | ||
68 | }; | 73 | }; |
69 | 74 | ||
70 | static struct fimd_driver_data s3c64xx_fimd_driver_data = { | 75 | static struct fimd_driver_data s3c64xx_fimd_driver_data = { |
71 | .timing_base = 0x0, | 76 | .timing_base = 0x0, |
72 | .has_clksel = 1, | 77 | .has_clksel = 1, |
78 | .has_limited_fmt = 1, | ||
73 | }; | 79 | }; |
74 | 80 | ||
75 | static struct fimd_driver_data exynos4_fimd_driver_data = { | 81 | static struct fimd_driver_data exynos4_fimd_driver_data = { |
@@ -90,6 +96,7 @@ struct fimd_win_data { | |||
90 | unsigned int fb_width; | 96 | unsigned int fb_width; |
91 | unsigned int fb_height; | 97 | unsigned int fb_height; |
92 | unsigned int bpp; | 98 | unsigned int bpp; |
99 | unsigned int pixel_format; | ||
93 | dma_addr_t dma_addr; | 100 | dma_addr_t dma_addr; |
94 | unsigned int buf_offsize; | 101 | unsigned int buf_offsize; |
95 | unsigned int line_size; /* bytes */ | 102 | unsigned int line_size; /* bytes */ |
@@ -115,11 +122,10 @@ struct fimd_context { | |||
115 | wait_queue_head_t wait_vsync_queue; | 122 | wait_queue_head_t wait_vsync_queue; |
116 | atomic_t wait_vsync_event; | 123 | atomic_t wait_vsync_event; |
117 | 124 | ||
118 | struct exynos_drm_panel_info *panel; | 125 | struct exynos_drm_panel_info panel; |
119 | struct fimd_driver_data *driver_data; | 126 | struct fimd_driver_data *driver_data; |
120 | }; | 127 | }; |
121 | 128 | ||
122 | #ifdef CONFIG_OF | ||
123 | static const struct of_device_id fimd_driver_dt_match[] = { | 129 | static const struct of_device_id fimd_driver_dt_match[] = { |
124 | { .compatible = "samsung,s3c6400-fimd", | 130 | { .compatible = "samsung,s3c6400-fimd", |
125 | .data = &s3c64xx_fimd_driver_data }, | 131 | .data = &s3c64xx_fimd_driver_data }, |
@@ -129,21 +135,14 @@ static const struct of_device_id fimd_driver_dt_match[] = { | |||
129 | .data = &exynos5_fimd_driver_data }, | 135 | .data = &exynos5_fimd_driver_data }, |
130 | {}, | 136 | {}, |
131 | }; | 137 | }; |
132 | #endif | ||
133 | 138 | ||
134 | static inline struct fimd_driver_data *drm_fimd_get_driver_data( | 139 | static inline struct fimd_driver_data *drm_fimd_get_driver_data( |
135 | struct platform_device *pdev) | 140 | struct platform_device *pdev) |
136 | { | 141 | { |
137 | #ifdef CONFIG_OF | ||
138 | const struct of_device_id *of_id = | 142 | const struct of_device_id *of_id = |
139 | of_match_device(fimd_driver_dt_match, &pdev->dev); | 143 | of_match_device(fimd_driver_dt_match, &pdev->dev); |
140 | 144 | ||
141 | if (of_id) | 145 | return (struct fimd_driver_data *)of_id->data; |
142 | return (struct fimd_driver_data *)of_id->data; | ||
143 | #endif | ||
144 | |||
145 | return (struct fimd_driver_data *) | ||
146 | platform_get_device_id(pdev)->driver_data; | ||
147 | } | 146 | } |
148 | 147 | ||
149 | static bool fimd_display_is_connected(struct device *dev) | 148 | static bool fimd_display_is_connected(struct device *dev) |
@@ -157,7 +156,7 @@ static void *fimd_get_panel(struct device *dev) | |||
157 | { | 156 | { |
158 | struct fimd_context *ctx = get_fimd_context(dev); | 157 | struct fimd_context *ctx = get_fimd_context(dev); |
159 | 158 | ||
160 | return ctx->panel; | 159 | return &ctx->panel; |
161 | } | 160 | } |
162 | 161 | ||
163 | static int fimd_check_mode(struct device *dev, struct drm_display_mode *mode) | 162 | static int fimd_check_mode(struct device *dev, struct drm_display_mode *mode) |
@@ -237,8 +236,8 @@ static void fimd_apply(struct device *subdrv_dev) | |||
237 | static void fimd_commit(struct device *dev) | 236 | static void fimd_commit(struct device *dev) |
238 | { | 237 | { |
239 | struct fimd_context *ctx = get_fimd_context(dev); | 238 | struct fimd_context *ctx = get_fimd_context(dev); |
240 | struct exynos_drm_panel_info *panel = ctx->panel; | 239 | struct exynos_drm_panel_info *panel = &ctx->panel; |
241 | struct fb_videomode *timing = &panel->timing; | 240 | struct videomode *vm = &panel->vm; |
242 | struct fimd_driver_data *driver_data; | 241 | struct fimd_driver_data *driver_data; |
243 | u32 val; | 242 | u32 val; |
244 | 243 | ||
@@ -250,22 +249,22 @@ static void fimd_commit(struct device *dev) | |||
250 | writel(ctx->vidcon1, ctx->regs + driver_data->timing_base + VIDCON1); | 249 | writel(ctx->vidcon1, ctx->regs + driver_data->timing_base + VIDCON1); |
251 | 250 | ||
252 | /* setup vertical timing values. */ | 251 | /* setup vertical timing values. */ |
253 | val = VIDTCON0_VBPD(timing->upper_margin - 1) | | 252 | val = VIDTCON0_VBPD(vm->vback_porch - 1) | |
254 | VIDTCON0_VFPD(timing->lower_margin - 1) | | 253 | VIDTCON0_VFPD(vm->vfront_porch - 1) | |
255 | VIDTCON0_VSPW(timing->vsync_len - 1); | 254 | VIDTCON0_VSPW(vm->vsync_len - 1); |
256 | writel(val, ctx->regs + driver_data->timing_base + VIDTCON0); | 255 | writel(val, ctx->regs + driver_data->timing_base + VIDTCON0); |
257 | 256 | ||
258 | /* setup horizontal timing values. */ | 257 | /* setup horizontal timing values. */ |
259 | val = VIDTCON1_HBPD(timing->left_margin - 1) | | 258 | val = VIDTCON1_HBPD(vm->hback_porch - 1) | |
260 | VIDTCON1_HFPD(timing->right_margin - 1) | | 259 | VIDTCON1_HFPD(vm->hfront_porch - 1) | |
261 | VIDTCON1_HSPW(timing->hsync_len - 1); | 260 | VIDTCON1_HSPW(vm->hsync_len - 1); |
262 | writel(val, ctx->regs + driver_data->timing_base + VIDTCON1); | 261 | writel(val, ctx->regs + driver_data->timing_base + VIDTCON1); |
263 | 262 | ||
264 | /* setup horizontal and vertical display size. */ | 263 | /* setup horizontal and vertical display size. */ |
265 | val = VIDTCON2_LINEVAL(timing->yres - 1) | | 264 | val = VIDTCON2_LINEVAL(vm->vactive - 1) | |
266 | VIDTCON2_HOZVAL(timing->xres - 1) | | 265 | VIDTCON2_HOZVAL(vm->hactive - 1) | |
267 | VIDTCON2_LINEVAL_E(timing->yres - 1) | | 266 | VIDTCON2_LINEVAL_E(vm->vactive - 1) | |
268 | VIDTCON2_HOZVAL_E(timing->xres - 1); | 267 | VIDTCON2_HOZVAL_E(vm->hactive - 1); |
269 | writel(val, ctx->regs + driver_data->timing_base + VIDTCON2); | 268 | writel(val, ctx->regs + driver_data->timing_base + VIDTCON2); |
270 | 269 | ||
271 | /* setup clock source, clock divider, enable dma. */ | 270 | /* setup clock source, clock divider, enable dma. */ |
@@ -396,6 +395,7 @@ static void fimd_win_mode_set(struct device *dev, | |||
396 | win_data->fb_height = overlay->fb_height; | 395 | win_data->fb_height = overlay->fb_height; |
397 | win_data->dma_addr = overlay->dma_addr[0] + offset; | 396 | win_data->dma_addr = overlay->dma_addr[0] + offset; |
398 | win_data->bpp = overlay->bpp; | 397 | win_data->bpp = overlay->bpp; |
398 | win_data->pixel_format = overlay->pixel_format; | ||
399 | win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) * | 399 | win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) * |
400 | (overlay->bpp >> 3); | 400 | (overlay->bpp >> 3); |
401 | win_data->line_size = overlay->crtc_width * (overlay->bpp >> 3); | 401 | win_data->line_size = overlay->crtc_width * (overlay->bpp >> 3); |
@@ -417,39 +417,38 @@ static void fimd_win_set_pixfmt(struct device *dev, unsigned int win) | |||
417 | 417 | ||
418 | val = WINCONx_ENWIN; | 418 | val = WINCONx_ENWIN; |
419 | 419 | ||
420 | switch (win_data->bpp) { | 420 | /* |
421 | case 1: | 421 | * In case of s3c64xx, window 0 doesn't support alpha channel. |
422 | val |= WINCON0_BPPMODE_1BPP; | 422 | * So the request format is ARGB8888 then change it to XRGB8888. |
423 | val |= WINCONx_BITSWP; | 423 | */ |
424 | val |= WINCONx_BURSTLEN_4WORD; | 424 | if (ctx->driver_data->has_limited_fmt && !win) { |
425 | break; | 425 | if (win_data->pixel_format == DRM_FORMAT_ARGB8888) |
426 | case 2: | 426 | win_data->pixel_format = DRM_FORMAT_XRGB8888; |
427 | val |= WINCON0_BPPMODE_2BPP; | 427 | } |
428 | val |= WINCONx_BITSWP; | 428 | |
429 | val |= WINCONx_BURSTLEN_8WORD; | 429 | switch (win_data->pixel_format) { |
430 | break; | 430 | case DRM_FORMAT_C8: |
431 | case 4: | ||
432 | val |= WINCON0_BPPMODE_4BPP; | ||
433 | val |= WINCONx_BITSWP; | ||
434 | val |= WINCONx_BURSTLEN_8WORD; | ||
435 | break; | ||
436 | case 8: | ||
437 | val |= WINCON0_BPPMODE_8BPP_PALETTE; | 431 | val |= WINCON0_BPPMODE_8BPP_PALETTE; |
438 | val |= WINCONx_BURSTLEN_8WORD; | 432 | val |= WINCONx_BURSTLEN_8WORD; |
439 | val |= WINCONx_BYTSWP; | 433 | val |= WINCONx_BYTSWP; |
440 | break; | 434 | break; |
441 | case 16: | 435 | case DRM_FORMAT_XRGB1555: |
436 | val |= WINCON0_BPPMODE_16BPP_1555; | ||
437 | val |= WINCONx_HAWSWP; | ||
438 | val |= WINCONx_BURSTLEN_16WORD; | ||
439 | break; | ||
440 | case DRM_FORMAT_RGB565: | ||
442 | val |= WINCON0_BPPMODE_16BPP_565; | 441 | val |= WINCON0_BPPMODE_16BPP_565; |
443 | val |= WINCONx_HAWSWP; | 442 | val |= WINCONx_HAWSWP; |
444 | val |= WINCONx_BURSTLEN_16WORD; | 443 | val |= WINCONx_BURSTLEN_16WORD; |
445 | break; | 444 | break; |
446 | case 24: | 445 | case DRM_FORMAT_XRGB8888: |
447 | val |= WINCON0_BPPMODE_24BPP_888; | 446 | val |= WINCON0_BPPMODE_24BPP_888; |
448 | val |= WINCONx_WSWP; | 447 | val |= WINCONx_WSWP; |
449 | val |= WINCONx_BURSTLEN_16WORD; | 448 | val |= WINCONx_BURSTLEN_16WORD; |
450 | break; | 449 | break; |
451 | case 32: | 450 | case DRM_FORMAT_ARGB8888: |
452 | val |= WINCON1_BPPMODE_28BPP_A4888 | 451 | val |= WINCON1_BPPMODE_25BPP_A1888 |
453 | | WINCON1_BLD_PIX | WINCON1_ALPHA_SEL; | 452 | | WINCON1_BLD_PIX | WINCON1_ALPHA_SEL; |
454 | val |= WINCONx_WSWP; | 453 | val |= WINCONx_WSWP; |
455 | val |= WINCONx_BURSTLEN_16WORD; | 454 | val |= WINCONx_BURSTLEN_16WORD; |
@@ -746,45 +745,54 @@ static void fimd_subdrv_remove(struct drm_device *drm_dev, struct device *dev) | |||
746 | drm_iommu_detach_device(drm_dev, dev); | 745 | drm_iommu_detach_device(drm_dev, dev); |
747 | } | 746 | } |
748 | 747 | ||
749 | static int fimd_calc_clkdiv(struct fimd_context *ctx, | 748 | static int fimd_configure_clocks(struct fimd_context *ctx, struct device *dev) |
750 | struct fb_videomode *timing) | ||
751 | { | 749 | { |
752 | unsigned long clk = clk_get_rate(ctx->lcd_clk); | 750 | struct videomode *vm = &ctx->panel.vm; |
753 | u32 retrace; | 751 | unsigned long clk; |
754 | u32 clkdiv; | 752 | |
755 | u32 best_framerate = 0; | 753 | ctx->bus_clk = devm_clk_get(dev, "fimd"); |
756 | u32 framerate; | 754 | if (IS_ERR(ctx->bus_clk)) { |
757 | 755 | dev_err(dev, "failed to get bus clock\n"); | |
758 | retrace = timing->left_margin + timing->hsync_len + | 756 | return PTR_ERR(ctx->bus_clk); |
759 | timing->right_margin + timing->xres; | 757 | } |
760 | retrace *= timing->upper_margin + timing->vsync_len + | 758 | |
761 | timing->lower_margin + timing->yres; | 759 | ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd"); |
762 | 760 | if (IS_ERR(ctx->lcd_clk)) { | |
763 | /* default framerate is 60Hz */ | 761 | dev_err(dev, "failed to get lcd clock\n"); |
764 | if (!timing->refresh) | 762 | return PTR_ERR(ctx->lcd_clk); |
765 | timing->refresh = 60; | 763 | } |
766 | 764 | ||
767 | clk /= retrace; | 765 | clk = clk_get_rate(ctx->lcd_clk); |
768 | 766 | if (clk == 0) { | |
769 | for (clkdiv = 1; clkdiv < 0x100; clkdiv++) { | 767 | dev_err(dev, "error getting sclk_fimd clock rate\n"); |
770 | int tmp; | 768 | return -EINVAL; |
771 | 769 | } | |
772 | /* get best framerate */ | 770 | |
773 | framerate = clk / clkdiv; | 771 | if (vm->pixelclock == 0) { |
774 | tmp = timing->refresh - framerate; | 772 | unsigned long c; |
775 | if (tmp < 0) { | 773 | c = vm->hactive + vm->hback_porch + vm->hfront_porch + |
776 | best_framerate = framerate; | 774 | vm->hsync_len; |
777 | continue; | 775 | c *= vm->vactive + vm->vback_porch + vm->vfront_porch + |
778 | } else { | 776 | vm->vsync_len; |
779 | if (!best_framerate) | 777 | vm->pixelclock = c * FIMD_DEFAULT_FRAMERATE; |
780 | best_framerate = framerate; | 778 | if (vm->pixelclock == 0) { |
781 | else if (tmp < (best_framerate - framerate)) | 779 | dev_err(dev, "incorrect display timings\n"); |
782 | best_framerate = framerate; | 780 | return -EINVAL; |
783 | break; | ||
784 | } | 781 | } |
782 | dev_warn(dev, "pixel clock recalculated to %luHz (%dHz frame rate)\n", | ||
783 | vm->pixelclock, FIMD_DEFAULT_FRAMERATE); | ||
785 | } | 784 | } |
785 | ctx->clkdiv = DIV_ROUND_UP(clk, vm->pixelclock); | ||
786 | if (ctx->clkdiv > 256) { | ||
787 | dev_warn(dev, "calculated pixel clock divider too high (%u), lowered to 256\n", | ||
788 | ctx->clkdiv); | ||
789 | ctx->clkdiv = 256; | ||
790 | } | ||
791 | vm->pixelclock = clk / ctx->clkdiv; | ||
792 | DRM_DEBUG_KMS("pixel clock = %lu, clkdiv = %d\n", vm->pixelclock, | ||
793 | ctx->clkdiv); | ||
786 | 794 | ||
787 | return clkdiv; | 795 | return 0; |
788 | } | 796 | } |
789 | 797 | ||
790 | static void fimd_clear_win(struct fimd_context *ctx, int win) | 798 | static void fimd_clear_win(struct fimd_context *ctx, int win) |
@@ -876,59 +884,53 @@ static int fimd_activate(struct fimd_context *ctx, bool enable) | |||
876 | return 0; | 884 | return 0; |
877 | } | 885 | } |
878 | 886 | ||
887 | static int fimd_get_platform_data(struct fimd_context *ctx, struct device *dev) | ||
888 | { | ||
889 | struct videomode *vm; | ||
890 | int ret; | ||
891 | |||
892 | vm = &ctx->panel.vm; | ||
893 | ret = of_get_videomode(dev->of_node, vm, OF_USE_NATIVE_MODE); | ||
894 | if (ret) { | ||
895 | DRM_ERROR("failed: of_get_videomode() : %d\n", ret); | ||
896 | return ret; | ||
897 | } | ||
898 | |||
899 | if (vm->flags & DISPLAY_FLAGS_VSYNC_LOW) | ||
900 | ctx->vidcon1 |= VIDCON1_INV_VSYNC; | ||
901 | if (vm->flags & DISPLAY_FLAGS_HSYNC_LOW) | ||
902 | ctx->vidcon1 |= VIDCON1_INV_HSYNC; | ||
903 | if (vm->flags & DISPLAY_FLAGS_DE_LOW) | ||
904 | ctx->vidcon1 |= VIDCON1_INV_VDEN; | ||
905 | if (vm->flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE) | ||
906 | ctx->vidcon1 |= VIDCON1_INV_VCLK; | ||
907 | |||
908 | return 0; | ||
909 | } | ||
910 | |||
879 | static int fimd_probe(struct platform_device *pdev) | 911 | static int fimd_probe(struct platform_device *pdev) |
880 | { | 912 | { |
881 | struct device *dev = &pdev->dev; | 913 | struct device *dev = &pdev->dev; |
882 | struct fimd_context *ctx; | 914 | struct fimd_context *ctx; |
883 | struct exynos_drm_subdrv *subdrv; | 915 | struct exynos_drm_subdrv *subdrv; |
884 | struct exynos_drm_fimd_pdata *pdata; | ||
885 | struct exynos_drm_panel_info *panel; | ||
886 | struct resource *res; | 916 | struct resource *res; |
887 | int win; | 917 | int win; |
888 | int ret = -EINVAL; | 918 | int ret = -EINVAL; |
889 | 919 | ||
890 | if (dev->of_node) { | 920 | if (!dev->of_node) |
891 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | 921 | return -ENODEV; |
892 | if (!pdata) { | ||
893 | DRM_ERROR("memory allocation for pdata failed\n"); | ||
894 | return -ENOMEM; | ||
895 | } | ||
896 | |||
897 | ret = of_get_fb_videomode(dev->of_node, &pdata->panel.timing, | ||
898 | OF_USE_NATIVE_MODE); | ||
899 | if (ret) { | ||
900 | DRM_ERROR("failed: of_get_fb_videomode() : %d\n", ret); | ||
901 | return ret; | ||
902 | } | ||
903 | } else { | ||
904 | pdata = dev->platform_data; | ||
905 | if (!pdata) { | ||
906 | DRM_ERROR("no platform data specified\n"); | ||
907 | return -EINVAL; | ||
908 | } | ||
909 | } | ||
910 | |||
911 | panel = &pdata->panel; | ||
912 | if (!panel) { | ||
913 | dev_err(dev, "panel is null.\n"); | ||
914 | return -EINVAL; | ||
915 | } | ||
916 | 922 | ||
917 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); | 923 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); |
918 | if (!ctx) | 924 | if (!ctx) |
919 | return -ENOMEM; | 925 | return -ENOMEM; |
920 | 926 | ||
921 | ctx->bus_clk = devm_clk_get(dev, "fimd"); | 927 | ret = fimd_get_platform_data(ctx, dev); |
922 | if (IS_ERR(ctx->bus_clk)) { | 928 | if (ret) |
923 | dev_err(dev, "failed to get bus clock\n"); | 929 | return ret; |
924 | return PTR_ERR(ctx->bus_clk); | ||
925 | } | ||
926 | 930 | ||
927 | ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd"); | 931 | ret = fimd_configure_clocks(ctx, dev); |
928 | if (IS_ERR(ctx->lcd_clk)) { | 932 | if (ret) |
929 | dev_err(dev, "failed to get lcd clock\n"); | 933 | return ret; |
930 | return PTR_ERR(ctx->lcd_clk); | ||
931 | } | ||
932 | 934 | ||
933 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 935 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
934 | 936 | ||
@@ -952,10 +954,6 @@ static int fimd_probe(struct platform_device *pdev) | |||
952 | } | 954 | } |
953 | 955 | ||
954 | ctx->driver_data = drm_fimd_get_driver_data(pdev); | 956 | ctx->driver_data = drm_fimd_get_driver_data(pdev); |
955 | ctx->vidcon0 = pdata->vidcon0; | ||
956 | ctx->vidcon1 = pdata->vidcon1; | ||
957 | ctx->default_win = pdata->default_win; | ||
958 | ctx->panel = panel; | ||
959 | DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue); | 957 | DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue); |
960 | atomic_set(&ctx->wait_vsync_event, 0); | 958 | atomic_set(&ctx->wait_vsync_event, 0); |
961 | 959 | ||
@@ -973,12 +971,6 @@ static int fimd_probe(struct platform_device *pdev) | |||
973 | pm_runtime_enable(dev); | 971 | pm_runtime_enable(dev); |
974 | pm_runtime_get_sync(dev); | 972 | pm_runtime_get_sync(dev); |
975 | 973 | ||
976 | ctx->clkdiv = fimd_calc_clkdiv(ctx, &panel->timing); | ||
977 | panel->timing.pixclock = clk_get_rate(ctx->lcd_clk) / ctx->clkdiv; | ||
978 | |||
979 | DRM_DEBUG_KMS("pixel clock = %d, clkdiv = %d\n", | ||
980 | panel->timing.pixclock, ctx->clkdiv); | ||
981 | |||
982 | for (win = 0; win < WINDOWS_NR; win++) | 974 | for (win = 0; win < WINDOWS_NR; win++) |
983 | fimd_clear_win(ctx, win); | 975 | fimd_clear_win(ctx, win); |
984 | 976 | ||
@@ -1067,20 +1059,6 @@ static int fimd_runtime_resume(struct device *dev) | |||
1067 | } | 1059 | } |
1068 | #endif | 1060 | #endif |
1069 | 1061 | ||
1070 | static struct platform_device_id fimd_driver_ids[] = { | ||
1071 | { | ||
1072 | .name = "s3c64xx-fb", | ||
1073 | .driver_data = (unsigned long)&s3c64xx_fimd_driver_data, | ||
1074 | }, { | ||
1075 | .name = "exynos4-fb", | ||
1076 | .driver_data = (unsigned long)&exynos4_fimd_driver_data, | ||
1077 | }, { | ||
1078 | .name = "exynos5-fb", | ||
1079 | .driver_data = (unsigned long)&exynos5_fimd_driver_data, | ||
1080 | }, | ||
1081 | {}, | ||
1082 | }; | ||
1083 | |||
1084 | static const struct dev_pm_ops fimd_pm_ops = { | 1062 | static const struct dev_pm_ops fimd_pm_ops = { |
1085 | SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume) | 1063 | SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume) |
1086 | SET_RUNTIME_PM_OPS(fimd_runtime_suspend, fimd_runtime_resume, NULL) | 1064 | SET_RUNTIME_PM_OPS(fimd_runtime_suspend, fimd_runtime_resume, NULL) |
@@ -1089,11 +1067,10 @@ static const struct dev_pm_ops fimd_pm_ops = { | |||
1089 | struct platform_driver fimd_driver = { | 1067 | struct platform_driver fimd_driver = { |
1090 | .probe = fimd_probe, | 1068 | .probe = fimd_probe, |
1091 | .remove = fimd_remove, | 1069 | .remove = fimd_remove, |
1092 | .id_table = fimd_driver_ids, | ||
1093 | .driver = { | 1070 | .driver = { |
1094 | .name = "exynos4-fb", | 1071 | .name = "exynos4-fb", |
1095 | .owner = THIS_MODULE, | 1072 | .owner = THIS_MODULE, |
1096 | .pm = &fimd_pm_ops, | 1073 | .pm = &fimd_pm_ops, |
1097 | .of_match_table = of_match_ptr(fimd_driver_dt_match), | 1074 | .of_match_table = fimd_driver_dt_match, |
1098 | }, | 1075 | }, |
1099 | }; | 1076 | }; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index eddea4941483..3271fd4b1724 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <drm/drmP.h> | 23 | #include <drm/drmP.h> |
24 | #include <drm/exynos_drm.h> | 24 | #include <drm/exynos_drm.h> |
25 | #include "exynos_drm_drv.h" | 25 | #include "exynos_drm_drv.h" |
26 | #include "exynos_drm_g2d.h" | ||
26 | #include "exynos_drm_gem.h" | 27 | #include "exynos_drm_gem.h" |
27 | #include "exynos_drm_iommu.h" | 28 | #include "exynos_drm_iommu.h" |
28 | 29 | ||
@@ -446,10 +447,8 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, | |||
446 | } | 447 | } |
447 | 448 | ||
448 | g2d_userptr = kzalloc(sizeof(*g2d_userptr), GFP_KERNEL); | 449 | g2d_userptr = kzalloc(sizeof(*g2d_userptr), GFP_KERNEL); |
449 | if (!g2d_userptr) { | 450 | if (!g2d_userptr) |
450 | DRM_ERROR("failed to allocate g2d_userptr.\n"); | ||
451 | return ERR_PTR(-ENOMEM); | 451 | return ERR_PTR(-ENOMEM); |
452 | } | ||
453 | 452 | ||
454 | atomic_set(&g2d_userptr->refcount, 1); | 453 | atomic_set(&g2d_userptr->refcount, 1); |
455 | 454 | ||
@@ -499,7 +498,6 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, | |||
499 | 498 | ||
500 | sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); | 499 | sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); |
501 | if (!sgt) { | 500 | if (!sgt) { |
502 | DRM_ERROR("failed to allocate sg table.\n"); | ||
503 | ret = -ENOMEM; | 501 | ret = -ENOMEM; |
504 | goto err_free_userptr; | 502 | goto err_free_userptr; |
505 | } | 503 | } |
@@ -808,17 +806,8 @@ static void g2d_dma_start(struct g2d_data *g2d, | |||
808 | int ret; | 806 | int ret; |
809 | 807 | ||
810 | ret = pm_runtime_get_sync(g2d->dev); | 808 | ret = pm_runtime_get_sync(g2d->dev); |
811 | if (ret < 0) { | 809 | if (ret < 0) |
812 | dev_warn(g2d->dev, "failed pm power on.\n"); | ||
813 | return; | ||
814 | } | ||
815 | |||
816 | ret = clk_prepare_enable(g2d->gate_clk); | ||
817 | if (ret < 0) { | ||
818 | dev_warn(g2d->dev, "failed to enable clock.\n"); | ||
819 | pm_runtime_put_sync(g2d->dev); | ||
820 | return; | 810 | return; |
821 | } | ||
822 | 811 | ||
823 | writel_relaxed(node->dma_addr, g2d->regs + G2D_DMA_SFR_BASE_ADDR); | 812 | writel_relaxed(node->dma_addr, g2d->regs + G2D_DMA_SFR_BASE_ADDR); |
824 | writel_relaxed(G2D_DMA_START, g2d->regs + G2D_DMA_COMMAND); | 813 | writel_relaxed(G2D_DMA_START, g2d->regs + G2D_DMA_COMMAND); |
@@ -871,7 +860,6 @@ static void g2d_runqueue_worker(struct work_struct *work) | |||
871 | runqueue_work); | 860 | runqueue_work); |
872 | 861 | ||
873 | mutex_lock(&g2d->runqueue_mutex); | 862 | mutex_lock(&g2d->runqueue_mutex); |
874 | clk_disable_unprepare(g2d->gate_clk); | ||
875 | pm_runtime_put_sync(g2d->dev); | 863 | pm_runtime_put_sync(g2d->dev); |
876 | 864 | ||
877 | complete(&g2d->runqueue_node->complete); | 865 | complete(&g2d->runqueue_node->complete); |
@@ -1096,8 +1084,6 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data, | |||
1096 | 1084 | ||
1097 | e = kzalloc(sizeof(*node->event), GFP_KERNEL); | 1085 | e = kzalloc(sizeof(*node->event), GFP_KERNEL); |
1098 | if (!e) { | 1086 | if (!e) { |
1099 | dev_err(dev, "failed to allocate event\n"); | ||
1100 | |||
1101 | spin_lock_irqsave(&drm_dev->event_lock, flags); | 1087 | spin_lock_irqsave(&drm_dev->event_lock, flags); |
1102 | file->event_space += sizeof(e->event); | 1088 | file->event_space += sizeof(e->event); |
1103 | spin_unlock_irqrestore(&drm_dev->event_lock, flags); | 1089 | spin_unlock_irqrestore(&drm_dev->event_lock, flags); |
@@ -1327,10 +1313,8 @@ static int g2d_open(struct drm_device *drm_dev, struct device *dev, | |||
1327 | struct exynos_drm_g2d_private *g2d_priv; | 1313 | struct exynos_drm_g2d_private *g2d_priv; |
1328 | 1314 | ||
1329 | g2d_priv = kzalloc(sizeof(*g2d_priv), GFP_KERNEL); | 1315 | g2d_priv = kzalloc(sizeof(*g2d_priv), GFP_KERNEL); |
1330 | if (!g2d_priv) { | 1316 | if (!g2d_priv) |
1331 | dev_err(dev, "failed to allocate g2d private data\n"); | ||
1332 | return -ENOMEM; | 1317 | return -ENOMEM; |
1333 | } | ||
1334 | 1318 | ||
1335 | g2d_priv->dev = dev; | 1319 | g2d_priv->dev = dev; |
1336 | file_priv->g2d_priv = g2d_priv; | 1320 | file_priv->g2d_priv = g2d_priv; |
@@ -1386,10 +1370,8 @@ static int g2d_probe(struct platform_device *pdev) | |||
1386 | int ret; | 1370 | int ret; |
1387 | 1371 | ||
1388 | g2d = devm_kzalloc(dev, sizeof(*g2d), GFP_KERNEL); | 1372 | g2d = devm_kzalloc(dev, sizeof(*g2d), GFP_KERNEL); |
1389 | if (!g2d) { | 1373 | if (!g2d) |
1390 | dev_err(dev, "failed to allocate driver data\n"); | ||
1391 | return -ENOMEM; | 1374 | return -ENOMEM; |
1392 | } | ||
1393 | 1375 | ||
1394 | g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab", | 1376 | g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab", |
1395 | sizeof(struct g2d_runqueue_node), 0, 0, NULL); | 1377 | sizeof(struct g2d_runqueue_node), 0, 0, NULL); |
@@ -1524,14 +1506,38 @@ static int g2d_resume(struct device *dev) | |||
1524 | } | 1506 | } |
1525 | #endif | 1507 | #endif |
1526 | 1508 | ||
1527 | static SIMPLE_DEV_PM_OPS(g2d_pm_ops, g2d_suspend, g2d_resume); | 1509 | #ifdef CONFIG_PM_RUNTIME |
1510 | static int g2d_runtime_suspend(struct device *dev) | ||
1511 | { | ||
1512 | struct g2d_data *g2d = dev_get_drvdata(dev); | ||
1513 | |||
1514 | clk_disable_unprepare(g2d->gate_clk); | ||
1515 | |||
1516 | return 0; | ||
1517 | } | ||
1518 | |||
1519 | static int g2d_runtime_resume(struct device *dev) | ||
1520 | { | ||
1521 | struct g2d_data *g2d = dev_get_drvdata(dev); | ||
1522 | int ret; | ||
1523 | |||
1524 | ret = clk_prepare_enable(g2d->gate_clk); | ||
1525 | if (ret < 0) | ||
1526 | dev_warn(dev, "failed to enable clock.\n"); | ||
1527 | |||
1528 | return ret; | ||
1529 | } | ||
1530 | #endif | ||
1531 | |||
1532 | static const struct dev_pm_ops g2d_pm_ops = { | ||
1533 | SET_SYSTEM_SLEEP_PM_OPS(g2d_suspend, g2d_resume) | ||
1534 | SET_RUNTIME_PM_OPS(g2d_runtime_suspend, g2d_runtime_resume, NULL) | ||
1535 | }; | ||
1528 | 1536 | ||
1529 | #ifdef CONFIG_OF | ||
1530 | static const struct of_device_id exynos_g2d_match[] = { | 1537 | static const struct of_device_id exynos_g2d_match[] = { |
1531 | { .compatible = "samsung,exynos5250-g2d" }, | 1538 | { .compatible = "samsung,exynos5250-g2d" }, |
1532 | {}, | 1539 | {}, |
1533 | }; | 1540 | }; |
1534 | #endif | ||
1535 | 1541 | ||
1536 | struct platform_driver g2d_driver = { | 1542 | struct platform_driver g2d_driver = { |
1537 | .probe = g2d_probe, | 1543 | .probe = g2d_probe, |
@@ -1540,6 +1546,6 @@ struct platform_driver g2d_driver = { | |||
1540 | .name = "s5p-g2d", | 1546 | .name = "s5p-g2d", |
1541 | .owner = THIS_MODULE, | 1547 | .owner = THIS_MODULE, |
1542 | .pm = &g2d_pm_ops, | 1548 | .pm = &g2d_pm_ops, |
1543 | .of_match_table = of_match_ptr(exynos_g2d_match), | 1549 | .of_match_table = exynos_g2d_match, |
1544 | }, | 1550 | }, |
1545 | }; | 1551 | }; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index f3c6f40666e1..49f9cd232757 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include "exynos_drm_drv.h" | 18 | #include "exynos_drm_drv.h" |
19 | #include "exynos_drm_gem.h" | 19 | #include "exynos_drm_gem.h" |
20 | #include "exynos_drm_buf.h" | 20 | #include "exynos_drm_buf.h" |
21 | #include "exynos_drm_iommu.h" | ||
21 | 22 | ||
22 | static unsigned int convert_to_vm_err_msg(int msg) | 23 | static unsigned int convert_to_vm_err_msg(int msg) |
23 | { | 24 | { |
@@ -191,10 +192,8 @@ struct exynos_drm_gem_obj *exynos_drm_gem_init(struct drm_device *dev, | |||
191 | int ret; | 192 | int ret; |
192 | 193 | ||
193 | exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL); | 194 | exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL); |
194 | if (!exynos_gem_obj) { | 195 | if (!exynos_gem_obj) |
195 | DRM_ERROR("failed to allocate exynos gem object\n"); | ||
196 | return NULL; | 196 | return NULL; |
197 | } | ||
198 | 197 | ||
199 | exynos_gem_obj->size = size; | 198 | exynos_gem_obj->size = size; |
200 | obj = &exynos_gem_obj->base; | 199 | obj = &exynos_gem_obj->base; |
@@ -668,6 +667,18 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv, | |||
668 | 667 | ||
669 | exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG | | 668 | exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG | |
670 | EXYNOS_BO_WC, args->size); | 669 | EXYNOS_BO_WC, args->size); |
670 | /* | ||
671 | * If physically contiguous memory allocation fails and if IOMMU is | ||
672 | * supported then try to get buffer from non physically contiguous | ||
673 | * memory area. | ||
674 | */ | ||
675 | if (IS_ERR(exynos_gem_obj) && is_drm_iommu_supported(dev)) { | ||
676 | dev_warn(dev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n"); | ||
677 | exynos_gem_obj = exynos_drm_gem_create(dev, | ||
678 | EXYNOS_BO_NONCONTIG | EXYNOS_BO_WC, | ||
679 | args->size); | ||
680 | } | ||
681 | |||
671 | if (IS_ERR(exynos_gem_obj)) | 682 | if (IS_ERR(exynos_gem_obj)) |
672 | return PTR_ERR(exynos_gem_obj); | 683 | return PTR_ERR(exynos_gem_obj); |
673 | 684 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c index 90b8a1a5344c..cd6aebd53bd0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <drm/drmP.h> | 20 | #include <drm/drmP.h> |
21 | #include <drm/exynos_drm.h> | 21 | #include <drm/exynos_drm.h> |
22 | #include "regs-gsc.h" | 22 | #include "regs-gsc.h" |
23 | #include "exynos_drm_drv.h" | ||
23 | #include "exynos_drm_ipp.h" | 24 | #include "exynos_drm_ipp.h" |
24 | #include "exynos_drm_gsc.h" | 25 | #include "exynos_drm_gsc.h" |
25 | 26 | ||
@@ -1337,10 +1338,8 @@ static int gsc_init_prop_list(struct exynos_drm_ippdrv *ippdrv) | |||
1337 | struct drm_exynos_ipp_prop_list *prop_list; | 1338 | struct drm_exynos_ipp_prop_list *prop_list; |
1338 | 1339 | ||
1339 | prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); | 1340 | prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); |
1340 | if (!prop_list) { | 1341 | if (!prop_list) |
1341 | DRM_ERROR("failed to alloc property list.\n"); | ||
1342 | return -ENOMEM; | 1342 | return -ENOMEM; |
1343 | } | ||
1344 | 1343 | ||
1345 | prop_list->version = 1; | 1344 | prop_list->version = 1; |
1346 | prop_list->writeback = 1; | 1345 | prop_list->writeback = 1; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c index 8d3bc01d6834..8548b974bd59 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c | |||
@@ -403,10 +403,8 @@ static int exynos_drm_hdmi_probe(struct platform_device *pdev) | |||
403 | struct drm_hdmi_context *ctx; | 403 | struct drm_hdmi_context *ctx; |
404 | 404 | ||
405 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); | 405 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); |
406 | if (!ctx) { | 406 | if (!ctx) |
407 | DRM_LOG_KMS("failed to alloc common hdmi context.\n"); | ||
408 | return -ENOMEM; | 407 | return -ENOMEM; |
409 | } | ||
410 | 408 | ||
411 | subdrv = &ctx->subdrv; | 409 | subdrv = &ctx->subdrv; |
412 | 410 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 3799d5c2b5df..fb8db0378274 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c | |||
@@ -47,10 +47,16 @@ int drm_create_iommu_mapping(struct drm_device *drm_dev) | |||
47 | 47 | ||
48 | dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), | 48 | dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), |
49 | GFP_KERNEL); | 49 | GFP_KERNEL); |
50 | if (!dev->dma_parms) | ||
51 | goto error; | ||
52 | |||
50 | dma_set_max_seg_size(dev, 0xffffffffu); | 53 | dma_set_max_seg_size(dev, 0xffffffffu); |
51 | dev->archdata.mapping = mapping; | 54 | dev->archdata.mapping = mapping; |
52 | 55 | ||
53 | return 0; | 56 | return 0; |
57 | error: | ||
58 | arm_iommu_release_mapping(mapping); | ||
59 | return -ENOMEM; | ||
54 | } | 60 | } |
55 | 61 | ||
56 | /* | 62 | /* |
@@ -91,6 +97,9 @@ int drm_iommu_attach_device(struct drm_device *drm_dev, | |||
91 | subdrv_dev->dma_parms = devm_kzalloc(subdrv_dev, | 97 | subdrv_dev->dma_parms = devm_kzalloc(subdrv_dev, |
92 | sizeof(*subdrv_dev->dma_parms), | 98 | sizeof(*subdrv_dev->dma_parms), |
93 | GFP_KERNEL); | 99 | GFP_KERNEL); |
100 | if (!subdrv_dev->dma_parms) | ||
101 | return -ENOMEM; | ||
102 | |||
94 | dma_set_max_seg_size(subdrv_dev, 0xffffffffu); | 103 | dma_set_max_seg_size(subdrv_dev, 0xffffffffu); |
95 | 104 | ||
96 | ret = arm_iommu_attach_device(subdrv_dev, dev->archdata.mapping); | 105 | ret = arm_iommu_attach_device(subdrv_dev, dev->archdata.mapping); |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c index d2b6ab4def93..824e0705c8d3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c | |||
@@ -408,10 +408,8 @@ static struct drm_exynos_ipp_cmd_work *ipp_create_cmd_work(void) | |||
408 | struct drm_exynos_ipp_cmd_work *cmd_work; | 408 | struct drm_exynos_ipp_cmd_work *cmd_work; |
409 | 409 | ||
410 | cmd_work = kzalloc(sizeof(*cmd_work), GFP_KERNEL); | 410 | cmd_work = kzalloc(sizeof(*cmd_work), GFP_KERNEL); |
411 | if (!cmd_work) { | 411 | if (!cmd_work) |
412 | DRM_ERROR("failed to alloc cmd_work.\n"); | ||
413 | return ERR_PTR(-ENOMEM); | 412 | return ERR_PTR(-ENOMEM); |
414 | } | ||
415 | 413 | ||
416 | INIT_WORK((struct work_struct *)cmd_work, ipp_sched_cmd); | 414 | INIT_WORK((struct work_struct *)cmd_work, ipp_sched_cmd); |
417 | 415 | ||
@@ -423,10 +421,8 @@ static struct drm_exynos_ipp_event_work *ipp_create_event_work(void) | |||
423 | struct drm_exynos_ipp_event_work *event_work; | 421 | struct drm_exynos_ipp_event_work *event_work; |
424 | 422 | ||
425 | event_work = kzalloc(sizeof(*event_work), GFP_KERNEL); | 423 | event_work = kzalloc(sizeof(*event_work), GFP_KERNEL); |
426 | if (!event_work) { | 424 | if (!event_work) |
427 | DRM_ERROR("failed to alloc event_work.\n"); | ||
428 | return ERR_PTR(-ENOMEM); | 425 | return ERR_PTR(-ENOMEM); |
429 | } | ||
430 | 426 | ||
431 | INIT_WORK((struct work_struct *)event_work, ipp_sched_event); | 427 | INIT_WORK((struct work_struct *)event_work, ipp_sched_event); |
432 | 428 | ||
@@ -482,10 +478,8 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data, | |||
482 | 478 | ||
483 | /* allocate command node */ | 479 | /* allocate command node */ |
484 | c_node = kzalloc(sizeof(*c_node), GFP_KERNEL); | 480 | c_node = kzalloc(sizeof(*c_node), GFP_KERNEL); |
485 | if (!c_node) { | 481 | if (!c_node) |
486 | DRM_ERROR("failed to allocate map node.\n"); | ||
487 | return -ENOMEM; | 482 | return -ENOMEM; |
488 | } | ||
489 | 483 | ||
490 | /* create property id */ | 484 | /* create property id */ |
491 | ret = ipp_create_id(&ctx->prop_idr, &ctx->prop_lock, c_node, | 485 | ret = ipp_create_id(&ctx->prop_idr, &ctx->prop_lock, c_node, |
@@ -694,10 +688,8 @@ static struct drm_exynos_ipp_mem_node | |||
694 | mutex_lock(&c_node->mem_lock); | 688 | mutex_lock(&c_node->mem_lock); |
695 | 689 | ||
696 | m_node = kzalloc(sizeof(*m_node), GFP_KERNEL); | 690 | m_node = kzalloc(sizeof(*m_node), GFP_KERNEL); |
697 | if (!m_node) { | 691 | if (!m_node) |
698 | DRM_ERROR("failed to allocate queue node.\n"); | ||
699 | goto err_unlock; | 692 | goto err_unlock; |
700 | } | ||
701 | 693 | ||
702 | /* clear base address for error handling */ | 694 | /* clear base address for error handling */ |
703 | memset(&buf_info, 0x0, sizeof(buf_info)); | 695 | memset(&buf_info, 0x0, sizeof(buf_info)); |
@@ -798,9 +790,7 @@ static int ipp_get_event(struct drm_device *drm_dev, | |||
798 | DRM_DEBUG_KMS("ops_id[%d]buf_id[%d]\n", qbuf->ops_id, qbuf->buf_id); | 790 | DRM_DEBUG_KMS("ops_id[%d]buf_id[%d]\n", qbuf->ops_id, qbuf->buf_id); |
799 | 791 | ||
800 | e = kzalloc(sizeof(*e), GFP_KERNEL); | 792 | e = kzalloc(sizeof(*e), GFP_KERNEL); |
801 | |||
802 | if (!e) { | 793 | if (!e) { |
803 | DRM_ERROR("failed to allocate event.\n"); | ||
804 | spin_lock_irqsave(&drm_dev->event_lock, flags); | 794 | spin_lock_irqsave(&drm_dev->event_lock, flags); |
805 | file->event_space += sizeof(e->event); | 795 | file->event_space += sizeof(e->event); |
806 | spin_unlock_irqrestore(&drm_dev->event_lock, flags); | 796 | spin_unlock_irqrestore(&drm_dev->event_lock, flags); |
@@ -1780,10 +1770,8 @@ static int ipp_subdrv_open(struct drm_device *drm_dev, struct device *dev, | |||
1780 | struct exynos_drm_ipp_private *priv; | 1770 | struct exynos_drm_ipp_private *priv; |
1781 | 1771 | ||
1782 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 1772 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
1783 | if (!priv) { | 1773 | if (!priv) |
1784 | DRM_ERROR("failed to allocate priv.\n"); | ||
1785 | return -ENOMEM; | 1774 | return -ENOMEM; |
1786 | } | ||
1787 | priv->dev = dev; | 1775 | priv->dev = dev; |
1788 | file_priv->ipp_priv = priv; | 1776 | file_priv->ipp_priv = priv; |
1789 | 1777 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 6ee55e68e0a2..fcb0652e77d0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include "exynos_drm_encoder.h" | 16 | #include "exynos_drm_encoder.h" |
17 | #include "exynos_drm_fb.h" | 17 | #include "exynos_drm_fb.h" |
18 | #include "exynos_drm_gem.h" | 18 | #include "exynos_drm_gem.h" |
19 | #include "exynos_drm_plane.h" | ||
19 | 20 | ||
20 | #define to_exynos_plane(x) container_of(x, struct exynos_plane, base) | 21 | #define to_exynos_plane(x) container_of(x, struct exynos_plane, base) |
21 | 22 | ||
@@ -264,10 +265,8 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev, | |||
264 | int err; | 265 | int err; |
265 | 266 | ||
266 | exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); | 267 | exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); |
267 | if (!exynos_plane) { | 268 | if (!exynos_plane) |
268 | DRM_ERROR("failed to allocate plane\n"); | ||
269 | return NULL; | 269 | return NULL; |
270 | } | ||
271 | 270 | ||
272 | err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs, | 271 | err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs, |
273 | &exynos_plane_funcs, formats, ARRAY_SIZE(formats), | 272 | &exynos_plane_funcs, formats, ARRAY_SIZE(formats), |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index 49669aa24c45..7b901688defa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <drm/exynos_drm.h> | 21 | #include <drm/exynos_drm.h> |
22 | #include "regs-rotator.h" | 22 | #include "regs-rotator.h" |
23 | #include "exynos_drm.h" | 23 | #include "exynos_drm.h" |
24 | #include "exynos_drm_drv.h" | ||
24 | #include "exynos_drm_ipp.h" | 25 | #include "exynos_drm_ipp.h" |
25 | 26 | ||
26 | /* | 27 | /* |
@@ -471,10 +472,8 @@ static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv) | |||
471 | struct drm_exynos_ipp_prop_list *prop_list; | 472 | struct drm_exynos_ipp_prop_list *prop_list; |
472 | 473 | ||
473 | prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); | 474 | prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); |
474 | if (!prop_list) { | 475 | if (!prop_list) |
475 | DRM_ERROR("failed to alloc property list.\n"); | ||
476 | return -ENOMEM; | 476 | return -ENOMEM; |
477 | } | ||
478 | 477 | ||
479 | prop_list->version = 1; | 478 | prop_list->version = 1; |
480 | prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) | | 479 | prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) | |
@@ -631,21 +630,96 @@ static int rotator_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd) | |||
631 | return 0; | 630 | return 0; |
632 | } | 631 | } |
633 | 632 | ||
633 | static struct rot_limit_table rot_limit_tbl_4210 = { | ||
634 | .ycbcr420_2p = { | ||
635 | .min_w = 32, | ||
636 | .min_h = 32, | ||
637 | .max_w = SZ_64K, | ||
638 | .max_h = SZ_64K, | ||
639 | .align = 3, | ||
640 | }, | ||
641 | .rgb888 = { | ||
642 | .min_w = 8, | ||
643 | .min_h = 8, | ||
644 | .max_w = SZ_16K, | ||
645 | .max_h = SZ_16K, | ||
646 | .align = 2, | ||
647 | }, | ||
648 | }; | ||
649 | |||
650 | static struct rot_limit_table rot_limit_tbl_4x12 = { | ||
651 | .ycbcr420_2p = { | ||
652 | .min_w = 32, | ||
653 | .min_h = 32, | ||
654 | .max_w = SZ_32K, | ||
655 | .max_h = SZ_32K, | ||
656 | .align = 3, | ||
657 | }, | ||
658 | .rgb888 = { | ||
659 | .min_w = 8, | ||
660 | .min_h = 8, | ||
661 | .max_w = SZ_8K, | ||
662 | .max_h = SZ_8K, | ||
663 | .align = 2, | ||
664 | }, | ||
665 | }; | ||
666 | |||
667 | static struct rot_limit_table rot_limit_tbl_5250 = { | ||
668 | .ycbcr420_2p = { | ||
669 | .min_w = 32, | ||
670 | .min_h = 32, | ||
671 | .max_w = SZ_32K, | ||
672 | .max_h = SZ_32K, | ||
673 | .align = 3, | ||
674 | }, | ||
675 | .rgb888 = { | ||
676 | .min_w = 8, | ||
677 | .min_h = 8, | ||
678 | .max_w = SZ_8K, | ||
679 | .max_h = SZ_8K, | ||
680 | .align = 1, | ||
681 | }, | ||
682 | }; | ||
683 | |||
684 | static const struct of_device_id exynos_rotator_match[] = { | ||
685 | { | ||
686 | .compatible = "samsung,exynos4210-rotator", | ||
687 | .data = &rot_limit_tbl_4210, | ||
688 | }, | ||
689 | { | ||
690 | .compatible = "samsung,exynos4212-rotator", | ||
691 | .data = &rot_limit_tbl_4x12, | ||
692 | }, | ||
693 | { | ||
694 | .compatible = "samsung,exynos5250-rotator", | ||
695 | .data = &rot_limit_tbl_5250, | ||
696 | }, | ||
697 | {}, | ||
698 | }; | ||
699 | |||
634 | static int rotator_probe(struct platform_device *pdev) | 700 | static int rotator_probe(struct platform_device *pdev) |
635 | { | 701 | { |
636 | struct device *dev = &pdev->dev; | 702 | struct device *dev = &pdev->dev; |
637 | struct rot_context *rot; | 703 | struct rot_context *rot; |
638 | struct exynos_drm_ippdrv *ippdrv; | 704 | struct exynos_drm_ippdrv *ippdrv; |
705 | const struct of_device_id *match; | ||
639 | int ret; | 706 | int ret; |
640 | 707 | ||
708 | if (!dev->of_node) { | ||
709 | dev_err(dev, "cannot find of_node.\n"); | ||
710 | return -ENODEV; | ||
711 | } | ||
712 | |||
641 | rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL); | 713 | rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL); |
642 | if (!rot) { | 714 | if (!rot) |
643 | dev_err(dev, "failed to allocate rot\n"); | ||
644 | return -ENOMEM; | 715 | return -ENOMEM; |
645 | } | ||
646 | 716 | ||
647 | rot->limit_tbl = (struct rot_limit_table *) | 717 | match = of_match_node(exynos_rotator_match, dev->of_node); |
648 | platform_get_device_id(pdev)->driver_data; | 718 | if (!match) { |
719 | dev_err(dev, "failed to match node\n"); | ||
720 | return -ENODEV; | ||
721 | } | ||
722 | rot->limit_tbl = (struct rot_limit_table *)match->data; | ||
649 | 723 | ||
650 | rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 724 | rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
651 | rot->regs = devm_ioremap_resource(dev, rot->regs_res); | 725 | rot->regs = devm_ioremap_resource(dev, rot->regs_res); |
@@ -717,31 +791,6 @@ static int rotator_remove(struct platform_device *pdev) | |||
717 | return 0; | 791 | return 0; |
718 | } | 792 | } |
719 | 793 | ||
720 | static struct rot_limit_table rot_limit_tbl = { | ||
721 | .ycbcr420_2p = { | ||
722 | .min_w = 32, | ||
723 | .min_h = 32, | ||
724 | .max_w = SZ_32K, | ||
725 | .max_h = SZ_32K, | ||
726 | .align = 3, | ||
727 | }, | ||
728 | .rgb888 = { | ||
729 | .min_w = 8, | ||
730 | .min_h = 8, | ||
731 | .max_w = SZ_8K, | ||
732 | .max_h = SZ_8K, | ||
733 | .align = 2, | ||
734 | }, | ||
735 | }; | ||
736 | |||
737 | static struct platform_device_id rotator_driver_ids[] = { | ||
738 | { | ||
739 | .name = "exynos-rot", | ||
740 | .driver_data = (unsigned long)&rot_limit_tbl, | ||
741 | }, | ||
742 | {}, | ||
743 | }; | ||
744 | |||
745 | static int rotator_clk_crtl(struct rot_context *rot, bool enable) | 794 | static int rotator_clk_crtl(struct rot_context *rot, bool enable) |
746 | { | 795 | { |
747 | if (enable) { | 796 | if (enable) { |
@@ -803,10 +852,10 @@ static const struct dev_pm_ops rotator_pm_ops = { | |||
803 | struct platform_driver rotator_driver = { | 852 | struct platform_driver rotator_driver = { |
804 | .probe = rotator_probe, | 853 | .probe = rotator_probe, |
805 | .remove = rotator_remove, | 854 | .remove = rotator_remove, |
806 | .id_table = rotator_driver_ids, | ||
807 | .driver = { | 855 | .driver = { |
808 | .name = "exynos-rot", | 856 | .name = "exynos-rot", |
809 | .owner = THIS_MODULE, | 857 | .owner = THIS_MODULE, |
810 | .pm = &rotator_pm_ops, | 858 | .pm = &rotator_pm_ops, |
859 | .of_match_table = exynos_rotator_match, | ||
811 | }, | 860 | }, |
812 | }; | 861 | }; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index c57c56519add..4400330e4449 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "exynos_drm_drv.h" | 23 | #include "exynos_drm_drv.h" |
24 | #include "exynos_drm_crtc.h" | 24 | #include "exynos_drm_crtc.h" |
25 | #include "exynos_drm_encoder.h" | 25 | #include "exynos_drm_encoder.h" |
26 | #include "exynos_drm_vidi.h" | ||
26 | 27 | ||
27 | /* vidi has totally three virtual windows. */ | 28 | /* vidi has totally three virtual windows. */ |
28 | #define WINDOWS_NR 3 | 29 | #define WINDOWS_NR 3 |
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 2f5c6942c968..a0e10aeb0e67 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/clk.h> | 32 | #include <linux/clk.h> |
33 | #include <linux/regulator/consumer.h> | 33 | #include <linux/regulator/consumer.h> |
34 | #include <linux/io.h> | 34 | #include <linux/io.h> |
35 | #include <linux/of.h> | ||
35 | #include <linux/of_gpio.h> | 36 | #include <linux/of_gpio.h> |
36 | 37 | ||
37 | #include <drm/exynos_drm.h> | 38 | #include <drm/exynos_drm.h> |
@@ -1824,10 +1825,8 @@ static int hdmi_resources_init(struct hdmi_context *hdata) | |||
1824 | 1825 | ||
1825 | res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) * | 1826 | res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) * |
1826 | sizeof(res->regul_bulk[0]), GFP_KERNEL); | 1827 | sizeof(res->regul_bulk[0]), GFP_KERNEL); |
1827 | if (!res->regul_bulk) { | 1828 | if (!res->regul_bulk) |
1828 | DRM_ERROR("failed to get memory for regulators\n"); | ||
1829 | goto fail; | 1829 | goto fail; |
1830 | } | ||
1831 | for (i = 0; i < ARRAY_SIZE(supply); ++i) { | 1830 | for (i = 0; i < ARRAY_SIZE(supply); ++i) { |
1832 | res->regul_bulk[i].supply = supply[i]; | 1831 | res->regul_bulk[i].supply = supply[i]; |
1833 | res->regul_bulk[i].consumer = NULL; | 1832 | res->regul_bulk[i].consumer = NULL; |
@@ -1859,7 +1858,6 @@ void hdmi_attach_hdmiphy_client(struct i2c_client *hdmiphy) | |||
1859 | hdmi_hdmiphy = hdmiphy; | 1858 | hdmi_hdmiphy = hdmiphy; |
1860 | } | 1859 | } |
1861 | 1860 | ||
1862 | #ifdef CONFIG_OF | ||
1863 | static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata | 1861 | static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata |
1864 | (struct device *dev) | 1862 | (struct device *dev) |
1865 | { | 1863 | { |
@@ -1868,10 +1866,8 @@ static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata | |||
1868 | u32 value; | 1866 | u32 value; |
1869 | 1867 | ||
1870 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); | 1868 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); |
1871 | if (!pd) { | 1869 | if (!pd) |
1872 | DRM_ERROR("memory allocation for pdata failed\n"); | ||
1873 | goto err_data; | 1870 | goto err_data; |
1874 | } | ||
1875 | 1871 | ||
1876 | if (!of_find_property(np, "hpd-gpio", &value)) { | 1872 | if (!of_find_property(np, "hpd-gpio", &value)) { |
1877 | DRM_ERROR("no hpd gpio property found\n"); | 1873 | DRM_ERROR("no hpd gpio property found\n"); |
@@ -1885,33 +1881,7 @@ static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata | |||
1885 | err_data: | 1881 | err_data: |
1886 | return NULL; | 1882 | return NULL; |
1887 | } | 1883 | } |
1888 | #else | ||
1889 | static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata | ||
1890 | (struct device *dev) | ||
1891 | { | ||
1892 | return NULL; | ||
1893 | } | ||
1894 | #endif | ||
1895 | |||
1896 | static struct platform_device_id hdmi_driver_types[] = { | ||
1897 | { | ||
1898 | .name = "s5pv210-hdmi", | ||
1899 | .driver_data = HDMI_TYPE13, | ||
1900 | }, { | ||
1901 | .name = "exynos4-hdmi", | ||
1902 | .driver_data = HDMI_TYPE13, | ||
1903 | }, { | ||
1904 | .name = "exynos4-hdmi14", | ||
1905 | .driver_data = HDMI_TYPE14, | ||
1906 | }, { | ||
1907 | .name = "exynos5-hdmi", | ||
1908 | .driver_data = HDMI_TYPE14, | ||
1909 | }, { | ||
1910 | /* end node */ | ||
1911 | } | ||
1912 | }; | ||
1913 | 1884 | ||
1914 | #ifdef CONFIG_OF | ||
1915 | static struct of_device_id hdmi_match_types[] = { | 1885 | static struct of_device_id hdmi_match_types[] = { |
1916 | { | 1886 | { |
1917 | .compatible = "samsung,exynos5-hdmi", | 1887 | .compatible = "samsung,exynos5-hdmi", |
@@ -1923,7 +1893,6 @@ static struct of_device_id hdmi_match_types[] = { | |||
1923 | /* end node */ | 1893 | /* end node */ |
1924 | } | 1894 | } |
1925 | }; | 1895 | }; |
1926 | #endif | ||
1927 | 1896 | ||
1928 | static int hdmi_probe(struct platform_device *pdev) | 1897 | static int hdmi_probe(struct platform_device *pdev) |
1929 | { | 1898 | { |
@@ -1932,36 +1901,23 @@ static int hdmi_probe(struct platform_device *pdev) | |||
1932 | struct hdmi_context *hdata; | 1901 | struct hdmi_context *hdata; |
1933 | struct s5p_hdmi_platform_data *pdata; | 1902 | struct s5p_hdmi_platform_data *pdata; |
1934 | struct resource *res; | 1903 | struct resource *res; |
1904 | const struct of_device_id *match; | ||
1935 | int ret; | 1905 | int ret; |
1936 | 1906 | ||
1937 | if (dev->of_node) { | 1907 | if (!dev->of_node) |
1938 | pdata = drm_hdmi_dt_parse_pdata(dev); | 1908 | return -ENODEV; |
1939 | if (IS_ERR(pdata)) { | ||
1940 | DRM_ERROR("failed to parse dt\n"); | ||
1941 | return PTR_ERR(pdata); | ||
1942 | } | ||
1943 | } else { | ||
1944 | pdata = dev->platform_data; | ||
1945 | } | ||
1946 | 1909 | ||
1947 | if (!pdata) { | 1910 | pdata = drm_hdmi_dt_parse_pdata(dev); |
1948 | DRM_ERROR("no platform data specified\n"); | 1911 | if (!pdata) |
1949 | return -EINVAL; | 1912 | return -EINVAL; |
1950 | } | ||
1951 | 1913 | ||
1952 | drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), | 1914 | drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), GFP_KERNEL); |
1953 | GFP_KERNEL); | 1915 | if (!drm_hdmi_ctx) |
1954 | if (!drm_hdmi_ctx) { | ||
1955 | DRM_ERROR("failed to allocate common hdmi context.\n"); | ||
1956 | return -ENOMEM; | 1916 | return -ENOMEM; |
1957 | } | ||
1958 | 1917 | ||
1959 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), | 1918 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); |
1960 | GFP_KERNEL); | 1919 | if (!hdata) |
1961 | if (!hdata) { | ||
1962 | DRM_ERROR("out of memory\n"); | ||
1963 | return -ENOMEM; | 1920 | return -ENOMEM; |
1964 | } | ||
1965 | 1921 | ||
1966 | mutex_init(&hdata->hdmi_mutex); | 1922 | mutex_init(&hdata->hdmi_mutex); |
1967 | 1923 | ||
@@ -1970,23 +1926,15 @@ static int hdmi_probe(struct platform_device *pdev) | |||
1970 | 1926 | ||
1971 | platform_set_drvdata(pdev, drm_hdmi_ctx); | 1927 | platform_set_drvdata(pdev, drm_hdmi_ctx); |
1972 | 1928 | ||
1973 | if (dev->of_node) { | 1929 | match = of_match_node(hdmi_match_types, dev->of_node); |
1974 | const struct of_device_id *match; | 1930 | if (!match) |
1975 | match = of_match_node(of_match_ptr(hdmi_match_types), | 1931 | return -ENODEV; |
1976 | dev->of_node); | 1932 | hdata->type = (enum hdmi_type)match->data; |
1977 | if (match == NULL) | ||
1978 | return -ENODEV; | ||
1979 | hdata->type = (enum hdmi_type)match->data; | ||
1980 | } else { | ||
1981 | hdata->type = (enum hdmi_type)platform_get_device_id | ||
1982 | (pdev)->driver_data; | ||
1983 | } | ||
1984 | 1933 | ||
1985 | hdata->hpd_gpio = pdata->hpd_gpio; | 1934 | hdata->hpd_gpio = pdata->hpd_gpio; |
1986 | hdata->dev = dev; | 1935 | hdata->dev = dev; |
1987 | 1936 | ||
1988 | ret = hdmi_resources_init(hdata); | 1937 | ret = hdmi_resources_init(hdata); |
1989 | |||
1990 | if (ret) { | 1938 | if (ret) { |
1991 | DRM_ERROR("hdmi_resources_init failed\n"); | 1939 | DRM_ERROR("hdmi_resources_init failed\n"); |
1992 | return -EINVAL; | 1940 | return -EINVAL; |
@@ -2141,11 +2089,10 @@ static const struct dev_pm_ops hdmi_pm_ops = { | |||
2141 | struct platform_driver hdmi_driver = { | 2089 | struct platform_driver hdmi_driver = { |
2142 | .probe = hdmi_probe, | 2090 | .probe = hdmi_probe, |
2143 | .remove = hdmi_remove, | 2091 | .remove = hdmi_remove, |
2144 | .id_table = hdmi_driver_types, | ||
2145 | .driver = { | 2092 | .driver = { |
2146 | .name = "exynos-hdmi", | 2093 | .name = "exynos-hdmi", |
2147 | .owner = THIS_MODULE, | 2094 | .owner = THIS_MODULE, |
2148 | .pm = &hdmi_pm_ops, | 2095 | .pm = &hdmi_pm_ops, |
2149 | .of_match_table = of_match_ptr(hdmi_match_types), | 2096 | .of_match_table = hdmi_match_types, |
2150 | }, | 2097 | }, |
2151 | }; | 2098 | }; |
diff --git a/drivers/gpu/drm/exynos/exynos_hdmiphy.c b/drivers/gpu/drm/exynos/exynos_hdmiphy.c index 6e320ae9afed..59abb1494ceb 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmiphy.c +++ b/drivers/gpu/drm/exynos/exynos_hdmiphy.c | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/of.h> | ||
18 | 19 | ||
19 | #include "exynos_drm_drv.h" | 20 | #include "exynos_drm_drv.h" |
20 | #include "exynos_hdmi.h" | 21 | #include "exynos_hdmi.h" |
@@ -39,13 +40,6 @@ static int hdmiphy_remove(struct i2c_client *client) | |||
39 | return 0; | 40 | return 0; |
40 | } | 41 | } |
41 | 42 | ||
42 | static const struct i2c_device_id hdmiphy_id[] = { | ||
43 | { "s5p_hdmiphy", 0 }, | ||
44 | { "exynos5-hdmiphy", 0 }, | ||
45 | { }, | ||
46 | }; | ||
47 | |||
48 | #ifdef CONFIG_OF | ||
49 | static struct of_device_id hdmiphy_match_types[] = { | 43 | static struct of_device_id hdmiphy_match_types[] = { |
50 | { | 44 | { |
51 | .compatible = "samsung,exynos5-hdmiphy", | 45 | .compatible = "samsung,exynos5-hdmiphy", |
@@ -57,15 +51,13 @@ static struct of_device_id hdmiphy_match_types[] = { | |||
57 | /* end node */ | 51 | /* end node */ |
58 | } | 52 | } |
59 | }; | 53 | }; |
60 | #endif | ||
61 | 54 | ||
62 | struct i2c_driver hdmiphy_driver = { | 55 | struct i2c_driver hdmiphy_driver = { |
63 | .driver = { | 56 | .driver = { |
64 | .name = "exynos-hdmiphy", | 57 | .name = "exynos-hdmiphy", |
65 | .owner = THIS_MODULE, | 58 | .owner = THIS_MODULE, |
66 | .of_match_table = of_match_ptr(hdmiphy_match_types), | 59 | .of_match_table = hdmiphy_match_types, |
67 | }, | 60 | }, |
68 | .id_table = hdmiphy_id, | ||
69 | .probe = hdmiphy_probe, | 61 | .probe = hdmiphy_probe, |
70 | .remove = hdmiphy_remove, | 62 | .remove = hdmiphy_remove, |
71 | .command = NULL, | 63 | .command = NULL, |
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index c9a137caea41..63bc5f92fbb3 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/pm_runtime.h> | 30 | #include <linux/pm_runtime.h> |
31 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
32 | #include <linux/regulator/consumer.h> | 32 | #include <linux/regulator/consumer.h> |
33 | #include <linux/of.h> | ||
33 | 34 | ||
34 | #include <drm/exynos_drm.h> | 35 | #include <drm/exynos_drm.h> |
35 | 36 | ||
@@ -1185,16 +1186,12 @@ static int mixer_probe(struct platform_device *pdev) | |||
1185 | 1186 | ||
1186 | drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), | 1187 | drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), |
1187 | GFP_KERNEL); | 1188 | GFP_KERNEL); |
1188 | if (!drm_hdmi_ctx) { | 1189 | if (!drm_hdmi_ctx) |
1189 | DRM_ERROR("failed to allocate common hdmi context.\n"); | ||
1190 | return -ENOMEM; | 1190 | return -ENOMEM; |
1191 | } | ||
1192 | 1191 | ||
1193 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); | 1192 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); |
1194 | if (!ctx) { | 1193 | if (!ctx) |
1195 | DRM_ERROR("failed to alloc mixer context.\n"); | ||
1196 | return -ENOMEM; | 1194 | return -ENOMEM; |
1197 | } | ||
1198 | 1195 | ||
1199 | mutex_init(&ctx->mixer_mutex); | 1196 | mutex_init(&ctx->mixer_mutex); |
1200 | 1197 | ||
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index c2bd711e86e9..b1f8fc69023f 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c | |||
@@ -596,6 +596,10 @@ tda998x_configure_audio(struct drm_encoder *encoder, | |||
596 | cts_n = CTS_N_M(3) | CTS_N_K(3); | 596 | cts_n = CTS_N_M(3) | CTS_N_K(3); |
597 | ca_i2s = CA_I2S_CA_I2S(0); | 597 | ca_i2s = CA_I2S_CA_I2S(0); |
598 | break; | 598 | break; |
599 | |||
600 | default: | ||
601 | BUG(); | ||
602 | return; | ||
599 | } | 603 | } |
600 | 604 | ||
601 | reg_write(encoder, REG_AIP_CLKSEL, clksel_aip); | 605 | reg_write(encoder, REG_AIP_CLKSEL, clksel_aip); |
diff --git a/drivers/gpu/drm/nouveau/core/core/ramht.c b/drivers/gpu/drm/nouveau/core/core/ramht.c index 86a64045dd60..f3b9bddc3875 100644 --- a/drivers/gpu/drm/nouveau/core/core/ramht.c +++ b/drivers/gpu/drm/nouveau/core/core/ramht.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | #include <core/object.h> | 23 | #include <core/object.h> |
24 | #include <core/ramht.h> | 24 | #include <core/ramht.h> |
25 | #include <core/math.h> | ||
26 | 25 | ||
27 | #include <subdev/bar.h> | 26 | #include <subdev/bar.h> |
28 | 27 | ||
@@ -104,6 +103,6 @@ nouveau_ramht_new(struct nouveau_object *parent, struct nouveau_object *pargpu, | |||
104 | if (ret) | 103 | if (ret) |
105 | return ret; | 104 | return ret; |
106 | 105 | ||
107 | ramht->bits = log2i(nv_gpuobj(ramht)->size >> 3); | 106 | ramht->bits = order_base_2(nv_gpuobj(ramht)->size >> 3); |
108 | return 0; | 107 | return 0; |
109 | } | 108 | } |
diff --git a/drivers/gpu/drm/nouveau/core/engine/bsp/nv98.c b/drivers/gpu/drm/nouveau/core/engine/bsp/nv98.c index 8bf92b0e6d82..6b089e022fd2 100644 --- a/drivers/gpu/drm/nouveau/core/engine/bsp/nv98.c +++ b/drivers/gpu/drm/nouveau/core/engine/bsp/nv98.c | |||
@@ -19,16 +19,14 @@ | |||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 21 | * |
22 | * Authors: Ben Skeggs | 22 | * Authors: Ben Skeggs, Maarten Lankhorst, Ilia Mirkin |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <core/engctx.h> | 25 | #include <engine/falcon.h> |
26 | #include <core/class.h> | ||
27 | |||
28 | #include <engine/bsp.h> | 26 | #include <engine/bsp.h> |
29 | 27 | ||
30 | struct nv98_bsp_priv { | 28 | struct nv98_bsp_priv { |
31 | struct nouveau_engine base; | 29 | struct nouveau_falcon base; |
32 | }; | 30 | }; |
33 | 31 | ||
34 | /******************************************************************************* | 32 | /******************************************************************************* |
@@ -37,31 +35,49 @@ struct nv98_bsp_priv { | |||
37 | 35 | ||
38 | static struct nouveau_oclass | 36 | static struct nouveau_oclass |
39 | nv98_bsp_sclass[] = { | 37 | nv98_bsp_sclass[] = { |
38 | { 0x88b1, &nouveau_object_ofuncs }, | ||
39 | { 0x85b1, &nouveau_object_ofuncs }, | ||
40 | { 0x86b1, &nouveau_object_ofuncs }, | ||
40 | {}, | 41 | {}, |
41 | }; | 42 | }; |
42 | 43 | ||
43 | /******************************************************************************* | 44 | /******************************************************************************* |
44 | * BSP context | 45 | * PBSP context |
45 | ******************************************************************************/ | 46 | ******************************************************************************/ |
46 | 47 | ||
47 | static struct nouveau_oclass | 48 | static struct nouveau_oclass |
48 | nv98_bsp_cclass = { | 49 | nv98_bsp_cclass = { |
49 | .handle = NV_ENGCTX(BSP, 0x98), | 50 | .handle = NV_ENGCTX(BSP, 0x98), |
50 | .ofuncs = &(struct nouveau_ofuncs) { | 51 | .ofuncs = &(struct nouveau_ofuncs) { |
51 | .ctor = _nouveau_engctx_ctor, | 52 | .ctor = _nouveau_falcon_context_ctor, |
52 | .dtor = _nouveau_engctx_dtor, | 53 | .dtor = _nouveau_falcon_context_dtor, |
53 | .init = _nouveau_engctx_init, | 54 | .init = _nouveau_falcon_context_init, |
54 | .fini = _nouveau_engctx_fini, | 55 | .fini = _nouveau_falcon_context_fini, |
55 | .rd32 = _nouveau_engctx_rd32, | 56 | .rd32 = _nouveau_falcon_context_rd32, |
56 | .wr32 = _nouveau_engctx_wr32, | 57 | .wr32 = _nouveau_falcon_context_wr32, |
57 | }, | 58 | }, |
58 | }; | 59 | }; |
59 | 60 | ||
60 | /******************************************************************************* | 61 | /******************************************************************************* |
61 | * BSP engine/subdev functions | 62 | * PBSP engine/subdev functions |
62 | ******************************************************************************/ | 63 | ******************************************************************************/ |
63 | 64 | ||
64 | static int | 65 | static int |
66 | nv98_bsp_init(struct nouveau_object *object) | ||
67 | { | ||
68 | struct nv98_bsp_priv *priv = (void *)object; | ||
69 | int ret; | ||
70 | |||
71 | ret = nouveau_falcon_init(&priv->base); | ||
72 | if (ret) | ||
73 | return ret; | ||
74 | |||
75 | nv_wr32(priv, 0x084010, 0x0000ffd2); | ||
76 | nv_wr32(priv, 0x08401c, 0x0000fff2); | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int | ||
65 | nv98_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 81 | nv98_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
66 | struct nouveau_oclass *oclass, void *data, u32 size, | 82 | struct nouveau_oclass *oclass, void *data, u32 size, |
67 | struct nouveau_object **pobject) | 83 | struct nouveau_object **pobject) |
@@ -69,7 +85,7 @@ nv98_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
69 | struct nv98_bsp_priv *priv; | 85 | struct nv98_bsp_priv *priv; |
70 | int ret; | 86 | int ret; |
71 | 87 | ||
72 | ret = nouveau_engine_create(parent, engine, oclass, true, | 88 | ret = nouveau_falcon_create(parent, engine, oclass, 0x084000, true, |
73 | "PBSP", "bsp", &priv); | 89 | "PBSP", "bsp", &priv); |
74 | *pobject = nv_object(priv); | 90 | *pobject = nv_object(priv); |
75 | if (ret) | 91 | if (ret) |
@@ -86,8 +102,10 @@ nv98_bsp_oclass = { | |||
86 | .handle = NV_ENGINE(BSP, 0x98), | 102 | .handle = NV_ENGINE(BSP, 0x98), |
87 | .ofuncs = &(struct nouveau_ofuncs) { | 103 | .ofuncs = &(struct nouveau_ofuncs) { |
88 | .ctor = nv98_bsp_ctor, | 104 | .ctor = nv98_bsp_ctor, |
89 | .dtor = _nouveau_engine_dtor, | 105 | .dtor = _nouveau_falcon_dtor, |
90 | .init = _nouveau_engine_init, | 106 | .init = nv98_bsp_init, |
91 | .fini = _nouveau_engine_fini, | 107 | .fini = _nouveau_falcon_fini, |
108 | .rd32 = _nouveau_falcon_rd32, | ||
109 | .wr32 = _nouveau_falcon_wr32, | ||
92 | }, | 110 | }, |
93 | }; | 111 | }; |
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c index f02fd9f443ff..a66b27c0fcab 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c | |||
@@ -49,18 +49,23 @@ int | |||
49 | nv50_dac_sense(struct nv50_disp_priv *priv, int or, u32 loadval) | 49 | nv50_dac_sense(struct nv50_disp_priv *priv, int or, u32 loadval) |
50 | { | 50 | { |
51 | const u32 doff = (or * 0x800); | 51 | const u32 doff = (or * 0x800); |
52 | int load = -EINVAL; | 52 | |
53 | nv_mask(priv, 0x61a004 + doff, 0x807f0000, 0x80150000); | 53 | nv_mask(priv, 0x61a004 + doff, 0x807f0000, 0x80150000); |
54 | nv_wait(priv, 0x61a004 + doff, 0x80000000, 0x00000000); | 54 | nv_wait(priv, 0x61a004 + doff, 0x80000000, 0x00000000); |
55 | |||
55 | nv_wr32(priv, 0x61a00c + doff, 0x00100000 | loadval); | 56 | nv_wr32(priv, 0x61a00c + doff, 0x00100000 | loadval); |
56 | mdelay(9); | 57 | mdelay(9); |
57 | udelay(500); | 58 | udelay(500); |
58 | nv_wr32(priv, 0x61a00c + doff, 0x80000000); | 59 | loadval = nv_mask(priv, 0x61a00c + doff, 0xffffffff, 0x00000000); |
59 | load = (nv_rd32(priv, 0x61a00c + doff) & 0x38000000) >> 27; | 60 | |
60 | nv_wr32(priv, 0x61a00c + doff, 0x00000000); | ||
61 | nv_mask(priv, 0x61a004 + doff, 0x807f0000, 0x80550000); | 61 | nv_mask(priv, 0x61a004 + doff, 0x807f0000, 0x80550000); |
62 | nv_wait(priv, 0x61a004 + doff, 0x80000000, 0x00000000); | 62 | nv_wait(priv, 0x61a004 + doff, 0x80000000, 0x00000000); |
63 | return load; | 63 | |
64 | nv_debug(priv, "DAC%d sense: 0x%08x\n", or, loadval); | ||
65 | if (!(loadval & 0x80000000)) | ||
66 | return -ETIMEDOUT; | ||
67 | |||
68 | return (loadval & 0x38000000) >> 27; | ||
64 | } | 69 | } |
65 | 70 | ||
66 | int | 71 | int |
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c index 7ffe2f309f12..c168ae3eaa97 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c | |||
@@ -628,7 +628,7 @@ nv50_disp_base_init(struct nouveau_object *object) | |||
628 | } | 628 | } |
629 | 629 | ||
630 | /* ... PIOR caps */ | 630 | /* ... PIOR caps */ |
631 | for (i = 0; i < 3; i++) { | 631 | for (i = 0; i < priv->pior.nr; i++) { |
632 | tmp = nv_rd32(priv, 0x61e000 + (i * 0x800)); | 632 | tmp = nv_rd32(priv, 0x61e000 + (i * 0x800)); |
633 | nv_wr32(priv, 0x6101f0 + (i * 0x04), tmp); | 633 | nv_wr32(priv, 0x6101f0 + (i * 0x04), tmp); |
634 | } | 634 | } |
@@ -834,10 +834,11 @@ exec_script(struct nv50_disp_priv *priv, int head, int id) | |||
834 | u8 ver, hdr, cnt, len; | 834 | u8 ver, hdr, cnt, len; |
835 | u16 data; | 835 | u16 data; |
836 | u32 ctrl = 0x00000000; | 836 | u32 ctrl = 0x00000000; |
837 | u32 reg; | ||
837 | int i; | 838 | int i; |
838 | 839 | ||
839 | /* DAC */ | 840 | /* DAC */ |
840 | for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) | 841 | for (i = 0; !(ctrl & (1 << head)) && i < priv->dac.nr; i++) |
841 | ctrl = nv_rd32(priv, 0x610b5c + (i * 8)); | 842 | ctrl = nv_rd32(priv, 0x610b5c + (i * 8)); |
842 | 843 | ||
843 | /* SOR */ | 844 | /* SOR */ |
@@ -845,19 +846,18 @@ exec_script(struct nv50_disp_priv *priv, int head, int id) | |||
845 | if (nv_device(priv)->chipset < 0x90 || | 846 | if (nv_device(priv)->chipset < 0x90 || |
846 | nv_device(priv)->chipset == 0x92 || | 847 | nv_device(priv)->chipset == 0x92 || |
847 | nv_device(priv)->chipset == 0xa0) { | 848 | nv_device(priv)->chipset == 0xa0) { |
848 | for (i = 0; !(ctrl & (1 << head)) && i < 2; i++) | 849 | reg = 0x610b74; |
849 | ctrl = nv_rd32(priv, 0x610b74 + (i * 8)); | ||
850 | i += 4; | ||
851 | } else { | 850 | } else { |
852 | for (i = 0; !(ctrl & (1 << head)) && i < 4; i++) | 851 | reg = 0x610798; |
853 | ctrl = nv_rd32(priv, 0x610798 + (i * 8)); | ||
854 | i += 4; | ||
855 | } | 852 | } |
853 | for (i = 0; !(ctrl & (1 << head)) && i < priv->sor.nr; i++) | ||
854 | ctrl = nv_rd32(priv, reg + (i * 8)); | ||
855 | i += 4; | ||
856 | } | 856 | } |
857 | 857 | ||
858 | /* PIOR */ | 858 | /* PIOR */ |
859 | if (!(ctrl & (1 << head))) { | 859 | if (!(ctrl & (1 << head))) { |
860 | for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) | 860 | for (i = 0; !(ctrl & (1 << head)) && i < priv->pior.nr; i++) |
861 | ctrl = nv_rd32(priv, 0x610b84 + (i * 8)); | 861 | ctrl = nv_rd32(priv, 0x610b84 + (i * 8)); |
862 | i += 8; | 862 | i += 8; |
863 | } | 863 | } |
@@ -893,10 +893,11 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk, | |||
893 | u8 ver, hdr, cnt, len; | 893 | u8 ver, hdr, cnt, len; |
894 | u32 ctrl = 0x00000000; | 894 | u32 ctrl = 0x00000000; |
895 | u32 data, conf = ~0; | 895 | u32 data, conf = ~0; |
896 | u32 reg; | ||
896 | int i; | 897 | int i; |
897 | 898 | ||
898 | /* DAC */ | 899 | /* DAC */ |
899 | for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) | 900 | for (i = 0; !(ctrl & (1 << head)) && i < priv->dac.nr; i++) |
900 | ctrl = nv_rd32(priv, 0x610b58 + (i * 8)); | 901 | ctrl = nv_rd32(priv, 0x610b58 + (i * 8)); |
901 | 902 | ||
902 | /* SOR */ | 903 | /* SOR */ |
@@ -904,19 +905,18 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk, | |||
904 | if (nv_device(priv)->chipset < 0x90 || | 905 | if (nv_device(priv)->chipset < 0x90 || |
905 | nv_device(priv)->chipset == 0x92 || | 906 | nv_device(priv)->chipset == 0x92 || |
906 | nv_device(priv)->chipset == 0xa0) { | 907 | nv_device(priv)->chipset == 0xa0) { |
907 | for (i = 0; !(ctrl & (1 << head)) && i < 2; i++) | 908 | reg = 0x610b70; |
908 | ctrl = nv_rd32(priv, 0x610b70 + (i * 8)); | ||
909 | i += 4; | ||
910 | } else { | 909 | } else { |
911 | for (i = 0; !(ctrl & (1 << head)) && i < 4; i++) | 910 | reg = 0x610794; |
912 | ctrl = nv_rd32(priv, 0x610794 + (i * 8)); | ||
913 | i += 4; | ||
914 | } | 911 | } |
912 | for (i = 0; !(ctrl & (1 << head)) && i < priv->sor.nr; i++) | ||
913 | ctrl = nv_rd32(priv, reg + (i * 8)); | ||
914 | i += 4; | ||
915 | } | 915 | } |
916 | 916 | ||
917 | /* PIOR */ | 917 | /* PIOR */ |
918 | if (!(ctrl & (1 << head))) { | 918 | if (!(ctrl & (1 << head))) { |
919 | for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) | 919 | for (i = 0; !(ctrl & (1 << head)) && i < priv->pior.nr; i++) |
920 | ctrl = nv_rd32(priv, 0x610b80 + (i * 8)); | 920 | ctrl = nv_rd32(priv, 0x610b80 + (i * 8)); |
921 | i += 8; | 921 | i += 8; |
922 | } | 922 | } |
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c index e9b8217d0075..7e5dff51d3c5 100644 --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <core/engctx.h> | 26 | #include <core/engctx.h> |
27 | #include <core/ramht.h> | 27 | #include <core/ramht.h> |
28 | #include <core/class.h> | 28 | #include <core/class.h> |
29 | #include <core/math.h> | ||
30 | 29 | ||
31 | #include <subdev/timer.h> | 30 | #include <subdev/timer.h> |
32 | #include <subdev/bar.h> | 31 | #include <subdev/bar.h> |
@@ -278,7 +277,7 @@ nv50_fifo_chan_ctor_ind(struct nouveau_object *parent, | |||
278 | return ret; | 277 | return ret; |
279 | 278 | ||
280 | ioffset = args->ioffset; | 279 | ioffset = args->ioffset; |
281 | ilength = log2i(args->ilength / 8); | 280 | ilength = order_base_2(args->ilength / 8); |
282 | 281 | ||
283 | nv_wo32(base->ramfc, 0x3c, 0x403f6078); | 282 | nv_wo32(base->ramfc, 0x3c, 0x403f6078); |
284 | nv_wo32(base->ramfc, 0x44, 0x01003fff); | 283 | nv_wo32(base->ramfc, 0x44, 0x01003fff); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c index 7f53196cff52..91a87cd7195a 100644 --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <core/ramht.h> | 28 | #include <core/ramht.h> |
29 | #include <core/event.h> | 29 | #include <core/event.h> |
30 | #include <core/class.h> | 30 | #include <core/class.h> |
31 | #include <core/math.h> | ||
32 | 31 | ||
33 | #include <subdev/timer.h> | 32 | #include <subdev/timer.h> |
34 | #include <subdev/bar.h> | 33 | #include <subdev/bar.h> |
@@ -57,6 +56,7 @@ nv84_fifo_context_attach(struct nouveau_object *parent, | |||
57 | case NVDEV_ENGINE_SW : return 0; | 56 | case NVDEV_ENGINE_SW : return 0; |
58 | case NVDEV_ENGINE_GR : addr = 0x0020; break; | 57 | case NVDEV_ENGINE_GR : addr = 0x0020; break; |
59 | case NVDEV_ENGINE_VP : addr = 0x0040; break; | 58 | case NVDEV_ENGINE_VP : addr = 0x0040; break; |
59 | case NVDEV_ENGINE_PPP : | ||
60 | case NVDEV_ENGINE_MPEG : addr = 0x0060; break; | 60 | case NVDEV_ENGINE_MPEG : addr = 0x0060; break; |
61 | case NVDEV_ENGINE_BSP : addr = 0x0080; break; | 61 | case NVDEV_ENGINE_BSP : addr = 0x0080; break; |
62 | case NVDEV_ENGINE_CRYPT: addr = 0x00a0; break; | 62 | case NVDEV_ENGINE_CRYPT: addr = 0x00a0; break; |
@@ -92,6 +92,7 @@ nv84_fifo_context_detach(struct nouveau_object *parent, bool suspend, | |||
92 | case NVDEV_ENGINE_SW : return 0; | 92 | case NVDEV_ENGINE_SW : return 0; |
93 | case NVDEV_ENGINE_GR : engn = 0; addr = 0x0020; break; | 93 | case NVDEV_ENGINE_GR : engn = 0; addr = 0x0020; break; |
94 | case NVDEV_ENGINE_VP : engn = 3; addr = 0x0040; break; | 94 | case NVDEV_ENGINE_VP : engn = 3; addr = 0x0040; break; |
95 | case NVDEV_ENGINE_PPP : | ||
95 | case NVDEV_ENGINE_MPEG : engn = 1; addr = 0x0060; break; | 96 | case NVDEV_ENGINE_MPEG : engn = 1; addr = 0x0060; break; |
96 | case NVDEV_ENGINE_BSP : engn = 5; addr = 0x0080; break; | 97 | case NVDEV_ENGINE_BSP : engn = 5; addr = 0x0080; break; |
97 | case NVDEV_ENGINE_CRYPT: engn = 4; addr = 0x00a0; break; | 98 | case NVDEV_ENGINE_CRYPT: engn = 4; addr = 0x00a0; break; |
@@ -258,7 +259,7 @@ nv84_fifo_chan_ctor_ind(struct nouveau_object *parent, | |||
258 | nv_parent(chan)->object_detach = nv50_fifo_object_detach; | 259 | nv_parent(chan)->object_detach = nv50_fifo_object_detach; |
259 | 260 | ||
260 | ioffset = args->ioffset; | 261 | ioffset = args->ioffset; |
261 | ilength = log2i(args->ilength / 8); | 262 | ilength = order_base_2(args->ilength / 8); |
262 | 263 | ||
263 | nv_wo32(base->ramfc, 0x3c, 0x403f6078); | 264 | nv_wo32(base->ramfc, 0x3c, 0x403f6078); |
264 | nv_wo32(base->ramfc, 0x44, 0x01003fff); | 265 | nv_wo32(base->ramfc, 0x44, 0x01003fff); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c index 46dfa68c47bb..ce92f289e751 100644 --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <core/engctx.h> | 29 | #include <core/engctx.h> |
30 | #include <core/event.h> | 30 | #include <core/event.h> |
31 | #include <core/class.h> | 31 | #include <core/class.h> |
32 | #include <core/math.h> | ||
33 | #include <core/enum.h> | 32 | #include <core/enum.h> |
34 | 33 | ||
35 | #include <subdev/timer.h> | 34 | #include <subdev/timer.h> |
@@ -200,7 +199,7 @@ nvc0_fifo_chan_ctor(struct nouveau_object *parent, | |||
200 | 199 | ||
201 | usermem = chan->base.chid * 0x1000; | 200 | usermem = chan->base.chid * 0x1000; |
202 | ioffset = args->ioffset; | 201 | ioffset = args->ioffset; |
203 | ilength = log2i(args->ilength / 8); | 202 | ilength = order_base_2(args->ilength / 8); |
204 | 203 | ||
205 | for (i = 0; i < 0x1000; i += 4) | 204 | for (i = 0; i < 0x1000; i += 4) |
206 | nv_wo32(priv->user.mem, usermem + i, 0x00000000); | 205 | nv_wo32(priv->user.mem, usermem + i, 0x00000000); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c index 09644fa9602c..8e8121abe31b 100644 --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <core/engctx.h> | 29 | #include <core/engctx.h> |
30 | #include <core/event.h> | 30 | #include <core/event.h> |
31 | #include <core/class.h> | 31 | #include <core/class.h> |
32 | #include <core/math.h> | ||
33 | #include <core/enum.h> | 32 | #include <core/enum.h> |
34 | 33 | ||
35 | #include <subdev/timer.h> | 34 | #include <subdev/timer.h> |
@@ -240,7 +239,7 @@ nve0_fifo_chan_ctor(struct nouveau_object *parent, | |||
240 | 239 | ||
241 | usermem = chan->base.chid * 0x200; | 240 | usermem = chan->base.chid * 0x200; |
242 | ioffset = args->ioffset; | 241 | ioffset = args->ioffset; |
243 | ilength = log2i(args->ilength / 8); | 242 | ilength = order_base_2(args->ilength / 8); |
244 | 243 | ||
245 | for (i = 0; i < 0x200; i += 4) | 244 | for (i = 0; i < 0x200; i += 4) |
246 | nv_wo32(priv->user.mem, usermem + i, 0x00000000); | 245 | nv_wo32(priv->user.mem, usermem + i, 0x00000000); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h index 7da35a4e7970..ad8209377529 100644 --- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h +++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #ifndef __NV40_GRAPH_H__ | 1 | #ifndef __NV40_GRAPH_H__ |
2 | #define __NV40_GRAPH_H__ | 2 | #define __NV40_GRAPH_H__ |
3 | 3 | ||
4 | #include <core/device.h> | ||
5 | #include <core/gpuobj.h> | ||
6 | |||
4 | /* returns 1 if device is one of the nv4x using the 0x4497 object class, | 7 | /* returns 1 if device is one of the nv4x using the 0x4497 object class, |
5 | * helpful to determine a number of other hardware features | 8 | * helpful to determine a number of other hardware features |
6 | */ | 9 | */ |
diff --git a/drivers/gpu/drm/nouveau/core/engine/ppp/nv98.c b/drivers/gpu/drm/nouveau/core/engine/ppp/nv98.c index 5a5b2a773ed7..13bf31c40aa1 100644 --- a/drivers/gpu/drm/nouveau/core/engine/ppp/nv98.c +++ b/drivers/gpu/drm/nouveau/core/engine/ppp/nv98.c | |||
@@ -19,21 +19,14 @@ | |||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 21 | * |
22 | * Authors: Ben Skeggs | 22 | * Authors: Ben Skeggs, Maarten Lankhorst, Ilia Mirkin |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <core/engine.h> | 25 | #include <engine/falcon.h> |
26 | #include <core/engctx.h> | ||
27 | #include <core/class.h> | ||
28 | |||
29 | #include <engine/ppp.h> | 26 | #include <engine/ppp.h> |
30 | 27 | ||
31 | struct nv98_ppp_priv { | 28 | struct nv98_ppp_priv { |
32 | struct nouveau_engine base; | 29 | struct nouveau_falcon base; |
33 | }; | ||
34 | |||
35 | struct nv98_ppp_chan { | ||
36 | struct nouveau_engctx base; | ||
37 | }; | 30 | }; |
38 | 31 | ||
39 | /******************************************************************************* | 32 | /******************************************************************************* |
@@ -42,6 +35,8 @@ struct nv98_ppp_chan { | |||
42 | 35 | ||
43 | static struct nouveau_oclass | 36 | static struct nouveau_oclass |
44 | nv98_ppp_sclass[] = { | 37 | nv98_ppp_sclass[] = { |
38 | { 0x88b3, &nouveau_object_ofuncs }, | ||
39 | { 0x85b3, &nouveau_object_ofuncs }, | ||
45 | {}, | 40 | {}, |
46 | }; | 41 | }; |
47 | 42 | ||
@@ -53,12 +48,12 @@ static struct nouveau_oclass | |||
53 | nv98_ppp_cclass = { | 48 | nv98_ppp_cclass = { |
54 | .handle = NV_ENGCTX(PPP, 0x98), | 49 | .handle = NV_ENGCTX(PPP, 0x98), |
55 | .ofuncs = &(struct nouveau_ofuncs) { | 50 | .ofuncs = &(struct nouveau_ofuncs) { |
56 | .ctor = _nouveau_engctx_ctor, | 51 | .ctor = _nouveau_falcon_context_ctor, |
57 | .dtor = _nouveau_engctx_dtor, | 52 | .dtor = _nouveau_falcon_context_dtor, |
58 | .init = _nouveau_engctx_init, | 53 | .init = _nouveau_falcon_context_init, |
59 | .fini = _nouveau_engctx_fini, | 54 | .fini = _nouveau_falcon_context_fini, |
60 | .rd32 = _nouveau_engctx_rd32, | 55 | .rd32 = _nouveau_falcon_context_rd32, |
61 | .wr32 = _nouveau_engctx_wr32, | 56 | .wr32 = _nouveau_falcon_context_wr32, |
62 | }, | 57 | }, |
63 | }; | 58 | }; |
64 | 59 | ||
@@ -67,6 +62,21 @@ nv98_ppp_cclass = { | |||
67 | ******************************************************************************/ | 62 | ******************************************************************************/ |
68 | 63 | ||
69 | static int | 64 | static int |
65 | nv98_ppp_init(struct nouveau_object *object) | ||
66 | { | ||
67 | struct nv98_ppp_priv *priv = (void *)object; | ||
68 | int ret; | ||
69 | |||
70 | ret = nouveau_falcon_init(&priv->base); | ||
71 | if (ret) | ||
72 | return ret; | ||
73 | |||
74 | nv_wr32(priv, 0x086010, 0x0000ffd2); | ||
75 | nv_wr32(priv, 0x08601c, 0x0000fff2); | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int | ||
70 | nv98_ppp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 80 | nv98_ppp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
71 | struct nouveau_oclass *oclass, void *data, u32 size, | 81 | struct nouveau_oclass *oclass, void *data, u32 size, |
72 | struct nouveau_object **pobject) | 82 | struct nouveau_object **pobject) |
@@ -74,7 +84,7 @@ nv98_ppp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
74 | struct nv98_ppp_priv *priv; | 84 | struct nv98_ppp_priv *priv; |
75 | int ret; | 85 | int ret; |
76 | 86 | ||
77 | ret = nouveau_engine_create(parent, engine, oclass, true, | 87 | ret = nouveau_falcon_create(parent, engine, oclass, 0x086000, true, |
78 | "PPPP", "ppp", &priv); | 88 | "PPPP", "ppp", &priv); |
79 | *pobject = nv_object(priv); | 89 | *pobject = nv_object(priv); |
80 | if (ret) | 90 | if (ret) |
@@ -91,8 +101,10 @@ nv98_ppp_oclass = { | |||
91 | .handle = NV_ENGINE(PPP, 0x98), | 101 | .handle = NV_ENGINE(PPP, 0x98), |
92 | .ofuncs = &(struct nouveau_ofuncs) { | 102 | .ofuncs = &(struct nouveau_ofuncs) { |
93 | .ctor = nv98_ppp_ctor, | 103 | .ctor = nv98_ppp_ctor, |
94 | .dtor = _nouveau_engine_dtor, | 104 | .dtor = _nouveau_falcon_dtor, |
95 | .init = _nouveau_engine_init, | 105 | .init = nv98_ppp_init, |
96 | .fini = _nouveau_engine_fini, | 106 | .fini = _nouveau_falcon_fini, |
107 | .rd32 = _nouveau_falcon_rd32, | ||
108 | .wr32 = _nouveau_falcon_wr32, | ||
97 | }, | 109 | }, |
98 | }; | 110 | }; |
diff --git a/drivers/gpu/drm/nouveau/core/engine/vp/nv98.c b/drivers/gpu/drm/nouveau/core/engine/vp/nv98.c index 8a8236bc84de..fc9ae0ff1ef5 100644 --- a/drivers/gpu/drm/nouveau/core/engine/vp/nv98.c +++ b/drivers/gpu/drm/nouveau/core/engine/vp/nv98.c | |||
@@ -19,16 +19,14 @@ | |||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 21 | * |
22 | * Authors: Ben Skeggs | 22 | * Authors: Ben Skeggs, Maarten Lankhorst, Ilia Mirkin |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <core/engctx.h> | 25 | #include <engine/falcon.h> |
26 | #include <core/class.h> | ||
27 | |||
28 | #include <engine/vp.h> | 26 | #include <engine/vp.h> |
29 | 27 | ||
30 | struct nv98_vp_priv { | 28 | struct nv98_vp_priv { |
31 | struct nouveau_engine base; | 29 | struct nouveau_falcon base; |
32 | }; | 30 | }; |
33 | 31 | ||
34 | /******************************************************************************* | 32 | /******************************************************************************* |
@@ -37,6 +35,8 @@ struct nv98_vp_priv { | |||
37 | 35 | ||
38 | static struct nouveau_oclass | 36 | static struct nouveau_oclass |
39 | nv98_vp_sclass[] = { | 37 | nv98_vp_sclass[] = { |
38 | { 0x88b2, &nouveau_object_ofuncs }, | ||
39 | { 0x85b2, &nouveau_object_ofuncs }, | ||
40 | {}, | 40 | {}, |
41 | }; | 41 | }; |
42 | 42 | ||
@@ -48,12 +48,12 @@ static struct nouveau_oclass | |||
48 | nv98_vp_cclass = { | 48 | nv98_vp_cclass = { |
49 | .handle = NV_ENGCTX(VP, 0x98), | 49 | .handle = NV_ENGCTX(VP, 0x98), |
50 | .ofuncs = &(struct nouveau_ofuncs) { | 50 | .ofuncs = &(struct nouveau_ofuncs) { |
51 | .ctor = _nouveau_engctx_ctor, | 51 | .ctor = _nouveau_falcon_context_ctor, |
52 | .dtor = _nouveau_engctx_dtor, | 52 | .dtor = _nouveau_falcon_context_dtor, |
53 | .init = _nouveau_engctx_init, | 53 | .init = _nouveau_falcon_context_init, |
54 | .fini = _nouveau_engctx_fini, | 54 | .fini = _nouveau_falcon_context_fini, |
55 | .rd32 = _nouveau_engctx_rd32, | 55 | .rd32 = _nouveau_falcon_context_rd32, |
56 | .wr32 = _nouveau_engctx_wr32, | 56 | .wr32 = _nouveau_falcon_context_wr32, |
57 | }, | 57 | }, |
58 | }; | 58 | }; |
59 | 59 | ||
@@ -62,6 +62,21 @@ nv98_vp_cclass = { | |||
62 | ******************************************************************************/ | 62 | ******************************************************************************/ |
63 | 63 | ||
64 | static int | 64 | static int |
65 | nv98_vp_init(struct nouveau_object *object) | ||
66 | { | ||
67 | struct nv98_vp_priv *priv = (void *)object; | ||
68 | int ret; | ||
69 | |||
70 | ret = nouveau_falcon_init(&priv->base); | ||
71 | if (ret) | ||
72 | return ret; | ||
73 | |||
74 | nv_wr32(priv, 0x085010, 0x0000ffd2); | ||
75 | nv_wr32(priv, 0x08501c, 0x0000fff2); | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int | ||
65 | nv98_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 80 | nv98_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
66 | struct nouveau_oclass *oclass, void *data, u32 size, | 81 | struct nouveau_oclass *oclass, void *data, u32 size, |
67 | struct nouveau_object **pobject) | 82 | struct nouveau_object **pobject) |
@@ -69,7 +84,7 @@ nv98_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
69 | struct nv98_vp_priv *priv; | 84 | struct nv98_vp_priv *priv; |
70 | int ret; | 85 | int ret; |
71 | 86 | ||
72 | ret = nouveau_engine_create(parent, engine, oclass, true, | 87 | ret = nouveau_falcon_create(parent, engine, oclass, 0x085000, true, |
73 | "PVP", "vp", &priv); | 88 | "PVP", "vp", &priv); |
74 | *pobject = nv_object(priv); | 89 | *pobject = nv_object(priv); |
75 | if (ret) | 90 | if (ret) |
@@ -86,8 +101,10 @@ nv98_vp_oclass = { | |||
86 | .handle = NV_ENGINE(VP, 0x98), | 101 | .handle = NV_ENGINE(VP, 0x98), |
87 | .ofuncs = &(struct nouveau_ofuncs) { | 102 | .ofuncs = &(struct nouveau_ofuncs) { |
88 | .ctor = nv98_vp_ctor, | 103 | .ctor = nv98_vp_ctor, |
89 | .dtor = _nouveau_engine_dtor, | 104 | .dtor = _nouveau_falcon_dtor, |
90 | .init = _nouveau_engine_init, | 105 | .init = nv98_vp_init, |
91 | .fini = _nouveau_engine_fini, | 106 | .fini = _nouveau_falcon_fini, |
107 | .rd32 = _nouveau_falcon_rd32, | ||
108 | .wr32 = _nouveau_falcon_wr32, | ||
92 | }, | 109 | }, |
93 | }; | 110 | }; |
diff --git a/drivers/gpu/drm/nouveau/core/include/core/math.h b/drivers/gpu/drm/nouveau/core/include/core/math.h deleted file mode 100644 index f808131c5cd8..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/math.h +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | #ifndef __NOUVEAU_MATH_H__ | ||
2 | #define __NOUVEAU_MATH_H__ | ||
3 | |||
4 | static inline int | ||
5 | log2i(u64 base) | ||
6 | { | ||
7 | u64 temp = base >> 1; | ||
8 | int log2; | ||
9 | |||
10 | for (log2 = 0; temp; log2++, temp >>= 1) { | ||
11 | } | ||
12 | |||
13 | return (base & (base - 1)) ? log2 + 1: log2; | ||
14 | } | ||
15 | |||
16 | #endif | ||
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h b/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h index 888384c0bed8..7e4e2775f249 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h | |||
@@ -39,8 +39,8 @@ struct nouveau_i2c_func { | |||
39 | int (*drv_ctl)(struct nouveau_i2c_port *, int lane, int sw, int pe); | 39 | int (*drv_ctl)(struct nouveau_i2c_port *, int lane, int sw, int pe); |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #define nouveau_i2c_port_create(p,e,o,i,a,d) \ | 42 | #define nouveau_i2c_port_create(p,e,o,i,a,f,d) \ |
43 | nouveau_i2c_port_create_((p), (e), (o), (i), (a), \ | 43 | nouveau_i2c_port_create_((p), (e), (o), (i), (a), (f), \ |
44 | sizeof(**d), (void **)d) | 44 | sizeof(**d), (void **)d) |
45 | #define nouveau_i2c_port_destroy(p) ({ \ | 45 | #define nouveau_i2c_port_destroy(p) ({ \ |
46 | struct nouveau_i2c_port *port = (p); \ | 46 | struct nouveau_i2c_port *port = (p); \ |
@@ -53,7 +53,9 @@ struct nouveau_i2c_func { | |||
53 | 53 | ||
54 | int nouveau_i2c_port_create_(struct nouveau_object *, struct nouveau_object *, | 54 | int nouveau_i2c_port_create_(struct nouveau_object *, struct nouveau_object *, |
55 | struct nouveau_oclass *, u8, | 55 | struct nouveau_oclass *, u8, |
56 | const struct i2c_algorithm *, int, void **); | 56 | const struct i2c_algorithm *, |
57 | const struct nouveau_i2c_func *, | ||
58 | int, void **); | ||
57 | void _nouveau_i2c_port_dtor(struct nouveau_object *); | 59 | void _nouveau_i2c_port_dtor(struct nouveau_object *); |
58 | #define _nouveau_i2c_port_init nouveau_object_init | 60 | #define _nouveau_i2c_port_init nouveau_object_init |
59 | #define _nouveau_i2c_port_fini nouveau_object_fini | 61 | #define _nouveau_i2c_port_fini nouveau_object_fini |
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/mc.h b/drivers/gpu/drm/nouveau/core/include/subdev/mc.h index 9d2cd2006250..ce6569f365a7 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/mc.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/mc.h | |||
@@ -12,6 +12,7 @@ struct nouveau_mc_intr { | |||
12 | struct nouveau_mc { | 12 | struct nouveau_mc { |
13 | struct nouveau_subdev base; | 13 | struct nouveau_subdev base; |
14 | const struct nouveau_mc_intr *intr_map; | 14 | const struct nouveau_mc_intr *intr_map; |
15 | bool use_msi; | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | static inline struct nouveau_mc * | 18 | static inline struct nouveau_mc * |
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/timer.h b/drivers/gpu/drm/nouveau/core/include/subdev/timer.h index e465d158d352..9ab70dfe5b02 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/timer.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/timer.h | |||
@@ -22,6 +22,7 @@ bool nouveau_timer_wait_eq(void *, u64 nsec, u32 addr, u32 mask, u32 data); | |||
22 | bool nouveau_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data); | 22 | bool nouveau_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data); |
23 | bool nouveau_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data); | 23 | bool nouveau_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data); |
24 | void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *); | 24 | void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *); |
25 | void nouveau_timer_alarm_cancel(void *, struct nouveau_alarm *); | ||
25 | 26 | ||
26 | #define NV_WAIT_DEFAULT 2000000000ULL | 27 | #define NV_WAIT_DEFAULT 2000000000ULL |
27 | #define nv_wait(o,a,m,v) \ | 28 | #define nv_wait(o,a,m,v) \ |
@@ -35,6 +36,7 @@ struct nouveau_timer { | |||
35 | struct nouveau_subdev base; | 36 | struct nouveau_subdev base; |
36 | u64 (*read)(struct nouveau_timer *); | 37 | u64 (*read)(struct nouveau_timer *); |
37 | void (*alarm)(struct nouveau_timer *, u64 time, struct nouveau_alarm *); | 38 | void (*alarm)(struct nouveau_timer *, u64 time, struct nouveau_alarm *); |
39 | void (*alarm_cancel)(struct nouveau_timer *, struct nouveau_alarm *); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | static inline struct nouveau_timer * | 42 | static inline struct nouveau_timer * |
diff --git a/drivers/gpu/drm/nouveau/core/os.h b/drivers/gpu/drm/nouveau/core/os.h index 3bd9be2ab37f..191e739f30d1 100644 --- a/drivers/gpu/drm/nouveau/core/os.h +++ b/drivers/gpu/drm/nouveau/core/os.h | |||
@@ -13,11 +13,13 @@ | |||
13 | #include <linux/i2c-algo-bit.h> | 13 | #include <linux/i2c-algo-bit.h> |
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/io-mapping.h> | 15 | #include <linux/io-mapping.h> |
16 | #include <linux/vmalloc.h> | ||
17 | #include <linux/acpi.h> | 16 | #include <linux/acpi.h> |
17 | #include <linux/vmalloc.h> | ||
18 | #include <linux/dmi.h> | 18 | #include <linux/dmi.h> |
19 | #include <linux/reboot.h> | 19 | #include <linux/reboot.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/log2.h> | ||
22 | #include <linux/pm_runtime.h> | ||
21 | 23 | ||
22 | #include <asm/unaligned.h> | 24 | #include <asm/unaligned.h> |
23 | 25 | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c index 2e11ea02cf87..57cda2a1437b 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c | |||
@@ -579,8 +579,22 @@ static void | |||
579 | init_reserved(struct nvbios_init *init) | 579 | init_reserved(struct nvbios_init *init) |
580 | { | 580 | { |
581 | u8 opcode = nv_ro08(init->bios, init->offset); | 581 | u8 opcode = nv_ro08(init->bios, init->offset); |
582 | trace("RESERVED\t0x%02x\n", opcode); | 582 | u8 length, i; |
583 | init->offset += 1; | 583 | |
584 | switch (opcode) { | ||
585 | case 0xaa: | ||
586 | length = 4; | ||
587 | break; | ||
588 | default: | ||
589 | length = 1; | ||
590 | break; | ||
591 | } | ||
592 | |||
593 | trace("RESERVED 0x%02x\t", opcode); | ||
594 | for (i = 1; i < length; i++) | ||
595 | cont(" 0x%02x", nv_ro08(init->bios, init->offset + i)); | ||
596 | cont("\n"); | ||
597 | init->offset += length; | ||
584 | } | 598 | } |
585 | 599 | ||
586 | /** | 600 | /** |
@@ -1437,7 +1451,7 @@ init_configure_mem(struct nvbios_init *init) | |||
1437 | data = init_rdvgai(init, 0x03c4, 0x01); | 1451 | data = init_rdvgai(init, 0x03c4, 0x01); |
1438 | init_wrvgai(init, 0x03c4, 0x01, data | 0x20); | 1452 | init_wrvgai(init, 0x03c4, 0x01, data | 0x20); |
1439 | 1453 | ||
1440 | while ((addr = nv_ro32(bios, sdata)) != 0xffffffff) { | 1454 | for (; (addr = nv_ro32(bios, sdata)) != 0xffffffff; sdata += 4) { |
1441 | switch (addr) { | 1455 | switch (addr) { |
1442 | case 0x10021c: /* CKE_NORMAL */ | 1456 | case 0x10021c: /* CKE_NORMAL */ |
1443 | case 0x1002d0: /* CMD_REFRESH */ | 1457 | case 0x1002d0: /* CMD_REFRESH */ |
@@ -2135,6 +2149,7 @@ static struct nvbios_init_opcode { | |||
2135 | [0x99] = { init_zm_auxch }, | 2149 | [0x99] = { init_zm_auxch }, |
2136 | [0x9a] = { init_i2c_long_if }, | 2150 | [0x9a] = { init_i2c_long_if }, |
2137 | [0xa9] = { init_gpio_ne }, | 2151 | [0xa9] = { init_gpio_ne }, |
2152 | [0xaa] = { init_reserved }, | ||
2138 | }; | 2153 | }; |
2139 | 2154 | ||
2140 | #define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0])) | 2155 | #define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0])) |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c b/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c index 22a20573ed1b..22ac6dbd6c8f 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c | |||
@@ -184,7 +184,8 @@ nvbios_therm_fan_parse(struct nouveau_bios *bios, | |||
184 | cur_trip->fan_duty = value; | 184 | cur_trip->fan_duty = value; |
185 | break; | 185 | break; |
186 | case 0x26: | 186 | case 0x26: |
187 | fan->pwm_freq = value; | 187 | if (!fan->pwm_freq) |
188 | fan->pwm_freq = value; | ||
188 | break; | 189 | break; |
189 | case 0x3b: | 190 | case 0x3b: |
190 | fan->bump_period = value; | 191 | fan->bump_period = value; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/anx9805.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/anx9805.c index dec94e9d776a..4b195ac4da66 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/anx9805.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/anx9805.c | |||
@@ -118,7 +118,8 @@ anx9805_aux_chan_ctor(struct nouveau_object *parent, | |||
118 | int ret; | 118 | int ret; |
119 | 119 | ||
120 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 120 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
121 | &nouveau_i2c_aux_algo, &chan); | 121 | &nouveau_i2c_aux_algo, &anx9805_aux_func, |
122 | &chan); | ||
122 | *pobject = nv_object(chan); | 123 | *pobject = nv_object(chan); |
123 | if (ret) | 124 | if (ret) |
124 | return ret; | 125 | return ret; |
@@ -140,8 +141,6 @@ anx9805_aux_chan_ctor(struct nouveau_object *parent, | |||
140 | struct i2c_algo_bit_data *algo = mast->adapter.algo_data; | 141 | struct i2c_algo_bit_data *algo = mast->adapter.algo_data; |
141 | algo->udelay = max(algo->udelay, 40); | 142 | algo->udelay = max(algo->udelay, 40); |
142 | } | 143 | } |
143 | |||
144 | chan->base.func = &anx9805_aux_func; | ||
145 | return 0; | 144 | return 0; |
146 | } | 145 | } |
147 | 146 | ||
@@ -234,7 +233,8 @@ anx9805_ddc_port_ctor(struct nouveau_object *parent, | |||
234 | int ret; | 233 | int ret; |
235 | 234 | ||
236 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 235 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
237 | &anx9805_i2c_algo, &port); | 236 | &anx9805_i2c_algo, &anx9805_i2c_func, |
237 | &port); | ||
238 | *pobject = nv_object(port); | 238 | *pobject = nv_object(port); |
239 | if (ret) | 239 | if (ret) |
240 | return ret; | 240 | return ret; |
@@ -256,8 +256,6 @@ anx9805_ddc_port_ctor(struct nouveau_object *parent, | |||
256 | struct i2c_algo_bit_data *algo = mast->adapter.algo_data; | 256 | struct i2c_algo_bit_data *algo = mast->adapter.algo_data; |
257 | algo->udelay = max(algo->udelay, 40); | 257 | algo->udelay = max(algo->udelay, 40); |
258 | } | 258 | } |
259 | |||
260 | port->base.func = &anx9805_i2c_func; | ||
261 | return 0; | 259 | return 0; |
262 | } | 260 | } |
263 | 261 | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c index 8ae2625415e1..2895c19bb152 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | |||
@@ -95,6 +95,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent, | |||
95 | struct nouveau_object *engine, | 95 | struct nouveau_object *engine, |
96 | struct nouveau_oclass *oclass, u8 index, | 96 | struct nouveau_oclass *oclass, u8 index, |
97 | const struct i2c_algorithm *algo, | 97 | const struct i2c_algorithm *algo, |
98 | const struct nouveau_i2c_func *func, | ||
98 | int size, void **pobject) | 99 | int size, void **pobject) |
99 | { | 100 | { |
100 | struct nouveau_device *device = nv_device(parent); | 101 | struct nouveau_device *device = nv_device(parent); |
@@ -112,6 +113,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent, | |||
112 | port->adapter.owner = THIS_MODULE; | 113 | port->adapter.owner = THIS_MODULE; |
113 | port->adapter.dev.parent = &device->pdev->dev; | 114 | port->adapter.dev.parent = &device->pdev->dev; |
114 | port->index = index; | 115 | port->index = index; |
116 | port->func = func; | ||
115 | i2c_set_adapdata(&port->adapter, i2c); | 117 | i2c_set_adapdata(&port->adapter, i2c); |
116 | 118 | ||
117 | if ( algo == &nouveau_i2c_bit_algo && | 119 | if ( algo == &nouveau_i2c_bit_algo && |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv04.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv04.c index 2ad18840fe63..860d5d2365da 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv04.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv04.c | |||
@@ -91,12 +91,12 @@ nv04_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
91 | int ret; | 91 | int ret; |
92 | 92 | ||
93 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 93 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
94 | &nouveau_i2c_bit_algo, &port); | 94 | &nouveau_i2c_bit_algo, &nv04_i2c_func, |
95 | &port); | ||
95 | *pobject = nv_object(port); | 96 | *pobject = nv_object(port); |
96 | if (ret) | 97 | if (ret) |
97 | return ret; | 98 | return ret; |
98 | 99 | ||
99 | port->base.func = &nv04_i2c_func; | ||
100 | port->drive = info->drive; | 100 | port->drive = info->drive; |
101 | port->sense = info->sense; | 101 | port->sense = info->sense; |
102 | return 0; | 102 | return 0; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv4e.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv4e.c index f501ae25dbb3..0c2655a03bb4 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv4e.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv4e.c | |||
@@ -84,12 +84,12 @@ nv4e_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
84 | int ret; | 84 | int ret; |
85 | 85 | ||
86 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 86 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
87 | &nouveau_i2c_bit_algo, &port); | 87 | &nouveau_i2c_bit_algo, &nv4e_i2c_func, |
88 | &port); | ||
88 | *pobject = nv_object(port); | 89 | *pobject = nv_object(port); |
89 | if (ret) | 90 | if (ret) |
90 | return ret; | 91 | return ret; |
91 | 92 | ||
92 | port->base.func = &nv4e_i2c_func; | ||
93 | port->addr = 0x600800 + info->drive; | 93 | port->addr = 0x600800 + info->drive; |
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv50.c index 378dfa324e5f..a8d67a287704 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv50.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv50.c | |||
@@ -85,7 +85,8 @@ nv50_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
85 | int ret; | 85 | int ret; |
86 | 86 | ||
87 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 87 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
88 | &nouveau_i2c_bit_algo, &port); | 88 | &nouveau_i2c_bit_algo, &nv50_i2c_func, |
89 | &port); | ||
89 | *pobject = nv_object(port); | 90 | *pobject = nv_object(port); |
90 | if (ret) | 91 | if (ret) |
91 | return ret; | 92 | return ret; |
@@ -93,7 +94,6 @@ nv50_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
93 | if (info->drive >= nv50_i2c_addr_nr) | 94 | if (info->drive >= nv50_i2c_addr_nr) |
94 | return -EINVAL; | 95 | return -EINVAL; |
95 | 96 | ||
96 | port->base.func = &nv50_i2c_func; | ||
97 | port->state = 0x00000007; | 97 | port->state = 0x00000007; |
98 | port->addr = nv50_i2c_addr[info->drive]; | 98 | port->addr = nv50_i2c_addr[info->drive]; |
99 | return 0; | 99 | return 0; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv94.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv94.c index 61b771670bfe..df6d3e4b68be 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/nv94.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/nv94.c | |||
@@ -186,7 +186,8 @@ nv94_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
186 | int ret; | 186 | int ret; |
187 | 187 | ||
188 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 188 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
189 | &nouveau_i2c_bit_algo, &port); | 189 | &nouveau_i2c_bit_algo, &nv94_i2c_func, |
190 | &port); | ||
190 | *pobject = nv_object(port); | 191 | *pobject = nv_object(port); |
191 | if (ret) | 192 | if (ret) |
192 | return ret; | 193 | return ret; |
@@ -194,7 +195,6 @@ nv94_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
194 | if (info->drive >= nv50_i2c_addr_nr) | 195 | if (info->drive >= nv50_i2c_addr_nr) |
195 | return -EINVAL; | 196 | return -EINVAL; |
196 | 197 | ||
197 | port->base.func = &nv94_i2c_func; | ||
198 | port->state = 7; | 198 | port->state = 7; |
199 | port->addr = nv50_i2c_addr[info->drive]; | 199 | port->addr = nv50_i2c_addr[info->drive]; |
200 | if (info->share != DCB_I2C_UNUSED) { | 200 | if (info->share != DCB_I2C_UNUSED) { |
@@ -221,12 +221,12 @@ nv94_aux_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
221 | int ret; | 221 | int ret; |
222 | 222 | ||
223 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 223 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
224 | &nouveau_i2c_aux_algo, &port); | 224 | &nouveau_i2c_aux_algo, &nv94_aux_func, |
225 | &port); | ||
225 | *pobject = nv_object(port); | 226 | *pobject = nv_object(port); |
226 | if (ret) | 227 | if (ret) |
227 | return ret; | 228 | return ret; |
228 | 229 | ||
229 | port->base.func = &nv94_aux_func; | ||
230 | port->addr = info->drive; | 230 | port->addr = info->drive; |
231 | if (info->share != DCB_I2C_UNUSED) { | 231 | if (info->share != DCB_I2C_UNUSED) { |
232 | port->ctrl = 0x00e500 + (info->drive * 0x50); | 232 | port->ctrl = 0x00e500 + (info->drive * 0x50); |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/nvd0.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/nvd0.c index f761b8a610f1..29967d30f97c 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/nvd0.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/nvd0.c | |||
@@ -60,12 +60,12 @@ nvd0_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
60 | int ret; | 60 | int ret; |
61 | 61 | ||
62 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, | 62 | ret = nouveau_i2c_port_create(parent, engine, oclass, index, |
63 | &nouveau_i2c_bit_algo, &port); | 63 | &nouveau_i2c_bit_algo, &nvd0_i2c_func, |
64 | &port); | ||
64 | *pobject = nv_object(port); | 65 | *pobject = nv_object(port); |
65 | if (ret) | 66 | if (ret) |
66 | return ret; | 67 | return ret; |
67 | 68 | ||
68 | port->base.func = &nvd0_i2c_func; | ||
69 | port->state = 0x00000007; | 69 | port->state = 0x00000007; |
70 | port->addr = 0x00d014 + (info->drive * 0x20); | 70 | port->addr = 0x00d014 + (info->drive * 0x20); |
71 | if (info->share != DCB_I2C_UNUSED) { | 71 | if (info->share != DCB_I2C_UNUSED) { |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c b/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c index 716bf41bc3c1..b10a143787a7 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c +++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c | |||
@@ -22,15 +22,9 @@ | |||
22 | * Authors: Ben Skeggs | 22 | * Authors: Ben Skeggs |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "nv04.h" | 25 | #include <engine/graph/nv40.h> |
26 | 26 | ||
27 | static inline int | 27 | #include "nv04.h" |
28 | nv44_graph_class(struct nv04_instmem_priv *priv) | ||
29 | { | ||
30 | if ((nv_device(priv)->chipset & 0xf0) == 0x60) | ||
31 | return 1; | ||
32 | return !(0x0baf & (1 << (nv_device(priv)->chipset & 0x0f))); | ||
33 | } | ||
34 | 28 | ||
35 | static int | 29 | static int |
36 | nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 30 | nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/base.c b/drivers/gpu/drm/nouveau/core/subdev/mc/base.c index 20f9a538746e..37712a6df923 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/mc/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/mc/base.c | |||
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <subdev/mc.h> | 25 | #include <subdev/mc.h> |
26 | #include <linux/pm_runtime.h> | 26 | #include <core/option.h> |
27 | 27 | ||
28 | static irqreturn_t | 28 | static irqreturn_t |
29 | nouveau_mc_intr(int irq, void *arg) | 29 | nouveau_mc_intr(int irq, void *arg) |
@@ -47,6 +47,9 @@ nouveau_mc_intr(int irq, void *arg) | |||
47 | map++; | 47 | map++; |
48 | } | 48 | } |
49 | 49 | ||
50 | if (pmc->use_msi) | ||
51 | nv_wr08(pmc->base.base.parent, 0x00088068, 0xff); | ||
52 | |||
50 | if (intr) { | 53 | if (intr) { |
51 | nv_error(pmc, "unknown intr 0x%08x\n", stat); | 54 | nv_error(pmc, "unknown intr 0x%08x\n", stat); |
52 | } | 55 | } |
@@ -81,6 +84,8 @@ _nouveau_mc_dtor(struct nouveau_object *object) | |||
81 | struct nouveau_device *device = nv_device(object); | 84 | struct nouveau_device *device = nv_device(object); |
82 | struct nouveau_mc *pmc = (void *)object; | 85 | struct nouveau_mc *pmc = (void *)object; |
83 | free_irq(device->pdev->irq, pmc); | 86 | free_irq(device->pdev->irq, pmc); |
87 | if (pmc->use_msi) | ||
88 | pci_disable_msi(device->pdev); | ||
84 | nouveau_subdev_destroy(&pmc->base); | 89 | nouveau_subdev_destroy(&pmc->base); |
85 | } | 90 | } |
86 | 91 | ||
@@ -102,6 +107,23 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, | |||
102 | 107 | ||
103 | pmc->intr_map = intr_map; | 108 | pmc->intr_map = intr_map; |
104 | 109 | ||
110 | switch (device->pdev->device & 0x0ff0) { | ||
111 | case 0x00f0: /* BR02? */ | ||
112 | case 0x02e0: /* BR02? */ | ||
113 | pmc->use_msi = false; | ||
114 | break; | ||
115 | default: | ||
116 | pmc->use_msi = nouveau_boolopt(device->cfgopt, "NvMSI", true); | ||
117 | if (pmc->use_msi) { | ||
118 | pmc->use_msi = pci_enable_msi(device->pdev) == 0; | ||
119 | if (pmc->use_msi) { | ||
120 | nv_info(pmc, "MSI interrupts enabled\n"); | ||
121 | nv_wr08(device, 0x00088068, 0xff); | ||
122 | } | ||
123 | } | ||
124 | break; | ||
125 | } | ||
126 | |||
105 | ret = request_irq(device->pdev->irq, nouveau_mc_intr, | 127 | ret = request_irq(device->pdev->irq, nouveau_mc_intr, |
106 | IRQF_SHARED, "nouveau", pmc); | 128 | IRQF_SHARED, "nouveau", pmc); |
107 | if (ret < 0) | 129 | if (ret < 0) |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c index 0d57b4d3e001..06710419a59b 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c +++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c | |||
@@ -35,6 +35,7 @@ nv98_mc_intr[] = { | |||
35 | { 0x00001000, NVDEV_ENGINE_GR }, | 35 | { 0x00001000, NVDEV_ENGINE_GR }, |
36 | { 0x00004000, NVDEV_ENGINE_CRYPT }, /* NV84:NVA3 */ | 36 | { 0x00004000, NVDEV_ENGINE_CRYPT }, /* NV84:NVA3 */ |
37 | { 0x00008000, NVDEV_ENGINE_BSP }, | 37 | { 0x00008000, NVDEV_ENGINE_BSP }, |
38 | { 0x00020000, NVDEV_ENGINE_VP }, | ||
38 | { 0x00080000, NVDEV_SUBDEV_THERM }, /* NVA3:NVC0 */ | 39 | { 0x00080000, NVDEV_SUBDEV_THERM }, /* NVA3:NVC0 */ |
39 | { 0x00100000, NVDEV_SUBDEV_TIMER }, | 40 | { 0x00100000, NVDEV_SUBDEV_TIMER }, |
40 | { 0x00200000, NVDEV_SUBDEV_GPIO }, | 41 | { 0x00200000, NVDEV_SUBDEV_GPIO }, |
@@ -42,7 +43,7 @@ nv98_mc_intr[] = { | |||
42 | { 0x04000000, NVDEV_ENGINE_DISP }, | 43 | { 0x04000000, NVDEV_ENGINE_DISP }, |
43 | { 0x10000000, NVDEV_SUBDEV_BUS }, | 44 | { 0x10000000, NVDEV_SUBDEV_BUS }, |
44 | { 0x80000000, NVDEV_ENGINE_SW }, | 45 | { 0x80000000, NVDEV_ENGINE_SW }, |
45 | { 0x0040d101, NVDEV_SUBDEV_FB }, | 46 | { 0x0042d101, NVDEV_SUBDEV_FB }, |
46 | {}, | 47 | {}, |
47 | }; | 48 | }; |
48 | 49 | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/base.c b/drivers/gpu/drm/nouveau/core/subdev/therm/base.c index a00a5a76e2d6..f1de7a9c572b 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/base.c | |||
@@ -95,12 +95,14 @@ nouveau_therm_update(struct nouveau_therm *therm, int mode) | |||
95 | int duty; | 95 | int duty; |
96 | 96 | ||
97 | spin_lock_irqsave(&priv->lock, flags); | 97 | spin_lock_irqsave(&priv->lock, flags); |
98 | nv_debug(therm, "FAN speed check\n"); | ||
98 | if (mode < 0) | 99 | if (mode < 0) |
99 | mode = priv->mode; | 100 | mode = priv->mode; |
100 | priv->mode = mode; | 101 | priv->mode = mode; |
101 | 102 | ||
102 | switch (mode) { | 103 | switch (mode) { |
103 | case NOUVEAU_THERM_CTRL_MANUAL: | 104 | case NOUVEAU_THERM_CTRL_MANUAL: |
105 | ptimer->alarm_cancel(ptimer, &priv->alarm); | ||
104 | duty = nouveau_therm_fan_get(therm); | 106 | duty = nouveau_therm_fan_get(therm); |
105 | if (duty < 0) | 107 | if (duty < 0) |
106 | duty = 100; | 108 | duty = 100; |
@@ -113,6 +115,7 @@ nouveau_therm_update(struct nouveau_therm *therm, int mode) | |||
113 | break; | 115 | break; |
114 | case NOUVEAU_THERM_CTRL_NONE: | 116 | case NOUVEAU_THERM_CTRL_NONE: |
115 | default: | 117 | default: |
118 | ptimer->alarm_cancel(ptimer, &priv->alarm); | ||
116 | goto done; | 119 | goto done; |
117 | } | 120 | } |
118 | 121 | ||
@@ -122,6 +125,8 @@ nouveau_therm_update(struct nouveau_therm *therm, int mode) | |||
122 | done: | 125 | done: |
123 | if (list_empty(&priv->alarm.head) && (mode == NOUVEAU_THERM_CTRL_AUTO)) | 126 | if (list_empty(&priv->alarm.head) && (mode == NOUVEAU_THERM_CTRL_AUTO)) |
124 | ptimer->alarm(ptimer, 1000000000ULL, &priv->alarm); | 127 | ptimer->alarm(ptimer, 1000000000ULL, &priv->alarm); |
128 | else if (!list_empty(&priv->alarm.head)) | ||
129 | nv_debug(therm, "therm fan alarm list is not empty\n"); | ||
125 | spin_unlock_irqrestore(&priv->lock, flags); | 130 | spin_unlock_irqrestore(&priv->lock, flags); |
126 | } | 131 | } |
127 | 132 | ||
@@ -267,9 +272,15 @@ _nouveau_therm_init(struct nouveau_object *object) | |||
267 | if (ret) | 272 | if (ret) |
268 | return ret; | 273 | return ret; |
269 | 274 | ||
270 | if (priv->suspend >= 0) | 275 | if (priv->suspend >= 0) { |
271 | nouveau_therm_fan_mode(therm, priv->mode); | 276 | /* restore the pwm value only when on manual or auto mode */ |
272 | priv->sensor.program_alarms(therm); | 277 | if (priv->suspend > 0) |
278 | nouveau_therm_fan_set(therm, true, priv->fan->percent); | ||
279 | |||
280 | nouveau_therm_fan_mode(therm, priv->suspend); | ||
281 | } | ||
282 | nouveau_therm_sensor_init(therm); | ||
283 | nouveau_therm_fan_init(therm); | ||
273 | return 0; | 284 | return 0; |
274 | } | 285 | } |
275 | 286 | ||
@@ -279,6 +290,8 @@ _nouveau_therm_fini(struct nouveau_object *object, bool suspend) | |||
279 | struct nouveau_therm *therm = (void *)object; | 290 | struct nouveau_therm *therm = (void *)object; |
280 | struct nouveau_therm_priv *priv = (void *)therm; | 291 | struct nouveau_therm_priv *priv = (void *)therm; |
281 | 292 | ||
293 | nouveau_therm_fan_fini(therm, suspend); | ||
294 | nouveau_therm_sensor_fini(therm, suspend); | ||
282 | if (suspend) { | 295 | if (suspend) { |
283 | priv->suspend = priv->mode; | 296 | priv->suspend = priv->mode; |
284 | priv->mode = NOUVEAU_THERM_CTRL_NONE; | 297 | priv->mode = NOUVEAU_THERM_CTRL_NONE; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c index c728380d3d62..39f47b950ad1 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c | |||
@@ -204,6 +204,23 @@ nouveau_therm_fan_safety_checks(struct nouveau_therm *therm) | |||
204 | } | 204 | } |
205 | 205 | ||
206 | int | 206 | int |
207 | nouveau_therm_fan_init(struct nouveau_therm *therm) | ||
208 | { | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | int | ||
213 | nouveau_therm_fan_fini(struct nouveau_therm *therm, bool suspend) | ||
214 | { | ||
215 | struct nouveau_therm_priv *priv = (void *)therm; | ||
216 | struct nouveau_timer *ptimer = nouveau_timer(therm); | ||
217 | |||
218 | if (suspend) | ||
219 | ptimer->alarm_cancel(ptimer, &priv->fan->alarm); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | int | ||
207 | nouveau_therm_fan_ctor(struct nouveau_therm *therm) | 224 | nouveau_therm_fan_ctor(struct nouveau_therm *therm) |
208 | { | 225 | { |
209 | struct nouveau_therm_priv *priv = (void *)therm; | 226 | struct nouveau_therm_priv *priv = (void *)therm; |
@@ -234,6 +251,9 @@ nouveau_therm_fan_ctor(struct nouveau_therm *therm) | |||
234 | 251 | ||
235 | nv_info(therm, "FAN control: %s\n", priv->fan->type); | 252 | nv_info(therm, "FAN control: %s\n", priv->fan->type); |
236 | 253 | ||
254 | /* read the current speed, it is useful when resuming */ | ||
255 | priv->fan->percent = nouveau_therm_fan_get(therm); | ||
256 | |||
237 | /* attempt to detect a tachometer connection */ | 257 | /* attempt to detect a tachometer connection */ |
238 | ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan->tach); | 258 | ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan->tach); |
239 | if (ret) | 259 | if (ret) |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h b/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h index 15ca64e481f1..dd38529262fb 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h | |||
@@ -113,6 +113,8 @@ void nouveau_therm_ic_ctor(struct nouveau_therm *therm); | |||
113 | int nouveau_therm_sensor_ctor(struct nouveau_therm *therm); | 113 | int nouveau_therm_sensor_ctor(struct nouveau_therm *therm); |
114 | 114 | ||
115 | int nouveau_therm_fan_ctor(struct nouveau_therm *therm); | 115 | int nouveau_therm_fan_ctor(struct nouveau_therm *therm); |
116 | int nouveau_therm_fan_init(struct nouveau_therm *therm); | ||
117 | int nouveau_therm_fan_fini(struct nouveau_therm *therm, bool suspend); | ||
116 | int nouveau_therm_fan_get(struct nouveau_therm *therm); | 118 | int nouveau_therm_fan_get(struct nouveau_therm *therm); |
117 | int nouveau_therm_fan_set(struct nouveau_therm *therm, bool now, int percent); | 119 | int nouveau_therm_fan_set(struct nouveau_therm *therm, bool now, int percent); |
118 | int nouveau_therm_fan_user_get(struct nouveau_therm *therm); | 120 | int nouveau_therm_fan_user_get(struct nouveau_therm *therm); |
@@ -122,6 +124,8 @@ int nouveau_therm_fan_sense(struct nouveau_therm *therm); | |||
122 | 124 | ||
123 | int nouveau_therm_preinit(struct nouveau_therm *); | 125 | int nouveau_therm_preinit(struct nouveau_therm *); |
124 | 126 | ||
127 | int nouveau_therm_sensor_init(struct nouveau_therm *therm); | ||
128 | int nouveau_therm_sensor_fini(struct nouveau_therm *therm, bool suspend); | ||
125 | void nouveau_therm_sensor_preinit(struct nouveau_therm *); | 129 | void nouveau_therm_sensor_preinit(struct nouveau_therm *); |
126 | void nouveau_therm_sensor_set_threshold_state(struct nouveau_therm *therm, | 130 | void nouveau_therm_sensor_set_threshold_state(struct nouveau_therm *therm, |
127 | enum nouveau_therm_thrs thrs, | 131 | enum nouveau_therm_thrs thrs, |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c index dde746c78c8a..b80a33011b93 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c | |||
@@ -180,6 +180,8 @@ alarm_timer_callback(struct nouveau_alarm *alarm) | |||
180 | 180 | ||
181 | spin_lock_irqsave(&priv->sensor.alarm_program_lock, flags); | 181 | spin_lock_irqsave(&priv->sensor.alarm_program_lock, flags); |
182 | 182 | ||
183 | nv_debug(therm, "polling the internal temperature\n"); | ||
184 | |||
183 | nouveau_therm_threshold_hyst_polling(therm, &sensor->thrs_fan_boost, | 185 | nouveau_therm_threshold_hyst_polling(therm, &sensor->thrs_fan_boost, |
184 | NOUVEAU_THERM_THRS_FANBOOST); | 186 | NOUVEAU_THERM_THRS_FANBOOST); |
185 | 187 | ||
@@ -216,6 +218,25 @@ nouveau_therm_program_alarms_polling(struct nouveau_therm *therm) | |||
216 | alarm_timer_callback(&priv->sensor.therm_poll_alarm); | 218 | alarm_timer_callback(&priv->sensor.therm_poll_alarm); |
217 | } | 219 | } |
218 | 220 | ||
221 | int | ||
222 | nouveau_therm_sensor_init(struct nouveau_therm *therm) | ||
223 | { | ||
224 | struct nouveau_therm_priv *priv = (void *)therm; | ||
225 | priv->sensor.program_alarms(therm); | ||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | int | ||
230 | nouveau_therm_sensor_fini(struct nouveau_therm *therm, bool suspend) | ||
231 | { | ||
232 | struct nouveau_therm_priv *priv = (void *)therm; | ||
233 | struct nouveau_timer *ptimer = nouveau_timer(therm); | ||
234 | |||
235 | if (suspend) | ||
236 | ptimer->alarm_cancel(ptimer, &priv->sensor.therm_poll_alarm); | ||
237 | return 0; | ||
238 | } | ||
239 | |||
219 | void | 240 | void |
220 | nouveau_therm_sensor_preinit(struct nouveau_therm *therm) | 241 | nouveau_therm_sensor_preinit(struct nouveau_therm *therm) |
221 | { | 242 | { |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/timer/base.c b/drivers/gpu/drm/nouveau/core/subdev/timer/base.c index 5d417cc9949b..cf8a0e0f8ee3 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/timer/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/timer/base.c | |||
@@ -85,3 +85,10 @@ nouveau_timer_alarm(void *obj, u32 nsec, struct nouveau_alarm *alarm) | |||
85 | struct nouveau_timer *ptimer = nouveau_timer(obj); | 85 | struct nouveau_timer *ptimer = nouveau_timer(obj); |
86 | ptimer->alarm(ptimer, nsec, alarm); | 86 | ptimer->alarm(ptimer, nsec, alarm); |
87 | } | 87 | } |
88 | |||
89 | void | ||
90 | nouveau_timer_alarm_cancel(void *obj, struct nouveau_alarm *alarm) | ||
91 | { | ||
92 | struct nouveau_timer *ptimer = nouveau_timer(obj); | ||
93 | ptimer->alarm_cancel(ptimer, alarm); | ||
94 | } | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/timer/nv04.c b/drivers/gpu/drm/nouveau/core/subdev/timer/nv04.c index 9469b8275675..57711ecb566c 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/timer/nv04.c +++ b/drivers/gpu/drm/nouveau/core/subdev/timer/nv04.c | |||
@@ -36,6 +36,7 @@ struct nv04_timer_priv { | |||
36 | struct nouveau_timer base; | 36 | struct nouveau_timer base; |
37 | struct list_head alarms; | 37 | struct list_head alarms; |
38 | spinlock_t lock; | 38 | spinlock_t lock; |
39 | u64 suspend_time; | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | static u64 | 42 | static u64 |
@@ -113,6 +114,25 @@ nv04_timer_alarm(struct nouveau_timer *ptimer, u64 time, | |||
113 | } | 114 | } |
114 | 115 | ||
115 | static void | 116 | static void |
117 | nv04_timer_alarm_cancel(struct nouveau_timer *ptimer, | ||
118 | struct nouveau_alarm *alarm) | ||
119 | { | ||
120 | struct nv04_timer_priv *priv = (void *)ptimer; | ||
121 | unsigned long flags; | ||
122 | |||
123 | /* avoid deleting an entry while the alarm intr is running */ | ||
124 | spin_lock_irqsave(&priv->lock, flags); | ||
125 | |||
126 | /* delete the alarm from the list */ | ||
127 | list_del(&alarm->head); | ||
128 | |||
129 | /* reset the head so as list_empty returns 1 */ | ||
130 | INIT_LIST_HEAD(&alarm->head); | ||
131 | |||
132 | spin_unlock_irqrestore(&priv->lock, flags); | ||
133 | } | ||
134 | |||
135 | static void | ||
116 | nv04_timer_intr(struct nouveau_subdev *subdev) | 136 | nv04_timer_intr(struct nouveau_subdev *subdev) |
117 | { | 137 | { |
118 | struct nv04_timer_priv *priv = (void *)subdev; | 138 | struct nv04_timer_priv *priv = (void *)subdev; |
@@ -146,6 +166,8 @@ nv04_timer_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
146 | priv->base.base.intr = nv04_timer_intr; | 166 | priv->base.base.intr = nv04_timer_intr; |
147 | priv->base.read = nv04_timer_read; | 167 | priv->base.read = nv04_timer_read; |
148 | priv->base.alarm = nv04_timer_alarm; | 168 | priv->base.alarm = nv04_timer_alarm; |
169 | priv->base.alarm_cancel = nv04_timer_alarm_cancel; | ||
170 | priv->suspend_time = 0; | ||
149 | 171 | ||
150 | INIT_LIST_HEAD(&priv->alarms); | 172 | INIT_LIST_HEAD(&priv->alarms); |
151 | spin_lock_init(&priv->lock); | 173 | spin_lock_init(&priv->lock); |
@@ -164,7 +186,7 @@ nv04_timer_init(struct nouveau_object *object) | |||
164 | { | 186 | { |
165 | struct nouveau_device *device = nv_device(object); | 187 | struct nouveau_device *device = nv_device(object); |
166 | struct nv04_timer_priv *priv = (void *)object; | 188 | struct nv04_timer_priv *priv = (void *)object; |
167 | u32 m = 1, f, n, d; | 189 | u32 m = 1, f, n, d, lo, hi; |
168 | int ret; | 190 | int ret; |
169 | 191 | ||
170 | ret = nouveau_timer_init(&priv->base); | 192 | ret = nouveau_timer_init(&priv->base); |
@@ -221,16 +243,25 @@ nv04_timer_init(struct nouveau_object *object) | |||
221 | d >>= 1; | 243 | d >>= 1; |
222 | } | 244 | } |
223 | 245 | ||
246 | /* restore the time before suspend */ | ||
247 | lo = priv->suspend_time; | ||
248 | hi = (priv->suspend_time >> 32); | ||
249 | |||
224 | nv_debug(priv, "input frequency : %dHz\n", f); | 250 | nv_debug(priv, "input frequency : %dHz\n", f); |
225 | nv_debug(priv, "input multiplier: %d\n", m); | 251 | nv_debug(priv, "input multiplier: %d\n", m); |
226 | nv_debug(priv, "numerator : 0x%08x\n", n); | 252 | nv_debug(priv, "numerator : 0x%08x\n", n); |
227 | nv_debug(priv, "denominator : 0x%08x\n", d); | 253 | nv_debug(priv, "denominator : 0x%08x\n", d); |
228 | nv_debug(priv, "timer frequency : %dHz\n", (f * m) * d / n); | 254 | nv_debug(priv, "timer frequency : %dHz\n", (f * m) * d / n); |
255 | nv_debug(priv, "time low : 0x%08x\n", lo); | ||
256 | nv_debug(priv, "time high : 0x%08x\n", hi); | ||
229 | 257 | ||
230 | nv_wr32(priv, NV04_PTIMER_NUMERATOR, n); | 258 | nv_wr32(priv, NV04_PTIMER_NUMERATOR, n); |
231 | nv_wr32(priv, NV04_PTIMER_DENOMINATOR, d); | 259 | nv_wr32(priv, NV04_PTIMER_DENOMINATOR, d); |
232 | nv_wr32(priv, NV04_PTIMER_INTR_0, 0xffffffff); | 260 | nv_wr32(priv, NV04_PTIMER_INTR_0, 0xffffffff); |
233 | nv_wr32(priv, NV04_PTIMER_INTR_EN_0, 0x00000000); | 261 | nv_wr32(priv, NV04_PTIMER_INTR_EN_0, 0x00000000); |
262 | nv_wr32(priv, NV04_PTIMER_TIME_1, hi); | ||
263 | nv_wr32(priv, NV04_PTIMER_TIME_0, lo); | ||
264 | |||
234 | return 0; | 265 | return 0; |
235 | } | 266 | } |
236 | 267 | ||
@@ -238,6 +269,8 @@ static int | |||
238 | nv04_timer_fini(struct nouveau_object *object, bool suspend) | 269 | nv04_timer_fini(struct nouveau_object *object, bool suspend) |
239 | { | 270 | { |
240 | struct nv04_timer_priv *priv = (void *)object; | 271 | struct nv04_timer_priv *priv = (void *)object; |
272 | if (suspend) | ||
273 | priv->suspend_time = nv04_timer_read(&priv->base); | ||
241 | nv_wr32(priv, NV04_PTIMER_INTR_EN_0, 0x00000000); | 274 | nv_wr32(priv, NV04_PTIMER_INTR_EN_0, 0x00000000); |
242 | return nouveau_timer_fini(&priv->base, suspend); | 275 | return nouveau_timer_fini(&priv->base, suspend); |
243 | } | 276 | } |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/vm/nv50.c index 07dd1fe2d6fb..a4aa81a2173b 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/vm/nv50.c +++ b/drivers/gpu/drm/nouveau/core/subdev/vm/nv50.c | |||
@@ -174,6 +174,7 @@ nv50_vm_flush(struct nouveau_vm *vm) | |||
174 | case NVDEV_ENGINE_GR : vme = 0x00; break; | 174 | case NVDEV_ENGINE_GR : vme = 0x00; break; |
175 | case NVDEV_ENGINE_VP : vme = 0x01; break; | 175 | case NVDEV_ENGINE_VP : vme = 0x01; break; |
176 | case NVDEV_SUBDEV_BAR : vme = 0x06; break; | 176 | case NVDEV_SUBDEV_BAR : vme = 0x06; break; |
177 | case NVDEV_ENGINE_PPP : | ||
177 | case NVDEV_ENGINE_MPEG : vme = 0x08; break; | 178 | case NVDEV_ENGINE_MPEG : vme = 0x08; break; |
178 | case NVDEV_ENGINE_BSP : vme = 0x09; break; | 179 | case NVDEV_ENGINE_BSP : vme = 0x09; break; |
179 | case NVDEV_ENGINE_CRYPT: vme = 0x0a; break; | 180 | case NVDEV_ENGINE_CRYPT: vme = 0x0a; break; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index 77ffded68837..7848590f5568 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c | |||
@@ -107,6 +107,11 @@ nouveau_framebuffer_init(struct drm_device *dev, | |||
107 | return -EINVAL; | 107 | return -EINVAL; |
108 | } | 108 | } |
109 | 109 | ||
110 | if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) { | ||
111 | NV_ERROR(drm, "framebuffer requires contiguous bo\n"); | ||
112 | return -EINVAL; | ||
113 | } | ||
114 | |||
110 | if (nv_device(drm->device)->chipset == 0x50) | 115 | if (nv_device(drm->device)->chipset == 0x50) |
111 | nv_fb->r_format |= (tile_flags << 8); | 116 | nv_fb->r_format |= (tile_flags << 8); |
112 | 117 | ||
@@ -273,7 +278,6 @@ nouveau_display_create(struct drm_device *dev) | |||
273 | { | 278 | { |
274 | struct nouveau_drm *drm = nouveau_drm(dev); | 279 | struct nouveau_drm *drm = nouveau_drm(dev); |
275 | struct nouveau_display *disp; | 280 | struct nouveau_display *disp; |
276 | u32 pclass = dev->pdev->class >> 8; | ||
277 | int ret, gen; | 281 | int ret, gen; |
278 | 282 | ||
279 | disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL); | 283 | disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL); |
@@ -335,29 +339,25 @@ nouveau_display_create(struct drm_device *dev) | |||
335 | drm_kms_helper_poll_init(dev); | 339 | drm_kms_helper_poll_init(dev); |
336 | drm_kms_helper_poll_disable(dev); | 340 | drm_kms_helper_poll_disable(dev); |
337 | 341 | ||
338 | if (nouveau_modeset == 1 || | 342 | if (drm->vbios.dcb.entries) { |
339 | (nouveau_modeset < 0 && pclass == PCI_CLASS_DISPLAY_VGA)) { | 343 | if (nv_device(drm->device)->card_type < NV_50) |
340 | if (drm->vbios.dcb.entries) { | 344 | ret = nv04_display_create(dev); |
341 | if (nv_device(drm->device)->card_type < NV_50) | 345 | else |
342 | ret = nv04_display_create(dev); | 346 | ret = nv50_display_create(dev); |
343 | else | 347 | } else { |
344 | ret = nv50_display_create(dev); | 348 | ret = 0; |
345 | } else { | 349 | } |
346 | ret = 0; | ||
347 | } | ||
348 | |||
349 | if (ret) | ||
350 | goto disp_create_err; | ||
351 | 350 | ||
352 | if (dev->mode_config.num_crtc) { | 351 | if (ret) |
353 | ret = drm_vblank_init(dev, dev->mode_config.num_crtc); | 352 | goto disp_create_err; |
354 | if (ret) | ||
355 | goto vblank_err; | ||
356 | } | ||
357 | 353 | ||
358 | nouveau_backlight_init(dev); | 354 | if (dev->mode_config.num_crtc) { |
355 | ret = drm_vblank_init(dev, dev->mode_config.num_crtc); | ||
356 | if (ret) | ||
357 | goto vblank_err; | ||
359 | } | 358 | } |
360 | 359 | ||
360 | nouveau_backlight_init(dev); | ||
361 | return 0; | 361 | return 0; |
362 | 362 | ||
363 | vblank_err: | 363 | vblank_err: |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 8863644024b7..e893c5362402 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c | |||
@@ -636,7 +636,8 @@ int nouveau_pmops_resume(struct device *dev) | |||
636 | nouveau_fbcon_set_suspend(drm_dev, 0); | 636 | nouveau_fbcon_set_suspend(drm_dev, 0); |
637 | 637 | ||
638 | nouveau_fbcon_zfill_all(drm_dev); | 638 | nouveau_fbcon_zfill_all(drm_dev); |
639 | nouveau_display_resume(drm_dev); | 639 | if (drm_dev->mode_config.num_crtc) |
640 | nouveau_display_resume(drm_dev); | ||
640 | nv_suspend_set_printk_level(NV_DBG_DEBUG); | 641 | nv_suspend_set_printk_level(NV_DBG_DEBUG); |
641 | return 0; | 642 | return 0; |
642 | } | 643 | } |
@@ -671,7 +672,8 @@ static int nouveau_pmops_thaw(struct device *dev) | |||
671 | if (drm_dev->mode_config.num_crtc) | 672 | if (drm_dev->mode_config.num_crtc) |
672 | nouveau_fbcon_set_suspend(drm_dev, 0); | 673 | nouveau_fbcon_set_suspend(drm_dev, 0); |
673 | nouveau_fbcon_zfill_all(drm_dev); | 674 | nouveau_fbcon_zfill_all(drm_dev); |
674 | nouveau_display_resume(drm_dev); | 675 | if (drm_dev->mode_config.num_crtc) |
676 | nouveau_display_resume(drm_dev); | ||
675 | nv_suspend_set_printk_level(NV_DBG_DEBUG); | 677 | nv_suspend_set_printk_level(NV_DBG_DEBUG); |
676 | return 0; | 678 | return 0; |
677 | } | 679 | } |
@@ -906,7 +908,8 @@ static int nouveau_pmops_runtime_resume(struct device *dev) | |||
906 | pci_set_master(pdev); | 908 | pci_set_master(pdev); |
907 | 909 | ||
908 | ret = nouveau_do_resume(drm_dev); | 910 | ret = nouveau_do_resume(drm_dev); |
909 | nouveau_display_resume(drm_dev); | 911 | if (drm_dev->mode_config.num_crtc) |
912 | nouveau_display_resume(drm_dev); | ||
910 | drm_kms_helper_poll_enable(drm_dev); | 913 | drm_kms_helper_poll_enable(drm_dev); |
911 | /* do magic */ | 914 | /* do magic */ |
912 | nv_mask(device, 0x88488, (1 << 25), (1 << 25)); | 915 | nv_mask(device, 0x88488, (1 << 25), (1 << 25)); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 8f6d63d7edd3..a86ecf65c164 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
@@ -454,7 +454,8 @@ nouveau_fbcon_init(struct drm_device *dev) | |||
454 | int preferred_bpp; | 454 | int preferred_bpp; |
455 | int ret; | 455 | int ret; |
456 | 456 | ||
457 | if (!dev->mode_config.num_crtc) | 457 | if (!dev->mode_config.num_crtc || |
458 | (dev->pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) | ||
458 | return 0; | 459 | return 0; |
459 | 460 | ||
460 | fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL); | 461 | fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 487242fb3fdc..f32b71238c03 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c | |||
@@ -579,18 +579,31 @@ nouveau_gem_pushbuf_validate(struct nouveau_channel *chan, | |||
579 | return 0; | 579 | return 0; |
580 | } | 580 | } |
581 | 581 | ||
582 | static inline void | ||
583 | u_free(void *addr) | ||
584 | { | ||
585 | if (!is_vmalloc_addr(addr)) | ||
586 | kfree(addr); | ||
587 | else | ||
588 | vfree(addr); | ||
589 | } | ||
590 | |||
582 | static inline void * | 591 | static inline void * |
583 | u_memcpya(uint64_t user, unsigned nmemb, unsigned size) | 592 | u_memcpya(uint64_t user, unsigned nmemb, unsigned size) |
584 | { | 593 | { |
585 | void *mem; | 594 | void *mem; |
586 | void __user *userptr = (void __force __user *)(uintptr_t)user; | 595 | void __user *userptr = (void __force __user *)(uintptr_t)user; |
587 | 596 | ||
588 | mem = kmalloc(nmemb * size, GFP_KERNEL); | 597 | size *= nmemb; |
598 | |||
599 | mem = kmalloc(size, GFP_KERNEL | __GFP_NOWARN); | ||
600 | if (!mem) | ||
601 | mem = vmalloc(size); | ||
589 | if (!mem) | 602 | if (!mem) |
590 | return ERR_PTR(-ENOMEM); | 603 | return ERR_PTR(-ENOMEM); |
591 | 604 | ||
592 | if (DRM_COPY_FROM_USER(mem, userptr, nmemb * size)) { | 605 | if (DRM_COPY_FROM_USER(mem, userptr, size)) { |
593 | kfree(mem); | 606 | u_free(mem); |
594 | return ERR_PTR(-EFAULT); | 607 | return ERR_PTR(-EFAULT); |
595 | } | 608 | } |
596 | 609 | ||
@@ -676,7 +689,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli, | |||
676 | nouveau_bo_wr32(nvbo, r->reloc_bo_offset >> 2, data); | 689 | nouveau_bo_wr32(nvbo, r->reloc_bo_offset >> 2, data); |
677 | } | 690 | } |
678 | 691 | ||
679 | kfree(reloc); | 692 | u_free(reloc); |
680 | return ret; | 693 | return ret; |
681 | } | 694 | } |
682 | 695 | ||
@@ -738,7 +751,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, | |||
738 | 751 | ||
739 | bo = u_memcpya(req->buffers, req->nr_buffers, sizeof(*bo)); | 752 | bo = u_memcpya(req->buffers, req->nr_buffers, sizeof(*bo)); |
740 | if (IS_ERR(bo)) { | 753 | if (IS_ERR(bo)) { |
741 | kfree(push); | 754 | u_free(push); |
742 | return nouveau_abi16_put(abi16, PTR_ERR(bo)); | 755 | return nouveau_abi16_put(abi16, PTR_ERR(bo)); |
743 | } | 756 | } |
744 | 757 | ||
@@ -849,8 +862,8 @@ out: | |||
849 | nouveau_fence_unref(&fence); | 862 | nouveau_fence_unref(&fence); |
850 | 863 | ||
851 | out_prevalid: | 864 | out_prevalid: |
852 | kfree(bo); | 865 | u_free(bo); |
853 | kfree(push); | 866 | u_free(push); |
854 | 867 | ||
855 | out_next: | 868 | out_next: |
856 | if (chan->dma.ib_max) { | 869 | if (chan->dma.ib_max) { |
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index ca5492ac2da5..0843ebc910d4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c | |||
@@ -104,9 +104,7 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, | |||
104 | else | 104 | else |
105 | nvbe->ttm.ttm.func = &nv50_sgdma_backend; | 105 | nvbe->ttm.ttm.func = &nv50_sgdma_backend; |
106 | 106 | ||
107 | if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) { | 107 | if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) |
108 | kfree(nvbe); | ||
109 | return NULL; | 108 | return NULL; |
110 | } | ||
111 | return &nvbe->ttm.ttm; | 109 | return &nvbe->ttm.ttm; |
112 | } | 110 | } |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 9d2092a5ed38..f8e66c08b11a 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
@@ -1583,7 +1583,7 @@ nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector) | |||
1583 | load = 340; | 1583 | load = 340; |
1584 | 1584 | ||
1585 | ret = nv_exec(disp->core, NV50_DISP_DAC_LOAD + or, &load, sizeof(load)); | 1585 | ret = nv_exec(disp->core, NV50_DISP_DAC_LOAD + or, &load, sizeof(load)); |
1586 | if (ret || load != 7) | 1586 | if (ret || !load) |
1587 | return connector_status_disconnected; | 1587 | return connector_status_disconnected; |
1588 | 1588 | ||
1589 | return connector_status_connected; | 1589 | return connector_status_connected; |
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c index dfac7965ea28..32923d2f6002 100644 --- a/drivers/gpu/drm/radeon/atombios_encoders.c +++ b/drivers/gpu/drm/radeon/atombios_encoders.c | |||
@@ -707,8 +707,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder) | |||
707 | switch (connector->connector_type) { | 707 | switch (connector->connector_type) { |
708 | case DRM_MODE_CONNECTOR_DVII: | 708 | case DRM_MODE_CONNECTOR_DVII: |
709 | case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */ | 709 | case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */ |
710 | if (drm_detect_hdmi_monitor(radeon_connector->edid) && | 710 | if ((radeon_connector->audio == RADEON_AUDIO_ENABLE) || |
711 | radeon_audio) | 711 | (drm_detect_hdmi_monitor(radeon_connector->edid) && |
712 | (radeon_connector->audio == RADEON_AUDIO_AUTO))) | ||
712 | return ATOM_ENCODER_MODE_HDMI; | 713 | return ATOM_ENCODER_MODE_HDMI; |
713 | else if (radeon_connector->use_digital) | 714 | else if (radeon_connector->use_digital) |
714 | return ATOM_ENCODER_MODE_DVI; | 715 | return ATOM_ENCODER_MODE_DVI; |
@@ -718,8 +719,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder) | |||
718 | case DRM_MODE_CONNECTOR_DVID: | 719 | case DRM_MODE_CONNECTOR_DVID: |
719 | case DRM_MODE_CONNECTOR_HDMIA: | 720 | case DRM_MODE_CONNECTOR_HDMIA: |
720 | default: | 721 | default: |
721 | if (drm_detect_hdmi_monitor(radeon_connector->edid) && | 722 | if ((radeon_connector->audio == RADEON_AUDIO_ENABLE) || |
722 | radeon_audio) | 723 | (drm_detect_hdmi_monitor(radeon_connector->edid) && |
724 | (radeon_connector->audio == RADEON_AUDIO_AUTO))) | ||
723 | return ATOM_ENCODER_MODE_HDMI; | 725 | return ATOM_ENCODER_MODE_HDMI; |
724 | else | 726 | else |
725 | return ATOM_ENCODER_MODE_DVI; | 727 | return ATOM_ENCODER_MODE_DVI; |
@@ -732,8 +734,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder) | |||
732 | if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || | 734 | if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
733 | (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) | 735 | (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
734 | return ATOM_ENCODER_MODE_DP; | 736 | return ATOM_ENCODER_MODE_DP; |
735 | else if (drm_detect_hdmi_monitor(radeon_connector->edid) && | 737 | else if ((radeon_connector->audio == RADEON_AUDIO_ENABLE) || |
736 | radeon_audio) | 738 | (drm_detect_hdmi_monitor(radeon_connector->edid) && |
739 | (radeon_connector->audio == RADEON_AUDIO_AUTO))) | ||
737 | return ATOM_ENCODER_MODE_HDMI; | 740 | return ATOM_ENCODER_MODE_HDMI; |
738 | else | 741 | else |
739 | return ATOM_ENCODER_MODE_DVI; | 742 | return ATOM_ENCODER_MODE_DVI; |
@@ -1647,8 +1650,12 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode) | |||
1647 | atombios_dig_encoder_setup(encoder, ATOM_ENABLE, 0); | 1650 | atombios_dig_encoder_setup(encoder, ATOM_ENABLE, 0); |
1648 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); | 1651 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); |
1649 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); | 1652 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); |
1650 | /* some early dce3.2 boards have a bug in their transmitter control table */ | 1653 | /* some dce3.x boards have a bug in their transmitter control table. |
1651 | if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730)) | 1654 | * ACTION_ENABLE_OUTPUT can probably be dropped since ACTION_ENABLE |
1655 | * does the same thing and more. | ||
1656 | */ | ||
1657 | if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730) && | ||
1658 | (rdev->family != CHIP_RS880)) | ||
1652 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); | 1659 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); |
1653 | } | 1660 | } |
1654 | if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { | 1661 | if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { |
diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c index 084e69414fd1..05ff315e8e9e 100644 --- a/drivers/gpu/drm/radeon/btc_dpm.c +++ b/drivers/gpu/drm/radeon/btc_dpm.c | |||
@@ -2340,12 +2340,6 @@ int btc_dpm_set_power_state(struct radeon_device *rdev) | |||
2340 | return ret; | 2340 | return ret; |
2341 | } | 2341 | } |
2342 | 2342 | ||
2343 | ret = rv770_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
2344 | if (ret) { | ||
2345 | DRM_ERROR("rv770_dpm_force_performance_level failed\n"); | ||
2346 | return ret; | ||
2347 | } | ||
2348 | |||
2349 | return 0; | 2343 | return 0; |
2350 | } | 2344 | } |
2351 | 2345 | ||
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c index 916630fdc796..899627443030 100644 --- a/drivers/gpu/drm/radeon/ci_dpm.c +++ b/drivers/gpu/drm/radeon/ci_dpm.c | |||
@@ -4208,6 +4208,7 @@ static void ci_request_link_speed_change_before_state_change(struct radeon_devic | |||
4208 | pi->pspp_notify_required = false; | 4208 | pi->pspp_notify_required = false; |
4209 | if (target_link_speed > current_link_speed) { | 4209 | if (target_link_speed > current_link_speed) { |
4210 | switch (target_link_speed) { | 4210 | switch (target_link_speed) { |
4211 | #ifdef CONFIG_ACPI | ||
4211 | case RADEON_PCIE_GEN3: | 4212 | case RADEON_PCIE_GEN3: |
4212 | if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN3, false) == 0) | 4213 | if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN3, false) == 0) |
4213 | break; | 4214 | break; |
@@ -4217,6 +4218,7 @@ static void ci_request_link_speed_change_before_state_change(struct radeon_devic | |||
4217 | case RADEON_PCIE_GEN2: | 4218 | case RADEON_PCIE_GEN2: |
4218 | if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) | 4219 | if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) |
4219 | break; | 4220 | break; |
4221 | #endif | ||
4220 | default: | 4222 | default: |
4221 | pi->force_pcie_gen = ci_get_current_pcie_speed(rdev); | 4223 | pi->force_pcie_gen = ci_get_current_pcie_speed(rdev); |
4222 | break; | 4224 | break; |
@@ -4248,7 +4250,9 @@ static void ci_notify_link_speed_change_after_state_change(struct radeon_device | |||
4248 | (ci_get_current_pcie_speed(rdev) > 0)) | 4250 | (ci_get_current_pcie_speed(rdev) > 0)) |
4249 | return; | 4251 | return; |
4250 | 4252 | ||
4253 | #ifdef CONFIG_ACPI | ||
4251 | radeon_acpi_pcie_performance_request(rdev, request, false); | 4254 | radeon_acpi_pcie_performance_request(rdev, request, false); |
4255 | #endif | ||
4252 | } | 4256 | } |
4253 | } | 4257 | } |
4254 | 4258 | ||
@@ -4744,12 +4748,6 @@ int ci_dpm_set_power_state(struct radeon_device *rdev) | |||
4744 | if (pi->pcie_performance_request) | 4748 | if (pi->pcie_performance_request) |
4745 | ci_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); | 4749 | ci_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); |
4746 | 4750 | ||
4747 | ret = ci_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
4748 | if (ret) { | ||
4749 | DRM_ERROR("ci_dpm_force_performance_level failed\n"); | ||
4750 | return ret; | ||
4751 | } | ||
4752 | |||
4753 | cik_update_cg(rdev, (RADEON_CG_BLOCK_GFX | | 4751 | cik_update_cg(rdev, (RADEON_CG_BLOCK_GFX | |
4754 | RADEON_CG_BLOCK_MC | | 4752 | RADEON_CG_BLOCK_MC | |
4755 | RADEON_CG_BLOCK_SDMA | | 4753 | RADEON_CG_BLOCK_SDMA | |
diff --git a/drivers/gpu/drm/radeon/ci_smc.c b/drivers/gpu/drm/radeon/ci_smc.c index 53b43dd3cf1e..252e10a41cf5 100644 --- a/drivers/gpu/drm/radeon/ci_smc.c +++ b/drivers/gpu/drm/radeon/ci_smc.c | |||
@@ -47,10 +47,11 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev, | |||
47 | u32 smc_start_address, | 47 | u32 smc_start_address, |
48 | const u8 *src, u32 byte_count, u32 limit) | 48 | const u8 *src, u32 byte_count, u32 limit) |
49 | { | 49 | { |
50 | unsigned long flags; | ||
50 | u32 data, original_data; | 51 | u32 data, original_data; |
51 | u32 addr; | 52 | u32 addr; |
52 | u32 extra_shift; | 53 | u32 extra_shift; |
53 | int ret; | 54 | int ret = 0; |
54 | 55 | ||
55 | if (smc_start_address & 3) | 56 | if (smc_start_address & 3) |
56 | return -EINVAL; | 57 | return -EINVAL; |
@@ -59,13 +60,14 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev, | |||
59 | 60 | ||
60 | addr = smc_start_address; | 61 | addr = smc_start_address; |
61 | 62 | ||
63 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
62 | while (byte_count >= 4) { | 64 | while (byte_count >= 4) { |
63 | /* SMC address space is BE */ | 65 | /* SMC address space is BE */ |
64 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; | 66 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; |
65 | 67 | ||
66 | ret = ci_set_smc_sram_address(rdev, addr, limit); | 68 | ret = ci_set_smc_sram_address(rdev, addr, limit); |
67 | if (ret) | 69 | if (ret) |
68 | return ret; | 70 | goto done; |
69 | 71 | ||
70 | WREG32(SMC_IND_DATA_0, data); | 72 | WREG32(SMC_IND_DATA_0, data); |
71 | 73 | ||
@@ -80,7 +82,7 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev, | |||
80 | 82 | ||
81 | ret = ci_set_smc_sram_address(rdev, addr, limit); | 83 | ret = ci_set_smc_sram_address(rdev, addr, limit); |
82 | if (ret) | 84 | if (ret) |
83 | return ret; | 85 | goto done; |
84 | 86 | ||
85 | original_data = RREG32(SMC_IND_DATA_0); | 87 | original_data = RREG32(SMC_IND_DATA_0); |
86 | 88 | ||
@@ -97,11 +99,15 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev, | |||
97 | 99 | ||
98 | ret = ci_set_smc_sram_address(rdev, addr, limit); | 100 | ret = ci_set_smc_sram_address(rdev, addr, limit); |
99 | if (ret) | 101 | if (ret) |
100 | return ret; | 102 | goto done; |
101 | 103 | ||
102 | WREG32(SMC_IND_DATA_0, data); | 104 | WREG32(SMC_IND_DATA_0, data); |
103 | } | 105 | } |
104 | return 0; | 106 | |
107 | done: | ||
108 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
109 | |||
110 | return ret; | ||
105 | } | 111 | } |
106 | 112 | ||
107 | void ci_start_smc(struct radeon_device *rdev) | 113 | void ci_start_smc(struct radeon_device *rdev) |
@@ -197,6 +203,7 @@ PPSMC_Result ci_wait_for_smc_inactive(struct radeon_device *rdev) | |||
197 | 203 | ||
198 | int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit) | 204 | int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit) |
199 | { | 205 | { |
206 | unsigned long flags; | ||
200 | u32 ucode_start_address; | 207 | u32 ucode_start_address; |
201 | u32 ucode_size; | 208 | u32 ucode_size; |
202 | const u8 *src; | 209 | const u8 *src; |
@@ -219,6 +226,7 @@ int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit) | |||
219 | return -EINVAL; | 226 | return -EINVAL; |
220 | 227 | ||
221 | src = (const u8 *)rdev->smc_fw->data; | 228 | src = (const u8 *)rdev->smc_fw->data; |
229 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
222 | WREG32(SMC_IND_INDEX_0, ucode_start_address); | 230 | WREG32(SMC_IND_INDEX_0, ucode_start_address); |
223 | WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); | 231 | WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); |
224 | while (ucode_size >= 4) { | 232 | while (ucode_size >= 4) { |
@@ -231,6 +239,7 @@ int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit) | |||
231 | ucode_size -= 4; | 239 | ucode_size -= 4; |
232 | } | 240 | } |
233 | WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); | 241 | WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); |
242 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
234 | 243 | ||
235 | return 0; | 244 | return 0; |
236 | } | 245 | } |
@@ -238,25 +247,29 @@ int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit) | |||
238 | int ci_read_smc_sram_dword(struct radeon_device *rdev, | 247 | int ci_read_smc_sram_dword(struct radeon_device *rdev, |
239 | u32 smc_address, u32 *value, u32 limit) | 248 | u32 smc_address, u32 *value, u32 limit) |
240 | { | 249 | { |
250 | unsigned long flags; | ||
241 | int ret; | 251 | int ret; |
242 | 252 | ||
253 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
243 | ret = ci_set_smc_sram_address(rdev, smc_address, limit); | 254 | ret = ci_set_smc_sram_address(rdev, smc_address, limit); |
244 | if (ret) | 255 | if (ret == 0) |
245 | return ret; | 256 | *value = RREG32(SMC_IND_DATA_0); |
257 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
246 | 258 | ||
247 | *value = RREG32(SMC_IND_DATA_0); | 259 | return ret; |
248 | return 0; | ||
249 | } | 260 | } |
250 | 261 | ||
251 | int ci_write_smc_sram_dword(struct radeon_device *rdev, | 262 | int ci_write_smc_sram_dword(struct radeon_device *rdev, |
252 | u32 smc_address, u32 value, u32 limit) | 263 | u32 smc_address, u32 value, u32 limit) |
253 | { | 264 | { |
265 | unsigned long flags; | ||
254 | int ret; | 266 | int ret; |
255 | 267 | ||
268 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
256 | ret = ci_set_smc_sram_address(rdev, smc_address, limit); | 269 | ret = ci_set_smc_sram_address(rdev, smc_address, limit); |
257 | if (ret) | 270 | if (ret == 0) |
258 | return ret; | 271 | WREG32(SMC_IND_DATA_0, value); |
272 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
259 | 273 | ||
260 | WREG32(SMC_IND_DATA_0, value); | 274 | return ret; |
261 | return 0; | ||
262 | } | 275 | } |
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index a3bba0587276..adbdb6503b05 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c | |||
@@ -77,6 +77,8 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev); | |||
77 | static void cik_program_aspm(struct radeon_device *rdev); | 77 | static void cik_program_aspm(struct radeon_device *rdev); |
78 | static void cik_init_pg(struct radeon_device *rdev); | 78 | static void cik_init_pg(struct radeon_device *rdev); |
79 | static void cik_init_cg(struct radeon_device *rdev); | 79 | static void cik_init_cg(struct radeon_device *rdev); |
80 | static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev, | ||
81 | bool enable); | ||
80 | 82 | ||
81 | /* get temperature in millidegrees */ | 83 | /* get temperature in millidegrees */ |
82 | int ci_get_temp(struct radeon_device *rdev) | 84 | int ci_get_temp(struct radeon_device *rdev) |
@@ -120,20 +122,27 @@ int kv_get_temp(struct radeon_device *rdev) | |||
120 | */ | 122 | */ |
121 | u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg) | 123 | u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg) |
122 | { | 124 | { |
125 | unsigned long flags; | ||
123 | u32 r; | 126 | u32 r; |
124 | 127 | ||
128 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); | ||
125 | WREG32(PCIE_INDEX, reg); | 129 | WREG32(PCIE_INDEX, reg); |
126 | (void)RREG32(PCIE_INDEX); | 130 | (void)RREG32(PCIE_INDEX); |
127 | r = RREG32(PCIE_DATA); | 131 | r = RREG32(PCIE_DATA); |
132 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); | ||
128 | return r; | 133 | return r; |
129 | } | 134 | } |
130 | 135 | ||
131 | void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 136 | void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
132 | { | 137 | { |
138 | unsigned long flags; | ||
139 | |||
140 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); | ||
133 | WREG32(PCIE_INDEX, reg); | 141 | WREG32(PCIE_INDEX, reg); |
134 | (void)RREG32(PCIE_INDEX); | 142 | (void)RREG32(PCIE_INDEX); |
135 | WREG32(PCIE_DATA, v); | 143 | WREG32(PCIE_DATA, v); |
136 | (void)RREG32(PCIE_DATA); | 144 | (void)RREG32(PCIE_DATA); |
145 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); | ||
137 | } | 146 | } |
138 | 147 | ||
139 | static const u32 spectre_rlc_save_restore_register_list[] = | 148 | static const u32 spectre_rlc_save_restore_register_list[] = |
@@ -2722,7 +2731,8 @@ static void cik_gpu_init(struct radeon_device *rdev) | |||
2722 | } else if ((rdev->pdev->device == 0x1309) || | 2731 | } else if ((rdev->pdev->device == 0x1309) || |
2723 | (rdev->pdev->device == 0x130A) || | 2732 | (rdev->pdev->device == 0x130A) || |
2724 | (rdev->pdev->device == 0x130D) || | 2733 | (rdev->pdev->device == 0x130D) || |
2725 | (rdev->pdev->device == 0x1313)) { | 2734 | (rdev->pdev->device == 0x1313) || |
2735 | (rdev->pdev->device == 0x131D)) { | ||
2726 | rdev->config.cik.max_cu_per_sh = 6; | 2736 | rdev->config.cik.max_cu_per_sh = 6; |
2727 | rdev->config.cik.max_backends_per_se = 2; | 2737 | rdev->config.cik.max_backends_per_se = 2; |
2728 | } else if ((rdev->pdev->device == 0x1306) || | 2738 | } else if ((rdev->pdev->device == 0x1306) || |
@@ -4013,6 +4023,8 @@ static int cik_cp_resume(struct radeon_device *rdev) | |||
4013 | { | 4023 | { |
4014 | int r; | 4024 | int r; |
4015 | 4025 | ||
4026 | cik_enable_gui_idle_interrupt(rdev, false); | ||
4027 | |||
4016 | r = cik_cp_load_microcode(rdev); | 4028 | r = cik_cp_load_microcode(rdev); |
4017 | if (r) | 4029 | if (r) |
4018 | return r; | 4030 | return r; |
@@ -4024,6 +4036,8 @@ static int cik_cp_resume(struct radeon_device *rdev) | |||
4024 | if (r) | 4036 | if (r) |
4025 | return r; | 4037 | return r; |
4026 | 4038 | ||
4039 | cik_enable_gui_idle_interrupt(rdev, true); | ||
4040 | |||
4027 | return 0; | 4041 | return 0; |
4028 | } | 4042 | } |
4029 | 4043 | ||
@@ -5376,7 +5390,9 @@ static void cik_enable_hdp_ls(struct radeon_device *rdev, | |||
5376 | void cik_update_cg(struct radeon_device *rdev, | 5390 | void cik_update_cg(struct radeon_device *rdev, |
5377 | u32 block, bool enable) | 5391 | u32 block, bool enable) |
5378 | { | 5392 | { |
5393 | |||
5379 | if (block & RADEON_CG_BLOCK_GFX) { | 5394 | if (block & RADEON_CG_BLOCK_GFX) { |
5395 | cik_enable_gui_idle_interrupt(rdev, false); | ||
5380 | /* order matters! */ | 5396 | /* order matters! */ |
5381 | if (enable) { | 5397 | if (enable) { |
5382 | cik_enable_mgcg(rdev, true); | 5398 | cik_enable_mgcg(rdev, true); |
@@ -5385,6 +5401,7 @@ void cik_update_cg(struct radeon_device *rdev, | |||
5385 | cik_enable_cgcg(rdev, false); | 5401 | cik_enable_cgcg(rdev, false); |
5386 | cik_enable_mgcg(rdev, false); | 5402 | cik_enable_mgcg(rdev, false); |
5387 | } | 5403 | } |
5404 | cik_enable_gui_idle_interrupt(rdev, true); | ||
5388 | } | 5405 | } |
5389 | 5406 | ||
5390 | if (block & RADEON_CG_BLOCK_MC) { | 5407 | if (block & RADEON_CG_BLOCK_MC) { |
@@ -5541,7 +5558,7 @@ static void cik_enable_gfx_cgpg(struct radeon_device *rdev, | |||
5541 | { | 5558 | { |
5542 | u32 data, orig; | 5559 | u32 data, orig; |
5543 | 5560 | ||
5544 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG)) { | 5561 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG)) { |
5545 | orig = data = RREG32(RLC_PG_CNTL); | 5562 | orig = data = RREG32(RLC_PG_CNTL); |
5546 | data |= GFX_PG_ENABLE; | 5563 | data |= GFX_PG_ENABLE; |
5547 | if (orig != data) | 5564 | if (orig != data) |
@@ -5805,7 +5822,7 @@ static void cik_init_pg(struct radeon_device *rdev) | |||
5805 | if (rdev->pg_flags) { | 5822 | if (rdev->pg_flags) { |
5806 | cik_enable_sck_slowdown_on_pu(rdev, true); | 5823 | cik_enable_sck_slowdown_on_pu(rdev, true); |
5807 | cik_enable_sck_slowdown_on_pd(rdev, true); | 5824 | cik_enable_sck_slowdown_on_pd(rdev, true); |
5808 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG) { | 5825 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
5809 | cik_init_gfx_cgpg(rdev); | 5826 | cik_init_gfx_cgpg(rdev); |
5810 | cik_enable_cp_pg(rdev, true); | 5827 | cik_enable_cp_pg(rdev, true); |
5811 | cik_enable_gds_pg(rdev, true); | 5828 | cik_enable_gds_pg(rdev, true); |
@@ -5819,7 +5836,7 @@ static void cik_fini_pg(struct radeon_device *rdev) | |||
5819 | { | 5836 | { |
5820 | if (rdev->pg_flags) { | 5837 | if (rdev->pg_flags) { |
5821 | cik_update_gfx_pg(rdev, false); | 5838 | cik_update_gfx_pg(rdev, false); |
5822 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG) { | 5839 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
5823 | cik_enable_cp_pg(rdev, false); | 5840 | cik_enable_cp_pg(rdev, false); |
5824 | cik_enable_gds_pg(rdev, false); | 5841 | cik_enable_gds_pg(rdev, false); |
5825 | } | 5842 | } |
@@ -5895,7 +5912,9 @@ static void cik_disable_interrupt_state(struct radeon_device *rdev) | |||
5895 | u32 tmp; | 5912 | u32 tmp; |
5896 | 5913 | ||
5897 | /* gfx ring */ | 5914 | /* gfx ring */ |
5898 | WREG32(CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | 5915 | tmp = RREG32(CP_INT_CNTL_RING0) & |
5916 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | ||
5917 | WREG32(CP_INT_CNTL_RING0, tmp); | ||
5899 | /* sdma */ | 5918 | /* sdma */ |
5900 | tmp = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; | 5919 | tmp = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; |
5901 | WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, tmp); | 5920 | WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, tmp); |
@@ -6036,8 +6055,7 @@ static int cik_irq_init(struct radeon_device *rdev) | |||
6036 | */ | 6055 | */ |
6037 | int cik_irq_set(struct radeon_device *rdev) | 6056 | int cik_irq_set(struct radeon_device *rdev) |
6038 | { | 6057 | { |
6039 | u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE | | 6058 | u32 cp_int_cntl; |
6040 | PRIV_INSTR_INT_ENABLE | PRIV_REG_INT_ENABLE; | ||
6041 | u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3; | 6059 | u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3; |
6042 | u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3; | 6060 | u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3; |
6043 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; | 6061 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; |
@@ -6058,6 +6076,10 @@ int cik_irq_set(struct radeon_device *rdev) | |||
6058 | return 0; | 6076 | return 0; |
6059 | } | 6077 | } |
6060 | 6078 | ||
6079 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0) & | ||
6080 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | ||
6081 | cp_int_cntl |= PRIV_INSTR_INT_ENABLE | PRIV_REG_INT_ENABLE; | ||
6082 | |||
6061 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; | 6083 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
6062 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; | 6084 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
6063 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; | 6085 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; |
diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c index 95a66db08d9b..91bb470de0a3 100644 --- a/drivers/gpu/drm/radeon/cypress_dpm.c +++ b/drivers/gpu/drm/radeon/cypress_dpm.c | |||
@@ -2014,12 +2014,6 @@ int cypress_dpm_set_power_state(struct radeon_device *rdev) | |||
2014 | if (eg_pi->pcie_performance_request) | 2014 | if (eg_pi->pcie_performance_request) |
2015 | cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); | 2015 | cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); |
2016 | 2016 | ||
2017 | ret = rv770_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
2018 | if (ret) { | ||
2019 | DRM_ERROR("rv770_dpm_force_performance_level failed\n"); | ||
2020 | return ret; | ||
2021 | } | ||
2022 | |||
2023 | return 0; | 2017 | return 0; |
2024 | } | 2018 | } |
2025 | 2019 | ||
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c index 8953255e894b..85a69d2ea3d2 100644 --- a/drivers/gpu/drm/radeon/dce6_afmt.c +++ b/drivers/gpu/drm/radeon/dce6_afmt.c | |||
@@ -28,22 +28,30 @@ | |||
28 | static u32 dce6_endpoint_rreg(struct radeon_device *rdev, | 28 | static u32 dce6_endpoint_rreg(struct radeon_device *rdev, |
29 | u32 block_offset, u32 reg) | 29 | u32 block_offset, u32 reg) |
30 | { | 30 | { |
31 | unsigned long flags; | ||
31 | u32 r; | 32 | u32 r; |
32 | 33 | ||
34 | spin_lock_irqsave(&rdev->end_idx_lock, flags); | ||
33 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); | 35 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
34 | r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset); | 36 | r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset); |
37 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); | ||
38 | |||
35 | return r; | 39 | return r; |
36 | } | 40 | } |
37 | 41 | ||
38 | static void dce6_endpoint_wreg(struct radeon_device *rdev, | 42 | static void dce6_endpoint_wreg(struct radeon_device *rdev, |
39 | u32 block_offset, u32 reg, u32 v) | 43 | u32 block_offset, u32 reg, u32 v) |
40 | { | 44 | { |
45 | unsigned long flags; | ||
46 | |||
47 | spin_lock_irqsave(&rdev->end_idx_lock, flags); | ||
41 | if (ASIC_IS_DCE8(rdev)) | 48 | if (ASIC_IS_DCE8(rdev)) |
42 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); | 49 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
43 | else | 50 | else |
44 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, | 51 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, |
45 | AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg)); | 52 | AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg)); |
46 | WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v); | 53 | WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v); |
54 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); | ||
47 | } | 55 | } |
48 | 56 | ||
49 | #define RREG32_ENDPOINT(block, reg) dce6_endpoint_rreg(rdev, (block), (reg)) | 57 | #define RREG32_ENDPOINT(block, reg) dce6_endpoint_rreg(rdev, (block), (reg)) |
@@ -86,12 +94,12 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder) | |||
86 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 94 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
87 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | 95 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
88 | u32 offset = dig->afmt->offset; | 96 | u32 offset = dig->afmt->offset; |
89 | u32 id = dig->afmt->pin->id; | ||
90 | 97 | ||
91 | if (!dig->afmt->pin) | 98 | if (!dig->afmt->pin) |
92 | return; | 99 | return; |
93 | 100 | ||
94 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, AFMT_AUDIO_SRC_SELECT(id)); | 101 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, |
102 | AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); | ||
95 | } | 103 | } |
96 | 104 | ||
97 | void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) | 105 | void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) |
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c index ecd60809db4e..71399065db04 100644 --- a/drivers/gpu/drm/radeon/kv_dpm.c +++ b/drivers/gpu/drm/radeon/kv_dpm.c | |||
@@ -40,6 +40,7 @@ static int kv_calculate_dpm_settings(struct radeon_device *rdev); | |||
40 | static void kv_enable_new_levels(struct radeon_device *rdev); | 40 | static void kv_enable_new_levels(struct radeon_device *rdev); |
41 | static void kv_program_nbps_index_settings(struct radeon_device *rdev, | 41 | static void kv_program_nbps_index_settings(struct radeon_device *rdev, |
42 | struct radeon_ps *new_rps); | 42 | struct radeon_ps *new_rps); |
43 | static int kv_set_enabled_level(struct radeon_device *rdev, u32 level); | ||
43 | static int kv_set_enabled_levels(struct radeon_device *rdev); | 44 | static int kv_set_enabled_levels(struct radeon_device *rdev); |
44 | static int kv_force_dpm_highest(struct radeon_device *rdev); | 45 | static int kv_force_dpm_highest(struct radeon_device *rdev); |
45 | static int kv_force_dpm_lowest(struct radeon_device *rdev); | 46 | static int kv_force_dpm_lowest(struct radeon_device *rdev); |
@@ -519,7 +520,7 @@ static int kv_set_dpm_boot_state(struct radeon_device *rdev) | |||
519 | 520 | ||
520 | static void kv_program_vc(struct radeon_device *rdev) | 521 | static void kv_program_vc(struct radeon_device *rdev) |
521 | { | 522 | { |
522 | WREG32_SMC(CG_FTV_0, 0x3FFFC000); | 523 | WREG32_SMC(CG_FTV_0, 0x3FFFC100); |
523 | } | 524 | } |
524 | 525 | ||
525 | static void kv_clear_vc(struct radeon_device *rdev) | 526 | static void kv_clear_vc(struct radeon_device *rdev) |
@@ -638,7 +639,10 @@ static int kv_force_lowest_valid(struct radeon_device *rdev) | |||
638 | 639 | ||
639 | static int kv_unforce_levels(struct radeon_device *rdev) | 640 | static int kv_unforce_levels(struct radeon_device *rdev) |
640 | { | 641 | { |
641 | return kv_notify_message_to_smu(rdev, PPSMC_MSG_NoForcedLevel); | 642 | if (rdev->family == CHIP_KABINI) |
643 | return kv_notify_message_to_smu(rdev, PPSMC_MSG_NoForcedLevel); | ||
644 | else | ||
645 | return kv_set_enabled_levels(rdev); | ||
642 | } | 646 | } |
643 | 647 | ||
644 | static int kv_update_sclk_t(struct radeon_device *rdev) | 648 | static int kv_update_sclk_t(struct radeon_device *rdev) |
@@ -667,9 +671,8 @@ static int kv_program_bootup_state(struct radeon_device *rdev) | |||
667 | &rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | 671 | &rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk; |
668 | 672 | ||
669 | if (table && table->count) { | 673 | if (table && table->count) { |
670 | for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { | 674 | for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) { |
671 | if ((table->entries[i].clk == pi->boot_pl.sclk) || | 675 | if (table->entries[i].clk == pi->boot_pl.sclk) |
672 | (i == 0)) | ||
673 | break; | 676 | break; |
674 | } | 677 | } |
675 | 678 | ||
@@ -682,9 +685,8 @@ static int kv_program_bootup_state(struct radeon_device *rdev) | |||
682 | if (table->num_max_dpm_entries == 0) | 685 | if (table->num_max_dpm_entries == 0) |
683 | return -EINVAL; | 686 | return -EINVAL; |
684 | 687 | ||
685 | for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { | 688 | for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) { |
686 | if ((table->entries[i].sclk_frequency == pi->boot_pl.sclk) || | 689 | if (table->entries[i].sclk_frequency == pi->boot_pl.sclk) |
687 | (i == 0)) | ||
688 | break; | 690 | break; |
689 | } | 691 | } |
690 | 692 | ||
@@ -1078,6 +1080,13 @@ static int kv_enable_ulv(struct radeon_device *rdev, bool enable) | |||
1078 | PPSMC_MSG_EnableULV : PPSMC_MSG_DisableULV); | 1080 | PPSMC_MSG_EnableULV : PPSMC_MSG_DisableULV); |
1079 | } | 1081 | } |
1080 | 1082 | ||
1083 | static void kv_reset_acp_boot_level(struct radeon_device *rdev) | ||
1084 | { | ||
1085 | struct kv_power_info *pi = kv_get_pi(rdev); | ||
1086 | |||
1087 | pi->acp_boot_level = 0xff; | ||
1088 | } | ||
1089 | |||
1081 | static void kv_update_current_ps(struct radeon_device *rdev, | 1090 | static void kv_update_current_ps(struct radeon_device *rdev, |
1082 | struct radeon_ps *rps) | 1091 | struct radeon_ps *rps) |
1083 | { | 1092 | { |
@@ -1100,6 +1109,18 @@ static void kv_update_requested_ps(struct radeon_device *rdev, | |||
1100 | pi->requested_rps.ps_priv = &pi->requested_ps; | 1109 | pi->requested_rps.ps_priv = &pi->requested_ps; |
1101 | } | 1110 | } |
1102 | 1111 | ||
1112 | void kv_dpm_enable_bapm(struct radeon_device *rdev, bool enable) | ||
1113 | { | ||
1114 | struct kv_power_info *pi = kv_get_pi(rdev); | ||
1115 | int ret; | ||
1116 | |||
1117 | if (pi->bapm_enable) { | ||
1118 | ret = kv_smc_bapm_enable(rdev, enable); | ||
1119 | if (ret) | ||
1120 | DRM_ERROR("kv_smc_bapm_enable failed\n"); | ||
1121 | } | ||
1122 | } | ||
1123 | |||
1103 | int kv_dpm_enable(struct radeon_device *rdev) | 1124 | int kv_dpm_enable(struct radeon_device *rdev) |
1104 | { | 1125 | { |
1105 | struct kv_power_info *pi = kv_get_pi(rdev); | 1126 | struct kv_power_info *pi = kv_get_pi(rdev); |
@@ -1192,6 +1213,8 @@ int kv_dpm_enable(struct radeon_device *rdev) | |||
1192 | return ret; | 1213 | return ret; |
1193 | } | 1214 | } |
1194 | 1215 | ||
1216 | kv_reset_acp_boot_level(rdev); | ||
1217 | |||
1195 | if (rdev->irq.installed && | 1218 | if (rdev->irq.installed && |
1196 | r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) { | 1219 | r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) { |
1197 | ret = kv_set_thermal_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX); | 1220 | ret = kv_set_thermal_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX); |
@@ -1203,6 +1226,12 @@ int kv_dpm_enable(struct radeon_device *rdev) | |||
1203 | radeon_irq_set(rdev); | 1226 | radeon_irq_set(rdev); |
1204 | } | 1227 | } |
1205 | 1228 | ||
1229 | ret = kv_smc_bapm_enable(rdev, false); | ||
1230 | if (ret) { | ||
1231 | DRM_ERROR("kv_smc_bapm_enable failed\n"); | ||
1232 | return ret; | ||
1233 | } | ||
1234 | |||
1206 | /* powerdown unused blocks for now */ | 1235 | /* powerdown unused blocks for now */ |
1207 | kv_dpm_powergate_acp(rdev, true); | 1236 | kv_dpm_powergate_acp(rdev, true); |
1208 | kv_dpm_powergate_samu(rdev, true); | 1237 | kv_dpm_powergate_samu(rdev, true); |
@@ -1226,6 +1255,8 @@ void kv_dpm_disable(struct radeon_device *rdev) | |||
1226 | RADEON_CG_BLOCK_BIF | | 1255 | RADEON_CG_BLOCK_BIF | |
1227 | RADEON_CG_BLOCK_HDP), false); | 1256 | RADEON_CG_BLOCK_HDP), false); |
1228 | 1257 | ||
1258 | kv_smc_bapm_enable(rdev, false); | ||
1259 | |||
1229 | /* powerup blocks */ | 1260 | /* powerup blocks */ |
1230 | kv_dpm_powergate_acp(rdev, false); | 1261 | kv_dpm_powergate_acp(rdev, false); |
1231 | kv_dpm_powergate_samu(rdev, false); | 1262 | kv_dpm_powergate_samu(rdev, false); |
@@ -1450,6 +1481,39 @@ static int kv_update_samu_dpm(struct radeon_device *rdev, bool gate) | |||
1450 | return kv_enable_samu_dpm(rdev, !gate); | 1481 | return kv_enable_samu_dpm(rdev, !gate); |
1451 | } | 1482 | } |
1452 | 1483 | ||
1484 | static u8 kv_get_acp_boot_level(struct radeon_device *rdev) | ||
1485 | { | ||
1486 | u8 i; | ||
1487 | struct radeon_clock_voltage_dependency_table *table = | ||
1488 | &rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table; | ||
1489 | |||
1490 | for (i = 0; i < table->count; i++) { | ||
1491 | if (table->entries[i].clk >= 0) /* XXX */ | ||
1492 | break; | ||
1493 | } | ||
1494 | |||
1495 | if (i >= table->count) | ||
1496 | i = table->count - 1; | ||
1497 | |||
1498 | return i; | ||
1499 | } | ||
1500 | |||
1501 | static void kv_update_acp_boot_level(struct radeon_device *rdev) | ||
1502 | { | ||
1503 | struct kv_power_info *pi = kv_get_pi(rdev); | ||
1504 | u8 acp_boot_level; | ||
1505 | |||
1506 | if (!pi->caps_stable_p_state) { | ||
1507 | acp_boot_level = kv_get_acp_boot_level(rdev); | ||
1508 | if (acp_boot_level != pi->acp_boot_level) { | ||
1509 | pi->acp_boot_level = acp_boot_level; | ||
1510 | kv_send_msg_to_smc_with_parameter(rdev, | ||
1511 | PPSMC_MSG_ACPDPM_SetEnabledMask, | ||
1512 | (1 << pi->acp_boot_level)); | ||
1513 | } | ||
1514 | } | ||
1515 | } | ||
1516 | |||
1453 | static int kv_update_acp_dpm(struct radeon_device *rdev, bool gate) | 1517 | static int kv_update_acp_dpm(struct radeon_device *rdev, bool gate) |
1454 | { | 1518 | { |
1455 | struct kv_power_info *pi = kv_get_pi(rdev); | 1519 | struct kv_power_info *pi = kv_get_pi(rdev); |
@@ -1461,7 +1525,7 @@ static int kv_update_acp_dpm(struct radeon_device *rdev, bool gate) | |||
1461 | if (pi->caps_stable_p_state) | 1525 | if (pi->caps_stable_p_state) |
1462 | pi->acp_boot_level = table->count - 1; | 1526 | pi->acp_boot_level = table->count - 1; |
1463 | else | 1527 | else |
1464 | pi->acp_boot_level = 0; | 1528 | pi->acp_boot_level = kv_get_acp_boot_level(rdev); |
1465 | 1529 | ||
1466 | ret = kv_copy_bytes_to_smc(rdev, | 1530 | ret = kv_copy_bytes_to_smc(rdev, |
1467 | pi->dpm_table_start + | 1531 | pi->dpm_table_start + |
@@ -1588,13 +1652,11 @@ static void kv_set_valid_clock_range(struct radeon_device *rdev, | |||
1588 | } | 1652 | } |
1589 | } | 1653 | } |
1590 | 1654 | ||
1591 | for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { | 1655 | for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) { |
1592 | if ((table->entries[i].clk <= new_ps->levels[new_ps->num_levels -1].sclk) || | 1656 | if (table->entries[i].clk <= new_ps->levels[new_ps->num_levels - 1].sclk) |
1593 | (i == 0)) { | ||
1594 | pi->highest_valid = i; | ||
1595 | break; | 1657 | break; |
1596 | } | ||
1597 | } | 1658 | } |
1659 | pi->highest_valid = i; | ||
1598 | 1660 | ||
1599 | if (pi->lowest_valid > pi->highest_valid) { | 1661 | if (pi->lowest_valid > pi->highest_valid) { |
1600 | if ((new_ps->levels[0].sclk - table->entries[pi->highest_valid].clk) > | 1662 | if ((new_ps->levels[0].sclk - table->entries[pi->highest_valid].clk) > |
@@ -1615,14 +1677,12 @@ static void kv_set_valid_clock_range(struct radeon_device *rdev, | |||
1615 | } | 1677 | } |
1616 | } | 1678 | } |
1617 | 1679 | ||
1618 | for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { | 1680 | for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) { |
1619 | if (table->entries[i].sclk_frequency <= | 1681 | if (table->entries[i].sclk_frequency <= |
1620 | new_ps->levels[new_ps->num_levels - 1].sclk || | 1682 | new_ps->levels[new_ps->num_levels - 1].sclk) |
1621 | i == 0) { | ||
1622 | pi->highest_valid = i; | ||
1623 | break; | 1683 | break; |
1624 | } | ||
1625 | } | 1684 | } |
1685 | pi->highest_valid = i; | ||
1626 | 1686 | ||
1627 | if (pi->lowest_valid > pi->highest_valid) { | 1687 | if (pi->lowest_valid > pi->highest_valid) { |
1628 | if ((new_ps->levels[0].sclk - | 1688 | if ((new_ps->levels[0].sclk - |
@@ -1724,6 +1784,14 @@ int kv_dpm_set_power_state(struct radeon_device *rdev) | |||
1724 | RADEON_CG_BLOCK_BIF | | 1784 | RADEON_CG_BLOCK_BIF | |
1725 | RADEON_CG_BLOCK_HDP), false); | 1785 | RADEON_CG_BLOCK_HDP), false); |
1726 | 1786 | ||
1787 | if (pi->bapm_enable) { | ||
1788 | ret = kv_smc_bapm_enable(rdev, rdev->pm.dpm.ac_power); | ||
1789 | if (ret) { | ||
1790 | DRM_ERROR("kv_smc_bapm_enable failed\n"); | ||
1791 | return ret; | ||
1792 | } | ||
1793 | } | ||
1794 | |||
1727 | if (rdev->family == CHIP_KABINI) { | 1795 | if (rdev->family == CHIP_KABINI) { |
1728 | if (pi->enable_dpm) { | 1796 | if (pi->enable_dpm) { |
1729 | kv_set_valid_clock_range(rdev, new_ps); | 1797 | kv_set_valid_clock_range(rdev, new_ps); |
@@ -1775,6 +1843,7 @@ int kv_dpm_set_power_state(struct radeon_device *rdev) | |||
1775 | return ret; | 1843 | return ret; |
1776 | } | 1844 | } |
1777 | #endif | 1845 | #endif |
1846 | kv_update_acp_boot_level(rdev); | ||
1778 | kv_update_sclk_t(rdev); | 1847 | kv_update_sclk_t(rdev); |
1779 | kv_enable_nb_dpm(rdev); | 1848 | kv_enable_nb_dpm(rdev); |
1780 | } | 1849 | } |
@@ -1785,7 +1854,6 @@ int kv_dpm_set_power_state(struct radeon_device *rdev) | |||
1785 | RADEON_CG_BLOCK_BIF | | 1854 | RADEON_CG_BLOCK_BIF | |
1786 | RADEON_CG_BLOCK_HDP), true); | 1855 | RADEON_CG_BLOCK_HDP), true); |
1787 | 1856 | ||
1788 | rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO; | ||
1789 | return 0; | 1857 | return 0; |
1790 | } | 1858 | } |
1791 | 1859 | ||
@@ -1806,12 +1874,23 @@ void kv_dpm_setup_asic(struct radeon_device *rdev) | |||
1806 | 1874 | ||
1807 | void kv_dpm_reset_asic(struct radeon_device *rdev) | 1875 | void kv_dpm_reset_asic(struct radeon_device *rdev) |
1808 | { | 1876 | { |
1809 | kv_force_lowest_valid(rdev); | 1877 | struct kv_power_info *pi = kv_get_pi(rdev); |
1810 | kv_init_graphics_levels(rdev); | 1878 | |
1811 | kv_program_bootup_state(rdev); | 1879 | if (rdev->family == CHIP_KABINI) { |
1812 | kv_upload_dpm_settings(rdev); | 1880 | kv_force_lowest_valid(rdev); |
1813 | kv_force_lowest_valid(rdev); | 1881 | kv_init_graphics_levels(rdev); |
1814 | kv_unforce_levels(rdev); | 1882 | kv_program_bootup_state(rdev); |
1883 | kv_upload_dpm_settings(rdev); | ||
1884 | kv_force_lowest_valid(rdev); | ||
1885 | kv_unforce_levels(rdev); | ||
1886 | } else { | ||
1887 | kv_init_graphics_levels(rdev); | ||
1888 | kv_program_bootup_state(rdev); | ||
1889 | kv_freeze_sclk_dpm(rdev, true); | ||
1890 | kv_upload_dpm_settings(rdev); | ||
1891 | kv_freeze_sclk_dpm(rdev, false); | ||
1892 | kv_set_enabled_level(rdev, pi->graphics_boot_level); | ||
1893 | } | ||
1815 | } | 1894 | } |
1816 | 1895 | ||
1817 | //XXX use sumo_dpm_display_configuration_changed | 1896 | //XXX use sumo_dpm_display_configuration_changed |
@@ -1871,12 +1950,15 @@ static int kv_force_dpm_highest(struct radeon_device *rdev) | |||
1871 | if (ret) | 1950 | if (ret) |
1872 | return ret; | 1951 | return ret; |
1873 | 1952 | ||
1874 | for (i = SMU7_MAX_LEVELS_GRAPHICS - 1; i >= 0; i--) { | 1953 | for (i = SMU7_MAX_LEVELS_GRAPHICS - 1; i > 0; i--) { |
1875 | if (enable_mask & (1 << i)) | 1954 | if (enable_mask & (1 << i)) |
1876 | break; | 1955 | break; |
1877 | } | 1956 | } |
1878 | 1957 | ||
1879 | return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i); | 1958 | if (rdev->family == CHIP_KABINI) |
1959 | return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i); | ||
1960 | else | ||
1961 | return kv_set_enabled_level(rdev, i); | ||
1880 | } | 1962 | } |
1881 | 1963 | ||
1882 | static int kv_force_dpm_lowest(struct radeon_device *rdev) | 1964 | static int kv_force_dpm_lowest(struct radeon_device *rdev) |
@@ -1893,7 +1975,10 @@ static int kv_force_dpm_lowest(struct radeon_device *rdev) | |||
1893 | break; | 1975 | break; |
1894 | } | 1976 | } |
1895 | 1977 | ||
1896 | return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i); | 1978 | if (rdev->family == CHIP_KABINI) |
1979 | return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i); | ||
1980 | else | ||
1981 | return kv_set_enabled_level(rdev, i); | ||
1897 | } | 1982 | } |
1898 | 1983 | ||
1899 | static u8 kv_get_sleep_divider_id_from_clock(struct radeon_device *rdev, | 1984 | static u8 kv_get_sleep_divider_id_from_clock(struct radeon_device *rdev, |
@@ -1911,9 +1996,9 @@ static u8 kv_get_sleep_divider_id_from_clock(struct radeon_device *rdev, | |||
1911 | if (!pi->caps_sclk_ds) | 1996 | if (!pi->caps_sclk_ds) |
1912 | return 0; | 1997 | return 0; |
1913 | 1998 | ||
1914 | for (i = KV_MAX_DEEPSLEEP_DIVIDER_ID; i <= 0; i--) { | 1999 | for (i = KV_MAX_DEEPSLEEP_DIVIDER_ID; i > 0; i--) { |
1915 | temp = sclk / sumo_get_sleep_divider_from_id(i); | 2000 | temp = sclk / sumo_get_sleep_divider_from_id(i); |
1916 | if ((temp >= min) || (i == 0)) | 2001 | if (temp >= min) |
1917 | break; | 2002 | break; |
1918 | } | 2003 | } |
1919 | 2004 | ||
@@ -2039,12 +2124,12 @@ static void kv_apply_state_adjust_rules(struct radeon_device *rdev, | |||
2039 | ps->dpmx_nb_ps_lo = 0x1; | 2124 | ps->dpmx_nb_ps_lo = 0x1; |
2040 | ps->dpmx_nb_ps_hi = 0x0; | 2125 | ps->dpmx_nb_ps_hi = 0x0; |
2041 | } else { | 2126 | } else { |
2042 | ps->dpm0_pg_nb_ps_lo = 0x1; | 2127 | ps->dpm0_pg_nb_ps_lo = 0x3; |
2043 | ps->dpm0_pg_nb_ps_hi = 0x0; | 2128 | ps->dpm0_pg_nb_ps_hi = 0x0; |
2044 | ps->dpmx_nb_ps_lo = 0x2; | 2129 | ps->dpmx_nb_ps_lo = 0x3; |
2045 | ps->dpmx_nb_ps_hi = 0x1; | 2130 | ps->dpmx_nb_ps_hi = 0x0; |
2046 | 2131 | ||
2047 | if (pi->sys_info.nb_dpm_enable && pi->battery_state) { | 2132 | if (pi->sys_info.nb_dpm_enable) { |
2048 | force_high = (mclk >= pi->sys_info.nbp_memory_clock[3]) || | 2133 | force_high = (mclk >= pi->sys_info.nbp_memory_clock[3]) || |
2049 | pi->video_start || (rdev->pm.dpm.new_active_crtc_count >= 3) || | 2134 | pi->video_start || (rdev->pm.dpm.new_active_crtc_count >= 3) || |
2050 | pi->disable_nb_ps3_in_battery; | 2135 | pi->disable_nb_ps3_in_battery; |
@@ -2210,6 +2295,15 @@ static void kv_enable_new_levels(struct radeon_device *rdev) | |||
2210 | } | 2295 | } |
2211 | } | 2296 | } |
2212 | 2297 | ||
2298 | static int kv_set_enabled_level(struct radeon_device *rdev, u32 level) | ||
2299 | { | ||
2300 | u32 new_mask = (1 << level); | ||
2301 | |||
2302 | return kv_send_msg_to_smc_with_parameter(rdev, | ||
2303 | PPSMC_MSG_SCLKDPM_SetEnabledMask, | ||
2304 | new_mask); | ||
2305 | } | ||
2306 | |||
2213 | static int kv_set_enabled_levels(struct radeon_device *rdev) | 2307 | static int kv_set_enabled_levels(struct radeon_device *rdev) |
2214 | { | 2308 | { |
2215 | struct kv_power_info *pi = kv_get_pi(rdev); | 2309 | struct kv_power_info *pi = kv_get_pi(rdev); |
diff --git a/drivers/gpu/drm/radeon/kv_dpm.h b/drivers/gpu/drm/radeon/kv_dpm.h index 32bb079572d7..8cef7525d7a8 100644 --- a/drivers/gpu/drm/radeon/kv_dpm.h +++ b/drivers/gpu/drm/radeon/kv_dpm.h | |||
@@ -192,6 +192,7 @@ int kv_send_msg_to_smc_with_parameter(struct radeon_device *rdev, | |||
192 | int kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, | 192 | int kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, |
193 | u32 *value, u32 limit); | 193 | u32 *value, u32 limit); |
194 | int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable); | 194 | int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable); |
195 | int kv_smc_bapm_enable(struct radeon_device *rdev, bool enable); | ||
195 | int kv_copy_bytes_to_smc(struct radeon_device *rdev, | 196 | int kv_copy_bytes_to_smc(struct radeon_device *rdev, |
196 | u32 smc_start_address, | 197 | u32 smc_start_address, |
197 | const u8 *src, u32 byte_count, u32 limit); | 198 | const u8 *src, u32 byte_count, u32 limit); |
diff --git a/drivers/gpu/drm/radeon/kv_smc.c b/drivers/gpu/drm/radeon/kv_smc.c index 34a226d7e34a..0000b59a6d05 100644 --- a/drivers/gpu/drm/radeon/kv_smc.c +++ b/drivers/gpu/drm/radeon/kv_smc.c | |||
@@ -107,6 +107,14 @@ int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable) | |||
107 | return kv_notify_message_to_smu(rdev, PPSMC_MSG_DPM_Disable); | 107 | return kv_notify_message_to_smu(rdev, PPSMC_MSG_DPM_Disable); |
108 | } | 108 | } |
109 | 109 | ||
110 | int kv_smc_bapm_enable(struct radeon_device *rdev, bool enable) | ||
111 | { | ||
112 | if (enable) | ||
113 | return kv_notify_message_to_smu(rdev, PPSMC_MSG_EnableBAPM); | ||
114 | else | ||
115 | return kv_notify_message_to_smu(rdev, PPSMC_MSG_DisableBAPM); | ||
116 | } | ||
117 | |||
110 | int kv_copy_bytes_to_smc(struct radeon_device *rdev, | 118 | int kv_copy_bytes_to_smc(struct radeon_device *rdev, |
111 | u32 smc_start_address, | 119 | u32 smc_start_address, |
112 | const u8 *src, u32 byte_count, u32 limit) | 120 | const u8 *src, u32 byte_count, u32 limit) |
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c index f7b625c9e0e9..6c398a456d78 100644 --- a/drivers/gpu/drm/radeon/ni_dpm.c +++ b/drivers/gpu/drm/radeon/ni_dpm.c | |||
@@ -3865,12 +3865,6 @@ int ni_dpm_set_power_state(struct radeon_device *rdev) | |||
3865 | return ret; | 3865 | return ret; |
3866 | } | 3866 | } |
3867 | 3867 | ||
3868 | ret = ni_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
3869 | if (ret) { | ||
3870 | DRM_ERROR("ni_dpm_force_performance_level failed\n"); | ||
3871 | return ret; | ||
3872 | } | ||
3873 | |||
3874 | return 0; | 3868 | return 0; |
3875 | } | 3869 | } |
3876 | 3870 | ||
diff --git a/drivers/gpu/drm/radeon/ppsmc.h b/drivers/gpu/drm/radeon/ppsmc.h index 682842804bce..5670b8291285 100644 --- a/drivers/gpu/drm/radeon/ppsmc.h +++ b/drivers/gpu/drm/radeon/ppsmc.h | |||
@@ -163,6 +163,8 @@ typedef uint8_t PPSMC_Result; | |||
163 | #define PPSMC_MSG_VCEPowerON ((uint32_t) 0x10f) | 163 | #define PPSMC_MSG_VCEPowerON ((uint32_t) 0x10f) |
164 | #define PPSMC_MSG_DCE_RemoveVoltageAdjustment ((uint32_t) 0x11d) | 164 | #define PPSMC_MSG_DCE_RemoveVoltageAdjustment ((uint32_t) 0x11d) |
165 | #define PPSMC_MSG_DCE_AllowVoltageAdjustment ((uint32_t) 0x11e) | 165 | #define PPSMC_MSG_DCE_AllowVoltageAdjustment ((uint32_t) 0x11e) |
166 | #define PPSMC_MSG_EnableBAPM ((uint32_t) 0x120) | ||
167 | #define PPSMC_MSG_DisableBAPM ((uint32_t) 0x121) | ||
166 | #define PPSMC_MSG_UVD_DPM_Config ((uint32_t) 0x124) | 168 | #define PPSMC_MSG_UVD_DPM_Config ((uint32_t) 0x124) |
167 | 169 | ||
168 | 170 | ||
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index 9fc61dd68bc0..24175717307b 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
@@ -2853,21 +2853,28 @@ static void r100_pll_errata_after_data(struct radeon_device *rdev) | |||
2853 | 2853 | ||
2854 | uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg) | 2854 | uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg) |
2855 | { | 2855 | { |
2856 | unsigned long flags; | ||
2856 | uint32_t data; | 2857 | uint32_t data; |
2857 | 2858 | ||
2859 | spin_lock_irqsave(&rdev->pll_idx_lock, flags); | ||
2858 | WREG8(RADEON_CLOCK_CNTL_INDEX, reg & 0x3f); | 2860 | WREG8(RADEON_CLOCK_CNTL_INDEX, reg & 0x3f); |
2859 | r100_pll_errata_after_index(rdev); | 2861 | r100_pll_errata_after_index(rdev); |
2860 | data = RREG32(RADEON_CLOCK_CNTL_DATA); | 2862 | data = RREG32(RADEON_CLOCK_CNTL_DATA); |
2861 | r100_pll_errata_after_data(rdev); | 2863 | r100_pll_errata_after_data(rdev); |
2864 | spin_unlock_irqrestore(&rdev->pll_idx_lock, flags); | ||
2862 | return data; | 2865 | return data; |
2863 | } | 2866 | } |
2864 | 2867 | ||
2865 | void r100_pll_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 2868 | void r100_pll_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
2866 | { | 2869 | { |
2870 | unsigned long flags; | ||
2871 | |||
2872 | spin_lock_irqsave(&rdev->pll_idx_lock, flags); | ||
2867 | WREG8(RADEON_CLOCK_CNTL_INDEX, ((reg & 0x3f) | RADEON_PLL_WR_EN)); | 2873 | WREG8(RADEON_CLOCK_CNTL_INDEX, ((reg & 0x3f) | RADEON_PLL_WR_EN)); |
2868 | r100_pll_errata_after_index(rdev); | 2874 | r100_pll_errata_after_index(rdev); |
2869 | WREG32(RADEON_CLOCK_CNTL_DATA, v); | 2875 | WREG32(RADEON_CLOCK_CNTL_DATA, v); |
2870 | r100_pll_errata_after_data(rdev); | 2876 | r100_pll_errata_after_data(rdev); |
2877 | spin_unlock_irqrestore(&rdev->pll_idx_lock, flags); | ||
2871 | } | 2878 | } |
2872 | 2879 | ||
2873 | static void r100_set_safe_registers(struct radeon_device *rdev) | 2880 | static void r100_set_safe_registers(struct radeon_device *rdev) |
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c index 4e796ecf9ea4..6edf2b3a52b4 100644 --- a/drivers/gpu/drm/radeon/r420.c +++ b/drivers/gpu/drm/radeon/r420.c | |||
@@ -160,18 +160,25 @@ void r420_pipes_init(struct radeon_device *rdev) | |||
160 | 160 | ||
161 | u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg) | 161 | u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg) |
162 | { | 162 | { |
163 | unsigned long flags; | ||
163 | u32 r; | 164 | u32 r; |
164 | 165 | ||
166 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
165 | WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg)); | 167 | WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg)); |
166 | r = RREG32(R_0001FC_MC_IND_DATA); | 168 | r = RREG32(R_0001FC_MC_IND_DATA); |
169 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
167 | return r; | 170 | return r; |
168 | } | 171 | } |
169 | 172 | ||
170 | void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 173 | void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
171 | { | 174 | { |
175 | unsigned long flags; | ||
176 | |||
177 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
172 | WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg) | | 178 | WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg) | |
173 | S_0001F8_MC_IND_WR_EN(1)); | 179 | S_0001F8_MC_IND_WR_EN(1)); |
174 | WREG32(R_0001FC_MC_IND_DATA, v); | 180 | WREG32(R_0001FC_MC_IND_DATA, v); |
181 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
175 | } | 182 | } |
176 | 183 | ||
177 | static void r420_debugfs(struct radeon_device *rdev) | 184 | static void r420_debugfs(struct radeon_device *rdev) |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index ea4d3734e6d9..2a1b1876b431 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -119,6 +119,11 @@ u32 r600_get_xclk(struct radeon_device *rdev) | |||
119 | return rdev->clock.spll.reference_freq; | 119 | return rdev->clock.spll.reference_freq; |
120 | } | 120 | } |
121 | 121 | ||
122 | int r600_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk) | ||
123 | { | ||
124 | return 0; | ||
125 | } | ||
126 | |||
122 | /* get temperature in millidegrees */ | 127 | /* get temperature in millidegrees */ |
123 | int rv6xx_get_temp(struct radeon_device *rdev) | 128 | int rv6xx_get_temp(struct radeon_device *rdev) |
124 | { | 129 | { |
@@ -1045,20 +1050,27 @@ int r600_mc_wait_for_idle(struct radeon_device *rdev) | |||
1045 | 1050 | ||
1046 | uint32_t rs780_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 1051 | uint32_t rs780_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
1047 | { | 1052 | { |
1053 | unsigned long flags; | ||
1048 | uint32_t r; | 1054 | uint32_t r; |
1049 | 1055 | ||
1056 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
1050 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg)); | 1057 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg)); |
1051 | r = RREG32(R_0028FC_MC_DATA); | 1058 | r = RREG32(R_0028FC_MC_DATA); |
1052 | WREG32(R_0028F8_MC_INDEX, ~C_0028F8_MC_IND_ADDR); | 1059 | WREG32(R_0028F8_MC_INDEX, ~C_0028F8_MC_IND_ADDR); |
1060 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
1053 | return r; | 1061 | return r; |
1054 | } | 1062 | } |
1055 | 1063 | ||
1056 | void rs780_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 1064 | void rs780_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
1057 | { | 1065 | { |
1066 | unsigned long flags; | ||
1067 | |||
1068 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
1058 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg) | | 1069 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg) | |
1059 | S_0028F8_MC_IND_WR_EN(1)); | 1070 | S_0028F8_MC_IND_WR_EN(1)); |
1060 | WREG32(R_0028FC_MC_DATA, v); | 1071 | WREG32(R_0028FC_MC_DATA, v); |
1061 | WREG32(R_0028F8_MC_INDEX, 0x7F); | 1072 | WREG32(R_0028F8_MC_INDEX, 0x7F); |
1073 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
1062 | } | 1074 | } |
1063 | 1075 | ||
1064 | static void r600_mc_program(struct radeon_device *rdev) | 1076 | static void r600_mc_program(struct radeon_device *rdev) |
@@ -2092,20 +2104,27 @@ static void r600_gpu_init(struct radeon_device *rdev) | |||
2092 | */ | 2104 | */ |
2093 | u32 r600_pciep_rreg(struct radeon_device *rdev, u32 reg) | 2105 | u32 r600_pciep_rreg(struct radeon_device *rdev, u32 reg) |
2094 | { | 2106 | { |
2107 | unsigned long flags; | ||
2095 | u32 r; | 2108 | u32 r; |
2096 | 2109 | ||
2110 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); | ||
2097 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | 2111 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); |
2098 | (void)RREG32(PCIE_PORT_INDEX); | 2112 | (void)RREG32(PCIE_PORT_INDEX); |
2099 | r = RREG32(PCIE_PORT_DATA); | 2113 | r = RREG32(PCIE_PORT_DATA); |
2114 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); | ||
2100 | return r; | 2115 | return r; |
2101 | } | 2116 | } |
2102 | 2117 | ||
2103 | void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2118 | void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2104 | { | 2119 | { |
2120 | unsigned long flags; | ||
2121 | |||
2122 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); | ||
2105 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | 2123 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); |
2106 | (void)RREG32(PCIE_PORT_INDEX); | 2124 | (void)RREG32(PCIE_PORT_INDEX); |
2107 | WREG32(PCIE_PORT_DATA, (v)); | 2125 | WREG32(PCIE_PORT_DATA, (v)); |
2108 | (void)RREG32(PCIE_PORT_DATA); | 2126 | (void)RREG32(PCIE_PORT_DATA); |
2127 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); | ||
2109 | } | 2128 | } |
2110 | 2129 | ||
2111 | /* | 2130 | /* |
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c index fa0de46fcc0d..e65f211a7be0 100644 --- a/drivers/gpu/drm/radeon/r600_dpm.c +++ b/drivers/gpu/drm/radeon/r600_dpm.c | |||
@@ -1219,30 +1219,20 @@ int r600_parse_extended_power_table(struct radeon_device *rdev) | |||
1219 | 1219 | ||
1220 | void r600_free_extended_power_table(struct radeon_device *rdev) | 1220 | void r600_free_extended_power_table(struct radeon_device *rdev) |
1221 | { | 1221 | { |
1222 | if (rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries) | 1222 | struct radeon_dpm_dynamic_state *dyn_state = &rdev->pm.dpm.dyn_state; |
1223 | kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries); | 1223 | |
1224 | if (rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk.entries) | 1224 | kfree(dyn_state->vddc_dependency_on_sclk.entries); |
1225 | kfree(rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk.entries); | 1225 | kfree(dyn_state->vddci_dependency_on_mclk.entries); |
1226 | if (rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk.entries) | 1226 | kfree(dyn_state->vddc_dependency_on_mclk.entries); |
1227 | kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk.entries); | 1227 | kfree(dyn_state->mvdd_dependency_on_mclk.entries); |
1228 | if (rdev->pm.dpm.dyn_state.mvdd_dependency_on_mclk.entries) | 1228 | kfree(dyn_state->cac_leakage_table.entries); |
1229 | kfree(rdev->pm.dpm.dyn_state.mvdd_dependency_on_mclk.entries); | 1229 | kfree(dyn_state->phase_shedding_limits_table.entries); |
1230 | if (rdev->pm.dpm.dyn_state.cac_leakage_table.entries) | 1230 | kfree(dyn_state->ppm_table); |
1231 | kfree(rdev->pm.dpm.dyn_state.cac_leakage_table.entries); | 1231 | kfree(dyn_state->cac_tdp_table); |
1232 | if (rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) | 1232 | kfree(dyn_state->vce_clock_voltage_dependency_table.entries); |
1233 | kfree(rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries); | 1233 | kfree(dyn_state->uvd_clock_voltage_dependency_table.entries); |
1234 | if (rdev->pm.dpm.dyn_state.ppm_table) | 1234 | kfree(dyn_state->samu_clock_voltage_dependency_table.entries); |
1235 | kfree(rdev->pm.dpm.dyn_state.ppm_table); | 1235 | kfree(dyn_state->acp_clock_voltage_dependency_table.entries); |
1236 | if (rdev->pm.dpm.dyn_state.cac_tdp_table) | ||
1237 | kfree(rdev->pm.dpm.dyn_state.cac_tdp_table); | ||
1238 | if (rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries) | ||
1239 | kfree(rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries); | ||
1240 | if (rdev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries) | ||
1241 | kfree(rdev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries); | ||
1242 | if (rdev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries) | ||
1243 | kfree(rdev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries); | ||
1244 | if (rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries) | ||
1245 | kfree(rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries); | ||
1246 | } | 1236 | } |
1247 | 1237 | ||
1248 | enum radeon_pcie_gen r600_get_pcie_gen_support(struct radeon_device *rdev, | 1238 | enum radeon_pcie_gen r600_get_pcie_gen_support(struct radeon_device *rdev, |
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h index 454f90a849e4..e673fe26ea84 100644 --- a/drivers/gpu/drm/radeon/r600d.h +++ b/drivers/gpu/drm/radeon/r600d.h | |||
@@ -1040,7 +1040,7 @@ | |||
1040 | # define HDMI0_AVI_INFO_CONT (1 << 1) | 1040 | # define HDMI0_AVI_INFO_CONT (1 << 1) |
1041 | # define HDMI0_AUDIO_INFO_SEND (1 << 4) | 1041 | # define HDMI0_AUDIO_INFO_SEND (1 << 4) |
1042 | # define HDMI0_AUDIO_INFO_CONT (1 << 5) | 1042 | # define HDMI0_AUDIO_INFO_CONT (1 << 5) |
1043 | # define HDMI0_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hmdi regs */ | 1043 | # define HDMI0_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hdmi regs */ |
1044 | # define HDMI0_AUDIO_INFO_UPDATE (1 << 7) | 1044 | # define HDMI0_AUDIO_INFO_UPDATE (1 << 7) |
1045 | # define HDMI0_MPEG_INFO_SEND (1 << 8) | 1045 | # define HDMI0_MPEG_INFO_SEND (1 << 8) |
1046 | # define HDMI0_MPEG_INFO_CONT (1 << 9) | 1046 | # define HDMI0_MPEG_INFO_CONT (1 << 9) |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index ff8b564ce2b2..a400ac1c4147 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -181,7 +181,7 @@ extern int radeon_aspm; | |||
181 | #define RADEON_CG_SUPPORT_HDP_MGCG (1 << 16) | 181 | #define RADEON_CG_SUPPORT_HDP_MGCG (1 << 16) |
182 | 182 | ||
183 | /* PG flags */ | 183 | /* PG flags */ |
184 | #define RADEON_PG_SUPPORT_GFX_CG (1 << 0) | 184 | #define RADEON_PG_SUPPORT_GFX_PG (1 << 0) |
185 | #define RADEON_PG_SUPPORT_GFX_SMG (1 << 1) | 185 | #define RADEON_PG_SUPPORT_GFX_SMG (1 << 1) |
186 | #define RADEON_PG_SUPPORT_GFX_DMG (1 << 2) | 186 | #define RADEON_PG_SUPPORT_GFX_DMG (1 << 2) |
187 | #define RADEON_PG_SUPPORT_UVD (1 << 3) | 187 | #define RADEON_PG_SUPPORT_UVD (1 << 3) |
@@ -1778,6 +1778,7 @@ struct radeon_asic { | |||
1778 | int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level); | 1778 | int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level); |
1779 | bool (*vblank_too_short)(struct radeon_device *rdev); | 1779 | bool (*vblank_too_short)(struct radeon_device *rdev); |
1780 | void (*powergate_uvd)(struct radeon_device *rdev, bool gate); | 1780 | void (*powergate_uvd)(struct radeon_device *rdev, bool gate); |
1781 | void (*enable_bapm)(struct radeon_device *rdev, bool enable); | ||
1781 | } dpm; | 1782 | } dpm; |
1782 | /* pageflipping */ | 1783 | /* pageflipping */ |
1783 | struct { | 1784 | struct { |
@@ -2110,6 +2111,28 @@ struct radeon_device { | |||
2110 | resource_size_t rmmio_size; | 2111 | resource_size_t rmmio_size; |
2111 | /* protects concurrent MM_INDEX/DATA based register access */ | 2112 | /* protects concurrent MM_INDEX/DATA based register access */ |
2112 | spinlock_t mmio_idx_lock; | 2113 | spinlock_t mmio_idx_lock; |
2114 | /* protects concurrent SMC based register access */ | ||
2115 | spinlock_t smc_idx_lock; | ||
2116 | /* protects concurrent PLL register access */ | ||
2117 | spinlock_t pll_idx_lock; | ||
2118 | /* protects concurrent MC register access */ | ||
2119 | spinlock_t mc_idx_lock; | ||
2120 | /* protects concurrent PCIE register access */ | ||
2121 | spinlock_t pcie_idx_lock; | ||
2122 | /* protects concurrent PCIE_PORT register access */ | ||
2123 | spinlock_t pciep_idx_lock; | ||
2124 | /* protects concurrent PIF register access */ | ||
2125 | spinlock_t pif_idx_lock; | ||
2126 | /* protects concurrent CG register access */ | ||
2127 | spinlock_t cg_idx_lock; | ||
2128 | /* protects concurrent UVD register access */ | ||
2129 | spinlock_t uvd_idx_lock; | ||
2130 | /* protects concurrent RCU register access */ | ||
2131 | spinlock_t rcu_idx_lock; | ||
2132 | /* protects concurrent DIDT register access */ | ||
2133 | spinlock_t didt_idx_lock; | ||
2134 | /* protects concurrent ENDPOINT (audio) register access */ | ||
2135 | spinlock_t end_idx_lock; | ||
2113 | void __iomem *rmmio; | 2136 | void __iomem *rmmio; |
2114 | radeon_rreg_t mc_rreg; | 2137 | radeon_rreg_t mc_rreg; |
2115 | radeon_wreg_t mc_wreg; | 2138 | radeon_wreg_t mc_wreg; |
@@ -2277,123 +2300,179 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v); | |||
2277 | */ | 2300 | */ |
2278 | static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) | 2301 | static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) |
2279 | { | 2302 | { |
2303 | unsigned long flags; | ||
2280 | uint32_t r; | 2304 | uint32_t r; |
2281 | 2305 | ||
2306 | spin_lock_irqsave(&rdev->pcie_idx_lock, flags); | ||
2282 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); | 2307 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
2283 | r = RREG32(RADEON_PCIE_DATA); | 2308 | r = RREG32(RADEON_PCIE_DATA); |
2309 | spin_unlock_irqrestore(&rdev->pcie_idx_lock, flags); | ||
2284 | return r; | 2310 | return r; |
2285 | } | 2311 | } |
2286 | 2312 | ||
2287 | static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 2313 | static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
2288 | { | 2314 | { |
2315 | unsigned long flags; | ||
2316 | |||
2317 | spin_lock_irqsave(&rdev->pcie_idx_lock, flags); | ||
2289 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); | 2318 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
2290 | WREG32(RADEON_PCIE_DATA, (v)); | 2319 | WREG32(RADEON_PCIE_DATA, (v)); |
2320 | spin_unlock_irqrestore(&rdev->pcie_idx_lock, flags); | ||
2291 | } | 2321 | } |
2292 | 2322 | ||
2293 | static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg) | 2323 | static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg) |
2294 | { | 2324 | { |
2325 | unsigned long flags; | ||
2295 | u32 r; | 2326 | u32 r; |
2296 | 2327 | ||
2328 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
2297 | WREG32(TN_SMC_IND_INDEX_0, (reg)); | 2329 | WREG32(TN_SMC_IND_INDEX_0, (reg)); |
2298 | r = RREG32(TN_SMC_IND_DATA_0); | 2330 | r = RREG32(TN_SMC_IND_DATA_0); |
2331 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
2299 | return r; | 2332 | return r; |
2300 | } | 2333 | } |
2301 | 2334 | ||
2302 | static inline void tn_smc_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2335 | static inline void tn_smc_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2303 | { | 2336 | { |
2337 | unsigned long flags; | ||
2338 | |||
2339 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
2304 | WREG32(TN_SMC_IND_INDEX_0, (reg)); | 2340 | WREG32(TN_SMC_IND_INDEX_0, (reg)); |
2305 | WREG32(TN_SMC_IND_DATA_0, (v)); | 2341 | WREG32(TN_SMC_IND_DATA_0, (v)); |
2342 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
2306 | } | 2343 | } |
2307 | 2344 | ||
2308 | static inline u32 r600_rcu_rreg(struct radeon_device *rdev, u32 reg) | 2345 | static inline u32 r600_rcu_rreg(struct radeon_device *rdev, u32 reg) |
2309 | { | 2346 | { |
2347 | unsigned long flags; | ||
2310 | u32 r; | 2348 | u32 r; |
2311 | 2349 | ||
2350 | spin_lock_irqsave(&rdev->rcu_idx_lock, flags); | ||
2312 | WREG32(R600_RCU_INDEX, ((reg) & 0x1fff)); | 2351 | WREG32(R600_RCU_INDEX, ((reg) & 0x1fff)); |
2313 | r = RREG32(R600_RCU_DATA); | 2352 | r = RREG32(R600_RCU_DATA); |
2353 | spin_unlock_irqrestore(&rdev->rcu_idx_lock, flags); | ||
2314 | return r; | 2354 | return r; |
2315 | } | 2355 | } |
2316 | 2356 | ||
2317 | static inline void r600_rcu_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2357 | static inline void r600_rcu_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2318 | { | 2358 | { |
2359 | unsigned long flags; | ||
2360 | |||
2361 | spin_lock_irqsave(&rdev->rcu_idx_lock, flags); | ||
2319 | WREG32(R600_RCU_INDEX, ((reg) & 0x1fff)); | 2362 | WREG32(R600_RCU_INDEX, ((reg) & 0x1fff)); |
2320 | WREG32(R600_RCU_DATA, (v)); | 2363 | WREG32(R600_RCU_DATA, (v)); |
2364 | spin_unlock_irqrestore(&rdev->rcu_idx_lock, flags); | ||
2321 | } | 2365 | } |
2322 | 2366 | ||
2323 | static inline u32 eg_cg_rreg(struct radeon_device *rdev, u32 reg) | 2367 | static inline u32 eg_cg_rreg(struct radeon_device *rdev, u32 reg) |
2324 | { | 2368 | { |
2369 | unsigned long flags; | ||
2325 | u32 r; | 2370 | u32 r; |
2326 | 2371 | ||
2372 | spin_lock_irqsave(&rdev->cg_idx_lock, flags); | ||
2327 | WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff)); | 2373 | WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff)); |
2328 | r = RREG32(EVERGREEN_CG_IND_DATA); | 2374 | r = RREG32(EVERGREEN_CG_IND_DATA); |
2375 | spin_unlock_irqrestore(&rdev->cg_idx_lock, flags); | ||
2329 | return r; | 2376 | return r; |
2330 | } | 2377 | } |
2331 | 2378 | ||
2332 | static inline void eg_cg_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2379 | static inline void eg_cg_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2333 | { | 2380 | { |
2381 | unsigned long flags; | ||
2382 | |||
2383 | spin_lock_irqsave(&rdev->cg_idx_lock, flags); | ||
2334 | WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff)); | 2384 | WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff)); |
2335 | WREG32(EVERGREEN_CG_IND_DATA, (v)); | 2385 | WREG32(EVERGREEN_CG_IND_DATA, (v)); |
2386 | spin_unlock_irqrestore(&rdev->cg_idx_lock, flags); | ||
2336 | } | 2387 | } |
2337 | 2388 | ||
2338 | static inline u32 eg_pif_phy0_rreg(struct radeon_device *rdev, u32 reg) | 2389 | static inline u32 eg_pif_phy0_rreg(struct radeon_device *rdev, u32 reg) |
2339 | { | 2390 | { |
2391 | unsigned long flags; | ||
2340 | u32 r; | 2392 | u32 r; |
2341 | 2393 | ||
2394 | spin_lock_irqsave(&rdev->pif_idx_lock, flags); | ||
2342 | WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); | 2395 | WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); |
2343 | r = RREG32(EVERGREEN_PIF_PHY0_DATA); | 2396 | r = RREG32(EVERGREEN_PIF_PHY0_DATA); |
2397 | spin_unlock_irqrestore(&rdev->pif_idx_lock, flags); | ||
2344 | return r; | 2398 | return r; |
2345 | } | 2399 | } |
2346 | 2400 | ||
2347 | static inline void eg_pif_phy0_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2401 | static inline void eg_pif_phy0_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2348 | { | 2402 | { |
2403 | unsigned long flags; | ||
2404 | |||
2405 | spin_lock_irqsave(&rdev->pif_idx_lock, flags); | ||
2349 | WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); | 2406 | WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); |
2350 | WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); | 2407 | WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); |
2408 | spin_unlock_irqrestore(&rdev->pif_idx_lock, flags); | ||
2351 | } | 2409 | } |
2352 | 2410 | ||
2353 | static inline u32 eg_pif_phy1_rreg(struct radeon_device *rdev, u32 reg) | 2411 | static inline u32 eg_pif_phy1_rreg(struct radeon_device *rdev, u32 reg) |
2354 | { | 2412 | { |
2413 | unsigned long flags; | ||
2355 | u32 r; | 2414 | u32 r; |
2356 | 2415 | ||
2416 | spin_lock_irqsave(&rdev->pif_idx_lock, flags); | ||
2357 | WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); | 2417 | WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); |
2358 | r = RREG32(EVERGREEN_PIF_PHY1_DATA); | 2418 | r = RREG32(EVERGREEN_PIF_PHY1_DATA); |
2419 | spin_unlock_irqrestore(&rdev->pif_idx_lock, flags); | ||
2359 | return r; | 2420 | return r; |
2360 | } | 2421 | } |
2361 | 2422 | ||
2362 | static inline void eg_pif_phy1_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2423 | static inline void eg_pif_phy1_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2363 | { | 2424 | { |
2425 | unsigned long flags; | ||
2426 | |||
2427 | spin_lock_irqsave(&rdev->pif_idx_lock, flags); | ||
2364 | WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); | 2428 | WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); |
2365 | WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); | 2429 | WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); |
2430 | spin_unlock_irqrestore(&rdev->pif_idx_lock, flags); | ||
2366 | } | 2431 | } |
2367 | 2432 | ||
2368 | static inline u32 r600_uvd_ctx_rreg(struct radeon_device *rdev, u32 reg) | 2433 | static inline u32 r600_uvd_ctx_rreg(struct radeon_device *rdev, u32 reg) |
2369 | { | 2434 | { |
2435 | unsigned long flags; | ||
2370 | u32 r; | 2436 | u32 r; |
2371 | 2437 | ||
2438 | spin_lock_irqsave(&rdev->uvd_idx_lock, flags); | ||
2372 | WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff)); | 2439 | WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff)); |
2373 | r = RREG32(R600_UVD_CTX_DATA); | 2440 | r = RREG32(R600_UVD_CTX_DATA); |
2441 | spin_unlock_irqrestore(&rdev->uvd_idx_lock, flags); | ||
2374 | return r; | 2442 | return r; |
2375 | } | 2443 | } |
2376 | 2444 | ||
2377 | static inline void r600_uvd_ctx_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2445 | static inline void r600_uvd_ctx_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2378 | { | 2446 | { |
2447 | unsigned long flags; | ||
2448 | |||
2449 | spin_lock_irqsave(&rdev->uvd_idx_lock, flags); | ||
2379 | WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff)); | 2450 | WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff)); |
2380 | WREG32(R600_UVD_CTX_DATA, (v)); | 2451 | WREG32(R600_UVD_CTX_DATA, (v)); |
2452 | spin_unlock_irqrestore(&rdev->uvd_idx_lock, flags); | ||
2381 | } | 2453 | } |
2382 | 2454 | ||
2383 | 2455 | ||
2384 | static inline u32 cik_didt_rreg(struct radeon_device *rdev, u32 reg) | 2456 | static inline u32 cik_didt_rreg(struct radeon_device *rdev, u32 reg) |
2385 | { | 2457 | { |
2458 | unsigned long flags; | ||
2386 | u32 r; | 2459 | u32 r; |
2387 | 2460 | ||
2461 | spin_lock_irqsave(&rdev->didt_idx_lock, flags); | ||
2388 | WREG32(CIK_DIDT_IND_INDEX, (reg)); | 2462 | WREG32(CIK_DIDT_IND_INDEX, (reg)); |
2389 | r = RREG32(CIK_DIDT_IND_DATA); | 2463 | r = RREG32(CIK_DIDT_IND_DATA); |
2464 | spin_unlock_irqrestore(&rdev->didt_idx_lock, flags); | ||
2390 | return r; | 2465 | return r; |
2391 | } | 2466 | } |
2392 | 2467 | ||
2393 | static inline void cik_didt_wreg(struct radeon_device *rdev, u32 reg, u32 v) | 2468 | static inline void cik_didt_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
2394 | { | 2469 | { |
2470 | unsigned long flags; | ||
2471 | |||
2472 | spin_lock_irqsave(&rdev->didt_idx_lock, flags); | ||
2395 | WREG32(CIK_DIDT_IND_INDEX, (reg)); | 2473 | WREG32(CIK_DIDT_IND_INDEX, (reg)); |
2396 | WREG32(CIK_DIDT_IND_DATA, (v)); | 2474 | WREG32(CIK_DIDT_IND_DATA, (v)); |
2475 | spin_unlock_irqrestore(&rdev->didt_idx_lock, flags); | ||
2397 | } | 2476 | } |
2398 | 2477 | ||
2399 | void r100_pll_errata_after_index(struct radeon_device *rdev); | 2478 | void r100_pll_errata_after_index(struct radeon_device *rdev); |
@@ -2569,6 +2648,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v); | |||
2569 | #define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l)) | 2648 | #define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l)) |
2570 | #define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev)) | 2649 | #define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev)) |
2571 | #define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g)) | 2650 | #define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g)) |
2651 | #define radeon_dpm_enable_bapm(rdev, e) rdev->asic->dpm.enable_bapm((rdev), (e)) | ||
2572 | 2652 | ||
2573 | /* Common functions */ | 2653 | /* Common functions */ |
2574 | /* AGP */ | 2654 | /* AGP */ |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index 630853b96841..5003385a7512 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c | |||
@@ -1037,6 +1037,7 @@ static struct radeon_asic rv6xx_asic = { | |||
1037 | .set_pcie_lanes = &r600_set_pcie_lanes, | 1037 | .set_pcie_lanes = &r600_set_pcie_lanes, |
1038 | .set_clock_gating = NULL, | 1038 | .set_clock_gating = NULL, |
1039 | .get_temperature = &rv6xx_get_temp, | 1039 | .get_temperature = &rv6xx_get_temp, |
1040 | .set_uvd_clocks = &r600_set_uvd_clocks, | ||
1040 | }, | 1041 | }, |
1041 | .dpm = { | 1042 | .dpm = { |
1042 | .init = &rv6xx_dpm_init, | 1043 | .init = &rv6xx_dpm_init, |
@@ -1126,6 +1127,7 @@ static struct radeon_asic rs780_asic = { | |||
1126 | .set_pcie_lanes = NULL, | 1127 | .set_pcie_lanes = NULL, |
1127 | .set_clock_gating = NULL, | 1128 | .set_clock_gating = NULL, |
1128 | .get_temperature = &rv6xx_get_temp, | 1129 | .get_temperature = &rv6xx_get_temp, |
1130 | .set_uvd_clocks = &r600_set_uvd_clocks, | ||
1129 | }, | 1131 | }, |
1130 | .dpm = { | 1132 | .dpm = { |
1131 | .init = &rs780_dpm_init, | 1133 | .init = &rs780_dpm_init, |
@@ -1141,6 +1143,7 @@ static struct radeon_asic rs780_asic = { | |||
1141 | .get_mclk = &rs780_dpm_get_mclk, | 1143 | .get_mclk = &rs780_dpm_get_mclk, |
1142 | .print_power_state = &rs780_dpm_print_power_state, | 1144 | .print_power_state = &rs780_dpm_print_power_state, |
1143 | .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level, | 1145 | .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level, |
1146 | .force_performance_level = &rs780_dpm_force_performance_level, | ||
1144 | }, | 1147 | }, |
1145 | .pflip = { | 1148 | .pflip = { |
1146 | .pre_page_flip = &rs600_pre_page_flip, | 1149 | .pre_page_flip = &rs600_pre_page_flip, |
@@ -1791,6 +1794,7 @@ static struct radeon_asic trinity_asic = { | |||
1791 | .print_power_state = &trinity_dpm_print_power_state, | 1794 | .print_power_state = &trinity_dpm_print_power_state, |
1792 | .debugfs_print_current_performance_level = &trinity_dpm_debugfs_print_current_performance_level, | 1795 | .debugfs_print_current_performance_level = &trinity_dpm_debugfs_print_current_performance_level, |
1793 | .force_performance_level = &trinity_dpm_force_performance_level, | 1796 | .force_performance_level = &trinity_dpm_force_performance_level, |
1797 | .enable_bapm = &trinity_dpm_enable_bapm, | ||
1794 | }, | 1798 | }, |
1795 | .pflip = { | 1799 | .pflip = { |
1796 | .pre_page_flip = &evergreen_pre_page_flip, | 1800 | .pre_page_flip = &evergreen_pre_page_flip, |
@@ -2166,6 +2170,7 @@ static struct radeon_asic kv_asic = { | |||
2166 | .debugfs_print_current_performance_level = &kv_dpm_debugfs_print_current_performance_level, | 2170 | .debugfs_print_current_performance_level = &kv_dpm_debugfs_print_current_performance_level, |
2167 | .force_performance_level = &kv_dpm_force_performance_level, | 2171 | .force_performance_level = &kv_dpm_force_performance_level, |
2168 | .powergate_uvd = &kv_dpm_powergate_uvd, | 2172 | .powergate_uvd = &kv_dpm_powergate_uvd, |
2173 | .enable_bapm = &kv_dpm_enable_bapm, | ||
2169 | }, | 2174 | }, |
2170 | .pflip = { | 2175 | .pflip = { |
2171 | .pre_page_flip = &evergreen_pre_page_flip, | 2176 | .pre_page_flip = &evergreen_pre_page_flip, |
@@ -2390,7 +2395,7 @@ int radeon_asic_init(struct radeon_device *rdev) | |||
2390 | RADEON_CG_SUPPORT_HDP_LS | | 2395 | RADEON_CG_SUPPORT_HDP_LS | |
2391 | RADEON_CG_SUPPORT_HDP_MGCG; | 2396 | RADEON_CG_SUPPORT_HDP_MGCG; |
2392 | rdev->pg_flags = 0 | | 2397 | rdev->pg_flags = 0 | |
2393 | /*RADEON_PG_SUPPORT_GFX_CG | */ | 2398 | /*RADEON_PG_SUPPORT_GFX_PG | */ |
2394 | RADEON_PG_SUPPORT_SDMA; | 2399 | RADEON_PG_SUPPORT_SDMA; |
2395 | break; | 2400 | break; |
2396 | case CHIP_OLAND: | 2401 | case CHIP_OLAND: |
@@ -2479,7 +2484,7 @@ int radeon_asic_init(struct radeon_device *rdev) | |||
2479 | RADEON_CG_SUPPORT_HDP_LS | | 2484 | RADEON_CG_SUPPORT_HDP_LS | |
2480 | RADEON_CG_SUPPORT_HDP_MGCG; | 2485 | RADEON_CG_SUPPORT_HDP_MGCG; |
2481 | rdev->pg_flags = 0; | 2486 | rdev->pg_flags = 0; |
2482 | /*RADEON_PG_SUPPORT_GFX_CG | | 2487 | /*RADEON_PG_SUPPORT_GFX_PG | |
2483 | RADEON_PG_SUPPORT_GFX_SMG | | 2488 | RADEON_PG_SUPPORT_GFX_SMG | |
2484 | RADEON_PG_SUPPORT_GFX_DMG | | 2489 | RADEON_PG_SUPPORT_GFX_DMG | |
2485 | RADEON_PG_SUPPORT_UVD | | 2490 | RADEON_PG_SUPPORT_UVD | |
@@ -2507,7 +2512,7 @@ int radeon_asic_init(struct radeon_device *rdev) | |||
2507 | RADEON_CG_SUPPORT_HDP_LS | | 2512 | RADEON_CG_SUPPORT_HDP_LS | |
2508 | RADEON_CG_SUPPORT_HDP_MGCG; | 2513 | RADEON_CG_SUPPORT_HDP_MGCG; |
2509 | rdev->pg_flags = 0; | 2514 | rdev->pg_flags = 0; |
2510 | /*RADEON_PG_SUPPORT_GFX_CG | | 2515 | /*RADEON_PG_SUPPORT_GFX_PG | |
2511 | RADEON_PG_SUPPORT_GFX_SMG | | 2516 | RADEON_PG_SUPPORT_GFX_SMG | |
2512 | RADEON_PG_SUPPORT_UVD | | 2517 | RADEON_PG_SUPPORT_UVD | |
2513 | RADEON_PG_SUPPORT_VCE | | 2518 | RADEON_PG_SUPPORT_VCE | |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 818bbe6b884b..70c29d5e080d 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h | |||
@@ -389,6 +389,7 @@ int r600_mc_wait_for_idle(struct radeon_device *rdev); | |||
389 | u32 r600_get_xclk(struct radeon_device *rdev); | 389 | u32 r600_get_xclk(struct radeon_device *rdev); |
390 | uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev); | 390 | uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev); |
391 | int rv6xx_get_temp(struct radeon_device *rdev); | 391 | int rv6xx_get_temp(struct radeon_device *rdev); |
392 | int r600_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk); | ||
392 | int r600_dpm_pre_set_power_state(struct radeon_device *rdev); | 393 | int r600_dpm_pre_set_power_state(struct radeon_device *rdev); |
393 | void r600_dpm_post_set_power_state(struct radeon_device *rdev); | 394 | void r600_dpm_post_set_power_state(struct radeon_device *rdev); |
394 | /* r600 dma */ | 395 | /* r600 dma */ |
@@ -428,6 +429,8 @@ void rs780_dpm_print_power_state(struct radeon_device *rdev, | |||
428 | struct radeon_ps *ps); | 429 | struct radeon_ps *ps); |
429 | void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, | 430 | void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, |
430 | struct seq_file *m); | 431 | struct seq_file *m); |
432 | int rs780_dpm_force_performance_level(struct radeon_device *rdev, | ||
433 | enum radeon_dpm_forced_level level); | ||
431 | 434 | ||
432 | /* | 435 | /* |
433 | * rv770,rv730,rv710,rv740 | 436 | * rv770,rv730,rv710,rv740 |
@@ -625,6 +628,7 @@ void trinity_dpm_debugfs_print_current_performance_level(struct radeon_device *r | |||
625 | struct seq_file *m); | 628 | struct seq_file *m); |
626 | int trinity_dpm_force_performance_level(struct radeon_device *rdev, | 629 | int trinity_dpm_force_performance_level(struct radeon_device *rdev, |
627 | enum radeon_dpm_forced_level level); | 630 | enum radeon_dpm_forced_level level); |
631 | void trinity_dpm_enable_bapm(struct radeon_device *rdev, bool enable); | ||
628 | 632 | ||
629 | /* DCE6 - SI */ | 633 | /* DCE6 - SI */ |
630 | void dce6_bandwidth_update(struct radeon_device *rdev); | 634 | void dce6_bandwidth_update(struct radeon_device *rdev); |
@@ -781,6 +785,7 @@ void kv_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, | |||
781 | int kv_dpm_force_performance_level(struct radeon_device *rdev, | 785 | int kv_dpm_force_performance_level(struct radeon_device *rdev, |
782 | enum radeon_dpm_forced_level level); | 786 | enum radeon_dpm_forced_level level); |
783 | void kv_dpm_powergate_uvd(struct radeon_device *rdev, bool gate); | 787 | void kv_dpm_powergate_uvd(struct radeon_device *rdev, bool gate); |
788 | void kv_dpm_enable_bapm(struct radeon_device *rdev, bool enable); | ||
784 | 789 | ||
785 | /* uvd v1.0 */ | 790 | /* uvd v1.0 */ |
786 | uint32_t uvd_v1_0_get_rptr(struct radeon_device *rdev, | 791 | uint32_t uvd_v1_0_get_rptr(struct radeon_device *rdev, |
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index 2399f25ec037..79159b5da05b 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c | |||
@@ -396,6 +396,21 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct | |||
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | if (property == rdev->mode_info.audio_property) { | ||
400 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | ||
401 | /* need to find digital encoder on connector */ | ||
402 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | ||
403 | if (!encoder) | ||
404 | return 0; | ||
405 | |||
406 | radeon_encoder = to_radeon_encoder(encoder); | ||
407 | |||
408 | if (radeon_connector->audio != val) { | ||
409 | radeon_connector->audio = val; | ||
410 | radeon_property_change_mode(&radeon_encoder->base); | ||
411 | } | ||
412 | } | ||
413 | |||
399 | if (property == rdev->mode_info.underscan_property) { | 414 | if (property == rdev->mode_info.underscan_property) { |
400 | /* need to find digital encoder on connector */ | 415 | /* need to find digital encoder on connector */ |
401 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | 416 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
@@ -1420,7 +1435,7 @@ radeon_dp_detect(struct drm_connector *connector, bool force) | |||
1420 | if (radeon_dp_getdpcd(radeon_connector)) | 1435 | if (radeon_dp_getdpcd(radeon_connector)) |
1421 | ret = connector_status_connected; | 1436 | ret = connector_status_connected; |
1422 | } else { | 1437 | } else { |
1423 | /* try non-aux ddc (DP to DVI/HMDI/etc. adapter) */ | 1438 | /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */ |
1424 | if (radeon_ddc_probe(radeon_connector, false)) | 1439 | if (radeon_ddc_probe(radeon_connector, false)) |
1425 | ret = connector_status_connected; | 1440 | ret = connector_status_connected; |
1426 | } | 1441 | } |
@@ -1489,6 +1504,24 @@ static const struct drm_connector_funcs radeon_dp_connector_funcs = { | |||
1489 | .force = radeon_dvi_force, | 1504 | .force = radeon_dvi_force, |
1490 | }; | 1505 | }; |
1491 | 1506 | ||
1507 | static const struct drm_connector_funcs radeon_edp_connector_funcs = { | ||
1508 | .dpms = drm_helper_connector_dpms, | ||
1509 | .detect = radeon_dp_detect, | ||
1510 | .fill_modes = drm_helper_probe_single_connector_modes, | ||
1511 | .set_property = radeon_lvds_set_property, | ||
1512 | .destroy = radeon_dp_connector_destroy, | ||
1513 | .force = radeon_dvi_force, | ||
1514 | }; | ||
1515 | |||
1516 | static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = { | ||
1517 | .dpms = drm_helper_connector_dpms, | ||
1518 | .detect = radeon_dp_detect, | ||
1519 | .fill_modes = drm_helper_probe_single_connector_modes, | ||
1520 | .set_property = radeon_lvds_set_property, | ||
1521 | .destroy = radeon_dp_connector_destroy, | ||
1522 | .force = radeon_dvi_force, | ||
1523 | }; | ||
1524 | |||
1492 | void | 1525 | void |
1493 | radeon_add_atom_connector(struct drm_device *dev, | 1526 | radeon_add_atom_connector(struct drm_device *dev, |
1494 | uint32_t connector_id, | 1527 | uint32_t connector_id, |
@@ -1580,8 +1613,6 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1580 | goto failed; | 1613 | goto failed; |
1581 | radeon_dig_connector->igp_lane_info = igp_lane_info; | 1614 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1582 | radeon_connector->con_priv = radeon_dig_connector; | 1615 | radeon_connector->con_priv = radeon_dig_connector; |
1583 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); | ||
1584 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | ||
1585 | if (i2c_bus->valid) { | 1616 | if (i2c_bus->valid) { |
1586 | /* add DP i2c bus */ | 1617 | /* add DP i2c bus */ |
1587 | if (connector_type == DRM_MODE_CONNECTOR_eDP) | 1618 | if (connector_type == DRM_MODE_CONNECTOR_eDP) |
@@ -1598,6 +1629,10 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1598 | case DRM_MODE_CONNECTOR_VGA: | 1629 | case DRM_MODE_CONNECTOR_VGA: |
1599 | case DRM_MODE_CONNECTOR_DVIA: | 1630 | case DRM_MODE_CONNECTOR_DVIA: |
1600 | default: | 1631 | default: |
1632 | drm_connector_init(dev, &radeon_connector->base, | ||
1633 | &radeon_dp_connector_funcs, connector_type); | ||
1634 | drm_connector_helper_add(&radeon_connector->base, | ||
1635 | &radeon_dp_connector_helper_funcs); | ||
1601 | connector->interlace_allowed = true; | 1636 | connector->interlace_allowed = true; |
1602 | connector->doublescan_allowed = true; | 1637 | connector->doublescan_allowed = true; |
1603 | radeon_connector->dac_load_detect = true; | 1638 | radeon_connector->dac_load_detect = true; |
@@ -1610,6 +1645,10 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1610 | case DRM_MODE_CONNECTOR_HDMIA: | 1645 | case DRM_MODE_CONNECTOR_HDMIA: |
1611 | case DRM_MODE_CONNECTOR_HDMIB: | 1646 | case DRM_MODE_CONNECTOR_HDMIB: |
1612 | case DRM_MODE_CONNECTOR_DisplayPort: | 1647 | case DRM_MODE_CONNECTOR_DisplayPort: |
1648 | drm_connector_init(dev, &radeon_connector->base, | ||
1649 | &radeon_dp_connector_funcs, connector_type); | ||
1650 | drm_connector_helper_add(&radeon_connector->base, | ||
1651 | &radeon_dp_connector_helper_funcs); | ||
1613 | drm_object_attach_property(&radeon_connector->base.base, | 1652 | drm_object_attach_property(&radeon_connector->base.base, |
1614 | rdev->mode_info.underscan_property, | 1653 | rdev->mode_info.underscan_property, |
1615 | UNDERSCAN_OFF); | 1654 | UNDERSCAN_OFF); |
@@ -1619,6 +1658,9 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1619 | drm_object_attach_property(&radeon_connector->base.base, | 1658 | drm_object_attach_property(&radeon_connector->base.base, |
1620 | rdev->mode_info.underscan_vborder_property, | 1659 | rdev->mode_info.underscan_vborder_property, |
1621 | 0); | 1660 | 0); |
1661 | drm_object_attach_property(&radeon_connector->base.base, | ||
1662 | rdev->mode_info.audio_property, | ||
1663 | RADEON_AUDIO_DISABLE); | ||
1622 | subpixel_order = SubPixelHorizontalRGB; | 1664 | subpixel_order = SubPixelHorizontalRGB; |
1623 | connector->interlace_allowed = true; | 1665 | connector->interlace_allowed = true; |
1624 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) | 1666 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) |
@@ -1634,6 +1676,10 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1634 | break; | 1676 | break; |
1635 | case DRM_MODE_CONNECTOR_LVDS: | 1677 | case DRM_MODE_CONNECTOR_LVDS: |
1636 | case DRM_MODE_CONNECTOR_eDP: | 1678 | case DRM_MODE_CONNECTOR_eDP: |
1679 | drm_connector_init(dev, &radeon_connector->base, | ||
1680 | &radeon_lvds_bridge_connector_funcs, connector_type); | ||
1681 | drm_connector_helper_add(&radeon_connector->base, | ||
1682 | &radeon_dp_connector_helper_funcs); | ||
1637 | drm_object_attach_property(&radeon_connector->base.base, | 1683 | drm_object_attach_property(&radeon_connector->base.base, |
1638 | dev->mode_config.scaling_mode_property, | 1684 | dev->mode_config.scaling_mode_property, |
1639 | DRM_MODE_SCALE_FULLSCREEN); | 1685 | DRM_MODE_SCALE_FULLSCREEN); |
@@ -1708,6 +1754,11 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1708 | rdev->mode_info.underscan_vborder_property, | 1754 | rdev->mode_info.underscan_vborder_property, |
1709 | 0); | 1755 | 0); |
1710 | } | 1756 | } |
1757 | if (ASIC_IS_DCE2(rdev)) { | ||
1758 | drm_object_attach_property(&radeon_connector->base.base, | ||
1759 | rdev->mode_info.audio_property, | ||
1760 | RADEON_AUDIO_DISABLE); | ||
1761 | } | ||
1711 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { | 1762 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
1712 | radeon_connector->dac_load_detect = true; | 1763 | radeon_connector->dac_load_detect = true; |
1713 | drm_object_attach_property(&radeon_connector->base.base, | 1764 | drm_object_attach_property(&radeon_connector->base.base, |
@@ -1748,6 +1799,11 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1748 | rdev->mode_info.underscan_vborder_property, | 1799 | rdev->mode_info.underscan_vborder_property, |
1749 | 0); | 1800 | 0); |
1750 | } | 1801 | } |
1802 | if (ASIC_IS_DCE2(rdev)) { | ||
1803 | drm_object_attach_property(&radeon_connector->base.base, | ||
1804 | rdev->mode_info.audio_property, | ||
1805 | RADEON_AUDIO_DISABLE); | ||
1806 | } | ||
1751 | subpixel_order = SubPixelHorizontalRGB; | 1807 | subpixel_order = SubPixelHorizontalRGB; |
1752 | connector->interlace_allowed = true; | 1808 | connector->interlace_allowed = true; |
1753 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) | 1809 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) |
@@ -1787,6 +1843,11 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1787 | rdev->mode_info.underscan_vborder_property, | 1843 | rdev->mode_info.underscan_vborder_property, |
1788 | 0); | 1844 | 0); |
1789 | } | 1845 | } |
1846 | if (ASIC_IS_DCE2(rdev)) { | ||
1847 | drm_object_attach_property(&radeon_connector->base.base, | ||
1848 | rdev->mode_info.audio_property, | ||
1849 | RADEON_AUDIO_DISABLE); | ||
1850 | } | ||
1790 | connector->interlace_allowed = true; | 1851 | connector->interlace_allowed = true; |
1791 | /* in theory with a DP to VGA converter... */ | 1852 | /* in theory with a DP to VGA converter... */ |
1792 | connector->doublescan_allowed = false; | 1853 | connector->doublescan_allowed = false; |
@@ -1797,7 +1858,7 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
1797 | goto failed; | 1858 | goto failed; |
1798 | radeon_dig_connector->igp_lane_info = igp_lane_info; | 1859 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1799 | radeon_connector->con_priv = radeon_dig_connector; | 1860 | radeon_connector->con_priv = radeon_dig_connector; |
1800 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); | 1861 | drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type); |
1801 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | 1862 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
1802 | if (i2c_bus->valid) { | 1863 | if (i2c_bus->valid) { |
1803 | /* add DP i2c bus */ | 1864 | /* add DP i2c bus */ |
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index a56084410372..ac6ece61a476 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <drm/radeon_drm.h> | 28 | #include <drm/radeon_drm.h> |
29 | #include "radeon_reg.h" | 29 | #include "radeon_reg.h" |
30 | #include "radeon.h" | 30 | #include "radeon.h" |
31 | #include "radeon_trace.h" | ||
31 | 32 | ||
32 | static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) | 33 | static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) |
33 | { | 34 | { |
@@ -80,9 +81,11 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) | |||
80 | p->relocs[i].lobj.bo = p->relocs[i].robj; | 81 | p->relocs[i].lobj.bo = p->relocs[i].robj; |
81 | p->relocs[i].lobj.written = !!r->write_domain; | 82 | p->relocs[i].lobj.written = !!r->write_domain; |
82 | 83 | ||
83 | /* the first reloc of an UVD job is the | 84 | /* the first reloc of an UVD job is the msg and that must be in |
84 | msg and that must be in VRAM */ | 85 | VRAM, also but everything into VRAM on AGP cards to avoid |
85 | if (p->ring == R600_RING_TYPE_UVD_INDEX && i == 0) { | 86 | image corruptions */ |
87 | if (p->ring == R600_RING_TYPE_UVD_INDEX && | ||
88 | (i == 0 || p->rdev->flags & RADEON_IS_AGP)) { | ||
86 | /* TODO: is this still needed for NI+ ? */ | 89 | /* TODO: is this still needed for NI+ ? */ |
87 | p->relocs[i].lobj.domain = | 90 | p->relocs[i].lobj.domain = |
88 | RADEON_GEM_DOMAIN_VRAM; | 91 | RADEON_GEM_DOMAIN_VRAM; |
@@ -559,6 +562,8 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
559 | return r; | 562 | return r; |
560 | } | 563 | } |
561 | 564 | ||
565 | trace_radeon_cs(&parser); | ||
566 | |||
562 | r = radeon_cs_ib_chunk(rdev, &parser); | 567 | r = radeon_cs_ib_chunk(rdev, &parser); |
563 | if (r) { | 568 | if (r) { |
564 | goto out; | 569 | goto out; |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 16cb8792b1e6..e29faa73b574 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
@@ -1249,6 +1249,17 @@ int radeon_device_init(struct radeon_device *rdev, | |||
1249 | /* Registers mapping */ | 1249 | /* Registers mapping */ |
1250 | /* TODO: block userspace mapping of io register */ | 1250 | /* TODO: block userspace mapping of io register */ |
1251 | spin_lock_init(&rdev->mmio_idx_lock); | 1251 | spin_lock_init(&rdev->mmio_idx_lock); |
1252 | spin_lock_init(&rdev->smc_idx_lock); | ||
1253 | spin_lock_init(&rdev->pll_idx_lock); | ||
1254 | spin_lock_init(&rdev->mc_idx_lock); | ||
1255 | spin_lock_init(&rdev->pcie_idx_lock); | ||
1256 | spin_lock_init(&rdev->pciep_idx_lock); | ||
1257 | spin_lock_init(&rdev->pif_idx_lock); | ||
1258 | spin_lock_init(&rdev->cg_idx_lock); | ||
1259 | spin_lock_init(&rdev->uvd_idx_lock); | ||
1260 | spin_lock_init(&rdev->rcu_idx_lock); | ||
1261 | spin_lock_init(&rdev->didt_idx_lock); | ||
1262 | spin_lock_init(&rdev->end_idx_lock); | ||
1252 | if (rdev->family >= CHIP_BONAIRE) { | 1263 | if (rdev->family >= CHIP_BONAIRE) { |
1253 | rdev->rmmio_base = pci_resource_start(rdev->pdev, 5); | 1264 | rdev->rmmio_base = pci_resource_start(rdev->pdev, 5); |
1254 | rdev->rmmio_size = pci_resource_len(rdev->pdev, 5); | 1265 | rdev->rmmio_size = pci_resource_len(rdev->pdev, 5); |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index b055bddaa94c..0d1aa050d41d 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -1172,6 +1172,12 @@ static struct drm_prop_enum_list radeon_underscan_enum_list[] = | |||
1172 | { UNDERSCAN_AUTO, "auto" }, | 1172 | { UNDERSCAN_AUTO, "auto" }, |
1173 | }; | 1173 | }; |
1174 | 1174 | ||
1175 | static struct drm_prop_enum_list radeon_audio_enum_list[] = | ||
1176 | { { RADEON_AUDIO_DISABLE, "off" }, | ||
1177 | { RADEON_AUDIO_ENABLE, "on" }, | ||
1178 | { RADEON_AUDIO_AUTO, "auto" }, | ||
1179 | }; | ||
1180 | |||
1175 | static int radeon_modeset_create_props(struct radeon_device *rdev) | 1181 | static int radeon_modeset_create_props(struct radeon_device *rdev) |
1176 | { | 1182 | { |
1177 | int sz; | 1183 | int sz; |
@@ -1222,6 +1228,12 @@ static int radeon_modeset_create_props(struct radeon_device *rdev) | |||
1222 | if (!rdev->mode_info.underscan_vborder_property) | 1228 | if (!rdev->mode_info.underscan_vborder_property) |
1223 | return -ENOMEM; | 1229 | return -ENOMEM; |
1224 | 1230 | ||
1231 | sz = ARRAY_SIZE(radeon_audio_enum_list); | ||
1232 | rdev->mode_info.audio_property = | ||
1233 | drm_property_create_enum(rdev->ddev, 0, | ||
1234 | "audio", | ||
1235 | radeon_audio_enum_list, sz); | ||
1236 | |||
1225 | return 0; | 1237 | return 0; |
1226 | } | 1238 | } |
1227 | 1239 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index cb4445f55a96..cdd12dcd988b 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
@@ -153,7 +153,7 @@ int radeon_benchmarking = 0; | |||
153 | int radeon_testing = 0; | 153 | int radeon_testing = 0; |
154 | int radeon_connector_table = 0; | 154 | int radeon_connector_table = 0; |
155 | int radeon_tv = 1; | 155 | int radeon_tv = 1; |
156 | int radeon_audio = 0; | 156 | int radeon_audio = 1; |
157 | int radeon_disp_priority = 0; | 157 | int radeon_disp_priority = 0; |
158 | int radeon_hw_i2c = 0; | 158 | int radeon_hw_i2c = 0; |
159 | int radeon_pcie_gen2 = -1; | 159 | int radeon_pcie_gen2 = -1; |
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h index d908d8d68f6b..ef63d3f00b2f 100644 --- a/drivers/gpu/drm/radeon/radeon_mode.h +++ b/drivers/gpu/drm/radeon/radeon_mode.h | |||
@@ -247,6 +247,8 @@ struct radeon_mode_info { | |||
247 | struct drm_property *underscan_property; | 247 | struct drm_property *underscan_property; |
248 | struct drm_property *underscan_hborder_property; | 248 | struct drm_property *underscan_hborder_property; |
249 | struct drm_property *underscan_vborder_property; | 249 | struct drm_property *underscan_vborder_property; |
250 | /* audio */ | ||
251 | struct drm_property *audio_property; | ||
250 | /* hardcoded DFP edid from BIOS */ | 252 | /* hardcoded DFP edid from BIOS */ |
251 | struct edid *bios_hardcoded_edid; | 253 | struct edid *bios_hardcoded_edid; |
252 | int bios_hardcoded_edid_size; | 254 | int bios_hardcoded_edid_size; |
@@ -471,6 +473,12 @@ struct radeon_router { | |||
471 | u8 cd_mux_state; | 473 | u8 cd_mux_state; |
472 | }; | 474 | }; |
473 | 475 | ||
476 | enum radeon_connector_audio { | ||
477 | RADEON_AUDIO_DISABLE = 0, | ||
478 | RADEON_AUDIO_ENABLE = 1, | ||
479 | RADEON_AUDIO_AUTO = 2 | ||
480 | }; | ||
481 | |||
474 | struct radeon_connector { | 482 | struct radeon_connector { |
475 | struct drm_connector base; | 483 | struct drm_connector base; |
476 | uint32_t connector_id; | 484 | uint32_t connector_id; |
@@ -489,6 +497,7 @@ struct radeon_connector { | |||
489 | struct radeon_hpd hpd; | 497 | struct radeon_hpd hpd; |
490 | struct radeon_router router; | 498 | struct radeon_router router; |
491 | struct radeon_i2c_chan *router_bus; | 499 | struct radeon_i2c_chan *router_bus; |
500 | enum radeon_connector_audio audio; | ||
492 | }; | 501 | }; |
493 | 502 | ||
494 | struct radeon_framebuffer { | 503 | struct radeon_framebuffer { |
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index d7555369a3e5..87e1d69e8fdb 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -67,7 +67,16 @@ int radeon_pm_get_type_index(struct radeon_device *rdev, | |||
67 | 67 | ||
68 | void radeon_pm_acpi_event_handler(struct radeon_device *rdev) | 68 | void radeon_pm_acpi_event_handler(struct radeon_device *rdev) |
69 | { | 69 | { |
70 | if (rdev->pm.pm_method == PM_METHOD_PROFILE) { | 70 | if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) { |
71 | mutex_lock(&rdev->pm.mutex); | ||
72 | if (power_supply_is_system_supplied() > 0) | ||
73 | rdev->pm.dpm.ac_power = true; | ||
74 | else | ||
75 | rdev->pm.dpm.ac_power = false; | ||
76 | if (rdev->asic->dpm.enable_bapm) | ||
77 | radeon_dpm_enable_bapm(rdev, rdev->pm.dpm.ac_power); | ||
78 | mutex_unlock(&rdev->pm.mutex); | ||
79 | } else if (rdev->pm.pm_method == PM_METHOD_PROFILE) { | ||
71 | if (rdev->pm.profile == PM_PROFILE_AUTO) { | 80 | if (rdev->pm.profile == PM_PROFILE_AUTO) { |
72 | mutex_lock(&rdev->pm.mutex); | 81 | mutex_lock(&rdev->pm.mutex); |
73 | radeon_pm_update_profile(rdev); | 82 | radeon_pm_update_profile(rdev); |
@@ -333,7 +342,7 @@ static ssize_t radeon_get_pm_profile(struct device *dev, | |||
333 | struct device_attribute *attr, | 342 | struct device_attribute *attr, |
334 | char *buf) | 343 | char *buf) |
335 | { | 344 | { |
336 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 345 | struct drm_device *ddev = dev_get_drvdata(dev); |
337 | struct radeon_device *rdev = ddev->dev_private; | 346 | struct radeon_device *rdev = ddev->dev_private; |
338 | int cp = rdev->pm.profile; | 347 | int cp = rdev->pm.profile; |
339 | 348 | ||
@@ -349,7 +358,7 @@ static ssize_t radeon_set_pm_profile(struct device *dev, | |||
349 | const char *buf, | 358 | const char *buf, |
350 | size_t count) | 359 | size_t count) |
351 | { | 360 | { |
352 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 361 | struct drm_device *ddev = dev_get_drvdata(dev); |
353 | struct radeon_device *rdev = ddev->dev_private; | 362 | struct radeon_device *rdev = ddev->dev_private; |
354 | 363 | ||
355 | mutex_lock(&rdev->pm.mutex); | 364 | mutex_lock(&rdev->pm.mutex); |
@@ -383,7 +392,7 @@ static ssize_t radeon_get_pm_method(struct device *dev, | |||
383 | struct device_attribute *attr, | 392 | struct device_attribute *attr, |
384 | char *buf) | 393 | char *buf) |
385 | { | 394 | { |
386 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 395 | struct drm_device *ddev = dev_get_drvdata(dev); |
387 | struct radeon_device *rdev = ddev->dev_private; | 396 | struct radeon_device *rdev = ddev->dev_private; |
388 | int pm = rdev->pm.pm_method; | 397 | int pm = rdev->pm.pm_method; |
389 | 398 | ||
@@ -397,7 +406,7 @@ static ssize_t radeon_set_pm_method(struct device *dev, | |||
397 | const char *buf, | 406 | const char *buf, |
398 | size_t count) | 407 | size_t count) |
399 | { | 408 | { |
400 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 409 | struct drm_device *ddev = dev_get_drvdata(dev); |
401 | struct radeon_device *rdev = ddev->dev_private; | 410 | struct radeon_device *rdev = ddev->dev_private; |
402 | 411 | ||
403 | /* we don't support the legacy modes with dpm */ | 412 | /* we don't support the legacy modes with dpm */ |
@@ -433,7 +442,7 @@ static ssize_t radeon_get_dpm_state(struct device *dev, | |||
433 | struct device_attribute *attr, | 442 | struct device_attribute *attr, |
434 | char *buf) | 443 | char *buf) |
435 | { | 444 | { |
436 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 445 | struct drm_device *ddev = dev_get_drvdata(dev); |
437 | struct radeon_device *rdev = ddev->dev_private; | 446 | struct radeon_device *rdev = ddev->dev_private; |
438 | enum radeon_pm_state_type pm = rdev->pm.dpm.user_state; | 447 | enum radeon_pm_state_type pm = rdev->pm.dpm.user_state; |
439 | 448 | ||
@@ -447,7 +456,7 @@ static ssize_t radeon_set_dpm_state(struct device *dev, | |||
447 | const char *buf, | 456 | const char *buf, |
448 | size_t count) | 457 | size_t count) |
449 | { | 458 | { |
450 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 459 | struct drm_device *ddev = dev_get_drvdata(dev); |
451 | struct radeon_device *rdev = ddev->dev_private; | 460 | struct radeon_device *rdev = ddev->dev_private; |
452 | 461 | ||
453 | mutex_lock(&rdev->pm.mutex); | 462 | mutex_lock(&rdev->pm.mutex); |
@@ -472,7 +481,7 @@ static ssize_t radeon_get_dpm_forced_performance_level(struct device *dev, | |||
472 | struct device_attribute *attr, | 481 | struct device_attribute *attr, |
473 | char *buf) | 482 | char *buf) |
474 | { | 483 | { |
475 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 484 | struct drm_device *ddev = dev_get_drvdata(dev); |
476 | struct radeon_device *rdev = ddev->dev_private; | 485 | struct radeon_device *rdev = ddev->dev_private; |
477 | enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level; | 486 | enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level; |
478 | 487 | ||
@@ -486,7 +495,7 @@ static ssize_t radeon_set_dpm_forced_performance_level(struct device *dev, | |||
486 | const char *buf, | 495 | const char *buf, |
487 | size_t count) | 496 | size_t count) |
488 | { | 497 | { |
489 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 498 | struct drm_device *ddev = dev_get_drvdata(dev); |
490 | struct radeon_device *rdev = ddev->dev_private; | 499 | struct radeon_device *rdev = ddev->dev_private; |
491 | enum radeon_dpm_forced_level level; | 500 | enum radeon_dpm_forced_level level; |
492 | int ret = 0; | 501 | int ret = 0; |
@@ -524,7 +533,7 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, | |||
524 | struct device_attribute *attr, | 533 | struct device_attribute *attr, |
525 | char *buf) | 534 | char *buf) |
526 | { | 535 | { |
527 | struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); | 536 | struct drm_device *ddev = dev_get_drvdata(dev); |
528 | struct radeon_device *rdev = ddev->dev_private; | 537 | struct radeon_device *rdev = ddev->dev_private; |
529 | int temp; | 538 | int temp; |
530 | 539 | ||
@@ -536,6 +545,23 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, | |||
536 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); | 545 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); |
537 | } | 546 | } |
538 | 547 | ||
548 | static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev, | ||
549 | struct device_attribute *attr, | ||
550 | char *buf) | ||
551 | { | ||
552 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
553 | struct radeon_device *rdev = ddev->dev_private; | ||
554 | int hyst = to_sensor_dev_attr(attr)->index; | ||
555 | int temp; | ||
556 | |||
557 | if (hyst) | ||
558 | temp = rdev->pm.dpm.thermal.min_temp; | ||
559 | else | ||
560 | temp = rdev->pm.dpm.thermal.max_temp; | ||
561 | |||
562 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); | ||
563 | } | ||
564 | |||
539 | static ssize_t radeon_hwmon_show_name(struct device *dev, | 565 | static ssize_t radeon_hwmon_show_name(struct device *dev, |
540 | struct device_attribute *attr, | 566 | struct device_attribute *attr, |
541 | char *buf) | 567 | char *buf) |
@@ -544,16 +570,37 @@ static ssize_t radeon_hwmon_show_name(struct device *dev, | |||
544 | } | 570 | } |
545 | 571 | ||
546 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); | 572 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); |
573 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); | ||
574 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); | ||
547 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); | 575 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); |
548 | 576 | ||
549 | static struct attribute *hwmon_attributes[] = { | 577 | static struct attribute *hwmon_attributes[] = { |
550 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 578 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
579 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | ||
580 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | ||
551 | &sensor_dev_attr_name.dev_attr.attr, | 581 | &sensor_dev_attr_name.dev_attr.attr, |
552 | NULL | 582 | NULL |
553 | }; | 583 | }; |
554 | 584 | ||
585 | static umode_t hwmon_attributes_visible(struct kobject *kobj, | ||
586 | struct attribute *attr, int index) | ||
587 | { | ||
588 | struct device *dev = container_of(kobj, struct device, kobj); | ||
589 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
590 | struct radeon_device *rdev = ddev->dev_private; | ||
591 | |||
592 | /* Skip limit attributes if DPM is not enabled */ | ||
593 | if (rdev->pm.pm_method != PM_METHOD_DPM && | ||
594 | (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || | ||
595 | attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr)) | ||
596 | return 0; | ||
597 | |||
598 | return attr->mode; | ||
599 | } | ||
600 | |||
555 | static const struct attribute_group hwmon_attrgroup = { | 601 | static const struct attribute_group hwmon_attrgroup = { |
556 | .attrs = hwmon_attributes, | 602 | .attrs = hwmon_attributes, |
603 | .is_visible = hwmon_attributes_visible, | ||
557 | }; | 604 | }; |
558 | 605 | ||
559 | static int radeon_hwmon_init(struct radeon_device *rdev) | 606 | static int radeon_hwmon_init(struct radeon_device *rdev) |
@@ -870,10 +917,13 @@ static void radeon_dpm_change_power_state_locked(struct radeon_device *rdev) | |||
870 | 917 | ||
871 | radeon_dpm_post_set_power_state(rdev); | 918 | radeon_dpm_post_set_power_state(rdev); |
872 | 919 | ||
873 | /* force low perf level for thermal */ | 920 | if (rdev->asic->dpm.force_performance_level) { |
874 | if (rdev->pm.dpm.thermal_active && | 921 | if (rdev->pm.dpm.thermal_active) |
875 | rdev->asic->dpm.force_performance_level) { | 922 | /* force low perf level for thermal */ |
876 | radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_LOW); | 923 | radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_LOW); |
924 | else | ||
925 | /* otherwise, enable auto */ | ||
926 | radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
877 | } | 927 | } |
878 | 928 | ||
879 | done: | 929 | done: |
@@ -1102,9 +1152,10 @@ static int radeon_pm_init_dpm(struct radeon_device *rdev) | |||
1102 | { | 1152 | { |
1103 | int ret; | 1153 | int ret; |
1104 | 1154 | ||
1105 | /* default to performance state */ | 1155 | /* default to balanced state */ |
1106 | rdev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; | 1156 | rdev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; |
1107 | rdev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; | 1157 | rdev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; |
1158 | rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO; | ||
1108 | rdev->pm.default_sclk = rdev->clock.default_sclk; | 1159 | rdev->pm.default_sclk = rdev->clock.default_sclk; |
1109 | rdev->pm.default_mclk = rdev->clock.default_mclk; | 1160 | rdev->pm.default_mclk = rdev->clock.default_mclk; |
1110 | rdev->pm.current_sclk = rdev->clock.default_sclk; | 1161 | rdev->pm.current_sclk = rdev->clock.default_sclk; |
diff --git a/drivers/gpu/drm/radeon/radeon_trace.h b/drivers/gpu/drm/radeon/radeon_trace.h index eafd8160a155..f7e367815964 100644 --- a/drivers/gpu/drm/radeon/radeon_trace.h +++ b/drivers/gpu/drm/radeon/radeon_trace.h | |||
@@ -27,6 +27,26 @@ TRACE_EVENT(radeon_bo_create, | |||
27 | TP_printk("bo=%p, pages=%u", __entry->bo, __entry->pages) | 27 | TP_printk("bo=%p, pages=%u", __entry->bo, __entry->pages) |
28 | ); | 28 | ); |
29 | 29 | ||
30 | TRACE_EVENT(radeon_cs, | ||
31 | TP_PROTO(struct radeon_cs_parser *p), | ||
32 | TP_ARGS(p), | ||
33 | TP_STRUCT__entry( | ||
34 | __field(u32, ring) | ||
35 | __field(u32, dw) | ||
36 | __field(u32, fences) | ||
37 | ), | ||
38 | |||
39 | TP_fast_assign( | ||
40 | __entry->ring = p->ring; | ||
41 | __entry->dw = p->chunks[p->chunk_ib_idx].length_dw; | ||
42 | __entry->fences = radeon_fence_count_emitted( | ||
43 | p->rdev, p->ring); | ||
44 | ), | ||
45 | TP_printk("ring=%u, dw=%u, fences=%u", | ||
46 | __entry->ring, __entry->dw, | ||
47 | __entry->fences) | ||
48 | ); | ||
49 | |||
30 | DECLARE_EVENT_CLASS(radeon_fence_request, | 50 | DECLARE_EVENT_CLASS(radeon_fence_request, |
31 | 51 | ||
32 | TP_PROTO(struct drm_device *dev, u32 seqno), | 52 | TP_PROTO(struct drm_device *dev, u32 seqno), |
@@ -53,13 +73,6 @@ DEFINE_EVENT(radeon_fence_request, radeon_fence_emit, | |||
53 | TP_ARGS(dev, seqno) | 73 | TP_ARGS(dev, seqno) |
54 | ); | 74 | ); |
55 | 75 | ||
56 | DEFINE_EVENT(radeon_fence_request, radeon_fence_retire, | ||
57 | |||
58 | TP_PROTO(struct drm_device *dev, u32 seqno), | ||
59 | |||
60 | TP_ARGS(dev, seqno) | ||
61 | ); | ||
62 | |||
63 | DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_begin, | 76 | DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_begin, |
64 | 77 | ||
65 | TP_PROTO(struct drm_device *dev, u32 seqno), | 78 | TP_PROTO(struct drm_device *dev, u32 seqno), |
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c index b8074a8ec75a..9566b5940a5a 100644 --- a/drivers/gpu/drm/radeon/rs400.c +++ b/drivers/gpu/drm/radeon/rs400.c | |||
@@ -274,19 +274,26 @@ static void rs400_mc_init(struct radeon_device *rdev) | |||
274 | 274 | ||
275 | uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 275 | uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
276 | { | 276 | { |
277 | unsigned long flags; | ||
277 | uint32_t r; | 278 | uint32_t r; |
278 | 279 | ||
280 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
279 | WREG32(RS480_NB_MC_INDEX, reg & 0xff); | 281 | WREG32(RS480_NB_MC_INDEX, reg & 0xff); |
280 | r = RREG32(RS480_NB_MC_DATA); | 282 | r = RREG32(RS480_NB_MC_DATA); |
281 | WREG32(RS480_NB_MC_INDEX, 0xff); | 283 | WREG32(RS480_NB_MC_INDEX, 0xff); |
284 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
282 | return r; | 285 | return r; |
283 | } | 286 | } |
284 | 287 | ||
285 | void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 288 | void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
286 | { | 289 | { |
290 | unsigned long flags; | ||
291 | |||
292 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
287 | WREG32(RS480_NB_MC_INDEX, ((reg) & 0xff) | RS480_NB_MC_IND_WR_EN); | 293 | WREG32(RS480_NB_MC_INDEX, ((reg) & 0xff) | RS480_NB_MC_IND_WR_EN); |
288 | WREG32(RS480_NB_MC_DATA, (v)); | 294 | WREG32(RS480_NB_MC_DATA, (v)); |
289 | WREG32(RS480_NB_MC_INDEX, 0xff); | 295 | WREG32(RS480_NB_MC_INDEX, 0xff); |
296 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
290 | } | 297 | } |
291 | 298 | ||
292 | #if defined(CONFIG_DEBUG_FS) | 299 | #if defined(CONFIG_DEBUG_FS) |
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c index 670b555d2ca2..6acba8017b9a 100644 --- a/drivers/gpu/drm/radeon/rs600.c +++ b/drivers/gpu/drm/radeon/rs600.c | |||
@@ -847,16 +847,26 @@ void rs600_bandwidth_update(struct radeon_device *rdev) | |||
847 | 847 | ||
848 | uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 848 | uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
849 | { | 849 | { |
850 | unsigned long flags; | ||
851 | u32 r; | ||
852 | |||
853 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
850 | WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | | 854 | WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | |
851 | S_000070_MC_IND_CITF_ARB0(1)); | 855 | S_000070_MC_IND_CITF_ARB0(1)); |
852 | return RREG32(R_000074_MC_IND_DATA); | 856 | r = RREG32(R_000074_MC_IND_DATA); |
857 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
858 | return r; | ||
853 | } | 859 | } |
854 | 860 | ||
855 | void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 861 | void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
856 | { | 862 | { |
863 | unsigned long flags; | ||
864 | |||
865 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
857 | WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | | 866 | WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | |
858 | S_000070_MC_IND_CITF_ARB0(1) | S_000070_MC_IND_WR_EN(1)); | 867 | S_000070_MC_IND_CITF_ARB0(1) | S_000070_MC_IND_WR_EN(1)); |
859 | WREG32(R_000074_MC_IND_DATA, v); | 868 | WREG32(R_000074_MC_IND_DATA, v); |
869 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
860 | } | 870 | } |
861 | 871 | ||
862 | static void rs600_debugfs(struct radeon_device *rdev) | 872 | static void rs600_debugfs(struct radeon_device *rdev) |
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c index d8ddfb34545d..1447d794c22a 100644 --- a/drivers/gpu/drm/radeon/rs690.c +++ b/drivers/gpu/drm/radeon/rs690.c | |||
@@ -631,20 +631,27 @@ void rs690_bandwidth_update(struct radeon_device *rdev) | |||
631 | 631 | ||
632 | uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 632 | uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
633 | { | 633 | { |
634 | unsigned long flags; | ||
634 | uint32_t r; | 635 | uint32_t r; |
635 | 636 | ||
637 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
636 | WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg)); | 638 | WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg)); |
637 | r = RREG32(R_00007C_MC_DATA); | 639 | r = RREG32(R_00007C_MC_DATA); |
638 | WREG32(R_000078_MC_INDEX, ~C_000078_MC_IND_ADDR); | 640 | WREG32(R_000078_MC_INDEX, ~C_000078_MC_IND_ADDR); |
641 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
639 | return r; | 642 | return r; |
640 | } | 643 | } |
641 | 644 | ||
642 | void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 645 | void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
643 | { | 646 | { |
647 | unsigned long flags; | ||
648 | |||
649 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
644 | WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg) | | 650 | WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg) | |
645 | S_000078_MC_IND_WR_EN(1)); | 651 | S_000078_MC_IND_WR_EN(1)); |
646 | WREG32(R_00007C_MC_DATA, v); | 652 | WREG32(R_00007C_MC_DATA, v); |
647 | WREG32(R_000078_MC_INDEX, 0x7F); | 653 | WREG32(R_000078_MC_INDEX, 0x7F); |
654 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
648 | } | 655 | } |
649 | 656 | ||
650 | static void rs690_mc_program(struct radeon_device *rdev) | 657 | static void rs690_mc_program(struct radeon_device *rdev) |
diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c index d1a1ce73bd45..6af8505cf4d2 100644 --- a/drivers/gpu/drm/radeon/rs780_dpm.c +++ b/drivers/gpu/drm/radeon/rs780_dpm.c | |||
@@ -62,9 +62,7 @@ static void rs780_get_pm_mode_parameters(struct radeon_device *rdev) | |||
62 | radeon_crtc = to_radeon_crtc(crtc); | 62 | radeon_crtc = to_radeon_crtc(crtc); |
63 | pi->crtc_id = radeon_crtc->crtc_id; | 63 | pi->crtc_id = radeon_crtc->crtc_id; |
64 | if (crtc->mode.htotal && crtc->mode.vtotal) | 64 | if (crtc->mode.htotal && crtc->mode.vtotal) |
65 | pi->refresh_rate = | 65 | pi->refresh_rate = drm_mode_vrefresh(&crtc->mode); |
66 | (crtc->mode.clock * 1000) / | ||
67 | (crtc->mode.htotal * crtc->mode.vtotal); | ||
68 | break; | 66 | break; |
69 | } | 67 | } |
70 | } | 68 | } |
@@ -376,9 +374,8 @@ static void rs780_disable_vbios_powersaving(struct radeon_device *rdev) | |||
376 | WREG32_P(CG_INTGFX_MISC, 0, ~0xFFF00000); | 374 | WREG32_P(CG_INTGFX_MISC, 0, ~0xFFF00000); |
377 | } | 375 | } |
378 | 376 | ||
379 | static void rs780_force_voltage_to_high(struct radeon_device *rdev) | 377 | static void rs780_force_voltage(struct radeon_device *rdev, u16 voltage) |
380 | { | 378 | { |
381 | struct igp_power_info *pi = rs780_get_pi(rdev); | ||
382 | struct igp_ps *current_state = rs780_get_ps(rdev->pm.dpm.current_ps); | 379 | struct igp_ps *current_state = rs780_get_ps(rdev->pm.dpm.current_ps); |
383 | 380 | ||
384 | if ((current_state->max_voltage == RS780_VDDC_LEVEL_HIGH) && | 381 | if ((current_state->max_voltage == RS780_VDDC_LEVEL_HIGH) && |
@@ -390,7 +387,7 @@ static void rs780_force_voltage_to_high(struct radeon_device *rdev) | |||
390 | udelay(1); | 387 | udelay(1); |
391 | 388 | ||
392 | WREG32_P(FVTHROT_PWM_CTRL_REG0, | 389 | WREG32_P(FVTHROT_PWM_CTRL_REG0, |
393 | STARTING_PWM_HIGHTIME(pi->max_voltage), | 390 | STARTING_PWM_HIGHTIME(voltage), |
394 | ~STARTING_PWM_HIGHTIME_MASK); | 391 | ~STARTING_PWM_HIGHTIME_MASK); |
395 | 392 | ||
396 | WREG32_P(FVTHROT_PWM_CTRL_REG0, | 393 | WREG32_P(FVTHROT_PWM_CTRL_REG0, |
@@ -404,6 +401,26 @@ static void rs780_force_voltage_to_high(struct radeon_device *rdev) | |||
404 | WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL); | 401 | WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL); |
405 | } | 402 | } |
406 | 403 | ||
404 | static void rs780_force_fbdiv(struct radeon_device *rdev, u32 fb_div) | ||
405 | { | ||
406 | struct igp_ps *current_state = rs780_get_ps(rdev->pm.dpm.current_ps); | ||
407 | |||
408 | if (current_state->sclk_low == current_state->sclk_high) | ||
409 | return; | ||
410 | |||
411 | WREG32_P(GFX_MACRO_BYPASS_CNTL, SPLL_BYPASS_CNTL, ~SPLL_BYPASS_CNTL); | ||
412 | |||
413 | WREG32_P(FVTHROT_FBDIV_REG2, FORCED_FEEDBACK_DIV(fb_div), | ||
414 | ~FORCED_FEEDBACK_DIV_MASK); | ||
415 | WREG32_P(FVTHROT_FBDIV_REG1, STARTING_FEEDBACK_DIV(fb_div), | ||
416 | ~STARTING_FEEDBACK_DIV_MASK); | ||
417 | WREG32_P(FVTHROT_FBDIV_REG1, FORCE_FEEDBACK_DIV, ~FORCE_FEEDBACK_DIV); | ||
418 | |||
419 | udelay(100); | ||
420 | |||
421 | WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL); | ||
422 | } | ||
423 | |||
407 | static int rs780_set_engine_clock_scaling(struct radeon_device *rdev, | 424 | static int rs780_set_engine_clock_scaling(struct radeon_device *rdev, |
408 | struct radeon_ps *new_ps, | 425 | struct radeon_ps *new_ps, |
409 | struct radeon_ps *old_ps) | 426 | struct radeon_ps *old_ps) |
@@ -432,17 +449,13 @@ static int rs780_set_engine_clock_scaling(struct radeon_device *rdev, | |||
432 | if (ret) | 449 | if (ret) |
433 | return ret; | 450 | return ret; |
434 | 451 | ||
435 | WREG32_P(GFX_MACRO_BYPASS_CNTL, SPLL_BYPASS_CNTL, ~SPLL_BYPASS_CNTL); | 452 | if ((min_dividers.ref_div != max_dividers.ref_div) || |
436 | 453 | (min_dividers.post_div != max_dividers.post_div) || | |
437 | WREG32_P(FVTHROT_FBDIV_REG2, FORCED_FEEDBACK_DIV(max_dividers.fb_div), | 454 | (max_dividers.ref_div != current_max_dividers.ref_div) || |
438 | ~FORCED_FEEDBACK_DIV_MASK); | 455 | (max_dividers.post_div != current_max_dividers.post_div)) |
439 | WREG32_P(FVTHROT_FBDIV_REG1, STARTING_FEEDBACK_DIV(max_dividers.fb_div), | 456 | return -EINVAL; |
440 | ~STARTING_FEEDBACK_DIV_MASK); | ||
441 | WREG32_P(FVTHROT_FBDIV_REG1, FORCE_FEEDBACK_DIV, ~FORCE_FEEDBACK_DIV); | ||
442 | |||
443 | udelay(100); | ||
444 | 457 | ||
445 | WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL); | 458 | rs780_force_fbdiv(rdev, max_dividers.fb_div); |
446 | 459 | ||
447 | if (max_dividers.fb_div > min_dividers.fb_div) { | 460 | if (max_dividers.fb_div > min_dividers.fb_div) { |
448 | WREG32_P(FVTHROT_FBDIV_REG0, | 461 | WREG32_P(FVTHROT_FBDIV_REG0, |
@@ -486,6 +499,9 @@ static void rs780_activate_engine_clk_scaling(struct radeon_device *rdev, | |||
486 | (new_state->sclk_low == old_state->sclk_low)) | 499 | (new_state->sclk_low == old_state->sclk_low)) |
487 | return; | 500 | return; |
488 | 501 | ||
502 | if (new_state->sclk_high == new_state->sclk_low) | ||
503 | return; | ||
504 | |||
489 | rs780_clk_scaling_enable(rdev, true); | 505 | rs780_clk_scaling_enable(rdev, true); |
490 | } | 506 | } |
491 | 507 | ||
@@ -649,7 +665,7 @@ int rs780_dpm_set_power_state(struct radeon_device *rdev) | |||
649 | rs780_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); | 665 | rs780_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); |
650 | 666 | ||
651 | if (pi->voltage_control) { | 667 | if (pi->voltage_control) { |
652 | rs780_force_voltage_to_high(rdev); | 668 | rs780_force_voltage(rdev, pi->max_voltage); |
653 | mdelay(5); | 669 | mdelay(5); |
654 | } | 670 | } |
655 | 671 | ||
@@ -717,14 +733,18 @@ static void rs780_parse_pplib_non_clock_info(struct radeon_device *rdev, | |||
717 | if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { | 733 | if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { |
718 | rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); | 734 | rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); |
719 | rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); | 735 | rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); |
720 | } else if (r600_is_uvd_state(rps->class, rps->class2)) { | ||
721 | rps->vclk = RS780_DEFAULT_VCLK_FREQ; | ||
722 | rps->dclk = RS780_DEFAULT_DCLK_FREQ; | ||
723 | } else { | 736 | } else { |
724 | rps->vclk = 0; | 737 | rps->vclk = 0; |
725 | rps->dclk = 0; | 738 | rps->dclk = 0; |
726 | } | 739 | } |
727 | 740 | ||
741 | if (r600_is_uvd_state(rps->class, rps->class2)) { | ||
742 | if ((rps->vclk == 0) || (rps->dclk == 0)) { | ||
743 | rps->vclk = RS780_DEFAULT_VCLK_FREQ; | ||
744 | rps->dclk = RS780_DEFAULT_DCLK_FREQ; | ||
745 | } | ||
746 | } | ||
747 | |||
728 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) | 748 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) |
729 | rdev->pm.dpm.boot_ps = rps; | 749 | rdev->pm.dpm.boot_ps = rps; |
730 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) | 750 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) |
@@ -986,3 +1006,55 @@ void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rde | |||
986 | seq_printf(m, "power level 1 sclk: %u vddc_index: %d\n", | 1006 | seq_printf(m, "power level 1 sclk: %u vddc_index: %d\n", |
987 | ps->sclk_high, ps->max_voltage); | 1007 | ps->sclk_high, ps->max_voltage); |
988 | } | 1008 | } |
1009 | |||
1010 | int rs780_dpm_force_performance_level(struct radeon_device *rdev, | ||
1011 | enum radeon_dpm_forced_level level) | ||
1012 | { | ||
1013 | struct igp_power_info *pi = rs780_get_pi(rdev); | ||
1014 | struct radeon_ps *rps = rdev->pm.dpm.current_ps; | ||
1015 | struct igp_ps *ps = rs780_get_ps(rps); | ||
1016 | struct atom_clock_dividers dividers; | ||
1017 | int ret; | ||
1018 | |||
1019 | rs780_clk_scaling_enable(rdev, false); | ||
1020 | rs780_voltage_scaling_enable(rdev, false); | ||
1021 | |||
1022 | if (level == RADEON_DPM_FORCED_LEVEL_HIGH) { | ||
1023 | if (pi->voltage_control) | ||
1024 | rs780_force_voltage(rdev, pi->max_voltage); | ||
1025 | |||
1026 | ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM, | ||
1027 | ps->sclk_high, false, ÷rs); | ||
1028 | if (ret) | ||
1029 | return ret; | ||
1030 | |||
1031 | rs780_force_fbdiv(rdev, dividers.fb_div); | ||
1032 | } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) { | ||
1033 | ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM, | ||
1034 | ps->sclk_low, false, ÷rs); | ||
1035 | if (ret) | ||
1036 | return ret; | ||
1037 | |||
1038 | rs780_force_fbdiv(rdev, dividers.fb_div); | ||
1039 | |||
1040 | if (pi->voltage_control) | ||
1041 | rs780_force_voltage(rdev, pi->min_voltage); | ||
1042 | } else { | ||
1043 | if (pi->voltage_control) | ||
1044 | rs780_force_voltage(rdev, pi->max_voltage); | ||
1045 | |||
1046 | if (ps->sclk_high != ps->sclk_low) { | ||
1047 | WREG32_P(FVTHROT_FBDIV_REG1, 0, ~FORCE_FEEDBACK_DIV); | ||
1048 | rs780_clk_scaling_enable(rdev, true); | ||
1049 | } | ||
1050 | |||
1051 | if (pi->voltage_control) { | ||
1052 | rs780_voltage_scaling_enable(rdev, true); | ||
1053 | rs780_enable_voltage_scaling(rdev, rps); | ||
1054 | } | ||
1055 | } | ||
1056 | |||
1057 | rdev->pm.dpm.forced_level = level; | ||
1058 | |||
1059 | return 0; | ||
1060 | } | ||
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c index 8ea1573ae820..873eb4b193b4 100644 --- a/drivers/gpu/drm/radeon/rv515.c +++ b/drivers/gpu/drm/radeon/rv515.c | |||
@@ -209,19 +209,27 @@ static void rv515_mc_init(struct radeon_device *rdev) | |||
209 | 209 | ||
210 | uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 210 | uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
211 | { | 211 | { |
212 | unsigned long flags; | ||
212 | uint32_t r; | 213 | uint32_t r; |
213 | 214 | ||
215 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
214 | WREG32(MC_IND_INDEX, 0x7f0000 | (reg & 0xffff)); | 216 | WREG32(MC_IND_INDEX, 0x7f0000 | (reg & 0xffff)); |
215 | r = RREG32(MC_IND_DATA); | 217 | r = RREG32(MC_IND_DATA); |
216 | WREG32(MC_IND_INDEX, 0); | 218 | WREG32(MC_IND_INDEX, 0); |
219 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
220 | |||
217 | return r; | 221 | return r; |
218 | } | 222 | } |
219 | 223 | ||
220 | void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 224 | void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
221 | { | 225 | { |
226 | unsigned long flags; | ||
227 | |||
228 | spin_lock_irqsave(&rdev->mc_idx_lock, flags); | ||
222 | WREG32(MC_IND_INDEX, 0xff0000 | ((reg) & 0xffff)); | 229 | WREG32(MC_IND_INDEX, 0xff0000 | ((reg) & 0xffff)); |
223 | WREG32(MC_IND_DATA, (v)); | 230 | WREG32(MC_IND_DATA, (v)); |
224 | WREG32(MC_IND_INDEX, 0); | 231 | WREG32(MC_IND_INDEX, 0); |
232 | spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); | ||
225 | } | 233 | } |
226 | 234 | ||
227 | #if defined(CONFIG_DEBUG_FS) | 235 | #if defined(CONFIG_DEBUG_FS) |
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c index ab1f2016f21e..5811d277a36a 100644 --- a/drivers/gpu/drm/radeon/rv6xx_dpm.c +++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c | |||
@@ -1758,8 +1758,6 @@ int rv6xx_dpm_set_power_state(struct radeon_device *rdev) | |||
1758 | 1758 | ||
1759 | rv6xx_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); | 1759 | rv6xx_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); |
1760 | 1760 | ||
1761 | rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO; | ||
1762 | |||
1763 | return 0; | 1761 | return 0; |
1764 | } | 1762 | } |
1765 | 1763 | ||
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c index 8cbb85dae5aa..913b025ae9b3 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.c +++ b/drivers/gpu/drm/radeon/rv770_dpm.c | |||
@@ -2064,12 +2064,6 @@ int rv770_dpm_set_power_state(struct radeon_device *rdev) | |||
2064 | rv770_program_dcodt_after_state_switch(rdev, new_ps, old_ps); | 2064 | rv770_program_dcodt_after_state_switch(rdev, new_ps, old_ps); |
2065 | rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); | 2065 | rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); |
2066 | 2066 | ||
2067 | ret = rv770_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
2068 | if (ret) { | ||
2069 | DRM_ERROR("rv770_dpm_force_performance_level failed\n"); | ||
2070 | return ret; | ||
2071 | } | ||
2072 | |||
2073 | return 0; | 2067 | return 0; |
2074 | } | 2068 | } |
2075 | 2069 | ||
@@ -2147,14 +2141,18 @@ static void rv7xx_parse_pplib_non_clock_info(struct radeon_device *rdev, | |||
2147 | if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { | 2141 | if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { |
2148 | rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); | 2142 | rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); |
2149 | rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); | 2143 | rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); |
2150 | } else if (r600_is_uvd_state(rps->class, rps->class2)) { | ||
2151 | rps->vclk = RV770_DEFAULT_VCLK_FREQ; | ||
2152 | rps->dclk = RV770_DEFAULT_DCLK_FREQ; | ||
2153 | } else { | 2144 | } else { |
2154 | rps->vclk = 0; | 2145 | rps->vclk = 0; |
2155 | rps->dclk = 0; | 2146 | rps->dclk = 0; |
2156 | } | 2147 | } |
2157 | 2148 | ||
2149 | if (r600_is_uvd_state(rps->class, rps->class2)) { | ||
2150 | if ((rps->vclk == 0) || (rps->dclk == 0)) { | ||
2151 | rps->vclk = RV770_DEFAULT_VCLK_FREQ; | ||
2152 | rps->dclk = RV770_DEFAULT_DCLK_FREQ; | ||
2153 | } | ||
2154 | } | ||
2155 | |||
2158 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) | 2156 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) |
2159 | rdev->pm.dpm.boot_ps = rps; | 2157 | rdev->pm.dpm.boot_ps = rps; |
2160 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) | 2158 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) |
diff --git a/drivers/gpu/drm/radeon/rv770_smc.c b/drivers/gpu/drm/radeon/rv770_smc.c index ab95da570215..b2a224407365 100644 --- a/drivers/gpu/drm/radeon/rv770_smc.c +++ b/drivers/gpu/drm/radeon/rv770_smc.c | |||
@@ -274,8 +274,8 @@ static const u8 cayman_smc_int_vectors[] = | |||
274 | 0x08, 0x72, 0x08, 0x72 | 274 | 0x08, 0x72, 0x08, 0x72 |
275 | }; | 275 | }; |
276 | 276 | ||
277 | int rv770_set_smc_sram_address(struct radeon_device *rdev, | 277 | static int rv770_set_smc_sram_address(struct radeon_device *rdev, |
278 | u16 smc_address, u16 limit) | 278 | u16 smc_address, u16 limit) |
279 | { | 279 | { |
280 | u32 addr; | 280 | u32 addr; |
281 | 281 | ||
@@ -296,9 +296,10 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev, | |||
296 | u16 smc_start_address, const u8 *src, | 296 | u16 smc_start_address, const u8 *src, |
297 | u16 byte_count, u16 limit) | 297 | u16 byte_count, u16 limit) |
298 | { | 298 | { |
299 | unsigned long flags; | ||
299 | u32 data, original_data, extra_shift; | 300 | u32 data, original_data, extra_shift; |
300 | u16 addr; | 301 | u16 addr; |
301 | int ret; | 302 | int ret = 0; |
302 | 303 | ||
303 | if (smc_start_address & 3) | 304 | if (smc_start_address & 3) |
304 | return -EINVAL; | 305 | return -EINVAL; |
@@ -307,13 +308,14 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev, | |||
307 | 308 | ||
308 | addr = smc_start_address; | 309 | addr = smc_start_address; |
309 | 310 | ||
311 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
310 | while (byte_count >= 4) { | 312 | while (byte_count >= 4) { |
311 | /* SMC address space is BE */ | 313 | /* SMC address space is BE */ |
312 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; | 314 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; |
313 | 315 | ||
314 | ret = rv770_set_smc_sram_address(rdev, addr, limit); | 316 | ret = rv770_set_smc_sram_address(rdev, addr, limit); |
315 | if (ret) | 317 | if (ret) |
316 | return ret; | 318 | goto done; |
317 | 319 | ||
318 | WREG32(SMC_SRAM_DATA, data); | 320 | WREG32(SMC_SRAM_DATA, data); |
319 | 321 | ||
@@ -328,7 +330,7 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev, | |||
328 | 330 | ||
329 | ret = rv770_set_smc_sram_address(rdev, addr, limit); | 331 | ret = rv770_set_smc_sram_address(rdev, addr, limit); |
330 | if (ret) | 332 | if (ret) |
331 | return ret; | 333 | goto done; |
332 | 334 | ||
333 | original_data = RREG32(SMC_SRAM_DATA); | 335 | original_data = RREG32(SMC_SRAM_DATA); |
334 | 336 | ||
@@ -346,12 +348,15 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev, | |||
346 | 348 | ||
347 | ret = rv770_set_smc_sram_address(rdev, addr, limit); | 349 | ret = rv770_set_smc_sram_address(rdev, addr, limit); |
348 | if (ret) | 350 | if (ret) |
349 | return ret; | 351 | goto done; |
350 | 352 | ||
351 | WREG32(SMC_SRAM_DATA, data); | 353 | WREG32(SMC_SRAM_DATA, data); |
352 | } | 354 | } |
353 | 355 | ||
354 | return 0; | 356 | done: |
357 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
358 | |||
359 | return ret; | ||
355 | } | 360 | } |
356 | 361 | ||
357 | static int rv770_program_interrupt_vectors(struct radeon_device *rdev, | 362 | static int rv770_program_interrupt_vectors(struct radeon_device *rdev, |
@@ -461,12 +466,15 @@ PPSMC_Result rv770_wait_for_smc_inactive(struct radeon_device *rdev) | |||
461 | 466 | ||
462 | static void rv770_clear_smc_sram(struct radeon_device *rdev, u16 limit) | 467 | static void rv770_clear_smc_sram(struct radeon_device *rdev, u16 limit) |
463 | { | 468 | { |
469 | unsigned long flags; | ||
464 | u16 i; | 470 | u16 i; |
465 | 471 | ||
472 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
466 | for (i = 0; i < limit; i += 4) { | 473 | for (i = 0; i < limit; i += 4) { |
467 | rv770_set_smc_sram_address(rdev, i, limit); | 474 | rv770_set_smc_sram_address(rdev, i, limit); |
468 | WREG32(SMC_SRAM_DATA, 0); | 475 | WREG32(SMC_SRAM_DATA, 0); |
469 | } | 476 | } |
477 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
470 | } | 478 | } |
471 | 479 | ||
472 | int rv770_load_smc_ucode(struct radeon_device *rdev, | 480 | int rv770_load_smc_ucode(struct radeon_device *rdev, |
@@ -595,27 +603,29 @@ int rv770_load_smc_ucode(struct radeon_device *rdev, | |||
595 | int rv770_read_smc_sram_dword(struct radeon_device *rdev, | 603 | int rv770_read_smc_sram_dword(struct radeon_device *rdev, |
596 | u16 smc_address, u32 *value, u16 limit) | 604 | u16 smc_address, u32 *value, u16 limit) |
597 | { | 605 | { |
606 | unsigned long flags; | ||
598 | int ret; | 607 | int ret; |
599 | 608 | ||
609 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
600 | ret = rv770_set_smc_sram_address(rdev, smc_address, limit); | 610 | ret = rv770_set_smc_sram_address(rdev, smc_address, limit); |
601 | if (ret) | 611 | if (ret == 0) |
602 | return ret; | 612 | *value = RREG32(SMC_SRAM_DATA); |
603 | 613 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | |
604 | *value = RREG32(SMC_SRAM_DATA); | ||
605 | 614 | ||
606 | return 0; | 615 | return ret; |
607 | } | 616 | } |
608 | 617 | ||
609 | int rv770_write_smc_sram_dword(struct radeon_device *rdev, | 618 | int rv770_write_smc_sram_dword(struct radeon_device *rdev, |
610 | u16 smc_address, u32 value, u16 limit) | 619 | u16 smc_address, u32 value, u16 limit) |
611 | { | 620 | { |
621 | unsigned long flags; | ||
612 | int ret; | 622 | int ret; |
613 | 623 | ||
624 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
614 | ret = rv770_set_smc_sram_address(rdev, smc_address, limit); | 625 | ret = rv770_set_smc_sram_address(rdev, smc_address, limit); |
615 | if (ret) | 626 | if (ret == 0) |
616 | return ret; | 627 | WREG32(SMC_SRAM_DATA, value); |
628 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
617 | 629 | ||
618 | WREG32(SMC_SRAM_DATA, value); | 630 | return ret; |
619 | |||
620 | return 0; | ||
621 | } | 631 | } |
diff --git a/drivers/gpu/drm/radeon/rv770_smc.h b/drivers/gpu/drm/radeon/rv770_smc.h index f78d92a4b325..3b2c963c4880 100644 --- a/drivers/gpu/drm/radeon/rv770_smc.h +++ b/drivers/gpu/drm/radeon/rv770_smc.h | |||
@@ -187,8 +187,6 @@ typedef struct RV770_SMC_STATETABLE RV770_SMC_STATETABLE; | |||
187 | #define RV770_SMC_SOFT_REGISTER_uvd_enabled 0x9C | 187 | #define RV770_SMC_SOFT_REGISTER_uvd_enabled 0x9C |
188 | #define RV770_SMC_SOFT_REGISTER_is_asic_lombok 0xA0 | 188 | #define RV770_SMC_SOFT_REGISTER_is_asic_lombok 0xA0 |
189 | 189 | ||
190 | int rv770_set_smc_sram_address(struct radeon_device *rdev, | ||
191 | u16 smc_address, u16 limit); | ||
192 | int rv770_copy_bytes_to_smc(struct radeon_device *rdev, | 190 | int rv770_copy_bytes_to_smc(struct radeon_device *rdev, |
193 | u16 smc_start_address, const u8 *src, | 191 | u16 smc_start_address, const u8 *src, |
194 | u16 byte_count, u16 limit); | 192 | u16 byte_count, u16 limit); |
diff --git a/drivers/gpu/drm/radeon/rv770d.h b/drivers/gpu/drm/radeon/rv770d.h index 9fe60e542922..1ae277152cc7 100644 --- a/drivers/gpu/drm/radeon/rv770d.h +++ b/drivers/gpu/drm/radeon/rv770d.h | |||
@@ -852,7 +852,7 @@ | |||
852 | #define AFMT_VBI_PACKET_CONTROL 0x7608 | 852 | #define AFMT_VBI_PACKET_CONTROL 0x7608 |
853 | # define AFMT_GENERIC0_UPDATE (1 << 2) | 853 | # define AFMT_GENERIC0_UPDATE (1 << 2) |
854 | #define AFMT_INFOFRAME_CONTROL0 0x760c | 854 | #define AFMT_INFOFRAME_CONTROL0 0x760c |
855 | # define AFMT_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hmdi regs */ | 855 | # define AFMT_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hdmi regs */ |
856 | # define AFMT_AUDIO_INFO_UPDATE (1 << 7) | 856 | # define AFMT_AUDIO_INFO_UPDATE (1 << 7) |
857 | # define AFMT_MPEG_INFO_UPDATE (1 << 10) | 857 | # define AFMT_MPEG_INFO_UPDATE (1 << 10) |
858 | #define AFMT_GENERIC0_7 0x7610 | 858 | #define AFMT_GENERIC0_7 0x7610 |
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index 3e23b757dcfa..c354c1094967 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c | |||
@@ -83,6 +83,8 @@ extern void si_dma_vm_set_page(struct radeon_device *rdev, | |||
83 | uint64_t pe, | 83 | uint64_t pe, |
84 | uint64_t addr, unsigned count, | 84 | uint64_t addr, unsigned count, |
85 | uint32_t incr, uint32_t flags); | 85 | uint32_t incr, uint32_t flags); |
86 | static void si_enable_gui_idle_interrupt(struct radeon_device *rdev, | ||
87 | bool enable); | ||
86 | 88 | ||
87 | static const u32 verde_rlc_save_restore_register_list[] = | 89 | static const u32 verde_rlc_save_restore_register_list[] = |
88 | { | 90 | { |
@@ -3386,6 +3388,8 @@ static int si_cp_resume(struct radeon_device *rdev) | |||
3386 | u32 rb_bufsz; | 3388 | u32 rb_bufsz; |
3387 | int r; | 3389 | int r; |
3388 | 3390 | ||
3391 | si_enable_gui_idle_interrupt(rdev, false); | ||
3392 | |||
3389 | WREG32(CP_SEM_WAIT_TIMER, 0x0); | 3393 | WREG32(CP_SEM_WAIT_TIMER, 0x0); |
3390 | WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); | 3394 | WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); |
3391 | 3395 | ||
@@ -3501,6 +3505,8 @@ static int si_cp_resume(struct radeon_device *rdev) | |||
3501 | rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false; | 3505 | rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false; |
3502 | } | 3506 | } |
3503 | 3507 | ||
3508 | si_enable_gui_idle_interrupt(rdev, true); | ||
3509 | |||
3504 | return 0; | 3510 | return 0; |
3505 | } | 3511 | } |
3506 | 3512 | ||
@@ -4888,7 +4894,7 @@ static void si_enable_gfx_cgpg(struct radeon_device *rdev, | |||
4888 | { | 4894 | { |
4889 | u32 tmp; | 4895 | u32 tmp; |
4890 | 4896 | ||
4891 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG)) { | 4897 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG)) { |
4892 | tmp = RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10); | 4898 | tmp = RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10); |
4893 | WREG32(RLC_TTOP_D, tmp); | 4899 | WREG32(RLC_TTOP_D, tmp); |
4894 | 4900 | ||
@@ -5250,6 +5256,7 @@ void si_update_cg(struct radeon_device *rdev, | |||
5250 | u32 block, bool enable) | 5256 | u32 block, bool enable) |
5251 | { | 5257 | { |
5252 | if (block & RADEON_CG_BLOCK_GFX) { | 5258 | if (block & RADEON_CG_BLOCK_GFX) { |
5259 | si_enable_gui_idle_interrupt(rdev, false); | ||
5253 | /* order matters! */ | 5260 | /* order matters! */ |
5254 | if (enable) { | 5261 | if (enable) { |
5255 | si_enable_mgcg(rdev, true); | 5262 | si_enable_mgcg(rdev, true); |
@@ -5258,6 +5265,7 @@ void si_update_cg(struct radeon_device *rdev, | |||
5258 | si_enable_cgcg(rdev, false); | 5265 | si_enable_cgcg(rdev, false); |
5259 | si_enable_mgcg(rdev, false); | 5266 | si_enable_mgcg(rdev, false); |
5260 | } | 5267 | } |
5268 | si_enable_gui_idle_interrupt(rdev, true); | ||
5261 | } | 5269 | } |
5262 | 5270 | ||
5263 | if (block & RADEON_CG_BLOCK_MC) { | 5271 | if (block & RADEON_CG_BLOCK_MC) { |
@@ -5408,7 +5416,7 @@ static void si_init_pg(struct radeon_device *rdev) | |||
5408 | si_init_dma_pg(rdev); | 5416 | si_init_dma_pg(rdev); |
5409 | } | 5417 | } |
5410 | si_init_ao_cu_mask(rdev); | 5418 | si_init_ao_cu_mask(rdev); |
5411 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG) { | 5419 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
5412 | si_init_gfx_cgpg(rdev); | 5420 | si_init_gfx_cgpg(rdev); |
5413 | } | 5421 | } |
5414 | si_enable_dma_pg(rdev, true); | 5422 | si_enable_dma_pg(rdev, true); |
@@ -5560,7 +5568,9 @@ static void si_disable_interrupt_state(struct radeon_device *rdev) | |||
5560 | { | 5568 | { |
5561 | u32 tmp; | 5569 | u32 tmp; |
5562 | 5570 | ||
5563 | WREG32(CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | 5571 | tmp = RREG32(CP_INT_CNTL_RING0) & |
5572 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | ||
5573 | WREG32(CP_INT_CNTL_RING0, tmp); | ||
5564 | WREG32(CP_INT_CNTL_RING1, 0); | 5574 | WREG32(CP_INT_CNTL_RING1, 0); |
5565 | WREG32(CP_INT_CNTL_RING2, 0); | 5575 | WREG32(CP_INT_CNTL_RING2, 0); |
5566 | tmp = RREG32(DMA_CNTL + DMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; | 5576 | tmp = RREG32(DMA_CNTL + DMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; |
@@ -5685,7 +5695,7 @@ static int si_irq_init(struct radeon_device *rdev) | |||
5685 | 5695 | ||
5686 | int si_irq_set(struct radeon_device *rdev) | 5696 | int si_irq_set(struct radeon_device *rdev) |
5687 | { | 5697 | { |
5688 | u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE; | 5698 | u32 cp_int_cntl; |
5689 | u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0; | 5699 | u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0; |
5690 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; | 5700 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; |
5691 | u32 hpd1 = 0, hpd2 = 0, hpd3 = 0, hpd4 = 0, hpd5 = 0, hpd6 = 0; | 5701 | u32 hpd1 = 0, hpd2 = 0, hpd3 = 0, hpd4 = 0, hpd5 = 0, hpd6 = 0; |
@@ -5706,6 +5716,9 @@ int si_irq_set(struct radeon_device *rdev) | |||
5706 | return 0; | 5716 | return 0; |
5707 | } | 5717 | } |
5708 | 5718 | ||
5719 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0) & | ||
5720 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | ||
5721 | |||
5709 | if (!ASIC_IS_NODCE(rdev)) { | 5722 | if (!ASIC_IS_NODCE(rdev)) { |
5710 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; | 5723 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
5711 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; | 5724 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c index 5be9b4e72350..cfe5d4d28915 100644 --- a/drivers/gpu/drm/radeon/si_dpm.c +++ b/drivers/gpu/drm/radeon/si_dpm.c | |||
@@ -6075,12 +6075,6 @@ int si_dpm_set_power_state(struct radeon_device *rdev) | |||
6075 | return ret; | 6075 | return ret; |
6076 | } | 6076 | } |
6077 | 6077 | ||
6078 | ret = si_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO); | ||
6079 | if (ret) { | ||
6080 | DRM_ERROR("si_dpm_force_performance_level failed\n"); | ||
6081 | return ret; | ||
6082 | } | ||
6083 | |||
6084 | si_update_cg(rdev, (RADEON_CG_BLOCK_GFX | | 6078 | si_update_cg(rdev, (RADEON_CG_BLOCK_GFX | |
6085 | RADEON_CG_BLOCK_MC | | 6079 | RADEON_CG_BLOCK_MC | |
6086 | RADEON_CG_BLOCK_SDMA | | 6080 | RADEON_CG_BLOCK_SDMA | |
diff --git a/drivers/gpu/drm/radeon/si_smc.c b/drivers/gpu/drm/radeon/si_smc.c index 5f524c0a541e..d422a1cbf727 100644 --- a/drivers/gpu/drm/radeon/si_smc.c +++ b/drivers/gpu/drm/radeon/si_smc.c | |||
@@ -29,8 +29,8 @@ | |||
29 | #include "ppsmc.h" | 29 | #include "ppsmc.h" |
30 | #include "radeon_ucode.h" | 30 | #include "radeon_ucode.h" |
31 | 31 | ||
32 | int si_set_smc_sram_address(struct radeon_device *rdev, | 32 | static int si_set_smc_sram_address(struct radeon_device *rdev, |
33 | u32 smc_address, u32 limit) | 33 | u32 smc_address, u32 limit) |
34 | { | 34 | { |
35 | if (smc_address & 3) | 35 | if (smc_address & 3) |
36 | return -EINVAL; | 36 | return -EINVAL; |
@@ -47,7 +47,8 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev, | |||
47 | u32 smc_start_address, | 47 | u32 smc_start_address, |
48 | const u8 *src, u32 byte_count, u32 limit) | 48 | const u8 *src, u32 byte_count, u32 limit) |
49 | { | 49 | { |
50 | int ret; | 50 | unsigned long flags; |
51 | int ret = 0; | ||
51 | u32 data, original_data, addr, extra_shift; | 52 | u32 data, original_data, addr, extra_shift; |
52 | 53 | ||
53 | if (smc_start_address & 3) | 54 | if (smc_start_address & 3) |
@@ -57,13 +58,14 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev, | |||
57 | 58 | ||
58 | addr = smc_start_address; | 59 | addr = smc_start_address; |
59 | 60 | ||
61 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
60 | while (byte_count >= 4) { | 62 | while (byte_count >= 4) { |
61 | /* SMC address space is BE */ | 63 | /* SMC address space is BE */ |
62 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; | 64 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; |
63 | 65 | ||
64 | ret = si_set_smc_sram_address(rdev, addr, limit); | 66 | ret = si_set_smc_sram_address(rdev, addr, limit); |
65 | if (ret) | 67 | if (ret) |
66 | return ret; | 68 | goto done; |
67 | 69 | ||
68 | WREG32(SMC_IND_DATA_0, data); | 70 | WREG32(SMC_IND_DATA_0, data); |
69 | 71 | ||
@@ -78,7 +80,7 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev, | |||
78 | 80 | ||
79 | ret = si_set_smc_sram_address(rdev, addr, limit); | 81 | ret = si_set_smc_sram_address(rdev, addr, limit); |
80 | if (ret) | 82 | if (ret) |
81 | return ret; | 83 | goto done; |
82 | 84 | ||
83 | original_data = RREG32(SMC_IND_DATA_0); | 85 | original_data = RREG32(SMC_IND_DATA_0); |
84 | 86 | ||
@@ -96,11 +98,15 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev, | |||
96 | 98 | ||
97 | ret = si_set_smc_sram_address(rdev, addr, limit); | 99 | ret = si_set_smc_sram_address(rdev, addr, limit); |
98 | if (ret) | 100 | if (ret) |
99 | return ret; | 101 | goto done; |
100 | 102 | ||
101 | WREG32(SMC_IND_DATA_0, data); | 103 | WREG32(SMC_IND_DATA_0, data); |
102 | } | 104 | } |
103 | return 0; | 105 | |
106 | done: | ||
107 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
108 | |||
109 | return ret; | ||
104 | } | 110 | } |
105 | 111 | ||
106 | void si_start_smc(struct radeon_device *rdev) | 112 | void si_start_smc(struct radeon_device *rdev) |
@@ -203,6 +209,7 @@ PPSMC_Result si_wait_for_smc_inactive(struct radeon_device *rdev) | |||
203 | 209 | ||
204 | int si_load_smc_ucode(struct radeon_device *rdev, u32 limit) | 210 | int si_load_smc_ucode(struct radeon_device *rdev, u32 limit) |
205 | { | 211 | { |
212 | unsigned long flags; | ||
206 | u32 ucode_start_address; | 213 | u32 ucode_start_address; |
207 | u32 ucode_size; | 214 | u32 ucode_size; |
208 | const u8 *src; | 215 | const u8 *src; |
@@ -241,6 +248,7 @@ int si_load_smc_ucode(struct radeon_device *rdev, u32 limit) | |||
241 | return -EINVAL; | 248 | return -EINVAL; |
242 | 249 | ||
243 | src = (const u8 *)rdev->smc_fw->data; | 250 | src = (const u8 *)rdev->smc_fw->data; |
251 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
244 | WREG32(SMC_IND_INDEX_0, ucode_start_address); | 252 | WREG32(SMC_IND_INDEX_0, ucode_start_address); |
245 | WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); | 253 | WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); |
246 | while (ucode_size >= 4) { | 254 | while (ucode_size >= 4) { |
@@ -253,6 +261,7 @@ int si_load_smc_ucode(struct radeon_device *rdev, u32 limit) | |||
253 | ucode_size -= 4; | 261 | ucode_size -= 4; |
254 | } | 262 | } |
255 | WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); | 263 | WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); |
264 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
256 | 265 | ||
257 | return 0; | 266 | return 0; |
258 | } | 267 | } |
@@ -260,25 +269,29 @@ int si_load_smc_ucode(struct radeon_device *rdev, u32 limit) | |||
260 | int si_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, | 269 | int si_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, |
261 | u32 *value, u32 limit) | 270 | u32 *value, u32 limit) |
262 | { | 271 | { |
272 | unsigned long flags; | ||
263 | int ret; | 273 | int ret; |
264 | 274 | ||
275 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
265 | ret = si_set_smc_sram_address(rdev, smc_address, limit); | 276 | ret = si_set_smc_sram_address(rdev, smc_address, limit); |
266 | if (ret) | 277 | if (ret == 0) |
267 | return ret; | 278 | *value = RREG32(SMC_IND_DATA_0); |
279 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
268 | 280 | ||
269 | *value = RREG32(SMC_IND_DATA_0); | 281 | return ret; |
270 | return 0; | ||
271 | } | 282 | } |
272 | 283 | ||
273 | int si_write_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, | 284 | int si_write_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, |
274 | u32 value, u32 limit) | 285 | u32 value, u32 limit) |
275 | { | 286 | { |
287 | unsigned long flags; | ||
276 | int ret; | 288 | int ret; |
277 | 289 | ||
290 | spin_lock_irqsave(&rdev->smc_idx_lock, flags); | ||
278 | ret = si_set_smc_sram_address(rdev, smc_address, limit); | 291 | ret = si_set_smc_sram_address(rdev, smc_address, limit); |
279 | if (ret) | 292 | if (ret == 0) |
280 | return ret; | 293 | WREG32(SMC_IND_DATA_0, value); |
294 | spin_unlock_irqrestore(&rdev->smc_idx_lock, flags); | ||
281 | 295 | ||
282 | WREG32(SMC_IND_DATA_0, value); | 296 | return ret; |
283 | return 0; | ||
284 | } | 297 | } |
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index 864761c0120e..96ea6db8bf57 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c | |||
@@ -1319,8 +1319,6 @@ int sumo_dpm_set_power_state(struct radeon_device *rdev) | |||
1319 | if (pi->enable_dpm) | 1319 | if (pi->enable_dpm) |
1320 | sumo_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); | 1320 | sumo_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); |
1321 | 1321 | ||
1322 | rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO; | ||
1323 | |||
1324 | return 0; | 1322 | return 0; |
1325 | } | 1323 | } |
1326 | 1324 | ||
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c index b07b7b8f1aff..7f998bf1cc9d 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.c +++ b/drivers/gpu/drm/radeon/trinity_dpm.c | |||
@@ -1068,6 +1068,17 @@ static void trinity_update_requested_ps(struct radeon_device *rdev, | |||
1068 | pi->requested_rps.ps_priv = &pi->requested_ps; | 1068 | pi->requested_rps.ps_priv = &pi->requested_ps; |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | void trinity_dpm_enable_bapm(struct radeon_device *rdev, bool enable) | ||
1072 | { | ||
1073 | struct trinity_power_info *pi = trinity_get_pi(rdev); | ||
1074 | |||
1075 | if (pi->enable_bapm) { | ||
1076 | trinity_acquire_mutex(rdev); | ||
1077 | trinity_dpm_bapm_enable(rdev, enable); | ||
1078 | trinity_release_mutex(rdev); | ||
1079 | } | ||
1080 | } | ||
1081 | |||
1071 | int trinity_dpm_enable(struct radeon_device *rdev) | 1082 | int trinity_dpm_enable(struct radeon_device *rdev) |
1072 | { | 1083 | { |
1073 | struct trinity_power_info *pi = trinity_get_pi(rdev); | 1084 | struct trinity_power_info *pi = trinity_get_pi(rdev); |
@@ -1091,6 +1102,7 @@ int trinity_dpm_enable(struct radeon_device *rdev) | |||
1091 | trinity_program_sclk_dpm(rdev); | 1102 | trinity_program_sclk_dpm(rdev); |
1092 | trinity_start_dpm(rdev); | 1103 | trinity_start_dpm(rdev); |
1093 | trinity_wait_for_dpm_enabled(rdev); | 1104 | trinity_wait_for_dpm_enabled(rdev); |
1105 | trinity_dpm_bapm_enable(rdev, false); | ||
1094 | trinity_release_mutex(rdev); | 1106 | trinity_release_mutex(rdev); |
1095 | 1107 | ||
1096 | if (rdev->irq.installed && | 1108 | if (rdev->irq.installed && |
@@ -1116,6 +1128,7 @@ void trinity_dpm_disable(struct radeon_device *rdev) | |||
1116 | trinity_release_mutex(rdev); | 1128 | trinity_release_mutex(rdev); |
1117 | return; | 1129 | return; |
1118 | } | 1130 | } |
1131 | trinity_dpm_bapm_enable(rdev, false); | ||
1119 | trinity_disable_clock_power_gating(rdev); | 1132 | trinity_disable_clock_power_gating(rdev); |
1120 | sumo_clear_vc(rdev); | 1133 | sumo_clear_vc(rdev); |
1121 | trinity_wait_for_level_0(rdev); | 1134 | trinity_wait_for_level_0(rdev); |
@@ -1212,6 +1225,8 @@ int trinity_dpm_set_power_state(struct radeon_device *rdev) | |||
1212 | 1225 | ||
1213 | trinity_acquire_mutex(rdev); | 1226 | trinity_acquire_mutex(rdev); |
1214 | if (pi->enable_dpm) { | 1227 | if (pi->enable_dpm) { |
1228 | if (pi->enable_bapm) | ||
1229 | trinity_dpm_bapm_enable(rdev, rdev->pm.dpm.ac_power); | ||
1215 | trinity_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); | 1230 | trinity_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); |
1216 | trinity_enable_power_level_0(rdev); | 1231 | trinity_enable_power_level_0(rdev); |
1217 | trinity_force_level_0(rdev); | 1232 | trinity_force_level_0(rdev); |
@@ -1221,7 +1236,6 @@ int trinity_dpm_set_power_state(struct radeon_device *rdev) | |||
1221 | trinity_force_level_0(rdev); | 1236 | trinity_force_level_0(rdev); |
1222 | trinity_unforce_levels(rdev); | 1237 | trinity_unforce_levels(rdev); |
1223 | trinity_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); | 1238 | trinity_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); |
1224 | rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO; | ||
1225 | } | 1239 | } |
1226 | trinity_release_mutex(rdev); | 1240 | trinity_release_mutex(rdev); |
1227 | 1241 | ||
@@ -1854,6 +1868,7 @@ int trinity_dpm_init(struct radeon_device *rdev) | |||
1854 | for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) | 1868 | for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) |
1855 | pi->at[i] = TRINITY_AT_DFLT; | 1869 | pi->at[i] = TRINITY_AT_DFLT; |
1856 | 1870 | ||
1871 | pi->enable_bapm = true; | ||
1857 | pi->enable_nbps_policy = true; | 1872 | pi->enable_nbps_policy = true; |
1858 | pi->enable_sclk_ds = true; | 1873 | pi->enable_sclk_ds = true; |
1859 | pi->enable_gfx_power_gating = true; | 1874 | pi->enable_gfx_power_gating = true; |
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.h b/drivers/gpu/drm/radeon/trinity_dpm.h index e82df071f8b3..c261657750ca 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.h +++ b/drivers/gpu/drm/radeon/trinity_dpm.h | |||
@@ -108,6 +108,7 @@ struct trinity_power_info { | |||
108 | bool enable_auto_thermal_throttling; | 108 | bool enable_auto_thermal_throttling; |
109 | bool enable_dpm; | 109 | bool enable_dpm; |
110 | bool enable_sclk_ds; | 110 | bool enable_sclk_ds; |
111 | bool enable_bapm; | ||
111 | bool uvd_dpm; | 112 | bool uvd_dpm; |
112 | struct radeon_ps current_rps; | 113 | struct radeon_ps current_rps; |
113 | struct trinity_ps current_ps; | 114 | struct trinity_ps current_ps; |
@@ -118,6 +119,7 @@ struct trinity_power_info { | |||
118 | #define TRINITY_AT_DFLT 30 | 119 | #define TRINITY_AT_DFLT 30 |
119 | 120 | ||
120 | /* trinity_smc.c */ | 121 | /* trinity_smc.c */ |
122 | int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable); | ||
121 | int trinity_dpm_config(struct radeon_device *rdev, bool enable); | 123 | int trinity_dpm_config(struct radeon_device *rdev, bool enable); |
122 | int trinity_uvd_dpm_config(struct radeon_device *rdev); | 124 | int trinity_uvd_dpm_config(struct radeon_device *rdev); |
123 | int trinity_dpm_force_state(struct radeon_device *rdev, u32 n); | 125 | int trinity_dpm_force_state(struct radeon_device *rdev, u32 n); |
diff --git a/drivers/gpu/drm/radeon/trinity_smc.c b/drivers/gpu/drm/radeon/trinity_smc.c index a42d89f1830c..9672bcbc7312 100644 --- a/drivers/gpu/drm/radeon/trinity_smc.c +++ b/drivers/gpu/drm/radeon/trinity_smc.c | |||
@@ -56,6 +56,14 @@ static int trinity_notify_message_to_smu(struct radeon_device *rdev, u32 id) | |||
56 | return 0; | 56 | return 0; |
57 | } | 57 | } |
58 | 58 | ||
59 | int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable) | ||
60 | { | ||
61 | if (enable) | ||
62 | return trinity_notify_message_to_smu(rdev, PPSMC_MSG_EnableBAPM); | ||
63 | else | ||
64 | return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DisableBAPM); | ||
65 | } | ||
66 | |||
59 | int trinity_dpm_config(struct radeon_device *rdev, bool enable) | 67 | int trinity_dpm_config(struct radeon_device *rdev, bool enable) |
60 | { | 68 | { |
61 | if (enable) | 69 | if (enable) |
diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c index 58a5f3261c0b..a868176c258a 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c | |||
@@ -218,7 +218,7 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, | |||
218 | uint32_t key) | 218 | uint32_t key) |
219 | { | 219 | { |
220 | struct ttm_object_device *tdev = tfile->tdev; | 220 | struct ttm_object_device *tdev = tfile->tdev; |
221 | struct ttm_base_object *base; | 221 | struct ttm_base_object *uninitialized_var(base); |
222 | struct drm_hash_item *hash; | 222 | struct drm_hash_item *hash; |
223 | int ret; | 223 | int ret; |
224 | 224 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 5e93a52d4f2c..210d50365162 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c | |||
@@ -170,7 +170,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm) | |||
170 | ttm_tt_unbind(ttm); | 170 | ttm_tt_unbind(ttm); |
171 | } | 171 | } |
172 | 172 | ||
173 | if (likely(ttm->pages != NULL)) { | 173 | if (ttm->state == tt_unbound) { |
174 | ttm->bdev->driver->ttm_tt_unpopulate(ttm); | 174 | ttm->bdev->driver->ttm_tt_unpopulate(ttm); |
175 | } | 175 | } |
176 | 176 | ||
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 8dbe9d0ae9a7..8bf646183bac 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c | |||
@@ -97,7 +97,6 @@ int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
97 | ret = vm_insert_page(vma, (unsigned long)vmf->virtual_address, page); | 97 | ret = vm_insert_page(vma, (unsigned long)vmf->virtual_address, page); |
98 | switch (ret) { | 98 | switch (ret) { |
99 | case -EAGAIN: | 99 | case -EAGAIN: |
100 | set_need_resched(); | ||
101 | case 0: | 100 | case 0: |
102 | case -ERESTARTSYS: | 101 | case -ERESTARTSYS: |
103 | return VM_FAULT_NOPAGE; | 102 | return VM_FAULT_NOPAGE; |
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 28e28a23d444..471630299878 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c | |||
@@ -43,7 +43,7 @@ void host1x_set_drm_data(struct device *dev, void *data) | |||
43 | void *host1x_get_drm_data(struct device *dev) | 43 | void *host1x_get_drm_data(struct device *dev) |
44 | { | 44 | { |
45 | struct host1x *host1x = dev_get_drvdata(dev); | 45 | struct host1x *host1x = dev_get_drvdata(dev); |
46 | return host1x->drm_data; | 46 | return host1x ? host1x->drm_data : NULL; |
47 | } | 47 | } |
48 | 48 | ||
49 | void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r) | 49 | void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r) |
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h index 790ddf114e58..bed90a8131be 100644 --- a/drivers/gpu/host1x/dev.h +++ b/drivers/gpu/host1x/dev.h | |||
@@ -301,8 +301,8 @@ static inline void host1x_hw_show_mlocks(struct host1x *host, struct output *o) | |||
301 | host->debug_op->show_mlocks(host, o); | 301 | host->debug_op->show_mlocks(host, o); |
302 | } | 302 | } |
303 | 303 | ||
304 | extern struct platform_driver tegra_hdmi_driver; | ||
305 | extern struct platform_driver tegra_dc_driver; | 304 | extern struct platform_driver tegra_dc_driver; |
305 | extern struct platform_driver tegra_hdmi_driver; | ||
306 | extern struct platform_driver tegra_gr2d_driver; | 306 | extern struct platform_driver tegra_gr2d_driver; |
307 | 307 | ||
308 | #endif | 308 | #endif |
diff --git a/drivers/gpu/host1x/drm/hdmi.c b/drivers/gpu/host1x/drm/hdmi.c index 52e3c9641a0f..644d95c7d489 100644 --- a/drivers/gpu/host1x/drm/hdmi.c +++ b/drivers/gpu/host1x/drm/hdmi.c | |||
@@ -888,6 +888,11 @@ static int tegra_hdmi_show_regs(struct seq_file *s, void *data) | |||
888 | { | 888 | { |
889 | struct drm_info_node *node = s->private; | 889 | struct drm_info_node *node = s->private; |
890 | struct tegra_hdmi *hdmi = node->info_ent->data; | 890 | struct tegra_hdmi *hdmi = node->info_ent->data; |
891 | int err; | ||
892 | |||
893 | err = clk_enable(hdmi->clk); | ||
894 | if (err) | ||
895 | return err; | ||
891 | 896 | ||
892 | #define DUMP_REG(name) \ | 897 | #define DUMP_REG(name) \ |
893 | seq_printf(s, "%-56s %#05x %08lx\n", #name, name, \ | 898 | seq_printf(s, "%-56s %#05x %08lx\n", #name, name, \ |
@@ -1053,6 +1058,8 @@ static int tegra_hdmi_show_regs(struct seq_file *s, void *data) | |||
1053 | 1058 | ||
1054 | #undef DUMP_REG | 1059 | #undef DUMP_REG |
1055 | 1060 | ||
1061 | clk_disable(hdmi->clk); | ||
1062 | |||
1056 | return 0; | 1063 | return 0; |
1057 | } | 1064 | } |
1058 | 1065 | ||
diff --git a/drivers/gpu/host1x/drm/rgb.c b/drivers/gpu/host1x/drm/rgb.c index ed4416f20260..5aa66ef7a946 100644 --- a/drivers/gpu/host1x/drm/rgb.c +++ b/drivers/gpu/host1x/drm/rgb.c | |||
@@ -147,6 +147,13 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) | |||
147 | if (!rgb) | 147 | if (!rgb) |
148 | return -ENOMEM; | 148 | return -ENOMEM; |
149 | 149 | ||
150 | rgb->output.dev = dc->dev; | ||
151 | rgb->output.of_node = np; | ||
152 | |||
153 | err = tegra_output_parse_dt(&rgb->output); | ||
154 | if (err < 0) | ||
155 | return err; | ||
156 | |||
150 | rgb->clk = devm_clk_get(dc->dev, NULL); | 157 | rgb->clk = devm_clk_get(dc->dev, NULL); |
151 | if (IS_ERR(rgb->clk)) { | 158 | if (IS_ERR(rgb->clk)) { |
152 | dev_err(dc->dev, "failed to get clock\n"); | 159 | dev_err(dc->dev, "failed to get clock\n"); |
@@ -165,13 +172,6 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) | |||
165 | return err; | 172 | return err; |
166 | } | 173 | } |
167 | 174 | ||
168 | rgb->output.dev = dc->dev; | ||
169 | rgb->output.of_node = np; | ||
170 | |||
171 | err = tegra_output_parse_dt(&rgb->output); | ||
172 | if (err < 0) | ||
173 | return err; | ||
174 | |||
175 | dc->rgb = &rgb->output; | 175 | dc->rgb = &rgb->output; |
176 | 176 | ||
177 | return 0; | 177 | return 0; |
diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c index cc807667d8f1..c4e1050f2252 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c | |||
@@ -42,12 +42,12 @@ struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, | |||
42 | 42 | ||
43 | /* Check that we're not going to overflow */ | 43 | /* Check that we're not going to overflow */ |
44 | total = sizeof(struct host1x_job) + | 44 | total = sizeof(struct host1x_job) + |
45 | num_relocs * sizeof(struct host1x_reloc) + | 45 | (u64)num_relocs * sizeof(struct host1x_reloc) + |
46 | num_unpins * sizeof(struct host1x_job_unpin_data) + | 46 | (u64)num_unpins * sizeof(struct host1x_job_unpin_data) + |
47 | num_waitchks * sizeof(struct host1x_waitchk) + | 47 | (u64)num_waitchks * sizeof(struct host1x_waitchk) + |
48 | num_cmdbufs * sizeof(struct host1x_job_gather) + | 48 | (u64)num_cmdbufs * sizeof(struct host1x_job_gather) + |
49 | num_unpins * sizeof(dma_addr_t) + | 49 | (u64)num_unpins * sizeof(dma_addr_t) + |
50 | num_unpins * sizeof(u32 *); | 50 | (u64)num_unpins * sizeof(u32 *); |
51 | if (total > ULONG_MAX) | 51 | if (total > ULONG_MAX) |
52 | return NULL; | 52 | return NULL; |
53 | 53 | ||
@@ -466,9 +466,8 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev) | |||
466 | &job->gather_copy, | 466 | &job->gather_copy, |
467 | GFP_KERNEL); | 467 | GFP_KERNEL); |
468 | if (!job->gather_copy_mapped) { | 468 | if (!job->gather_copy_mapped) { |
469 | int err = PTR_ERR(job->gather_copy_mapped); | ||
470 | job->gather_copy_mapped = NULL; | 469 | job->gather_copy_mapped = NULL; |
471 | return err; | 470 | return -ENOMEM; |
472 | } | 471 | } |
473 | 472 | ||
474 | job->gather_copy_size = size; | 473 | job->gather_copy_size = size; |