From cbb2300459a8b8bee350eb24e48a17f558b4f334 Mon Sep 17 00:00:00 2001 From: Harshdeep Dhatt Date: Tue, 21 Apr 2020 23:26:55 -0600 Subject: [PATCH] msm: kgsl: Separate out reset sequence for a6xx gmu targets Now that we have a6xx gmu specific gpudev, we can dissociate the gmu reset sequence from the generic a6xx_reset function. Change-Id: Ib56456d5390fc059fc34407941f805c06cdfe42a Signed-off-by: Harshdeep Dhatt --- drivers/gpu/msm/adreno_a6xx.c | 16 ++++---------- drivers/gpu/msm/adreno_a6xx_gmu.c | 36 +++++++++++++++++++++++++------ drivers/gpu/msm/adreno_a6xx_gmu.h | 8 +++++++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/msm/adreno_a6xx.c b/drivers/gpu/msm/adreno_a6xx.c index 5eb7e8eee1f0..91087ae772b6 100644 --- a/drivers/gpu/msm/adreno_a6xx.c +++ b/drivers/gpu/msm/adreno_a6xx.c @@ -1080,23 +1080,15 @@ static int64_t a6xx_read_throttling_counters(struct adreno_device *adreno_dev) * a6xx_reset() - Helper function to reset the GPU * @device: Pointer to the KGSL device structure for the GPU * - * Try to reset the GPU to recover from a fault. First, try to do a low latency - * soft reset. If the soft reset fails for some reason, then bring out the big - * guns and toggle the footswitch. + * Try to reset the GPU to recover from a fault for targets without + * a GMU. */ static int a6xx_reset(struct kgsl_device *device) { struct adreno_device *adreno_dev = ADRENO_DEVICE(device); int ret; - /* - * GMU devices transition to KGSL_STATE_RESET, non GMU devices go - * directly to KGSL_STATE_INIT - */ - if (gmu_core_isenabled(device)) - kgsl_pwrctrl_change_state(device, KGSL_STATE_RESET); - else - kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT); + kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT); /* since device is officially off now clear start bit */ clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); @@ -2702,7 +2694,7 @@ struct adreno_gpudev adreno_a6xx_gmu_gpudev = { .gpu_keepalive = a6xx_gpu_keepalive, .hw_isidle = a6xx_hw_isidle, .iommu_fault_block = a6xx_iommu_fault_block, - .reset = a6xx_reset, + .reset = a6xx_gmu_restart, .preemption_pre_ibsubmit = a6xx_preemption_pre_ibsubmit, .preemption_post_ibsubmit = a6xx_preemption_post_ibsubmit, .preemption_init = a6xx_preemption_init, diff --git a/drivers/gpu/msm/adreno_a6xx_gmu.c b/drivers/gpu/msm/adreno_a6xx_gmu.c index c54bc19c9441..6e71a5287e5b 100644 --- a/drivers/gpu/msm/adreno_a6xx_gmu.c +++ b/drivers/gpu/msm/adreno_a6xx_gmu.c @@ -2098,12 +2098,15 @@ static int a6xx_gmu_first_boot(struct adreno_device *adreno_dev) icc_set_bw(pwr->icc_path, 0, 0); + gmu->fault = false; + return 0; err: - a6xx_gmu_suspend(adreno_dev); - - return ret; + if (gmu->fault) { + a6xx_gmu_suspend(adreno_dev); + return ret; + } clks_gdsc_off: clk_bulk_disable_unprepare(gmu->num_clks, gmu->clks); @@ -2168,12 +2171,15 @@ static int a6xx_gmu_boot(struct adreno_device *adreno_dev) if (ret) goto err; + gmu->fault = false; + return 0; err: - a6xx_gmu_suspend(adreno_dev); - - return ret; + if (gmu->fault) { + a6xx_gmu_suspend(adreno_dev); + return ret; + } clks_gdsc_off: clk_bulk_disable_unprepare(gmu->num_clks, gmu->clks); @@ -3144,6 +3150,24 @@ int a6xx_gmu_device_probe(struct platform_device *pdev, return 0; } +int a6xx_gmu_restart(struct kgsl_device *device) +{ + struct adreno_device *adreno_dev = ADRENO_DEVICE(device); + struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev); + + a6xx_hfi_stop(adreno_dev); + + disable_gpu_irq(adreno_dev); + + /* Hard reset the gmu and gpu */ + a6xx_gmu_suspend(adreno_dev); + + clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); + + /* Attempt to reboot the gmu and gpu */ + return a6xx_boot(adreno_dev); +} + static int a6xx_gmu_bind(struct device *dev, struct device *master, void *data) { struct kgsl_device *device = dev_get_drvdata(master); diff --git a/drivers/gpu/msm/adreno_a6xx_gmu.h b/drivers/gpu/msm/adreno_a6xx_gmu.h index dd0c37eb7f9e..a0caf28c25fe 100644 --- a/drivers/gpu/msm/adreno_a6xx_gmu.h +++ b/drivers/gpu/msm/adreno_a6xx_gmu.h @@ -266,4 +266,12 @@ void a6xx_gmu_device_snapshot(struct kgsl_device *device, */ int a6xx_gmu_device_probe(struct platform_device *pdev, u32 chipid, const struct adreno_gpu_core *gpucore); + +/** + * a6xx_gmu_restart - Reset and restart the gmu + * @device: Pointer to the kgsl device + * + * Return: 0 on success or negative error on failure + */ +int a6xx_gmu_restart(struct kgsl_device *device); #endif