Skip to content

Commit 1ada9c0

Browse files
committed
Merge tag 'drm-fixes-2023-08-18-1' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Dave Airlie: "Regular enough week, mostly the usual amdgpu and i915 fixes. Also qaic, nouveau, qxl and a revert for an EDID patch that had some side effects, along with a couple of panel fixes. edid: - revert mode parsing fix that had side effects. i915: - Fix the flow for ignoring GuC SLPC efficient frequency selection - Fix SDVO panel_type initialization - Fix display probe for IVB Q and IVB D GT2 server nouveau: - fix use-after-free in connector code qaic: - integer overflow check fix - fix slicing memory leak panel: - fix JDI LT070ME05000 probing - fix AUO G121EAN01 timings amdgpu: - SMU 13.x fixes - Fix mcbp parameter for gfx9 - SMU 11.x fixes - Temporary fix for large numbers of XCP partitions - S0ix fixes - DCN 2.0 fix qxl: - fix use after free race in dumb object allocation" * tag 'drm-fixes-2023-08-18-1' of git://anongit.freedesktop.org/drm/drm: drm/qxl: fix UAF on handle creation Revert "drm/edid: Fix csync detailed mode parsing" drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create Revert "Revert "drm/amdgpu/display: change pipe policy for DCN 2.0"" drm/amd: flush any delayed gfxoff on suspend entry drm/amdgpu: skip fence GFX interrupts disable/enable for S0ix drm/amdgpu: skip xcp drm device allocation when out of drm resource drm/amd/pm: Update pci link width for smu v13.0.6 drm/amd/pm: Fix temperature unit of SMU v13.0.6 drm/amdgpu/pm: fix throttle_status for other than MP1 11.0.7 drm/amdgpu: disable mcbp if parameter zero is set drm/amd/pm: disallow the fan setting if there is no fan on smu 13.0.0 accel/qaic: Clean up integer overflow checking in map_user_pages() accel/qaic: Fix slicing memory leak drm/i915: fix display probe for IVB Q and IVB D GT2 server drm/i915/sdvo: fix panel_type initialization drm/i915/guc/slpc: Restore efficient freq earlier drm/panel: simple: Fix AUO G121EAN01 panel timings according to the docs drm/panel: JDI LT070ME05000 simplify with dev_err_probe()
2 parents 1693185 + c611589 commit 1ada9c0

24 files changed

+216
-132
lines changed

drivers/accel/qaic/qaic_control.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,31 @@ static int find_and_map_user_pages(struct qaic_device *qdev,
392392
struct qaic_manage_trans_dma_xfer *in_trans,
393393
struct ioctl_resources *resources, struct dma_xfer *xfer)
394394
{
395+
u64 xfer_start_addr, remaining, end, total;
395396
unsigned long need_pages;
396397
struct page **page_list;
397398
unsigned long nr_pages;
398399
struct sg_table *sgt;
399-
u64 xfer_start_addr;
400400
int ret;
401401
int i;
402402

403-
xfer_start_addr = in_trans->addr + resources->xferred_dma_size;
403+
if (check_add_overflow(in_trans->addr, resources->xferred_dma_size, &xfer_start_addr))
404+
return -EINVAL;
404405

405-
need_pages = DIV_ROUND_UP(in_trans->size + offset_in_page(xfer_start_addr) -
406-
resources->xferred_dma_size, PAGE_SIZE);
406+
if (in_trans->size < resources->xferred_dma_size)
407+
return -EINVAL;
408+
remaining = in_trans->size - resources->xferred_dma_size;
409+
if (remaining == 0)
410+
return 0;
411+
412+
if (check_add_overflow(xfer_start_addr, remaining, &end))
413+
return -EINVAL;
414+
415+
total = remaining + offset_in_page(xfer_start_addr);
416+
if (total >= SIZE_MAX)
417+
return -EINVAL;
418+
419+
need_pages = DIV_ROUND_UP(total, PAGE_SIZE);
407420

408421
nr_pages = need_pages;
409422

@@ -435,7 +448,7 @@ static int find_and_map_user_pages(struct qaic_device *qdev,
435448

436449
ret = sg_alloc_table_from_pages(sgt, page_list, nr_pages,
437450
offset_in_page(xfer_start_addr),
438-
in_trans->size - resources->xferred_dma_size, GFP_KERNEL);
451+
remaining, GFP_KERNEL);
439452
if (ret) {
440453
ret = -ENOMEM;
441454
goto free_sgt;
@@ -566,9 +579,6 @@ static int encode_dma(struct qaic_device *qdev, void *trans, struct wrapper_list
566579
QAIC_MANAGE_EXT_MSG_LENGTH)
567580
return -ENOMEM;
568581

569-
if (in_trans->addr + in_trans->size < in_trans->addr || !in_trans->size)
570-
return -EINVAL;
571-
572582
xfer = kmalloc(sizeof(*xfer), GFP_KERNEL);
573583
if (!xfer)
574584
return -ENOMEM;

drivers/accel/qaic/qaic_data.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
10211021
bo->dbc = dbc;
10221022
srcu_read_unlock(&dbc->ch_lock, rcu_id);
10231023
drm_gem_object_put(obj);
1024+
kfree(slice_ent);
10241025
srcu_read_unlock(&qdev->dev_lock, qdev_rcu_id);
10251026
srcu_read_unlock(&usr->qddev_lock, usr_rcu_id);
10261027

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,10 +3722,11 @@ static void amdgpu_device_set_mcbp(struct amdgpu_device *adev)
37223722
{
37233723
if (amdgpu_mcbp == 1)
37243724
adev->gfx.mcbp = true;
3725-
3726-
if ((adev->ip_versions[GC_HWIP][0] >= IP_VERSION(9, 0, 0)) &&
3727-
(adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 0, 0)) &&
3728-
adev->gfx.num_gfx_rings)
3725+
else if (amdgpu_mcbp == 0)
3726+
adev->gfx.mcbp = false;
3727+
else if ((adev->ip_versions[GC_HWIP][0] >= IP_VERSION(9, 0, 0)) &&
3728+
(adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 0, 0)) &&
3729+
adev->gfx.num_gfx_rings)
37293730
adev->gfx.mcbp = true;
37303731

37313732
if (amdgpu_sriov_vf(adev))
@@ -4393,6 +4394,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
43934394
drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);
43944395

43954396
cancel_delayed_work_sync(&adev->delayed_init_work);
4397+
flush_delayed_work(&adev->gfx.gfx_off_delay_work);
43964398

43974399
amdgpu_ras_suspend(adev);
43984400

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,41 @@ int amdgpu_fence_driver_sw_init(struct amdgpu_device *adev)
551551
return 0;
552552
}
553553

554+
/**
555+
* amdgpu_fence_need_ring_interrupt_restore - helper function to check whether
556+
* fence driver interrupts need to be restored.
557+
*
558+
* @ring: ring that to be checked
559+
*
560+
* Interrupts for rings that belong to GFX IP don't need to be restored
561+
* when the target power state is s0ix.
562+
*
563+
* Return true if need to restore interrupts, false otherwise.
564+
*/
565+
static bool amdgpu_fence_need_ring_interrupt_restore(struct amdgpu_ring *ring)
566+
{
567+
struct amdgpu_device *adev = ring->adev;
568+
bool is_gfx_power_domain = false;
569+
570+
switch (ring->funcs->type) {
571+
case AMDGPU_RING_TYPE_SDMA:
572+
/* SDMA 5.x+ is part of GFX power domain so it's covered by GFXOFF */
573+
if (adev->ip_versions[SDMA0_HWIP][0] >= IP_VERSION(5, 0, 0))
574+
is_gfx_power_domain = true;
575+
break;
576+
case AMDGPU_RING_TYPE_GFX:
577+
case AMDGPU_RING_TYPE_COMPUTE:
578+
case AMDGPU_RING_TYPE_KIQ:
579+
case AMDGPU_RING_TYPE_MES:
580+
is_gfx_power_domain = true;
581+
break;
582+
default:
583+
break;
584+
}
585+
586+
return !(adev->in_s0ix && is_gfx_power_domain);
587+
}
588+
554589
/**
555590
* amdgpu_fence_driver_hw_fini - tear down the fence driver
556591
* for all possible rings.
@@ -579,7 +614,8 @@ void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev)
579614
amdgpu_fence_driver_force_completion(ring);
580615

581616
if (!drm_dev_is_unplugged(adev_to_drm(adev)) &&
582-
ring->fence_drv.irq_src)
617+
ring->fence_drv.irq_src &&
618+
amdgpu_fence_need_ring_interrupt_restore(ring))
583619
amdgpu_irq_put(adev, ring->fence_drv.irq_src,
584620
ring->fence_drv.irq_type);
585621

@@ -655,7 +691,8 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
655691
continue;
656692

657693
/* enable the interrupt */
658-
if (ring->fence_drv.irq_src)
694+
if (ring->fence_drv.irq_src &&
695+
amdgpu_fence_need_ring_interrupt_restore(ring))
659696
amdgpu_irq_get(adev, ring->fence_drv.irq_src,
660697
ring->fence_drv.irq_type);
661698
}

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -692,15 +692,8 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)
692692

693693
if (adev->gfx.gfx_off_req_count == 0 &&
694694
!adev->gfx.gfx_off_state) {
695-
/* If going to s2idle, no need to wait */
696-
if (adev->in_s0ix) {
697-
if (!amdgpu_dpm_set_powergating_by_smu(adev,
698-
AMD_IP_BLOCK_TYPE_GFX, true))
699-
adev->gfx.gfx_off_state = true;
700-
} else {
701-
schedule_delayed_work(&adev->gfx.gfx_off_delay_work,
695+
schedule_delayed_work(&adev->gfx.gfx_off_delay_work,
702696
delay);
703-
}
704697
}
705698
} else {
706699
if (adev->gfx.gfx_off_req_count == 0) {

drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ void amdgpu_sw_ring_ib_begin(struct amdgpu_ring *ring)
397397
struct amdgpu_ring_mux *mux = &adev->gfx.muxer;
398398

399399
WARN_ON(!ring->is_sw_ring);
400-
if (ring->hw_prio > AMDGPU_RING_PRIO_DEFAULT) {
400+
if (adev->gfx.mcbp && ring->hw_prio > AMDGPU_RING_PRIO_DEFAULT) {
401401
if (amdgpu_mcbp_scan(mux) > 0)
402402
amdgpu_mcbp_trigger_preempt(mux);
403403
return;

drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,13 @@ static int amdgpu_xcp_dev_alloc(struct amdgpu_device *adev)
239239

240240
for (i = 1; i < MAX_XCP; i++) {
241241
ret = amdgpu_xcp_drm_dev_alloc(&p_ddev);
242-
if (ret)
242+
if (ret == -ENOSPC) {
243+
dev_warn(adev->dev,
244+
"Skip xcp node #%d when out of drm node resource.", i);
245+
return 0;
246+
} else if (ret) {
243247
return ret;
248+
}
244249

245250
/* Redirect all IOCTLs to the primary device */
246251
adev->xcp_mgr->xcp[i].rdev = p_ddev->render->dev;
@@ -328,6 +333,9 @@ int amdgpu_xcp_dev_register(struct amdgpu_device *adev,
328333
return 0;
329334

330335
for (i = 1; i < MAX_XCP; i++) {
336+
if (!adev->xcp_mgr->xcp[i].ddev)
337+
break;
338+
331339
ret = drm_dev_register(adev->xcp_mgr->xcp[i].ddev, ent->driver_data);
332340
if (ret)
333341
return ret;
@@ -345,6 +353,9 @@ void amdgpu_xcp_dev_unplug(struct amdgpu_device *adev)
345353
return;
346354

347355
for (i = 1; i < MAX_XCP; i++) {
356+
if (!adev->xcp_mgr->xcp[i].ddev)
357+
break;
358+
348359
p_ddev = adev->xcp_mgr->xcp[i].ddev;
349360
drm_dev_unplug(p_ddev);
350361
p_ddev->render->dev = adev->xcp_mgr->xcp[i].rdev;

drivers/gpu/drm/amd/amdkfd/kfd_topology.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,14 @@ int kfd_topology_add_device(struct kfd_node *gpu)
19651965
const char *asic_name = amdgpu_asic_name[gpu->adev->asic_type];
19661966

19671967
gpu_id = kfd_generate_gpu_id(gpu);
1968-
pr_debug("Adding new GPU (ID: 0x%x) to topology\n", gpu_id);
1968+
if (gpu->xcp && !gpu->xcp->ddev) {
1969+
dev_warn(gpu->adev->dev,
1970+
"Won't add GPU (ID: 0x%x) to topology since it has no drm node assigned.",
1971+
gpu_id);
1972+
return 0;
1973+
} else {
1974+
pr_debug("Adding new GPU (ID: 0x%x) to topology\n", gpu_id);
1975+
}
19691976

19701977
/* Check to see if this gpu device exists in the topology_device_list.
19711978
* If so, assign the gpu to that device,

drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static const struct dc_debug_options debug_defaults_drv = {
712712
.timing_trace = false,
713713
.clock_trace = true,
714714
.disable_pplib_clock_request = true,
715-
.pipe_split_policy = MPC_SPLIT_DYNAMIC,
715+
.pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
716716
.force_single_disp_pipe_split = false,
717717
.disable_dcc = DCC_ENABLE,
718718
.vsr_support = true,

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -588,21 +588,21 @@ static int sienna_cichlid_tables_init(struct smu_context *smu)
588588
return -ENOMEM;
589589
}
590590

591-
static uint32_t sienna_cichlid_get_throttler_status_locked(struct smu_context *smu)
591+
static uint32_t sienna_cichlid_get_throttler_status_locked(struct smu_context *smu,
592+
bool use_metrics_v3,
593+
bool use_metrics_v2)
592594
{
593595
struct smu_table_context *smu_table= &smu->smu_table;
594596
SmuMetricsExternal_t *metrics_ext =
595597
(SmuMetricsExternal_t *)(smu_table->metrics_table);
596598
uint32_t throttler_status = 0;
597599
int i;
598600

599-
if ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 7)) &&
600-
(smu->smc_fw_version >= 0x3A4900)) {
601+
if (use_metrics_v3) {
601602
for (i = 0; i < THROTTLER_COUNT; i++)
602603
throttler_status |=
603604
(metrics_ext->SmuMetrics_V3.ThrottlingPercentage[i] ? 1U << i : 0);
604-
} else if ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 7)) &&
605-
(smu->smc_fw_version >= 0x3A4300)) {
605+
} else if (use_metrics_v2) {
606606
for (i = 0; i < THROTTLER_COUNT; i++)
607607
throttler_status |=
608608
(metrics_ext->SmuMetrics_V2.ThrottlingPercentage[i] ? 1U << i : 0);
@@ -864,7 +864,7 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,
864864
metrics->TemperatureVrSoc) * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
865865
break;
866866
case METRICS_THROTTLER_STATUS:
867-
*value = sienna_cichlid_get_throttler_status_locked(smu);
867+
*value = sienna_cichlid_get_throttler_status_locked(smu, use_metrics_v3, use_metrics_v2);
868868
break;
869869
case METRICS_CURR_FANSPEED:
870870
*value = use_metrics_v3 ? metrics_v3->CurrFanSpeed :
@@ -4017,7 +4017,7 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
40174017
gpu_metrics->current_dclk1 = use_metrics_v3 ? metrics_v3->CurrClock[PPCLK_DCLK_1] :
40184018
use_metrics_v2 ? metrics_v2->CurrClock[PPCLK_DCLK_1] : metrics->CurrClock[PPCLK_DCLK_1];
40194019

4020-
gpu_metrics->throttle_status = sienna_cichlid_get_throttler_status_locked(smu);
4020+
gpu_metrics->throttle_status = sienna_cichlid_get_throttler_status_locked(smu, use_metrics_v3, use_metrics_v2);
40214021
gpu_metrics->indep_throttle_status =
40224022
smu_cmn_get_indep_throttler_status(gpu_metrics->throttle_status,
40234023
sienna_cichlid_throttler_map);

0 commit comments

Comments
 (0)