Re: [Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Harry Wentland
On 2018-03-22 01:54 PM, Emil Velikov wrote:
> Hi Ville,
> 
> On 22 March 2018 at 15:22, Ville Syrjala  
> wrote:
>> From: Ville Syrjälä 
>>
>> I really just wanted to fix i915 to re-enable its planes afer load
>> detection (a two line patch). This is what I actually ended up with
>> after I ran into a framebuffer refcount leak with said two line patch.
>>
>> I've tested this on a few i915 boxes and so far it's looking
>> good. Everything else is just compile tested.
>>
> Mostly thinking out loud:
> 
> Wondering if one cannot somehow (re)move plane->fb/crtc altogether.
> Otherwise drivers will reintroduce similar code, despite the WARNs and
> beefy documentation :-\

Wouldn't that require an atomic conversion of all remaining drivers?

Harry

> 
> HTH
> Emil
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Noralf Trønnes


Den 22.03.2018 19.49, skrev Ville Syrjälä:

On Thu, Mar 22, 2018 at 05:51:35PM +0100, Noralf Trønnes wrote:

tinydrm is also using plane->fb:

$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/
drivers/gpu/drm/tinydrm/repaper.c:  if (tdev->pipe.plane.fb != fb)
drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb)
drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb =
mipi->tinydrm.pipe.plane.fb;

Oh dear, and naturally it's the most annoying one of the bunch. So we
want to take the plane lock in the fb.dirty() hook to look at the fb,
but mipi-dbi.c calls that directly from the bowels of its
.atomic_enable() hook. So that would deadlock pretty neatly if the
commit happens while already holding the lock.

So we'd either need to plumb an acquire context into fb.dirty(),
or maybe have tinydrm provide a lower level lockless dirty() hook
that gets called by both (there are just too many layers in this
particular cake to immediately see where such a hook would be best
placed). Or maybe there's some other solution I didn't think of.

Looking at this I'm also left wondering how this is supposed
handle fb.dirty() getting called concurrently with a modeset.
The dirty_mutex only seems to offer any protection for
fb.dirty() against another fb.dirty()...



I have been waiting for the 'page-flip with damage'[1] work to come to
fruition so I could handle all flushing during atomic commit.
The idea is to use the same damage rect for a generic dirtyfb callback.

Maybe a temporary tinydrm specific solution is possible until that work
lands, but I don't know enough about how to implement such a dirtyfb
callback.

I imagine it could look something like this:

 struct tinydrm_device {
+    struct drm_clip_rect dirtyfb_rect;
 };

static int tinydrm_fb_dirty(struct drm_framebuffer *fb,
                struct drm_file *file_priv,
                unsigned int flags, unsigned int color,
                struct drm_clip_rect *clips,
                unsigned int num_clips)
{
    struct tinydrm_device *tdev = fb->dev->dev_private;
    struct drm_framebuffer *planefb;

    /* Grab whatever lock needed to check this */
    planefb = tdev->pipe.plane.state->fb;

    /* fbdev can flush even when we're not interested */
    if (fb != planefb)
        return 0;

    /* Protect dirtyfb_rect with a lock */
    tinydrm_merge_clips(&tdev->dirty_rectfb, clips, num_clips, flags,
                fb->width, fb->height);

    /*
     * Somehow do an atomic commit that results in the atomic update
     * callback being called
     */
    ret = drm_atomic_commit(state);
...
}

static void mipi_dbi_flush(struct drm_framebuffer *fb,
               struct drm_clip_rect *clip)
{
    /* Flush out framebuffer */
}

void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
              struct drm_plane_state *old_state)
{
    struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
    struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
    struct drm_framebuffer *fb = pipe->plane.state->fb;
    struct drm_crtc *crtc = &tdev->pipe.crtc;

    if (!fb || (fb == old_state->fb && !tdev->dirty_rect.x2))
        goto out_vblank;

    /* Don't flush if the controller isn't initialized yet */
    if (!mipi->enabled)
        goto out_vblank;

    if (fb != old_state->fb) { /* Page flip or new, flush all */
        mipi_dbi_flush(fb, NULL);
    } else { /* dirtyfb ioctl */
        mipi_dbi_flush(fb, &tdev->dirtyfb_rect);
        memset(&tdev->dirtyfb_rect, 0, sizeof(tdev->dirtyfb_rect));
    }

out_vblank:
    if (crtc->state->event) {
        spin_lock_irq(&crtc->dev->event_lock);
        drm_crtc_send_vblank_event(crtc, crtc->state->event);
        spin_unlock_irq(&crtc->dev->event_lock);
        crtc->state->event = NULL;
    }
}

This is called from the driver pipe enable callback after the controller
has been initialized:

 void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe,
           struct drm_crtc_state *crtc_state)
 {
 struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
 struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
-     struct drm_framebuffer *fb = pipe->plane.fb;
+    struct drm_framebuffer *fb = pipe->plane.state->fb;

 DRM_DEBUG_KMS("\n");

 mipi->enabled = true;
-     if (fb)
-         fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
+    mipi_dbi_flush(fb, NULL);
 tinydrm_enable_backlight(mipi->backlight);
 }

I can make patches if this makes any sense and you can help me with the
dirtyfb implementation.

Noralf.

[1] 
https://lists.freedesktop.org/archives/dri-devel/2017-December/161003.html


___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Ville Syrjälä
On Thu, Mar 22, 2018 at 05:51:35PM +0100, Noralf Trønnes wrote:
> tinydrm is also using plane->fb:
> 
> $ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/
> drivers/gpu/drm/tinydrm/repaper.c:  if (tdev->pipe.plane.fb != fb)
> drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb)
> drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = 
> mipi->tinydrm.pipe.plane.fb;

Oh dear, and naturally it's the most annoying one of the bunch. So we
want to take the plane lock in the fb.dirty() hook to look at the fb,
but mipi-dbi.c calls that directly from the bowels of its
.atomic_enable() hook. So that would deadlock pretty neatly if the
commit happens while already holding the lock.

So we'd either need to plumb an acquire context into fb.dirty(),
or maybe have tinydrm provide a lower level lockless dirty() hook
that gets called by both (there are just too many layers in this
particular cake to immediately see where such a hook would be best
placed). Or maybe there's some other solution I didn't think of.

Looking at this I'm also left wondering how this is supposed
handle fb.dirty() getting called concurrently with a modeset.
The dirty_mutex only seems to offer any protection for
fb.dirty() against another fb.dirty()...

-- 
Ville Syrjälä
Intel OTC
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Emil Velikov
On 22 March 2018 at 18:03, Harry Wentland  wrote:
> On 2018-03-22 01:54 PM, Emil Velikov wrote:
>> Hi Ville,
>>
>> On 22 March 2018 at 15:22, Ville Syrjala  
>> wrote:
>>> From: Ville Syrjälä 
>>>
>>> I really just wanted to fix i915 to re-enable its planes afer load
>>> detection (a two line patch). This is what I actually ended up with
>>> after I ran into a framebuffer refcount leak with said two line patch.
>>>
>>> I've tested this on a few i915 boxes and so far it's looking
>>> good. Everything else is just compile tested.
>>>
>> Mostly thinking out loud:
>>
>> Wondering if one cannot somehow (re)move plane->fb/crtc altogether.
>> Otherwise drivers will reintroduce similar code, despite the WARNs and
>> beefy documentation :-\
>
> Wouldn't that require an atomic conversion of all remaining drivers?
>
That or maybe move into plane->legacy->{fb,crtc}. Feel free to swap
'legacy' with flashier name.

Hmm back in 2015 we had a GSoC that updated BOCHS and CIRRUS drivers,
but they never got merged.
Don't recall the details - from memory the conversion seemed fine, but
there was either shortage on review/other.

Might be worth reviving that... regardless it's getting a bit off-topic.
-Emil

[1] 
https://www.google-melange.com/archive/gsoc/2015/orgs/xorg/projects/johnhunter.html
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Emil Velikov
Hi Ville,

On 22 March 2018 at 15:22, Ville Syrjala  wrote:
> From: Ville Syrjälä 
>
> I really just wanted to fix i915 to re-enable its planes afer load
> detection (a two line patch). This is what I actually ended up with
> after I ran into a framebuffer refcount leak with said two line patch.
>
> I've tested this on a few i915 boxes and so far it's looking
> good. Everything else is just compile tested.
>
Mostly thinking out loud:

Wondering if one cannot somehow (re)move plane->fb/crtc altogether.
Otherwise drivers will reintroduce similar code, despite the WARNs and
beefy documentation :-\

HTH
Emil
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Noralf Trønnes


Den 22.03.2018 16.22, skrev Ville Syrjala:

From: Ville Syrjälä 

I really just wanted to fix i915 to re-enable its planes afer load
detection (a two line patch). This is what I actually ended up with
after I ran into a framebuffer refcount leak with said two line patch.

I've tested this on a few i915 boxes and so far it's looking
good. Everything else is just compile tested.

Entire series available here:
git://github.com/vsyrjala/linux.git plane_fb_crtc_nuke

Cc: Alex Deucher 
Cc: amd-...@lists.freedesktop.org
Cc: Benjamin Gaignard 
Cc: Boris Brezillon 
Cc: ch...@chris-wilson.co.uk
Cc: "Christian König" 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: David Airlie 
Cc: "David (ChunMing) Zhou" 
Cc: Eric Anholt 
Cc: freedreno@lists.freedesktop.org
Cc: Gerd Hoffmann 
Cc: Harry Wentland 
Cc: Inki Dae 
Cc: Joonyoung Shim 
Cc: Kyungmin Park 
Cc: linux-arm-...@vger.kernel.org
Cc: Maarten Lankhorst 
Cc: martin.pe...@free.fr
Cc: Rob Clark 
Cc: Seung-Woo Kim 
Cc: Shawn Guo 
Cc: Sinclair Yeh 
Cc: Thomas Hellstrom 
Cc: Vincent Abriou 
Cc: virtualizat...@lists.linux-foundation.org
Cc: VMware Graphics 

Ville Syrjälä (23):
   Revert "drm/atomic-helper: Fix leak in disable_all"
   drm/atomic-helper: Make drm_atomic_helper_disable_all() update the
 plane->fb pointers
   drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()
   drm/atomic-helper: WARN if legacy plane fb pointers are bogus when
 committing duplicated state
   drm: Add local 'plane' variable for primary/cursor planes
   drm: Adjust whitespace for legibility
   drm: Make the fb refcount handover less magic
   drm: Use plane->state->fb over plane->fb
   drm/i915: Stop consulting plane->fb
   drm/msm: Stop consulting plane->fb
   drm/sti: Stop consulting plane->fb
   drm/vmwgfx: Stop consulting plane->fb
   drm/zte: Stop consulting plane->fb
   drm/atmel-hlcdc: Stop using plane->fb
   drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
   drm/amdgpu/dc: Stop updating plane->fb
   drm/i915: Stop updating plane->fb/crtc
   drm/exynos: Stop updating plane->crtc
   drm/msm: Stop updating plane->fb/crtc
   drm/virtio: Stop updating plane->fb
   drm/vc4: Stop updating plane->fb/crtc
   drm/i915: Restore planes after load detection
   drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug


tinydrm is also using plane->fb:

$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/
drivers/gpu/drm/tinydrm/repaper.c:  if (tdev->pipe.plane.fb != fb)
drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb)
drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = 
mipi->tinydrm.pipe.plane.fb;

drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c: pipe->plane.fb = fb;
drivers/gpu/drm/tinydrm/ili9225.c:  if (tdev->pipe.plane.fb != fb)
drivers/gpu/drm/tinydrm/st7586.c:   if (tdev->pipe.plane.fb != fb)

Noralf.


  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 -
  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c   | 12 +---
  drivers/gpu/drm/drm_atomic.c  | 55 ++--
  drivers/gpu/drm/drm_atomic_helper.c   | 79 ++-
  drivers/gpu/drm/drm_crtc.c| 51 ++-
  drivers/gpu/drm/drm_fb_helper.c   |  7 --
  drivers/gpu/drm/drm_framebuffer.c |  5 --
  drivers/gpu/drm/drm_plane.c   | 64 +++---
  drivers/gpu/drm/drm_plane_helper.c|  4 +-
  drivers/gpu/drm/exynos/exynos_drm_plane.c |  2 -
  drivers/gpu/drm/i915/intel_crt.c  |  6 ++
  drivers/gpu/drm/i915/intel_display.c  |  9 +--
  drivers/gpu/drm/i915/intel_fbdev.c|  2 +-
  drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |  3 +-
  drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c|  2 -
  drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c|  2 -
  drivers/gpu/drm/sti/sti_plane.c   |  9 +--
  drivers/gpu/drm/vc4/vc4_crtc.c|  3 -
  drivers/gpu/drm/virtio/virtgpu_display.c  |  2 -
  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c   |  6 +-
  drivers/gpu/drm/zte/zx_vou.c  |  2 +-
  include/drm/drm_atomic.h  |  3 -
  22 files changed, 143 insertions(+), 187 deletions(-)



___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH v2 0/8] freedreno: a2xx improvements

2018-03-22 Thread Wladimir J. van der Laan
On Thu, Mar 22, 2018 at 11:46:57AM -0400, Ilia Mirkin wrote:
> With the minor whitespace issue I pointed out (which might also apply
> to 8/8, couldn't tell), this is

Looks like there is also a case in 5/8, will go over them and resubmit the ones
with wacky spacing.
(I think the issue here is that I had set my editor for spaces due to the other
parts of mesa)

> Reviewed-by: Ilia Mirkin 

Thanks.

Wladimir
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH v2 0/8] freedreno: a2xx improvements

2018-03-22 Thread Ilia Mirkin
With the minor whitespace issue I pointed out (which might also apply
to 8/8, couldn't tell), this is

Reviewed-by: Ilia Mirkin 

On Thu, Mar 22, 2018 at 11:26 AM, Wladimir J. van der Laan
 wrote:
> While working on a205 support for i.MX51/53, I've also written some patches
> that are not specific to a20x but should apply to the whole a2xx range.
>
> As I'm figuring out how to handle backward compatibility to other a2xx, I
> think it makes sense to send these upstream already to reduce the patch stack.
>
> Changes since first post:
>
> - Split up rnndb patch into a patch that changes formate numeration
>   and one that changed BLEND->BLEND2.
> - fd2_emit emit_texture const correctness.
>
> I checked that there is no Gallium capability to be set for TEXTURE_RECT.
>
> Wladimir J. van der Laan (8):
>   freedreno: a2xx: Update rnndb header for formats enumeration
>   freedreno: a2xx: Change use of BLEND_ to BLEND2_
>   freedreno: a2xx: Fix fd2_tex_swiz
>   freedreno: a2xx: Prevent crash in emit_texture if view is not set
>   freedreno: a2xx: Support TEXTURE_RECT
>   freedreno: a2xx: Compressed textures support
>   freedreno: a2xx: implement SEQ/SNE instructions
>   freedreno: a2xx: Implement DP2 instruction
>
>  src/gallium/drivers/freedreno/a2xx/a2xx.xml.h | 33 +++-
>  src/gallium/drivers/freedreno/a2xx/fd2_compiler.c | 47 
> +--
>  src/gallium/drivers/freedreno/a2xx/fd2_emit.c | 13 +--
>  src/gallium/drivers/freedreno/a2xx/fd2_gmem.c |  4 +-
>  src/gallium/drivers/freedreno/a2xx/fd2_util.c | 29 +-
>  src/gallium/drivers/freedreno/a2xx/ir-a2xx.c  |  1 +
>  src/gallium/drivers/freedreno/a2xx/ir-a2xx.h  |  1 +
>  7 files changed, 90 insertions(+), 38 deletions(-)
>
> --
> 2.7.4
>
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH v2 7/8] freedreno: a2xx: implement SEQ/SNE instructions

2018-03-22 Thread Ilia Mirkin
On Thu, Mar 22, 2018 at 11:26 AM, Wladimir J. van der Laan
 wrote:
> Extend translate_sge_slt to emit these, in analogous fashion
> but using CNDEv.
>
> Signed-off-by: Wladimir J. van der Laan 
> ---
>  src/gallium/drivers/freedreno/a2xx/fd2_compiler.c | 23 
> ---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c 
> b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
> index 9f2fc61..52f0aba 100644
> --- a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
> +++ b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
> @@ -829,8 +829,10 @@ translate_tex(struct fd2_compile_context *ctx,
>
>  /* SGE(a,b) = GTE((b - a), 1.0, 0.0) */
>  /* SLT(a,b) = GTE((b - a), 0.0, 1.0) */
> +/* SEQ(a,b) = EQU((b - a), 1.0, 0.0) */
> +/* SNE(a,b) = EQU((b - a), 0.0, 1.0) */
>  static void
> -translate_sge_slt(struct fd2_compile_context *ctx,
> +translate_sge_slt_seq_sne(struct fd2_compile_context *ctx,
> struct tgsi_full_instruction *inst, unsigned opc)
>  {
> struct ir2_instruction *instr;
> @@ -838,6 +840,7 @@ translate_sge_slt(struct fd2_compile_context *ctx,
> struct tgsi_src_register tmp_src;
> struct tgsi_src_register tmp_const;
> float c0, c1;
> +instr_vector_opc_t vopc;

tabs vs spaces, here and elsewhere in this commit.

>
> switch (opc) {
> default:
> @@ -845,10 +848,22 @@ translate_sge_slt(struct fd2_compile_context *ctx,
> case TGSI_OPCODE_SGE:
> c0 = 1.0;
> c1 = 0.0;
> +vopc = CNDGTEv;
> break;
> case TGSI_OPCODE_SLT:
> c0 = 0.0;
> c1 = 1.0;
> +vopc = CNDGTEv;
> +   break;
> +   case TGSI_OPCODE_SEQ:
> +   c0 = 0.0;
> +   c1 = 1.0;
> +vopc = CNDEv;
> +   break;
> +   case TGSI_OPCODE_SNE:
> +   c0 = 1.0;
> +   c1 = 0.0;
> +vopc = CNDEv;
> break;
> }
>
> @@ -859,7 +874,7 @@ translate_sge_slt(struct fd2_compile_context *ctx,
> add_src_reg(ctx, instr, &inst->Src[0].Register)->flags |= 
> IR2_REG_NEGATE;
> add_src_reg(ctx, instr, &inst->Src[1].Register);
>
> -   instr = ir2_instr_create_alu(next_exec_cf(ctx), CNDGTEv, ~0);
> +   instr = ir2_instr_create_alu(next_exec_cf(ctx), vopc, ~0);
> add_dst_reg(ctx, instr, &inst->Dst[0].Register);
> /* maybe should re-arrange the syntax some day, but
>  * in assembler/disassembler and what ir.c expects
> @@ -1057,7 +1072,9 @@ translate_instruction(struct fd2_compile_context *ctx,
> break;
> case TGSI_OPCODE_SLT:
> case TGSI_OPCODE_SGE:
> -   translate_sge_slt(ctx, inst, opc);
> +case TGSI_OPCODE_SEQ:
> +case TGSI_OPCODE_SNE:
> +   translate_sge_slt_seq_sne(ctx, inst, opc);
> break;
> case TGSI_OPCODE_MAD:
> instr = ir2_instr_create_alu(cf, MULADDv, ~0);
> --
> 2.7.4
>
> ___
> Freedreno mailing list
> Freedreno@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 8/8] freedreno: a2xx: Implement DP2 instruction

2018-03-22 Thread Wladimir J. van der Laan
Use DOT2ADDv instruction with 0.0f constant add.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_compiler.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
index 52f0aba..ce0b33a 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
@@ -987,6 +987,24 @@ translate_trig(struct fd2_compile_context *ctx,
add_src_reg(ctx, instr, &tmp_src);
 }
 
+static void
+translate_dp2(struct fd2_compile_context *ctx,
+   struct tgsi_full_instruction *inst,
+   unsigned opc)
+{
+struct tgsi_src_register tmp_const;
+struct ir2_instruction *instr;
+/* DP2ADD c,a,b -> dot2(a,b) + c */
+/* for c we use the constant 0.0 */
+instr = ir2_instr_create_alu(next_exec_cf(ctx), DOT2ADDv, ~0);
+get_immediate(ctx, &tmp_const, fui(0.0f));
+add_dst_reg(ctx, instr, &inst->Dst[0].Register);
+add_src_reg(ctx, instr, &tmp_const);
+add_src_reg(ctx, instr, &inst->Src[0].Register);
+add_src_reg(ctx, instr, &inst->Src[1].Register);
+add_vector_clamp(inst, instr);
+}
+
 /*
  * Main part of compiler/translator:
  */
@@ -1054,6 +1072,9 @@ translate_instruction(struct fd2_compile_context *ctx,
instr = ir2_instr_create_alu(cf, ADDv, ~0);
add_regs_vector_2(ctx, inst, instr);
break;
+   case TGSI_OPCODE_DP2:
+   translate_dp2(ctx, inst, opc);
+   break;
case TGSI_OPCODE_DP3:
instr = ir2_instr_create_alu(cf, DOT3v, ~0);
add_regs_vector_2(ctx, inst, instr);
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 4/8] freedreno: a2xx: Prevent crash in emit_texture if view is not set

2018-03-22 Thread Wladimir J. van der Laan
Textures will sometimes be updated if texture view state was
un-set, without this change that causes an assertion crash or
segfault.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_emit.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c
index 5a1db13..a787b71 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c
@@ -125,8 +125,9 @@ emit_texture(struct fd_ringbuffer *ring, struct fd_context 
*ctx,
 {
unsigned const_idx = fd2_get_const_idx(ctx, tex, samp_id);
static const struct fd2_sampler_stateobj dummy_sampler = {};
+   static const struct fd2_pipe_sampler_view dummy_view = {};
const struct fd2_sampler_stateobj *sampler;
-   struct fd2_pipe_sampler_view *view;
+   const struct fd2_pipe_sampler_view *view;
 
if (emitted & (1 << const_idx))
return 0;
@@ -134,13 +135,19 @@ emit_texture(struct fd_ringbuffer *ring, struct 
fd_context *ctx,
sampler = tex->samplers[samp_id] ?
fd2_sampler_stateobj(tex->samplers[samp_id]) :
&dummy_sampler;
-   view = fd2_pipe_sampler_view(tex->textures[samp_id]);
+   view = tex->textures[samp_id] ?
+   fd2_pipe_sampler_view(tex->textures[samp_id]) :
+   &dummy_view;
 
OUT_PKT3(ring, CP_SET_CONSTANT, 7);
OUT_RING(ring, 0x0001 + (0x6 * const_idx));
 
OUT_RING(ring, sampler->tex0 | view->tex0);
-   OUT_RELOC(ring, fd_resource(view->base.texture)->bo, 0, view->fmt, 0);
+   if (view->base.texture)
+   OUT_RELOC(ring, fd_resource(view->base.texture)->bo, 0, 
view->fmt, 0);
+   else
+   OUT_RING(ring, 0);
+
OUT_RING(ring, view->tex2);
OUT_RING(ring, sampler->tex3 | view->tex3);
OUT_RING(ring, sampler->tex4);
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 7/8] freedreno: a2xx: implement SEQ/SNE instructions

2018-03-22 Thread Wladimir J. van der Laan
Extend translate_sge_slt to emit these, in analogous fashion
but using CNDEv.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_compiler.c | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
index 9f2fc61..52f0aba 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
@@ -829,8 +829,10 @@ translate_tex(struct fd2_compile_context *ctx,
 
 /* SGE(a,b) = GTE((b - a), 1.0, 0.0) */
 /* SLT(a,b) = GTE((b - a), 0.0, 1.0) */
+/* SEQ(a,b) = EQU((b - a), 1.0, 0.0) */
+/* SNE(a,b) = EQU((b - a), 0.0, 1.0) */
 static void
-translate_sge_slt(struct fd2_compile_context *ctx,
+translate_sge_slt_seq_sne(struct fd2_compile_context *ctx,
struct tgsi_full_instruction *inst, unsigned opc)
 {
struct ir2_instruction *instr;
@@ -838,6 +840,7 @@ translate_sge_slt(struct fd2_compile_context *ctx,
struct tgsi_src_register tmp_src;
struct tgsi_src_register tmp_const;
float c0, c1;
+instr_vector_opc_t vopc;
 
switch (opc) {
default:
@@ -845,10 +848,22 @@ translate_sge_slt(struct fd2_compile_context *ctx,
case TGSI_OPCODE_SGE:
c0 = 1.0;
c1 = 0.0;
+vopc = CNDGTEv;
break;
case TGSI_OPCODE_SLT:
c0 = 0.0;
c1 = 1.0;
+vopc = CNDGTEv;
+   break;
+   case TGSI_OPCODE_SEQ:
+   c0 = 0.0;
+   c1 = 1.0;
+vopc = CNDEv;
+   break;
+   case TGSI_OPCODE_SNE:
+   c0 = 1.0;
+   c1 = 0.0;
+vopc = CNDEv;
break;
}
 
@@ -859,7 +874,7 @@ translate_sge_slt(struct fd2_compile_context *ctx,
add_src_reg(ctx, instr, &inst->Src[0].Register)->flags |= 
IR2_REG_NEGATE;
add_src_reg(ctx, instr, &inst->Src[1].Register);
 
-   instr = ir2_instr_create_alu(next_exec_cf(ctx), CNDGTEv, ~0);
+   instr = ir2_instr_create_alu(next_exec_cf(ctx), vopc, ~0);
add_dst_reg(ctx, instr, &inst->Dst[0].Register);
/* maybe should re-arrange the syntax some day, but
 * in assembler/disassembler and what ir.c expects
@@ -1057,7 +1072,9 @@ translate_instruction(struct fd2_compile_context *ctx,
break;
case TGSI_OPCODE_SLT:
case TGSI_OPCODE_SGE:
-   translate_sge_slt(ctx, inst, opc);
+case TGSI_OPCODE_SEQ:
+case TGSI_OPCODE_SNE:
+   translate_sge_slt_seq_sne(ctx, inst, opc);
break;
case TGSI_OPCODE_MAD:
instr = ir2_instr_create_alu(cf, MULADDv, ~0);
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 6/8] freedreno: a2xx: Compressed textures support

2018-03-22 Thread Wladimir J. van der Laan
Add support for:

- PIPE_FORMAT_ETC1_RGB8
- PIPE_FORMAT_DXT1_RGB
- PIPE_FORMAT_DXT1_RGBA
- PIPE_FORMAT_DXT3_RGBA
- PIPE_FORMAT_DXT5_RGBA

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_util.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_util.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_util.c
index 25f2bf4..60e5c39 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_util.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_util.c
@@ -183,6 +183,17 @@ fd2_pipe2surface(enum pipe_format format)
case PIPE_FORMAT_R32G32B32A32_FLOAT:
return FMT_32_32_32_32_FLOAT;
 
+/* Compressed textures. */
+case PIPE_FORMAT_ETC1_RGB8:
+return FMT_ETC1_RGB;
+case PIPE_FORMAT_DXT1_RGB:
+case PIPE_FORMAT_DXT1_RGBA:
+return FMT_DXT1;
+case PIPE_FORMAT_DXT3_RGBA:
+return FMT_DXT2_3;
+case PIPE_FORMAT_DXT5_RGBA:
+return FMT_DXT4_5;
+
/* YUV buffers. */
case PIPE_FORMAT_UYVY:
return FMT_Cr_Y1_Cb_Y0;
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 5/8] freedreno: a2xx: Support TEXTURE_RECT

2018-03-22 Thread Wladimir J. van der Laan
Denormalized texture coordinates are required for text rendering in
GALLIUM_HUD.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_compiler.c | 3 ++-
 src/gallium/drivers/freedreno/a2xx/ir-a2xx.c  | 1 +
 src/gallium/drivers/freedreno/a2xx/ir-a2xx.h  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
index 2ffd8cd..9f2fc61 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
@@ -791,6 +791,7 @@ translate_tex(struct fd2_compile_context *ctx,
instr = ir2_instr_create(next_exec_cf(ctx), IR2_FETCH);
instr->fetch.opc = TEX_FETCH;
instr->fetch.is_cube = (inst->Texture.Texture == TGSI_TEXTURE_3D);
+   instr->fetch.is_rect = (inst->Texture.Texture == TGSI_TEXTURE_RECT);
assert(inst->Texture.NumOffsets <= 1); // TODO what to do in other 
cases?
 
/* save off the tex fetch to be patched later with correct const_idx: */
@@ -802,7 +803,7 @@ translate_tex(struct fd2_compile_context *ctx,
reg = add_src_reg(ctx, instr, coord);
 
/* blob compiler always sets 3rd component to same as 1st for 2d: */
-   if (inst->Texture.Texture == TGSI_TEXTURE_2D)
+   if (inst->Texture.Texture == TGSI_TEXTURE_2D || inst->Texture.Texture 
== TGSI_TEXTURE_RECT)
reg->swizzle[2] = reg->swizzle[0];
 
/* dst register needs to be marked for sync: */
diff --git a/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c 
b/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c
index 163c282..42a9ab4 100644
--- a/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c
+++ b/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c
@@ -341,6 +341,7 @@ static int instr_emit_fetch(struct ir2_instruction *instr,
tex->use_comp_lod = 1;
tex->use_reg_lod = !instr->fetch.is_cube;
tex->sample_location = SAMPLE_CENTER;
+   tex->tx_coord_denorm = instr->fetch.is_rect;
 
if (instr->pred != IR2_PRED_NONE) {
tex->pred_select = 1;
diff --git a/src/gallium/drivers/freedreno/a2xx/ir-a2xx.h 
b/src/gallium/drivers/freedreno/a2xx/ir-a2xx.h
index 36ed204..c4b6c18 100644
--- a/src/gallium/drivers/freedreno/a2xx/ir-a2xx.h
+++ b/src/gallium/drivers/freedreno/a2xx/ir-a2xx.h
@@ -74,6 +74,7 @@ struct ir2_instruction {
unsigned const_idx;
/* texture fetch specific: */
bool is_cube : 1;
+   bool is_rect : 1;
/* vertex fetch specific: */
unsigned const_idx_sel;
enum a2xx_sq_surfaceformat fmt;
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 3/8] freedreno: a2xx: Fix fd2_tex_swiz

2018-03-22 Thread Wladimir J. van der Laan
Compose swizzles using util_format_compose_swizzles instead
of the custom code (which somehow had a bug).

This makes the GL_ALPHA internal format work.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_util.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_util.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_util.c
index 0bdcfcd..25f2bf4 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_util.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_util.c
@@ -309,14 +309,14 @@ fd2_tex_swiz(enum pipe_format format, unsigned swizzle_r, 
unsigned swizzle_g,
 {
const struct util_format_description *desc =
util_format_description(format);
-   uint8_t swiz[] = {
-   swizzle_r, swizzle_g, swizzle_b, swizzle_a,
-   PIPE_SWIZZLE_0, PIPE_SWIZZLE_1,
-   PIPE_SWIZZLE_1, PIPE_SWIZZLE_1,
-   };
+   unsigned char swiz[4] = {
+   swizzle_r, swizzle_g, swizzle_b, swizzle_a,
+   }, rswiz[4];
 
-   return A2XX_SQ_TEX_3_SWIZ_X(tex_swiz(swiz[desc->swizzle[0]])) |
-   A2XX_SQ_TEX_3_SWIZ_Y(tex_swiz(swiz[desc->swizzle[1]])) |
-   A2XX_SQ_TEX_3_SWIZ_Z(tex_swiz(swiz[desc->swizzle[2]])) |
-   A2XX_SQ_TEX_3_SWIZ_W(tex_swiz(swiz[desc->swizzle[3]]));
+   util_format_compose_swizzles(desc->swizzle, swiz, rswiz);
+
+   return A2XX_SQ_TEX_3_SWIZ_X(tex_swiz(rswiz[0])) |
+   A2XX_SQ_TEX_3_SWIZ_Y(tex_swiz(rswiz[1])) |
+   A2XX_SQ_TEX_3_SWIZ_Z(tex_swiz(rswiz[2])) |
+   A2XX_SQ_TEX_3_SWIZ_W(tex_swiz(rswiz[3]));
 }
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 0/8] freedreno: a2xx improvements

2018-03-22 Thread Wladimir J. van der Laan
While working on a205 support for i.MX51/53, I've also written some patches
that are not specific to a20x but should apply to the whole a2xx range.

As I'm figuring out how to handle backward compatibility to other a2xx, I
think it makes sense to send these upstream already to reduce the patch stack.

Changes since first post:

- Split up rnndb patch into a patch that changes formate numeration
  and one that changed BLEND->BLEND2.
- fd2_emit emit_texture const correctness.

I checked that there is no Gallium capability to be set for TEXTURE_RECT.

Wladimir J. van der Laan (8):
  freedreno: a2xx: Update rnndb header for formats enumeration
  freedreno: a2xx: Change use of BLEND_ to BLEND2_
  freedreno: a2xx: Fix fd2_tex_swiz
  freedreno: a2xx: Prevent crash in emit_texture if view is not set
  freedreno: a2xx: Support TEXTURE_RECT
  freedreno: a2xx: Compressed textures support
  freedreno: a2xx: implement SEQ/SNE instructions
  freedreno: a2xx: Implement DP2 instruction

 src/gallium/drivers/freedreno/a2xx/a2xx.xml.h | 33 +++-
 src/gallium/drivers/freedreno/a2xx/fd2_compiler.c | 47 +--
 src/gallium/drivers/freedreno/a2xx/fd2_emit.c | 13 +--
 src/gallium/drivers/freedreno/a2xx/fd2_gmem.c |  4 +-
 src/gallium/drivers/freedreno/a2xx/fd2_util.c | 29 +-
 src/gallium/drivers/freedreno/a2xx/ir-a2xx.c  |  1 +
 src/gallium/drivers/freedreno/a2xx/ir-a2xx.h  |  1 +
 7 files changed, 90 insertions(+), 38 deletions(-)

-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 1/8] freedreno: a2xx: Update rnndb header for formats enumeration

2018-03-22 Thread Wladimir J. van der Laan
The format enumeration comes comes from the yamoto
register headers that are part of the amd-gpu kernel driver.
(see freedreno envytools commit 1b32c444f82cd7144d71602106462f59f146c1d0)

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/a2xx.xml.h | 33 +++
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h 
b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h
index 55a4355..279a652 100644
--- a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h
+++ b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h
@@ -84,13 +84,12 @@ enum a2xx_sq_surfaceformat {
FMT_5_5_5_1 = 13,
FMT_8_8_8_8_A = 14,
FMT_4_4_4_4 = 15,
-   FMT_10_11_11 = 16,
-   FMT_11_11_10 = 17,
+   FMT_8_8_8 = 16,
FMT_DXT1 = 18,
FMT_DXT2_3 = 19,
FMT_DXT4_5 = 20,
+   FMT_10_10_10_2 = 21,
FMT_24_8 = 22,
-   FMT_24_8_FLOAT = 23,
FMT_16 = 24,
FMT_16_16 = 25,
FMT_16_16_16_16 = 26,
@@ -106,29 +105,23 @@ enum a2xx_sq_surfaceformat {
FMT_32_FLOAT = 36,
FMT_32_32_FLOAT = 37,
FMT_32_32_32_32_FLOAT = 38,
-   FMT_32_AS_8 = 39,
-   FMT_32_AS_8_8 = 40,
-   FMT_16_MPEG = 41,
-   FMT_16_16_MPEG = 42,
-   FMT_8_INTERLACED = 43,
-   FMT_32_AS_8_INTERLACED = 44,
-   FMT_32_AS_8_8_INTERLACED = 45,
-   FMT_16_INTERLACED = 46,
-   FMT_16_MPEG_INTERLACED = 47,
-   FMT_16_16_MPEG_INTERLACED = 48,
+   FMT_ATI_TC_RGB = 39,
+   FMT_ATI_TC_RGBA = 40,
+   FMT_ATI_TC_555_565_RGB = 41,
+   FMT_ATI_TC_555_565_RGBA = 42,
+   FMT_ATI_TC_RGBA_INTERP = 43,
+   FMT_ATI_TC_555_565_RGBA_INTERP = 44,
+   FMT_ETC1_RGBA_INTERP = 46,
+   FMT_ETC1_RGB = 47,
+   FMT_ETC1_RGBA = 48,
FMT_DXN = 49,
-   FMT_8_8_8_8_AS_16_16_16_16 = 50,
-   FMT_DXT1_AS_16_16_16_16 = 51,
-   FMT_DXT2_3_AS_16_16_16_16 = 52,
-   FMT_DXT4_5_AS_16_16_16_16 = 53,
+   FMT_2_3_3 = 51,
FMT_2_10_10_10_AS_16_16_16_16 = 54,
-   FMT_10_11_11_AS_16_16_16_16 = 55,
-   FMT_11_11_10_AS_16_16_16_16 = 56,
+   FMT_10_10_10_2_AS_16_16_16_16 = 55,
FMT_32_32_32_FLOAT = 57,
FMT_DXT3A = 58,
FMT_DXT5A = 59,
FMT_CTX1 = 60,
-   FMT_DXT3A_AS_1_1_1_1 = 61,
 };
 
 enum a2xx_sq_ps_vtx_mode {
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH v2 2/8] freedreno: a2xx: Change use of BLEND_ to BLEND2_

2018-03-22 Thread Wladimir J. van der Laan
Change use of BLEND_ to BLEND2_,

BLEND_* a3xx_rb_blend_opcode
BLEND2_* is a2xx_rb_blend_opcode

This makes no effective difference as the used enumerant has the same
value (0), but the other enumerants do not match 1-to-1 so this will
avoid future problems.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/freedreno/a2xx/fd2_gmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c
index 0905ab6..46a7d18 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c
@@ -293,10 +293,10 @@ fd2_emit_tile_mem2gmem(struct fd_batch *batch, struct 
fd_tile *tile)
OUT_PKT3(ring, CP_SET_CONSTANT, 2);
OUT_RING(ring, CP_REG(REG_A2XX_RB_BLEND_CONTROL));
OUT_RING(ring, A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND(FACTOR_ONE) |
-   
A2XX_RB_BLEND_CONTROL_COLOR_COMB_FCN(BLEND_DST_PLUS_SRC) |
+   
A2XX_RB_BLEND_CONTROL_COLOR_COMB_FCN(BLEND2_DST_PLUS_SRC) |
A2XX_RB_BLEND_CONTROL_COLOR_DESTBLEND(FACTOR_ZERO) |
A2XX_RB_BLEND_CONTROL_ALPHA_SRCBLEND(FACTOR_ONE) |
-   
A2XX_RB_BLEND_CONTROL_ALPHA_COMB_FCN(BLEND_DST_PLUS_SRC) |
+   
A2XX_RB_BLEND_CONTROL_ALPHA_COMB_FCN(BLEND2_DST_PLUS_SRC) |
A2XX_RB_BLEND_CONTROL_ALPHA_DESTBLEND(FACTOR_ZERO));
 
OUT_PKT3(ring, CP_SET_CONSTANT, 3);
-- 
2.7.4

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH 19/23] drm/msm: Stop updating plane->fb/crtc

2018-03-22 Thread Ville Syrjala
From: Ville Syrjälä 

We want to get rid of plane->fb/crtc on atomic drivers. Stop setting
them.

Cc: Rob Clark 
Cc: linux-arm-...@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c  | 1 -
 drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 --
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 --
 3 files changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
index 99ead8e37c72..13f3f155dc67 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -664,7 +664,6 @@ struct drm_crtc *mdp4_crtc_init(struct drm_device *dev,
drm_crtc_init_with_planes(dev, crtc, plane, NULL, &mdp4_crtc_funcs,
  NULL);
drm_crtc_helper_add(crtc, &mdp4_crtc_helper_funcs);
-   plane->crtc = crtc;
 
return crtc;
 }
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
index 7a1ad3af08e3..782b1e27f040 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
@@ -182,8 +182,6 @@ static void mdp4_plane_set_scanout(struct drm_plane *plane,
msm_framebuffer_iova(fb, kms->aspace, 2));
mdp4_write(mdp4_kms, REG_MDP4_PIPE_SRCP3_BASE(pipe),
msm_framebuffer_iova(fb, kms->aspace, 3));
-
-   plane->fb = fb;
 }
 
 static void mdp4_write_csc_config(struct mdp4_kms *mdp4_kms,
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
index a9f31da7d45a..29c2988e8104 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
@@ -1043,8 +1043,6 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
 src_img_w, src_img_h,
 src_x + src_w, src_y, src_w, src_h);
 
-   plane->fb = fb;
-
return ret;
 }
 
-- 
2.16.1

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH 10/23] drm/msm: Stop consulting plane->fb

2018-03-22 Thread Ville Syrjala
From: Ville Syrjälä 

We want to get rid of plane->fb on atomic drivers. Stop looking at it.

Cc: Rob Clark 
Cc: linux-arm-...@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
index 6e5e1aa54ce1..99ead8e37c72 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -201,7 +201,7 @@ static void blend_setup(struct drm_crtc *crtc)
int idx = idxs[pipe_id];
if (idx > 0) {
const struct mdp_format *format =
-   
to_mdp_format(msm_framebuffer_format(plane->fb));
+   
to_mdp_format(msm_framebuffer_format(plane->state->fb));
alpha[idx-1] = format->alpha_enable;
}
}
-- 
2.16.1

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-03-22 Thread Ville Syrjala
From: Ville Syrjälä 

I really just wanted to fix i915 to re-enable its planes afer load
detection (a two line patch). This is what I actually ended up with
after I ran into a framebuffer refcount leak with said two line patch.

I've tested this on a few i915 boxes and so far it's looking
good. Everything else is just compile tested.

Entire series available here:
git://github.com/vsyrjala/linux.git plane_fb_crtc_nuke

Cc: Alex Deucher 
Cc: amd-...@lists.freedesktop.org
Cc: Benjamin Gaignard 
Cc: Boris Brezillon 
Cc: ch...@chris-wilson.co.uk
Cc: "Christian König" 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: David Airlie 
Cc: "David (ChunMing) Zhou" 
Cc: Eric Anholt 
Cc: freedreno@lists.freedesktop.org
Cc: Gerd Hoffmann 
Cc: Harry Wentland 
Cc: Inki Dae 
Cc: Joonyoung Shim 
Cc: Kyungmin Park 
Cc: linux-arm-...@vger.kernel.org
Cc: Maarten Lankhorst 
Cc: martin.pe...@free.fr
Cc: Rob Clark 
Cc: Seung-Woo Kim 
Cc: Shawn Guo 
Cc: Sinclair Yeh 
Cc: Thomas Hellstrom 
Cc: Vincent Abriou 
Cc: virtualizat...@lists.linux-foundation.org
Cc: VMware Graphics 

Ville Syrjälä (23):
  Revert "drm/atomic-helper: Fix leak in disable_all"
  drm/atomic-helper: Make drm_atomic_helper_disable_all() update the
plane->fb pointers
  drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()
  drm/atomic-helper: WARN if legacy plane fb pointers are bogus when
committing duplicated state
  drm: Add local 'plane' variable for primary/cursor planes
  drm: Adjust whitespace for legibility
  drm: Make the fb refcount handover less magic
  drm: Use plane->state->fb over plane->fb
  drm/i915: Stop consulting plane->fb
  drm/msm: Stop consulting plane->fb
  drm/sti: Stop consulting plane->fb
  drm/vmwgfx: Stop consulting plane->fb
  drm/zte: Stop consulting plane->fb
  drm/atmel-hlcdc: Stop using plane->fb
  drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
  drm/amdgpu/dc: Stop updating plane->fb
  drm/i915: Stop updating plane->fb/crtc
  drm/exynos: Stop updating plane->crtc
  drm/msm: Stop updating plane->fb/crtc
  drm/virtio: Stop updating plane->fb
  drm/vc4: Stop updating plane->fb/crtc
  drm/i915: Restore planes after load detection
  drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c   | 12 +---
 drivers/gpu/drm/drm_atomic.c  | 55 ++--
 drivers/gpu/drm/drm_atomic_helper.c   | 79 ++-
 drivers/gpu/drm/drm_crtc.c| 51 ++-
 drivers/gpu/drm/drm_fb_helper.c   |  7 --
 drivers/gpu/drm/drm_framebuffer.c |  5 --
 drivers/gpu/drm/drm_plane.c   | 64 +++---
 drivers/gpu/drm/drm_plane_helper.c|  4 +-
 drivers/gpu/drm/exynos/exynos_drm_plane.c |  2 -
 drivers/gpu/drm/i915/intel_crt.c  |  6 ++
 drivers/gpu/drm/i915/intel_display.c  |  9 +--
 drivers/gpu/drm/i915/intel_fbdev.c|  2 +-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |  3 +-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c|  2 -
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c|  2 -
 drivers/gpu/drm/sti/sti_plane.c   |  9 +--
 drivers/gpu/drm/vc4/vc4_crtc.c|  3 -
 drivers/gpu/drm/virtio/virtgpu_display.c  |  2 -
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c   |  6 +-
 drivers/gpu/drm/zte/zx_vou.c  |  2 +-
 include/drm/drm_atomic.h  |  3 -
 22 files changed, 143 insertions(+), 187 deletions(-)

-- 
2.16.1

___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 4/7] freedreno: a2xx: Support TEXTURE_RECT

2018-03-22 Thread Ilia Mirkin
On Thu, Mar 22, 2018 at 10:43 AM, Wladimir J. van der Laan
 wrote:
> Hello Ilia,
>
> On Thu, Jan 25, 2018 at 08:41:11AM -0500, Ilia Mirkin wrote:
>> Should you also expose PIPE_CAP_TEXTURE_RECTANGLE? (Or whatever it's
>> called... I forget.)
>
> I checked and I don't think a capability exists for this (anymore?).
>
> Everywhere, the assumption is meant that all Gallium drivers support, or at 
> least emulate this.
>
> For example in src/mesa/state_tracker/st_extensions.c:
>
> extensions->NV_texture_rectangle = GL_TRUE;

You're probably right - texture rect is required as part of Gallium.
Probably always has been.
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 4/7] freedreno: a2xx: Support TEXTURE_RECT

2018-03-22 Thread Wladimir J. van der Laan
Hello Ilia,

On Thu, Jan 25, 2018 at 08:41:11AM -0500, Ilia Mirkin wrote:
> Should you also expose PIPE_CAP_TEXTURE_RECTANGLE? (Or whatever it's
> called... I forget.)

I checked and I don't think a capability exists for this (anymore?).

Everywhere, the assumption is meant that all Gallium drivers support, or at 
least emulate this.

For example in src/mesa/state_tracker/st_extensions.c:

extensions->NV_texture_rectangle = GL_TRUE;

Regards,
Wladimir
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno