Pull drm fixes from Dave Airlie: "Nothing too crazy this week, one amdgpu fix to use vmalloc for a struct that grew in size, and another MST fix for nouveau, and some other misc fixes: i915: - single GVT use after free fix scheduler: - entity destruction race fix amdgpu: - struct allocation fix - gfx9 soft recovery fix nouveau: - followup MST fix ast: - vga register race fix" * tag 'drm-fixes-2019-08-16' of git://anongit.freedesktop.org/drm/drm: drm/nouveau: Only recalculate PBN/VCPI on mode/connector changes drm/ast: Fixed reboot test may cause system hanged drm/scheduler: use job count instead of peek drm/amd/display: use kvmalloc for dc_state (v2) drm/amdgpu: fix gfx9 soft recovery drm/i915: Use after free in error path in intel_vgpu_create_workload()
Unified · Split
| @@ -4869,7 +4869,7 @@ static void gfx_v9_0_ring_soft_recovery(struct amdgpu_ring *ring, unsigned vmid) · 4868 unmodified lines | |||
| 4869 | value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01); | 4869 | value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01); |
| 4870 | value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1); | 4870 | value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1); |
| 4871 | value = REG_SET_FIELD(value, SQ_CMD, VM_ID, vmid); | 4871 | value = REG_SET_FIELD(value, SQ_CMD, VM_ID, vmid); |
| 4872 | WREG32(mmSQ_CMD, value); | 4872 | WREG32_SOC15(GC, 0, mmSQ_CMD, value); |
| 4873 | } | 4873 | } |
| 4874 | 4874 | ||
| 4875 | static void gfx_v9_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, | 4875 | static void gfx_v9_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 26 | #include <linux/mm.h> | ||
| 26 | 27 | ||
| 27 | #include "dm_services.h" | 28 | #include "dm_services.h" |
| 28 | 29 | ||
| @@ -1171,8 +1172,8 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc) · 1142 unmodified lines | |||
| 1171 | 1172 | ||
| 1172 | struct dc_state *dc_create_state(struct dc *dc) | 1173 | struct dc_state *dc_create_state(struct dc *dc) |
| 1173 | { | 1174 | { |
| 1174 | struct dc_state *context = kzalloc(sizeof(struct dc_state), | 1175 | struct dc_state *context = kvzalloc(sizeof(struct dc_state), |
| 1175 | GFP_KERNEL); | 1176 | GFP_KERNEL); |
| 1176 | 1177 | ||
| 1177 | if (!context) | 1178 | if (!context) |
| 1178 | return NULL; | 1179 | return NULL; |
| @@ -1192,11 +1193,11 @@ struct dc_state *dc_create_state(struct dc *dc) · 13 unmodified lines | |||
| 1192 | struct dc_state *dc_copy_state(struct dc_state *src_ctx) | 1193 | struct dc_state *dc_copy_state(struct dc_state *src_ctx) |
| 1193 | { | 1194 | { |
| 1194 | int i, j; | 1195 | int i, j; |
| 1195 | struct dc_state *new_ctx = kmemdup(src_ctx, | 1196 | struct dc_state *new_ctx = kvmalloc(sizeof(struct dc_state), GFP_KERNEL); |
| 1196 | sizeof(struct dc_state), GFP_KERNEL); | ||
| 1197 | 1197 | ||
| 1198 | if (!new_ctx) | 1198 | if (!new_ctx) |
| 1199 | return NULL; | 1199 | return NULL; |
| 1200 | memcpy(new_ctx, src_ctx, sizeof(struct dc_state)); | ||
| 1200 | 1201 | ||
| 1201 | for (i = 0; i < MAX_PIPES; i++) { | 1202 | for (i = 0; i < MAX_PIPES; i++) { |
| 1202 | struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i]; | 1203 | struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i]; |
| @@ -1230,7 +1231,7 @@ static void dc_state_free(struct kref *kref) · 27 unmodified lines | |||
| 1230 | { | 1231 | { |
| 1231 | struct dc_state *context = container_of(kref, struct dc_state, refcount); | 1232 | struct dc_state *context = container_of(kref, struct dc_state, refcount); |
| 1232 | dc_resource_state_destruct(context); | 1233 | dc_resource_state_destruct(context); |
| 1233 | kfree(context); | 1234 | kvfree(context); |
| 1234 | } | 1235 | } |
| 1235 | 1236 | ||
| 1236 | void dc_release_state(struct dc_state *context) | 1237 | void dc_release_state(struct dc_state *context) |
| @@ -131,8 +131,8 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) · 130 unmodified lines | |||
| 131 | 131 | ||
| 132 | 132 | ||
| 133 | /* Enable extended register access */ | 133 | /* Enable extended register access */ |
| 134 | ast_enable_mmio(dev); | ||
| 135 | ast_open_key(ast); | 134 | ast_open_key(ast); |
| 135 | ast_enable_mmio(dev); | ||
| 136 | 136 | ||
| 137 | /* Find out whether P2A works or whether to use device-tree */ | 137 | /* Find out whether P2A works or whether to use device-tree */ |
| 138 | ast_detect_config_mode(dev, &scu_rev); | 138 | ast_detect_config_mode(dev, &scu_rev); |
| @@ -576,6 +576,9 @@ void ast_driver_unload(struct drm_device *dev) · 437 unmodified lines | |||
| 576 | { | 576 | { |
| 577 | struct ast_private *ast = dev->dev_private; | 577 | struct ast_private *ast = dev->dev_private; |
| 578 | 578 | ||
| 579 | /* enable standard VGA decode */ | ||
| 580 | ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04); | ||
| 581 | |||
| 579 | ast_release_firmware(dev); | 582 | ast_release_firmware(dev); |
| 580 | kfree(ast->dp501_fw_addr); | 583 | kfree(ast->dp501_fw_addr); |
| 581 | ast_mode_fini(dev); | 584 | ast_mode_fini(dev); |
| @@ -604,7 +604,7 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc, · 603 unmodified lines | |||
| 604 | return -EINVAL; | 604 | return -EINVAL; |
| 605 | ast_open_key(ast); | 605 | ast_open_key(ast); |
| 606 | 606 | ||
| 607 | ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa1, 0xff, 0x04); | 607 | ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06); |
| 608 | 608 | ||
| 609 | ast_set_std_reg(crtc, adjusted_mode, &vbios_mode); | 609 | ast_set_std_reg(crtc, adjusted_mode, &vbios_mode); |
| 610 | ast_set_crtc_reg(crtc, adjusted_mode, &vbios_mode); | 610 | ast_set_crtc_reg(crtc, adjusted_mode, &vbios_mode); |
| @@ -46,7 +46,7 @@ void ast_enable_mmio(struct drm_device *dev) · 45 unmodified lines | |||
| 46 | { | 46 | { |
| 47 | struct ast_private *ast = dev->dev_private; | 47 | struct ast_private *ast = dev->dev_private; |
| 48 | 48 | ||
| 49 | ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa1, 0xff, 0x04); | 49 | ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | 52 | ||
| @@ -1528,9 +1528,9 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id, · 1527 unmodified lines | |||
| 1528 | if (!intel_gvt_ggtt_validate_range(vgpu, | 1528 | if (!intel_gvt_ggtt_validate_range(vgpu, |
| 1529 | workload->wa_ctx.indirect_ctx.guest_gma, | 1529 | workload->wa_ctx.indirect_ctx.guest_gma, |
| 1530 | workload->wa_ctx.indirect_ctx.size)) { | 1530 | workload->wa_ctx.indirect_ctx.size)) { |
| 1531 | kmem_cache_free(s->workloads, workload); | ||
| 1532 | gvt_vgpu_err("invalid wa_ctx at: 0x%lx\n", | 1531 | gvt_vgpu_err("invalid wa_ctx at: 0x%lx\n", |
| 1533 | workload->wa_ctx.indirect_ctx.guest_gma); | 1532 | workload->wa_ctx.indirect_ctx.guest_gma); |
| 1533 | kmem_cache_free(s->workloads, workload); | ||
| 1534 | return ERR_PTR(-EINVAL); | 1534 | return ERR_PTR(-EINVAL); |
| 1535 | } | 1535 | } |
| 1536 | } | 1536 | } |
| @@ -1542,9 +1542,9 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id, · 5 unmodified lines | |||
| 1542 | if (!intel_gvt_ggtt_validate_range(vgpu, | 1542 | if (!intel_gvt_ggtt_validate_range(vgpu, |
| 1543 | workload->wa_ctx.per_ctx.guest_gma, | 1543 | workload->wa_ctx.per_ctx.guest_gma, |
| 1544 | CACHELINE_BYTES)) { | 1544 | CACHELINE_BYTES)) { |
| 1545 | kmem_cache_free(s->workloads, workload); | ||
| 1546 | gvt_vgpu_err("invalid per_ctx at: 0x%lx\n", | 1545 | gvt_vgpu_err("invalid per_ctx at: 0x%lx\n", |
| 1547 | workload->wa_ctx.per_ctx.guest_gma); | 1546 | workload->wa_ctx.per_ctx.guest_gma); |
| 1547 | kmem_cache_free(s->workloads, workload); | ||
| 1548 | return ERR_PTR(-EINVAL); | 1548 | return ERR_PTR(-EINVAL); |
| 1549 | } | 1549 | } |
| 1550 | } | 1550 | } |
| @@ -771,16 +771,20 @@ nv50_msto_atomic_check(struct drm_encoder *encoder, · 770 unmodified lines | |||
| 771 | struct nv50_head_atom *asyh = nv50_head_atom(crtc_state); | 771 | struct nv50_head_atom *asyh = nv50_head_atom(crtc_state); |
| 772 | int slots; | 772 | int slots; |
| 773 | 773 | ||
| 774 | /* When restoring duplicated states, we need to make sure that the | 774 | if (crtc_state->mode_changed || crtc_state->connectors_changed) { |
| 775 | * bw remains the same and avoid recalculating it, as the connector's | 775 | /* |
| 776 | * bpc may have changed after the state was duplicated | 776 | * When restoring duplicated states, we need to make sure that |
| 777 | */ | 777 | * the bw remains the same and avoid recalculating it, as the |
| 778 | if (!state->duplicated) | 778 | * connector's bpc may have changed after the state was |
| 779 | asyh->dp.pbn = | 779 | * duplicated |
| 780 | drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, | 780 | */ |
| 781 | connector->display_info.bpc * 3); | 781 | if (!state->duplicated) { |
| 782 | const int bpp = connector->display_info.bpc * 3; | ||
| 783 | const int clock = crtc_state->adjusted_mode.clock; | ||
| 784 | |||
| 785 | asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp); | ||
| 786 | } | ||
| 782 | 787 | ||
| 783 | if (crtc_state->mode_changed) { | ||
| 784 | slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr, | 788 | slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr, |
| 785 | mstc->port, | 789 | mstc->port, |
| 786 | asyh->dp.pbn); | 790 | asyh->dp.pbn); |
| @@ -95,7 +95,7 @@ static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity) · 94 unmodified lines | |||
| 95 | rmb(); /* for list_empty to work without lock */ | 95 | rmb(); /* for list_empty to work without lock */ |
| 96 | 96 | ||
| 97 | if (list_empty(&entity->list) || | 97 | if (list_empty(&entity->list) || |
| 98 | spsc_queue_peek(&entity->job_queue) == NULL) | 98 | spsc_queue_count(&entity->job_queue) == 0) |
| 99 | return true; | 99 | return true; |
| 100 | 100 | ||
| 101 | return false; | 101 | return false; |
| @@ -281,7 +281,7 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity) · 179 unmodified lines | |||
| 281 | /* Consumption of existing IBs wasn't completed. Forcefully | 281 | /* Consumption of existing IBs wasn't completed. Forcefully |
| 282 | * remove them here. | 282 | * remove them here. |
| 283 | */ | 283 | */ |
| 284 | if (spsc_queue_peek(&entity->job_queue)) { | 284 | if (spsc_queue_count(&entity->job_queue)) { |
| 285 | if (sched) { | 285 | if (sched) { |
| 286 | /* Park the kernel for a moment to make sure it isn't processing | 286 | /* Park the kernel for a moment to make sure it isn't processing |
| 287 | * our enity. | 287 | * our enity. |