Pull drm fixes from Dave Airlie: "Oh I screwed up last week's fixes pull, and forgot to send.. Back to work, thanks to Sima for last week, not too many fixes as expected getting close to release [ sic - Linus ], amdgpu and xe have a couple each, and then some other misc ones. amdgpu: - PSR-SU fix - Reseved VMID fix xe: - Use write-back caching mode for system memory on DGFX - Do not leak object when finalizing hdcp gsc bridge: - adv7511 EDID irq fix gma500: - NULL mode fixes. meson: - fix resource leak" * tag 'drm-fixes-2024-07-12' of https://gitlab.freedesktop.org/drm/kernel: Revert "drm/amd/display: Reset freesync config before update new state" drm/xe/display/xe_hdcp_gsc: Free arbiter on driver removal drm/xe: Use write-back caching mode for system memory on DGFX drm/amdgpu: reject gang submit on reserved VMIDs drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes drm/meson: fix canvas release in bind function drm/bridge: adv7511: Fix Intermittent EDID failures
Unified · Split
| @@ -1093,6 +1093,21 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) · 1092 unmodified lines | |||
| 1093 | unsigned int i; | 1093 | unsigned int i; |
| 1094 | int r; | 1094 | int r; |
| 1095 | 1095 | ||
| 1096 | /* | ||
| 1097 | * We can't use gang submit on with reserved VMIDs when the VM changes | ||
| 1098 | * can't be invalidated by more than one engine at the same time. | ||
| 1099 | */ | ||
| 1100 | if (p->gang_size > 1 && !p->adev->vm_manager.concurrent_flush) { | ||
| 1101 | for (i = 0; i < p->gang_size; ++i) { | ||
| 1102 | struct drm_sched_entity *entity = p->entities[i]; | ||
| 1103 | struct drm_gpu_scheduler *sched = entity->rq->sched; | ||
| 1104 | struct amdgpu_ring *ring = to_amdgpu_ring(sched); | ||
| 1105 | |||
| 1106 | if (amdgpu_vmid_uses_reserved(vm, ring->vm_hub)) | ||
| 1107 | return -EINVAL; | ||
| 1108 | } | ||
| 1109 | } | ||
| 1110 | |||
| 1096 | r = amdgpu_vm_clear_freed(adev, vm, NULL); | 1111 | r = amdgpu_vm_clear_freed(adev, vm, NULL); |
| 1097 | if (r) | 1112 | if (r) |
| 1098 | return r; | 1113 | return r; |
| @@ -406,7 +406,7 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring, · 405 unmodified lines | |||
| 406 | if (r || !idle) | 406 | if (r || !idle) |
| 407 | goto error; | 407 | goto error; |
| 408 | 408 | ||
| 409 | if (vm->reserved_vmid[vmhub] || (enforce_isolation && (vmhub == AMDGPU_GFXHUB(0)))) { | 409 | if (amdgpu_vmid_uses_reserved(vm, vmhub)) { |
| 410 | r = amdgpu_vmid_grab_reserved(vm, ring, job, &id, fence); | 410 | r = amdgpu_vmid_grab_reserved(vm, ring, job, &id, fence); |
| 411 | if (r || !id) | 411 | if (r || !id) |
| 412 | goto error; | 412 | goto error; |
| @@ -456,6 +456,19 @@ error: · 43 unmodified lines | |||
| 456 | return r; | 456 | return r; |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | /* | ||
| 460 | * amdgpu_vmid_uses_reserved - check if a VM will use a reserved VMID | ||
| 461 | * @vm: the VM to check | ||
| 462 | * @vmhub: the VMHUB which will be used | ||
| 463 | * | ||
| 464 | * Returns: True if the VM will use a reserved VMID. | ||
| 465 | */ | ||
| 466 | bool amdgpu_vmid_uses_reserved(struct amdgpu_vm *vm, unsigned int vmhub) | ||
| 467 | { | ||
| 468 | return vm->reserved_vmid[vmhub] || | ||
| 469 | (enforce_isolation && (vmhub == AMDGPU_GFXHUB(0))); | ||
| 470 | } | ||
| 471 | |||
| 459 | int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev, | 472 | int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev, |
| 460 | unsigned vmhub) | 473 | unsigned vmhub) |
| 461 | { | 474 | { |
| @@ -78,6 +78,7 @@ void amdgpu_pasid_free_delayed(struct dma_resv *resv, · 77 unmodified lines | |||
| 78 | 78 | ||
| 79 | bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev, | 79 | bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev, |
| 80 | struct amdgpu_vmid *id); | 80 | struct amdgpu_vmid *id); |
| 81 | bool amdgpu_vmid_uses_reserved(struct amdgpu_vm *vm, unsigned int vmhub); | ||
| 81 | int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev, | 82 | int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev, |
| 82 | unsigned vmhub); | 83 | unsigned vmhub); |
| 83 | void amdgpu_vmid_free_reserved(struct amdgpu_device *adev, | 84 | void amdgpu_vmid_free_reserved(struct amdgpu_device *adev, |
| @@ -10048,7 +10048,6 @@ skip_modeset: · 10047 unmodified lines | |||
| 10048 | } | 10048 | } |
| 10049 | 10049 | ||
| 10050 | /* Update Freesync settings. */ | 10050 | /* Update Freesync settings. */ |
| 10051 | reset_freesync_config_for_crtc(dm_new_crtc_state); | ||
| 10052 | get_freesync_config_for_crtc(dm_new_crtc_state, | 10051 | get_freesync_config_for_crtc(dm_new_crtc_state, |
| 10053 | dm_new_conn_state); | 10052 | dm_new_conn_state); |
| 10054 | 10053 | ||
| @@ -401,7 +401,7 @@ struct adv7511 { · 400 unmodified lines | |||
| 401 | 401 | ||
| 402 | #ifdef CONFIG_DRM_I2C_ADV7511_CEC | 402 | #ifdef CONFIG_DRM_I2C_ADV7511_CEC |
| 403 | int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511); | 403 | int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511); |
| 404 | void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1); | 404 | int adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1); |
| 405 | #else | 405 | #else |
| 406 | static inline int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511) | 406 | static inline int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511) |
| 407 | { | 407 | { |
| @@ -119,7 +119,7 @@ static void adv7511_cec_rx(struct adv7511 *adv7511, int rx_buf) · 118 unmodified lines | |||
| 119 | cec_received_msg(adv7511->cec_adap, &msg); | 119 | cec_received_msg(adv7511->cec_adap, &msg); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1) | 122 | int adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1) |
| 123 | { | 123 | { |
| 124 | unsigned int offset = adv7511->info->reg_cec_offset; | 124 | unsigned int offset = adv7511->info->reg_cec_offset; |
| 125 | const u32 irq_tx_mask = ADV7511_INT1_CEC_TX_READY | | 125 | const u32 irq_tx_mask = ADV7511_INT1_CEC_TX_READY | |
| @@ -131,16 +131,19 @@ void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1) · 5 unmodified lines | |||
| 131 | unsigned int rx_status; | 131 | unsigned int rx_status; |
| 132 | int rx_order[3] = { -1, -1, -1 }; | 132 | int rx_order[3] = { -1, -1, -1 }; |
| 133 | int i; | 133 | int i; |
| 134 | int irq_status = IRQ_NONE; | ||
| 134 | 135 | ||
| 135 | if (irq1 & irq_tx_mask) | 136 | if (irq1 & irq_tx_mask) { |
| 136 | adv_cec_tx_raw_status(adv7511, irq1); | 137 | adv_cec_tx_raw_status(adv7511, irq1); |
| 138 | irq_status = IRQ_HANDLED; | ||
| 139 | } | ||
| 137 | 140 | ||
| 138 | if (!(irq1 & irq_rx_mask)) | 141 | if (!(irq1 & irq_rx_mask)) |
| 139 | return; | 142 | return irq_status; |
| 140 | 143 | ||
| 141 | if (regmap_read(adv7511->regmap_cec, | 144 | if (regmap_read(adv7511->regmap_cec, |
| 142 | ADV7511_REG_CEC_RX_STATUS + offset, &rx_status)) | 145 | ADV7511_REG_CEC_RX_STATUS + offset, &rx_status)) |
| 143 | return; | 146 | return irq_status; |
| 144 | 147 | ||
| 145 | /* | 148 | /* |
| 146 | * ADV7511_REG_CEC_RX_STATUS[5:0] contains the reception order of RX | 149 | * ADV7511_REG_CEC_RX_STATUS[5:0] contains the reception order of RX |
| @@ -172,6 +175,8 @@ void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1) · 25 unmodified lines | |||
| 172 | 175 | ||
| 173 | adv7511_cec_rx(adv7511, rx_buf); | 176 | adv7511_cec_rx(adv7511, rx_buf); |
| 174 | } | 177 | } |
| 178 | |||
| 179 | return IRQ_HANDLED; | ||
| 175 | } | 180 | } |
| 176 | 181 | ||
| 177 | static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable) | 182 | static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable) |
| @@ -469,6 +469,8 @@ static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd) · 468 unmodified lines | |||
| 469 | { | 469 | { |
| 470 | unsigned int irq0, irq1; | 470 | unsigned int irq0, irq1; |
| 471 | int ret; | 471 | int ret; |
| 472 | int cec_status = IRQ_NONE; | ||
| 473 | int irq_status = IRQ_NONE; | ||
| 472 | 474 | ||
| 473 | ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); | 475 | ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); |
| 474 | if (ret < 0) | 476 | if (ret < 0) |
| @@ -478,29 +480,31 @@ static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd) · 3 unmodified lines | |||
| 478 | if (ret < 0) | 480 | if (ret < 0) |
| 479 | return ret; | 481 | return ret; |
| 480 | 482 | ||
| 481 | /* If there is no IRQ to handle, exit indicating no IRQ data */ | ||
| 482 | if (!(irq0 & (ADV7511_INT0_HPD | ADV7511_INT0_EDID_READY)) && | ||
| 483 | !(irq1 & ADV7511_INT1_DDC_ERROR)) | ||
| 484 | return -ENODATA; | ||
| 485 | |||
| 486 | regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); | 483 | regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); |
| 487 | regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); | 484 | regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); |
| 488 | 485 | ||
| 489 | if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder) | 486 | if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder) { |
| 490 | schedule_work(&adv7511->hpd_work); | 487 | schedule_work(&adv7511->hpd_work); |
| 488 | irq_status = IRQ_HANDLED; | ||
| 489 | } | ||
| 491 | 490 | ||
| 492 | if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) { | 491 | if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) { |
| 493 | adv7511->edid_read = true; | 492 | adv7511->edid_read = true; |
| 494 | 493 | ||
| 495 | if (adv7511->i2c_main->irq) | 494 | if (adv7511->i2c_main->irq) |
| 496 | wake_up_all(&adv7511->wq); | 495 | wake_up_all(&adv7511->wq); |
| 496 | irq_status = IRQ_HANDLED; | ||
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | #ifdef CONFIG_DRM_I2C_ADV7511_CEC | 499 | #ifdef CONFIG_DRM_I2C_ADV7511_CEC |
| 500 | adv7511_cec_irq_process(adv7511, irq1); | 500 | cec_status = adv7511_cec_irq_process(adv7511, irq1); |
| 501 | #endif | 501 | #endif |
| 502 | 502 | ||
| 503 | return 0; | 503 | /* If there is no IRQ to handle, exit indicating no IRQ data */ |
| 504 | if (irq_status == IRQ_HANDLED || cec_status == IRQ_HANDLED) | ||
| 505 | return IRQ_HANDLED; | ||
| 506 | |||
| 507 | return IRQ_NONE; | ||
| 504 | } | 508 | } |
| 505 | 509 | ||
| 506 | static irqreturn_t adv7511_irq_handler(int irq, void *devid) | 510 | static irqreturn_t adv7511_irq_handler(int irq, void *devid) |
| @@ -509,7 +513,7 @@ static irqreturn_t adv7511_irq_handler(int irq, void *devid) · 2 unmodified lines | |||
| 509 | int ret; | 513 | int ret; |
| 510 | 514 | ||
| 511 | ret = adv7511_irq_process(adv7511, true); | 515 | ret = adv7511_irq_process(adv7511, true); |
| 512 | return ret < 0 ? IRQ_NONE : IRQ_HANDLED; | 516 | return ret < 0 ? IRQ_NONE : ret; |
| 513 | } | 517 | } |
| 514 | 518 | ||
| 515 | /* ----------------------------------------------------------------------------- | 519 | /* ----------------------------------------------------------------------------- |
| @@ -311,6 +311,9 @@ static int cdv_intel_lvds_get_modes(struct drm_connector *connector) · 310 unmodified lines | |||
| 311 | if (mode_dev->panel_fixed_mode != NULL) { | 311 | if (mode_dev->panel_fixed_mode != NULL) { |
| 312 | struct drm_display_mode *mode = | 312 | struct drm_display_mode *mode = |
| 313 | drm_mode_duplicate(dev, mode_dev->panel_fixed_mode); | 313 | drm_mode_duplicate(dev, mode_dev->panel_fixed_mode); |
| 314 | if (!mode) | ||
| 315 | return 0; | ||
| 316 | |||
| 314 | drm_mode_probed_add(connector, mode); | 317 | drm_mode_probed_add(connector, mode); |
| 315 | return 1; | 318 | return 1; |
| 316 | } | 319 | } |
| @@ -504,6 +504,9 @@ static int psb_intel_lvds_get_modes(struct drm_connector *connector) · 503 unmodified lines | |||
| 504 | if (mode_dev->panel_fixed_mode != NULL) { | 504 | if (mode_dev->panel_fixed_mode != NULL) { |
| 505 | struct drm_display_mode *mode = | 505 | struct drm_display_mode *mode = |
| 506 | drm_mode_duplicate(dev, mode_dev->panel_fixed_mode); | 506 | drm_mode_duplicate(dev, mode_dev->panel_fixed_mode); |
| 507 | if (!mode) | ||
| 508 | return 0; | ||
| 509 | |||
| 507 | drm_mode_probed_add(connector, mode); | 510 | drm_mode_probed_add(connector, mode); |
| 508 | return 1; | 511 | return 1; |
| 509 | } | 512 | } |
| @@ -250,29 +250,20 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) · 249 unmodified lines | |||
| 250 | if (ret) | 250 | if (ret) |
| 251 | goto free_drm; | 251 | goto free_drm; |
| 252 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_0); | 252 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_0); |
| 253 | if (ret) { | 253 | if (ret) |
| 254 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); | 254 | goto free_canvas_osd1; |
| 255 | goto free_drm; | ||
| 256 | } | ||
| 257 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_1); | 255 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_1); |
| 258 | if (ret) { | 256 | if (ret) |
| 259 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); | 257 | goto free_canvas_vd1_0; |
| 260 | meson_canvas_free(priv->canvas, priv->canvas_id_vd1_0); | ||
| 261 | goto free_drm; | ||
| 262 | } | ||
| 263 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_2); | 258 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_2); |
| 264 | if (ret) { | 259 | if (ret) |
| 265 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); | 260 | goto free_canvas_vd1_1; |
| 266 | meson_canvas_free(priv->canvas, priv->canvas_id_vd1_0); | ||
| 267 | meson_canvas_free(priv->canvas, priv->canvas_id_vd1_1); | ||
| 268 | goto free_drm; | ||
| 269 | } | ||
| 270 | 261 | ||
| 271 | priv->vsync_irq = platform_get_irq(pdev, 0); | 262 | priv->vsync_irq = platform_get_irq(pdev, 0); |
| 272 | 263 | ||
| 273 | ret = drm_vblank_init(drm, 1); | 264 | ret = drm_vblank_init(drm, 1); |
| 274 | if (ret) | 265 | if (ret) |
| 275 | goto free_drm; | 266 | goto free_canvas_vd1_2; |
| 276 | 267 | ||
| 277 | /* Assign limits per soc revision/package */ | 268 | /* Assign limits per soc revision/package */ |
| 278 | for (i = 0 ; i < ARRAY_SIZE(meson_drm_soc_attrs) ; ++i) { | 269 | for (i = 0 ; i < ARRAY_SIZE(meson_drm_soc_attrs) ; ++i) { |
| @@ -288,11 +279,11 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) · 9 unmodified lines | |||
| 288 | */ | 279 | */ |
| 289 | ret = drm_aperture_remove_framebuffers(&meson_driver); | 280 | ret = drm_aperture_remove_framebuffers(&meson_driver); |
| 290 | if (ret) | 281 | if (ret) |
| 291 | goto free_drm; | 282 | goto free_canvas_vd1_2; |
| 292 | 283 | ||
| 293 | ret = drmm_mode_config_init(drm); | 284 | ret = drmm_mode_config_init(drm); |
| 294 | if (ret) | 285 | if (ret) |
| 295 | goto free_drm; | 286 | goto free_canvas_vd1_2; |
| 296 | drm->mode_config.max_width = 3840; | 287 | drm->mode_config.max_width = 3840; |
| 297 | drm->mode_config.max_height = 2160; | 288 | drm->mode_config.max_height = 2160; |
| 298 | drm->mode_config.funcs = &meson_mode_config_funcs; | 289 | drm->mode_config.funcs = &meson_mode_config_funcs; |
| @@ -307,7 +298,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) · 8 unmodified lines | |||
| 307 | if (priv->afbcd.ops) { | 298 | if (priv->afbcd.ops) { |
| 308 | ret = priv->afbcd.ops->init(priv); | 299 | ret = priv->afbcd.ops->init(priv); |
| 309 | if (ret) | 300 | if (ret) |
| 310 | goto free_drm; | 301 | goto free_canvas_vd1_2; |
| 311 | } | 302 | } |
| 312 | 303 | ||
| 313 | /* Encoder Initialization */ | 304 | /* Encoder Initialization */ |
| @@ -371,6 +362,14 @@ uninstall_irq: · 57 unmodified lines | |||
| 371 | exit_afbcd: | 362 | exit_afbcd: |
| 372 | if (priv->afbcd.ops) | 363 | if (priv->afbcd.ops) |
| 373 | priv->afbcd.ops->exit(priv); | 364 | priv->afbcd.ops->exit(priv); |
| 365 | free_canvas_vd1_2: | ||
| 366 | meson_canvas_free(priv->canvas, priv->canvas_id_vd1_2); | ||
| 367 | free_canvas_vd1_1: | ||
| 368 | meson_canvas_free(priv->canvas, priv->canvas_id_vd1_1); | ||
| 369 | free_canvas_vd1_0: | ||
| 370 | meson_canvas_free(priv->canvas, priv->canvas_id_vd1_0); | ||
| 371 | free_canvas_osd1: | ||
| 372 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); | ||
| 374 | free_drm: | 373 | free_drm: |
| 375 | drm_dev_put(drm); | 374 | drm_dev_put(drm); |
| 376 | 375 | ||
| @@ -159,12 +159,16 @@ void intel_hdcp_gsc_fini(struct xe_device *xe) · 158 unmodified lines | |||
| 159 | { | 159 | { |
| 160 | struct intel_hdcp_gsc_message *hdcp_message = | 160 | struct intel_hdcp_gsc_message *hdcp_message = |
| 161 | xe->display.hdcp.hdcp_message; | 161 | xe->display.hdcp.hdcp_message; |
| 162 | struct i915_hdcp_arbiter *arb = xe->display.hdcp.arbiter; | ||
| 162 | 163 | ||
| 163 | if (!hdcp_message) | 164 | if (hdcp_message) { |
| 164 | return; | 165 | xe_bo_unpin_map_no_vm(hdcp_message->hdcp_bo); |
| 166 | kfree(hdcp_message); | ||
| 167 | xe->display.hdcp.hdcp_message = NULL; | ||
| 168 | } | ||
| 165 | 169 | ||
| 166 | xe_bo_unpin_map_no_vm(hdcp_message->hdcp_bo); | 170 | kfree(arb); |
| 167 | kfree(hdcp_message); | 171 | xe->display.hdcp.arbiter = NULL; |
| 168 | } | 172 | } |
| 169 | 173 | ||
| 170 | static int xe_gsc_send_sync(struct xe_device *xe, | 174 | static int xe_gsc_send_sync(struct xe_device *xe, |
| @@ -317,7 +317,7 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo, · 316 unmodified lines | |||
| 317 | struct xe_device *xe = xe_bo_device(bo); | 317 | struct xe_device *xe = xe_bo_device(bo); |
| 318 | struct xe_ttm_tt *tt; | 318 | struct xe_ttm_tt *tt; |
| 319 | unsigned long extra_pages; | 319 | unsigned long extra_pages; |
| 320 | enum ttm_caching caching; | 320 | enum ttm_caching caching = ttm_cached; |
| 321 | int err; | 321 | int err; |
| 322 | 322 | ||
| 323 | tt = kzalloc(sizeof(*tt), GFP_KERNEL); | 323 | tt = kzalloc(sizeof(*tt), GFP_KERNEL); |
| @@ -331,26 +331,35 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo, · 7 unmodified lines | |||
| 331 | extra_pages = DIV_ROUND_UP(xe_device_ccs_bytes(xe, bo->size), | 331 | extra_pages = DIV_ROUND_UP(xe_device_ccs_bytes(xe, bo->size), |
| 332 | PAGE_SIZE); | 332 | PAGE_SIZE); |
| 333 | 333 | ||
| 334 | switch (bo->cpu_caching) { | ||
| 335 | case DRM_XE_GEM_CPU_CACHING_WC: | ||
| 336 | caching = ttm_write_combined; | ||
| 337 | break; | ||
| 338 | default: | ||
| 339 | caching = ttm_cached; | ||
| 340 | break; | ||
| 341 | } | ||
| 342 | |||
| 343 | WARN_ON((bo->flags & XE_BO_FLAG_USER) && !bo->cpu_caching); | ||
| 344 | |||
| 345 | /* | 334 | /* |
| 346 | * Display scanout is always non-coherent with the CPU cache. | 335 | * DGFX system memory is always WB / ttm_cached, since |
| 347 | * | 336 | * other caching modes are only supported on x86. DGFX |
| 348 | * For Xe_LPG and beyond, PPGTT PTE lookups are also non-coherent and | 337 | * GPU system memory accesses are always coherent with the |
| 349 | * require a CPU:WC mapping. | 338 | * CPU. |
| 350 | */ | 339 | */ |
| 351 | if ((!bo->cpu_caching && bo->flags & XE_BO_FLAG_SCANOUT) || | 340 | if (!IS_DGFX(xe)) { |
| 352 | (xe->info.graphics_verx100 >= 1270 && bo->flags & XE_BO_FLAG_PAGETABLE)) | 341 | switch (bo->cpu_caching) { |
| 353 | caching = ttm_write_combined; | 342 | case DRM_XE_GEM_CPU_CACHING_WC: |
| 343 | caching = ttm_write_combined; | ||
| 344 | break; | ||
| 345 | default: | ||
| 346 | caching = ttm_cached; | ||
| 347 | break; | ||
| 348 | } | ||
| 349 | |||
| 350 | WARN_ON((bo->flags & XE_BO_FLAG_USER) && !bo->cpu_caching); | ||
| 351 | |||
| 352 | /* | ||
| 353 | * Display scanout is always non-coherent with the CPU cache. | ||
| 354 | * | ||
| 355 | * For Xe_LPG and beyond, PPGTT PTE lookups are also | ||
| 356 | * non-coherent and require a CPU:WC mapping. | ||
| 357 | */ | ||
| 358 | if ((!bo->cpu_caching && bo->flags & XE_BO_FLAG_SCANOUT) || | ||
| 359 | (xe->info.graphics_verx100 >= 1270 && | ||
| 360 | bo->flags & XE_BO_FLAG_PAGETABLE)) | ||
| 361 | caching = ttm_write_combined; | ||
| 362 | } | ||
| 354 | 363 | ||
| 355 | err = ttm_tt_init(&tt->ttm, &bo->ttm, page_flags, caching, extra_pages); | 364 | err = ttm_tt_init(&tt->ttm, &bo->ttm, page_flags, caching, extra_pages); |
| 356 | if (err) { | 365 | if (err) { |
| @@ -66,7 +66,8 @@ struct xe_bo { · 65 unmodified lines | |||
| 66 | 66 | ||
| 67 | /** | 67 | /** |
| 68 | * @cpu_caching: CPU caching mode. Currently only used for userspace | 68 | * @cpu_caching: CPU caching mode. Currently only used for userspace |
| 69 | * objects. | 69 | * objects. Exceptions are system memory on DGFX, which is always |
| 70 | * WB. | ||
| 70 | */ | 71 | */ |
| 71 | u16 cpu_caching; | 72 | u16 cpu_caching; |
| 72 | 73 | ||
| @@ -776,7 +776,13 @@ struct drm_xe_gem_create { · 775 unmodified lines | |||
| 776 | #define DRM_XE_GEM_CPU_CACHING_WC 2 | 776 | #define DRM_XE_GEM_CPU_CACHING_WC 2 |
| 777 | /** | 777 | /** |
| 778 | * @cpu_caching: The CPU caching mode to select for this object. If | 778 | * @cpu_caching: The CPU caching mode to select for this object. If |
| 779 | * mmaping the object the mode selected here will also be used. | 779 | * mmaping the object the mode selected here will also be used. The |
| 780 | * exception is when mapping system memory (including data evicted | ||
| 781 | * to system) on discrete GPUs. The caching mode selected will | ||
| 782 | * then be overridden to DRM_XE_GEM_CPU_CACHING_WB, and coherency | ||
| 783 | * between GPU- and CPU is guaranteed. The caching mode of | ||
| 784 | * existing CPU-mappings will be updated transparently to | ||
| 785 | * user-space clients. | ||
| 780 | */ | 786 | */ |
| 781 | __u16 cpu_caching; | 787 | __u16 cpu_caching; |
| 782 | /** @pad: MBZ */ | 788 | /** @pad: MBZ */ |