Re: amdgpu: Manual Card Configuration Change

2020-10-19 Thread Josh Fuhs
Thanks. I tried 5.9.1 and I think there's still a problem, or at least 
something different.

Using the same configuration script, I noticed that my cards are running a lot 
hotter. For example, here's total power consumption of a two-card system with 
two different kernels:

5.8.14: 460W
5.9.1:  560+W

Memory and system clocks are initially set the same on all cards in all cases.

Josh


‐‐‐ Original Message ‐‐‐
On Monday, October 19, 2020 2:22 PM, Alex Deucher  wrote:

> On Sun, Oct 18, 2020 at 4:32 PM Josh Fuhs joshua.f...@pm.me wrote:
>
> > Hello all,
> > Regarding amdgpu, I've been using some Radeon 5700XTs for compute work with 
> > kernels through 5.8.14. I recently tried kernel 5.9.0, and found that the 
> > following is no longer allowed:
> > echo "m 1 200" | sudo tee /sys/class/drm/card0/device/pp_od_clk_voltage
> > Is this an expected change? If so, where should I look for documentation 
> > regarding how to manually configure these cards with this kernel. Note, 
> > I've had this working with 5.8 kernels for months.
>
> It was a bug. Fixed in 5.9.1.
>
> Alex


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] [RFC/HACK] drm/ttm: avoid multihop moves in drivers.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 128 +++-
 drivers/gpu/drm/nouveau/nouveau_bo.c| 106 ++--
 drivers/gpu/drm/radeon/radeon_ttm.c | 110 ++--
 drivers/gpu/drm/ttm/ttm_bo.c|  44 +++-
 4 files changed, 77 insertions(+), 311 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 872795affe87..51d55e3fd8c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -515,109 +515,6 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
return r;
 }
 
-static int amdgpu_move_setup_tt(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx,
-   struct ttm_resource *tmp_mem)
-{
-   struct ttm_place placements;
-   struct ttm_placement placement;
-   int r;
-
-   placement.num_placement = 1;
-   placement.placement = 
-   placement.num_busy_placement = 1;
-   placement.busy_placement = 
-   placements.fpfn = 0;
-   placements.lpfn = 0;
-   placements.mem_type = TTM_PL_TT;
-   placements.flags = 0;
-   r = ttm_bo_mem_space(bo, , tmp_mem, ctx);
-   if (unlikely(r)) {
-   pr_err("Failed to find GTT space for blit from VRAM\n");
-   return r;
-   }
-
-   r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
-   if (unlikely(r))
-   goto out_cleanup;
-
-   /* Bind the memory to the GTT space */
-   r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, tmp_mem);
-   if (unlikely(r)) {
-   goto out_cleanup;
-   }
-   return 0;
-out_cleanup:
-   ttm_resource_free(bo, tmp_mem);
-   return r;
-}
-/**
- * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
- *
- * Called by amdgpu_bo_move().
- */
-static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
-   struct ttm_operation_ctx *ctx,
-   struct ttm_resource *new_mem)
-{
-   struct ttm_resource *old_mem = >mem;
-   struct ttm_resource tmp_mem;
-   int r;
-
-   /* create space/pages for new_mem in GTT space */
-   tmp_mem = *new_mem;
-   tmp_mem.mm_node = NULL;
-
-   r = amdgpu_move_setup_tt(bo, ctx, _mem);
-   if (unlikely(r))
-   return r;
-
-   /* blit VRAM to GTT */
-   r = amdgpu_move_blit(bo, evict, _mem, old_mem);
-   if (unlikely(r)) {
-   goto out_cleanup;
-   }
-
-   r = ttm_bo_wait_ctx(bo, ctx);
-   if (unlikely(r))
-   goto out_cleanup;
-
-   amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
-   ttm_resource_free(bo, >mem);
-   ttm_bo_assign_mem(bo, new_mem);
-out_cleanup:
-   ttm_resource_free(bo, _mem);
-   return r;
-}
-
-/**
- * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
- *
- * Called by amdgpu_bo_move().
- */
-static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
-   struct ttm_operation_ctx *ctx,
-   struct ttm_resource *new_mem)
-{
-   struct ttm_resource *old_mem = >mem;
-   struct ttm_resource tmp_mem;
-   int r;
-
-   /* make space in GTT for old_mem buffer */
-   tmp_mem = *new_mem;
-   tmp_mem.mm_node = NULL;
-
-   r = amdgpu_move_setup_tt(bo, ctx, _mem);
-   if (unlikely(r))
-   return r;
-
-   ttm_bo_assign_mem(bo, _mem);
-   /* copy to VRAM */
-   r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
-   ttm_resource_free(bo, _mem);
-   return r;
-}
-
 /**
  * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
  *
@@ -656,6 +553,19 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
struct ttm_resource *old_mem = >mem;
int r;
 
+   /* don't go from system->vram in one hop,
+  report this back to the caller tell it
+  where to bounce this buffer through. */
+
+   if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+new_mem->mem_type == TTM_PL_VRAM) ||
+   (old_mem->mem_type == TTM_PL_VRAM &&
+new_mem->mem_type == TTM_PL_SYSTEM)) {
+   new_mem->mem_type = TTM_PL_TT;
+   new_mem->placement = 0;
+   return -EMULTIHOP;
+   }
+
if (new_mem->mem_type == TTM_PL_TT) {
r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
if (r)
@@ -709,16 +619,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
goto memcpy;
}
 
-   if (old_mem->mem_type == TTM_PL_VRAM &&
-   new_mem->mem_type == TTM_PL_SYSTEM) {
-   r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
-   } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
-  new_mem->mem_type == TTM_PL_VRAM) {
-

[RFC HACKY] ttm don't allow multihop moves

2020-10-19 Thread Dave Airlie
This is an RFC for a hacky idea I had to at least move the converation forward.

The branch with this in it is:
https://github.com/airlied/linux/tree/ttm-bounce

it won't apply to any other tree as it's based on all those patches I posted 
and some other refactorings.

The basic idea is if the driver gets a move request from the TTM core that 
requires it to bounce the buffer
through another domain, it returns -EMULTIHOP and puts the domain details into 
the mem_type, the core
code then just does the mem space for the new temp placment, and retries the 
final placement again.

I've tested on nouveau that the code gets executed (a printk prints at least), 
and it all doesn't burn
down, but it's very lightly tested.

It does allow getting rid of a lot of driver code to handle bouncing moves.

I'm sure this could be prettier or done in a very different way more 
effectively, but hey this was
my chance to misuse an errno value.

Dave.


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/5] drm/ttm: drop bo->num_pages.

2020-10-19 Thread Dave Airlie
On Tue, 20 Oct 2020 at 08:23, Dave Airlie  wrote:
>
> From: Dave Airlie 
>
> This is stored in the mem field, everywhere that a new mem is
> created, the bo->mem is either copied or this field is copied
> explicitly.

This has a problem with the pipeline gutting path, since it memset
(bo->mem to 0), but I'll fix that up in a v2.

Dave.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: document that user-space should avoid parsing EDIDs

2020-10-19 Thread Vitaly Prosyak


On 2020-10-19 3:49 a.m., Pekka Paalanen wrote:

On Fri, 16 Oct 2020 16:50:16 +0300
Ville Syrjälä  wrote:


On Mon, Oct 12, 2020 at 10:11:01AM +0300, Pekka Paalanen wrote:

On Fri, 9 Oct 2020 17:20:18 +0300
Ville Syrjälä  wrote:
   

On Fri, Oct 09, 2020 at 04:56:51PM +0300, Pekka Paalanen wrote:

On Fri, 9 Oct 2020 16:10:25 +0300
Ville Syrjälä  wrote:
 

On Fri, Oct 09, 2020 at 01:07:20PM +0100, Daniel Stone wrote:

Hi,

On Fri, 9 Oct 2020 at 10:24, Simon Ser  wrote:

User-space should avoid parsing EDIDs for metadata already exposed via
other KMS interfaces and properties. For instance, user-space should not
try to extract a list of modes from the EDID: the kernel might mutate
the mode list (because of link capabilities or quirks for instance).

Other metadata not exposed by KMS can be parsed by user-space. This
includes for instance monitor identification (make/model/serial) and
supported color-spaces.

So I take it the only way to get modes is through the connector's list
of modes. That sounds reasonable enough to me, but I think to properly
handle colour (e.g. CEA modes have different behaviour for
limited/full range depending on which VIC they correspond to IIRC)

If the mode has a VIC and that VIC is not 1, then it's limited range,
otherwise full range. There are fortunately no cases where you would
have the same exact timings corresponding to different quantization
range depending on the VIC.

And the only reason the same timings could correspond to multiple VICs
is aspect ratio. Which is already exposed via the mode flags, assuming
the appropriate client cap is enabled.

So I think the only reason to expose the VIC would be if userspace is
non-lazy and wants to manage its colors presicely, but is otherwise lazy
and doesn't want to figure out what the VIC of the mode is on its own.

What would "figure out what the VIC of the mode is" require in userspace?

A database of all VIC modes and then compare if the detailed timings match?

Is that also how the kernel recognises that userspace wants to set a
certain VIC mode instead of some arbitrary mode?

Yes and yes.

Note that atm we also don't have a way for userspace to say that it
wants to signal limited range to the sink but wants the kernel
to not do the full->limited range conversion. Ie. no way for userspace
to pass in pixels that are already in limited range. There was a patch
for that posted quite long ago, but it didn't go in.

Thanks for the heads-up.

If userspace uses all available KMS color management properties
(CTM, LUTs, etc.)*and*  the video mode implies limited range on the
cable, at what point in the pixel pipeline does that conversion from
full to limited range occur?

It should be the last step.



There is a slight snag on some Intel platforms that the gamma LUT
is sitting after the CSC unit, and currently we use the CSC for
the range compression.


Thanks a lot for letting us to know about this!
AMD display pipe has always at the end CSC matrix where we apply appropriate 
range conversion if necessary.



On glk in particular I*think*  we currently just do the wrong
thing do the range compression before gamma. The same probably
applies to hsw+ when both gamma and degamma are used at the same
time. But that is clearly buggy, and we should fix it to either:
a) return an error, which isn't super awesome since then you
can't do gamma+limited range at the same time on glk, nor
gamma+degamma+limited range on hsw+.
b) for the glk case we could use the hw degamma LUT for the
gamma, which isn't great becasue the hw gamma and degamma
LUTs are quite different beasts, and so the hw degamma LUT
might not be able to do exactly what we need.


Do you mean that hw de-gamma LUT build on ROM ( it is not programmable, just 
select the proper bit)?


On hsw+ we do
use this trick already to get the gamma+limited range right,
but on these platforms the hw gamma and degamma LUTs have
identical capabilities.
c) do the range compression with the hw gamma LUT instead, which
of course means we have to combine the user gamma and range
compression into the same gamma LUT.


Nice w/a and in amdgpu we are using also curve concatenations into re gamma LUT.

The number of concatenations could be as many as need it and we may take 
advantage of this in user mode. Does this sounds preliminarily  good?

Wouldn't the following sentence be interesting for you if the user mode 
generates 1D LUT points using X axis exponential distribution to avoid
unnecessary interpolation in kernel?  It may be especially important if curve 
concatenation is expected?



So I think c) is what it should be. Would just need to find the time
to implement it, and figure out how to not totally mess up our
driver's hw state checker. Hmm, except this won't help at all
with YCbCr output since we need to apply gamma before the
RGB->YCbCr conversion (which uses the same CSC again). Argh.
So YCbCr output would still need option b).

Thankfully icl+ 

[PATCH 1/7] drm/ttm: move some move binds into the drivers

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

This just gives the driver control over some of the bind paths.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  7 ++-
 drivers/gpu/drm/nouveau/nouveau_bo.c| 10 +++---
 drivers/gpu/drm/radeon/radeon_ttm.c | 11 ---
 drivers/gpu/drm/ttm/ttm_bo_util.c   |  1 -
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 91b20aa2294d..4af4891264e1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -605,10 +605,15 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object 
*bo, bool evict,
}
 
/* move/bind old memory to GTT space */
-   r = ttm_bo_move_to_new_tt_mem(bo, ctx, _mem);
+   r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+   if (unlikely(r))
+   return r;
+
+   r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, _mem);
if (unlikely(r)) {
goto out_cleanup;
}
+
ttm_bo_assign_mem(bo, _mem);
/* copy to VRAM */
r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index fec7a901865e..7e604340b780 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -931,9 +931,13 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool 
evict,
if (ret)
return ret;
 
-   ret = ttm_bo_move_to_new_tt_mem(bo, ctx, _reg);
-   if (ret)
-   goto out;
+   ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+   if (unlikely(ret != 0))
+   return ret;
+
+   ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, _reg);
+   if (unlikely(ret != 0))
+   return ret;
 
ttm_bo_assign_mem(bo, _reg);
ret = nouveau_bo_move_m2mf(bo, true, ctx, new_reg);
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index ec713f0e55e5..24ef25665249 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -279,10 +279,15 @@ static int radeon_move_ram_vram(struct ttm_buffer_object 
*bo,
if (unlikely(r)) {
return r;
}
-   r = ttm_bo_move_to_new_tt_mem(bo, ctx, _mem);
-   if (unlikely(r)) {
+
+   r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+   if (unlikely(r))
goto out_cleanup;
-   }
+
+   r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, _mem);
+   if (unlikely(r))
+   goto out_cleanup;
+
ttm_bo_assign_mem(bo, _mem);
r = radeon_move_blit(bo, true, new_mem, old_mem);
if (unlikely(r)) {
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index e4bd381a8962..c8ca6694cc1c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -64,7 +64,6 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
 
return 0;
 }
-EXPORT_SYMBOL(ttm_bo_move_to_new_tt_mem);
 
 int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
  struct ttm_operation_ctx *ctx)
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/7] drm/ttm: add move to system into drivers

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

This moves the to system move into the drivers, and moves all
the unbinds in the move path under driver control

Note: radeon/nouveau already wait so don't duplicate it.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 12 +---
 drivers/gpu/drm/nouveau/nouveau_bo.c   | 10 ++
 drivers/gpu/drm/radeon/radeon_ttm.c| 12 +++-
 drivers/gpu/drm/ttm/ttm_bo_util.c  | 21 -
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c |  5 -
 include/drm/ttm/ttm_bo_driver.h|  2 --
 6 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 4af4891264e1..fcec99aea019 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -66,6 +66,8 @@
 static int amdgpu_ttm_backend_bind(struct ttm_bo_device *bdev,
   struct ttm_tt *ttm,
   struct ttm_resource *bo_mem);
+static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
+ struct ttm_tt *ttm);
 
 static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
unsigned int type,
@@ -561,11 +563,12 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object 
*bo, bool evict,
goto out_cleanup;
}
 
-   /* move BO (in tmp_mem) to new_mem */
-   r = ttm_bo_move_to_system(bo, ctx);
+   r = ttm_bo_wait_ctx(bo, ctx);
if (unlikely(r))
goto out_cleanup;
 
+   amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
+   ttm_resource_free(bo, >mem);
ttm_bo_assign_mem(bo, new_mem);
 out_cleanup:
ttm_resource_free(bo, _mem);
@@ -682,9 +685,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
 
if (old_mem->mem_type == TTM_PL_TT &&
new_mem->mem_type == TTM_PL_SYSTEM) {
-   r = ttm_bo_move_to_system(bo, ctx);
+   r = ttm_bo_wait_ctx(bo, ctx);
if (r)
return r;
+
+   amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
+   ttm_resource_free(bo, >mem);
ttm_bo_assign_mem(bo, new_mem);
return 0;
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7e604340b780..c58c8951f72f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -46,6 +46,7 @@
 
 static int nouveau_ttm_tt_bind(struct ttm_bo_device *bdev, struct ttm_tt *ttm,
   struct ttm_resource *reg);
+static void nouveau_ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt 
*ttm);
 
 /*
  * NV10-NV40 tiling helpers
@@ -897,10 +898,12 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool 
evict,
if (ret)
goto out;
 
-   ret = ttm_bo_move_to_system(bo, ctx);
+   ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
goto out;
 
+   nouveau_ttm_tt_unbind(bo->bdev, bo->ttm);
+   ttm_resource_free(bo, >mem);
ttm_bo_assign_mem(bo, _reg);
 out:
ttm_resource_free(bo, _reg);
@@ -1056,9 +1059,8 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
 
if (old_reg->mem_type == TTM_PL_TT &&
new_reg->mem_type == TTM_PL_SYSTEM) {
-   ret = ttm_bo_move_to_system(bo, ctx);
-   if (ret)
-   return ret;
+   nouveau_ttm_tt_unbind(bo->bdev, bo->ttm);
+   ttm_resource_free(bo, >mem);
ttm_bo_assign_mem(bo, new_reg);
goto out;
}
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index 24ef25665249..d3d39823b69f 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -59,6 +59,8 @@ static void radeon_ttm_debugfs_fini(struct radeon_device 
*rdev);
 static int radeon_ttm_tt_bind(struct ttm_bo_device *bdev,
  struct ttm_tt *ttm,
  struct ttm_resource *bo_mem);
+static void radeon_ttm_tt_unbind(struct ttm_bo_device *bdev,
+struct ttm_tt *ttm);
 
 struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
 {
@@ -244,10 +246,12 @@ static int radeon_move_vram_ram(struct ttm_buffer_object 
*bo,
if (unlikely(r)) {
goto out_cleanup;
}
-   r = ttm_bo_move_to_system(bo, ctx);
+   r = ttm_bo_wait_ctx(bo, ctx);
if (unlikely(r))
goto out_cleanup;
 
+   radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
+   ttm_resource_free(bo, >mem);
ttm_bo_assign_mem(bo, new_mem);
 out_cleanup:
ttm_resource_free(bo, _mem);
@@ -329,10 +333,8 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, 
bool evict,
 

[PATCH 6/7] drm/ttm: drop move notify around move.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

The drivers now do this in the move callback.

move_notify is still needed in the destroy path.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 13 +--
 drivers/gpu/drm/drm_gem_vram_helper.c  | 11 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c   | 12 --
 drivers/gpu/drm/qxl/qxl_ttm.c  | 45 +-
 drivers/gpu/drm/radeon/radeon_ttm.c| 11 +-
 drivers/gpu/drm/ttm/ttm_bo.c   | 12 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 14 ++-
 7 files changed, 78 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ac93a537f2e2..9aba34b57e60 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -666,6 +666,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
struct ttm_resource *old_mem = >mem;
int r;
 
+   amdgpu_bo_move_notify(bo, evict, new_mem);
+
/* Can't move a pinned BO */
abo = ttm_to_amdgpu_bo(bo);
if (WARN_ON_ONCE(abo->tbo.pin_count > 0))
@@ -687,7 +689,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
new_mem->mem_type == TTM_PL_SYSTEM) {
r = ttm_bo_wait_ctx(bo, ctx);
if (r)
-   return r;
+   goto fail;
 
amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
ttm_resource_free(bo, >mem);
@@ -728,12 +730,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
if (!amdgpu_mem_visible(adev, old_mem) ||
!amdgpu_mem_visible(adev, new_mem)) {
pr_err("Move buffer fallback to memcpy unavailable\n");
-   return r;
+   goto fail;
}
 
r = ttm_bo_move_memcpy(bo, ctx, new_mem);
if (r)
-   return r;
+   goto fail;
}
 
if (bo->type == ttm_bo_type_device &&
@@ -748,6 +750,11 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
/* update statistics */
atomic64_add((u64)bo->mem.num_pages << PAGE_SHIFT, 
>num_bytes_moved);
return 0;
+fail:
+   swap(*new_mem, bo->mem);
+   amdgpu_bo_move_notify(bo, false, new_mem);
+   swap(*new_mem, bo->mem);
+   return r;
 }
 
 /**
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index e99782bc13f1..b4b419732676 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -590,7 +590,16 @@ static int drm_gem_vram_bo_driver_move(struct 
drm_gem_vram_object *gbo,
   struct ttm_operation_ctx *ctx,
   struct ttm_resource *new_mem)
 {
-   return ttm_bo_move_memcpy(>bo, ctx, new_mem);
+   int ret;
+
+   drm_gem_vram_bo_driver_move_notify(gbo, evict, new_mem);
+   ret = ttm_bo_move_memcpy(>bo, ctx, new_mem);
+   if (ret) {
+   swap(*new_mem, gbo->bo.mem);
+   drm_gem_vram_bo_driver_move_notify(gbo, false, new_mem);
+   swap(*new_mem, gbo->bo.mem);
+   }
+   return ret;
 }
 
 /*
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7fb65b87f815..ad0493c5103b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1032,9 +1032,10 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
struct nouveau_drm_tile *new_tile = NULL;
int ret = 0;
 
+   nouveau_bo_move_ntfy(bo, evict, new_reg);
ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
-   return ret;
+   goto out_ntfy;
 
if (nvbo->bo.pin_count)
NV_WARN(drm, "Moving pinned object %p!\n", nvbo);
@@ -1042,7 +1043,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
ret = nouveau_bo_vm_bind(bo, new_reg, _tile);
if (ret)
-   return ret;
+   goto out_ntfy;
}
 
/* Fake bo copy. */
@@ -1090,7 +1091,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
else
nouveau_bo_vm_cleanup(bo, new_tile, >tile);
}
-
+out_ntfy:
+   if (ret) {
+   swap(*new_reg, bo->mem);
+   nouveau_bo_move_ntfy(bo, false, new_reg);
+   swap(*new_reg, bo->mem);
+   }
return ret;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 95c4f2c7ab79..a6149e3cc3d2 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -136,24 +136,6 @@ static struct ttm_tt 

[PATCH 7/7] drm/ttm: move last binding into the drivers.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

This moves the call to tt binding into the driver move,
and drops the driver callback.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  7 ++-
 drivers/gpu/drm/nouveau/nouveau_bo.c   |  7 ++-
 drivers/gpu/drm/qxl/qxl_ttm.c  | 14 --
 drivers/gpu/drm/radeon/radeon_ttm.c|  6 +-
 drivers/gpu/drm/ttm/ttm_bo.c   |  4 
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c |  7 ++-
 include/drm/ttm/ttm_bo_driver.h| 14 --
 7 files changed, 23 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 9aba34b57e60..d1d1bd656153 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -666,6 +666,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
struct ttm_resource *old_mem = >mem;
int r;
 
+   if (new_mem->mem_type == TTM_PL_TT) {
+   r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
+   if (r)
+   return r;
+   }
+
amdgpu_bo_move_notify(bo, evict, new_mem);
 
/* Can't move a pinned BO */
@@ -1728,7 +1734,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
.ttm_tt_create = _ttm_tt_create,
.ttm_tt_populate = _ttm_tt_populate,
.ttm_tt_unpopulate = _ttm_tt_unpopulate,
-   .ttm_tt_bind = _ttm_backend_bind,
.ttm_tt_destroy = _ttm_backend_destroy,
.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
.evict_flags = _evict_flags,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index ad0493c5103b..a69bd4098984 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1032,6 +1032,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
struct nouveau_drm_tile *new_tile = NULL;
int ret = 0;
 
+   if (new_reg->mem_type == TTM_PL_TT) {
+   ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, new_reg);
+   if (ret)
+   return ret;
+   }
+
nouveau_bo_move_ntfy(bo, evict, new_reg);
ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
@@ -1399,7 +1405,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
.ttm_tt_create = _ttm_tt_create,
.ttm_tt_populate = _ttm_tt_populate,
.ttm_tt_unpopulate = _ttm_tt_unpopulate,
-   .ttm_tt_bind = _ttm_tt_bind,
.ttm_tt_destroy = _ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = nouveau_bo_evict_flags,
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index a6149e3cc3d2..1cc3c14bc684 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -100,19 +100,6 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
 /*
  * TTM backend functions.
  */
-
-static int qxl_ttm_backend_bind(struct ttm_bo_device *bdev,
-   struct ttm_tt *ttm,
-   struct ttm_resource *bo_mem)
-{
-   if (!ttm->num_pages) {
-   WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n",
-ttm->num_pages, bo_mem, ttm);
-   }
-   /* Not implemented */
-   return -1;
-}
-
 static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
struct ttm_tt *ttm)
 {
@@ -181,7 +168,6 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool 
evict,
 
 static struct ttm_bo_driver qxl_bo_driver = {
.ttm_tt_create = _ttm_tt_create,
-   .ttm_tt_bind = _ttm_backend_bind,
.ttm_tt_destroy = _ttm_backend_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = _evict_flags,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index e427194b0b50..ac916fdd54d1 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -311,6 +311,11 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, 
bool evict,
struct ttm_resource *old_mem = >mem;
int r;
 
+   if (new_mem->mem_type == TTM_PL_TT) {
+   r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
+   if (r)
+   return r;
+   }
radeon_bo_move_notify(bo, evict, new_mem);
 
r = ttm_bo_wait_ctx(bo, ctx);
@@ -823,7 +828,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
.ttm_tt_create = _ttm_tt_create,
.ttm_tt_populate = _ttm_tt_populate,
.ttm_tt_unpopulate = _ttm_tt_unpopulate,
-   .ttm_tt_bind = _ttm_tt_bind,
.ttm_tt_destroy = _ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = _evict_flags,
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 

[PATCH 2/7] drm/ttm: minor cleanup to move to system

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

resource free already sets the domain to system, and old_mem
isn't really needed.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index c8ca6694cc1c..b730e624a220 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -68,10 +68,9 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
 int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
  struct ttm_operation_ctx *ctx)
 {
-   struct ttm_resource *old_mem = >mem;
int ret;
 
-   if (old_mem->mem_type == TTM_PL_SYSTEM)
+   if (bo->mem.mem_type == TTM_PL_SYSTEM)
return 0;
 
ret = ttm_bo_wait_ctx(bo, ctx);
@@ -83,7 +82,6 @@ int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
 
ttm_bo_tt_unbind(bo);
ttm_resource_free(bo, >mem);
-   old_mem->mem_type = TTM_PL_SYSTEM;
return 0;
 }
 EXPORT_SYMBOL(ttm_bo_move_to_system);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/7] drm/ttm: drop unbind callback.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

The drivers now control this, so drop unbinding.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  1 -
 drivers/gpu/drm/nouveau/nouveau_bo.c   |  1 -
 drivers/gpu/drm/qxl/qxl_ttm.c  |  7 ---
 drivers/gpu/drm/radeon/radeon_ttm.c|  1 -
 drivers/gpu/drm/ttm/ttm_bo.c   |  5 -
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c |  1 -
 include/drm/ttm/ttm_bo_driver.h| 18 --
 7 files changed, 34 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index fcec99aea019..ac93a537f2e2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1722,7 +1722,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
.ttm_tt_populate = _ttm_tt_populate,
.ttm_tt_unpopulate = _ttm_tt_unpopulate,
.ttm_tt_bind = _ttm_backend_bind,
-   .ttm_tt_unbind = _ttm_backend_unbind,
.ttm_tt_destroy = _ttm_backend_destroy,
.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
.evict_flags = _evict_flags,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index c58c8951f72f..7fb65b87f815 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1394,7 +1394,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
.ttm_tt_populate = _ttm_tt_populate,
.ttm_tt_unpopulate = _ttm_tt_unpopulate,
.ttm_tt_bind = _ttm_tt_bind,
-   .ttm_tt_unbind = _ttm_tt_unbind,
.ttm_tt_destroy = _ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = nouveau_bo_evict_flags,
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index e3ed20215f18..95c4f2c7ab79 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -113,12 +113,6 @@ static int qxl_ttm_backend_bind(struct ttm_bo_device *bdev,
return -1;
 }
 
-static void qxl_ttm_backend_unbind(struct ttm_bo_device *bdev,
-  struct ttm_tt *ttm)
-{
-   /* Not implemented */
-}
-
 static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
struct ttm_tt *ttm)
 {
@@ -180,7 +174,6 @@ static struct ttm_bo_driver qxl_bo_driver = {
.ttm_tt_create = _ttm_tt_create,
.ttm_tt_bind = _ttm_backend_bind,
.ttm_tt_destroy = _ttm_backend_destroy,
-   .ttm_tt_unbind = _ttm_backend_unbind,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = _evict_flags,
.move = _bo_move,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index d3d39823b69f..7fe4a98ece54 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -817,7 +817,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
.ttm_tt_populate = _ttm_tt_populate,
.ttm_tt_unpopulate = _ttm_tt_unpopulate,
.ttm_tt_bind = _ttm_tt_bind,
-   .ttm_tt_unbind = _ttm_tt_unbind,
.ttm_tt_destroy = _ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = _evict_flags,
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 7602d7734d38..358d09ef852a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1493,8 +1493,3 @@ int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct 
ttm_resource *mem)
 {
return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
 }
-
-void ttm_bo_tt_unbind(struct ttm_buffer_object *bo)
-{
-   bo->bdev->driver->ttm_tt_unbind(bo->bdev, bo->ttm);
-}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 1d220a9794e6..6e07ea982961 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -760,7 +760,6 @@ struct ttm_bo_driver vmw_bo_driver = {
.ttm_tt_populate = _ttm_populate,
.ttm_tt_unpopulate = _ttm_unpopulate,
.ttm_tt_bind = _ttm_bind,
-   .ttm_tt_unbind = _ttm_unbind,
.ttm_tt_destroy = _ttm_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = vmw_evict_flags,
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 81a1618b9535..fbbcf10670c1 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -104,17 +104,6 @@ struct ttm_bo_driver {
 */
int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, 
struct ttm_resource *bo_mem);
 
-   /**
-* ttm_tt_unbind
-*
-* @bdev: Pointer to a ttm device
-* @ttm: Pointer to a struct ttm_tt.
-*
-* Unbind previously bound backend pages. This function should be
-* able to handle differences between aperture and system page sizes.

[PATCH 5/7] drm/ttm: remove move to new and inline into remainging place.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

This show the remaining bind callback, which my next series of
patches will aim to remove.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/ttm/ttm_bo.c  | 16 +---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 20 
 include/drm/ttm/ttm_bo_driver.h   |  4 
 3 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 358d09ef852a..705ea3ef91f9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -252,9 +252,15 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object 
*bo,
if (ret)
goto out_err;
 
-   ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem);
-   if (ret)
-   goto out_err;
+   if (mem->mem_type != TTM_PL_SYSTEM) {
+   ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+   if (ret)
+   goto out_err;
+
+   ret = bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
+   if (ret)
+   goto out_err;
+   }
}
 
if (bdev->driver->move_notify)
@@ -1489,7 +1495,3 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)
bo->ttm = NULL;
 }
 
-int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
-{
-   return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
-}
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 21811bbda2e4..fae31f7f5c35 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -45,26 +45,6 @@ struct ttm_transfer_obj {
struct ttm_buffer_object *bo;
 };
 
-int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx,
- struct ttm_resource *new_mem)
-{
-   int ret;
-
-   if (new_mem->mem_type == TTM_PL_SYSTEM)
-   return 0;
-
-   ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
-   if (unlikely(ret != 0))
-   return ret;
-
-   ret = ttm_bo_tt_bind(bo, new_mem);
-   if (unlikely(ret != 0))
-   return ret;
-
-   return 0;
-}
-
 int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
   struct ttm_resource *mem)
 {
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index fbbcf10670c1..0c4efc169f46 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -560,10 +560,6 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
 void ttm_mem_io_free(struct ttm_bo_device *bdev,
 struct ttm_resource *mem);
 
-int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx,
- struct ttm_resource *new_mem);
-
 /**
  * ttm_bo_move_memcpy
  *
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/7] drm/ttm: get rid of bind/unbind

2020-10-19 Thread Dave Airlie
This series is a rebase/cleanup of previous patches.

The goal is to drop the bind/unbind callbacks from the ttm and
have the driver handle it all in it's move function.

This also has the driver do it's own move notifys from within
move as well (move notify is still used for cleanup_memtype_use0.

I've booted this on nouveau and vmwgfx.

Dave.


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/5] ttm fix range checks + drop some fields

2020-10-19 Thread Dave Airlie
This fixes some range checks first.

Then drops bo->num_pages in favour of bo->mem.num_pages,
and drops bo->mem.size in favour of bo->mem.num_pages.

Dave.

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/5] drm/ttm: fix eviction valuable range check.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

This was adding size to start, but pfn and start are in pages,
so it should be using num_pages.

Not sure this fixes anything in the real world, just noticed it
during refactoring.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cbc74a320db2..3101650c01b4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -620,7 +620,7 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
/* Don't evict this BO if it's outside of the
 * requested placement range
 */
-   if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
+   if (place->fpfn >= (bo->mem.start + bo->mem.num_pages) ||
(place->lpfn && place->lpfn <= bo->mem.start))
return false;
 
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/5] drm/ttm: add bo size in bytes wrapper.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

We store size and num pages, wrap size so it can be removed.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 8 
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.c   | 2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c | 8 
 drivers/gpu/drm/nouveau/nouveau_display.c| 6 +++---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
 include/drm/ttm/ttm_bo_api.h | 5 +
 6 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 64d4b5ff95d6..60e8fdbcfd89 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -454,7 +454,7 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct 
kgd_mem *mem,
struct amdgpu_bo *bo = mem->bo;
uint64_t va = mem->va;
struct list_head *list_bo_va = >bo_va_list;
-   unsigned long bo_size = bo->tbo.mem.size;
+   unsigned long bo_size = ttm_bo_size_bytes(>tbo);
 
if (!va) {
pr_err("Invalid VA when adding BO to VM\n");
@@ -1282,7 +1282,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, uint64_t *size)
 {
struct amdkfd_process_info *process_info = mem->process_info;
-   unsigned long bo_size = mem->bo->tbo.mem.size;
+   unsigned long bo_size = ttm_bo_size_bytes(>bo->tbo);
struct kfd_bo_va_list *entry, *tmp;
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
@@ -1403,7 +1403,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
mutex_lock(>lock);
 
domain = mem->domain;
-   bo_size = bo->tbo.mem.size;
+   bo_size = ttm_bo_size_bytes(>tbo);
 
pr_debug("Map VA 0x%llx - 0x%llx to vm %p domain %s\n",
mem->va,
@@ -1507,7 +1507,7 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
struct amdgpu_device *adev = get_amdgpu_device(kgd);
struct amdkfd_process_info *process_info =
((struct amdgpu_vm *)vm)->process_info;
-   unsigned long bo_size = mem->bo->tbo.mem.size;
+   unsigned long bo_size = ttm_bo_size_bytes(>bo->tbo);
struct kfd_bo_va_list *entry;
struct bo_vm_reservation_context ctx;
int ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c 
b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
index 4b746584a797..f3b3276a27e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
@@ -554,7 +554,7 @@ static int mes_v10_1_allocate_eop_buf(struct amdgpu_device 
*adev)
return r;
}
 
-   memset(eop, 0, adev->mes.eop_gpu_obj->tbo.mem.size);
+   memset(eop, 0, ttm_bo_size_bytes(>mes.eop_gpu_obj->tbo));
 
amdgpu_bo_kunmap(adev->mes.eop_gpu_obj);
amdgpu_bo_unreserve(adev->mes.eop_gpu_obj);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index ec79c3b251e8..3c24873ae8e9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -473,10 +473,10 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, 
bool contig)
 
switch (bo->mem.mem_type) {
case TTM_PL_VRAM:
-   drm->gem.vram_available -= bo->mem.size;
+   drm->gem.vram_available -= ttm_bo_size_bytes(bo);
break;
case TTM_PL_TT:
-   drm->gem.gart_available -= bo->mem.size;
+   drm->gem.gart_available -= ttm_bo_size_bytes(bo);
break;
default:
break;
@@ -504,10 +504,10 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
if (!nvbo->bo.pin_count) {
switch (bo->mem.mem_type) {
case TTM_PL_VRAM:
-   drm->gem.vram_available += bo->mem.size;
+   drm->gem.vram_available += ttm_bo_size_bytes(bo);
break;
case TTM_PL_TT:
-   drm->gem.gart_available += bo->mem.size;
+   drm->gem.gart_available += ttm_bo_size_bytes(bo);
break;
default:
break;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index bceb48a2dfca..af28e3d16abd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -288,9 +288,9 @@ nouveau_check_bl_size(struct nouveau_drm *drm, struct 
nouveau_bo *nvbo,
 
DRM_DEBUG_KMS("offset=%u stride=%u h=%u tile_mode=0x%02x bw=%u bh=%u 
gob_size=%u bl_size=%llu size=%lu\n",
  offset, stride, h, tile_mode, bw, bh, gob_size, bl_size,
- nvbo->bo.mem.size);
+ ttm_bo_size_bytes(>bo));
 
-   if (bl_size + offset > 

[PATCH 3/5] drm/ttm: drop bo->num_pages.

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

This is stored in the mem field, everywhere that a new mem is
created, the bo->mem is either copied or this field is copied
explicitly.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c   | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h| 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 6 +++---
 drivers/gpu/drm/drm_gem_vram_helper.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_prime.c   | 4 ++--
 drivers/gpu/drm/qxl/qxl_object.c  | 2 +-
 drivers/gpu/drm/qxl/qxl_object.h  | 2 +-
 drivers/gpu/drm/radeon/radeon_cs.c| 2 +-
 drivers/gpu/drm/radeon/radeon_object.c| 6 +++---
 drivers/gpu/drm/radeon/radeon_object.h| 4 ++--
 drivers/gpu/drm/radeon/radeon_prime.c | 4 ++--
 drivers/gpu/drm/radeon/radeon_trace.h | 2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c   | 2 +-
 drivers/gpu/drm/ttm/ttm_bo.c  | 7 +++
 drivers/gpu/drm/ttm/ttm_bo_util.c | 4 ++--
 drivers/gpu/drm/ttm/ttm_bo_vm.c   | 6 +++---
 drivers/gpu/drm/ttm/ttm_tt.c  | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_blit.c  | 4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_bo.c| 6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c   | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c   | 4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 5 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c   | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c| 8 
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c  | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_shader.c| 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c  | 4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c   | 6 +++---
 include/drm/ttm/ttm_bo_api.h  | 1 -
 32 files changed, 56 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index 5b465ab774d1..ca52c0ac051e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -55,7 +55,7 @@ void *amdgpu_gem_prime_vmap(struct drm_gem_object *obj)
struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
int ret;
 
-   ret = ttm_bo_kmap(>tbo, 0, bo->tbo.num_pages,
+   ret = ttm_bo_kmap(>tbo, 0, bo->tbo.mem.num_pages,
  >dma_buf_vmap);
if (ret)
return ERR_PTR(ret);
@@ -305,7 +305,7 @@ static struct sg_table *amdgpu_dma_buf_map(struct 
dma_buf_attachment *attach,
case TTM_PL_TT:
sgt = drm_prime_pages_to_sg(obj->dev,
bo->tbo.ttm->pages,
-   bo->tbo.num_pages);
+   bo->tbo.mem.num_pages);
if (IS_ERR(sgt))
return sgt;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 3c5ad69eff19..3ab10e40a026 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -124,7 +124,7 @@ uint64_t amdgpu_gmc_agp_addr(struct ttm_buffer_object *bo)
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
struct ttm_dma_tt *ttm;
 
-   if (bo->num_pages != 1 || bo->ttm->caching == ttm_cached)
+   if (bo->mem.num_pages != 1 || bo->ttm->caching == ttm_cached)
return AMDGPU_BO_INVALID_OFFSET;
 
ttm = container_of(bo->ttm, struct ttm_dma_tt, ttm);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 1aa516429c80..08dbc92cdb64 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -786,7 +786,7 @@ int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)
if (r < 0)
return r;
 
-   r = ttm_bo_kmap(>tbo, 0, bo->tbo.num_pages, >kmap);
+   r = ttm_bo_kmap(>tbo, 0, bo->tbo.mem.num_pages, >kmap);
if (r)
return r;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 132e5f955180..edf2f5b55e9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -175,12 +175,12 @@ static inline void amdgpu_bo_unreserve(struct amdgpu_bo 
*bo)
 
 static inline unsigned long amdgpu_bo_size(struct amdgpu_bo *bo)
 {
-   return bo->tbo.num_pages << PAGE_SHIFT;
+   return bo->tbo.mem.num_pages << PAGE_SHIFT;
 }
 
 static inline unsigned amdgpu_bo_ngpu_pages(struct amdgpu_bo *bo)
 {
-   return (bo->tbo.num_pages << PAGE_SHIFT) / AMDGPU_GPU_PAGE_SIZE;
+   return (bo->tbo.mem.num_pages << PAGE_SHIFT) / AMDGPU_GPU_PAGE_SIZE;
 }
 
 static inline unsigned 

[PATCH 2/5] drm/ttm: fix memcpy move bo size comparison

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

start is in page units, so compare with pages.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 558e78ad82aa..b31be57884ba 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -268,7 +268,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
dir = 1;
 
if ((old_mem->mem_type == new_mem->mem_type) &&
-   (new_mem->start < old_mem->start + old_mem->size)) {
+   (new_mem->start < old_mem->start + old_mem->num_pages)) {
dir = -1;
add = new_mem->num_pages - 1;
}
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/5] drm/ttm: get rid of storing size in ttm_resource

2020-10-19 Thread Dave Airlie
From: Dave Airlie 

Just use num_pages and a shift directly.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +-
 drivers/gpu/drm/nouveau/nv17_fence.c | 2 +-
 drivers/gpu/drm/nouveau/nv50_fence.c | 2 +-
 drivers/gpu/drm/ttm/ttm_bo.c | 2 --
 include/drm/ttm/ttm_bo_api.h | 2 +-
 include/drm/ttm/ttm_resource.h   | 2 --
 6 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 3c24873ae8e9..fec7a901865e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -994,7 +994,7 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct 
ttm_resource *new_reg,
return 0;
 
if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
-   *new_tile = nv10_bo_set_tiling(dev, offset, new_reg->size,
+   *new_tile = nv10_bo_set_tiling(dev, offset, new_reg->num_pages 
<< PAGE_SHIFT,
   nvbo->mode, nvbo->zeta);
}
 
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c 
b/drivers/gpu/drm/nouveau/nv17_fence.c
index 1253fdec712d..a6da8765f262 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -80,7 +80,7 @@ nv17_fence_context_new(struct nouveau_channel *chan)
struct nv10_fence_chan *fctx;
struct ttm_resource *reg = >bo->bo.mem;
u32 start = reg->start * PAGE_SIZE;
-   u32 limit = start + reg->size - 1;
+   u32 limit = start + (reg->num_pages << PAGE_SHIFT) - 1;
int ret = 0;
 
fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c 
b/drivers/gpu/drm/nouveau/nv50_fence.c
index 447238e3cbe7..65d9a20f4e55 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -39,7 +39,7 @@ nv50_fence_context_new(struct nouveau_channel *chan)
struct nv10_fence_chan *fctx;
struct ttm_resource *reg = >bo->bo.mem;
u32 start = reg->start * PAGE_SIZE;
-   u32 limit = start + reg->size - 1;
+   u32 limit = start + (reg->num_pages << PAGE_SHIFT) - 1;
int ret;
 
fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index a9f184cdbe24..7602d7734d38 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -956,7 +956,6 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
dma_resv_assert_held(bo->base.resv);
 
mem.num_pages = bo->mem.num_pages;
-   mem.size = mem.num_pages << PAGE_SHIFT;
mem.page_alignment = bo->mem.page_alignment;
mem.bus.offset = 0;
mem.bus.addr = NULL;
@@ -1102,7 +1101,6 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
INIT_LIST_HEAD(>swap);
bo->bdev = bdev;
bo->type = type;
-   bo->mem.size = num_pages << PAGE_SHIFT;
bo->mem.mem_type = TTM_PL_SYSTEM;
bo->mem.num_pages = num_pages;
bo->mem.mm_node = NULL;
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index f201ec42b90b..f98d14957869 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -614,7 +614,7 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned 
long addr,
 
 static inline unsigned long ttm_bo_size_bytes(struct ttm_buffer_object *bo)
 {
-   return bo->mem.size;
+   return bo->mem.num_pages << PAGE_SHIFT;
 }
 
 #endif
diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h
index f48a70d39ac5..fc9d9d7f9f15 100644
--- a/include/drm/ttm/ttm_resource.h
+++ b/include/drm/ttm/ttm_resource.h
@@ -159,7 +159,6 @@ struct ttm_bus_placement {
  * struct ttm_resource
  *
  * @mm_node: Memory manager node.
- * @size: Requested size of memory region.
  * @num_pages: Actual size of memory region in pages.
  * @page_alignment: Page alignment.
  * @placement: Placement flags.
@@ -171,7 +170,6 @@ struct ttm_bus_placement {
 struct ttm_resource {
void *mm_node;
unsigned long start;
-   unsigned long size;
unsigned long num_pages;
uint32_t page_alignment;
uint32_t mem_type;
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


ttm_bo_eviction_valuable wrong units?

2020-10-19 Thread Dave Airlie
if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
(place->lpfn && place->lpfn <= bo->mem.start))
return false;

Should the bo->mem.size there be bo->mem.num_pages?

I was just writing patches to get rid of size and noticed this.

Dave.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm/msm/atomic: Convert to per-CRTC kthread_work

2020-10-19 Thread Rob Clark
From: Rob Clark 

Use a SCHED_FIFO kthread_worker for async atomic commits.  We have a
hard deadline if we don't want to miss a frame.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_atomic.c | 25 -
 drivers/gpu/drm/msm/msm_drv.h|  3 ++-
 drivers/gpu/drm/msm/msm_kms.h| 17 +
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index 561bfa48841c..484438f1e028 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -103,14 +103,13 @@ static enum hrtimer_restart 
msm_atomic_pending_timer(struct hrtimer *t)
 {
struct msm_pending_timer *timer = container_of(t,
struct msm_pending_timer, timer);
-   struct msm_drm_private *priv = timer->kms->dev->dev_private;
 
-   queue_work(priv->wq, >work);
+   kthread_queue_work(timer->worker, >work);
 
return HRTIMER_NORESTART;
 }
 
-static void msm_atomic_pending_work(struct work_struct *work)
+static void msm_atomic_pending_work(struct kthread_work *work)
 {
struct msm_pending_timer *timer = container_of(work,
struct msm_pending_timer, work);
@@ -118,14 +117,30 @@ static void msm_atomic_pending_work(struct work_struct 
*work)
msm_atomic_async_commit(timer->kms, timer->crtc_idx);
 }
 
-void msm_atomic_init_pending_timer(struct msm_pending_timer *timer,
+int msm_atomic_init_pending_timer(struct msm_pending_timer *timer,
struct msm_kms *kms, int crtc_idx)
 {
timer->kms = kms;
timer->crtc_idx = crtc_idx;
hrtimer_init(>timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
timer->timer.function = msm_atomic_pending_timer;
-   INIT_WORK(>work, msm_atomic_pending_work);
+
+   timer->worker = kthread_create_worker(0, "atomic-worker-%d", crtc_idx);
+   if (IS_ERR(timer->worker)) {
+   int ret = PTR_ERR(timer->worker);
+   timer->worker = NULL;
+   return ret;
+   }
+   sched_set_fifo(timer->worker->task);
+   kthread_init_work(>work, msm_atomic_pending_work);
+
+   return 0;
+}
+
+void msm_atomic_destroy_pending_timer(struct msm_pending_timer *timer)
+{
+   if (timer->worker)
+   kthread_destroy_worker(timer->worker);
 }
 
 static bool can_do_async(struct drm_atomic_state *state,
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 5308e636a90c..f869ed67b5da 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -235,8 +235,9 @@ struct msm_pending_timer;
 
 int msm_atomic_prepare_fb(struct drm_plane *plane,
  struct drm_plane_state *new_state);
-void msm_atomic_init_pending_timer(struct msm_pending_timer *timer,
+int msm_atomic_init_pending_timer(struct msm_pending_timer *timer,
struct msm_kms *kms, int crtc_idx);
+void msm_atomic_destroy_pending_timer(struct msm_pending_timer *timer);
 void msm_atomic_commit_tail(struct drm_atomic_state *state);
 struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev);
 void msm_atomic_state_clear(struct drm_atomic_state *state);
diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h
index 0be9e6487556..26321c13f950 100644
--- a/drivers/gpu/drm/msm/msm_kms.h
+++ b/drivers/gpu/drm/msm/msm_kms.h
@@ -136,7 +136,8 @@ struct msm_kms;
  */
 struct msm_pending_timer {
struct hrtimer timer;
-   struct work_struct work;
+   struct kthread_work work;
+   struct kthread_worker *worker;
struct msm_kms *kms;
unsigned crtc_idx;
 };
@@ -163,19 +164,27 @@ struct msm_kms {
 static inline int msm_kms_init(struct msm_kms *kms,
const struct msm_kms_funcs *funcs)
 {
-   unsigned i;
+   unsigned i, ret;
 
mutex_init(>commit_lock);
kms->funcs = funcs;
 
-   for (i = 0; i < ARRAY_SIZE(kms->pending_timers); i++)
-   msm_atomic_init_pending_timer(>pending_timers[i], kms, i);
+   for (i = 0; i < ARRAY_SIZE(kms->pending_timers); i++) {
+   ret = msm_atomic_init_pending_timer(>pending_timers[i], 
kms, i);
+   if (ret) {
+   return ret;
+   }
+   }
 
return 0;
 }
 
 static inline void msm_kms_destroy(struct msm_kms *kms)
 {
+   unsigned i;
+
+   for (i = 0; i < ARRAY_SIZE(kms->pending_timers); i++)
+   msm_atomic_destroy_pending_timer(>pending_timers[i]);
 }
 
 struct msm_kms *mdp4_kms_init(struct drm_device *dev);
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/3] drm/msm/kms: Update msm_kms_init/destroy

2020-10-19 Thread Rob Clark
From: Rob Clark 

Add msm_kms_destroy() and add err return from msm_kms_init().  Prep work
for next patch.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  |  8 +++-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c |  8 +++-
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 11 ---
 drivers/gpu/drm/msm/disp/mdp_kms.h   |  9 +++--
 drivers/gpu/drm/msm/msm_kms.h|  8 +++-
 5 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index d93c44f6996d..b77d1a9ace2b 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -718,6 +718,8 @@ static void dpu_kms_destroy(struct msm_kms *kms)
dpu_kms = to_dpu_kms(kms);
 
_dpu_kms_hw_destroy(dpu_kms);
+
+   msm_kms_destroy(_kms->base);
 }
 
 static void _dpu_kms_set_encoder_mode(struct msm_kms *kms,
@@ -1108,7 +1110,11 @@ static int dpu_bind(struct device *dev, struct device 
*master, void *data)
 
platform_set_drvdata(pdev, dpu_kms);
 
-   msm_kms_init(_kms->base, _funcs);
+   ret = msm_kms_init(_kms->base, _funcs);
+   if (ret) {
+   DPU_ERROR("failed to init kms, ret=%d\n", ret);
+   goto err;
+   }
dpu_kms->dev = ddev;
dpu_kms->pdev = pdev;
 
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
index dbf8d429223e..3d729270bde1 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
@@ -175,6 +175,8 @@ static void mdp4_destroy(struct msm_kms *kms)
if (mdp4_kms->rpm_enabled)
pm_runtime_disable(dev);
 
+   mdp_kms_destroy(_kms->base);
+
kfree(mdp4_kms);
 }
 
@@ -427,7 +429,11 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
goto fail;
}
 
-   mdp_kms_init(_kms->base, _funcs);
+   ret = mdp_kms_init(_kms->base, _funcs);
+   if (ret) {
+   DRM_DEV_ERROR(dev->dev, "failed to init kms\n");
+   goto fail;
+   }
 
kms = _kms->base.base;
 
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index e193865ce9a2..b3eecf869477 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -232,6 +232,8 @@ static void mdp5_kms_destroy(struct msm_kms *kms)
aspace->mmu->funcs->detach(aspace->mmu);
msm_gem_address_space_put(aspace);
}
+
+   mdp_kms_destroy(_kms->base);
 }
 
 #ifdef CONFIG_DEBUG_FS
@@ -592,11 +594,14 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
return NULL;
 
mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
-
-   mdp_kms_init(_kms->base, _funcs);
-
pdev = mdp5_kms->pdev;
 
+   ret = mdp_kms_init(_kms->base, _funcs);
+   if (ret) {
+   DRM_DEV_ERROR(>dev, "failed to init kms\n");
+   goto fail;
+   }
+
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
if (irq < 0) {
ret = irq;
diff --git a/drivers/gpu/drm/msm/disp/mdp_kms.h 
b/drivers/gpu/drm/msm/disp/mdp_kms.h
index 1535c5618491..b0286d5d5130 100644
--- a/drivers/gpu/drm/msm/disp/mdp_kms.h
+++ b/drivers/gpu/drm/msm/disp/mdp_kms.h
@@ -36,12 +36,17 @@ struct mdp_kms {
 };
 #define to_mdp_kms(x) container_of(x, struct mdp_kms, base)
 
-static inline void mdp_kms_init(struct mdp_kms *mdp_kms,
+static inline int mdp_kms_init(struct mdp_kms *mdp_kms,
const struct mdp_kms_funcs *funcs)
 {
mdp_kms->funcs = funcs;
INIT_LIST_HEAD(_kms->irq_list);
-   msm_kms_init(_kms->base, >base);
+   return msm_kms_init(_kms->base, >base);
+}
+
+static inline void mdp_kms_destroy(struct mdp_kms *mdp_kms)
+{
+   msm_kms_destroy(_kms->base);
 }
 
 /*
diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h
index 1cbef6b200b7..0be9e6487556 100644
--- a/drivers/gpu/drm/msm/msm_kms.h
+++ b/drivers/gpu/drm/msm/msm_kms.h
@@ -160,7 +160,7 @@ struct msm_kms {
struct msm_pending_timer pending_timers[MAX_CRTCS];
 };
 
-static inline void msm_kms_init(struct msm_kms *kms,
+static inline int msm_kms_init(struct msm_kms *kms,
const struct msm_kms_funcs *funcs)
 {
unsigned i;
@@ -170,6 +170,12 @@ static inline void msm_kms_init(struct msm_kms *kms,
 
for (i = 0; i < ARRAY_SIZE(kms->pending_timers); i++)
msm_atomic_init_pending_timer(>pending_timers[i], kms, i);
+
+   return 0;
+}
+
+static inline void msm_kms_destroy(struct msm_kms *kms)
+{
 }
 
 struct msm_kms *mdp4_kms_init(struct drm_device *dev);
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] drm/msm/gpu: Convert retire/recover work to kthread_worker

2020-10-19 Thread Rob Clark
From: Rob Clark 

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c |  3 +--
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c |  6 ++---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c |  4 +--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c |  4 +--
 drivers/gpu/drm/msm/msm_gpu.c | 30 +++
 drivers/gpu/drm/msm/msm_gpu.h | 13 +++---
 6 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index 2befaf304f04..b0005ccd81c6 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -1056,7 +1056,6 @@ static void a5xx_gpmu_err_irq(struct msm_gpu *gpu)
 static void a5xx_fault_detect_irq(struct msm_gpu *gpu)
 {
struct drm_device *dev = gpu->dev;
-   struct msm_drm_private *priv = dev->dev_private;
struct msm_ringbuffer *ring = gpu->funcs->active_ring(gpu);
 
DRM_DEV_ERROR(dev->dev, "gpu fault ring %d fence %x status %8.8X rb 
%4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n",
@@ -1072,7 +1071,7 @@ static void a5xx_fault_detect_irq(struct msm_gpu *gpu)
/* Turn off the hangcheck timer to keep it from bothering us */
del_timer(>hangcheck_timer);
 
-   queue_work(priv->wq, >recover_work);
+   kthread_queue_work(gpu->worker, >recover_work);
 }
 
 #define RBBM_ERROR_MASK \
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c 
b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
index 183de1139eeb..42eaef7ad7c7 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
@@ -78,13 +78,12 @@ static void a5xx_preempt_timer(struct timer_list *t)
struct a5xx_gpu *a5xx_gpu = from_timer(a5xx_gpu, t, preempt_timer);
struct msm_gpu *gpu = _gpu->base.base;
struct drm_device *dev = gpu->dev;
-   struct msm_drm_private *priv = dev->dev_private;
 
if (!try_preempt_state(a5xx_gpu, PREEMPT_TRIGGERED, PREEMPT_FAULTED))
return;
 
DRM_DEV_ERROR(dev->dev, "%s: preemption timed out\n", gpu->name);
-   queue_work(priv->wq, >recover_work);
+   kthread_queue_work(gpu->worker, >recover_work);
 }
 
 /* Try to trigger a preemption switch */
@@ -162,7 +161,6 @@ void a5xx_preempt_irq(struct msm_gpu *gpu)
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
struct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);
struct drm_device *dev = gpu->dev;
-   struct msm_drm_private *priv = dev->dev_private;
 
if (!try_preempt_state(a5xx_gpu, PREEMPT_TRIGGERED, PREEMPT_PENDING))
return;
@@ -181,7 +179,7 @@ void a5xx_preempt_irq(struct msm_gpu *gpu)
set_preempt_state(a5xx_gpu, PREEMPT_FAULTED);
DRM_DEV_ERROR(dev->dev, "%s: Preemption failed to complete\n",
gpu->name);
-   queue_work(priv->wq, >recover_work);
+   kthread_queue_work(gpu->worker, >recover_work);
return;
}
 
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 491fee410daf..e6703ae98760 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -19,8 +19,6 @@ static void a6xx_gmu_fault(struct a6xx_gmu *gmu)
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
struct adreno_gpu *adreno_gpu = _gpu->base;
struct msm_gpu *gpu = _gpu->base;
-   struct drm_device *dev = gpu->dev;
-   struct msm_drm_private *priv = dev->dev_private;
 
/* FIXME: add a banner here */
gmu->hung = true;
@@ -29,7 +27,7 @@ static void a6xx_gmu_fault(struct a6xx_gmu *gmu)
del_timer(>hangcheck_timer);
 
/* Queue the GPU handler because we need to treat this as a recovery */
-   queue_work(priv->wq, >recover_work);
+   kthread_queue_work(gpu->worker, >recover_work);
 }
 
 static irqreturn_t a6xx_gmu_irq(int irq, void *data)
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 5dddb9163bd3..2f236aadfa9c 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -965,8 +965,6 @@ static void a6xx_fault_detect_irq(struct msm_gpu *gpu)
 {
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
-   struct drm_device *dev = gpu->dev;
-   struct msm_drm_private *priv = dev->dev_private;
struct msm_ringbuffer *ring = gpu->funcs->active_ring(gpu);
 
/*
@@ -989,7 +987,7 @@ static void a6xx_fault_detect_irq(struct msm_gpu *gpu)
/* Turn off the hangcheck timer to keep it from bothering us */
del_timer(>hangcheck_timer);
 
-   queue_work(priv->wq, >recover_work);
+   kthread_queue_work(gpu->worker, >recover_work);
 }
 
 static irqreturn_t a6xx_irq(struct msm_gpu *gpu)
diff --git 

[PATCH 0/3] drm/msm: kthread_worker conversion

2020-10-19 Thread Rob Clark
From: Rob Clark 

In particular, converting the async atomic commit (for cursor updates,
etc) to SCHED_FIFO kthread_worker helps with some cases where we
wouldn't manage to flush the updates within the 1ms-before-vblank
deadline resulting in fps drops when there is cursor movement.

Rob Clark (3):
  drm/msm/gpu: Convert retire/recover work to kthread_worker
  drm/msm/kms: Update msm_kms_init/destroy
  drm/msm/atomic: Convert to per-CRTC kthread_work

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c |  3 +--
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c |  6 ++---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c |  4 +--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c |  4 +--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |  8 +-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c  |  8 +-
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  | 11 ++---
 drivers/gpu/drm/msm/disp/mdp_kms.h|  9 +--
 drivers/gpu/drm/msm/msm_atomic.c  | 25 +++
 drivers/gpu/drm/msm/msm_drv.h |  3 ++-
 drivers/gpu/drm/msm/msm_gpu.c | 30 +++
 drivers/gpu/drm/msm/msm_gpu.h | 13 +++---
 drivers/gpu/drm/msm/msm_kms.h | 23 ++---
 13 files changed, 104 insertions(+), 43 deletions(-)

-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 17/23] drm/msm: Remove obj->gpu

2020-10-19 Thread Rob Clark
From: Rob Clark 

It cannot be atomically updated with obj->active_count, and the only
purpose is a useless WARN_ON() (which becomes a buggy WARN_ON() once
retire_submits() is not serialized with incoming submits via
struct_mutex)

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c | 2 --
 drivers/gpu/drm/msm/msm_gem.h | 1 -
 drivers/gpu/drm/msm/msm_gpu.c | 5 -
 3 files changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 092ed152999e..e4876498be47 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -775,7 +775,6 @@ void msm_gem_active_get(struct drm_gem_object *obj, struct 
msm_gpu *gpu)
 
if (!atomic_fetch_inc(_obj->active_count)) {
mutex_lock(>mm_lock);
-   msm_obj->gpu = gpu;
list_del_init(_obj->mm_list);
list_add_tail(_obj->mm_list, >active_list);
mutex_unlock(>mm_lock);
@@ -791,7 +790,6 @@ void msm_gem_active_put(struct drm_gem_object *obj)
 
if (!atomic_dec_return(_obj->active_count)) {
mutex_lock(>mm_lock);
-   msm_obj->gpu = NULL;
list_del_init(_obj->mm_list);
list_add_tail(_obj->mm_list, >inactive_list);
mutex_unlock(>mm_lock);
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index 2f289c436ddd..f4e73c6f07bf 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -64,7 +64,6 @@ struct msm_gem_object {
 *
 */
struct list_head mm_list;
-   struct msm_gpu *gpu; /* non-null if active */
 
/* Transiently in the process of submit ioctl, objects associated
 * with the submit are on submit->bo_list.. this only lasts for
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index bcd9b4fa98b2..d0f625112a97 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -810,11 +810,6 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct 
msm_gem_submit *submit)
struct drm_gem_object *drm_obj = _obj->base;
uint64_t iova;
 
-   /* can't happen yet.. but when we add 2d support we'll have
-* to deal w/ cross-ring synchronization:
-*/
-   WARN_ON(is_active(msm_obj) && (msm_obj->gpu != gpu));
-
/* submit takes a reference to the bo and iova until retired: */
drm_gem_object_get(_obj->base);
msm_gem_get_and_pin_iova_locked(_obj->base, submit->aspace, 
);
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 22/23] drm/msm: Drop struct_mutex in shrinker path

2020-10-19 Thread Rob Clark
From: Rob Clark 

Now that the inactive_list is protected by mm_lock, and everything
else on per-obj basis is protected by obj->lock, we no longer depend
on struct_mutex.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c  |  1 -
 drivers/gpu/drm/msm/msm_gem_shrinker.c | 54 --
 2 files changed, 55 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index c39ba9030001..cf17c79d99ae 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -688,7 +688,6 @@ void msm_gem_purge(struct drm_gem_object *obj)
struct drm_device *dev = obj->dev;
struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
-   WARN_ON(!mutex_is_locked(>struct_mutex));
WARN_ON(!is_purgeable(msm_obj));
WARN_ON(obj->import_attach);
 
diff --git a/drivers/gpu/drm/msm/msm_gem_shrinker.c 
b/drivers/gpu/drm/msm/msm_gem_shrinker.c
index 6be073b8ca08..6f4b1355725f 100644
--- a/drivers/gpu/drm/msm/msm_gem_shrinker.c
+++ b/drivers/gpu/drm/msm/msm_gem_shrinker.c
@@ -8,48 +8,13 @@
 #include "msm_gem.h"
 #include "msm_gpu_trace.h"
 
-static bool msm_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
-{
-   /* NOTE: we are *closer* to being able to get rid of
-* mutex_trylock_recursive().. the msm_gem code itself does
-* not need struct_mutex, although codepaths that can trigger
-* shrinker are still called in code-paths that hold the
-* struct_mutex.
-*
-* Also, msm_obj->madv is protected by struct_mutex.
-*
-* The next step is probably split out a seperate lock for
-* protecting inactive_list, so that shrinker does not need
-* struct_mutex.
-*/
-   switch (mutex_trylock_recursive(>struct_mutex)) {
-   case MUTEX_TRYLOCK_FAILED:
-   return false;
-
-   case MUTEX_TRYLOCK_SUCCESS:
-   *unlock = true;
-   return true;
-
-   case MUTEX_TRYLOCK_RECURSIVE:
-   *unlock = false;
-   return true;
-   }
-
-   BUG();
-}
-
 static unsigned long
 msm_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc)
 {
struct msm_drm_private *priv =
container_of(shrinker, struct msm_drm_private, shrinker);
-   struct drm_device *dev = priv->dev;
struct msm_gem_object *msm_obj;
unsigned long count = 0;
-   bool unlock;
-
-   if (!msm_gem_shrinker_lock(dev, ))
-   return 0;
 
mutex_lock(>mm_lock);
 
@@ -63,9 +28,6 @@ msm_gem_shrinker_count(struct shrinker *shrinker, struct 
shrink_control *sc)
 
mutex_unlock(>mm_lock);
 
-   if (unlock)
-   mutex_unlock(>struct_mutex);
-
return count;
 }
 
@@ -74,13 +36,8 @@ msm_gem_shrinker_scan(struct shrinker *shrinker, struct 
shrink_control *sc)
 {
struct msm_drm_private *priv =
container_of(shrinker, struct msm_drm_private, shrinker);
-   struct drm_device *dev = priv->dev;
struct msm_gem_object *msm_obj;
unsigned long freed = 0;
-   bool unlock;
-
-   if (!msm_gem_shrinker_lock(dev, ))
-   return SHRINK_STOP;
 
mutex_lock(>mm_lock);
 
@@ -98,9 +55,6 @@ msm_gem_shrinker_scan(struct shrinker *shrinker, struct 
shrink_control *sc)
 
mutex_unlock(>mm_lock);
 
-   if (unlock)
-   mutex_unlock(>struct_mutex);
-
if (freed > 0)
trace_msm_gem_purge(freed << PAGE_SHIFT);
 
@@ -112,13 +66,8 @@ msm_gem_shrinker_vmap(struct notifier_block *nb, unsigned 
long event, void *ptr)
 {
struct msm_drm_private *priv =
container_of(nb, struct msm_drm_private, vmap_notifier);
-   struct drm_device *dev = priv->dev;
struct msm_gem_object *msm_obj;
unsigned unmapped = 0;
-   bool unlock;
-
-   if (!msm_gem_shrinker_lock(dev, ))
-   return NOTIFY_DONE;
 
mutex_lock(>mm_lock);
 
@@ -141,9 +90,6 @@ msm_gem_shrinker_vmap(struct notifier_block *nb, unsigned 
long event, void *ptr)
 
mutex_unlock(>mm_lock);
 
-   if (unlock)
-   mutex_unlock(>struct_mutex);
-
*(unsigned long *)ptr += unmapped;
 
if (unmapped > 0)
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 23/23] drm/msm: Don't implicit-sync if only a single ring

2020-10-19 Thread Rob Clark
From: Rob Clark 

If there is only a single ring (no-preemption), everything is FIFO order
and there is no need to implicit-sync.

Mesa should probably just always use MSM_SUBMIT_NO_IMPLICIT, as behavior
is undefined when fences are not used to synchronize buffer usage across
contexts (which is the only case where multiple different priority rings
could come into play).

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index d784e97f233f..96832debc3b6 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -277,7 +277,7 @@ static int submit_lock_objects(struct msm_gem_submit 
*submit)
return ret;
 }
 
-static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)
+static int submit_fence_sync(struct msm_gem_submit *submit, bool implicit_sync)
 {
int i, ret = 0;
 
@@ -297,7 +297,7 @@ static int submit_fence_sync(struct msm_gem_submit *submit, 
bool no_implicit)
return ret;
}
 
-   if (no_implicit)
+   if (!implicit_sync)
continue;
 
ret = msm_gem_sync_object(_obj->base, submit->ring->fctx,
@@ -768,7 +768,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
if (ret)
goto out;
 
-   ret = submit_fence_sync(submit, !!(args->flags & 
MSM_SUBMIT_NO_IMPLICIT));
+   ret = submit_fence_sync(submit, (gpu->nr_rings > 1) &&
+   !(args->flags & MSM_SUBMIT_NO_IMPLICIT));
if (ret)
goto out;
 
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 19/23] drm/msm: Drop struct_mutex in free_object() path

2020-10-19 Thread Rob Clark
From: Rob Clark 

Now that active_list/inactive_list is protected by mm_lock, we no longer
need dev->struct_mutex in the free_object() path.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index e4876498be47..af1abddca78e 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -949,8 +949,6 @@ static void free_object(struct msm_gem_object *msm_obj)
struct drm_device *dev = obj->dev;
struct msm_drm_private *priv = dev->dev_private;
 
-   WARN_ON(!mutex_is_locked(>struct_mutex));
-
/* object should not be on active list: */
WARN_ON(is_active(msm_obj));
 
@@ -987,20 +985,14 @@ void msm_gem_free_work(struct work_struct *work)
 {
struct msm_drm_private *priv =
container_of(work, struct msm_drm_private, free_work);
-   struct drm_device *dev = priv->dev;
struct llist_node *freed;
struct msm_gem_object *msm_obj, *next;
 
while ((freed = llist_del_all(>free_list))) {
-
-   mutex_lock(>struct_mutex);
-
llist_for_each_entry_safe(msm_obj, next,
  freed, freed)
free_object(msm_obj);
 
-   mutex_unlock(>struct_mutex);
-
if (need_resched())
break;
}
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 15/23] drm/msm: Protect ring->submits with it's own lock

2020-10-19 Thread Rob Clark
From: Rob Clark 

One less place to rely on dev->struct_mutex.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/msm_gem_submit.c |  2 ++
 drivers/gpu/drm/msm/msm_gpu.c| 37 ++--
 drivers/gpu/drm/msm/msm_ringbuffer.c |  1 +
 drivers/gpu/drm/msm/msm_ringbuffer.h |  6 +
 4 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index 50ecc8455197..c078b58d9c10 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -65,7 +65,9 @@ void msm_gem_submit_free(struct msm_gem_submit *submit)
unsigned i;
 
dma_fence_put(submit->fence);
+   spin_lock(>ring->submit_lock);
list_del(>node);
+   spin_unlock(>ring->submit_lock);
put_pid(submit->pid);
msm_submitqueue_put(submit->queue);
 
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 1667d8066897..1d6f3dc3fe78 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -270,6 +270,7 @@ static void update_fences(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring,
 {
struct msm_gem_submit *submit;
 
+   spin_lock(>submit_lock);
list_for_each_entry(submit, >submits, node) {
if (submit->seqno > fence)
break;
@@ -277,6 +278,7 @@ static void update_fences(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring,
msm_update_fence(submit->ring->fctx,
submit->fence->seqno);
}
+   spin_unlock(>submit_lock);
 }
 
 #ifdef CONFIG_DEV_COREDUMP
@@ -432,11 +434,14 @@ find_submit(struct msm_ringbuffer *ring, uint32_t fence)
 {
struct msm_gem_submit *submit;
 
-   WARN_ON(!mutex_is_locked(>gpu->dev->struct_mutex));
-
-   list_for_each_entry(submit, >submits, node)
-   if (submit->seqno == fence)
+   spin_lock(>submit_lock);
+   list_for_each_entry(submit, >submits, node) {
+   if (submit->seqno == fence) {
+   spin_unlock(>submit_lock);
return submit;
+   }
+   }
+   spin_unlock(>submit_lock);
 
return NULL;
 }
@@ -533,8 +538,10 @@ static void recover_worker(struct work_struct *work)
for (i = 0; i < gpu->nr_rings; i++) {
struct msm_ringbuffer *ring = gpu->rb[i];
 
+   spin_lock(>submit_lock);
list_for_each_entry(submit, >submits, node)
gpu->funcs->submit(gpu, submit);
+   spin_unlock(>submit_lock);
}
}
 
@@ -721,7 +728,6 @@ static void retire_submit(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring,
 static void retire_submits(struct msm_gpu *gpu)
 {
struct drm_device *dev = gpu->dev;
-   struct msm_gem_submit *submit, *tmp;
int i;
 
WARN_ON(!mutex_is_locked(>struct_mutex));
@@ -730,9 +736,24 @@ static void retire_submits(struct msm_gpu *gpu)
for (i = 0; i < gpu->nr_rings; i++) {
struct msm_ringbuffer *ring = gpu->rb[i];
 
-   list_for_each_entry_safe(submit, tmp, >submits, node) {
-   if (dma_fence_is_signaled(submit->fence))
+   while (true) {
+   struct msm_gem_submit *submit = NULL;
+
+   spin_lock(>submit_lock);
+   submit = list_first_entry_or_null(>submits,
+   struct msm_gem_submit, node);
+   spin_unlock(>submit_lock);
+
+   /*
+* If no submit, we are done.  If submit->fence hasn't
+* been signalled, then later submits are not signalled
+* either, so we are also done.
+*/
+   if (submit && dma_fence_is_signaled(submit->fence)) {
retire_submit(gpu, ring, submit);
+   } else {
+   break;
+   }
}
}
 }
@@ -775,7 +796,9 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct 
msm_gem_submit *submit)
 
submit->seqno = ++ring->seqno;
 
+   spin_lock(>submit_lock);
list_add_tail(>node, >submits);
+   spin_unlock(>submit_lock);
 
msm_rd_dump_submit(priv->rd, submit, NULL);
 
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c 
b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 1b6958e908dc..4d2a2a4abef8 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -46,6 +46,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu 
*gpu, int id,
ring->memptrs_iova = memptrs_iova;
 
INIT_LIST_HEAD(>submits);
+   spin_lock_init(>submit_lock);
spin_lock_init(>preempt_lock);
 
   

[PATCH v3 14/23] drm/msm: Document and rename preempt_lock

2020-10-19 Thread Rob Clark
From: Rob Clark 

Before adding another lock, give ring->lock a more descriptive name.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c |  4 ++--
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 12 ++--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c |  4 ++--
 drivers/gpu/drm/msm/msm_ringbuffer.c  |  2 +-
 drivers/gpu/drm/msm/msm_ringbuffer.h  |  7 ++-
 5 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index b2593c6bd2ac..2befaf304f04 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -36,7 +36,7 @@ void a5xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer 
*ring,
OUT_RING(ring, upper_32_bits(shadowptr(a5xx_gpu, ring)));
}
 
-   spin_lock_irqsave(>lock, flags);
+   spin_lock_irqsave(>preempt_lock, flags);
 
/* Copy the shadow to the actual register */
ring->cur = ring->next;
@@ -44,7 +44,7 @@ void a5xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer 
*ring,
/* Make sure to wrap wptr if we need to */
wptr = get_wptr(ring);
 
-   spin_unlock_irqrestore(>lock, flags);
+   spin_unlock_irqrestore(>preempt_lock, flags);
 
/* Make sure everything is posted before making a decision */
mb();
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c 
b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
index 7e04509c4e1f..183de1139eeb 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
@@ -45,9 +45,9 @@ static inline void update_wptr(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring)
if (!ring)
return;
 
-   spin_lock_irqsave(>lock, flags);
+   spin_lock_irqsave(>preempt_lock, flags);
wptr = get_wptr(ring);
-   spin_unlock_irqrestore(>lock, flags);
+   spin_unlock_irqrestore(>preempt_lock, flags);
 
gpu_write(gpu, REG_A5XX_CP_RB_WPTR, wptr);
 }
@@ -62,9 +62,9 @@ static struct msm_ringbuffer *get_next_ring(struct msm_gpu 
*gpu)
bool empty;
struct msm_ringbuffer *ring = gpu->rb[i];
 
-   spin_lock_irqsave(>lock, flags);
+   spin_lock_irqsave(>preempt_lock, flags);
empty = (get_wptr(ring) == ring->memptrs->rptr);
-   spin_unlock_irqrestore(>lock, flags);
+   spin_unlock_irqrestore(>preempt_lock, flags);
 
if (!empty)
return ring;
@@ -132,9 +132,9 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)
}
 
/* Make sure the wptr doesn't update while we're in motion */
-   spin_lock_irqsave(>lock, flags);
+   spin_lock_irqsave(>preempt_lock, flags);
a5xx_gpu->preempt[ring->id]->wptr = get_wptr(ring);
-   spin_unlock_irqrestore(>lock, flags);
+   spin_unlock_irqrestore(>preempt_lock, flags);
 
/* Set the address of the incoming preemption record */
gpu_write64(gpu, REG_A5XX_CP_CONTEXT_SWITCH_RESTORE_ADDR_LO,
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 0894703a742e..5dddb9163bd3 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -65,7 +65,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring)
OUT_RING(ring, upper_32_bits(shadowptr(a6xx_gpu, ring)));
}
 
-   spin_lock_irqsave(>lock, flags);
+   spin_lock_irqsave(>preempt_lock, flags);
 
/* Copy the shadow to the actual register */
ring->cur = ring->next;
@@ -73,7 +73,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring)
/* Make sure to wrap wptr if we need to */
wptr = get_wptr(ring);
 
-   spin_unlock_irqrestore(>lock, flags);
+   spin_unlock_irqrestore(>preempt_lock, flags);
 
/* Make sure everything is posted before making a decision */
mb();
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c 
b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 935bf9b1d941..1b6958e908dc 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -46,7 +46,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu 
*gpu, int id,
ring->memptrs_iova = memptrs_iova;
 
INIT_LIST_HEAD(>submits);
-   spin_lock_init(>lock);
+   spin_lock_init(>preempt_lock);
 
snprintf(name, sizeof(name), "gpu-ring-%d", ring->id);
 
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.h 
b/drivers/gpu/drm/msm/msm_ringbuffer.h
index 0987d6bf848c..4956d1bc5d0e 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.h
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.h
@@ -46,7 +46,12 @@ struct msm_ringbuffer {
struct msm_rbmemptrs *memptrs;
uint64_t memptrs_iova;
struct msm_fence_context *fctx;
-   spinlock_t lock;
+
+   /*
+* 

[PATCH v3 21/23] drm/msm: Drop struct_mutex in madvise path

2020-10-19 Thread Rob Clark
From: Rob Clark 

The obj->lock is sufficient for what we need.

This *does* have the implication that userspace can try to shoot
themselves in the foot by racing madvise(DONTNEED) with submit.  But
the result will be about the same if they did madvise(DONTNEED) before
the submit ioctl, ie. they might not get want they want if they race
with shrinker.  But iova fault handling is robust enough, and userspace
is only shooting it's own foot.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_drv.c | 11 ++-
 drivers/gpu/drm/msm/msm_gem.c |  4 +---
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index ebcd8e827363..4d808769e6ed 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -939,14 +939,9 @@ static int msm_ioctl_gem_madvise(struct drm_device *dev, 
void *data,
return -EINVAL;
}
 
-   ret = mutex_lock_interruptible(>struct_mutex);
-   if (ret)
-   return ret;
-
obj = drm_gem_object_lookup(file, args->handle);
if (!obj) {
-   ret = -ENOENT;
-   goto unlock;
+   return -ENOENT;
}
 
ret = msm_gem_madvise(obj, args->madv);
@@ -955,10 +950,8 @@ static int msm_ioctl_gem_madvise(struct drm_device *dev, 
void *data,
ret = 0;
}
 
-   drm_gem_object_put_locked(obj);
+   drm_gem_object_put(obj);
 
-unlock:
-   mutex_unlock(>struct_mutex);
return ret;
 }
 
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 827c7397ed12..c39ba9030001 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -673,8 +673,6 @@ int msm_gem_madvise(struct drm_gem_object *obj, unsigned 
madv)
 
msm_gem_lock(obj);
 
-   WARN_ON(!mutex_is_locked(>dev->struct_mutex));
-
if (msm_obj->madv != __MSM_MADV_PURGED)
msm_obj->madv = madv;
 
@@ -691,7 +689,6 @@ void msm_gem_purge(struct drm_gem_object *obj)
struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
WARN_ON(!mutex_is_locked(>struct_mutex));
-   WARN_ON(!msm_gem_is_locked(obj));
WARN_ON(!is_purgeable(msm_obj));
WARN_ON(obj->import_attach);
 
@@ -771,6 +768,7 @@ void msm_gem_active_get(struct drm_gem_object *obj, struct 
msm_gpu *gpu)
struct msm_drm_private *priv = obj->dev->dev_private;
 
might_sleep();
+   WARN_ON(!msm_gem_is_locked(obj));
WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED);
 
if (!atomic_fetch_inc(_obj->active_count)) {
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index ffa2130ee97d..d79e7019cc88 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -190,8 +190,6 @@ static inline bool is_active(struct msm_gem_object *msm_obj)
 
 static inline bool is_purgeable(struct msm_gem_object *msm_obj)
 {
-   WARN_ON(!msm_gem_is_locked(_obj->base));
-   WARN_ON(!mutex_is_locked(_obj->base.dev->struct_mutex));
return (msm_obj->madv == MSM_MADV_DONTNEED) && msm_obj->sgt &&
!msm_obj->base.dma_buf && !msm_obj->base.import_attach;
 }
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 12/23] drm/msm: Move update_fences()

2020-10-19 Thread Rob Clark
From: Rob Clark 

Small cleanup, update_fences() is used in the hangcheck path, but also
in the normal retire path.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/msm_gpu.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index ed6645aa0ae5..1667d8066897 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -265,6 +265,20 @@ int msm_gpu_hw_init(struct msm_gpu *gpu)
return ret;
 }
 
+static void update_fences(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
+   uint32_t fence)
+{
+   struct msm_gem_submit *submit;
+
+   list_for_each_entry(submit, >submits, node) {
+   if (submit->seqno > fence)
+   break;
+
+   msm_update_fence(submit->ring->fctx,
+   submit->fence->seqno);
+   }
+}
+
 #ifdef CONFIG_DEV_COREDUMP
 static ssize_t msm_gpu_devcoredump_read(char *buffer, loff_t offset,
size_t count, void *data, size_t datalen)
@@ -413,20 +427,6 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu,
  * Hangcheck detection for locked gpu:
  */
 
-static void update_fences(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
-   uint32_t fence)
-{
-   struct msm_gem_submit *submit;
-
-   list_for_each_entry(submit, >submits, node) {
-   if (submit->seqno > fence)
-   break;
-
-   msm_update_fence(submit->ring->fctx,
-   submit->fence->seqno);
-   }
-}
-
 static struct msm_gem_submit *
 find_submit(struct msm_ringbuffer *ring, uint32_t fence)
 {
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 18/23] drm/msm: Drop struct_mutex from the retire path

2020-10-19 Thread Rob Clark
From: Rob Clark 

Now that we are not relying on dev->struct_mutex to protect the
ring->submits lists, drop the struct_mutex lock.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/msm_gpu.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index d0f625112a97..30ba3beaad0a 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -717,7 +717,7 @@ static void retire_submit(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring,
 
msm_gem_active_put(_obj->base);
msm_gem_unpin_iova(_obj->base, submit->aspace);
-   drm_gem_object_put_locked(_obj->base);
+   drm_gem_object_put(_obj->base);
}
 
pm_runtime_mark_last_busy(>pdev->dev);
@@ -732,11 +732,8 @@ static void retire_submit(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring,
 
 static void retire_submits(struct msm_gpu *gpu)
 {
-   struct drm_device *dev = gpu->dev;
int i;
 
-   WARN_ON(!mutex_is_locked(>struct_mutex));
-
/* Retire the commits starting with highest priority */
for (i = 0; i < gpu->nr_rings; i++) {
struct msm_ringbuffer *ring = gpu->rb[i];
@@ -766,15 +763,12 @@ static void retire_submits(struct msm_gpu *gpu)
 static void retire_worker(struct work_struct *work)
 {
struct msm_gpu *gpu = container_of(work, struct msm_gpu, retire_work);
-   struct drm_device *dev = gpu->dev;
int i;
 
for (i = 0; i < gpu->nr_rings; i++)
update_fences(gpu, gpu->rb[i], gpu->rb[i]->memptrs->fence);
 
-   mutex_lock(>struct_mutex);
retire_submits(gpu);
-   mutex_unlock(>struct_mutex);
 }
 
 /* call from irq handler to schedule work to retire bo's */
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 20/23] drm/msm: Remove msm_gem_free_work

2020-10-19 Thread Rob Clark
From: Rob Clark 

Now that we don't need struct_mutex in the free path, we can get rid of
the asynchronous free altogether.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_drv.c |  3 ---
 drivers/gpu/drm/msm/msm_drv.h |  5 -
 drivers/gpu/drm/msm/msm_gem.c | 27 ---
 drivers/gpu/drm/msm/msm_gem.h |  1 -
 4 files changed, 36 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 15c41786d018..ebcd8e827363 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -465,9 +465,6 @@ static int msm_drm_init(struct device *dev, struct 
drm_driver *drv)
 
priv->wq = alloc_ordered_workqueue("msm", 0);
 
-   INIT_WORK(>free_work, msm_gem_free_work);
-   init_llist_head(>free_list);
-
INIT_LIST_HEAD(>inactive_list);
mutex_init(>mm_lock);
 
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 7e6fb4af4964..5308e636a90c 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -188,10 +188,6 @@ struct msm_drm_private {
struct list_head inactive_list;
struct mutex mm_lock;
 
-   /* worker for delayed free of objects: */
-   struct work_struct free_work;
-   struct llist_head free_list;
-
struct workqueue_struct *wq;
 
unsigned int num_planes;
@@ -291,7 +287,6 @@ struct drm_gem_object *msm_gem_prime_import_sg_table(struct 
drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg);
 int msm_gem_prime_pin(struct drm_gem_object *obj);
 void msm_gem_prime_unpin(struct drm_gem_object *obj);
-void msm_gem_free_work(struct work_struct *work);
 
 int msm_framebuffer_prepare(struct drm_framebuffer *fb,
struct msm_gem_address_space *aspace);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index af1abddca78e..827c7397ed12 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -939,16 +939,6 @@ void msm_gem_free_object(struct drm_gem_object *obj)
struct drm_device *dev = obj->dev;
struct msm_drm_private *priv = dev->dev_private;
 
-   if (llist_add(_obj->freed, >free_list))
-   queue_work(priv->wq, >free_work);
-}
-
-static void free_object(struct msm_gem_object *msm_obj)
-{
-   struct drm_gem_object *obj = _obj->base;
-   struct drm_device *dev = obj->dev;
-   struct msm_drm_private *priv = dev->dev_private;
-
/* object should not be on active list: */
WARN_ON(is_active(msm_obj));
 
@@ -981,23 +971,6 @@ static void free_object(struct msm_gem_object *msm_obj)
kfree(msm_obj);
 }
 
-void msm_gem_free_work(struct work_struct *work)
-{
-   struct msm_drm_private *priv =
-   container_of(work, struct msm_drm_private, free_work);
-   struct llist_node *freed;
-   struct msm_gem_object *msm_obj, *next;
-
-   while ((freed = llist_del_all(>free_list))) {
-   llist_for_each_entry_safe(msm_obj, next,
- freed, freed)
-   free_object(msm_obj);
-
-   if (need_resched())
-   break;
-   }
-}
-
 /* convenience method to construct a GEM buffer object, and userspace handle */
 int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
uint32_t size, uint32_t flags, uint32_t *handle,
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index f4e73c6f07bf..ffa2130ee97d 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -204,7 +204,6 @@ static inline bool is_vunmapable(struct msm_gem_object 
*msm_obj)
 
 void msm_gem_purge(struct drm_gem_object *obj);
 void msm_gem_vunmap(struct drm_gem_object *obj);
-void msm_gem_free_work(struct work_struct *work);
 
 /* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
  * associated with the cmdstream submission for synchronization (and
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 16/23] drm/msm: Refcount submits

2020-10-19 Thread Rob Clark
From: Rob Clark 

Before we remove dev->struct_mutex from the retire path, we have to deal
with the situation of a submit retiring before the submit ioctl returns.

To deal with this, ring->submits will hold a reference to the submit,
which is dropped when the submit is retired.  And the submit ioctl path
holds it's own ref, which it drops when it is done with the submit.

Also, add to submit list *after* getting/pinning bo's, to prevent badness
in case the completed fence is corrupted, and retire_worker mistakenly
believes the submit is done too early.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/msm_drv.h|  1 -
 drivers/gpu/drm/msm/msm_gem.h| 13 +
 drivers/gpu/drm/msm/msm_gem_submit.c | 11 +--
 drivers/gpu/drm/msm/msm_gpu.c| 21 -
 4 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 7431d68ea102..7e6fb4af4964 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -277,7 +277,6 @@ void msm_unregister_mmu(struct drm_device *dev, struct 
msm_mmu *mmu);
 
 bool msm_use_mmu(struct drm_device *dev);
 
-void msm_gem_submit_free(struct msm_gem_submit *submit);
 int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
struct drm_file *file);
 
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index f0608d96ef03..2f289c436ddd 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -213,6 +213,7 @@ void msm_gem_free_work(struct work_struct *work);
  * lasts for the duration of the submit-ioctl.
  */
 struct msm_gem_submit {
+   struct kref ref;
struct drm_device *dev;
struct msm_gpu *gpu;
struct msm_gem_address_space *aspace;
@@ -249,6 +250,18 @@ struct msm_gem_submit {
} bos[];
 };
 
+void __msm_gem_submit_destroy(struct kref *kref);
+
+static inline void msm_gem_submit_get(struct msm_gem_submit *submit)
+{
+   kref_get(>ref);
+}
+
+static inline void msm_gem_submit_put(struct msm_gem_submit *submit)
+{
+   kref_put(>ref, __msm_gem_submit_destroy);
+}
+
 /* helper to determine of a buffer in submit should be dumped, used for both
  * devcoredump and debugfs cmdstream dumping:
  */
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index c078b58d9c10..d784e97f233f 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -42,6 +42,7 @@ static struct msm_gem_submit *submit_create(struct drm_device 
*dev,
if (!submit)
return NULL;
 
+   kref_init(>ref);
submit->dev = dev;
submit->aspace = queue->ctx->aspace;
submit->gpu = gpu;
@@ -60,14 +61,13 @@ static struct msm_gem_submit *submit_create(struct 
drm_device *dev,
return submit;
 }
 
-void msm_gem_submit_free(struct msm_gem_submit *submit)
+void __msm_gem_submit_destroy(struct kref *kref)
 {
+   struct msm_gem_submit *submit =
+   container_of(kref, struct msm_gem_submit, ref);
unsigned i;
 
dma_fence_put(submit->fence);
-   spin_lock(>ring->submit_lock);
-   list_del(>node);
-   spin_unlock(>ring->submit_lock);
put_pid(submit->pid);
msm_submitqueue_put(submit->queue);
 
@@ -841,8 +841,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
submit_cleanup(submit);
if (has_ww_ticket)
ww_acquire_fini(>ticket);
-   if (ret)
-   msm_gem_submit_free(submit);
+   msm_gem_submit_put(submit);
 out_unlock:
if (ret && (out_fence_fd >= 0))
put_unused_fd(out_fence_fd);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 1d6f3dc3fe78..bcd9b4fa98b2 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -722,7 +722,12 @@ static void retire_submit(struct msm_gpu *gpu, struct 
msm_ringbuffer *ring,
 
pm_runtime_mark_last_busy(>pdev->dev);
pm_runtime_put_autosuspend(>pdev->dev);
-   msm_gem_submit_free(submit);
+
+   spin_lock(>submit_lock);
+   list_del(>node);
+   spin_unlock(>submit_lock);
+
+   msm_gem_submit_put(submit);
 }
 
 static void retire_submits(struct msm_gpu *gpu)
@@ -796,10 +801,6 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct 
msm_gem_submit *submit)
 
submit->seqno = ++ring->seqno;
 
-   spin_lock(>submit_lock);
-   list_add_tail(>node, >submits);
-   spin_unlock(>submit_lock);
-
msm_rd_dump_submit(priv->rd, submit, NULL);
 
update_sw_cntrs(gpu);
@@ -826,6 +827,16 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct 
msm_gem_submit *submit)
msm_gem_active_get(drm_obj, gpu);
}
 
+   /*
+* ring->submits holds a ref to the submit, to deal with the case
+* that a submit completes before 

[PATCH v3 13/23] drm/msm: Add priv->mm_lock to protect active/inactive lists

2020-10-19 Thread Rob Clark
From: Rob Clark 

Rather than relying on the big dev->struct_mutex hammer, introduce a
more specific lock for protecting the bo lists.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/msm_debugfs.c  |  7 +++
 drivers/gpu/drm/msm/msm_drv.c  |  7 +++
 drivers/gpu/drm/msm/msm_drv.h  | 13 +++-
 drivers/gpu/drm/msm/msm_gem.c  | 28 +++---
 drivers/gpu/drm/msm/msm_gem_shrinker.c | 12 +++
 drivers/gpu/drm/msm/msm_gpu.h  |  5 -
 6 files changed, 58 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_debugfs.c 
b/drivers/gpu/drm/msm/msm_debugfs.c
index ee2e270f464c..64afbed89821 100644
--- a/drivers/gpu/drm/msm/msm_debugfs.c
+++ b/drivers/gpu/drm/msm/msm_debugfs.c
@@ -112,6 +112,11 @@ static int msm_gem_show(struct drm_device *dev, struct 
seq_file *m)
 {
struct msm_drm_private *priv = dev->dev_private;
struct msm_gpu *gpu = priv->gpu;
+   int ret;
+
+   ret = mutex_lock_interruptible(>mm_lock);
+   if (ret)
+   return ret;
 
if (gpu) {
seq_printf(m, "Active Objects (%s):\n", gpu->name);
@@ -121,6 +126,8 @@ static int msm_gem_show(struct drm_device *dev, struct 
seq_file *m)
seq_printf(m, "Inactive Objects:\n");
msm_gem_describe_objects(>inactive_list, m);
 
+   mutex_unlock(>mm_lock);
+
return 0;
 }
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 70bc4bb69edc..15c41786d018 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -468,6 +469,12 @@ static int msm_drm_init(struct device *dev, struct 
drm_driver *drv)
init_llist_head(>free_list);
 
INIT_LIST_HEAD(>inactive_list);
+   mutex_init(>mm_lock);
+
+   /* Teach lockdep about lock ordering wrt. shrinker: */
+   fs_reclaim_acquire(GFP_KERNEL);
+   might_lock(>mm_lock);
+   fs_reclaim_release(GFP_KERNEL);
 
drm_mode_config_init(ddev);
 
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 713a0ae28125..7431d68ea102 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -174,8 +174,19 @@ struct msm_drm_private {
struct msm_rd_state *hangrd;   /* debugfs to dump hanging submits */
struct msm_perf_state *perf;
 
-   /* list of GEM objects: */
+   /*
+* List of inactive GEM objects.  Every bo is either in the 
inactive_list
+* or gpu->active_list (for the gpu it is active on[1])
+*
+* These lists are protected by mm_lock.  If struct_mutex is involved, 
it
+* should be aquired prior to mm_lock.  One should *not* hold mm_lock in
+* get_pages()/vmap()/etc paths, as they can trigger the shrinker.
+*
+* [1] if someone ever added support for the old 2d cores, there could 
be
+* more than one gpu object
+*/
struct list_head inactive_list;
+   struct mutex mm_lock;
 
/* worker for delayed free of objects: */
struct work_struct free_work;
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 3dcb2ef4740f..092ed152999e 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -768,13 +768,17 @@ int msm_gem_sync_object(struct drm_gem_object *obj,
 void msm_gem_active_get(struct drm_gem_object *obj, struct msm_gpu *gpu)
 {
struct msm_gem_object *msm_obj = to_msm_bo(obj);
-   WARN_ON(!mutex_is_locked(>dev->struct_mutex));
+   struct msm_drm_private *priv = obj->dev->dev_private;
+
+   might_sleep();
WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED);
 
if (!atomic_fetch_inc(_obj->active_count)) {
+   mutex_lock(>mm_lock);
msm_obj->gpu = gpu;
list_del_init(_obj->mm_list);
list_add_tail(_obj->mm_list, >active_list);
+   mutex_unlock(>mm_lock);
}
 }
 
@@ -783,12 +787,14 @@ void msm_gem_active_put(struct drm_gem_object *obj)
struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct msm_drm_private *priv = obj->dev->dev_private;
 
-   WARN_ON(!mutex_is_locked(>dev->struct_mutex));
+   might_sleep();
 
if (!atomic_dec_return(_obj->active_count)) {
+   mutex_lock(>mm_lock);
msm_obj->gpu = NULL;
list_del_init(_obj->mm_list);
list_add_tail(_obj->mm_list, >inactive_list);
+   mutex_unlock(>mm_lock);
}
 }
 
@@ -943,13 +949,16 @@ static void free_object(struct msm_gem_object *msm_obj)
 {
struct drm_gem_object *obj = _obj->base;
struct drm_device *dev = obj->dev;
+   struct msm_drm_private *priv = dev->dev_private;
 
WARN_ON(!mutex_is_locked(>struct_mutex));
 
/* object should not be on active list: */
   

[PATCH v3 02/23] drm/msm/gem: Add obj->lock wrappers

2020-10-19 Thread Rob Clark
From: Rob Clark 

This will make it easier to transition over to obj->resv locking for
everything that is per-bo locking.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c | 99 ---
 drivers/gpu/drm/msm/msm_gem.h | 28 ++
 2 files changed, 74 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 14e14caf90f9..afef9c6b1a1c 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -178,15 +178,15 @@ struct page **msm_gem_get_pages(struct drm_gem_object 
*obj)
struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct page **p;
 
-   mutex_lock(_obj->lock);
+   msm_gem_lock(obj);
 
if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED)) {
-   mutex_unlock(_obj->lock);
+   msm_gem_unlock(obj);
return ERR_PTR(-EBUSY);
}
 
p = get_pages(obj);
-   mutex_unlock(_obj->lock);
+   msm_gem_unlock(obj);
return p;
 }
 
@@ -252,14 +252,14 @@ vm_fault_t msm_gem_fault(struct vm_fault *vmf)
 * vm_ops.open/drm_gem_mmap_obj and close get and put
 * a reference on obj. So, we dont need to hold one here.
 */
-   err = mutex_lock_interruptible(_obj->lock);
+   err = msm_gem_lock_interruptible(obj);
if (err) {
ret = VM_FAULT_NOPAGE;
goto out;
}
 
if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED)) {
-   mutex_unlock(_obj->lock);
+   msm_gem_unlock(obj);
return VM_FAULT_SIGBUS;
}
 
@@ -280,7 +280,7 @@ vm_fault_t msm_gem_fault(struct vm_fault *vmf)
 
ret = vmf_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV));
 out_unlock:
-   mutex_unlock(_obj->lock);
+   msm_gem_unlock(obj);
 out:
return ret;
 }
@@ -289,10 +289,9 @@ vm_fault_t msm_gem_fault(struct vm_fault *vmf)
 static uint64_t mmap_offset(struct drm_gem_object *obj)
 {
struct drm_device *dev = obj->dev;
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
int ret;
 
-   WARN_ON(!mutex_is_locked(_obj->lock));
+   WARN_ON(!msm_gem_is_locked(obj));
 
/* Make it mmapable */
ret = drm_gem_create_mmap_offset(obj);
@@ -308,11 +307,10 @@ static uint64_t mmap_offset(struct drm_gem_object *obj)
 uint64_t msm_gem_mmap_offset(struct drm_gem_object *obj)
 {
uint64_t offset;
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
-   mutex_lock(_obj->lock);
+   msm_gem_lock(obj);
offset = mmap_offset(obj);
-   mutex_unlock(_obj->lock);
+   msm_gem_unlock(obj);
return offset;
 }
 
@@ -322,7 +320,7 @@ static struct msm_gem_vma *add_vma(struct drm_gem_object 
*obj,
struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct msm_gem_vma *vma;
 
-   WARN_ON(!mutex_is_locked(_obj->lock));
+   WARN_ON(!msm_gem_is_locked(obj));
 
vma = kzalloc(sizeof(*vma), GFP_KERNEL);
if (!vma)
@@ -341,7 +339,7 @@ static struct msm_gem_vma *lookup_vma(struct drm_gem_object 
*obj,
struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct msm_gem_vma *vma;
 
-   WARN_ON(!mutex_is_locked(_obj->lock));
+   WARN_ON(!msm_gem_is_locked(obj));
 
list_for_each_entry(vma, _obj->vmas, list) {
if (vma->aspace == aspace)
@@ -360,14 +358,14 @@ static void del_vma(struct msm_gem_vma *vma)
kfree(vma);
 }
 
-/* Called with msm_obj->lock locked */
+/* Called with msm_obj locked */
 static void
 put_iova(struct drm_gem_object *obj)
 {
struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct msm_gem_vma *vma, *tmp;
 
-   WARN_ON(!mutex_is_locked(_obj->lock));
+   WARN_ON(!msm_gem_is_locked(obj));
 
list_for_each_entry_safe(vma, tmp, _obj->vmas, list) {
if (vma->aspace) {
@@ -382,11 +380,10 @@ static int msm_gem_get_iova_locked(struct drm_gem_object 
*obj,
struct msm_gem_address_space *aspace, uint64_t *iova,
u64 range_start, u64 range_end)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct msm_gem_vma *vma;
int ret = 0;
 
-   WARN_ON(!mutex_is_locked(_obj->lock));
+   WARN_ON(!msm_gem_is_locked(obj));
 
vma = lookup_vma(obj, aspace);
 
@@ -421,7 +418,7 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
if (msm_obj->flags & MSM_BO_MAP_PRIV)
prot |= IOMMU_PRIV;
 
-   WARN_ON(!mutex_is_locked(_obj->lock));
+   WARN_ON(!msm_gem_is_locked(obj));
 
if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED))
return -EBUSY;
@@ -446,11 +443,10 @@ int msm_gem_get_and_pin_iova_range(struct drm_gem_object 
*obj,
struct msm_gem_address_space *aspace, uint64_t *iova,
u64 range_start, u64 range_end)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
u64 local;
 

[PATCH v3 03/23] drm/msm/gem: Rename internal get_iova_locked helper

2020-10-19 Thread Rob Clark
From: Rob Clark 

We'll need to introduce a _locked() version of msm_gem_get_iova(), so we
need to make that name available.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index afef9c6b1a1c..dec89fe79025 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -376,7 +376,7 @@ put_iova(struct drm_gem_object *obj)
}
 }
 
-static int msm_gem_get_iova_locked(struct drm_gem_object *obj,
+static int get_iova_locked(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace, uint64_t *iova,
u64 range_start, u64 range_end)
 {
@@ -448,7 +448,7 @@ int msm_gem_get_and_pin_iova_range(struct drm_gem_object 
*obj,
 
msm_gem_lock(obj);
 
-   ret = msm_gem_get_iova_locked(obj, aspace, ,
+   ret = get_iova_locked(obj, aspace, ,
range_start, range_end);
 
if (!ret)
@@ -478,7 +478,7 @@ int msm_gem_get_iova(struct drm_gem_object *obj,
int ret;
 
msm_gem_lock(obj);
-   ret = msm_gem_get_iova_locked(obj, aspace, iova, 0, U64_MAX);
+   ret = get_iova_locked(obj, aspace, iova, 0, U64_MAX);
msm_gem_unlock(obj);
 
return ret;
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 11/23] drm/msm: Drop chatty trace

2020-10-19 Thread Rob Clark
From: Rob Clark 

It is somewhat redundant with the gpu tracepoints, and anyways not too
useful to justify spamming the log when debug traces are enabled.

Signed-off-by: Rob Clark 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/msm_gpu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 015f6b884e2e..ed6645aa0ae5 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -545,7 +545,6 @@ static void recover_worker(struct work_struct *work)
 
 static void hangcheck_timer_reset(struct msm_gpu *gpu)
 {
-   DBG("%s", gpu->name);
mod_timer(>hangcheck_timer,
round_jiffies_up(jiffies + DRM_MSM_HANGCHECK_JIFFIES));
 }
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 00/23] drm/msm: de-struct_mutex-ification

2020-10-19 Thread Rob Clark
From: Rob Clark 

This doesn't remove *all* the struct_mutex, but it covers the worst
of it, ie. shrinker/madvise/free/retire.  The submit path still uses
struct_mutex, but it still needs *something* serialize a portion of
the submit path, and lock_stat mostly just shows the lock contention
there being with other submits.  And there are a few other bits of
struct_mutex usage in less critical paths (debugfs, etc).  But this
seems like a reasonable step in the right direction.

v2: teach lockdep about shrinker locking patters (danvet) and
convert to obj->resv locking (danvet)
v3: fix get_vaddr locking for legacy userspace (relocs), devcoredump,
and rd/hangrd

Rob Clark (23):
  drm/msm: Fix a couple incorrect usages of get_vaddr_active()
  drm/msm/gem: Add obj->lock wrappers
  drm/msm/gem: Rename internal get_iova_locked helper
  drm/msm/gem: Move prototypes to msm_gem.h
  drm/msm/gem: Add some _locked() helpers
  drm/msm/gem: Move locking in shrinker path
  drm/msm/submit: Move copy_from_user ahead of locking bos
  drm/msm: Do rpm get sooner in the submit path
  drm/msm/gem: Switch over to obj->resv for locking
  drm/msm: Use correct drm_gem_object_put() in fail case
  drm/msm: Drop chatty trace
  drm/msm: Move update_fences()
  drm/msm: Add priv->mm_lock to protect active/inactive lists
  drm/msm: Document and rename preempt_lock
  drm/msm: Protect ring->submits with it's own lock
  drm/msm: Refcount submits
  drm/msm: Remove obj->gpu
  drm/msm: Drop struct_mutex from the retire path
  drm/msm: Drop struct_mutex in free_object() path
  drm/msm: Remove msm_gem_free_work
  drm/msm: Drop struct_mutex in madvise path
  drm/msm: Drop struct_mutex in shrinker path
  drm/msm: Don't implicit-sync if only a single ring

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c |   6 +-
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c |  12 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c |   6 +-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |   1 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c |   1 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|   1 +
 drivers/gpu/drm/msm/msm_debugfs.c |   7 +
 drivers/gpu/drm/msm/msm_drv.c |  21 +-
 drivers/gpu/drm/msm/msm_drv.h |  73 +-
 drivers/gpu/drm/msm/msm_fbdev.c   |   1 +
 drivers/gpu/drm/msm/msm_gem.c | 266 +++---
 drivers/gpu/drm/msm/msm_gem.h | 133 +--
 drivers/gpu/drm/msm/msm_gem_shrinker.c|  81 ++-
 drivers/gpu/drm/msm/msm_gem_submit.c  | 158 -
 drivers/gpu/drm/msm/msm_gpu.c | 110 +
 drivers/gpu/drm/msm/msm_gpu.h |   5 +-
 drivers/gpu/drm/msm/msm_rd.c  |   2 +-
 drivers/gpu/drm/msm/msm_ringbuffer.c  |   3 +-
 drivers/gpu/drm/msm/msm_ringbuffer.h  |  13 +-
 19 files changed, 495 insertions(+), 405 deletions(-)

-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 07/23] drm/msm/submit: Move copy_from_user ahead of locking bos

2020-10-19 Thread Rob Clark
From: Rob Clark 

We cannot switch to using obj->resv for locking without first moving all
the copy_from_user() ahead of submit_lock_objects().  Otherwise in the
mm fault path we aquire mm->mmap_sem before obj lock, but in the submit
path the order is reversed.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.h|   3 +
 drivers/gpu/drm/msm/msm_gem_submit.c | 121 ---
 2 files changed, 76 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index c5232b8da794..0b7dda312992 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -240,7 +240,10 @@ struct msm_gem_submit {
uint32_t type;
uint32_t size;  /* in dwords */
uint64_t iova;
+   uint32_t offset;/* in dwords */
uint32_t idx;   /* cmdstream buffer idx in bos[] */
+   uint32_t nr_relocs;
+   struct drm_msm_gem_submit_reloc *relocs;
} *cmd;  /* array of size nr_cmds */
struct {
uint32_t flags;
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index aa5c60a7132d..002130d826aa 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -62,11 +62,16 @@ static struct msm_gem_submit *submit_create(struct 
drm_device *dev,
 
 void msm_gem_submit_free(struct msm_gem_submit *submit)
 {
+   unsigned i;
+
dma_fence_put(submit->fence);
list_del(>node);
put_pid(submit->pid);
msm_submitqueue_put(submit->queue);
 
+   for (i = 0; i < submit->nr_cmds; i++)
+   kfree(submit->cmd[i].relocs);
+
kfree(submit);
 }
 
@@ -150,6 +155,60 @@ static int submit_lookup_objects(struct msm_gem_submit 
*submit,
return ret;
 }
 
+static int submit_lookup_cmds(struct msm_gem_submit *submit,
+   struct drm_msm_gem_submit *args, struct drm_file *file)
+{
+   unsigned i, sz;
+   int ret = 0;
+
+   for (i = 0; i < args->nr_cmds; i++) {
+   struct drm_msm_gem_submit_cmd submit_cmd;
+   void __user *userptr =
+   u64_to_user_ptr(args->cmds + (i * sizeof(submit_cmd)));
+
+   ret = copy_from_user(_cmd, userptr, sizeof(submit_cmd));
+   if (ret) {
+   ret = -EFAULT;
+   goto out;
+   }
+
+   /* validate input from userspace: */
+   switch (submit_cmd.type) {
+   case MSM_SUBMIT_CMD_BUF:
+   case MSM_SUBMIT_CMD_IB_TARGET_BUF:
+   case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
+   break;
+   default:
+   DRM_ERROR("invalid type: %08x\n", submit_cmd.type);
+   return -EINVAL;
+   }
+
+   if (submit_cmd.size % 4) {
+   DRM_ERROR("non-aligned cmdstream buffer size: %u\n",
+   submit_cmd.size);
+   ret = -EINVAL;
+   goto out;
+   }
+
+   submit->cmd[i].type = submit_cmd.type;
+   submit->cmd[i].size = submit_cmd.size / 4;
+   submit->cmd[i].offset = submit_cmd.submit_offset / 4;
+   submit->cmd[i].idx  = submit_cmd.submit_idx;
+   submit->cmd[i].nr_relocs = submit_cmd.nr_relocs;
+
+   sz = sizeof(struct drm_msm_gem_submit_reloc) * 
submit_cmd.nr_relocs;
+   submit->cmd[i].relocs = kmalloc(sz, GFP_KERNEL);
+   ret = copy_from_user(submit->cmd[i].relocs, userptr, sz);
+   if (ret) {
+   ret = -EFAULT;
+   goto out;
+   }
+   }
+
+out:
+   return ret;
+}
+
 static void submit_unlock_unpin_bo(struct msm_gem_submit *submit,
int i, bool backoff)
 {
@@ -301,7 +360,7 @@ static int submit_bo(struct msm_gem_submit *submit, 
uint32_t idx,
 
 /* process the reloc's and patch up the cmdstream as needed: */
 static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object 
*obj,
-   uint32_t offset, uint32_t nr_relocs, uint64_t relocs)
+   uint32_t offset, uint32_t nr_relocs, struct 
drm_msm_gem_submit_reloc *relocs)
 {
uint32_t i, last_offset = 0;
uint32_t *ptr;
@@ -327,18 +386,11 @@ static int submit_reloc(struct msm_gem_submit *submit, 
struct msm_gem_object *ob
}
 
for (i = 0; i < nr_relocs; i++) {
-   struct drm_msm_gem_submit_reloc submit_reloc;
-   void __user *userptr =
-   u64_to_user_ptr(relocs + (i * sizeof(submit_reloc)));
+   struct drm_msm_gem_submit_reloc submit_reloc = relocs[i];
uint32_t off;
uint64_t iova;
bool valid;
 
-   if (copy_from_user(_reloc, 

[PATCH v3 10/23] drm/msm: Use correct drm_gem_object_put() in fail case

2020-10-19 Thread Rob Clark
From: Rob Clark 

We only want to use the _unlocked() variant in the unlocked case.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 6abcf9fe480d..3dcb2ef4740f 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -1135,7 +1135,11 @@ static struct drm_gem_object *_msm_gem_new(struct 
drm_device *dev,
return obj;
 
 fail:
-   drm_gem_object_put(obj);
+   if (struct_mutex_locked) {
+   drm_gem_object_put_locked(obj);
+   } else {
+   drm_gem_object_put(obj);
+   }
return ERR_PTR(ret);
 }
 
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 04/23] drm/msm/gem: Move prototypes to msm_gem.h

2020-10-19 Thread Rob Clark
From: Rob Clark 

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |  1 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c |  1 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  1 +
 drivers/gpu/drm/msm/msm_drv.h | 54 --
 drivers/gpu/drm/msm/msm_fbdev.c   |  1 +
 drivers/gpu/drm/msm/msm_gem.h | 56 +++
 6 files changed, 60 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
index a0253297bc76..b65b2329cc8d 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -11,6 +11,7 @@
 #include 
 
 #include "mdp4_kms.h"
+#include "msm_gem.h"
 
 struct mdp4_crtc {
struct drm_crtc base;
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index c39dad151bb6..81fbd52ad7e7 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -15,6 +15,7 @@
 #include 
 
 #include "mdp5_kms.h"
+#include "msm_gem.h"
 
 #define CURSOR_WIDTH   64
 #define CURSOR_HEIGHT  64
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index cee5c50c8e52..71160b4d77a0 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -26,6 +26,7 @@
 #include "sfpb.xml.h"
 #include "dsi_cfg.h"
 #include "msm_kms.h"
+#include "msm_gem.h"
 
 #define DSI_RESET_TOGGLE_DELAY_MS 20
 
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 7fbcdaebeff8..713a0ae28125 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -273,28 +273,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void 
*data,
 void msm_gem_shrinker_init(struct drm_device *dev);
 void msm_gem_shrinker_cleanup(struct drm_device *dev);
 
-int msm_gem_mmap_obj(struct drm_gem_object *obj,
-   struct vm_area_struct *vma);
-int msm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
-vm_fault_t msm_gem_fault(struct vm_fault *vmf);
-uint64_t msm_gem_mmap_offset(struct drm_gem_object *obj);
-int msm_gem_get_iova(struct drm_gem_object *obj,
-   struct msm_gem_address_space *aspace, uint64_t *iova);
-int msm_gem_get_and_pin_iova_range(struct drm_gem_object *obj,
-   struct msm_gem_address_space *aspace, uint64_t *iova,
-   u64 range_start, u64 range_end);
-int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
-   struct msm_gem_address_space *aspace, uint64_t *iova);
-uint64_t msm_gem_iova(struct drm_gem_object *obj,
-   struct msm_gem_address_space *aspace);
-void msm_gem_unpin_iova(struct drm_gem_object *obj,
-   struct msm_gem_address_space *aspace);
-struct page **msm_gem_get_pages(struct drm_gem_object *obj);
-void msm_gem_put_pages(struct drm_gem_object *obj);
-int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
-   struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-   uint32_t handle, uint64_t *offset);
 struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
 void *msm_gem_prime_vmap(struct drm_gem_object *obj);
 void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
@@ -303,38 +281,8 @@ struct drm_gem_object 
*msm_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg);
 int msm_gem_prime_pin(struct drm_gem_object *obj);
 void msm_gem_prime_unpin(struct drm_gem_object *obj);
-void *msm_gem_get_vaddr(struct drm_gem_object *obj);
-void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
-void msm_gem_put_vaddr(struct drm_gem_object *obj);
-int msm_gem_madvise(struct drm_gem_object *obj, unsigned madv);
-int msm_gem_sync_object(struct drm_gem_object *obj,
-   struct msm_fence_context *fctx, bool exclusive);
-void msm_gem_active_get(struct drm_gem_object *obj, struct msm_gpu *gpu);
-void msm_gem_active_put(struct drm_gem_object *obj);
-int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t 
*timeout);
-int msm_gem_cpu_fini(struct drm_gem_object *obj);
-void msm_gem_free_object(struct drm_gem_object *obj);
-int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
-   uint32_t size, uint32_t flags, uint32_t *handle, char *name);
-struct drm_gem_object *msm_gem_new(struct drm_device *dev,
-   uint32_t size, uint32_t flags);
-struct drm_gem_object *msm_gem_new_locked(struct drm_device *dev,
-   uint32_t size, uint32_t flags);
-void *msm_gem_kernel_new(struct drm_device *dev, uint32_t size,
-   uint32_t flags, struct msm_gem_address_space *aspace,
-   struct drm_gem_object **bo, uint64_t *iova);
-void *msm_gem_kernel_new_locked(struct drm_device *dev, uint32_t size,
-   

[PATCH v3 09/23] drm/msm/gem: Switch over to obj->resv for locking

2020-10-19 Thread Rob Clark
From: Rob Clark 

This also converts the special msm_gem_get_vaddr_active() to expect the
lock to already be held.  There are two call-sites for this, one already
has the lock held, so it is more straightforward to just open-code the
locking for the other caller.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c| 12 ++--
 drivers/gpu/drm/msm/msm_gem.h| 16 +---
 drivers/gpu/drm/msm/msm_gem_submit.c |  8 
 drivers/gpu/drm/msm/msm_gpu.c| 14 --
 drivers/gpu/drm/msm/msm_rd.c |  2 +-
 5 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 1195847714ba..6abcf9fe480d 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -644,13 +644,7 @@ void *msm_gem_get_vaddr(struct drm_gem_object *obj)
  */
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj)
 {
-   void *ret;
-
-   msm_gem_lock(obj);
-   ret = get_vaddr(obj, __MSM_MADV_PURGED);
-   msm_gem_unlock(obj);
-
-   return ret;
+   return get_vaddr(obj, __MSM_MADV_PURGED);
 }
 
 void msm_gem_put_vaddr_locked(struct drm_gem_object *obj)
@@ -976,9 +970,9 @@ static void free_object(struct msm_gem_object *msm_obj)
put_pages(obj);
}
 
+   msm_gem_unlock(obj);
drm_gem_object_release(obj);
 
-   msm_gem_unlock(obj);
kfree(msm_obj);
 }
 
@@ -1050,8 +1044,6 @@ static int msm_gem_new_impl(struct drm_device *dev,
if (!msm_obj)
return -ENOMEM;
 
-   mutex_init(_obj->lock);
-
msm_obj->flags = flags;
msm_obj->madv = MSM_MADV_WILLNEED;
 
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index 0b7dda312992..f0608d96ef03 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -85,7 +85,6 @@ struct msm_gem_object {
 * an IOMMU.  Also used for stolen/splashscreen buffer.
 */
struct drm_mm_node *vram_node;
-   struct mutex lock; /* Protects resources associated with bo */
 
char name[32]; /* Identifier to print for the debugfs files */
 
@@ -158,36 +157,31 @@ void msm_gem_describe_objects(struct list_head *list, 
struct seq_file *m);
 static inline void
 msm_gem_lock(struct drm_gem_object *obj)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
-   mutex_lock(_obj->lock);
+   dma_resv_lock(obj->resv, NULL);
 }
 
 static inline bool __must_check
 msm_gem_trylock(struct drm_gem_object *obj)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
-   return mutex_trylock_recursive(_obj->lock) == MUTEX_TRYLOCK_SUCCESS;
+   return dma_resv_trylock(obj->resv);
 }
 
 static inline int
 msm_gem_lock_interruptible(struct drm_gem_object *obj)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
-   return mutex_lock_interruptible(_obj->lock);
+   return dma_resv_lock_interruptible(obj->resv, NULL);
 }
 
 static inline void
 msm_gem_unlock(struct drm_gem_object *obj)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
-   mutex_unlock(_obj->lock);
+   dma_resv_unlock(obj->resv);
 }
 
 static inline bool
 msm_gem_is_locked(struct drm_gem_object *obj)
 {
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
-   return mutex_is_locked(_obj->lock);
+   return dma_resv_is_locked(obj->resv);
 }
 
 static inline bool is_active(struct msm_gem_object *msm_obj)
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index a9422d043bfe..50ecc8455197 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -215,7 +215,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit 
*submit,
struct msm_gem_object *msm_obj = submit->bos[i].obj;
 
if (submit->bos[i].flags & BO_PINNED)
-   msm_gem_unpin_iova(_obj->base, submit->aspace);
+   msm_gem_unpin_iova_locked(_obj->base, submit->aspace);
 
if (submit->bos[i].flags & BO_LOCKED)
dma_resv_unlock(msm_obj->base.resv);
@@ -318,7 +318,7 @@ static int submit_pin_objects(struct msm_gem_submit *submit)
uint64_t iova;
 
/* if locking succeeded, pin bo: */
-   ret = msm_gem_get_and_pin_iova(_obj->base,
+   ret = msm_gem_get_and_pin_iova_locked(_obj->base,
submit->aspace, );
 
if (ret)
@@ -377,7 +377,7 @@ static int submit_reloc(struct msm_gem_submit *submit, 
struct msm_gem_object *ob
/* For now, just map the entire thing.  Eventually we probably
 * to do it page-by-page, w/ kmap() if not vmap()d..
 */
-   ptr = msm_gem_get_vaddr(>base);
+   ptr = msm_gem_get_vaddr_locked(>base);
 
if (IS_ERR(ptr)) {
ret = PTR_ERR(ptr);
@@ -428,7 +428,7 @@ static int submit_reloc(struct msm_gem_submit *submit, 
struct msm_gem_object 

[PATCH v3 08/23] drm/msm: Do rpm get sooner in the submit path

2020-10-19 Thread Rob Clark
From: Rob Clark 

Unfortunately, due to an dev_pm_opp locking interaction with
mm->mmap_sem, we need to do pm get before aquiring obj locks,
otherwise we can have anger lockdep with the chain:

  opp_table_lock --> >mmap_sem --> reservation_ww_class_mutex

For an explicit fencing userspace, the impact should be minimal
as we do all the fence waits before this point.  It could result
in some needless resumes in error cases, etc.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index 002130d826aa..a9422d043bfe 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -744,11 +744,20 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void 
*data,
 
ret = submit_lookup_objects(submit, args, file);
if (ret)
-   goto out;
+   goto out_pre_pm;
 
ret = submit_lookup_cmds(submit, args, file);
if (ret)
-   goto out;
+   goto out_pre_pm;
+
+   /*
+* Thanks to dev_pm_opp opp_table_lock interactions with mm->mmap_sem
+* in the resume path, we need to to rpm get before we lock objs.
+* Which unfortunately might involve powering up the GPU sooner than
+* is necessary.  But at least in the explicit fencing case, we will
+* have already done all the fence waiting.
+*/
+   pm_runtime_get_sync(>pdev->dev);
 
/* copy_*_user while holding a ww ticket upsets lockdep */
ww_acquire_init(>ticket, _ww_class);
@@ -825,6 +834,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 
 
 out:
+   pm_runtime_put(>pdev->dev);
+out_pre_pm:
submit_cleanup(submit);
if (has_ww_ticket)
ww_acquire_fini(>ticket);
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 05/23] drm/msm/gem: Add some _locked() helpers

2020-10-19 Thread Rob Clark
From: Rob Clark 

When we cut-over to using dma_resv_lock/etc instead of msm_obj->lock,
we'll need these for the submit path (where resv->lock is already held).

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c | 89 +++
 drivers/gpu/drm/msm/msm_gem.h |  6 +++
 2 files changed, 75 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index dec89fe79025..e0d8d739b068 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -435,18 +435,14 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
msm_obj->sgt, obj->size >> PAGE_SHIFT);
 }
 
-/*
- * get iova and pin it. Should have a matching put
- * limits iova to specified range (in pages)
- */
-int msm_gem_get_and_pin_iova_range(struct drm_gem_object *obj,
+static int get_and_pin_iova_range_locked(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace, uint64_t *iova,
u64 range_start, u64 range_end)
 {
u64 local;
int ret;
 
-   msm_gem_lock(obj);
+   WARN_ON(!msm_gem_is_locked(obj));
 
ret = get_iova_locked(obj, aspace, ,
range_start, range_end);
@@ -457,10 +453,32 @@ int msm_gem_get_and_pin_iova_range(struct drm_gem_object 
*obj,
if (!ret)
*iova = local;
 
+   return ret;
+}
+
+/*
+ * get iova and pin it. Should have a matching put
+ * limits iova to specified range (in pages)
+ */
+int msm_gem_get_and_pin_iova_range(struct drm_gem_object *obj,
+   struct msm_gem_address_space *aspace, uint64_t *iova,
+   u64 range_start, u64 range_end)
+{
+   int ret;
+
+   msm_gem_lock(obj);
+   ret = get_and_pin_iova_range_locked(obj, aspace, iova, range_start, 
range_end);
msm_gem_unlock(obj);
+
return ret;
 }
 
+int msm_gem_get_and_pin_iova_locked(struct drm_gem_object *obj,
+   struct msm_gem_address_space *aspace, uint64_t *iova)
+{
+   return get_and_pin_iova_range_locked(obj, aspace, iova, 0, U64_MAX);
+}
+
 /* get iova and pin it. Should have a matching put */
 int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace, uint64_t *iova)
@@ -501,21 +519,31 @@ uint64_t msm_gem_iova(struct drm_gem_object *obj,
 }
 
 /*
- * Unpin a iova by updating the reference counts. The memory isn't actually
- * purged until something else (shrinker, mm_notifier, destroy, etc) decides
- * to get rid of it
+ * Locked variant of msm_gem_unpin_iova()
  */
-void msm_gem_unpin_iova(struct drm_gem_object *obj,
+void msm_gem_unpin_iova_locked(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace)
 {
struct msm_gem_vma *vma;
 
-   msm_gem_lock(obj);
+   WARN_ON(!msm_gem_is_locked(obj));
+
vma = lookup_vma(obj, aspace);
 
if (!WARN_ON(!vma))
msm_gem_unmap_vma(aspace, vma);
+}
 
+/*
+ * Unpin a iova by updating the reference counts. The memory isn't actually
+ * purged until something else (shrinker, mm_notifier, destroy, etc) decides
+ * to get rid of it
+ */
+void msm_gem_unpin_iova(struct drm_gem_object *obj,
+   struct msm_gem_address_space *aspace)
+{
+   msm_gem_lock(obj);
+   msm_gem_unpin_iova_locked(obj, aspace);
msm_gem_unlock(obj);
 }
 
@@ -554,15 +582,14 @@ static void *get_vaddr(struct drm_gem_object *obj, 
unsigned madv)
struct msm_gem_object *msm_obj = to_msm_bo(obj);
int ret = 0;
 
+   WARN_ON(!msm_gem_is_locked(obj));
+
if (obj->import_attach)
return ERR_PTR(-ENODEV);
 
-   msm_gem_lock(obj);
-
if (WARN_ON(msm_obj->madv > madv)) {
DRM_DEV_ERROR(obj->dev->dev, "Invalid madv state: %u vs %u\n",
msm_obj->madv, madv);
-   msm_gem_unlock(obj);
return ERR_PTR(-EBUSY);
}
 
@@ -588,20 +615,29 @@ static void *get_vaddr(struct drm_gem_object *obj, 
unsigned madv)
}
}
 
-   msm_gem_unlock(obj);
return msm_obj->vaddr;
 
 fail:
msm_obj->vmap_count--;
-   msm_gem_unlock(obj);
return ERR_PTR(ret);
 }
 
-void *msm_gem_get_vaddr(struct drm_gem_object *obj)
+void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj)
 {
return get_vaddr(obj, MSM_MADV_WILLNEED);
 }
 
+void *msm_gem_get_vaddr(struct drm_gem_object *obj)
+{
+   void *ret;
+
+   msm_gem_lock(obj);
+   ret = msm_gem_get_vaddr_locked(obj);
+   msm_gem_unlock(obj);
+
+   return ret;
+}
+
 /*
  * Don't use this!  It is for the very special case of dumping
  * submits from GPU hangs or faults, were the bo may already
@@ -610,16 +646,29 @@ void *msm_gem_get_vaddr(struct drm_gem_object *obj)
  */
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj)
 {
-   return get_vaddr(obj, __MSM_MADV_PURGED);
+   void *ret;
+
+   

[PATCH v3 06/23] drm/msm/gem: Move locking in shrinker path

2020-10-19 Thread Rob Clark
From: Rob Clark 

Move grabbing the bo lock into shrinker, with a msm_gem_trylock() to
skip over bo's that are already locked.  This gets rid of the nested
lock classes.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gem.c  | 24 +
 drivers/gpu/drm/msm/msm_gem.h  | 29 ++
 drivers/gpu/drm/msm/msm_gem_shrinker.c | 27 +---
 3 files changed, 35 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index e0d8d739b068..1195847714ba 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -17,8 +17,6 @@
 #include "msm_gpu.h"
 #include "msm_mmu.h"
 
-static void msm_gem_vunmap_locked(struct drm_gem_object *obj);
-
 
 static dma_addr_t physaddr(struct drm_gem_object *obj)
 {
@@ -693,20 +691,19 @@ int msm_gem_madvise(struct drm_gem_object *obj, unsigned 
madv)
return (madv != __MSM_MADV_PURGED);
 }
 
-void msm_gem_purge(struct drm_gem_object *obj, enum msm_gem_lock subclass)
+void msm_gem_purge(struct drm_gem_object *obj)
 {
struct drm_device *dev = obj->dev;
struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
WARN_ON(!mutex_is_locked(>struct_mutex));
+   WARN_ON(!msm_gem_is_locked(obj));
WARN_ON(!is_purgeable(msm_obj));
WARN_ON(obj->import_attach);
 
-   mutex_lock_nested(_obj->lock, subclass);
-
put_iova(obj);
 
-   msm_gem_vunmap_locked(obj);
+   msm_gem_vunmap(obj);
 
put_pages(obj);
 
@@ -724,11 +721,9 @@ void msm_gem_purge(struct drm_gem_object *obj, enum 
msm_gem_lock subclass)
 
invalidate_mapping_pages(file_inode(obj->filp)->i_mapping,
0, (loff_t)-1);
-
-   msm_gem_unlock(obj);
 }
 
-static void msm_gem_vunmap_locked(struct drm_gem_object *obj)
+void msm_gem_vunmap(struct drm_gem_object *obj)
 {
struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
@@ -741,15 +736,6 @@ static void msm_gem_vunmap_locked(struct drm_gem_object 
*obj)
msm_obj->vaddr = NULL;
 }
 
-void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass)
-{
-   struct msm_gem_object *msm_obj = to_msm_bo(obj);
-
-   mutex_lock_nested(_obj->lock, subclass);
-   msm_gem_vunmap_locked(obj);
-   msm_gem_unlock(obj);
-}
-
 /* must be called before _move_to_active().. */
 int msm_gem_sync_object(struct drm_gem_object *obj,
struct msm_fence_context *fctx, bool exclusive)
@@ -986,7 +972,7 @@ static void free_object(struct msm_gem_object *msm_obj)
 
drm_prime_gem_destroy(obj, msm_obj->sgt);
} else {
-   msm_gem_vunmap_locked(obj);
+   msm_gem_vunmap(obj);
put_pages(obj);
}
 
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index d55d5401a2d2..c5232b8da794 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -162,6 +162,13 @@ msm_gem_lock(struct drm_gem_object *obj)
mutex_lock(_obj->lock);
 }
 
+static inline bool __must_check
+msm_gem_trylock(struct drm_gem_object *obj)
+{
+   struct msm_gem_object *msm_obj = to_msm_bo(obj);
+   return mutex_trylock_recursive(_obj->lock) == MUTEX_TRYLOCK_SUCCESS;
+}
+
 static inline int
 msm_gem_lock_interruptible(struct drm_gem_object *obj)
 {
@@ -190,6 +197,7 @@ static inline bool is_active(struct msm_gem_object *msm_obj)
 
 static inline bool is_purgeable(struct msm_gem_object *msm_obj)
 {
+   WARN_ON(!msm_gem_is_locked(_obj->base));
WARN_ON(!mutex_is_locked(_obj->base.dev->struct_mutex));
return (msm_obj->madv == MSM_MADV_DONTNEED) && msm_obj->sgt &&
!msm_obj->base.dma_buf && !msm_obj->base.import_attach;
@@ -197,27 +205,12 @@ static inline bool is_purgeable(struct msm_gem_object 
*msm_obj)
 
 static inline bool is_vunmapable(struct msm_gem_object *msm_obj)
 {
+   WARN_ON(!msm_gem_is_locked(_obj->base));
return (msm_obj->vmap_count == 0) && msm_obj->vaddr;
 }
 
-/* The shrinker can be triggered while we hold objA->lock, and need
- * to grab objB->lock to purge it.  Lockdep just sees these as a single
- * class of lock, so we use subclasses to teach it the difference.
- *
- * OBJ_LOCK_NORMAL is implicit (ie. normal mutex_lock() call), and
- * OBJ_LOCK_SHRINKER is used by shrinker.
- *
- * It is *essential* that we never go down paths that could trigger the
- * shrinker for a purgable object.  This is ensured by checking that
- * msm_obj->madv == MSM_MADV_WILLNEED.
- */
-enum msm_gem_lock {
-   OBJ_LOCK_NORMAL,
-   OBJ_LOCK_SHRINKER,
-};
-
-void msm_gem_purge(struct drm_gem_object *obj, enum msm_gem_lock subclass);
-void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass);
+void msm_gem_purge(struct drm_gem_object *obj);
+void msm_gem_vunmap(struct drm_gem_object *obj);
 void msm_gem_free_work(struct work_struct *work);
 
 /* Created per submit-ioctl, to track 

[PATCH v3 01/23] drm/msm: Fix a couple incorrect usages of get_vaddr_active()

2020-10-19 Thread Rob Clark
From: Rob Clark 

The microcode bo's should never be madvise(WONTNEED), so these should
not be using msm_gem_get_vaddr_active().

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index d6804a802355..b2593c6bd2ac 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -426,7 +426,7 @@ static int a5xx_preempt_start(struct msm_gpu *gpu)
 static void a5xx_ucode_check_version(struct a5xx_gpu *a5xx_gpu,
struct drm_gem_object *obj)
 {
-   u32 *buf = msm_gem_get_vaddr_active(obj);
+   u32 *buf = msm_gem_get_vaddr(obj);
 
if (IS_ERR(buf))
return;
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 948f3656c20c..0894703a742e 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -522,7 +522,7 @@ static int a6xx_cp_init(struct msm_gpu *gpu)
 static void a6xx_ucode_check_version(struct a6xx_gpu *a6xx_gpu,
struct drm_gem_object *obj)
 {
-   u32 *buf = msm_gem_get_vaddr_active(obj);
+   u32 *buf = msm_gem_get_vaddr(obj);
 
if (IS_ERR(buf))
return;
-- 
2.26.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: It appears drm-next TTM cleanup broke something . . .

2020-10-19 Thread Sam Ravnborg
Hi Kevin.

On Mon, Oct 19, 2020 at 09:43:08PM +0200, Kevin Brace wrote:
> Hi Sam,
> 
> Thanks for asking the question.
> The current OpenChrome DRM code has these two major issues.
> 
> 1) It does not support atomic modesetting
> 
> I do internally have working code to support atomic modesetting, but it is 
> not ready for committing into the upstream OpenChrome DRM repository.
> In particular, it suffers from a freeze relating to a cursor plane.
> The freeze is a bad kind that kern.log does not really tell me what is wrong.
> If I disable hardware cursor, the atomic modesetting based OpenChrome DRM 
> appears to work okay.
> In other words, I am getting close to getting atomic modesetting working, but 
> I am stuck.
Maybe posting what you have now - and explain that it has this defect.
Chances are that you will receive feedback that may help you on your way
to fix this.

With all the infrastructure improvements made the last years I would be
suprised if you have managed to include it all and maybe some of the
infrastructure may help you.

Also I know we have seems some cursor plane related discussions the last
months so maybe there are something to gain from the people involved
there.


> 2) Double allocation of visible portion of frame buffer
> 
> This is a big problem left behind from the previous developer who developed 
> OpenChrome prior to me.
> For some reason, the developer wanted to allocate visible portion of the 
> frame buffer to be the maximum possible size supported by the detected 
> monitor when initializing the frame buffer inside OpenChrome DRM code.
> I believe Radeon DRM does something similar to that.
> The problem is, OpenChrome DDX allocates an equal sized frame buffer visible 
> portion during the DDX's initialization.
> This means that we got two same sized visible portions allocated, but 
> OpenChrome DDX and OpenChrome DRM combined should really be allocating only 
> one.
> At this point, OpenChrome is not supporting double buffering.
> This double allocation of a visible portion of the frame buffer contributes 
> to a X Server crash when the screen is resized and 16 MB or less (i.e., 8 MB) 
> shared frame buffer is reserved by the system via BIOS setup.
> I personally think letting OpenChrome DRM allocate the visible portion of the 
> frame buffer is the way to go, but if so, how do I get the DDX or shadow FB 
> to access the frame buffer visible portion allocated by OpenChrome DRM?
> Any suggestions on what to do about this issue will be greatly appreciated.
> Perhaps, I should post a question to dri-devel regarding this issue.
> I really do not know what I should do at this point.
Likewise.

But obviously you shall not post it to dri-devel unless you are prepared
to handle the feedback that you *may* get.

I promise to take a look - but that will cover mostly trivial stuff.
You have to rely on others for all the stuff around atomic modestetting
and the memory handling etc. - the areas where you have challenges now.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: It appears drm-next TTM cleanup broke something . . .

2020-10-19 Thread Kevin Brace
Hi Sam,

Thanks for asking the question.
The current OpenChrome DRM code has these two major issues.

1) It does not support atomic modesetting

I do internally have working code to support atomic modesetting, but it is not 
ready for committing into the upstream OpenChrome DRM repository.
In particular, it suffers from a freeze relating to a cursor plane.
The freeze is a bad kind that kern.log does not really tell me what is wrong.
If I disable hardware cursor, the atomic modesetting based OpenChrome DRM 
appears to work okay.
In other words, I am getting close to getting atomic modesetting working, but I 
am stuck.


2) Double allocation of visible portion of frame buffer

This is a big problem left behind from the previous developer who developed 
OpenChrome prior to me.
For some reason, the developer wanted to allocate visible portion of the frame 
buffer to be the maximum possible size supported by the detected monitor when 
initializing the frame buffer inside OpenChrome DRM code.
I believe Radeon DRM does something similar to that.
The problem is, OpenChrome DDX allocates an equal sized frame buffer visible 
portion during the DDX's initialization.
This means that we got two same sized visible portions allocated, but 
OpenChrome DDX and OpenChrome DRM combined should really be allocating only one.
At this point, OpenChrome is not supporting double buffering.
This double allocation of a visible portion of the frame buffer contributes to 
a X Server crash when the screen is resized and 16 MB or less (i.e., 8 MB) 
shared frame buffer is reserved by the system via BIOS setup.
I personally think letting OpenChrome DRM allocate the visible portion of the 
frame buffer is the way to go, but if so, how do I get the DDX or shadow FB to 
access the frame buffer visible portion allocated by OpenChrome DRM?
Any suggestions on what to do about this issue will be greatly appreciated.
Perhaps, I should post a question to dri-devel regarding this issue.
I really do not know what I should do at this point.

Regards,

Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com


> Sent: Sunday, October 18, 2020 at 2:04 PM
> From: "Sam Ravnborg" 
> To: "Kevin Brace" 
> Cc: dri-devel@lists.freedesktop.org, "Dave Airlie" 
> Subject: Re: It appears drm-next TTM cleanup broke something . . .
>
> Hi Kevin.
>
> On Sun, Oct 18, 2020 at 09:15:17PM +0200, Kevin Brace wrote:
> > As usual, I pulled in DRM repository code for an out of tree OpenChrome DRM 
> > repository a few days ago.
>
> I know you have been working on and off on the openchrome driver for a
> long time now. Any chance we will see the driver submitted for upstream soon?
>
>   Sam
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd/display: fix a possible NULL pointer dereference in bios_parser_get_src_obj()

2020-10-19 Thread estherbdf
[Why] the func  bios_parser_get_src_obj () is similar to  
bios_parser_get_dst_obj () which is fixed by the 
commit("drm/amd/display: Banch of smatch error and warning fixes 
in DC").
the symbol 'id' is uninitialized and it is not checked before dereference 
it,may lead to null pointer dereference.
[How] Initialized variable explicitly with NULL and add sanitizer.

Signed-off-by: estherbdf <603571...@qq.com>
---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c 
b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
index 008d4d1..94c6cca 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
@@ -190,7 +190,7 @@ static enum bp_result bios_parser_get_src_obj(struct 
dc_bios *dcb,
struct graphics_object_id *src_object_id)
 {
uint32_t number;
-   uint16_t *id;
+   uint16_t *id = NULL;
ATOM_OBJECT *object;
struct bios_parser *bp = BP_FROM_DCB(dcb);
 
@@ -206,7 +206,7 @@ static enum bp_result bios_parser_get_src_obj(struct 
dc_bios *dcb,
 
number = get_src_obj_list(bp, object, );
 
-   if (number <= index)
+   if (number <= index || !id)
return BP_RESULT_BADINPUT;
 
*src_object_id = object_id_from_bios_object_id(id[index]);
-- 
1.9.1


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 19/20] drm/tegra: Implement new UAPI

2020-10-19 Thread Dmitry Osipenko
07.10.2020 20:12, Mikko Perttunen пишет:
> +int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data,
> + struct drm_file *file)
> +{

Hello, Mikko!

Could you please tell what are the host1x clients that are going to be
upstreamed and will need this IOCTL?
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 19/20] drm/tegra: Implement new UAPI

2020-10-19 Thread Dmitry Osipenko
19.10.2020 11:13, Mikko Perttunen пишет:
> On 10/19/20 5:21 AM, Dmitry Osipenko wrote:
>> 07.10.2020 20:12, Mikko Perttunen пишет:
>>> +int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data,
>>> +    struct drm_file *file)
>>> +{
>>
>> Hello, Mikko!
>>
>> Could you please tell what are the host1x clients that are going to be
>> upstreamed and will need this IOCTL?
>>
> 
> Hi Dmitry!
> 
> It is needed for any engine/job that wants to access memory, as this
> IOCTL must be used to map memory for the engine. So all of them.
> 
> Downstream doesn't have an equivalent IOCTL because it (currently) does
> mapping at submit time, but that is suboptimal because
> 
> - it requires doing relocations in the kernel which isn't required for
> T186+
> - it's a big performance penalty, due to which the downstream kernel has
> the "deferred dma-buf unmapping" feature, where unmapping a dma_buf may
> not immediately unmap it in case it's used later, so that the "mapping"
> later is faster. A feature which we'd preferably get rid of.
> - because of the above feature not being controlled by the user, it can
> cause variance in submit times.
> 
> On the other hand, we cannot (at least always) do the mapping at
> allocation/import time, because
> 
> - A single FD may have multiple channel_ctx's, and an allocation/import
> may need to be used in any subset of them
> - The import IOCTL is fixed and doesn't have the parameters we'd need to
> do this at import time
> - Overall it's more orthogonal to have GEM object acquirement in one
> step and mapping in another.
> 
> Maybe that's not quite what you asked, but it's some background anyway :)

I'm asking this question because right now there is only one potential
client for this IOCTL, the VIC. If other clients aren't supposed to be a
part of the DRM driver, like for example NVDEC which probably should be
a V4L driver, then DRM driver will have only a single VIC and in this
case we shouldn't need this IOCTL because DRM and V4L should use generic
dmabuf API for importing and exporting buffers.

I'm also not quite sure about whether the current model of the unified
Tegra DRM driver is suitable for having the separated engines. Perhaps
each separated engine should just have its own rendering node?
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()

2020-10-19 Thread Christophe Leroy
Include  in order to avoid following build failure
because of missing declaration of enable_kernel_vsx()

  CC [M]  drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.o
In file included from 
./drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
 from 
./drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services.h:37,
 from 
drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c:27:
drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c: In function 
'dcn_bw_apply_registry_override':
./drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:64:3: error: implicit 
declaration of function 'enable_kernel_vsx'; did you mean 'enable_kernel_fp'? 
[-Werror=implicit-function-declaration]
   64 |   enable_kernel_vsx(); \
  |   ^
drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c:640:2: note: in 
expansion of macro 'DC_FP_START'
  640 |  DC_FP_START();
  |  ^~~
./drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:75:3: error: implicit 
declaration of function 'disable_kernel_vsx'; did you mean 'disable_kernel_fp'? 
[-Werror=implicit-function-declaration]
   75 |   disable_kernel_vsx(); \
  |   ^~
drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c:676:2: note: in 
expansion of macro 'DC_FP_END'
  676 |  DC_FP_END();
  |  ^
cc1: some warnings being treated as errors
make[5]: *** [drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.o] Error 
1

Fixes: 16a9dea110a6 ("amdgpu: Enable initial DCN support on POWER")
Cc: sta...@vger.kernel.org
Signed-off-by: Christophe Leroy 
---
 drivers/gpu/drm/amd/display/dc/os_types.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h 
b/drivers/gpu/drm/amd/display/dc/os_types.h
index c3bbfe397e8d..9000cf188544 100644
--- a/drivers/gpu/drm/amd/display/dc/os_types.h
+++ b/drivers/gpu/drm/amd/display/dc/os_types.h
@@ -33,6 +33,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
-- 
2.25.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/of: Consider the state in which the ep is disabled

2020-10-19 Thread Kever Yang

Hi Daniel,

On 2020/10/15 下午11:23, Daniel Vetter wrote:

On Wed, Oct 14, 2020 at 09:48:43AM +0800, Kever Yang wrote:

Hi Maintainers,

     Does this patch ready to merge?

Would maybe be good to get some acks from other drivers using this, then
Sandy can push to drm-misc-next.


Thanks for your reply, I can understand more 'acks' will be better, but 
there is no comments object to this patch


or any 'NAK' common for more then 3 months, maintainers should move to 
next step.



Thanks,

- Kever


-Daniel

On 2020/7/7 下午7:25, Sandy Huang wrote:

don't mask possible_crtcs if remote-point is disabled.

Signed-off-by: Sandy Huang 
---
   drivers/gpu/drm/drm_of.c | 3 +++
   1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index fdb05fbf72a0..565f05f5f11b 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -66,6 +66,9 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
uint32_t possible_crtcs = 0;
for_each_endpoint_of_node(port, ep) {
+   if (!of_device_is_available(ep))
+   continue;
+
remote_port = of_graph_get_remote_port(ep);
if (!remote_port) {
of_node_put(ep);

Looks good to me.


Reviewed-by: Kever Yang 



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/nouveau: fix memory leak in iccsense/base.c

2020-10-19 Thread Vamshi K Sthambamkadi
kmemleak report:
  unreferenced object 0x9071c65644e0 (size 96):
  comm "systemd-udevd", pid 347, jiffies 4294898424 (age 810.828s)
  hex dump (first 32 bytes):
02 01 00 00 00 00 00 00 00 00 10 00 02 04 00 00  
00 00 00 00 00 00 a0 86 00 00 00 00 00 00 00 00  
  backtrace:
[<7c0d0ac3>] __kmalloc+0x337/0x500
[<551bfaeb>] nvbios_iccsense_parse+0xf7/0x280 [nouveau]
[] nvkm_iccsense_oneinit+0x6c/0x4e0 [nouveau]
[<287e7701>] nvkm_subdev_init+0x58/0xd0 [nouveau]
[<08e4793e>] nvkm_device_init+0x118/0x1a0 [nouveau]
[<8cd3afa3>] nvkm_udevice_init+0x48/0x60 [nouveau]
[<7e047aee>] nvkm_object_init+0x43/0x110 [nouveau]
[<6c56b3a4>] nvkm_ioctl_new+0x184/0x210 [nouveau]
[<80abc890>] nvkm_ioctl+0xf0/0x190 [nouveau]
[] nvkm_client_ioctl+0x12/0x20 [nouveau]
[<0f001008>] nvif_object_ioctl+0x4f/0x60 [nouveau]
[<98d66807>] nvif_object_ctor+0xfb/0x160 [nouveau]
[] nvif_device_ctor+0x24/0x70 [nouveau]
[<878b3286>] nouveau_cli_init+0x1a3/0x460 [nouveau]
[] nouveau_drm_device_init+0x77/0x740 [nouveau]
[] nouveau_drm_probe+0x132/0x1f0 [nouveau]

Fix nvkm_iccsense_oneinit(), to free stbl.rail post iteration.

Signed-off-by: Vamshi K Sthambamkadi 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index fecfa6a..23d91b6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -291,6 +291,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
list_add_tail(>head, >rails);
}
}
+   kfree(stbl.rail);
return 0;
 }
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/4] drm/vc4: kms: Split the HVS muxing check in a separate function

2020-10-19 Thread Maxime Ripard
Hi Hoegeun,

On Mon, Oct 12, 2020 at 09:25:05PM +0900, Hoegeun Kwon wrote:
> Hi Maxime,
> 
> On 10/8/20 8:25 PM, Maxime Ripard wrote:
> > The code that assigns HVS channels during atomic_check is starting to grow
> > a bit big, let's move it into a separate function.
> >
> > Signed-off-by: Maxime Ripard 
> 
> Thanks for this patch set, I checked all patches well works.
> 
> All patches:
> 
> Reviewed-by: Hoegeun Kwon 
> Tested-by: Hoegeun Kwon 

Following some discussion with Daniel last week, this is going to be
significantly reworked for the next iteration, so I won't take your tags
(but will Cc you for the next version).

Maxime


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/5] dt-bindings: panel: add documentation for oneplus6 panel

2020-10-19 Thread Caleb Connolly
On 2020-10-09 15:05, Rob Herring wrote:
> On Wed, Oct 07, 2020 at 05:49:14PM +, Caleb Connolly wrote:
>> Document the OnePlus 6/T common panel driver, example from
>> arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>
>> Signed-off-by: Caleb Connolly 
>> ---
>>   .../display/panel/panel-oneplus6.yaml | 73 +++
>>   1 file changed, 73 insertions(+)
>>   create mode 100644 
>> Documentation/devicetree/bindings/display/panel/panel-oneplus6.yaml
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/display/panel/panel-oneplus6.yaml 
>> b/Documentation/devicetree/bindings/display/panel/panel-oneplus6.yaml
>> new file mode 100644
>> index ..23ba369cc2f5
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/display/panel/panel-oneplus6.yaml
>> @@ -0,0 +1,73 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/display/panel/panel-oneplus6.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: OnePlus 6/T panel driver
>> +
>> +description: |
>> +  The OnePlus 6 panel driver encompasses the display panels found in the
>> +  OnePlus 6 and 6T devices, the panels have almost identical behaviour and
>> +  are not used by any other devices.
>> +
>> +maintainers:
>> +  - Caleb Connolly 
>> +
>> +allOf:
>> +  - $ref: panel-common.yaml#
>> +
>> +properties:
>> +  compatible:
>> +enum:
>> +  - samsung,sofef00
>> +  - samsung,s6e3fc2x01
>> +
>> +  reg: true
>> +  reset-gpios: true
>> +  port: true
>> +
>> +  vddio-supply:
>> +description: VDDIO regulator
> A panel with a single supply can use panel-simple-dsi.yaml.
>
> 'reset-gpios' was missing, but has been added recently.
>
> Rob

Thanks, I'll move docs into panel-simple-dsi.yaml

Caleb


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()

2020-10-19 Thread Christophe Leroy




Le 19/10/2020 à 14:52, kernel test robot a écrit :

Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
7cf726a59435301046250c42131554d9ccc566b8
config: arc-randconfig-r013-20201019 (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
 wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
 chmod +x ~/bin/make.cross
 # 
https://github.com/0day-ci/linux/commit/33f0ea8bebc4132d957107f55776d8f1e02df928
 git remote add linux-review https://github.com/0day-ci/linux
 git fetch --no-tags linux-review 
Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
 git checkout 33f0ea8bebc4132d957107f55776d8f1e02df928
 # save the attached .config to linux build tree
 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

In file included from 
drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
 from 
drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26,
 from drivers/gpu/drm/amd/amdgpu/amdgpu.h:67,
 from drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:40:

drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:36:10: fatal error: 
asm/switch-to.h: No such file or directory

   36 | #include 
  |  ^
compilation terminated.



Argh ! Yes that's a typo. And anyway it fixes nothing because  
is already included.

The issue is that enable_kernel_vsx() is only declared when CONFIG_VSX is set. The simplest solution 
will probably be to declare it at all time.


Christophe



vim +36 drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h

 34 
 35 #include 
   > 36  #include 
 37 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu: ipu-v3: replace spin_lock_irqsave by spin_lock in hard IRQ

2020-10-19 Thread Tian Tao
The code has been in a irq-disabled context since it is hard IRQ. There
is no necessity to do it again.

Signed-off-by: Tian Tao 
---
 drivers/gpu/ipu-v3/ipu-image-convert.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c 
b/drivers/gpu/ipu-v3/ipu-image-convert.c
index aa1d4b6..c28764c 100644
--- a/drivers/gpu/ipu-v3/ipu-image-convert.c
+++ b/drivers/gpu/ipu-v3/ipu-image-convert.c
@@ -1737,9 +1737,8 @@ static irqreturn_t eof_irq(int irq, void *data)
struct ipu_image_convert_run *run;
irqreturn_t ret = IRQ_HANDLED;
bool tile_complete = false;
-   unsigned long flags;
 
-   spin_lock_irqsave(>irqlock, flags);
+   spin_lock(>irqlock);
 
/* get current run and its context */
run = chan->current_run;
@@ -1778,7 +1777,7 @@ static irqreturn_t eof_irq(int irq, void *data)
if (tile_complete)
ret = do_tile_complete(run);
 out:
-   spin_unlock_irqrestore(>irqlock, flags);
+   spin_unlock(>irqlock);
return ret;
 }
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/5] drm/panel/oneplus6: Add panel-oneplus6

2020-10-19 Thread Caleb Connolly
Hi Sam,

Thanks a lot for the feedback! I'll get those issues resolved for the 
next revision.

Caleb

On 2020-10-18 14:35, Sam Ravnborg wrote:
> Hi Caleb.
>
> I have missed to provice review feedback so here goes.
> There is some improvements that can be made as the infrastructure has
> evolved since the driver was started.
> But despite the number of comments below it is all trivial and the
> driver looks good in general.
>
> I look forward to see the next revision.
>
>   Sam
>
> On Wed, Oct 07, 2020 at 05:49:08PM +, Caleb Connolly wrote:
>> This commit adds support for the display panels used in the OnePlus 6 /
>> T devices.
>>
>> The OnePlus 6/T devices use different panels however they are
>> functionally identical with much of the commands being shared. The
>> panels don't appear to be used by any other devices some combine them as
>> one driver that is specific to the devices.
>>
>> The panels are: samsung,sofef00
>> and samsung,s6e3fc2x01
>>
>> Signed-off-by: Caleb Connolly 
>> ---
>>   drivers/gpu/drm/panel/Kconfig  |  12 +
>>   drivers/gpu/drm/panel/Makefile |   1 +
>>   drivers/gpu/drm/panel/panel-oneplus6.c | 418 +
> It would be better to name the driver after the panels and not their
> user. So something like panel-samsung-sofef00.
> It is OK to name it after one panel and let it support mroe than one
> panel. The Kconfig description could then expain where it is used.
>
>
>>   3 files changed, 431 insertions(+)
>>   create mode 100644 drivers/gpu/drm/panel/panel-oneplus6.c
>>
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index de2f2a452be5..d72862265400 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -229,6 +229,18 @@ config DRM_PANEL_OLIMEX_LCD_OLINUXINO
>>Say Y here if you want to enable support for Olimex Ltd.
>>LCD-OLinuXino panel.
>>
>> +config DRM_PANEL_ONEPLUS6
>> +tristate "OnePlus 6/6T Samsung AMOLED DSI command mode panels"
>> +depends on OF
>> +depends on DRM_MIPI_DSI
>> +depends on BACKLIGHT_CLASS_DEVICE
>> +select VIDEOMODE_HELPERS
>> +help
>> +  Say Y or M here if you want to enable support for the Samsung AMOLED
>> +  command mode panels found in the OnePlus 6/6T smartphones.
>> +
>> +  The panels are 2280x1080@60Hz and 2340x1080@60Hz respectively
>> +
>>   config DRM_PANEL_ORISETECH_OTM8009A
>>  tristate "Orise Technology otm8009a 480x800 dsi 2dl panel"
>>  depends on OF
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index e45ceac6286f..017539056f53 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -21,6 +21,7 @@ obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += 
>> panel-nec-nl8048hl11.o
>>   obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
>>   obj-$(CONFIG_DRM_PANEL_NOVATEK_NT39016) += panel-novatek-nt39016.o
>>   obj-$(CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO) += 
>> panel-olimex-lcd-olinuxino.o
>> +obj-$(CONFIG_DRM_PANEL_ONEPLUS6) += panel-oneplus6.o
>>   obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o
>>   obj-$(CONFIG_DRM_PANEL_OSD_OSD101T2587_53TS) += 
>> panel-osd-osd101t2587-53ts.o
>>   obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += 
>> panel-panasonic-vvx10f034n00.o
>> diff --git a/drivers/gpu/drm/panel/panel-oneplus6.c 
>> b/drivers/gpu/drm/panel/panel-oneplus6.c
>> new file mode 100644
>> index ..5e212774b1e0
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-oneplus6.c
>> @@ -0,0 +1,418 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/* Copyright (c) 2020 Caleb Connolly 
>> + * Generated with linux-mdss-dsi-panel-driver-generator from vendor device 
>> tree:
>> + *   Copyright (c) 2020, The Linux Foundation. All rights reserved.
>> + *
>> + * Caleb Connolly 
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
> Keep all linux include together.
>
>> +
>> +struct oneplus6_panel {
>> +struct drm_panel panel;
>> +struct mipi_dsi_device *dsi;
>> +struct backlight_device *backlight;
> Use drm_panel backlight support - so you can drop this variable and
> simplify some of the code below.
>
>> +struct regulator *supply;
>> +struct gpio_desc *reset_gpio;
>> +struct gpio_desc *enable_gpio;
> The enable_gpio is not used.
>
>> +const struct drm_display_mode *mode;
>> +bool prepared;
>> +bool enabled;
>> +};
>> +
>> +static inline
>> +struct oneplus6_panel *to_oneplus6_panel(struct drm_panel *panel)
>> +{
>> +return container_of(panel, struct oneplus6_panel, panel);
>> +}
>> +
>> +#define dsi_dcs_write_seq(dsi, seq...) do { \
>> +static const u8 d[] = { seq };  \
>> +int ret; 

[PATCH] drm/msm: Remove redundant null check

2020-10-19 Thread Tian Tao
clk_prepare_enable() and clk_disable_unprepare() will check
NULL clock parameter, so It is not necessary to add additional checks.

Signed-off-by: Tian Tao 
---
 drivers/gpu/drm/msm/msm_gpu.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 57ddc94..25bc654 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -175,15 +175,12 @@ static int disable_clk(struct msm_gpu *gpu)
 
 static int enable_axi(struct msm_gpu *gpu)
 {
-   if (gpu->ebi1_clk)
-   clk_prepare_enable(gpu->ebi1_clk);
-   return 0;
+   return clk_prepare_enable(gpu->ebi1_clk);
 }
 
 static int disable_axi(struct msm_gpu *gpu)
 {
-   if (gpu->ebi1_clk)
-   clk_disable_unprepare(gpu->ebi1_clk);
+   clk_disable_unprepare(gpu->ebi1_clk);
return 0;
 }
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH] drm/i915/ehl: Remove require_force_probe protection

2020-10-19 Thread Chris Wilson
Quoting Rodrigo Vivi (2020-10-19 19:29:36)
> 
> I just checked the CI picture and it looks much better indeed.
> 
> Only bad case being the gt_pm, which is also failing on other platforms.

Not nearly in the same manner. CI is indicating that there is no RC6
entry and no power saving at all; neither in the selftests nor visible
from userspace. That is a critical battery eating bug.

If there's a patch to fix it for ehl and jsl, send it to CI for proving.
-Chris
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH] drm/i915/ehl: Remove require_force_probe protection

2020-10-19 Thread Rodrigo Vivi


I just checked the CI picture and it looks much better indeed.

Only bad case being the gt_pm, which is also failing on other platforms.

So,

Acked-by: Rodrigo Vivi 



On Thu, Oct 15, 2020 at 08:41:32AM +, K, SrinivasX wrote:
> Hi Hariom,
> 
> With Sunil's help was able to see EHL achieving rc6 state. 
> Verified from sys entries, under no load to gpu rc6_residency_ms counter is 
> changing.
> Also ran all the Rodrigo mention tests and I see them passing. But with 
> i915_selftest dmesg warnings are still seen.
> 
> Thanks,
> Srinivas
> 
> -Original Message-
> From: Pandey, Hariom  
> Sent: 09 October 2020 23:39
> To: K, SrinivasX 
> Cc: Souza, Jose ; ch...@chris-wilson.co.uk; Ausmus, 
> James ; Nikula, Jani ; Roper, 
> Matthew D ; intel-...@lists.freedesktop.org; 
> dri-devel@lists.freedesktop.org; Surendrakumar Upadhyay, TejaskumarX 
> ; Vivi, Rodrigo 
> 
> Subject: RE: [Intel-gfx] [PATCH] drm/i915/ehl: Remove require_force_probe 
> protection
> 
> Hi Srinivas,
> 
> Take Sunil's help who has recently validated RC6 on EHL DRM tip and found to 
> be passing. If the WA were sporadically failing and if you confirm that RC6 
> is passing, this patch can be proceeded with. 
> 
> Thanks
> Hariom Pandey
> 
> -Original Message-
> From: Vivi, Rodrigo  
> Sent: Friday, October 9, 2020 7:09 PM
> To: K, SrinivasX 
> Cc: Souza, Jose ; ch...@chris-wilson.co.uk; Ausmus, 
> James ; Nikula, Jani ; Pandey, 
> Hariom ; Roper, Matthew D 
> ; intel-...@lists.freedesktop.org; 
> dri-devel@lists.freedesktop.org; Surendrakumar Upadhyay, TejaskumarX 
> 
> Subject: Re: [Intel-gfx] [PATCH] drm/i915/ehl: Remove require_force_probe 
> protection
> 
> 
> 
> > On Oct 9, 2020, at 1:31 AM, K, SrinivasX  wrote:
> > 
> > Hi Rodrigo,
> > 
> > How do we get W/A and rc6 changes in, do you have any details?
> 
> I told based on what I was seeing on 
> https://intel-gfx-ci.01.org/tree/drm-tip/drmtip-alt.html?
> focusing on the issues that are exclusively for ehl and not happening on 
> other platforms.
> 
> It looks like workarounds are fine there now. so I'm not sure if it was 
> sporadic thing that day.
> 
> for the rc6 there are a few testcases failing around it:
> https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_675/fi-ehl-1/igt@i915_pm_rc6_reside...@rc6-fence.html
> https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_675/fi-ehl-1/igt@i915_pm_rc6_reside...@rc6-idle.html
> https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_675/fi-ehl-1/igt@i915_selftest@live@gt_pm.html#dmesg-warnings415
> 
> > 
> > Thanks,
> > Srinivas
> > 
> > -Original Message-
> > From: Souza, Jose 
> > Sent: 06 October 2020 23:33
> > To: Vivi, Rodrigo ; ch...@chris-wilson.co.uk
> > Cc: Ausmus, James ; Nikula, Jani 
> > ; Pandey, Hariom ; 
> > Roper, Matthew D ; 
> > intel-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org; K, 
> > SrinivasX ; Surendrakumar Upadhyay, TejaskumarX 
> > 
> > Subject: Re: [Intel-gfx] [PATCH] drm/i915/ehl: Remove 
> > require_force_probe protection
> > 
> > On Tue, 2020-10-06 at 10:55 -0700, Vivi, Rodrigo wrote:
> >> 
> >>> On Oct 6, 2020, at 10:48 AM, Chris Wilson  
> >>> wrote:
> >>> 
> >>> Quoting Souza, Jose (2020-10-06 18:46:45)
>  +Rodrigo and Jani
>  
>  On Tue, 2020-10-06 at 14:56 +, Kamati Srinivas wrote:
> > Removing force probe protection from EHL platform. Did not observe 
> > warnings, errors, flickering or any visual defects while doing 
> > ordinary tasks like browsing and editing documents in a two 
> > monitor setup.
>  
>  One of the requirements was also to have CI BAT all green and 
>  shards as green is possible but EHL don't show up in CI results, we 
>  actually have one single EHL machine in CI but I guess it is not able to 
>  run all tests that shards do:
>  https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9097/filelist.html
> >>> 
> >>> https://intel-gfx-ci.01.org/tree/drm-tip/drmtip-alt.html
> >> 
> >> we are really close to that point. We just need to fix some w/a and
> >> rc6 issues before applying this change.
> >> 
> >>> -Chris
> >> 
> > 
> > Huum okay we have drm-tip results for EHL but if someone sends a patch that 
> > breaks EHL it will not be caught in pre-merge testing.
> > 
> 
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH] drm/i915/jsl: Remove require_force_probe protection

2020-10-19 Thread Rodrigo Vivi
On Thu, Oct 15, 2020 at 08:53:08AM +, Kamati Srinivas wrote:
> Removing force probe protection from JSL platform. Did
> not observe warnings, errors, flickering or any visual
> defects while doing ordinary tasks like browsing and
> editing documents in a two monitor setup.

I'm afraid we first need to get a JSL on CI. Or what am I missing?

> 
> Signed-off-by: Kamati Srinivas 
> ---
>  drivers/gpu/drm/i915/i915_pci.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 16d4e72bed09..a61195a1883a 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -849,7 +849,6 @@ static const struct intel_device_info ehl_info = {
>  static const struct intel_device_info jsl_info = {
>   GEN11_FEATURES,
>   PLATFORM(INTEL_JASPERLAKE),
> - .require_force_probe = 1,
>   .platform_engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(VCS0) | BIT(VECS0),
>   .ppgtt_size = 36,
>  };
> -- 
> 2.25.1
> 
> ___
> Intel-gfx mailing list
> intel-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: amdgpu: Manual Card Configuration Change

2020-10-19 Thread Alex Deucher
On Sun, Oct 18, 2020 at 4:32 PM Josh Fuhs  wrote:
>
> Hello all,
>
> Regarding amdgpu, I've been using some Radeon 5700XTs for compute work with 
> kernels through 5.8.14. I recently tried kernel 5.9.0, and found that the 
> following is no longer allowed:
>
> echo "m 1 200" | sudo tee /sys/class/drm/card0/device/pp_od_clk_voltage
>
> Is this an expected change? If so, where should I look for documentation 
> regarding how to manually configure these cards with this kernel. Note, I've 
> had this working with 5.8 kernels for months.
>

It was a bug.  Fixed in 5.9.1.

Alex
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: remove unneeded break

2020-10-19 Thread Sam Ravnborg
Hi Tom
On Mon, Oct 19, 2020 at 09:31:15AM -0700, t...@redhat.com wrote:
> From: Tom Rix 
> 
> A break is not needed if it is preceded by a return or break
> 
> Signed-off-by: Tom Rix 

Looks good and builds with no warnings.

One of the diffs made me - "oh this looks wrong". But after I looked again
it was right and the resulting code is more readable - so good.

Acked-by: Sam Ravnborg 

Was tempted to just apply to drm-misc-next but will give others the
opportunity to chime in.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 0/2] drm: add DisplayPort connector

2020-10-19 Thread Tomi Valkeinen
Hi,

This series adds the DT bindings and a driver for DisplayPort connector.

I have previously sent v1 and v2 with only the bindings. The bindings
are unchanged, but I updated the patch description slightly for eDP and
DP++.

 Tomi

Tomi Valkeinen (2):
  dt-bindings: dp-connector: add binding for DisplayPort connector
  drm/bridge: display-connector: add DP support

 .../display/connector/dp-connector.yaml   | 55 +++
 drivers/gpu/drm/bridge/display-connector.c| 46 +++-
 2 files changed, 99 insertions(+), 2 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/display/connector/dp-connector.yaml

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 2/2] drm/bridge: display-connector: add DP support

2020-10-19 Thread Tomi Valkeinen
Add DP support to display-connector driver. The driver will support HPD
via a GPIO and DP PWR.

DP PWR will be enabled at probe, which is not optimal, but I'm not sure
what would be a good place to enable and disable DP PWR. Perhaps
attach/detach, but I don't know if enabling HW is something that attach
is supposed to do.

In any case, I don't think there's much difference in power consumption
between the version in this patch and enabling the regulator later: if
the driver probes, supposedly it will attach very soon afterwards, and
we need to enable the DP PWR as soon as possible.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/bridge/display-connector.c | 46 +-
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/display-connector.c 
b/drivers/gpu/drm/bridge/display-connector.c
index 4d278573cdb9..04362feccd75 100644
--- a/drivers/gpu/drm/bridge/display-connector.c
+++ b/drivers/gpu/drm/bridge/display-connector.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,6 +21,8 @@ struct display_connector {
 
struct gpio_desc*hpd_gpio;
int hpd_irq;
+
+   struct regulator*dp_pwr;
 };
 
 static inline struct display_connector *
@@ -172,11 +175,12 @@ static int display_connector_probe(struct platform_device 
*pdev)
of_property_read_string(pdev->dev.of_node, "label", );
 
/*
-* Get the HPD GPIO for DVI and HDMI connectors. If the GPIO can provide
+* Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can 
provide
 * edge interrupts, register an interrupt handler.
 */
if (type == DRM_MODE_CONNECTOR_DVII ||
-   type == DRM_MODE_CONNECTOR_HDMIA) {
+   type == DRM_MODE_CONNECTOR_HDMIA ||
+   type == DRM_MODE_CONNECTOR_DisplayPort) {
conn->hpd_gpio = devm_gpiod_get_optional(>dev, "hpd",
 GPIOD_IN);
if (IS_ERR(conn->hpd_gpio)) {
@@ -223,6 +227,38 @@ static int display_connector_probe(struct platform_device 
*pdev)
}
}
 
+   /* Get the DP PWR for DP connector */
+   if (type == DRM_MODE_CONNECTOR_DisplayPort) {
+   int r;
+
+   conn->dp_pwr = devm_regulator_get_optional(>dev, 
"dp-pwr");
+
+   if (IS_ERR(conn->dp_pwr)) {
+   r = PTR_ERR(conn->dp_pwr);
+
+   switch (r) {
+   case -ENODEV:
+   conn->dp_pwr = NULL;
+   break;
+
+   case -EPROBE_DEFER:
+   return -EPROBE_DEFER;
+
+   default:
+   dev_err(>dev, "failed to get DP PWR 
regulator: %d\n", r);
+   return r;
+   }
+   }
+
+   if (conn->dp_pwr) {
+   r = regulator_enable(conn->dp_pwr);
+   if (r) {
+   dev_err(>dev, "failed to enable DP PWR 
regulator: %d\n", r);
+   return r;
+   }
+   }
+   }
+
conn->bridge.funcs = _connector_bridge_funcs;
conn->bridge.of_node = pdev->dev.of_node;
 
@@ -251,6 +287,9 @@ static int display_connector_remove(struct platform_device 
*pdev)
 {
struct display_connector *conn = platform_get_drvdata(pdev);
 
+   if (conn->dp_pwr)
+   regulator_disable(conn->dp_pwr);
+
drm_bridge_remove(>bridge);
 
if (!IS_ERR(conn->bridge.ddc))
@@ -275,6 +314,9 @@ static const struct of_device_id display_connector_match[] 
= {
}, {
.compatible = "vga-connector",
.data = (void *)DRM_MODE_CONNECTOR_VGA,
+   }, {
+   .compatible = "dp-connector",
+   .data = (void *)DRM_MODE_CONNECTOR_DisplayPort,
},
{},
 };
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 1/2] dt-bindings: dp-connector: add binding for DisplayPort connector

2020-10-19 Thread Tomi Valkeinen
Add binding for DisplayPort connector. A few notes:

* Similar to hdmi-connector, it has hpd-gpios as an optional property,
  as the HPD could also be handled by, e.g., the DP bridge.

* dp-pwr-supply, which provides 3.3V on DP_PWR pin, is optional, as it
  is not strictly required: standard DP cables do not even have the pin
  connected.

* Connector type. Full size and mini connectors are identical except for
  the connector size and form, so I believe there is no functional need
  for this property. But similar to 'label' property, it might be used
  to present information about the connector to the userspace.

* No eDP. There's really no "eDP connector", as it's always a custom
  made connection between the DP and the DP panel, although the eDP spec
  does offer a few suggested pin setups. So possibly there is no need for
  edp-connector binding, but even if there is, I don't want to guess what
  it could look like, and could it be part of the dp-connector binding.

* No DP++. I'm not familiar with DP++. DP++ might need an i2c bus added
  to the bindings.

Signed-off-by: Tomi Valkeinen 
---
 .../display/connector/dp-connector.yaml   | 55 +++
 1 file changed, 55 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/connector/dp-connector.yaml

diff --git 
a/Documentation/devicetree/bindings/display/connector/dp-connector.yaml 
b/Documentation/devicetree/bindings/display/connector/dp-connector.yaml
new file mode 100644
index ..b5fc3e52899e
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/connector/dp-connector.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/connector/dp-connector.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DisplayPort Connector
+
+maintainers:
+  - Tomi Valkeinen 
+
+properties:
+  compatible:
+const: dp-connector
+
+  label: true
+
+  type:
+enum:
+  - full-size
+  - mini
+
+  hpd-gpios:
+description: A GPIO line connected to HPD
+maxItems: 1
+
+  dp-pwr-supply:
+description: Power supply for the DP_PWR pin
+maxItems: 1
+
+  port:
+description: Connection to controller providing DP signals
+
+required:
+  - compatible
+  - type
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+connector {
+compatible = "dp-connector";
+label = "dp0";
+type = "full-size";
+
+port {
+dp_connector_in: endpoint {
+remote-endpoint = <_out>;
+};
+};
+};
+
+...
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: It appears drm-next TTM cleanup broke something . . .

2020-10-19 Thread Christian König

Hi Kevin,


OpenChrome DDX was sending TTM_PL_FLAG_* based flags to OpenChrome DRM.


Ugh, that would be an absolute no-go for upstreaming.


Is it too much to ask for using more BUG_ON null pointer assertions for TTM 
callbacks?


I don't think that this is useful at all. See a BUG_ON() has the same 
result as a NULL pointer dereference.



While that may be true, I do plan to implement acceleration later, and this is 
why I do not want to settle with the GEM VRAM helpers.


TTM is quite a mess and the effort here is essential to clean it up and 
kill most of the driver specific workarounds we have in there.


As the maintainer of all of this I would probably reject any newly added 
driver which is using the layer directly instead of the VRAM GEM wrapper.


Regards,
Christian.

Am 19.10.20 um 18:20 schrieb Kevin Brace:

Hi Christian,

I looked into a few more things, and figured out why OpenChrome DRM was not 
booting X Server.
Now the situation is under control in my side of the world (OpenChrome 
development world), and I got X Server working again with drm-next 5.10 code 
and OpenChrome DRM.
Code will be committed into OpenChrome DRM upstream repository's drm-next-5.10 
branch in the next few days.
 I can see that OpenChrome DRM "just happened to" work without 
ttm_tt_create/destroy callbacks being specified.
I can fix this issue easily.
The other issue I was facing was that commit 
48e07c23cbeba2a2cda7ca73be0015e727818536 (drm/ttm: nuke memory type flags) 
discontinued TTM_PL_FLAG_* flags.
This caused incompatibility between OpenChrome DDX and the updated OpenChrome 
DRM that incorporated the changes made with commit 48e07c2.
OpenChrome DDX was sending TTM_PL_FLAG_* based flags to OpenChrome DRM.
I changed OpenChrome DDX code to use TTM_PL_* instead for allocating memory via 
TTM, and OpenChrome DRM based Linux kernel was able to boot X Server properly.
Again, the code change to the DDX will happen in a few days.
 Before I moved on from this issue, I will like to ask for one request 
regarding TTM and its callbacks.
Is it too much to ask for using more BUG_ON null pointer assertions for TTM 
callbacks?
Although I did not bring it up with you back then, I did get hit with an issue 
similar to this 3 years ago.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fopenchrome%2Fdrm-openchrome%2Fcommit%2F%3Fh%3Ddrm-next-4.13%26id%3D3c08ec601bb1ccd5ff58a9101317b728aa7204bddata=02%7C01%7Cchristian.koenig%40amd.com%7C053fff6809b14e2976d408d8744aee28%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637387212462965991sdata=wmGsqFinBsTLJSgp6G5ygoW7J%2Fppph4CzgO9q7q4h34%3Dreserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fopenchrome%2Fdrm-openchrome%2Fcommit%2F%3Fh%3Ddrm-next-4.13%26id%3D2064175f977d9859831be653df16e3ea10415a8adata=02%7C01%7Cchristian.koenig%40amd.com%7C053fff6809b14e2976d408d8744aee28%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637387212462965991sdata=1Pl3PZ%2FY8P2aFE9in3oYCgl1CW6Nq%2FIQiHe75U8Dp0I%3Dreserved=0


I did not send you an e-mail about it, I do recall complaining to Alex Deucher 
about the above io_mem_pfn null pointer bug at XDC2017 (I did attend it, and I 
presented about the state of OpenChrome Project.).
I brought this up with Alex because I stuck for more than 2 weeks to figure out 
the issue (the commit for overcoming io_mem_pfn callback issue was made on 
2017-09-13, but the commit prior to that was on 2017-08-28).

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fopenchrome%2Fdrm-openchrome%2Flog%2F%3Fh%3Ddrm-next-4.13%26ofs%3D50data=02%7C01%7Cchristian.koenig%40amd.com%7C053fff6809b14e2976d408d8744aee28%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637387212462965991sdata=zsLWqjAPDFhokHptCAHl4XRCZJSjcWsnvAimoUyb7Mk%3Dreserved=0


Anyway, someone else got hit by the same issue a month or two later

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Farchives%2Fdri-devel%2F2017-November%2F159002.htmldata=02%7C01%7Cchristian.koenig%40amd.com%7C053fff6809b14e2976d408d8744aee28%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637387212462965991sdata=wbkUKUL0XVOviw%2Bvt0WFGvSyJiOF%2Bdz%2FZVSMSPTwuwI%3Dreserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Farchives%2Fdri-devel%2F2017-December%2F161168.htmldata=02%7C01%7Cchristian.koenig%40amd.com%7C053fff6809b14e2976d408d8744aee28%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637387212462965991sdata=nJ8n0lFRTX%2FoxPsKCvV%2FYvtUvmvzxLGVikUWtBsZy5U%3Dreserved=0


These are the commits that fixed the issue.


[PATCH] drm: remove unneeded break

2020-10-19 Thread trix
From: Tom Rix 

A break is not needed if it is preceded by a return or break

Signed-off-by: Tom Rix 
---
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 5 -
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/pll.c   | 1 -
 drivers/gpu/drm/nouveau/nvkm/subdev/clk/mcp77.c  | 3 ---
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv50.c | 1 -
 drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c  | 1 -
 drivers/gpu/drm/qxl/qxl_ioctl.c  | 1 -
 6 files changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 38672f9e5c4f..bbe4e60dfd08 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -794,21 +794,16 @@ static int mgag200_crtc_set_plls(struct mga_device *mdev, 
long clock)
case G200_SE_A:
case G200_SE_B:
return mga_g200se_set_plls(mdev, clock);
-   break;
case G200_WB:
case G200_EW3:
return mga_g200wb_set_plls(mdev, clock);
-   break;
case G200_EV:
return mga_g200ev_set_plls(mdev, clock);
-   break;
case G200_EH:
case G200_EH3:
return mga_g200eh_set_plls(mdev, clock);
-   break;
case G200_ER:
return mga_g200er_set_plls(mdev, clock);
-   break;
}
 
misc = RREG8(MGA_MISC_IN);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/pll.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/pll.c
index 350f10a3de37..2ec84b8a3b3a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/pll.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/pll.c
@@ -123,7 +123,6 @@ pll_map(struct nvkm_bios *bios)
case NV_20:
case NV_30:
return nv04_pll_mapping;
-   break;
case NV_40:
return nv40_pll_mapping;
case NV_50:
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/mcp77.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/mcp77.c
index efa50274df97..4884eb4a9221 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/mcp77.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/mcp77.c
@@ -140,17 +140,14 @@ mcp77_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
break;
case nv_clk_src_mem:
return 0;
-   break;
case nv_clk_src_vdec:
P = (read_div(clk) & 0x0700) >> 8;
 
switch (mast & 0x0040) {
case 0x0040:
return nvkm_clk_read(>base, nv_clk_src_core) >> P;
-   break;
default:
return 50 >> P;
-   break;
}
break;
default:
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv50.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv50.c
index 2ccb4b6be153..7b1eb44ff3da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv50.c
@@ -171,7 +171,6 @@ nv50_ram_timing_read(struct nv50_ram *ram, u32 *timing)
break;
default:
return -ENOSYS;
-   break;
}
 
T(WR) = ((timing[1] >> 24) & 0xff) - 1 - T(CWL);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
index e01746ce9fc4..1156634533f9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
@@ -90,7 +90,6 @@ gk104_top_oneinit(struct nvkm_top *top)
case 0x0010: B_(NVDEC ); break;
case 0x0013: B_(CE); break;
case 0x0014: C_(GSP   ); break;
-   break;
default:
break;
}
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 5cea6eea72ab..2072ddc9549c 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -160,7 +160,6 @@ static int qxl_process_single_command(struct qxl_device 
*qdev,
default:
DRM_DEBUG("Only draw commands in execbuffers\n");
return -EINVAL;
-   break;
}
 
if (cmd->command_size > PAGE_SIZE - sizeof(union qxl_release_info))
-- 
2.18.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: It appears drm-next TTM cleanup broke something . . .

2020-10-19 Thread Kevin Brace
Hi Christian,

I looked into a few more things, and figured out why OpenChrome DRM was not 
booting X Server.
Now the situation is under control in my side of the world (OpenChrome 
development world), and I got X Server working again with drm-next 5.10 code 
and OpenChrome DRM.
Code will be committed into OpenChrome DRM upstream repository's drm-next-5.10 
branch in the next few days.
I can see that OpenChrome DRM "just happened to" work without 
ttm_tt_create/destroy callbacks being specified.
I can fix this issue easily.
The other issue I was facing was that commit 
48e07c23cbeba2a2cda7ca73be0015e727818536 (drm/ttm: nuke memory type flags) 
discontinued TTM_PL_FLAG_* flags.
This caused incompatibility between OpenChrome DDX and the updated OpenChrome 
DRM that incorporated the changes made with commit 48e07c2.
OpenChrome DDX was sending TTM_PL_FLAG_* based flags to OpenChrome DRM.
I changed OpenChrome DDX code to use TTM_PL_* instead for allocating memory via 
TTM, and OpenChrome DRM based Linux kernel was able to boot X Server properly.
Again, the code change to the DDX will happen in a few days.
Before I moved on from this issue, I will like to ask for one request 
regarding TTM and its callbacks.
Is it too much to ask for using more BUG_ON null pointer assertions for TTM 
callbacks?
Although I did not bring it up with you back then, I did get hit with an issue 
similar to this 3 years ago.

https://cgit.freedesktop.org/openchrome/drm-openchrome/commit/?h=drm-next-4.13=3c08ec601bb1ccd5ff58a9101317b728aa7204bd
https://cgit.freedesktop.org/openchrome/drm-openchrome/commit/?h=drm-next-4.13=2064175f977d9859831be653df16e3ea10415a8a


I did not send you an e-mail about it, I do recall complaining to Alex Deucher 
about the above io_mem_pfn null pointer bug at XDC2017 (I did attend it, and I 
presented about the state of OpenChrome Project.).
I brought this up with Alex because I stuck for more than 2 weeks to figure out 
the issue (the commit for overcoming io_mem_pfn callback issue was made on 
2017-09-13, but the commit prior to that was on 2017-08-28).

https://cgit.freedesktop.org/openchrome/drm-openchrome/log/?h=drm-next-4.13=50


Anyway, someone else got hit by the same issue a month or two later

https://lists.freedesktop.org/archives/dri-devel/2017-November/159002.html
https://lists.freedesktop.org/archives/dri-devel/2017-December/161168.html


These are the commits that fixed the issue.

https://cgit.freedesktop.org/drm/drm/commit/?id=ea642c3216cb2a60d1c0e760ae47ee85c9c16447
https://cgit.freedesktop.org/drm/drm/commit/?id=c67fa6edc8b11afe22c88a23963170bf5f151acf


If you compare the commit date, I figured it out io_mem_pfn null pointer bug 2 
to 3 months earlier.
I think the problem we got with the latest code change to the TTM is, many TTM 
callbacks do not check for a null pointer for mandatory callbacks.
Also, the ttm_bo_driver struct comment section inside ttm_bo_driver.h does not 
make it 100% clear that what is mandatory and what is not.
If these were done, I am sure I would have left ttm_tt_create/destroy callbacks 
intact.

https://cgit.freedesktop.org/openchrome/drm-openchrome/commit/?h=drm-next-5.10=64947142a1cf8b83faa73da7aa35a17f6a24568a
(scroll down to openchrome/openchrome_ttm.c)


Regarding your suggestion that I should abandon OpenChrome DRM's current 
GEM / TTM implementation and instead I should use the GEM VRAM helpers, since I 
was able to figure out the issues with some suggestions from you and Dave, I do 
not think it is worth switching to GEM VRAM helpers at this point.
Obviously, the current implementation does not support acceleration, hence, it 
appears to be a good candidate for switching to GEM VRAM helpers.
While that may be true, I do plan to implement acceleration later, and this is 
why I do not want to settle with the GEM VRAM helpers.

Regards,

Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com


> Sent: Monday, October 19, 2020 at 3:13 AM
> From: "Christian König" 
> To: "Kevin Brace" , "Dave Airlie" , 
> "dri-devel" 
> Subject: Re: It appears drm-next TTM cleanup broke something . . .
>
> Hi Kevin,
> 
> the basic problem you are facing is that ttm_tt_create/destroy is 
> mandatory (It always was). You need an implementation or otherwise you 
> won't be able to use the system domain (additional to the optional GTT 
> domain).
> 
> My best guess is that the difference is that we now force to initiate 
> the system domain for all drivers.
> 
> If that is correct you just that you never ran into because you never 
> correctly initialized TTM to support buffer moves.
> 
> I'm not sure what exactly the OpenChrome DRM driver is doing, but I 
> strongly suggest to just drop TTM support completely and use the GEM 
> VRAM helper layer instead.
> 
> Regards,
> Christian.
> 
> Am 19.10.20 um 09:23 schrieb Kevin Brace:
> > Hi Dave,
> >
> > Yeah, with the workaround I mentioned in my previous e-mail, OpenChrome DRM 
> > does not crash for 

Re: [PATCH 0/5] drm/tidss: Use new connector model for tidss

2020-10-19 Thread Tomi Valkeinen
Hi Nikhil,

On 16/10/2020 13:39, Nikhil Devshatwar wrote:
> This series moves the tidss to using new connectoe model, where the 
> SoC driver (tidss) creates the connector and all the bridges are 
> attached with the flag DRM_BRIDGE_ATTACH_NO_CONNECTOR
> 
> Since the bridges do not create the connector, the bus format and
> bus_flag is set after the format negotiation.
> Support format negotiations in the tfp410 and mhdp bridge drivers.
> 
> Nikhil Devshatwar (5):
>   drm/tidss: Move to newer connector model
>   drm/tidss: Set bus_format correctly from bridge/connector
>   drm: bridge: Propagate the bus flags from bridge->timings
>   drm/bridge: tfp410: Support format negotiation
>   drm/bridge: mhdp8564: Support format negotiation

I think the patch order could be a bit different. If you first change the tidss 
to use the new
connector model, and only afterwards fix the bridges we use, then there's a 
time when the displays
won't work.

Also, with J7 EVM and DP, when I unload the modules I see:

[   43.238895] irq 31: nobody cared (try booting with the "irqpoll" option)
[   43.245591] CPU: 0 PID: 349 Comm: irq/31-mhdp8546 Not tainted 
5.9.0-rc5-00605-g08a291316f86 #4
[   43.254186] Hardware name: Texas Instruments K3 J721E SoC (DT)
[   43.260006] Call trace:
[   43.262453]  dump_backtrace+0x0/0x1d8
[   43.266107]  show_stack+0x18/0x28
[   43.269416]  dump_stack+0xe0/0x14c
[   43.272810]  __report_bad_irq+0x4c/0xdc
[   43.276637]  note_interrupt+0x2cc/0x388
[   43.280465]  handle_irq_event_percpu+0x88/0x90
[   43.284898]  handle_irq_event+0x48/0xf8
[   43.288725]  handle_fasteoi_irq+0xcc/0x180
[   43.292811]  generic_handle_irq+0x30/0x48
[   43.296811]  __handle_domain_irq+0x94/0x108
[   43.300986]  gic_handle_irq+0x60/0x158
[   43.304726]  el1_irq+0xbc/0x180
[   43.307862]  _raw_spin_unlock_irq+0x48/0x90
[   43.312035]  irq_finalize_oneshot.part.0+0x68/0x108
[   43.316903]  irq_thread_fn+0x60/0xa0
[   43.320469]  irq_thread+0x1b8/0x248
[   43.323949]  kthread+0x128/0x160
[   43.327169]  ret_from_fork+0x10/0x34
[   43.330735] handlers:
[   43.333020] [<5367c4f9>] irq_default_primary_handler threaded 
[<7e02b601>]
cdns_mhdp_irq_handler [cdns_mhdp8546]
[   43.344607] Disabling IRQ #31

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/2 RESEND] docs: fb: Add font_6x8 to available built-in fonts

2020-10-19 Thread Daniel Vetter
On Sun, Oct 18, 2020 at 04:54:01PM -0400, Peilin Ye wrote:
> Recently we added a new 6x8 font in commit e2028c8e6bf9 ("lib/fonts: add
> font 6x8 for OLED display"). Add its name to the "compiled-in fonts"
> list.
> 
> Signed-off-by: Peilin Ye 
> ---
> Resending +Cc: dri-devel, sorry if I spammed.

Both this and patch 1/2 with the actual bugfix merged to
drm-misc-next-fixes, should still make it into the merge window before
-rc1.

Thanks, Daniel

> 
>  Documentation/fb/fbcon.rst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Documentation/fb/fbcon.rst b/Documentation/fb/fbcon.rst
> index 9aad964b767c..57f66de2f7e1 100644
> --- a/Documentation/fb/fbcon.rst
> +++ b/Documentation/fb/fbcon.rst
> @@ -81,7 +81,7 @@ C. Boot options
>  1. fbcon=font:
>  
>   Select the initial font to use. The value 'name' can be any of the
> - compiled-in fonts: 10x18, 6x10, 7x14, Acorn8x8, MINI4x6,
> + compiled-in fonts: 10x18, 6x10, 6x8, 7x14, Acorn8x8, MINI4x6,
>   PEARL8x8, ProFont6x11, SUN12x22, SUN8x16, TER16x32, VGA8x16, VGA8x8.
>  
>   Note, not all drivers can handle font with widths not divisible by 8,
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/drm_vblank: use drm_warn_once() to warn undefined mode timing

2020-10-19 Thread Daniel Vetter
On Fri, Oct 16, 2020 at 07:46:41PM +0800, Shawn Guo wrote:
> On Fri, Oct 16, 2020 at 11:30:04AM +0200, Daniel Vetter wrote:
> > On Fri, Oct 16, 2020 at 10:54 AM Shawn Guo  wrote:
> > >
> > > On Fri, Oct 16, 2020 at 09:58:46AM +0200, Daniel Vetter wrote:
> > > > On Fri, Oct 16, 2020 at 9:13 AM Shawn Guo  wrote:
> > > > >
> > > > > Commit 5caa0feafcc6 ("drm/vblank: Lock down vblank->hwmode more") 
> > > > > added
> > > > > WARN_ON_ONCE() for atomic drivers to warn the case that vsync is 
> > > > > enabled
> > > > > before a mode has been set on CRTC.  This happens sometimes during the
> > > > > initial mode setting of a CRTC.  It also happens on Android running 
> > > > > HWC2
> > > > > backed with drm_hwcomposer, where HWC2::SetVsyncEnabled could be 
> > > > > called
> > > > > before the atomic mode setting on CRTC happens.
> > > > >
> > > > > In this case, there is nothing really bad to happen as kernel function
> > > > > returns as no-op.  So using WARN() version might be overkilled,
> > > > > considering some user space crash reporting services may treat kernel
> > > > > WARNINGS as crashes.  Let's drop WARN_ON_ONCE() and change 
> > > > > drm_dbg_core()
> > > > > to drm_warn_once() for warning undefined mode timing.
> > > >
> > > > This indicates a bug in your driver. Please fix it there, not by
> > > > shutting up the core code complaining about that. Either you're
> > > > getting vblank timestamps when the vblank isn't set up yet
> > > > (drm_crtc_vblank_on/off) or there's some other race going on in your
> > > > driver code resulting in this.
> > >
> > > Thanks for the comment, Daniel.
> > >
> > > I'm hitting this warning on an Android running drm_hwcomposer.  I'm
> > > indeed getting vblank timestamps request before drm_crtc_vblank_on() is
> > > called.  I'm not sure this is a bug or race condition in the driver
> > > code, as both vblank timestamps and on/off requests are coming from user
> > > space ioctl for my case.  @Sean, that means the problem is in Android
> > > drm_hwcomposer code?
> > 
> > vblank request when the crtc is off should be rejected. Most drivers
> > got this wrong before I added the required drm_crtc_vblank_reset()
> > into atomic helpers in 51f644b40b4b ("drm/atomic-helper: reset vblank
> > on crtc reset")
> > 
> > Please make sure you have that, and that drm_crtc_vblank_reset is run
> > at driver load time. If the crtc is off, vblank ioctl should be
> > rejected. So this is definitely not a userspace bug, still a driver
> > bug. In general, userspace is not allowed to do anything that results
> > in dmesg spam at normal log levels. Anytime that happens it's a kernel
> > bug. And if it's a warning in core code, it's most likely a driver bug
> > since the core code tends to be better debugged about these things.
> > But there's ofc exceptions.
> 
> Indeed!  Adding drm_crtc_vblank_reset() into driver crtc reset hook
> removes the WARNING for me.  Really appreciate your comments, Daniel!

This should work automatically if you're using the atomic state helpers.
Please try to unify as much as possible, so you're not missing any future
bugfixes in this area. Although I thought I've completely reviewed all
drivers to fix as many as possible for this bug. Are you on some older
kernel that didn't have this? Maybe good idea to submit the bugfix in
upstream to stable, if that's the case.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 05/10] drm/ttm: Add vmap/vunmap to TTM and TTM GEM helpers

2020-10-19 Thread Daniel Vetter
On Mon, Oct 19, 2020 at 11:45:05AM +0200, Christian König wrote:
> Hi Thomas,
> 
> [SNIP]
> > > >    +int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map 
> > > > *map)
> > > > +{
> > > > +    struct ttm_resource *mem = >mem;
> > > > +    int ret;
> > > > +
> > > > +    ret = ttm_mem_io_reserve(bo->bdev, mem);
> > > > +    if (ret)
> > > > +    return ret;
> > > > +
> > > > +    if (mem->bus.is_iomem) {
> > > > +    void __iomem *vaddr_iomem;
> > > > +    unsigned long size = bo->num_pages << PAGE_SHIFT;
> > > Please use uint64_t here and make sure to cast bo->num_pages before
> > > shifting.
> > I thought the rule of thumb is to use u64 in source code. Yet TTM only
> > uses uint*_t types. Is there anything special about TTM?
> 
> My last status is that you can use both and my personal preference is to use
> the uint*_t types because they are part of a higher level standard.

Yeah the only hard rule is that in uapi headers you need to use the __u64
and similar typedefs, to avoid cluttering the namespace for unrelated
stuff in userspace.

In the kernel c99 types are perfectly fine, and I think slowly on the
rise.
-Daniel

> 
> > > We have an unit tests of allocating a 8GB BO and that should work on a
> > > 32bit machine as well :)
> > > 
> > > > +
> > > > +    if (mem->bus.addr)
> > > > +    vaddr_iomem = (void *)(((u8 *)mem->bus.addr));
> > I after reading the patch again, I realized that this is the
> > 'ttm_bo_map_premapped' case and it's missing from _vunmap(). I see two
> > options here: ignore this case in _vunmap(), or do an ioremap()
> > unconditionally. Which one is preferable?
> 
> ioremap would be very very bad, so we should just do nothing.
> 
> Thanks,
> Christian.
> 
> > 
> > Best regards
> > Thomas
> > 
> > > > +    else if (mem->placement & TTM_PL_FLAG_WC)
> > > I've just nuked the TTM_PL_FLAG_WC flag in drm-misc-next. There is a new
> > > mem->bus.caching enum as replacement.
> > > 
> > > > +    vaddr_iomem = ioremap_wc(mem->bus.offset, size);
> > > > +    else
> > > > +    vaddr_iomem = ioremap(mem->bus.offset, size);
> > > > +
> > > > +    if (!vaddr_iomem)
> > > > +    return -ENOMEM;
> > > > +
> > > > +    dma_buf_map_set_vaddr_iomem(map, vaddr_iomem);
> > > > +
> > > > +    } else {
> > > > +    struct ttm_operation_ctx ctx = {
> > > > +    .interruptible = false,
> > > > +    .no_wait_gpu = false
> > > > +    };
> > > > +    struct ttm_tt *ttm = bo->ttm;
> > > > +    pgprot_t prot;
> > > > +    void *vaddr;
> > > > +
> > > > +    BUG_ON(!ttm);
> > > I think we can drop this, populate will just crash badly anyway.
> > > 
> > > > +
> > > > +    ret = ttm_tt_populate(bo->bdev, ttm, );
> > > > +    if (ret)
> > > > +    return ret;
> > > > +
> > > > +    /*
> > > > + * We need to use vmap to get the desired page protection
> > > > + * or to make the buffer object look contiguous.
> > > > + */
> > > > +    prot = ttm_io_prot(mem->placement, PAGE_KERNEL);
> > > The calling convention has changed on drm-misc-next as well, but should
> > > be trivial to adapt.
> > > 
> > > Regards,
> > > Christian.
> > > 
> > > > +    vaddr = vmap(ttm->pages, bo->num_pages, 0, prot);
> > > > +    if (!vaddr)
> > > > +    return -ENOMEM;
> > > > +
> > > > +    dma_buf_map_set_vaddr(map, vaddr);
> > > > +    }
> > > > +
> > > > +    return 0;
> > > > +}
> > > > +EXPORT_SYMBOL(ttm_bo_vmap);
> > > > +
> > > > +void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct dma_buf_map
> > > > *map)
> > > > +{
> > > > +    if (dma_buf_map_is_null(map))
> > > > +    return;
> > > > +
> > > > +    if (map->is_iomem)
> > > > +    iounmap(map->vaddr_iomem);
> > > > +    else
> > > > +    vunmap(map->vaddr);
> > > > +    dma_buf_map_clear(map);
> > > > +
> > > > +    ttm_mem_io_free(bo->bdev, >mem);
> > > > +}
> > > > +EXPORT_SYMBOL(ttm_bo_vunmap);
> > > > +
> > > >    static int ttm_bo_wait_free_node(struct ttm_buffer_object *bo,
> > > >     bool dst_use_tt)
> > > >    {
> > > > diff --git a/include/drm/drm_gem_ttm_helper.h
> > > > b/include/drm/drm_gem_ttm_helper.h
> > > > index 118cef76f84f..7c6d874910b8 100644
> > > > --- a/include/drm/drm_gem_ttm_helper.h
> > > > +++ b/include/drm/drm_gem_ttm_helper.h
> > > > @@ -10,11 +10,17 @@
> > > >    #include 
> > > >    #include 
> > > >    +struct dma_buf_map;
> > > > +
> > > >    #define drm_gem_ttm_of_gem(gem_obj) \
> > > >    container_of(gem_obj, struct ttm_buffer_object, base)
> > > >      void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int
> > > > indent,
> > > >    const struct drm_gem_object *gem);
> > > > +int drm_gem_ttm_vmap(struct drm_gem_object *gem,
> > > > + struct dma_buf_map *map);
> > > > +void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
> > > > +    struct dma_buf_map *map);
> > > >    int 

Re: [PATCH v2 0/3] drm/panel: mantix panel reset fixes

2020-10-19 Thread Daniel Vetter
On Sat, Oct 17, 2020 at 12:47:36PM +0200, Sam Ravnborg wrote:
> Hi Guido.
> 
> On Sat, Oct 17, 2020 at 11:13:07AM +0200, Guido Günther wrote:
> > Hi Sam,
> > On Fri, Oct 16, 2020 at 04:29:16PM +0200, Sam Ravnborg wrote:
> > > Hi Guido.
> > > On Tue, Oct 13, 2020 at 12:32:45PM +0200, Guido Günther wrote:
> > [..snip..]
> > > > 
> > > > Changes from v1:
> > > >  - As per review comments by Fabio Estevam
> > > >
> > > > https://lore.kernel.org/dri-devel/CAOMZO5B5ECcConvKej=rcaf8wvoxgq7nuzkj-ad0asaozuq...@mail.gmail.com/
> > > >- Fix typo in commit messages
> > > >  - As per review comments by Rob Herring
> > > >https://lore.kernel.org/dri-devel/20200929174624.GA832332@bogus/
> > > >- Don't use an array of reset lines
> > > > 
> > > > Guido Günther (3):
> > > >   drm/panel: mantix: Don't dereference NULL mode
> > > >   drm/panel: mantix: Fix panel reset
> > > >   dt-binding: display: Require two resets on mantix panel
> > > 
> > > All applied to drm-misc-next and pushed out.
> > > And then I remembered you had commit right - sigh.
> > 
> > Thanks! Is there any special care needed to get that into 5.10? The
> > driver landed there in 72967d5616d3f0c714f8eb6c4e258179a9031c45.
> 
> As the patches was applied to drm-misc-next the easiet path would
> be to cherry-pick them and apply to drm-misc-fixes.
> dim has cherry-pick support - try to use it rahter than doing it by
> hand.

drm-misc-next-fixes while we're between freeze and merge window end:

https://drm.pages.freedesktop.org/maintainer-tools/committer-drm-misc.html#where-do-i-apply-my-patch

Cheers, Daniel

> 

> When you apply to drm-misc-fixes include a Fixes: tag so the tooling
> will pick the patches automagically.
> 
> In hindsight the patches should have carried a Fixes: tag from a start
> and should have been applied to drm-misc-fixes from a start too.
> 
> I have done something like above once or twice but anyway reach out if
> you have questions. Or ask at #dri-devel.
> 
>   Sam

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/amdgpu: remove unneeded break

2020-10-19 Thread Harry Wentland

On 2020-10-19 10:55 a.m., Christian König wrote:

Am 19.10.20 um 16:43 schrieb t...@redhat.com:

From: Tom Rix 

A break is not needed if it is preceded by a return or break

Signed-off-by: Tom Rix 


Acked-by: Christian König 


Reviewed-by: Harry Wentland 

Harry




---
  drivers/gpu/drm/amd/display/dc/dce/dce_transform.c  | 1 -
  drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c   | 7 ---
  drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c   | 7 ---
  7 files changed, 43 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c

index 2a32b66959ba..130a0a0c8332 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
@@ -1330,7 +1330,6 @@ static bool configure_graphics_mode(
  REG_SET(OUTPUT_CSC_CONTROL, 0,
  OUTPUT_CSC_GRPH_MODE, 0);
  break;
-    break;
  case COLOR_SPACE_SRGB_LIMITED:
  /* TV RGB */
  REG_SET(OUTPUT_CSC_CONTROL, 0,
diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c

index d741787f75dc..42c7d157da32 100644
--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
@@ -418,25 +418,18 @@ static int map_transmitter_id_to_phy_instance(
  switch (transmitter) {
  case TRANSMITTER_UNIPHY_A:
  return 0;
-    break;
  case TRANSMITTER_UNIPHY_B:
  return 1;
-    break;
  case TRANSMITTER_UNIPHY_C:
  return 2;
-    break;
  case TRANSMITTER_UNIPHY_D:
  return 3;
-    break;
  case TRANSMITTER_UNIPHY_E:
  return 4;
-    break;
  case TRANSMITTER_UNIPHY_F:
  return 5;
-    break;
  case TRANSMITTER_UNIPHY_G:
  return 6;
-    break;
  default:
  ASSERT(0);
  return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c

index 2bbfa2e176a9..382581c4a674 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
@@ -471,25 +471,18 @@ static int map_transmitter_id_to_phy_instance(
  switch (transmitter) {
  case TRANSMITTER_UNIPHY_A:
  return 0;
-    break;
  case TRANSMITTER_UNIPHY_B:
  return 1;
-    break;
  case TRANSMITTER_UNIPHY_C:
  return 2;
-    break;
  case TRANSMITTER_UNIPHY_D:
  return 3;
-    break;
  case TRANSMITTER_UNIPHY_E:
  return 4;
-    break;
  case TRANSMITTER_UNIPHY_F:
  return 5;
-    break;
  case TRANSMITTER_UNIPHY_G:
  return 6;
-    break;
  default:
  ASSERT(0);
  return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c

index b622b4b1dac3..7b4b2304bbff 100644
--- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
@@ -446,25 +446,18 @@ static int map_transmitter_id_to_phy_instance(
  switch (transmitter) {
  case TRANSMITTER_UNIPHY_A:
  return 0;
-    break;
  case TRANSMITTER_UNIPHY_B:
  return 1;
-    break;
  case TRANSMITTER_UNIPHY_C:
  return 2;
-    break;
  case TRANSMITTER_UNIPHY_D:
  return 3;
-    break;
  case TRANSMITTER_UNIPHY_E:
  return 4;
-    break;
  case TRANSMITTER_UNIPHY_F:
  return 5;
-    break;
  case TRANSMITTER_UNIPHY_G:
  return 6;
-    break;
  default:
  ASSERT(0);
  return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c

index 16fe7344702f..3d782b7c86cb 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
@@ -383,25 +383,18 @@ static int map_transmitter_id_to_phy_instance(
  switch (transmitter) {
  case TRANSMITTER_UNIPHY_A:
  return 0;
-    break;
  case TRANSMITTER_UNIPHY_B:
  return 1;
-    break;
  case TRANSMITTER_UNIPHY_C:
  return 2;
-    break;
  case TRANSMITTER_UNIPHY_D:
  return 3;
-    break;
  case TRANSMITTER_UNIPHY_E:
  return 4;
-    break;
  case TRANSMITTER_UNIPHY_F:
  return 5;
-    break;
  case TRANSMITTER_UNIPHY_G:
  return 6;
-    break;
  default:
  ASSERT(0);
  return 0;
diff --git 

Re: [PATCH 2/2] drm/msm: Fix duplicate gpu node in icc summary

2020-10-19 Thread Jordan Crouse
On Mon, Oct 19, 2020 at 06:49:18PM +0530, Akhil P Oommen wrote:
> On targets with a6xx gpu, there is a duplicate gpu icc node listed in
> the interconnect summary. On these targets, calling

This first sentence is confusing to me. I think the following few sentences do
a better job of explaining what you are trying to do.

> dev_pm_opp_of_add_table() api initializes the icc nodes for gpu indirectly.
> So we should avoid using of_icc_get() api in the common probe path. To fix
> this, we can move of_icc_get() to target specific code where it is
> required.

> Signed-off-by: Akhil P Oommen 
> ---
>  drivers/gpu/drm/msm/adreno/a3xx_gpu.c   | 21 +++--
>  drivers/gpu/drm/msm/adreno/a4xx_gpu.c   | 20 ++--
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 29 +
>  3 files changed, 38 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c 
> b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
> index f29c77d..93da668 100644
> --- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
> @@ -519,6 +519,8 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
>   struct msm_gpu *gpu;
>   struct msm_drm_private *priv = dev->dev_private;
>   struct platform_device *pdev = priv->gpu_pdev;
> + struct icc_path *ocmem_icc_path;
> + struct icc_path *icc_path;
>   int ret;
>  
>   if (!pdev) {
> @@ -566,13 +568,28 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
>   goto fail;
>   }
>  
> + icc_path = devm_of_icc_get(>dev, "gfx-mem");
> + ret = IS_ERR(icc_path);
> + if (ret)
> + goto fail;
> +
> + ocmem_icc_path = devm_of_icc_get(>dev, "ocmem");
> + ret = IS_ERR(ocmem_icc_path);
> + if (ret) {
> + /* allow -ENODATA, ocmem icc is optional */
> + if (ret != -ENODATA)
> + goto fail;
> + ocmem_icc_path = NULL;
> + }
> +
> +
>   /*
>* Set the ICC path to maximum speed for now by multiplying the fastest
>* frequency by the bus width (8). We'll want to scale this later on to
>* improve battery life.
>*/
> - icc_set_bw(gpu->icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
> - icc_set_bw(gpu->ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
> + icc_set_bw(icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
> + icc_set_bw(ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);

This seems reasonable but I hope we can get somebody to sign off on a real a3xx
part.

>  
>   return gpu;
>  
> diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c 
> b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
> index 2b93b33..c0be3a0 100644
> --- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
> @@ -648,6 +648,8 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
>   struct msm_gpu *gpu;
>   struct msm_drm_private *priv = dev->dev_private;
>   struct platform_device *pdev = priv->gpu_pdev;
> + struct icc_path *ocmem_icc_path;
> + struct icc_path *icc_path;
>   int ret;
>  
>   if (!pdev) {
> @@ -694,13 +696,27 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
>   goto fail;
>   }
>  
> + icc_path = devm_of_icc_get(>dev, "gfx-mem");
> + ret = IS_ERR(icc_path);
> + if (ret)
> + goto fail;
> +
> + ocmem_icc_path = devm_of_icc_get(>dev, "ocmem");
> + ret = IS_ERR(ocmem_icc_path);
> + if (ret) {
> + /* allow -ENODATA, ocmem icc is optional */
> + if (ret != -ENODATA)
> + goto fail;
> + ocmem_icc_path = NULL;
> + }
> +
>   /*
>* Set the ICC path to maximum speed for now by multiplying the fastest
>* frequency by the bus width (8). We'll want to scale this later on to
>* improve battery life.
>*/
> - icc_set_bw(gpu->icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
> - icc_set_bw(gpu->ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
> + icc_set_bw(icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
> + icc_set_bw(ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);

Less confident we can find any 4xx fans to test this, but if a3xx works then so
should this (in theory).

>   return gpu;
>  
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
> b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index fd8f491..6e3b820 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -920,35 +920,8 @@ int adreno_gpu_init(struct drm_device *drm, struct 
> platform_device *pdev,
>  
>   ret = msm_gpu_init(drm, pdev, _gpu->base, >base,
>   adreno_gpu->info->name, _gpu_config);
> - if (ret)
> - return ret;
> -
> - /*
> -  * The legacy case, before "interconnect-names", only has a
> -  * single interconnect path which is equivalent to "gfx-mem"
> -  */
> -  

Re: [PATCH] drm/amdgpu: remove unneeded break

2020-10-19 Thread Christian König

Am 19.10.20 um 16:43 schrieb t...@redhat.com:

From: Tom Rix 

A break is not needed if it is preceded by a return or break

Signed-off-by: Tom Rix 


Acked-by: Christian König 


---
  drivers/gpu/drm/amd/display/dc/dce/dce_transform.c  | 1 -
  drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 7 ---
  drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c   | 7 ---
  drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c   | 7 ---
  7 files changed, 43 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
index 2a32b66959ba..130a0a0c8332 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
@@ -1330,7 +1330,6 @@ static bool configure_graphics_mode(
REG_SET(OUTPUT_CSC_CONTROL, 0,
OUTPUT_CSC_GRPH_MODE, 0);
break;
-   break;
case COLOR_SPACE_SRGB_LIMITED:
/* TV RGB */
REG_SET(OUTPUT_CSC_CONTROL, 0,
diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
index d741787f75dc..42c7d157da32 100644
--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
@@ -418,25 +418,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 4;
-   break;
case TRANSMITTER_UNIPHY_F:
return 5;
-   break;
case TRANSMITTER_UNIPHY_G:
return 6;
-   break;
default:
ASSERT(0);
return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
index 2bbfa2e176a9..382581c4a674 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
@@ -471,25 +471,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 4;
-   break;
case TRANSMITTER_UNIPHY_F:
return 5;
-   break;
case TRANSMITTER_UNIPHY_G:
return 6;
-   break;
default:
ASSERT(0);
return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
index b622b4b1dac3..7b4b2304bbff 100644
--- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
@@ -446,25 +446,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 4;
-   break;
case TRANSMITTER_UNIPHY_F:
return 5;
-   break;
case TRANSMITTER_UNIPHY_G:
return 6;
-   break;
default:
ASSERT(0);
return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
index 16fe7344702f..3d782b7c86cb 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
@@ -383,25 +383,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:

Re: [Freedreno] [PATCH] drm/msm: Remove redundant null check

2020-10-19 Thread Jordan Crouse
On Mon, Oct 19, 2020 at 02:04:22PM +0800, Tian Tao wrote:
> clk_prepare_enable() and clk_disable_unprepare() will check
> NULL clock parameter, so It is not necessary to add additional checks.

Reviewed-by: Jordan Crouse 

> Signed-off-by: Tian Tao 
> ---
>  drivers/gpu/drm/msm/msm_gpu.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 57ddc94..25bc654 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -175,15 +175,12 @@ static int disable_clk(struct msm_gpu *gpu)
>  
>  static int enable_axi(struct msm_gpu *gpu)
>  {
> - if (gpu->ebi1_clk)
> - clk_prepare_enable(gpu->ebi1_clk);
> - return 0;
> + return clk_prepare_enable(gpu->ebi1_clk);
>  }
>  
>  static int disable_axi(struct msm_gpu *gpu)
>  {
> - if (gpu->ebi1_clk)
> - clk_disable_unprepare(gpu->ebi1_clk);
> + clk_disable_unprepare(gpu->ebi1_clk);
>   return 0;
>  }
>  
> -- 
> 2.7.4
> 
> ___
> Freedreno mailing list
> freedr...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amdgpu: remove unneeded break

2020-10-19 Thread trix
From: Tom Rix 

A break is not needed if it is preceded by a return or break

Signed-off-by: Tom Rix 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_transform.c  | 1 -
 drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 7 ---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 7 ---
 drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 7 ---
 drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 7 ---
 drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c   | 7 ---
 drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c   | 7 ---
 7 files changed, 43 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
index 2a32b66959ba..130a0a0c8332 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
@@ -1330,7 +1330,6 @@ static bool configure_graphics_mode(
REG_SET(OUTPUT_CSC_CONTROL, 0,
OUTPUT_CSC_GRPH_MODE, 0);
break;
-   break;
case COLOR_SPACE_SRGB_LIMITED:
/* TV RGB */
REG_SET(OUTPUT_CSC_CONTROL, 0,
diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
index d741787f75dc..42c7d157da32 100644
--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
@@ -418,25 +418,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 4;
-   break;
case TRANSMITTER_UNIPHY_F:
return 5;
-   break;
case TRANSMITTER_UNIPHY_G:
return 6;
-   break;
default:
ASSERT(0);
return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
index 2bbfa2e176a9..382581c4a674 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
@@ -471,25 +471,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 4;
-   break;
case TRANSMITTER_UNIPHY_F:
return 5;
-   break;
case TRANSMITTER_UNIPHY_G:
return 6;
-   break;
default:
ASSERT(0);
return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
index b622b4b1dac3..7b4b2304bbff 100644
--- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
@@ -446,25 +446,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 4;
-   break;
case TRANSMITTER_UNIPHY_F:
return 5;
-   break;
case TRANSMITTER_UNIPHY_G:
return 6;
-   break;
default:
ASSERT(0);
return 0;
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
index 16fe7344702f..3d782b7c86cb 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
@@ -383,25 +383,18 @@ static int map_transmitter_id_to_phy_instance(
switch (transmitter) {
case TRANSMITTER_UNIPHY_A:
return 0;
-   break;
case TRANSMITTER_UNIPHY_B:
return 1;
-   break;
case TRANSMITTER_UNIPHY_C:
return 2;
-   break;
case TRANSMITTER_UNIPHY_D:
return 3;
-   break;
case TRANSMITTER_UNIPHY_E:
return 

Re: [PATCH v2 0/3] drm/panel: mantix panel reset fixes

2020-10-19 Thread Guido Günther
Hi,
On Sun, Oct 18, 2020 at 03:38:45PM +0200, Sam Ravnborg wrote:
>  Hi Guido
> > On Sun, Oct 18, 2020 at 03:01:22PM +0200, Guido Günther wrote:
> > Hi Sam,
> > On Sat, Oct 17, 2020 at 12:47:36PM +0200, Sam Ravnborg wrote:
> > > Hi Guido.
> > > 
> > > On Sat, Oct 17, 2020 at 11:13:07AM +0200, Guido Günther wrote:
> > > > Hi Sam,
> > > > On Fri, Oct 16, 2020 at 04:29:16PM +0200, Sam Ravnborg wrote:
> > > > > Hi Guido.
> > > > > On Tue, Oct 13, 2020 at 12:32:45PM +0200, Guido Günther wrote:
> > > > [..snip..]
> > > > > > 
> > > > > > Changes from v1:
> > > > > >  - As per review comments by Fabio Estevam
> > > > > >
> > > > > > https://lore.kernel.org/dri-devel/CAOMZO5B5ECcConvKej=rcaf8wvoxgq7nuzkj-ad0asaozuq...@mail.gmail.com/
> > > > > >- Fix typo in commit messages
> > > > > >  - As per review comments by Rob Herring
> > > > > >https://lore.kernel.org/dri-devel/20200929174624.GA832332@bogus/
> > > > > >- Don't use an array of reset lines
> > > > > > 
> > > > > > Guido Günther (3):
> > > > > >   drm/panel: mantix: Don't dereference NULL mode
> > > > > >   drm/panel: mantix: Fix panel reset
> > > > > >   dt-binding: display: Require two resets on mantix panel
> > > > > 
> > > > > All applied to drm-misc-next and pushed out.
> > > > > And then I remembered you had commit right - sigh.
> > > > 
> > > > Thanks! Is there any special care needed to get that into 5.10? The
> > > > driver landed there in 72967d5616d3f0c714f8eb6c4e258179a9031c45.
> > > 
> > > As the patches was applied to drm-misc-next the easiet path would
> > > be to cherry-pick them and apply to drm-misc-fixes.
> > > dim has cherry-pick support - try to use it rahter than doing it by
> > > hand.
> > 
> > Does that require any further ACKs or just cherry-pick and push out?
> To the best of my knowledge just cherry-pick, test and push out.

drm-misc-fixes does not yet have the corresponding code so i assume i
have to wait for back merge of 5.10-rc1 ? At least

   https://drm.pages.freedesktop.org/maintainer-tools/drm-misc.html

seems to indicate that.
Cheers,
 -- Guido

> 
>   Sam
> 
> > 
> > > When you apply to drm-misc-fixes include a Fixes: tag so the tooling
> > > will pick the patches automagically.
> > 
> > Will do. It was unfortunate that the initial ones didn't get them but
> > i think the drm merge happened while v2 was out on the list. I'll try
> > add that relevant information to the cover letter in the future.
> > 
> > Cheers,
> >  -- Guido
> > 
> > > 
> > > In hindsight the patches should have carried a Fixes: tag from a start
> > > and should have been applied to drm-misc-fixes from a start too.
> > > 
> > > I have done something like above once or twice but anyway reach out if
> > > you have questions. Or ask at #dri-devel.
> > > 
> > >   Sam
> > > 
> > ___
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()

2020-10-19 Thread kernel test robot
Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
7cf726a59435301046250c42131554d9ccc566b8
config: x86_64-randconfig-a015-20201019 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
094e9f4779eb9b5c6a49014f2f80b8cbb833572f)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# 
https://github.com/0day-ci/linux/commit/33f0ea8bebc4132d957107f55776d8f1e02df928
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
git checkout 33f0ea8bebc4132d957107f55776d8f1e02df928
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from 
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/tonga_baco.c:23:
   In file included from drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgpu.h:67:
   In file included from 
drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26:
   In file included from 
drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29:
>> drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:36:10: fatal error: 
>> 'asm/switch-to.h' file not found
   #include 
^
   1 error generated.

vim +36 drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h

34  
35  #include 
  > 36  #include 
37  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] drm/msm: Fix duplicate gpu node in icc summary

2020-10-19 Thread Akhil P Oommen
On targets with a6xx gpu, there is a duplicate gpu icc node listed in
the interconnect summary. On these targets, calling
dev_pm_opp_of_add_table() api initializes the icc nodes for gpu indirectly.
So we should avoid using of_icc_get() api in the common probe path. To fix
this, we can move of_icc_get() to target specific code where it is
required.

Signed-off-by: Akhil P Oommen 
---
 drivers/gpu/drm/msm/adreno/a3xx_gpu.c   | 21 +++--
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c   | 20 ++--
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 29 +
 3 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index f29c77d..93da668 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -519,6 +519,8 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
struct msm_gpu *gpu;
struct msm_drm_private *priv = dev->dev_private;
struct platform_device *pdev = priv->gpu_pdev;
+   struct icc_path *ocmem_icc_path;
+   struct icc_path *icc_path;
int ret;
 
if (!pdev) {
@@ -566,13 +568,28 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
goto fail;
}
 
+   icc_path = devm_of_icc_get(>dev, "gfx-mem");
+   ret = IS_ERR(icc_path);
+   if (ret)
+   goto fail;
+
+   ocmem_icc_path = devm_of_icc_get(>dev, "ocmem");
+   ret = IS_ERR(ocmem_icc_path);
+   if (ret) {
+   /* allow -ENODATA, ocmem icc is optional */
+   if (ret != -ENODATA)
+   goto fail;
+   ocmem_icc_path = NULL;
+   }
+
+
/*
 * Set the ICC path to maximum speed for now by multiplying the fastest
 * frequency by the bus width (8). We'll want to scale this later on to
 * improve battery life.
 */
-   icc_set_bw(gpu->icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
-   icc_set_bw(gpu->ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
+   icc_set_bw(icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
+   icc_set_bw(ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
 
return gpu;
 
diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
index 2b93b33..c0be3a0 100644
--- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
@@ -648,6 +648,8 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
struct msm_gpu *gpu;
struct msm_drm_private *priv = dev->dev_private;
struct platform_device *pdev = priv->gpu_pdev;
+   struct icc_path *ocmem_icc_path;
+   struct icc_path *icc_path;
int ret;
 
if (!pdev) {
@@ -694,13 +696,27 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
goto fail;
}
 
+   icc_path = devm_of_icc_get(>dev, "gfx-mem");
+   ret = IS_ERR(icc_path);
+   if (ret)
+   goto fail;
+
+   ocmem_icc_path = devm_of_icc_get(>dev, "ocmem");
+   ret = IS_ERR(ocmem_icc_path);
+   if (ret) {
+   /* allow -ENODATA, ocmem icc is optional */
+   if (ret != -ENODATA)
+   goto fail;
+   ocmem_icc_path = NULL;
+   }
+
/*
 * Set the ICC path to maximum speed for now by multiplying the fastest
 * frequency by the bus width (8). We'll want to scale this later on to
 * improve battery life.
 */
-   icc_set_bw(gpu->icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
-   icc_set_bw(gpu->ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
+   icc_set_bw(icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
+   icc_set_bw(ocmem_icc_path, 0, Bps_to_icc(gpu->fast_rate) * 8);
 
return gpu;
 
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index fd8f491..6e3b820 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -920,35 +920,8 @@ int adreno_gpu_init(struct drm_device *drm, struct 
platform_device *pdev,
 
ret = msm_gpu_init(drm, pdev, _gpu->base, >base,
adreno_gpu->info->name, _gpu_config);
-   if (ret)
-   return ret;
-
-   /*
-* The legacy case, before "interconnect-names", only has a
-* single interconnect path which is equivalent to "gfx-mem"
-*/
-   if (!of_find_property(dev->of_node, "interconnect-names", NULL)) {
-   gpu->icc_path = of_icc_get(dev, NULL);
-   } else {
-   gpu->icc_path = of_icc_get(dev, "gfx-mem");
-   gpu->ocmem_icc_path = of_icc_get(dev, "ocmem");
-   }
 
-   if (IS_ERR(gpu->icc_path)) {
-   ret = PTR_ERR(gpu->icc_path);
-   gpu->icc_path = NULL;
-   return ret;
-   }
-
-   if (IS_ERR(gpu->ocmem_icc_path)) {
- 

[PATCH 1/2] drm/msm: Implement shutdown callback for adreno

2020-10-19 Thread Akhil P Oommen
Implement the shutdown callback for adreno gpu platform device
to safely shutdown it before a system reboot. This helps to avoid
futher transactions from gpu after the smmu is moved to bypass mode.

Signed-off-by: Akhil P Oommen 
---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 58e03b2..87c8b03 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -475,6 +475,11 @@ static int adreno_remove(struct platform_device *pdev)
return 0;
 }
 
+static void adreno_shutdown(struct platform_device *pdev)
+{
+   pm_runtime_force_suspend(>dev);
+}
+
 static const struct of_device_id dt_match[] = {
{ .compatible = "qcom,adreno" },
{ .compatible = "qcom,adreno-3xx" },
@@ -509,6 +514,7 @@ static const struct dev_pm_ops adreno_pm_ops = {
 static struct platform_driver adreno_driver = {
.probe = adreno_probe,
.remove = adreno_remove,
+   .shutdown = adreno_shutdown,
.driver = {
.name = "adreno",
.of_match_table = dt_match,
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 3/3] dt-bindings: drm/msm/gpu: Add cooling device support

2020-10-19 Thread Akhil P Oommen
Add cooling device support to gpu. A cooling device is bound to a
thermal zone to allow thermal mitigation.

Signed-off-by: Akhil P Oommen 
---
 Documentation/devicetree/bindings/display/msm/gpu.txt | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/msm/gpu.txt 
b/Documentation/devicetree/bindings/display/msm/gpu.txt
index 1af0ff1..a496381 100644
--- a/Documentation/devicetree/bindings/display/msm/gpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/gpu.txt
@@ -39,6 +39,10 @@ Required properties:
 a4xx Snapdragon SoCs. See
 Documentation/devicetree/bindings/sram/qcom,ocmem.yaml.
 
+Optional properties:
+- #cooling-cells: The value must be 2. Please refer
+   Documentation/devicetree/bindings/thermal/thermal.txt for detail.
+
 Example 3xx/4xx:
 
 / {
@@ -61,6 +65,7 @@ Example 3xx/4xx:
power-domains = < OXILICX_GDSC>;
operating-points-v2 = <_opp_table>;
iommus = <_iommu 0>;
+   #cooling-cells = <2>;
};
 
gpu_sram: ocmem@fdd0 {
@@ -98,6 +103,8 @@ Example a6xx (with GMU):
reg = <0x500 0x4>, <0x509e000 0x10>;
reg-names = "kgsl_3d0_reg_memory", "cx_mem";
 
+   #cooling-cells = <2>;
+
/*
 * Look ma, no clocks! The GPU clocks and power are
 * controlled entirely by the GMU
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 2/3] arm64: dts: qcom: sc7180: Add gpu cooling support

2020-10-19 Thread Akhil P Oommen
Add cooling-cells property and the cooling maps for the gpu tzones
to support GPU cooling.

Signed-off-by: Akhil P Oommen 
---
The thermal policy should be set as 'step_wise' for gpu tzones from
the userspace during boot up.

 arch/arm64/boot/dts/qcom/sc7180.dtsi | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index d46b383..a7ea029 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -2,7 +2,7 @@
 /*
  * SC7180 SoC device tree source
  *
- * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-20, The Linux Foundation. All rights reserved.
  */
 
 #include 
@@ -1886,6 +1886,8 @@
operating-points-v2 = <_opp_table>;
qcom,gmu = <>;
 
+   #cooling-cells = <2>;
+
interconnects = <_noc MASTER_GFX3D _virt 
SLAVE_EBI1>;
interconnect-names = "gfx-mem";
 
@@ -3825,16 +3827,16 @@
};
 
gpuss0-thermal {
-   polling-delay-passive = <0>;
+   polling-delay-passive = <100>;
polling-delay = <0>;
 
thermal-sensors = < 13>;
 
trips {
gpuss0_alert0: trip-point0 {
-   temperature = <9>;
+   temperature = <95000>;
hysteresis = <2000>;
-   type = "hot";
+   type = "passive";
};
 
gpuss0_crit: gpuss0_crit {
@@ -3843,19 +3845,26 @@
type = "critical";
};
};
+
+   cooling-maps {
+   map0 {
+   trip = <_alert0>;
+   cooling-device = < THERMAL_NO_LIMIT 
THERMAL_NO_LIMIT>;
+   };
+   };
};
 
gpuss1-thermal {
-   polling-delay-passive = <0>;
+   polling-delay-passive = <100>;
polling-delay = <0>;
 
thermal-sensors = < 14>;
 
trips {
gpuss1_alert0: trip-point0 {
-   temperature = <9>;
+   temperature = <95000>;
hysteresis = <2000>;
-   type = "hot";
+   type = "passive";
};
 
gpuss1_crit: gpuss1_crit {
@@ -3864,6 +3873,13 @@
type = "critical";
};
};
+
+   cooling-maps {
+   map0 {
+   trip = <_alert0>;
+   cooling-device = < THERMAL_NO_LIMIT 
THERMAL_NO_LIMIT>;
+   };
+   };
};
 
aoss1-thermal {
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 1/3] drm/msm: Add support for GPU cooling

2020-10-19 Thread Akhil P Oommen
Register GPU as a devfreq cooling device so that it can be passively
cooled by the thermal framework.

Signed-off-by: Akhil P Oommen 
---
Changes in v2:
1. Update the dt bindings documentation

 drivers/gpu/drm/msm/msm_gpu.c | 12 
 drivers/gpu/drm/msm/msm_gpu.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 55d1648..9f9db46 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -107,9 +108,18 @@ static void msm_devfreq_init(struct msm_gpu *gpu)
if (IS_ERR(gpu->devfreq.devfreq)) {
DRM_DEV_ERROR(>pdev->dev, "Couldn't initialize GPU 
devfreq\n");
gpu->devfreq.devfreq = NULL;
+   return;
}
 
devfreq_suspend_device(gpu->devfreq.devfreq);
+
+   gpu->cooling = of_devfreq_cooling_register(gpu->pdev->dev.of_node,
+   gpu->devfreq.devfreq);
+   if (IS_ERR(gpu->cooling)) {
+   DRM_DEV_ERROR(>pdev->dev,
+   "Couldn't register GPU cooling device\n");
+   gpu->cooling = NULL;
+   }
 }
 
 static int enable_pwrrail(struct msm_gpu *gpu)
@@ -1005,4 +1015,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu);
msm_gem_address_space_put(gpu->aspace);
}
+
+   devfreq_cooling_unregister(gpu->cooling);
 }
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 6c9e1fd..9a8f20d 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -147,6 +147,8 @@ struct msm_gpu {
struct msm_gpu_state *crashstate;
/* True if the hardware supports expanded apriv (a650 and newer) */
bool hw_apriv;
+
+   struct thermal_cooling_device *cooling;
 };
 
 static inline struct msm_gpu *dev_to_gpu(struct device *dev)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()

2020-10-19 Thread kernel test robot
Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
7cf726a59435301046250c42131554d9ccc566b8
config: arc-randconfig-r013-20201019 (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/33f0ea8bebc4132d957107f55776d8f1e02df928
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
git checkout 33f0ea8bebc4132d957107f55776d8f1e02df928
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from 
drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
from 
drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26,
from drivers/gpu/drm/amd/amdgpu/amdgpu.h:67,
from drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:40:
>> drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:36:10: fatal error: 
>> asm/switch-to.h: No such file or directory
  36 | #include 
 |  ^
   compilation terminated.

vim +36 drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h

34  
35  #include 
  > 36  #include 
37  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH AUTOSEL 5.9 090/111] drm/amd/display: Fix a list corruption

2020-10-19 Thread Alex Deucher
On Sun, Oct 18, 2020 at 3:19 PM Sasha Levin  wrote:
>
> From: xinhui pan 
>
> [ Upstream commit 1545fbf97eafc1dbdc2923e58b4186b16a834784 ]
>
> Remove the private obj from the internal list before we free aconnector.
>
> [   56.925828] BUG: unable to handle page fault for address: 8f84a870a560
> [   56.933272] #PF: supervisor read access in kernel mode
> [   56.938801] #PF: error_code(0x) - not-present page
> [   56.944376] PGD 18e605067 P4D 18e605067 PUD 86a614067 PMD 86a4d0067 PTE 
> 8008578f5060
> [   56.953260] Oops:  [#1] SMP DEBUG_PAGEALLOC NOPTI
> [   56.958815] CPU: 6 PID: 1407 Comm: bash Tainted: G   O  
> 5.9.0-rc2+ #46
> [   56.967092] Hardware name: System manufacturer System Product Name/PRIME 
> Z390-A, BIOS 1401 11/26/2019
> [   56.977162] RIP: 0010:__list_del_entry_valid+0x31/0xa0
> [   56.982768] Code: 00 ad de 55 48 8b 17 4c 8b 47 08 48 89 e5 48 39 c2 74 27 
> 48 b8 22 01 00 00 00 00 ad de 49 39 c0 74 2d 49 8b 30 48 39 fe 75 3d <48> 8b 
> 52 08 48 39 f2 75 4c b8 01 00 00 00 5d c3 48 89 7
> [   57.003327] RSP: 0018:b40c81687c90 EFLAGS: 00010246
> [   57.009048] RAX: dead0122 RBX: 8f84ea41f4f0 RCX: 
> 0006
> [   57.016871] RDX: 8f84a870a558 RSI: 8f84ea41f4f0 RDI: 
> 8f84ea41f4f0
> [   57.024672] RBP: b40c81687c90 R08: 8f84ea400998 R09: 
> 0001
> [   57.032490] R10:  R11:  R12: 
> 0006
> [   57.040287] R13: 8f84ea422a90 R14: 8f84b4129a20 R15: 
> fff2
> [   57.048105] FS:  7f550d885740() GS:8f850960() 
> knlGS:
> [   57.056979] CS:  0010 DS:  ES:  CR0: 80050033
> [   57.063260] CR2: 8f84a870a560 CR3: 0007e5144001 CR4: 
> 003706e0
> [   57.071053] DR0:  DR1:  DR2: 
> 
> [   57.078849] DR3:  DR6: fffe0ff0 DR7: 
> 0400
> [   57.086684] Call Trace:
> [   57.089381]  drm_atomic_private_obj_fini+0x29/0x82 [drm]
> [   57.095247]  amdgpu_dm_fini+0x83/0x170 [amdgpu]
> [   57.100264]  dm_hw_fini+0x23/0x30 [amdgpu]
> [   57.104814]  amdgpu_device_fini+0x1df/0x4fe [amdgpu]
> [   57.110271]  amdgpu_driver_unload_kms+0x43/0x70 [amdgpu]
> [   57.116136]  amdgpu_pci_remove+0x3b/0x60 [amdgpu]
> [   57.121291]  pci_device_remove+0x3e/0xb0
> [   57.125583]  device_release_driver_internal+0xff/0x1d0
> [   57.131223]  device_release_driver+0x12/0x20
> [   57.135903]  pci_stop_bus_device+0x70/0xa0
> [   57.140401]  pci_stop_and_remove_bus_device_locked+0x1b/0x30
> [   57.146571]  remove_store+0x7b/0x90
> [   57.150429]  dev_attr_store+0x17/0x30
> [   57.154441]  sysfs_kf_write+0x4b/0x60
> [   57.158479]  kernfs_fop_write+0xe8/0x1d0
> [   57.162788]  vfs_write+0xf5/0x230
> [   57.166426]  ksys_write+0x70/0xf0
> [   57.170087]  __x64_sys_write+0x1a/0x20
> [   57.174219]  do_syscall_64+0x38/0x90
> [   57.178145]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> Signed-off-by: xinhui pan 
> Acked-by: Feifei Xu 
> Signed-off-by: Alex Deucher 
> Signed-off-by: Sasha Levin 

This ended up getting reverted.  Please drop this one.

Alex


> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index a717a4904268e..57ad6450e20b2 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4882,6 +4882,7 @@ static void amdgpu_dm_connector_destroy(struct 
> drm_connector *connector)
> struct amdgpu_device *adev = connector->dev->dev_private;
> struct amdgpu_display_manager *dm = >dm;
>
> +   drm_atomic_private_obj_fini(>mst_mgr.base);
>  #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) ||\
> defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
>
> --
> 2.25.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 209673] divide_error in amdgpu freezes screen

2020-10-19 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=209673

--- Comment #10 from cornelius.riemenschnei...@googlemail.com ---
Created attachment 293057
  --> https://bugzilla.kernel.org/attachment.cgi?id=293057=edit
crashing dmesg #7

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: It appears drm-next TTM cleanup broke something . . .

2020-10-19 Thread Christian König

Hi Kevin,

the basic problem you are facing is that ttm_tt_create/destroy is 
mandatory (It always was). You need an implementation or otherwise you 
won't be able to use the system domain (additional to the optional GTT 
domain).


My best guess is that the difference is that we now force to initiate 
the system domain for all drivers.


If that is correct you just that you never ran into because you never 
correctly initialized TTM to support buffer moves.


I'm not sure what exactly the OpenChrome DRM driver is doing, but I 
strongly suggest to just drop TTM support completely and use the GEM 
VRAM helper layer instead.


Regards,
Christian.

Am 19.10.20 um 09:23 schrieb Kevin Brace:

Hi Dave,

Yeah, with the workaround I mentioned in my previous e-mail, OpenChrome DRM does not 
crash for "ttm_tt_create" member being null.
It is still not able to boot X Server due to some other TTM related memory 
allocation issue it is suffering from.
I think making huge changes to TTM during this development cycle broke 
OpenChrome DRM.
 Following up on the question I raised during the previous e-mail.
Shouldn't "use_tt" parameter being "false" for ttm_range_man_init() disable TTM 
TT functionality?
I feel like that should be the expected behavior.
Again, there is only 5 to 6 more days left until Linux 5.10-rc2, so I decided 
to contact you on Sunday (I consider this bug to be urgent.).
Assuming what I am asserting is correct, I think the reason why this was not 
discovered earlier was due to the following reasons.

1) nouveau, radeon, and amdgpu already use TTM TT functionality.
2) ast uses GEM VRAM helper that internally uses TTM. It populates "ttm_tt_create" and 
"ttm_tt_destroy" members, hence, the developers did not notice the breakage.
3) OpenChrome DRM is still not in the mainline tree, so no one other than 
myself noticed the problem until now.


Regarding the TTM TT functionality, OpenChrome DRM currently does not support acceleration, hence, 
I did not believe it was necessary to populate "ttm_tt_create" and 
"ttm_tt_destroy" members.
That implementation worked fine until the previous development cycle code.
Of course, I will eventually add support for acceleration, hence, TTM TT 
functionality will be utilized at some point.

Regards,

Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com



Sent: Sunday, October 18, 2020 at 12:50 PM
From: "Dave Airlie" 
To: "Kevin Brace" , "Christian König" 

Cc: "dri-devel" , "Dave Airlie" 

Subject: Re: It appears drm-next TTM cleanup broke something . . .

On Mon, 19 Oct 2020 at 05:15, Kevin Brace  wrote:

Hi Dave,

It is a little urgent, so I am writing this right now.
As usual, I pulled in DRM repository code for an out of tree OpenChrome DRM 
repository a few days ago.
While going through the changes I need to make to OpenChrome DRM to compile 
with the latest Linux kernel, I noticed that ttm_bo_init_mm() was discontinued, 
and it was replaced with ttm_range_man_init().
ttm_range_man_init() has a parameter called "bool use_tt", but honestly, I do 
not think it is functioning correctly.
If I keep "ttm_tt_create" member of ttm_bo_driver struct null by not specifying 
it, TTM still tries to call it, and crashes due to a null pointer access.
The workaround I found so far is to specify the "ttm_tt_create" member by 
copying bo_driver_ttm_tt_create() from drm/drm_gem_vram_helper.c.
This is what the call trace looks like without specifying the "ttm_tt_create" 
member (i.e., this member is null).

cc'ing Christian,

I can't remember if we did this deliberately or if just worked by
accident previously.

Either way, you should probably need a ttm_tt_create going forward.

Dave.


___
. . .
kernel: [   34.310674] [drm:openchrome_bo_create [openchrome]] Entered 
openchrome_bo_create.
kernel: [   34.310697] [drm:openchrome_ttm_domain_to_placement [openchrome]] 
Entered openchrome_ttm_domain_to_placement.
kernel: [   34.310706] [drm:openchrome_ttm_domain_to_placement [openchrome]] 
Exiting openchrome_ttm_domain_to_placement.
kernel: [   34.310737] BUG: kernel NULL pointer dereference, address: 

kernel: [   34.310742] #PF: supervisor instruction fetch in kernel mode
kernel: [   34.310745] #PF: error_code(0x0010) - not-present page
. . .
kernel: [   34.310807] Call Trace:
kernel: [   34.310827]  ttm_tt_create+0x5f/0xa0 [ttm]
kernel: [   34.310839]  ttm_bo_validate+0xb8/0x140 [ttm]
kernel: [   34.310886]  ? drm_vma_offset_add+0x56/0x70 [drm]
kernel: [   34.310897]  ? openchrome_gem_create_ioctl+0x150/0x150 [openchrome]
. . .
___

The erroneous call to  "ttm_tt_create" member happens right after TTM placement 
is performed (openchrome_ttm_domain_to_placement()).
Currently, OpenChrome DRM's TTM implementation does not use "ttm_tt_create" 
member, and this arrangement worked fine until Linux 5.9's drm-next code.
It appears that Linux 5.10's drm-next code broke 

Re: [PATCH 4/5] drm/ttm: add move old to system to drivers.

2020-10-19 Thread Christian König

Am 19.10.20 um 09:13 schrieb Dave Airlie:

From: Dave Airlie 

Uninline ttm_bo_move_ttm. Eventually want to unhook the unbind out.

Reviewed-by: Ben Skeggs 
Signed-off-by: Dave Airlie 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 15 ---
  drivers/gpu/drm/nouveau/nouveau_bo.c   | 11 +--
  drivers/gpu/drm/radeon/radeon_ttm.c| 15 ---
  drivers/gpu/drm/ttm/ttm_bo_util.c  |  5 +++--
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c |  7 ++-
  include/drm/ttm/ttm_bo_driver.h|  2 ++
  6 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index f8c9d66d3ef7..b052d3e6f635 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -562,7 +562,11 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object 
*bo, bool evict,
}
  
  	/* move BO (in tmp_mem) to new_mem */

-   r = ttm_bo_move_ttm(bo, ctx, new_mem);
+   r = ttm_bo_move_old_to_system(bo, ctx);
+   if (unlikely(r))
+   goto out_cleanup;
+
+   ttm_bo_assign_mem(bo, new_mem);
  out_cleanup:
ttm_resource_free(bo, _mem);
return r;
@@ -672,8 +676,13 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, 
bool evict,
}
  
  	if (old_mem->mem_type == TTM_PL_TT &&

-   new_mem->mem_type == TTM_PL_SYSTEM)
-   return ttm_bo_move_ttm(bo, ctx, new_mem);
+   new_mem->mem_type == TTM_PL_SYSTEM) {
+   r = ttm_bo_move_old_to_system(bo, ctx);
+   if (r)
+   return r;
+   ttm_bo_assign_mem(bo, new_mem);
+   return 0;
+   }
  
  	if (old_mem->mem_type == AMDGPU_PL_GDS ||

old_mem->mem_type == AMDGPU_PL_GWS ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 63baa9367851..e7e83f00674e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -897,7 +897,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool 
evict,
if (ret)
goto out;
  
-	ret = ttm_bo_move_ttm(bo, ctx, new_reg);

+   ret = ttm_bo_move_old_to_system(bo, ctx);
+   if (ret)
+   goto out;
+
+   ttm_bo_assign_mem(bo, _reg);
  out:
ttm_resource_free(bo, _reg);
return ret;
@@ -1048,7 +1052,10 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
  
  	if (old_reg->mem_type == TTM_PL_TT &&

new_reg->mem_type == TTM_PL_SYSTEM) {
-   ret = ttm_bo_move_ttm(bo, ctx, new_reg);
+   ret = ttm_bo_move_old_to_system(bo, ctx);
+   if (ret)
+   return ret;
+   ttm_bo_assign_mem(bo, new_reg);
goto out;
}
  
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c

index 9437d29248fd..4274f5ea56e4 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -244,7 +244,11 @@ static int radeon_move_vram_ram(struct ttm_buffer_object 
*bo,
if (unlikely(r)) {
goto out_cleanup;
}
-   r = ttm_bo_move_ttm(bo, ctx, new_mem);
+   r = ttm_bo_move_old_to_system(bo, ctx);
+   if (unlikely(r))
+   goto out_cleanup;
+
+   ttm_bo_assign_mem(bo, new_mem);
  out_cleanup:
ttm_resource_free(bo, _mem);
return r;
@@ -319,9 +323,14 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, 
bool evict,
}
  
  	if (old_mem->mem_type == TTM_PL_TT &&

-   new_mem->mem_type == TTM_PL_SYSTEM)
-   return ttm_bo_move_ttm(bo, ctx, new_mem);
+   new_mem->mem_type == TTM_PL_SYSTEM) {
+   r = ttm_bo_move_old_to_system(bo, ctx);
+   if (r)
+   return r;
  
+		ttm_bo_assign_mem(bo, new_mem);

+   return 0;
+   }
if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
rdev->asic->copy.copy == NULL) {
/* use memcpy */
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 39e03d99a377..1c1055a500cd 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -66,8 +66,8 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
  }
  EXPORT_SYMBOL(ttm_bo_move_to_new_tt_mem);
  
-static int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,

-struct ttm_operation_ctx *ctx)
+int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,
+ struct ttm_operation_ctx *ctx)
  {
struct ttm_resource *old_mem = >mem;
int ret;
@@ -87,6 +87,7 @@ static int ttm_bo_move_old_to_system(struct ttm_buffer_object 
*bo,
old_mem->mem_type = TTM_PL_SYSTEM;
return 0;
  }

Re: [PATCH 5/5] drm/ttm: drop ttm_bo_move_ttm wrapper

2020-10-19 Thread Christian König

Am 19.10.20 um 09:13 schrieb Dave Airlie:

From: Dave Airlie 

The apis to move old/new are in place everywhere so this is no
longer needed.


Reviewed-by: Christian König 


---
  drivers/gpu/drm/ttm/ttm_bo_util.c | 20 
  include/drm/ttm/ttm_bo_driver.h   | 22 --
  2 files changed, 42 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 1c1055a500cd..a3132e8a4102 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -89,26 +89,6 @@ int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,
  }
  EXPORT_SYMBOL(ttm_bo_move_old_to_system);
  
-int ttm_bo_move_ttm(struct ttm_buffer_object *bo,

-  struct ttm_operation_ctx *ctx,
-   struct ttm_resource *new_mem)
-{
-   struct ttm_resource *old_mem = >mem;
-   int ret;
-
-   ret = ttm_bo_move_old_to_system(bo, ctx);
-   if (unlikely(ret != 0))
-   return ret;
-
-   ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem);
-   if (unlikely(ret != 0))
-   return ret;
-
-   ttm_bo_assign_mem(bo, new_mem);
-   return 0;
-}
-EXPORT_SYMBOL(ttm_bo_move_ttm);
-
  int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
   struct ttm_resource *mem)
  {
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 4b341914858b..2fbd9adc1645 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -566,32 +566,10 @@ static inline void ttm_bo_unreserve(struct 
ttm_buffer_object *bo)
  /*
   * ttm_bo_util.c
   */
-
  int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
   struct ttm_resource *mem);
  void ttm_mem_io_free(struct ttm_bo_device *bdev,
 struct ttm_resource *mem);
-/**
- * ttm_bo_move_ttm
- *
- * @bo: A pointer to a struct ttm_buffer_object.
- * @interruptible: Sleep interruptible if waiting.
- * @no_wait_gpu: Return immediately if the GPU is busy.
- * @new_mem: struct ttm_resource indicating where to move.
- *
- * Optimized move function for a buffer object with both old and
- * new placement backed by a TTM. The function will, if successful,
- * free any old aperture space, and set (@new_mem)->mm_node to NULL,
- * and update the (@bo)->mem placement flags. If unsuccessful, the old
- * data remains untouched, and it's up to the caller to free the
- * memory space indicated by @new_mem.
- * Returns:
- * !0: Failure.
- */
-
-int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx,
-   struct ttm_resource *new_mem);
  
  int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,

  struct ttm_operation_ctx *ctx,


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/5] drm/ttm: use new move interface for known system->ttm moves

2020-10-19 Thread Christian König

Am 19.10.20 um 09:13 schrieb Dave Airlie:

From: Dave Airlie 

In all 3 drivers there is a case where the driver knows the
bo is in SYSTEM so don't call the api that checks that.

Reviewed-by: Ben Skeggs 
Signed-off-by: Dave Airlie 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++--
  drivers/gpu/drm/nouveau/nouveau_bo.c| 3 ++-
  drivers/gpu/drm/radeon/radeon_ttm.c | 3 ++-
  drivers/gpu/drm/ttm/ttm_bo_util.c   | 1 +
  4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 8cdec58b9106..f8c9d66d3ef7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -601,11 +601,11 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object 
*bo, bool evict,
}
  
  	/* move/bind old memory to GTT space */

-   r = ttm_bo_move_ttm(bo, ctx, _mem);
+   r = ttm_bo_move_to_new_tt_mem(bo, ctx, _mem);
if (unlikely(r)) {
goto out_cleanup;
}
-
+   ttm_bo_assign_mem(bo, _mem);
/* copy to VRAM */
r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
if (unlikely(r)) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 4ccb3329014b..63baa9367851 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -927,10 +927,11 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool 
evict,
if (ret)
return ret;
  
-	ret = ttm_bo_move_ttm(bo, ctx, _reg);

+   ret = ttm_bo_move_to_new_tt_mem(bo, ctx, _reg);
if (ret)
goto out;
  
+	ttm_bo_assign_mem(bo, _reg);

ret = nouveau_bo_move_m2mf(bo, true, ctx, new_reg);
if (ret)
goto out;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index d6f42fbc81f4..9437d29248fd 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -275,10 +275,11 @@ static int radeon_move_ram_vram(struct ttm_buffer_object 
*bo,
if (unlikely(r)) {
return r;
}
-   r = ttm_bo_move_ttm(bo, ctx, _mem);
+   r = ttm_bo_move_to_new_tt_mem(bo, ctx, _mem);
if (unlikely(r)) {
goto out_cleanup;
}
+   ttm_bo_assign_mem(bo, _mem);
r = radeon_move_blit(bo, true, new_mem, old_mem);
if (unlikely(r)) {
goto out_cleanup;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 29726652fef7..39e03d99a377 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -64,6 +64,7 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
  
  	return 0;

  }
+EXPORT_SYMBOL(ttm_bo_move_to_new_tt_mem);
  
  static int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,

 struct ttm_operation_ctx *ctx)


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/5] drm/ttm: split out the move to system from move ttm code

2020-10-19 Thread Christian König

Am 19.10.20 um 09:13 schrieb Dave Airlie:

From: Dave Airlie 

Reviewed-by: Ben Skeggs 
Signed-off-by: Dave Airlie 


Maybe just call it ...move_to_system(), but either way Reviewed-by: 
Christian König 



---
  drivers/gpu/drm/ttm/ttm_bo_util.c | 38 ---
  1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index a36c615bdf24..29726652fef7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -65,6 +65,28 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
return 0;
  }
  
+static int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,

+struct ttm_operation_ctx *ctx)
+{
+   struct ttm_resource *old_mem = >mem;
+   int ret;
+
+   if (old_mem->mem_type == TTM_PL_SYSTEM)
+   return 0;
+
+   ret = ttm_bo_wait_ctx(bo, ctx);
+   if (unlikely(ret != 0)) {
+   if (ret != -ERESTARTSYS)
+   pr_err("Failed to expire sync object before unbinding 
TTM\n");
+   return ret;
+   }
+
+   ttm_bo_tt_unbind(bo);
+   ttm_resource_free(bo, >mem);
+   old_mem->mem_type = TTM_PL_SYSTEM;
+   return 0;
+}
+
  int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
   struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem)
@@ -72,19 +94,9 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
struct ttm_resource *old_mem = >mem;
int ret;
  
-	if (old_mem->mem_type != TTM_PL_SYSTEM) {

-   ret = ttm_bo_wait_ctx(bo, ctx);
-
-   if (unlikely(ret != 0)) {
-   if (ret != -ERESTARTSYS)
-   pr_err("Failed to expire sync object before 
unbinding TTM\n");
-   return ret;
-   }
-
-   ttm_bo_tt_unbind(bo);
-   ttm_resource_free(bo, >mem);
-   old_mem->mem_type = TTM_PL_SYSTEM;
-   }
+   ret = ttm_bo_move_old_to_system(bo, ctx);
+   if (unlikely(ret != 0))
+   return ret;
  
  	ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem);

if (unlikely(ret != 0))


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8

2020-10-19 Thread Peilin Ye
On Sun, Oct 18, 2020 at 11:51:19PM +0200, Daniel Vetter wrote:
> On Sun, Oct 18, 2020 at 10:45 PM Peilin Ye  wrote:
> > I'm confused, I see it on LKML in the link above. Sure I'll resend soon.
> 
> My brain didn't work, sorry about the confusion.
> 
> I'll pick up the patches tomorrow, probably not a good idea I do
> anything more today :-)

Ah, no worries, thanks!

Peilin Ye

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/5] drm/ttm: refactor out common code to setup a new tt backed resource

2020-10-19 Thread Christian König

Am 19.10.20 um 09:13 schrieb Dave Airlie:

From: Dave Airlie 

This factors out the code to setup non-system tt.

The same code was used twice in the move paths.

Reviewed-by: Ben Skeggs 
Signed-off-by: Dave Airlie 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/ttm/ttm_bo.c  | 12 +++
  drivers/gpu/drm/ttm/ttm_bo_util.c | 34 +--
  include/drm/ttm/ttm_bo_driver.h   |  4 
  3 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index b97ed6ca8765..cbc74a320db2 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -252,15 +252,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object 
*bo,
if (ret)
goto out_err;
  
-		if (mem->mem_type != TTM_PL_SYSTEM) {

-   ret = ttm_tt_populate(bdev, bo->ttm, ctx);
-   if (ret)
-   goto out_err;
-
-   ret = ttm_bo_tt_bind(bo, mem);
-   if (ret)
-   goto out_err;
-   }
+   ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem);
+   if (ret)
+   goto out_err;
}
  
  	if (bdev->driver->move_notify)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index ed1114235b66..a36c615bdf24 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -45,11 +45,30 @@ struct ttm_transfer_obj {
struct ttm_buffer_object *bo;
  };
  
+int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,

+ struct ttm_operation_ctx *ctx,
+ struct ttm_resource *new_mem)
+{
+   int ret;
+
+   if (new_mem->mem_type == TTM_PL_SYSTEM)
+   return 0;
+
+   ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+   if (unlikely(ret != 0))
+   return ret;
+
+   ret = ttm_bo_tt_bind(bo, new_mem);
+   if (unlikely(ret != 0))
+   return ret;
+
+   return 0;
+}
+
  int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
   struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem)
  {
-   struct ttm_tt *ttm = bo->ttm;
struct ttm_resource *old_mem = >mem;
int ret;
  
@@ -67,16 +86,9 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,

old_mem->mem_type = TTM_PL_SYSTEM;
}
  
-	if (new_mem->mem_type != TTM_PL_SYSTEM) {

-
-   ret = ttm_tt_populate(bo->bdev, ttm, ctx);
-   if (unlikely(ret != 0))
-   return ret;
-
-   ret = ttm_bo_tt_bind(bo, new_mem);
-   if (unlikely(ret != 0))
-   return ret;
-   }
+   ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem);
+   if (unlikely(ret != 0))
+   return ret;
  
  	ttm_bo_assign_mem(bo, new_mem);

return 0;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 3dbc11eb6787..1f4d2b1febd0 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -593,6 +593,10 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem);
  
+int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,

+ struct ttm_operation_ctx *ctx,
+ struct ttm_resource *new_mem);
+
  /**
   * ttm_bo_move_memcpy
   *


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >