[Freedreno] [bug report] drm/msm/dpu: drop separate dpu_core_perf_tune overrides

2023-08-03 Thread Dan Carpenter
Hello Dmitry Baryshkov,

The patch 6a4bc73915af: "drm/msm/dpu: drop separate
dpu_core_perf_tune overrides" from Jul 30, 2023 (linux-next), leads
to the following Smatch static checker warning:

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c:295 
_dpu_core_perf_get_core_clk_rate()
error: uninitialized symbol 'clk_rate'.

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
280 static u64 _dpu_core_perf_get_core_clk_rate(struct dpu_kms *kms)
281 {
282 u64 clk_rate;
283 struct drm_crtc *crtc;
284 struct dpu_crtc_state *dpu_cstate;
285 
286 if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED)
287 return kms->perf.fix_core_clk_rate;
288 
289 if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM)
290 return kms->perf.max_core_clk_rate;
291 
292 drm_for_each_crtc(crtc, kms->dev) {
293 if (crtc->enabled) {
294 dpu_cstate = to_dpu_crtc_state(crtc->state);
--> 295 clk_rate = 
max(dpu_cstate->new_perf.core_clk_rate,
296 clk_rate);

Never initialized

297 }
298 }
299 
300 return clk_rate;
301 }

regards,
dan carpenter


Re: [Freedreno] [PATCH 2/2] drm/msm/dpu: Add SM7150 support

2023-08-03 Thread Dmitry Baryshkov
On Fri, 4 Aug 2023 at 00:13, Danila Tikhonov  wrote:
>
> So here too I add new sm7150_vig_sblk_0 and sm7150_vig_sblk_1 with v3lite?
>
> static const struct dpu_sspp_sub_blks sm7150_vig_sblk_0 =
> _VIG_SBLK(5, DPU_SSPP_SCALER_QSEED3LITE);
> static const struct dpu_sspp_sub_blks sm7150_vig_sblk_1 =
> _VIG_SBLK(6, DPU_SSPP_SCALER_QSEED3LITE);

Yes, please, close to other sblk variables.

But the priorities should be 4 and 5 (and 1, 2, 3 for DMA).

>
> > +static const struct dpu_sspp_cfg sm7150_sspp[] = {
> > + {
> > + .name = "sspp_0", .id = SSPP_VIG0,
> > + .base = 0x4000, .len = 0x1f0,
> > + .features = VIG_SDM845_MASK,
> > - .sblk = &sm8250_vig_sblk_0, // &sm7150_vig_sblk_0
> > + .xin_id = 0,
> > + .type = SSPP_TYPE_VIG,
> > + .clk_ctrl = DPU_CLK_CTRL_VIG0,
> > + }, {
> > + .name = "sspp_1", .id = SSPP_VIG1,
> > + .base = 0x6000, .len = 0x1f0,
> > + .features = VIG_SDM845_MASK,
> > + .sblk = &sm8250_vig_sblk_1,  // &sm7150_vig_sblk_1
> > + .xin_id = 4,
> > + .type = SSPP_TYPE_VIG,
> > + .clk_ctrl = DPU_CLK_CTRL_VIG1,
> > + }, {
>
> --
> Best regards,
> Danila
>



-- 
With best wishes
Dmitry


[Freedreno] [PATCH v3 9/9] drm/msm: Enable fence signalling annotations

2023-08-03 Thread Rob Clark
From: Rob Clark 

Now that the runpm/qos/interconnect lockdep vs reclaim issues are
solved, we can enable the fence signalling annotations without lockdep
making it's immediate displeasure known.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_ringbuffer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c 
b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 7f5e0a961bba..cb9cf41bcb9b 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -97,6 +97,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu 
*gpu, int id,
 /* currently managing hangcheck ourselves: */
sched_timeout = MAX_SCHEDULE_TIMEOUT;
 
+   ring->sched.fence_signalling = true;
ret = drm_sched_init(&ring->sched, &msm_sched_ops,
num_hw_submissions, 0, sched_timeout,
NULL, NULL, to_msm_bo(ring->bo)->name, gpu->dev->dev);
-- 
2.41.0



[Freedreno] [PATCH v3 8/9] drm/sched: Add (optional) fence signaling annotation

2023-08-03 Thread Rob Clark
From: Rob Clark 

Based on
https://lore.kernel.org/dri-devel/20200604081224.863494-10-daniel.vet...@ffwll.ch/
but made to be optional.

Signed-off-by: Rob Clark 
Reviewed-by: Luben Tuikov 
---
 drivers/gpu/drm/scheduler/sched_main.c | 9 +
 include/drm/gpu_scheduler.h| 2 ++
 2 files changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index 7b2bfc10c1a5..b0368b815ff5 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -1005,10 +1005,15 @@ static bool drm_sched_blocked(struct drm_gpu_scheduler 
*sched)
 static int drm_sched_main(void *param)
 {
struct drm_gpu_scheduler *sched = (struct drm_gpu_scheduler *)param;
+   const bool fence_signalling = sched->fence_signalling;
+   bool fence_cookie;
int r;
 
sched_set_fifo_low(current);
 
+   if (fence_signalling)
+   fence_cookie = dma_fence_begin_signalling();
+
while (!kthread_should_stop()) {
struct drm_sched_entity *entity = NULL;
struct drm_sched_fence *s_fence;
@@ -1064,6 +1069,10 @@ static int drm_sched_main(void *param)
 
wake_up(&sched->job_scheduled);
}
+
+   if (fence_signalling)
+   dma_fence_end_signalling(fence_cookie);
+
return 0;
 }
 
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
index e95b4837e5a3..58d958ad31a1 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -493,6 +493,7 @@ struct drm_sched_backend_ops {
  * @ready: marks if the underlying HW is ready to work
  * @free_guilty: A hit to time out handler to free the guilty job.
  * @dev: system &struct device
+ * @fence_signalling: Opt in to fence signalling annotations
  *
  * One scheduler is implemented for each hardware ring.
  */
@@ -517,6 +518,7 @@ struct drm_gpu_scheduler {
boolready;
boolfree_guilty;
struct device   *dev;
+   boolfence_signalling;
 };
 
 int drm_sched_init(struct drm_gpu_scheduler *sched,
-- 
2.41.0



[Freedreno] [PATCH v3 7/9] interconnect: Teach lockdep about icc_bw_lock order

2023-08-03 Thread Rob Clark
From: Rob Clark 

Teach lockdep that icc_bw_lock is needed in code paths that could
deadlock if they trigger reclaim.

Signed-off-by: Rob Clark 
---
 drivers/interconnect/core.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index e15a92a79df1..1afbc4f7c6e7 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -1041,13 +1041,21 @@ void icc_sync_state(struct device *dev)
}
}
}
+   mutex_unlock(&icc_bw_lock);
mutex_unlock(&icc_lock);
 }
 EXPORT_SYMBOL_GPL(icc_sync_state);
 
 static int __init icc_init(void)
 {
-   struct device_node *root = of_find_node_by_path("/");
+   struct device_node *root;
+
+   /* Teach lockdep about lock ordering wrt. shrinker: */
+   fs_reclaim_acquire(GFP_KERNEL);
+   might_lock(&icc_bw_lock);
+   fs_reclaim_release(GFP_KERNEL);
+
+   root = of_find_node_by_path("/");
 
providers_count = of_count_icc_providers(root);
of_node_put(root);
-- 
2.41.0



[Freedreno] [PATCH v3 6/9] interconnect: Fix locking for runpm vs reclaim

2023-08-03 Thread Rob Clark
From: Rob Clark 

For cases where icc_bw_set() can be called in callbaths that could
deadlock against shrinker/reclaim, such as runpm resume, we need to
decouple the icc locking.  Introduce a new icc_bw_lock for cases where
we need to serialize bw aggregation and update to decouple that from
paths that require memory allocation such as node/link creation/
destruction.

Fixes this lockdep splat:

   ==
   WARNING: possible circular locking dependency detected
   6.2.0-rc8-debug+ #554 Not tainted
   --
   ring0/132 is trying to acquire lock:
   ff80871916d0 (&gmu->lock){+.+.}-{3:3}, at: a6xx_pm_resume+0xf0/0x234

   but task is already holding lock:
   ffdb5aee57e8 (dma_fence_map){}-{0:0}, at: msm_job_run+0x68/0x150

   which lock already depends on the new lock.

   the existing dependency chain (in reverse order) is:

   -> #4 (dma_fence_map){}-{0:0}:
  __dma_fence_might_wait+0x74/0xc0
  dma_resv_lockdep+0x1f4/0x2f4
  do_one_initcall+0x104/0x2bc
  kernel_init_freeable+0x344/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #3 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}:
  fs_reclaim_acquire+0x80/0xa8
  slab_pre_alloc_hook.constprop.0+0x40/0x25c
  __kmem_cache_alloc_node+0x60/0x1cc
  __kmalloc+0xd8/0x100
  topology_parse_cpu_capacity+0x8c/0x178
  get_cpu_for_node+0x88/0xc4
  parse_cluster+0x1b0/0x28c
  parse_cluster+0x8c/0x28c
  init_cpu_topology+0x168/0x188
  smp_prepare_cpus+0x24/0xf8
  kernel_init_freeable+0x18c/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #2 (fs_reclaim){+.+.}-{0:0}:
  __fs_reclaim_acquire+0x3c/0x48
  fs_reclaim_acquire+0x54/0xa8
  slab_pre_alloc_hook.constprop.0+0x40/0x25c
  __kmem_cache_alloc_node+0x60/0x1cc
  __kmalloc+0xd8/0x100
  kzalloc.constprop.0+0x14/0x20
  icc_node_create_nolock+0x4c/0xc4
  icc_node_create+0x38/0x58
  qcom_icc_rpmh_probe+0x1b8/0x248
  platform_probe+0x70/0xc4
  really_probe+0x158/0x290
  __driver_probe_device+0xc8/0xe0
  driver_probe_device+0x44/0x100
  __driver_attach+0xf8/0x108
  bus_for_each_dev+0x78/0xc4
  driver_attach+0x2c/0x38
  bus_add_driver+0xd0/0x1d8
  driver_register+0xbc/0xf8
  __platform_driver_register+0x30/0x3c
  qnoc_driver_init+0x24/0x30
  do_one_initcall+0x104/0x2bc
  kernel_init_freeable+0x344/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #1 (icc_lock){+.+.}-{3:3}:
  __mutex_lock+0xcc/0x3c8
  mutex_lock_nested+0x30/0x44
  icc_set_bw+0x88/0x2b4
  _set_opp_bw+0x8c/0xd8
  _set_opp+0x19c/0x300
  dev_pm_opp_set_opp+0x84/0x94
  a6xx_gmu_resume+0x18c/0x804
  a6xx_pm_resume+0xf8/0x234
  adreno_runtime_resume+0x2c/0x38
  pm_generic_runtime_resume+0x30/0x44
  __rpm_callback+0x15c/0x174
  rpm_callback+0x78/0x7c
  rpm_resume+0x318/0x524
  __pm_runtime_resume+0x78/0xbc
  adreno_load_gpu+0xc4/0x17c
  msm_open+0x50/0x120
  drm_file_alloc+0x17c/0x228
  drm_open_helper+0x74/0x118
  drm_open+0xa0/0x144
  drm_stub_open+0xd4/0xe4
  chrdev_open+0x1b8/0x1e4
  do_dentry_open+0x2f8/0x38c
  vfs_open+0x34/0x40
  path_openat+0x64c/0x7b4
  do_filp_open+0x54/0xc4
  do_sys_openat2+0x9c/0x100
  do_sys_open+0x50/0x7c
  __arm64_sys_openat+0x28/0x34
  invoke_syscall+0x8c/0x128
  el0_svc_common.constprop.0+0xa0/0x11c
  do_el0_svc+0xac/0xbc
  el0_svc+0x48/0xa0
  el0t_64_sync_handler+0xac/0x13c
  el0t_64_sync+0x190/0x194

   -> #0 (&gmu->lock){+.+.}-{3:3}:
  __lock_acquire+0xe00/0x1060
  lock_acquire+0x1e0/0x2f8
  __mutex_lock+0xcc/0x3c8
  mutex_lock_nested+0x30/0x44
  a6xx_pm_resume+0xf0/0x234
  adreno_runtime_resume+0x2c/0x38
  pm_generic_runtime_resume+0x30/0x44
  __rpm_callback+0x15c/0x174
  rpm_callback+0x78/0x7c
  rpm_resume+0x318/0x524
  __pm_runtime_resume+0x78/0xbc
  pm_runtime_get_sync.isra.0+0x14/0x20
  msm_gpu_submit+0x58/0x178
  msm_job_run+0x78/0x150
  drm_sched_main+0x290/0x370
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   other info that might help us debug this:

   Chain exists of:
 &gmu->lock --> mmu_notifier_invalidate_range_start --> dma_fence_map

Possible unsafe locking scenario:

  CPU0CPU1
  
 lock(dma_fence_map);
  lock(mmu_notif

[Freedreno] [PATCH v3 5/9] PM / QoS: Teach lockdep about dev_pm_qos_mtx locking order

2023-08-03 Thread Rob Clark
From: Rob Clark 

Annotate dev_pm_qos_mtx to teach lockdep to scream about allocations
that could trigger reclaim under dev_pm_qos_mtx.

Signed-off-by: Rob Clark 
---
 drivers/base/power/qos.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 4537d93ddb45..6cb4143d1090 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -1010,3 +1010,14 @@ void dev_pm_qos_hide_latency_tolerance(struct device 
*dev)
pm_runtime_put(dev);
 }
 EXPORT_SYMBOL_GPL(dev_pm_qos_hide_latency_tolerance);
+
+static int __init dev_pm_qos_init(void)
+{
+   /* Teach lockdep about lock ordering wrt. shrinker: */
+   fs_reclaim_acquire(GFP_KERNEL);
+   might_lock(&dev_pm_qos_mtx);
+   fs_reclaim_release(GFP_KERNEL);
+
+   return 0;
+}
+early_initcall(dev_pm_qos_init);
-- 
2.41.0



[Freedreno] [PATCH v3 4/9] PM / QoS: Decouple request alloc from dev_pm_qos_mtx

2023-08-03 Thread Rob Clark
From: Rob Clark 

Similar to the previous patch, move the allocation out from under
dev_pm_qos_mtx, by speculatively doing the allocation and handle
any race after acquiring dev_pm_qos_mtx by freeing the redundant
allocation.

Signed-off-by: Rob Clark 
---
 drivers/base/power/qos.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index f3e0c6b65635..4537d93ddb45 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -922,17 +922,19 @@ s32 dev_pm_qos_get_user_latency_tolerance(struct device 
*dev)
  */
 int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
 {
+   struct dev_pm_qos_request *req = NULL;
int ret;
 
ret = dev_pm_qos_constraints_ensure_allocated(dev);
if (ret)
return ret;
 
+   if (!dev->power.qos->latency_tolerance_req)
+   req = kzalloc(sizeof(*req), GFP_KERNEL);
+
mutex_lock(&dev_pm_qos_mtx);
 
if (!dev->power.qos->latency_tolerance_req) {
-   struct dev_pm_qos_request *req;
-
if (val < 0) {
if (val == PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT)
ret = 0;
@@ -940,7 +942,6 @@ int dev_pm_qos_update_user_latency_tolerance(struct device 
*dev, s32 val)
ret = -EINVAL;
goto out;
}
-   req = kzalloc(sizeof(*req), GFP_KERNEL);
if (!req) {
ret = -ENOMEM;
goto out;
@@ -952,6 +953,13 @@ int dev_pm_qos_update_user_latency_tolerance(struct device 
*dev, s32 val)
}
dev->power.qos->latency_tolerance_req = req;
} else {
+   /*
+* If we raced with another thread to allocate the request,
+* simply free the redundant allocation and move on.
+*/
+   if (req)
+   kfree(req);
+
if (val < 0) {
__dev_pm_qos_drop_user_request(dev, 
DEV_PM_QOS_LATENCY_TOLERANCE);
ret = 0;
-- 
2.41.0



[Freedreno] [PATCH v3 3/9] PM / QoS: Fix constraints alloc vs reclaim locking

2023-08-03 Thread Rob Clark
From: Rob Clark 

In the process of adding lockdep annotation for drm GPU scheduler's
job_run() to detect potential deadlock against shrinker/reclaim, I hit
this lockdep splat:

   ==
   WARNING: possible circular locking dependency detected
   6.2.0-rc8-debug+ #558 Tainted: GW
   --
   ring0/125 is trying to acquire lock:
   ffd6d6ce0f28 (dev_pm_qos_mtx){+.+.}-{3:3}, at: 
dev_pm_qos_update_request+0x38/0x68

   but task is already holding lock:
   ff8087239208 (&gpu->active_lock){+.+.}-{3:3}, at: 
msm_gpu_submit+0xec/0x178

   which lock already depends on the new lock.

   the existing dependency chain (in reverse order) is:

   -> #4 (&gpu->active_lock){+.+.}-{3:3}:
  __mutex_lock+0xcc/0x3c8
  mutex_lock_nested+0x30/0x44
  msm_gpu_submit+0xec/0x178
  msm_job_run+0x78/0x150
  drm_sched_main+0x290/0x370
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   -> #3 (dma_fence_map){}-{0:0}:
  __dma_fence_might_wait+0x74/0xc0
  dma_resv_lockdep+0x1f4/0x2f4
  do_one_initcall+0x104/0x2bc
  kernel_init_freeable+0x344/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #2 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}:
  fs_reclaim_acquire+0x80/0xa8
  slab_pre_alloc_hook.constprop.0+0x40/0x25c
  __kmem_cache_alloc_node+0x60/0x1cc
  __kmalloc+0xd8/0x100
  topology_parse_cpu_capacity+0x8c/0x178
  get_cpu_for_node+0x88/0xc4
  parse_cluster+0x1b0/0x28c
  parse_cluster+0x8c/0x28c
  init_cpu_topology+0x168/0x188
  smp_prepare_cpus+0x24/0xf8
  kernel_init_freeable+0x18c/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #1 (fs_reclaim){+.+.}-{0:0}:
  __fs_reclaim_acquire+0x3c/0x48
  fs_reclaim_acquire+0x54/0xa8
  slab_pre_alloc_hook.constprop.0+0x40/0x25c
  __kmem_cache_alloc_node+0x60/0x1cc
  kmalloc_trace+0x50/0xa8
  dev_pm_qos_constraints_allocate+0x38/0x100
  __dev_pm_qos_add_request+0xb0/0x1e8
  dev_pm_qos_add_request+0x58/0x80
  dev_pm_qos_expose_latency_limit+0x60/0x13c
  register_cpu+0x12c/0x130
  topology_init+0xac/0xbc
  do_one_initcall+0x104/0x2bc
  kernel_init_freeable+0x344/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #0 (dev_pm_qos_mtx){+.+.}-{3:3}:
  __lock_acquire+0xe00/0x1060
  lock_acquire+0x1e0/0x2f8
  __mutex_lock+0xcc/0x3c8
  mutex_lock_nested+0x30/0x44
  dev_pm_qos_update_request+0x38/0x68
  msm_devfreq_boost+0x40/0x70
  msm_devfreq_active+0xc0/0xf0
  msm_gpu_submit+0x10c/0x178
  msm_job_run+0x78/0x150
  drm_sched_main+0x290/0x370
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   other info that might help us debug this:

   Chain exists of:
 dev_pm_qos_mtx --> dma_fence_map --> &gpu->active_lock

Possible unsafe locking scenario:

  CPU0CPU1
  
 lock(&gpu->active_lock);
  lock(dma_fence_map);
  lock(&gpu->active_lock);
 lock(dev_pm_qos_mtx);

*** DEADLOCK ***

   3 locks held by ring0/123:
#0: ff8087251170 (&gpu->lock){+.+.}-{3:3}, at: msm_job_run+0x64/0x150
#1: ffd00b0e57e8 (dma_fence_map){}-{0:0}, at: msm_job_run+0x68/0x150
#2: ff8087251208 (&gpu->active_lock){+.+.}-{3:3}, at: 
msm_gpu_submit+0xec/0x178

   stack backtrace:
   CPU: 6 PID: 123 Comm: ring0 Not tainted 6.2.0-rc8-debug+ #559
   Hardware name: Google Lazor (rev1 - 2) with LTE (DT)
   Call trace:
dump_backtrace.part.0+0xb4/0xf8
show_stack+0x20/0x38
dump_stack_lvl+0x9c/0xd0
dump_stack+0x18/0x34
print_circular_bug+0x1b4/0x1f0
check_noncircular+0x78/0xac
__lock_acquire+0xe00/0x1060
lock_acquire+0x1e0/0x2f8
__mutex_lock+0xcc/0x3c8
mutex_lock_nested+0x30/0x44
dev_pm_qos_update_request+0x38/0x68
msm_devfreq_boost+0x40/0x70
msm_devfreq_active+0xc0/0xf0
msm_gpu_submit+0x10c/0x178
msm_job_run+0x78/0x150
drm_sched_main+0x290/0x370
kthread+0xf0/0x100
ret_from_fork+0x10/0x20

The issue is that dev_pm_qos_mtx is held in the runpm suspend/resume (or
freq change) path, but it is also held across allocations that could
recurse into shrinker.

Solve this by changing dev_pm_qos_constraints_allocate() into a function
that can be called unconditionally before the device qos object is
needed and before aquiring dev_pm_qos_mtx.  This way the allocations can
be done without holding the mutex.  In the case that we raced with
another thread to allocate the qos object, detect this *after* acquiring
the dev_pm_qos_mtx and simply free the

[Freedreno] [PATCH v3 1/9] PM / devfreq: Drop unneed locking to appease lockdep

2023-08-03 Thread Rob Clark
From: Rob Clark 

In the process of adding lockdep annotation for GPU job_run() path to
catch potential deadlocks against the shrinker/reclaim path, I turned
up this lockdep splat:

   ==
   WARNING: possible circular locking dependency detected
   6.2.0-rc8-debug+ #556 Not tainted
   --
   ring0/123 is trying to acquire lock:
   ff8087219078 (&devfreq->lock){+.+.}-{3:3}, at: 
devfreq_monitor_resume+0x3c/0xf0

   but task is already holding lock:
   ffd6f64e57e8 (dma_fence_map){}-{0:0}, at: msm_job_run+0x68/0x150

   which lock already depends on the new lock.

   the existing dependency chain (in reverse order) is:

   -> #3 (dma_fence_map){}-{0:0}:
  __dma_fence_might_wait+0x74/0xc0
  dma_resv_lockdep+0x1f4/0x2f4
  do_one_initcall+0x104/0x2bc
  kernel_init_freeable+0x344/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #2 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}:
  fs_reclaim_acquire+0x80/0xa8
  slab_pre_alloc_hook.constprop.0+0x40/0x25c
  __kmem_cache_alloc_node+0x60/0x1cc
  __kmalloc+0xd8/0x100
  topology_parse_cpu_capacity+0x8c/0x178
  get_cpu_for_node+0x88/0xc4
  parse_cluster+0x1b0/0x28c
  parse_cluster+0x8c/0x28c
  init_cpu_topology+0x168/0x188
  smp_prepare_cpus+0x24/0xf8
  kernel_init_freeable+0x18c/0x34c
  kernel_init+0x30/0x134
  ret_from_fork+0x10/0x20

   -> #1 (fs_reclaim){+.+.}-{0:0}:
  __fs_reclaim_acquire+0x3c/0x48
  fs_reclaim_acquire+0x54/0xa8
  slab_pre_alloc_hook.constprop.0+0x40/0x25c
  __kmem_cache_alloc_node+0x60/0x1cc
  __kmalloc_node_track_caller+0xb8/0xe0
  kstrdup+0x70/0x90
  kstrdup_const+0x38/0x48
  kvasprintf_const+0x48/0xbc
  kobject_set_name_vargs+0x40/0xb0
  dev_set_name+0x64/0x8c
  devfreq_add_device+0x31c/0x55c
  devm_devfreq_add_device+0x6c/0xb8
  msm_devfreq_init+0xa8/0x16c
  msm_gpu_init+0x38c/0x570
  adreno_gpu_init+0x1b4/0x2b4
  a6xx_gpu_init+0x15c/0x3e4
  adreno_bind+0x218/0x254
  component_bind_all+0x114/0x1ec
  msm_drm_bind+0x2b8/0x608
  try_to_bring_up_aggregate_device+0x88/0x1a4
  __component_add+0xec/0x13c
  component_add+0x1c/0x28
  dsi_dev_attach+0x28/0x34
  dsi_host_attach+0xdc/0x124
  mipi_dsi_attach+0x30/0x44
  devm_mipi_dsi_attach+0x2c/0x70
  ti_sn_bridge_probe+0x298/0x2c4
  auxiliary_bus_probe+0x7c/0x94
  really_probe+0x158/0x290
  __driver_probe_device+0xc8/0xe0
  driver_probe_device+0x44/0x100
  __device_attach_driver+0x64/0xdc
  bus_for_each_drv+0xa0/0xc8
  __device_attach+0xd8/0x168
  device_initial_probe+0x1c/0x28
  bus_probe_device+0x38/0xa0
  deferred_probe_work_func+0xc8/0xe0
  process_one_work+0x2d8/0x478
  process_scheduled_works+0x4c/0x50
  worker_thread+0x218/0x274
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   -> #0 (&devfreq->lock){+.+.}-{3:3}:
  __lock_acquire+0xe00/0x1060
  lock_acquire+0x1e0/0x2f8
  __mutex_lock+0xcc/0x3c8
  mutex_lock_nested+0x30/0x44
  devfreq_monitor_resume+0x3c/0xf0
  devfreq_simple_ondemand_handler+0x54/0x7c
  devfreq_resume_device+0xa4/0xe8
  msm_devfreq_resume+0x78/0xa8
  a6xx_pm_resume+0x110/0x234
  adreno_runtime_resume+0x2c/0x38
  pm_generic_runtime_resume+0x30/0x44
  __rpm_callback+0x15c/0x174
  rpm_callback+0x78/0x7c
  rpm_resume+0x318/0x524
  __pm_runtime_resume+0x78/0xbc
  pm_runtime_get_sync.isra.0+0x14/0x20
  msm_gpu_submit+0x58/0x178
  msm_job_run+0x78/0x150
  drm_sched_main+0x290/0x370
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   other info that might help us debug this:

   Chain exists of:
 &devfreq->lock --> mmu_notifier_invalidate_range_start --> dma_fence_map

Possible unsafe locking scenario:

  CPU0CPU1
  
 lock(dma_fence_map);
  lock(mmu_notifier_invalidate_range_start);
  lock(dma_fence_map);
 lock(&devfreq->lock);

*** DEADLOCK ***

   2 locks held by ring0/123:
#0: ff8087201170 (&gpu->lock){+.+.}-{3:3}, at: msm_job_run+0x64/0x150
#1: ffd6f64e57e8 (dma_fence_map){}-{0:0}, at: msm_job_run+0x68/0x150

   stack backtrace:
   CPU: 6 PID: 123 Comm: ring0 Not tainted 6.2.0-rc8-debug+ #556
   Hardware name: Google Lazor (rev1 - 2) with LTE (DT)
   Call trace:
dump_backtrace.part.0+0xb4/0xf8
show_stack+0x20/0x38
dump_stack_lvl+0

[Freedreno] [PATCH v3 2/9] PM / devfreq: Teach lockdep about locking order

2023-08-03 Thread Rob Clark
From: Rob Clark 

This will make it easier to catch places doing allocations that can
trigger reclaim under devfreq->lock.

Because devfreq->lock is held over various devfreq_dev_profile
callbacks, there might be some fallout if those callbacks do allocations
that can trigger reclaim, but I've looked through the various callback
implementations and don't see anything obvious.  If it does trigger any
lockdep splats, those should be fixed.

Signed-off-by: Rob Clark 
---
 drivers/devfreq/devfreq.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index e5558ec68ce8..81add6064406 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -817,6 +817,12 @@ struct devfreq *devfreq_add_device(struct device *dev,
}
 
mutex_init(&devfreq->lock);
+
+   /* Teach lockdep about lock ordering wrt. shrinker: */
+   fs_reclaim_acquire(GFP_KERNEL);
+   might_lock(&devfreq->lock);
+   fs_reclaim_release(GFP_KERNEL);
+
devfreq->dev.parent = dev;
devfreq->dev.class = devfreq_class;
devfreq->dev.release = devfreq_dev_release;
-- 
2.41.0



[Freedreno] [PATCH v3 0/9] drm/msm+PM+icc: Make job_run() reclaim-safe

2023-08-03 Thread Rob Clark
From: Rob Clark 

Inspired by 
https://lore.kernel.org/dri-devel/20200604081224.863494-10-daniel.vet...@ffwll.ch/
it seemed like a good idea to get rid of memory allocation in job_run()
fence signaling path, and use lockdep annotations to yell at us about
anything that could deadlock against shrinker/reclaim.  Anything that
can trigger reclaim, or block on any other thread that has triggered
reclaim, can block the GPU shrinker from releasing memory if it is
waiting the job to complete, causing deadlock.

The first two patches decouple allocation from devfreq->lock, and teach
lockdep that devfreq->lock can be acquired in paths that the shrinker
indirectly depends on.

The next three patches do the same for PM QoS.  And the next two do a
similar thing for interconnect.

And then finally the last two patches enable the lockdep fence-
signalling annotations.


v2: Switch from embedding hw_fence in submit/job object to preallocating
the hw_fence.  Rework "fenced unpin" locking to drop obj lock from
fence signaling path (ie. the part that was still WIP in the first
iteration of the patchset).  Adds the final patch to enable fence
signaling annotations now that job_run() and job_free() are safe.
The PM devfreq/QoS and interconnect patches are unchanged.

v3: Mostly unchanged, but series is much smaller now that drm changes
have landed, mostly consisting of the remaining devfreq/qos/
interconnect fixes.

Rob Clark (9):
  PM / devfreq: Drop unneed locking to appease lockdep
  PM / devfreq: Teach lockdep about locking order
  PM / QoS: Fix constraints alloc vs reclaim locking
  PM / QoS: Decouple request alloc from dev_pm_qos_mtx
  PM / QoS: Teach lockdep about dev_pm_qos_mtx locking order
  interconnect: Fix locking for runpm vs reclaim
  interconnect: Teach lockdep about icc_bw_lock order
  drm/sched: Add (optional) fence signaling annotation
  drm/msm: Enable fence signalling annotations

 drivers/base/power/qos.c   | 85 +++---
 drivers/devfreq/devfreq.c  | 52 
 drivers/gpu/drm/msm/msm_ringbuffer.c   |  1 +
 drivers/gpu/drm/scheduler/sched_main.c |  9 +++
 drivers/interconnect/core.c| 18 +-
 include/drm/gpu_scheduler.h|  2 +
 6 files changed, 117 insertions(+), 50 deletions(-)

-- 
2.41.0



Re: [Freedreno] [PATCH 2/2] drm/msm/dpu: Add SM7150 support

2023-08-03 Thread Marijn Suijten
On 2023-08-03 22:47:24, Danila Tikhonov wrote:
> Add definitions for the display hardware used on the Qualcomm SM7150
> platform.
> 
> Signed-off-by: Danila Tikhonov 
> ---
>  .../msm/disp/dpu1/catalog/dpu_5_2_sm7150.h| 277 ++
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c|   1 +
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h|   1 +
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |   1 +
>  4 files changed, 280 insertions(+)
>  create mode 100644 drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h 
> b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
> new file mode 100644
> index ..5823879a705a
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
> @@ -0,0 +1,277 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023, Danila Tikhonov 
> + */
> +
> +#ifndef _DPU_5_2_SM7150_H
> +#define _DPU_5_2_SM7150_H
> +
> +static const struct dpu_caps sm7150_dpu_caps = {
> + .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
> + .max_mixer_blendstages = 0xb,
> + .qseed_type = DPU_SSPP_SCALER_QSEED4,
> + .has_src_split = true,
> + .has_dim_layer = true,
> + .has_idle_pc = true,
> + .has_3d_merge = true,
> + .max_linewidth = 4096,
> + .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE,
> + .max_hdeci_exp = MAX_HORZ_DECIMATION,
> + .max_vdeci_exp = MAX_VERT_DECIMATION,
> +};
> +
> +static const struct dpu_mdp_cfg sm7150_mdp[] = {
> + {
> + .name = "top_0",
> + .base = 0x0, .len = 0x45c,
> + .features = BIT(DPU_MDP_AUDIO_SELECT),
> + .clk_ctrls[DPU_CLK_CTRL_VIG0] = { .reg_off = 0x2ac, .bit_off = 0 },
> + .clk_ctrls[DPU_CLK_CTRL_VIG1] = { .reg_off = 0x2b4, .bit_off = 0 },
> + .clk_ctrls[DPU_CLK_CTRL_DMA0] = { .reg_off = 0x2ac, .bit_off = 8 },
> + .clk_ctrls[DPU_CLK_CTRL_DMA1] = { .reg_off = 0x2b4, .bit_off = 8 },
> + .clk_ctrls[DPU_CLK_CTRL_DMA2] = { .reg_off = 0x2bc, .bit_off = 8 },
> + .clk_ctrls[DPU_CLK_CTRL_WB2] = { .reg_off = 0x3b8, .bit_off = 24 },

This array can be written more concisely, as done in the other catalog
files:

.clk_ctrls = {
[DPU_CLK_CTRL_VIG0] = { .reg_off = 0x2ac, .bit_off = 0 },
[DPU_CLK_CTRL_VIG1] = { .reg_off = 0x2b4, .bit_off = 0 },
[DPU_CLK_CTRL_DMA0] = { .reg_off = 0x2ac, .bit_off = 8 },
[DPU_CLK_CTRL_DMA1] = { .reg_off = 0x2b4, .bit_off = 8 },
[DPU_CLK_CTRL_DMA2] = { .reg_off = 0x2bc, .bit_off = 8 },
[DPU_CLK_CTRL_WB2] = { .reg_off = 0x3b8, .bit_off = 24 },
},


> + },
> +};
> +
> +static const struct dpu_sspp_cfg sm7150_sspp[] = {
> + {
> + .name = "sspp_0", .id = SSPP_VIG0,
> + .base = 0x4000, .len = 0x1f0,
> + .features = VIG_SDM845_MASK,
> + .sblk = &sm8250_vig_sblk_0,
> + .xin_id = 0,
> + .type = SSPP_TYPE_VIG,
> + .clk_ctrl = DPU_CLK_CTRL_VIG0,
> + }, {
> + .name = "sspp_1", .id = SSPP_VIG1,
> + .base = 0x6000, .len = 0x1f0,
> + .features = VIG_SDM845_MASK,
> + .sblk = &sm8250_vig_sblk_1,
> + .xin_id = 4,
> + .type = SSPP_TYPE_VIG,
> + .clk_ctrl = DPU_CLK_CTRL_VIG1,
> + }, {
> + .name = "sspp_2", .id = SSPP_DMA0,
> + .base = 0x24000, .len = 0x1f0,
> + .features = DMA_SDM845_MASK,
> + .sblk = &sdm845_dma_sblk_0,
> + .xin_id = 1,
> + .type = SSPP_TYPE_DMA,
> + .clk_ctrl = DPU_CLK_CTRL_DMA0,
> + }, {
> + .name = "sspp_9", .id = SSPP_DMA1,
> + .base = 0x26000, .len = 0x1f0,
> + .features = DMA_SDM845_MASK,
> + .sblk = &sdm845_dma_sblk_1,
> + .xin_id = 5,
> + .type = SSPP_TYPE_DMA,
> + .clk_ctrl = DPU_CLK_CTRL_DMA1,
> + }, {
> + .name = "sspp_10", .id = SSPP_DMA2,
> + .base = 0x28000, .len = 0x1f0,
> + .features = DMA_CURSOR_SDM845_MASK,
> + .sblk = &sdm845_dma_sblk_2,
> + .xin_id = 9,
> + .type = SSPP_TYPE_DMA,
> + .clk_ctrl = DPU_CLK_CTRL_DMA2,
> + },
> +};
> +
> +static const struct dpu_lm_cfg sm7150_lm[] = {
> + {
> + .name = "lm_0", .id = LM_0,
> + .base = 0x44000, .len = 0x320,
> + .features = MIXER_SDM845_MASK,
> + .sblk = &sdm845_lm_sblk,
> + .lm_pair = LM_1,
> + .pingpong = PINGPONG_0,
> + .dspp = DSPP_0,
> + }, {
> + .name = "lm_1", .id = LM_1,
> + .base = 0x45000, .len = 0x320,
> + .features = MIXER_SDM845_MASK,
> + .sblk = &sdm845_lm_sblk,
> + .lm_pair = LM_0,
> +

Re: [Freedreno] [PATCH 1/2] dt-bindings: display/msm: document DPU on SM7150

2023-08-03 Thread Marijn Suijten
On 2023-08-03 22:47:23, Danila Tikhonov wrote:
> Document the DPU hardware found on the Qualcomm SM7150 platform.
> 
> Signed-off-by: Danila Tikhonov 
> ---
>  .../bindings/display/msm/qcom,sm7150-dpu.yaml | 116 ++
>  1 file changed, 116 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml 
> b/Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
> new file mode 100644
> index ..0d86997ae09f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
> @@ -0,0 +1,116 @@
> +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/display/msm/qcom,sm7150-dpu.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm SM7150 Display DPU
> +
> +maintainers:
> +  - Dmitry Baryshkov 
> +  - Danila Tikhonov 
> +
> +$ref: /schemas/display/msm/dpu-common.yaml#
> +
> +properties:
> +  compatible:
> +const: qcom,sm7150-dpu
> +
> +  reg:
> +items:
> +  - description: Address offset and size for mdp register set
> +  - description: Address offset and size for vbif register set
> +
> +  reg-names:
> +items:
> +  - const: mdp
> +  - const: vbif
> +
> +  clocks:
> +items:
> +  - description: Display hf axi clock
> +  - description: Display ahb clock
> +  - description: Display rotator clock
> +  - description: Display lut clock
> +  - description: Display core clock
> +  - description: Display vsync clock
> +
> +  clock-names:
> +items:
> +  - const: bus
> +  - const: iface
> +  - const: rot
> +  - const: lut
> +  - const: core
> +  - const: vsync
> +
> +required:
> +  - compatible
> +  - reg
> +  - reg-names
> +  - clocks
> +  - clock-names
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +display-controller@ae01000 {
> +compatible = "qcom,sm7150-dpu";
> +reg = <0x0ae01000 0x8f000>,
> +  <0x0aeb 0x2008>;
> +reg-names = "mdp", "vbif";
> +
> +clocks = <&gcc GCC_DISP_HF_AXI_CLK>,
> + <&dispcc DISP_CC_MDSS_AHB_CLK>,
> + <&dispcc DISP_CC_MDSS_ROT_CLK>,
> + <&dispcc DISP_CC_MDSS_MDP_LUT_CLK>,
> + <&dispcc DISP_CC_MDSS_MDP_CLK>,
> + <&dispcc DISP_CC_MDSS_VSYNC_CLK>;
> +clock-names = "bus", "iface", "rot", "lut", "core",
> +  "vsync";
> +
> +assigned-clocks = <&dispcc DISP_CC_MDSS_VSYNC_CLK>,
> +  <&dispcc DISP_CC_MDSS_ROT_CLK>,
> +  <&dispcc DISP_CC_MDSS_AHB_CLK>;
> +assigned-clock-rates = <1920>,
> +   <1920>,
> +   <1920>;
> +
> +operating-points-v2 = <&mdp_opp_table>;
> +power-domains = <&rpmhpd SM7150_CX>;
> +
> +interrupt-parent = <&mdss>;
> +interrupts = <0>;
> +
> +ports {
> +#address-cells = <1>;
> +#size-cells = <0>;
> +
> +port@0 {
> +reg = <0>;
> +endpoint {
> +remote-endpoint = <&dsi0_in>;
> +};
> +};
> +
> +port@1 {
> +reg = <1>;
> +endpoint {
> +remote-endpoint = <&dsi1_in>;
> +};

I don't think this compiles with a missing closing bracket.  Did you
test the bindings?

- Marijn

> +
> +port@2 {
> +reg = <2>;
> +endpoint {
> +remote-endpoint = <&dp_in>;
> +};
> +};
> +};
> +};
> +...
> -- 
> 2.41.0
> 


Re: [Freedreno] [PATCH 2/2] drm/msm/dpu: Add SM7150 support

2023-08-03 Thread Danila Tikhonov

So here too I add new sm7150_vig_sblk_0 and sm7150_vig_sblk_1 with v3lite?
 
static const struct dpu_sspp_sub_blks sm7150_vig_sblk_0 =
    _VIG_SBLK(5, DPU_SSPP_SCALER_QSEED3LITE);
static const struct dpu_sspp_sub_blks sm7150_vig_sblk_1 =
    _VIG_SBLK(6, DPU_SSPP_SCALER_QSEED3LITE);
> +static const struct dpu_sspp_cfg sm7150_sspp[] = {
> + {
> + .name = "sspp_0", .id = SSPP_VIG0,
> + .base = 0x4000, .len = 0x1f0,
> + .features = VIG_SDM845_MASK,
> - .sblk = &sm8250_vig_sblk_0, // &sm7150_vig_sblk_0
> + .xin_id = 0,
> + .type = SSPP_TYPE_VIG,
> + .clk_ctrl = DPU_CLK_CTRL_VIG0,
> + }, {
> + .name = "sspp_1", .id = SSPP_VIG1,
> + .base = 0x6000, .len = 0x1f0,
> + .features = VIG_SDM845_MASK,
> + .sblk = &sm8250_vig_sblk_1,  // &sm7150_vig_sblk_1
> + .xin_id = 4,
> + .type = SSPP_TYPE_VIG,
> + .clk_ctrl = DPU_CLK_CTRL_VIG1,
> + }, {

--
Best regards,
Danila
 

Re: [Freedreno] [PATCH] drm/msm/mdp5: Don't leak some plane state

2023-08-03 Thread Abhinav Kumar




On 8/3/2023 1:45 PM, Daniel Vetter wrote:

Apparently no one noticed that mdp5 plane states leak like a sieve
ever since we introduced plane_state->commit refcount a few years ago
in 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too
early by tracking commits, v3.")

Fix it by using the right helpers.

Fixes: 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too early by 
tracking commits, v3.")
Cc: Maarten Lankhorst 
Cc: Daniel Vetter 
Cc: Rob Clark 
Cc: Abhinav Kumar 
Cc: Dmitry Baryshkov 
Cc: linux-arm-...@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Reported-and-tested-by: do...@noisolation.com
Cc: do...@noisolation.com
Signed-off-by: Daniel Vetter 
---
  drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)



Reviewed-by: Abhinav Kumar 



Re: [Freedreno] [PATCH] drm/msm/mdp5: Don't leak some plane state

2023-08-03 Thread Dmitry Baryshkov
On Thu, 3 Aug 2023 at 23:45, Daniel Vetter  wrote:
>
> Apparently no one noticed that mdp5 plane states leak like a sieve
> ever since we introduced plane_state->commit refcount a few years ago
> in 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too
> early by tracking commits, v3.")
>
> Fix it by using the right helpers.
>
> Fixes: 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too early 
> by tracking commits, v3.")
> Cc: Maarten Lankhorst 
> Cc: Daniel Vetter 
> Cc: Rob Clark 
> Cc: Abhinav Kumar 
> Cc: Dmitry Baryshkov 
> Cc: linux-arm-...@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Reported-and-tested-by: do...@noisolation.com
> Cc: do...@noisolation.com
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry


Re: [Freedreno] [PATCH 0/2] drm/msm/dpu: Add support for SM7150

2023-08-03 Thread Dmitry Baryshkov
On Thu, 3 Aug 2023 at 22:47, Danila Tikhonov  wrote:
>
> This series adds DPU support for Qualcomm SM7150 SoC.
>
> Danila Tikhonov (2):
>   dt-bindings: display/msm: document DPU on SM7150
>   drm/msm/dpu: Add SM7150 support
>
>  .../bindings/display/msm/qcom,sm7150-dpu.yaml | 116 
>  .../msm/disp/dpu1/catalog/dpu_5_2_sm7150.h| 277 ++
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c|   1 +
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h|   1 +
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |   1 +
>  5 files changed, 396 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
>  create mode 100644 drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h

Could you please include MDSS bindings and msm_mdss.c patch into v2?

-- 
With best wishes
Dmitry


Re: [Freedreno] [PATCH 2/2] drm/msm/dpu: Add SM7150 support

2023-08-03 Thread Dmitry Baryshkov
On Thu, 3 Aug 2023 at 22:47, Danila Tikhonov  wrote:
>
> Add definitions for the display hardware used on the Qualcomm SM7150
> platform.
>
> Signed-off-by: Danila Tikhonov 
> ---
>  .../msm/disp/dpu1/catalog/dpu_5_2_sm7150.h| 277 ++
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c|   1 +
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h|   1 +
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |   1 +
>  4 files changed, 280 insertions(+)
>  create mode 100644 drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h 
> b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
> new file mode 100644
> index ..5823879a705a
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
> @@ -0,0 +1,277 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023, Danila Tikhonov 
> + */
> +
> +#ifndef _DPU_5_2_SM7150_H
> +#define _DPU_5_2_SM7150_H
> +
> +static const struct dpu_caps sm7150_dpu_caps = {
> +   .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
> +   .max_mixer_blendstages = 0xb,
> +   .qseed_type = DPU_SSPP_SCALER_QSEED4,

v3lite

> +   .has_src_split = true,
> +   .has_dim_layer = true,
> +   .has_idle_pc = true,
> +   .has_3d_merge = true,
> +   .max_linewidth = 4096,

2880 according to the vendor DTS file.

> +   .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE,
> +   .max_hdeci_exp = MAX_HORZ_DECIMATION,
> +   .max_vdeci_exp = MAX_VERT_DECIMATION,
> +};
> +
> +static const struct dpu_mdp_cfg sm7150_mdp[] = {
> +   {
> +   .name = "top_0",
> +   .base = 0x0, .len = 0x45c,
> +   .features = BIT(DPU_MDP_AUDIO_SELECT),
> +   .clk_ctrls[DPU_CLK_CTRL_VIG0] = { .reg_off = 0x2ac, .bit_off = 0 },
> +   .clk_ctrls[DPU_CLK_CTRL_VIG1] = { .reg_off = 0x2b4, .bit_off = 0 },
> +   .clk_ctrls[DPU_CLK_CTRL_DMA0] = { .reg_off = 0x2ac, .bit_off = 8 },
> +   .clk_ctrls[DPU_CLK_CTRL_DMA1] = { .reg_off = 0x2b4, .bit_off = 8 },
> +   .clk_ctrls[DPU_CLK_CTRL_DMA2] = { .reg_off = 0x2bc, .bit_off = 8 },
> +   .clk_ctrls[DPU_CLK_CTRL_WB2] = { .reg_off = 0x3b8, .bit_off = 24 },
> +   },
> +};
> +
> +static const struct dpu_sspp_cfg sm7150_sspp[] = {
> +   {
> +   .name = "sspp_0", .id = SSPP_VIG0,
> +   .base = 0x4000, .len = 0x1f0,
> +   .features = VIG_SDM845_MASK,
> +   .sblk = &sm8250_vig_sblk_0,
> +   .xin_id = 0,
> +   .type = SSPP_TYPE_VIG,
> +   .clk_ctrl = DPU_CLK_CTRL_VIG0,
> +   }, {
> +   .name = "sspp_1", .id = SSPP_VIG1,
> +   .base = 0x6000, .len = 0x1f0,
> +   .features = VIG_SDM845_MASK,
> +   .sblk = &sm8250_vig_sblk_1,
> +   .xin_id = 4,
> +   .type = SSPP_TYPE_VIG,
> +   .clk_ctrl = DPU_CLK_CTRL_VIG1,
> +   }, {
> +   .name = "sspp_2", .id = SSPP_DMA0,
> +   .base = 0x24000, .len = 0x1f0,
> +   .features = DMA_SDM845_MASK,
> +   .sblk = &sdm845_dma_sblk_0,
> +   .xin_id = 1,
> +   .type = SSPP_TYPE_DMA,
> +   .clk_ctrl = DPU_CLK_CTRL_DMA0,
> +   }, {
> +   .name = "sspp_9", .id = SSPP_DMA1,
> +   .base = 0x26000, .len = 0x1f0,
> +   .features = DMA_SDM845_MASK,
> +   .sblk = &sdm845_dma_sblk_1,
> +   .xin_id = 5,
> +   .type = SSPP_TYPE_DMA,
> +   .clk_ctrl = DPU_CLK_CTRL_DMA1,
> +   }, {
> +   .name = "sspp_10", .id = SSPP_DMA2,
> +   .base = 0x28000, .len = 0x1f0,
> +   .features = DMA_CURSOR_SDM845_MASK,
> +   .sblk = &sdm845_dma_sblk_2,
> +   .xin_id = 9,
> +   .type = SSPP_TYPE_DMA,
> +   .clk_ctrl = DPU_CLK_CTRL_DMA2,
> +   },
> +};
> +
> +static const struct dpu_lm_cfg sm7150_lm[] = {
> +   {
> +   .name = "lm_0", .id = LM_0,
> +   .base = 0x44000, .len = 0x320,
> +   .features = MIXER_SDM845_MASK,
> +   .sblk = &sdm845_lm_sblk,
> +   .lm_pair = LM_1,
> +   .pingpong = PINGPONG_0,
> +   .dspp = DSPP_0,
> +   }, {
> +   .name = "lm_1", .id = LM_1,
> +   .base = 0x45000, .len = 0x320,
> +   .features = MIXER_SDM845_MASK,
> +   .sblk = &sdm845_lm_sblk,
> +   .lm_pair = LM_0,
> +   .pingpong = PINGPONG_1,
> +   .dspp = DSPP_1,
> +   }, {
> +   .name = "lm_2", .id = LM_2,
> +   .base = 0x46000, .len = 0x320,
> +   .features = MIXER_SDM845_MASK,
> +   .sblk = &sdm845_lm_sblk,
> +   .lm_pair = LM_3,
> +   .pingpong = PINGPONG_2,
> 

Re: [Freedreno] [PATCH] drm/msm/mdp5: Don't leak some plane state

2023-08-03 Thread Rob Clark
On Thu, Aug 3, 2023 at 1:45 PM Daniel Vetter  wrote:
>
> Apparently no one noticed that mdp5 plane states leak like a sieve
> ever since we introduced plane_state->commit refcount a few years ago
> in 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too
> early by tracking commits, v3.")
>
> Fix it by using the right helpers.
>
> Fixes: 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too early 
> by tracking commits, v3.")
> Cc: Maarten Lankhorst 
> Cc: Daniel Vetter 
> Cc: Rob Clark 
> Cc: Abhinav Kumar 
> Cc: Dmitry Baryshkov 
> Cc: linux-arm-...@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Reported-and-tested-by: do...@noisolation.com
> Cc: do...@noisolation.com
> Signed-off-by: Daniel Vetter 

Reviewed-by: Rob Clark 

> ---
>  drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c 
> b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> index bd2c4ac45601..0d5ff03cb091 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> @@ -130,8 +130,7 @@ static void mdp5_plane_destroy_state(struct drm_plane 
> *plane,
>  {
> struct mdp5_plane_state *pstate = to_mdp5_plane_state(state);
>
> -   if (state->fb)
> -   drm_framebuffer_put(state->fb);
> +   __drm_atomic_helper_plane_destroy_state(state);
>
> kfree(pstate);
>  }
> --
> 2.40.1
>


[Freedreno] [PATCH] drm/msm/mdp5: Don't leak some plane state

2023-08-03 Thread Daniel Vetter
Apparently no one noticed that mdp5 plane states leak like a sieve
ever since we introduced plane_state->commit refcount a few years ago
in 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too
early by tracking commits, v3.")

Fix it by using the right helpers.

Fixes: 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too early 
by tracking commits, v3.")
Cc: Maarten Lankhorst 
Cc: Daniel Vetter 
Cc: Rob Clark 
Cc: Abhinav Kumar 
Cc: Dmitry Baryshkov 
Cc: linux-arm-...@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Reported-and-tested-by: do...@noisolation.com
Cc: do...@noisolation.com
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
index bd2c4ac45601..0d5ff03cb091 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
@@ -130,8 +130,7 @@ static void mdp5_plane_destroy_state(struct drm_plane 
*plane,
 {
struct mdp5_plane_state *pstate = to_mdp5_plane_state(state);
 
-   if (state->fb)
-   drm_framebuffer_put(state->fb);
+   __drm_atomic_helper_plane_destroy_state(state);
 
kfree(pstate);
 }
-- 
2.40.1



[Freedreno] [PATCH 1/2] dt-bindings: display/msm: document DPU on SM7150

2023-08-03 Thread Danila Tikhonov
Document the DPU hardware found on the Qualcomm SM7150 platform.

Signed-off-by: Danila Tikhonov 
---
 .../bindings/display/msm/qcom,sm7150-dpu.yaml | 116 ++
 1 file changed, 116 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml

diff --git a/Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml 
b/Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
new file mode 100644
index ..0d86997ae09f
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
@@ -0,0 +1,116 @@
+# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/msm/qcom,sm7150-dpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm SM7150 Display DPU
+
+maintainers:
+  - Dmitry Baryshkov 
+  - Danila Tikhonov 
+
+$ref: /schemas/display/msm/dpu-common.yaml#
+
+properties:
+  compatible:
+const: qcom,sm7150-dpu
+
+  reg:
+items:
+  - description: Address offset and size for mdp register set
+  - description: Address offset and size for vbif register set
+
+  reg-names:
+items:
+  - const: mdp
+  - const: vbif
+
+  clocks:
+items:
+  - description: Display hf axi clock
+  - description: Display ahb clock
+  - description: Display rotator clock
+  - description: Display lut clock
+  - description: Display core clock
+  - description: Display vsync clock
+
+  clock-names:
+items:
+  - const: bus
+  - const: iface
+  - const: rot
+  - const: lut
+  - const: core
+  - const: vsync
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+#include 
+#include 
+#include 
+#include 
+
+display-controller@ae01000 {
+compatible = "qcom,sm7150-dpu";
+reg = <0x0ae01000 0x8f000>,
+  <0x0aeb 0x2008>;
+reg-names = "mdp", "vbif";
+
+clocks = <&gcc GCC_DISP_HF_AXI_CLK>,
+ <&dispcc DISP_CC_MDSS_AHB_CLK>,
+ <&dispcc DISP_CC_MDSS_ROT_CLK>,
+ <&dispcc DISP_CC_MDSS_MDP_LUT_CLK>,
+ <&dispcc DISP_CC_MDSS_MDP_CLK>,
+ <&dispcc DISP_CC_MDSS_VSYNC_CLK>;
+clock-names = "bus", "iface", "rot", "lut", "core",
+  "vsync";
+
+assigned-clocks = <&dispcc DISP_CC_MDSS_VSYNC_CLK>,
+  <&dispcc DISP_CC_MDSS_ROT_CLK>,
+  <&dispcc DISP_CC_MDSS_AHB_CLK>;
+assigned-clock-rates = <1920>,
+   <1920>,
+   <1920>;
+
+operating-points-v2 = <&mdp_opp_table>;
+power-domains = <&rpmhpd SM7150_CX>;
+
+interrupt-parent = <&mdss>;
+interrupts = <0>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@0 {
+reg = <0>;
+endpoint {
+remote-endpoint = <&dsi0_in>;
+};
+};
+
+port@1 {
+reg = <1>;
+endpoint {
+remote-endpoint = <&dsi1_in>;
+};
+
+port@2 {
+reg = <2>;
+endpoint {
+remote-endpoint = <&dp_in>;
+};
+};
+};
+};
+...
-- 
2.41.0



[Freedreno] [PATCH 2/2] drm/msm/dpu: Add SM7150 support

2023-08-03 Thread Danila Tikhonov
Add definitions for the display hardware used on the Qualcomm SM7150
platform.

Signed-off-by: Danila Tikhonov 
---
 .../msm/disp/dpu1/catalog/dpu_5_2_sm7150.h| 277 ++
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c|   1 +
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h|   1 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |   1 +
 4 files changed, 280 insertions(+)
 create mode 100644 drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h

diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h 
b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
new file mode 100644
index ..5823879a705a
--- /dev/null
+++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h
@@ -0,0 +1,277 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023, Danila Tikhonov 
+ */
+
+#ifndef _DPU_5_2_SM7150_H
+#define _DPU_5_2_SM7150_H
+
+static const struct dpu_caps sm7150_dpu_caps = {
+   .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
+   .max_mixer_blendstages = 0xb,
+   .qseed_type = DPU_SSPP_SCALER_QSEED4,
+   .has_src_split = true,
+   .has_dim_layer = true,
+   .has_idle_pc = true,
+   .has_3d_merge = true,
+   .max_linewidth = 4096,
+   .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE,
+   .max_hdeci_exp = MAX_HORZ_DECIMATION,
+   .max_vdeci_exp = MAX_VERT_DECIMATION,
+};
+
+static const struct dpu_mdp_cfg sm7150_mdp[] = {
+   {
+   .name = "top_0",
+   .base = 0x0, .len = 0x45c,
+   .features = BIT(DPU_MDP_AUDIO_SELECT),
+   .clk_ctrls[DPU_CLK_CTRL_VIG0] = { .reg_off = 0x2ac, .bit_off = 0 },
+   .clk_ctrls[DPU_CLK_CTRL_VIG1] = { .reg_off = 0x2b4, .bit_off = 0 },
+   .clk_ctrls[DPU_CLK_CTRL_DMA0] = { .reg_off = 0x2ac, .bit_off = 8 },
+   .clk_ctrls[DPU_CLK_CTRL_DMA1] = { .reg_off = 0x2b4, .bit_off = 8 },
+   .clk_ctrls[DPU_CLK_CTRL_DMA2] = { .reg_off = 0x2bc, .bit_off = 8 },
+   .clk_ctrls[DPU_CLK_CTRL_WB2] = { .reg_off = 0x3b8, .bit_off = 24 },
+   },
+};
+
+static const struct dpu_sspp_cfg sm7150_sspp[] = {
+   {
+   .name = "sspp_0", .id = SSPP_VIG0,
+   .base = 0x4000, .len = 0x1f0,
+   .features = VIG_SDM845_MASK,
+   .sblk = &sm8250_vig_sblk_0,
+   .xin_id = 0,
+   .type = SSPP_TYPE_VIG,
+   .clk_ctrl = DPU_CLK_CTRL_VIG0,
+   }, {
+   .name = "sspp_1", .id = SSPP_VIG1,
+   .base = 0x6000, .len = 0x1f0,
+   .features = VIG_SDM845_MASK,
+   .sblk = &sm8250_vig_sblk_1,
+   .xin_id = 4,
+   .type = SSPP_TYPE_VIG,
+   .clk_ctrl = DPU_CLK_CTRL_VIG1,
+   }, {
+   .name = "sspp_2", .id = SSPP_DMA0,
+   .base = 0x24000, .len = 0x1f0,
+   .features = DMA_SDM845_MASK,
+   .sblk = &sdm845_dma_sblk_0,
+   .xin_id = 1,
+   .type = SSPP_TYPE_DMA,
+   .clk_ctrl = DPU_CLK_CTRL_DMA0,
+   }, {
+   .name = "sspp_9", .id = SSPP_DMA1,
+   .base = 0x26000, .len = 0x1f0,
+   .features = DMA_SDM845_MASK,
+   .sblk = &sdm845_dma_sblk_1,
+   .xin_id = 5,
+   .type = SSPP_TYPE_DMA,
+   .clk_ctrl = DPU_CLK_CTRL_DMA1,
+   }, {
+   .name = "sspp_10", .id = SSPP_DMA2,
+   .base = 0x28000, .len = 0x1f0,
+   .features = DMA_CURSOR_SDM845_MASK,
+   .sblk = &sdm845_dma_sblk_2,
+   .xin_id = 9,
+   .type = SSPP_TYPE_DMA,
+   .clk_ctrl = DPU_CLK_CTRL_DMA2,
+   },
+};
+
+static const struct dpu_lm_cfg sm7150_lm[] = {
+   {
+   .name = "lm_0", .id = LM_0,
+   .base = 0x44000, .len = 0x320,
+   .features = MIXER_SDM845_MASK,
+   .sblk = &sdm845_lm_sblk,
+   .lm_pair = LM_1,
+   .pingpong = PINGPONG_0,
+   .dspp = DSPP_0,
+   }, {
+   .name = "lm_1", .id = LM_1,
+   .base = 0x45000, .len = 0x320,
+   .features = MIXER_SDM845_MASK,
+   .sblk = &sdm845_lm_sblk,
+   .lm_pair = LM_0,
+   .pingpong = PINGPONG_1,
+   .dspp = DSPP_1,
+   }, {
+   .name = "lm_2", .id = LM_2,
+   .base = 0x46000, .len = 0x320,
+   .features = MIXER_SDM845_MASK,
+   .sblk = &sdm845_lm_sblk,
+   .lm_pair = LM_3,
+   .pingpong = PINGPONG_2,
+   }, {
+   .name = "lm_3", .id = LM_3,
+   .base = 0x47000, .len = 0x320,
+   .features = MIXER_SDM845_MASK,
+   .sblk = &sdm845_lm_sblk,
+   .lm_pair = LM_2,
+   .pingpong = PINGPONG_3,
+   }, {
+   .name = "lm_4", .id = LM_4,
+   .base = 0x0, .l

[Freedreno] [PATCH 0/2] drm/msm/dpu: Add support for SM7150

2023-08-03 Thread Danila Tikhonov
This series adds DPU support for Qualcomm SM7150 SoC.

Danila Tikhonov (2):
  dt-bindings: display/msm: document DPU on SM7150
  drm/msm/dpu: Add SM7150 support

 .../bindings/display/msm/qcom,sm7150-dpu.yaml | 116 
 .../msm/disp/dpu1/catalog/dpu_5_2_sm7150.h| 277 ++
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c|   1 +
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h|   1 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |   1 +
 5 files changed, 396 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/msm/qcom,sm7150-dpu.yaml
 create mode 100644 drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_2_sm7150.h

--
2.41.0



[Freedreno] [PATCH] drm/msm: Disallow relocs on a6xx+

2023-08-03 Thread Rob Clark
From: Rob Clark 

Mesa stopped using these pretty early in a6xx bringup[1].  Take advantage
of this to disallow some legacy UABI.

[1] 
https://gitlab.freedesktop.org/mesa/mesa/-/commit/7ef722861b691ce99be3827ed05f8c0ddf2cd66e

Signed-off-by: Rob Clark 
Acked-by: Daniel Vetter 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c |  2 ++
 drivers/gpu/drm/msm/msm_gem_submit.c| 10 ++
 drivers/gpu/drm/msm/msm_gpu.h   |  9 +
 3 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index ba35c2a87021..695cce82d914 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -1078,6 +1078,8 @@ int adreno_gpu_init(struct drm_device *drm, struct 
platform_device *pdev,
adreno_gpu->info = config->info;
adreno_gpu->chip_id = config->chip_id;
 
+   gpu->allow_relocs = config->info->family < ADRENO_6XX_GEN1;
+
/* Only handle the core clock when GMU is not in use (or is absent). */
if (adreno_has_gmu_wrapper(adreno_gpu) ||
adreno_gpu->info->family < ADRENO_6XX_GEN1) {
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index 63c96416e183..3b908f9f5493 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -882,6 +882,16 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void 
*data,
if (submit->valid)
continue;
 
+   if (!gpu->allow_relocs) {
+   if (submit->cmd[i].nr_relocs) {
+   DRM_ERROR("relocs not allowed\n");
+   ret = -EINVAL;
+   goto out;
+   }
+
+   continue;
+   }
+
ret = submit_reloc(submit, msm_obj, submit->cmd[i].offset * 4,
submit->cmd[i].nr_relocs, 
submit->cmd[i].relocs);
if (ret)
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 7a4fa1b8655b..4252e3839fbc 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -285,6 +285,15 @@ struct msm_gpu {
/* True if the hardware supports expanded apriv (a650 and newer) */
bool hw_apriv;
 
+   /**
+* @allow_relocs: allow relocs in SUBMIT ioctl
+*
+* Mesa won't use relocs for driver version 1.4.0 and later.  This
+* switch-over happened early enough in mesa a6xx bringup that we
+* can disallow relocs for a6xx and newer.
+*/
+   bool allow_relocs;
+
struct thermal_cooling_device *cooling;
 };
 
-- 
2.41.0



[Freedreno] [PATCH] drm/msm/a6xx: Fix GMU lockdep splat

2023-08-03 Thread Rob Clark
From: Rob Clark 

For normal GPU devfreq, we need to acquire the GMU lock while already
holding devfreq locks.  But in the teardown path, we were calling
dev_pm_domain_detach() while already holding the GMU lock, resulting in
this lockdep splat:

   ==
   WARNING: possible circular locking dependency detected
   6.4.3-debug+ #3 Not tainted
   --
   ring0/391 is trying to acquire lock:
   ff80a025c078 (&devfreq->lock){+.+.}-{3:3}, at: 
qos_notifier_call+0x30/0x74

   but task is already holding lock:
   ff809b8c1ce8 (&(c->notifiers)->rwsem){}-{3:3}, at: 
blocking_notifier_call_chain+0x34/0x78

   which lock already depends on the new lock.

   the existing dependency chain (in reverse order) is:

   -> #4 (&(c->notifiers)->rwsem){}-{3:3}:
  down_write+0x58/0x74
  __blocking_notifier_chain_register+0x64/0x84
  blocking_notifier_chain_register+0x1c/0x28
  freq_qos_add_notifier+0x5c/0x7c
  dev_pm_qos_add_notifier+0xd4/0xf0
  devfreq_add_device+0x42c/0x560
  devm_devfreq_add_device+0x6c/0xb8
  msm_devfreq_init+0xa8/0x16c [msm]
  msm_gpu_init+0x368/0x54c [msm]
  adreno_gpu_init+0x248/0x2b0 [msm]
  a6xx_gpu_init+0x2d0/0x384 [msm]
  adreno_bind+0x264/0x2bc [msm]
  component_bind_all+0x124/0x1f4
  msm_drm_bind+0x2d0/0x5f4 [msm]
  try_to_bring_up_aggregate_device+0x88/0x1a4
  __component_add+0xd4/0x128
  component_add+0x1c/0x28
  dp_display_probe+0x37c/0x3c0 [msm]
  platform_probe+0x70/0xc0
  really_probe+0x148/0x280
  __driver_probe_device+0xfc/0x114
  driver_probe_device+0x44/0x100
  __device_attach_driver+0x64/0xdc
  bus_for_each_drv+0xb0/0xd8
  __device_attach+0xe4/0x140
  device_initial_probe+0x1c/0x28
  bus_probe_device+0x44/0xb0
  deferred_probe_work_func+0xb0/0xc8
  process_one_work+0x288/0x3d8
  worker_thread+0x1f0/0x260
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   -> #3 (dev_pm_qos_mtx){+.+.}-{3:3}:
  __mutex_lock+0xc8/0x388
  mutex_lock_nested+0x2c/0x38
  dev_pm_qos_remove_notifier+0x3c/0xc8
  genpd_remove_device+0x40/0x11c
  genpd_dev_pm_detach+0x88/0x130
  dev_pm_domain_detach+0x2c/0x3c
  a6xx_gmu_remove+0x44/0xdc [msm]
  a6xx_destroy+0x7c/0xa4 [msm]
  adreno_unbind+0x50/0x64 [msm]
  component_unbind+0x44/0x64
  component_unbind_all+0xb4/0xbc
  msm_drm_uninit.isra.0+0x124/0x17c [msm]
  msm_drm_bind+0x340/0x5f4 [msm]
  try_to_bring_up_aggregate_device+0x88/0x1a4
  __component_add+0xd4/0x128
  component_add+0x1c/0x28
  dp_display_probe+0x37c/0x3c0 [msm]
  platform_probe+0x70/0xc0
  really_probe+0x148/0x280
  __driver_probe_device+0xfc/0x114
  driver_probe_device+0x44/0x100
  __device_attach_driver+0x64/0xdc
  bus_for_each_drv+0xb0/0xd8
  __device_attach+0xe4/0x140
  device_initial_probe+0x1c/0x28
  bus_probe_device+0x44/0xb0
  deferred_probe_work_func+0xb0/0xc8
  process_one_work+0x288/0x3d8
  worker_thread+0x1f0/0x260
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   -> #2 (&a6xx_gpu->gmu.lock){+.+.}-{3:3}:
  __mutex_lock+0xc8/0x388
  mutex_lock_nested+0x2c/0x38
  a6xx_gpu_set_freq+0x38/0x64 [msm]
  msm_devfreq_target+0x170/0x18c [msm]
  devfreq_set_target+0x90/0x1e4
  devfreq_update_target+0xb4/0xf0
  update_devfreq+0x1c/0x28
  devfreq_monitor+0x3c/0x10c
  process_one_work+0x288/0x3d8
  worker_thread+0x1f0/0x260
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   -> #1 (&df->lock){+.+.}-{3:3}:
  __mutex_lock+0xc8/0x388
  mutex_lock_nested+0x2c/0x38
  msm_devfreq_get_dev_status+0x4c/0x104 [msm]
  devfreq_simple_ondemand_func+0x5c/0x128
  devfreq_update_target+0x68/0xf0
  update_devfreq+0x1c/0x28
  devfreq_monitor+0x3c/0x10c
  process_one_work+0x288/0x3d8
  worker_thread+0x1f0/0x260
  kthread+0xf0/0x100
  ret_from_fork+0x10/0x20

   -> #0 (&devfreq->lock){+.+.}-{3:3}:
  __lock_acquire+0xdf8/0x109c
  lock_acquire+0x234/0x284
  __mutex_lock+0xc8/0x388
  mutex_lock_nested+0x2c/0x38
  qos_notifier_call+0x30/0x74
  qos_min_notifier_call+0x1c/0x28
  notifier_call_chain+0xf4/0x114
  blocking_notifier_call_chain+0x4c/0x78
  pm_qos_update_target+0x184/0x190
  freq_qos_apply+0x4c/0x64
  apply_constraint+0xf8/0xfc
  __dev_pm_qos_update_request+0x138/0x164
  dev_pm_qos_update_request+0x44/0x68
  msm_devfreq_b

Re: [Freedreno] [PATCH 4/4] drm/msm: Remove vma use tracking

2023-08-03 Thread Rob Clark
On Thu, Aug 3, 2023 at 1:38 AM Daniel Vetter  wrote:
>
> On Wed, Aug 02, 2023 at 03:21:52PM -0700, Rob Clark wrote:
> > From: Rob Clark 
> >
> > This was not strictly necessary, as page unpinning (ie. shrinker) only
> > cares about the resv.  It did give us some extra sanity checking for
> > userspace controlled iova, and was useful to catch issues on kernel and
> > userspace side when enabling userspace iova.  But if userspace screws
> > this up, it just corrupts it's own gpu buffers and/or gets iova faults.
> > So we can just let userspace shoot it's own foot and drop the extra per-
> > buffer SUBMIT overhead.
> >
> > Signed-off-by: Rob Clark 
>
> I did check a few things (like that the gem lru helpers have all the
> needed lockdep_assert_held) and I think aside from the optimization this
> is a nice semantic cleanup. Since iirc we've had a locking inversion
> discussion and the vma tracking here came up as a culprit. On the series:

yup, I try to make sure there are sufficient locking asserts when it
comes to gem stuff ;-)

There shouldn't have been any locking inversion with the vma lock (no
other locks acquired under it) but it was hurting cpu overhead.  The
big remaining locking headache for me is run-pm / pm-qos

BR,
-R

> Acked-by: Daniel Vetter 
>
> > ---
> >  drivers/gpu/drm/msm/msm_gem.c|  9 +---
> >  drivers/gpu/drm/msm/msm_gem.h| 12 +
> >  drivers/gpu/drm/msm/msm_gem_submit.c | 14 ++
> >  drivers/gpu/drm/msm/msm_gem_vma.c| 67 +---
> >  drivers/gpu/drm/msm/msm_ringbuffer.c |  3 +-
> >  5 files changed, 9 insertions(+), 96 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> > index 1c81ff6115ac..ce1ed0f9ad2d 100644
> > --- a/drivers/gpu/drm/msm/msm_gem.c
> > +++ b/drivers/gpu/drm/msm/msm_gem.c
> > @@ -607,9 +607,6 @@ static int clear_iova(struct drm_gem_object *obj,
> >   if (!vma)
> >   return 0;
> >
> > - if (msm_gem_vma_inuse(vma))
> > - return -EBUSY;
> > -
> >   msm_gem_vma_purge(vma);
> >   msm_gem_vma_close(vma);
> >   del_vma(vma);
> > @@ -660,7 +657,6 @@ void msm_gem_unpin_iova(struct drm_gem_object *obj,
> >   msm_gem_lock(obj);
> >   vma = lookup_vma(obj, aspace);
> >   if (!GEM_WARN_ON(!vma)) {
> > - msm_gem_vma_unpin(vma);
> >   msm_gem_unpin_locked(obj);
> >   }
> >   msm_gem_unlock(obj);
> > @@ -991,11 +987,10 @@ void msm_gem_describe(struct drm_gem_object *obj, 
> > struct seq_file *m,
> >   } else {
> >   name = comm = NULL;
> >   }
> > - seq_printf(m, " [%s%s%s: aspace=%p, 
> > %08llx,%s,inuse=%d]",
> > + seq_printf(m, " [%s%s%s: aspace=%p, %08llx,%s]",
> >   name, comm ? ":" : "", comm ? comm : "",
> >   vma->aspace, vma->iova,
> > - vma->mapped ? "mapped" : "unmapped",
> > - msm_gem_vma_inuse(vma));
> > + vma->mapped ? "mapped" : "unmapped");
> >   kfree(comm);
> >   }
> >
> > diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
> > index 2ddd896aac68..8ddef5443140 100644
> > --- a/drivers/gpu/drm/msm/msm_gem.h
> > +++ b/drivers/gpu/drm/msm/msm_gem.h
> > @@ -59,24 +59,16 @@ struct msm_fence_context;
> >
> >  struct msm_gem_vma {
> >   struct drm_mm_node node;
> > - spinlock_t lock;
> >   uint64_t iova;
> >   struct msm_gem_address_space *aspace;
> >   struct list_head list;/* node in msm_gem_object::vmas */
> >   bool mapped;
> > - int inuse;
> > - uint32_t fence_mask;
> > - uint32_t fence[MSM_GPU_MAX_RINGS];
> > - struct msm_fence_context *fctx[MSM_GPU_MAX_RINGS];
> >  };
> >
> >  struct msm_gem_vma *msm_gem_vma_new(struct msm_gem_address_space *aspace);
> >  int msm_gem_vma_init(struct msm_gem_vma *vma, int size,
> >   u64 range_start, u64 range_end);
> > -bool msm_gem_vma_inuse(struct msm_gem_vma *vma);
> >  void msm_gem_vma_purge(struct msm_gem_vma *vma);
> > -void msm_gem_vma_unpin(struct msm_gem_vma *vma);
> > -void msm_gem_vma_unpin_fenced(struct msm_gem_vma *vma, struct 
> > msm_fence_context *fctx);
> >  int msm_gem_vma_map(struct msm_gem_vma *vma, int prot, struct sg_table 
> > *sgt, int size);
> >  void msm_gem_vma_close(struct msm_gem_vma *vma);
> >
> > @@ -298,15 +290,13 @@ struct msm_gem_submit {
> >  /* make sure these don't conflict w/ MSM_SUBMIT_BO_x */
> >  #define BO_VALID 0x8000  /* is current addr in cmdstream 
> > correct/valid? */
> >  #define BO_LOCKED0x4000  /* obj lock is held */
> > -#define BO_OBJ_PINNED0x2000  /* obj (pages) is pinned and on 
> > active list */
> > -#define BO_VMA_PINNED0x1000  /* vma (virtual address) is pinned */
> > +#define BO_PINNED0x2000  /* obj (pages) is pinned 

Re: [Freedreno] [PATCH] drm/msm/dpu: increase memtype count to 16 for sm8550

2023-08-03 Thread Dmitry Baryshkov


On Wed, 02 Aug 2023 09:48:53 -0400, Jonathan Marek wrote:
> sm8550 has 16 vbif clients.
> 
> This fixes the extra 2 clients (DMA4/DMA5) not having their memtype
> initialized. This fixes DMA4/DMA5 planes not displaying correctly.
> 
> 

Applied, thanks!

[1/1] drm/msm/dpu: increase memtype count to 16 for sm8550
  https://gitlab.freedesktop.org/lumag/msm/-/commit/42d0d253ed03

Best regards,
-- 
Dmitry Baryshkov 


Re: [Freedreno] [PATCH v2 1/2] drm/msm/dpu: fix DSC 1.2 block lengths

2023-08-03 Thread Dmitry Baryshkov


On Wed, 02 Aug 2023 21:36:54 +0300, Dmitry Baryshkov wrote:
> All DSC_BLK_1_2 declarations incorrectly pass 0x29c as the block length.
> This includes the common block itself, enc subblocks and some empty
> space around. Change that to pass 0x4 instead, the length of common
> register block itself.
> 
> 

Applied, thanks!

[1/2] drm/msm/dpu: fix DSC 1.2 block lengths
  https://gitlab.freedesktop.org/lumag/msm/-/commit/e550ad0e5c3d
[2/2] drm/msm/dpu: fix DSC 1.2 enc subblock length
  https://gitlab.freedesktop.org/lumag/msm/-/commit/57a1ca6cf73b

Best regards,
-- 
Dmitry Baryshkov 


Re: [Freedreno] [PATCH 00/14] A7xx support

2023-08-03 Thread Neil Armstrong

On 28/06/2023 22:35, Konrad Dybcio wrote:

This series attempts to introduce Adreno 700 support (with A730 and A740
found on SM8450 and SM8550 respectively), reusing much of the existing
A6xx code. This submission largely lays the groundwork for expansion and
more or less gives us feature parity (on the kernel side, that is) with
existing A6xx parts.

On top of introducing a very messy set of three (!) separate and
obfuscated deivce identifiers for each 7xx part, this generation
introduces very sophisticated hardware multi-threading and (on some SKUs)
hardware ray-tracing (not supported yet).

After this series, a long-overdue cleanup of drm/msm/adreno is planned
in preparation for adding more features and removing some hardcoding.

The last patch is a hack that may or may not be necessary depending
on your board's humour.. eh.. :/

Developed atop (and hence depends on) [1]

The corresponding devicetree patches are initially available at [2] and
will be posted after this series gets merged. To test it, you'll also need
firmware that you need to obtain from your board (there's none with a
redistributable license, sorry..). Most likely it will be in one of
these directories on your stock android installation:

* /vendor/firmware
* /vendor/firmware_mnt
* /system

..but some vendors make it hard and you have to do some grepping ;)

Requires [3] to work on the userspace side. You'll almost cerainly want
to test it alongside Zink with a lot of debug flags (early impl), like:

TU_DEBUG=sysmem,nolrz,flushall,noubwc MESA_LOADER_DRIVER_OVERRIDE=zink kmscube

[1] 
https://lore.kernel.org/linux-arm-msm/20230517-topic-a7xx_prep-v4-0-b16f273a9...@linaro.org/
[2] https://github.com/SoMainline/linux/commits/topic/a7xx_dt
[3] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23217

Signed-off-by: Konrad Dybcio 
---
Konrad Dybcio (14):
   dt-bindings: display/msm/gmu: Add Adreno 7[34]0 GMU
   dt-bindings: display/msm/gmu: Allow passing QMP handle
   dt-bindings: display/msm/gpu: Allow A7xx SKUs
   drm/msm/a6xx: Add missing regs for A7XX
   drm/msm/a6xx: Introduce a6xx_llc_read
   drm/msm/a6xx: Move LLC accessors to the common header
   drm/msm/a6xx: Bail out early if setting GPU OOB fails
   drm/msm/a6xx: Add skeleton A7xx support
   drm/msm/a6xx: Send ACD state to QMP at GMU resume
   drm/msm/a6xx: Mostly implement A7xx gpu_state
   drm/msm/a6xx: Add A730 support
   drm/msm/a6xx: Add A740 support
   drm/msm/a6xx: Vastly increase HFI timeout
   [RFC] drm/msm/a6xx: Poll for GBIF unhalt status in hw_init

  .../devicetree/bindings/display/msm/gmu.yaml   |  47 +-
  .../devicetree/bindings/display/msm/gpu.yaml   |   4 +-
  drivers/gpu/drm/msm/adreno/a6xx.xml.h  |   9 +
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c  | 188 --
  drivers/gpu/drm/msm/adreno/a6xx_gmu.h  |   3 +
  drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h  |   8 +
  drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 658 ++---
  drivers/gpu/drm/msm/adreno/a6xx_gpu.h  |  15 +
  drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c|  52 +-
  drivers/gpu/drm/msm/adreno/a6xx_gpu_state.h|  61 +-
  drivers/gpu/drm/msm/adreno/a6xx_hfi.c  |  90 ++-
  drivers/gpu/drm/msm/adreno/adreno_device.c |  26 +
  drivers/gpu/drm/msm/adreno/adreno_gpu.c|   7 +-
  drivers/gpu/drm/msm/adreno/adreno_gpu.h|  24 +-
  drivers/gpu/drm/msm/msm_ringbuffer.h   |   2 +
  15 files changed, 1070 insertions(+), 124 deletions(-)
---
base-commit: 6f9b660e9cbb30669fcfec83288d527c0844717d
change-id: 20230628-topic-a7xx_drmmsm-123f30d76cf7

Best regards,


Tested-by: Neil Armstrong  # on SM8550-QRD


Re: [Freedreno] [PATCH 4/4] drm/msm: Remove vma use tracking

2023-08-03 Thread Daniel Vetter
On Wed, Aug 02, 2023 at 03:21:52PM -0700, Rob Clark wrote:
> From: Rob Clark 
> 
> This was not strictly necessary, as page unpinning (ie. shrinker) only
> cares about the resv.  It did give us some extra sanity checking for
> userspace controlled iova, and was useful to catch issues on kernel and
> userspace side when enabling userspace iova.  But if userspace screws
> this up, it just corrupts it's own gpu buffers and/or gets iova faults.
> So we can just let userspace shoot it's own foot and drop the extra per-
> buffer SUBMIT overhead.
> 
> Signed-off-by: Rob Clark 

I did check a few things (like that the gem lru helpers have all the
needed lockdep_assert_held) and I think aside from the optimization this
is a nice semantic cleanup. Since iirc we've had a locking inversion
discussion and the vma tracking here came up as a culprit. On the series:

Acked-by: Daniel Vetter 

> ---
>  drivers/gpu/drm/msm/msm_gem.c|  9 +---
>  drivers/gpu/drm/msm/msm_gem.h| 12 +
>  drivers/gpu/drm/msm/msm_gem_submit.c | 14 ++
>  drivers/gpu/drm/msm/msm_gem_vma.c| 67 +---
>  drivers/gpu/drm/msm/msm_ringbuffer.c |  3 +-
>  5 files changed, 9 insertions(+), 96 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index 1c81ff6115ac..ce1ed0f9ad2d 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -607,9 +607,6 @@ static int clear_iova(struct drm_gem_object *obj,
>   if (!vma)
>   return 0;
>  
> - if (msm_gem_vma_inuse(vma))
> - return -EBUSY;
> -
>   msm_gem_vma_purge(vma);
>   msm_gem_vma_close(vma);
>   del_vma(vma);
> @@ -660,7 +657,6 @@ void msm_gem_unpin_iova(struct drm_gem_object *obj,
>   msm_gem_lock(obj);
>   vma = lookup_vma(obj, aspace);
>   if (!GEM_WARN_ON(!vma)) {
> - msm_gem_vma_unpin(vma);
>   msm_gem_unpin_locked(obj);
>   }
>   msm_gem_unlock(obj);
> @@ -991,11 +987,10 @@ void msm_gem_describe(struct drm_gem_object *obj, 
> struct seq_file *m,
>   } else {
>   name = comm = NULL;
>   }
> - seq_printf(m, " [%s%s%s: aspace=%p, 
> %08llx,%s,inuse=%d]",
> + seq_printf(m, " [%s%s%s: aspace=%p, %08llx,%s]",
>   name, comm ? ":" : "", comm ? comm : "",
>   vma->aspace, vma->iova,
> - vma->mapped ? "mapped" : "unmapped",
> - msm_gem_vma_inuse(vma));
> + vma->mapped ? "mapped" : "unmapped");
>   kfree(comm);
>   }
>  
> diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
> index 2ddd896aac68..8ddef5443140 100644
> --- a/drivers/gpu/drm/msm/msm_gem.h
> +++ b/drivers/gpu/drm/msm/msm_gem.h
> @@ -59,24 +59,16 @@ struct msm_fence_context;
>  
>  struct msm_gem_vma {
>   struct drm_mm_node node;
> - spinlock_t lock;
>   uint64_t iova;
>   struct msm_gem_address_space *aspace;
>   struct list_head list;/* node in msm_gem_object::vmas */
>   bool mapped;
> - int inuse;
> - uint32_t fence_mask;
> - uint32_t fence[MSM_GPU_MAX_RINGS];
> - struct msm_fence_context *fctx[MSM_GPU_MAX_RINGS];
>  };
>  
>  struct msm_gem_vma *msm_gem_vma_new(struct msm_gem_address_space *aspace);
>  int msm_gem_vma_init(struct msm_gem_vma *vma, int size,
>   u64 range_start, u64 range_end);
> -bool msm_gem_vma_inuse(struct msm_gem_vma *vma);
>  void msm_gem_vma_purge(struct msm_gem_vma *vma);
> -void msm_gem_vma_unpin(struct msm_gem_vma *vma);
> -void msm_gem_vma_unpin_fenced(struct msm_gem_vma *vma, struct 
> msm_fence_context *fctx);
>  int msm_gem_vma_map(struct msm_gem_vma *vma, int prot, struct sg_table *sgt, 
> int size);
>  void msm_gem_vma_close(struct msm_gem_vma *vma);
>  
> @@ -298,15 +290,13 @@ struct msm_gem_submit {
>  /* make sure these don't conflict w/ MSM_SUBMIT_BO_x */
>  #define BO_VALID 0x8000  /* is current addr in cmdstream correct/valid? 
> */
>  #define BO_LOCKED0x4000  /* obj lock is held */
> -#define BO_OBJ_PINNED0x2000  /* obj (pages) is pinned and on active 
> list */
> -#define BO_VMA_PINNED0x1000  /* vma (virtual address) is pinned */
> +#define BO_PINNED0x2000  /* obj (pages) is pinned and on active list */
>   uint32_t flags;
>   union {
>   struct drm_gem_object *obj;
>   uint32_t handle;
>   };
>   uint64_t iova;
> - struct msm_gem_vma *vma;
>   } bos[];
>  };
>  
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
> b/drivers/gpu/drm/msm/msm_gem_submit.c
> index b17561ebd518..5f90cc8e7b7f 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -261,10 +261,7 @@ static voi

Re: [Freedreno] [RFC] drm/msm: Disallow relocs on a6xx+

2023-08-03 Thread Daniel Vetter
On Wed, Aug 02, 2023 at 03:10:44PM -0700, Rob Clark wrote:
> From: Rob Clark 
> 
> Mesa stopped using these pretty early in a6xx bringup.  Take advantage
> of this to disallow some legacy UABI.
> 
> Signed-off-by: Rob Clark 
> ---
> So, it was late 2018 when mesa stopped using relocs.  At that point a6xx
> support was still in a pretty early state.  I guess you _could_ use such
> an old version of mesa with a6xx hw.. but you really shouldn't.

Acked-by: Daniel Vetter 

Might be good to cite the mesa commit that removed the a6xx reloc code in
the commit message.
-Sima

> 
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c |  2 ++
>  drivers/gpu/drm/msm/msm_gem_submit.c| 10 ++
>  drivers/gpu/drm/msm/msm_gpu.h   |  9 +
>  3 files changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
> b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index ba35c2a87021..695cce82d914 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -1078,6 +1078,8 @@ int adreno_gpu_init(struct drm_device *drm, struct 
> platform_device *pdev,
>   adreno_gpu->info = config->info;
>   adreno_gpu->chip_id = config->chip_id;
>  
> + gpu->allow_relocs = config->info->family < ADRENO_6XX_GEN1;
> +
>   /* Only handle the core clock when GMU is not in use (or is absent). */
>   if (adreno_has_gmu_wrapper(adreno_gpu) ||
>   adreno_gpu->info->family < ADRENO_6XX_GEN1) {
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
> b/drivers/gpu/drm/msm/msm_gem_submit.c
> index 63c96416e183..3b908f9f5493 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -882,6 +882,16 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void 
> *data,
>   if (submit->valid)
>   continue;
>  
> + if (!gpu->allow_relocs) {
> + if (submit->cmd[i].nr_relocs) {
> + DRM_ERROR("relocs not allowed\n");
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + continue;
> + }
> +
>   ret = submit_reloc(submit, msm_obj, submit->cmd[i].offset * 4,
>   submit->cmd[i].nr_relocs, 
> submit->cmd[i].relocs);
>   if (ret)
> diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
> index 7a4fa1b8655b..4252e3839fbc 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.h
> +++ b/drivers/gpu/drm/msm/msm_gpu.h
> @@ -285,6 +285,15 @@ struct msm_gpu {
>   /* True if the hardware supports expanded apriv (a650 and newer) */
>   bool hw_apriv;
>  
> + /**
> +  * @allow_relocs: allow relocs in SUBMIT ioctl
> +  *
> +  * Mesa won't use relocs for driver version 1.4.0 and later.  This
> +  * switch-over happened early enough in mesa a6xx bringup that we
> +  * can disallow relocs for a6xx and newer.
> +  */
> + bool allow_relocs;
> +
>   struct thermal_cooling_device *cooling;
>  };
>  
> -- 
> 2.41.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch