Skip to contentSkip to conversation

nv50, nvc0: don't base decisions on available pushbuf space

PATCH In review Ilia Mirkin 3 participants 9 messages Oct 10, 2015 – Oct 11, 2015 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nv50, nvc0: don't base decisions on available pushbuf space

We still have to push everything out, might as well kick earlier and flip pushbufs when we know we'll need it. This resolves some issues with the new policy of making sure that we always leave a bit of room at the end for fences.

---
 src/gallium/drivers/nouveau/nv50/nv50_shader_state.c |  9 ++-------
 src/gallium/drivers/nouveau/nv50/nv50_transfer.c     | 16 +++-------------
 src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c     | 20 +++++---------------
 3 files changed, 10 insertions(+), 35 deletions(-)
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +2 -7
index fdde11f..941555f 100644
@@ -65,14 +65,9 @@ nv50_constbufs_validate(struct nv50_context *nv50)
                PUSH_DATA (push, (b << 12) | (i << 8) | p | 1);
             }
             while (words) {
-               unsigned nr;
-
-               if (!PUSH_SPACE(push, 16))
-                  break;
-               nr = PUSH_AVAIL(push);
-               assert(nr >= 16);
-               nr = MIN2(MIN2(nr - 3, words), NV04_PFIFO_MAX_PACKET_LEN);
+               unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
 
+               PUSH_SPACE(push, nr + 3);
                BEGIN_NV04(push, NV50_3D(CB_ADDR), 1);
                PUSH_DATA (push, (start << 8) | b);
                BEGIN_NI04(push, NV50_3D(CB_DATA(0)), nr);
src/gallium/drivers/nouveau/nv50/nv50_transfer.c +3 -13
index be51407..9a3fd1e 100644
@@ -187,14 +187,7 @@ nv50_sifc_linear_u8(struct nouveau_context *nv,
    PUSH_DATA (push, 0);
 
    while (count) {
-      unsigned nr;
-
-      if (!PUSH_SPACE(push, 16))
-         break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 1);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
 
       BEGIN_NI04(push, NV50_2D(SIFC_DATA), nr);
       PUSH_DATAp(push, src, nr);
@@ -395,12 +388,9 @@ nv50_cb_push(struct nouveau_context *nv,
    nouveau_pushbuf_validate(push);
 
    while (words) {
-      unsigned nr;
-
-      nr = PUSH_AVAIL(push);
-      nr = MIN2(nr - 7, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
 
+      PUSH_SPACE(push, nr + 7);
       BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3);
       PUSH_DATAh(push, bo->offset + base);
       PUSH_DATA (push, bo->offset + base);
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +5 -15
index aaec60a..d459dd6 100644
@@ -188,14 +188,10 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
    nouveau_pushbuf_validate(push);
 
    while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
 
-      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 9))
          break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 9);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
 
       BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2);
       PUSH_DATAh(push, dst->offset + offset);
@@ -234,14 +230,10 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
    nouveau_pushbuf_validate(push);
 
    while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1));
 
-      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 10))
          break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 8);
-      nr = MIN2(nr, (NV04_PFIFO_MAX_PACKET_LEN - 1));
 
       BEGIN_NVC0(push, NVE4_P2MF(UPLOAD_DST_ADDRESS_HIGH), 2);
       PUSH_DATAh(push, dst->offset + offset);
@@ -571,9 +563,7 @@ nvc0_cb_bo_push(struct nouveau_context *nv,
    PUSH_DATA (push, bo->offset + base);
 
    while (words) {
-      unsigned nr = PUSH_AVAIL(push);
-      nr = MIN2(nr, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN - 1);
 
       PUSH_SPACE(push, nr + 2);
       PUSH_REFN (push, bo, NOUVEAU_BO_WR | domain);
Signature · 6 lines
2.4.9

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#1 lore raw

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for PUSH_SPACE calls, sometimes you add it sometimes not.

Did you run a full piglit test this time ? :)

See my comment below.

Quoted 21 lines · Ilia Mirkin

We still have to push everything out, might as well kick earlier and flip pushbufs when we know we'll need it. This resolves some issues with the new policy of making sure that we always leave a bit of room at the end for fences.

---
  src/gallium/drivers/nouveau/nv50/nv50_shader_state.c |  9 ++-------
  src/gallium/drivers/nouveau/nv50/nv50_transfer.c     | 16 +++-------------
  src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c     | 20 +++++---------------
  3 files changed, 10 insertions(+), 35 deletions(-)
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +0 -0
index fdde11f..941555f 100644
@@ -65,14 +65,9 @@ nv50_constbufs_validate(struct nv50_context *nv50)
                 PUSH_DATA (push, (b << 12) | (i << 8) | p | 1);
              }
              while (words) {

src/gallium/drivers/nouveau/nv50/nv50_shader_state.c nv50_constbufs_validate(struct nv50_context *nv50) · line 70

Quoted 10 lines
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +2 -7
-               unsigned nr;
-
-               if (!PUSH_SPACE(push, 16))
-                  break;
-               nr = PUSH_AVAIL(push);
-               assert(nr >= 16);
-               nr = MIN2(MIN2(nr - 3, words), NV04_PFIFO_MAX_PACKET_LEN);
+               unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
 
+               PUSH_SPACE(push, nr + 3);

This PUSH_SPACE call doesn't seem to be needed for me because NV50_PUSH_EXPLICIT_SPACE_CHECKING is not set and the following BEGIN_XXX calls will allocate space.

Quoted 77 lines
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +0 -0
                 BEGIN_NV04(push, NV50_3D(CB_ADDR), 1);
                 PUSH_DATA (push, (start << 8) | b);
                 BEGIN_NI04(push, NV50_3D(CB_DATA(0)), nr);
src/gallium/drivers/nouveau/nv50/nv50_transfer.c +3 -13
index be51407..9a3fd1e 100644
@@ -187,14 +187,7 @@ nv50_sifc_linear_u8(struct nouveau_context *nv,
     PUSH_DATA (push, 0);
 
     while (count) {
-      unsigned nr;
-
-      if (!PUSH_SPACE(push, 16))
-         break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 1);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
 
        BEGIN_NI04(push, NV50_2D(SIFC_DATA), nr);
        PUSH_DATAp(push, src, nr);
@@ -395,12 +388,9 @@ nv50_cb_push(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
 
     while (words) {
-      unsigned nr;
-
-      nr = PUSH_AVAIL(push);
-      nr = MIN2(nr - 7, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
 
+      PUSH_SPACE(push, nr + 7);
        BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3);
        PUSH_DATAh(push, bo->offset + base);
        PUSH_DATA (push, bo->offset + base);
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +4 -12
index aaec60a..d459dd6 100644
@@ -188,14 +188,10 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
 
     while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
 
-      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 9))
           break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 9);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
 
        BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2);
        PUSH_DATAh(push, dst->offset + offset);
@@ -234,14 +230,10 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
 
     while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1));
 
-      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 10))
           break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 8);
-      nr = MIN2(nr, (NV04_PFIFO_MAX_PACKET_LEN - 1));
 
        BEGIN_NVC0(push, NVE4_P2MF(UPLOAD_DST_ADDRESS_HIGH), 2);
        PUSH_DATAh(push, dst->offset + offset);

src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c nvc0_cb_bo_push(struct nouveau_context *nv, · line 569

Quoted 10 lines
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +1 -3
@@ -571,9 +563,7 @@ nvc0_cb_bo_push(struct nouveau_context *nv,
     PUSH_DATA (push, bo->offset + base);
 
     while (words) {
-      unsigned nr = PUSH_AVAIL(push);
-      nr = MIN2(nr, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN - 1);
 
        PUSH_SPACE(push, nr + 2);
        PUSH_REFN (push, bo, NOUVEAU_BO_WR | domain);

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 3 lines · Samuel Pitoiset

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for PUSH_SPACE calls, sometimes you add it sometimes not.

Meh. We need to get our error checking situation straight, but this isn't the patch to do it in.

Quoted 2 lines

Did you run a full piglit test this time ? :)

Nope, but I ran a full piglit before this patch. Almost took down my box. Probably won't be running it again for this patch.

Quoted 36 lines

See my comment below.

Quoted 31 lines · Ilia Mirkin

We still have to push everything out, might as well kick earlier and flip pushbufs when we know we'll need it. This resolves some issues with the new policy of making sure that we always leave a bit of room at the end for fences.

---
  src/gallium/drivers/nouveau/nv50/nv50_shader_state.c |  9 ++-------
  src/gallium/drivers/nouveau/nv50/nv50_transfer.c     | 16
+++-------------
  src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c     | 20
+++++---------------
  3 files changed, 10 insertions(+), 35 deletions(-)
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +0 -6
index fdde11f..941555f 100644
@@ -65,14 +65,9 @@ nv50_constbufs_validate(struct nv50_context *nv50)
                 PUSH_DATA (push, (b << 12) | (i << 8) | p | 1);
              }
              while (words) {
-               unsigned nr;
-
-               if (!PUSH_SPACE(push, 16))
-                  break;
-               nr = PUSH_AVAIL(push);
-               assert(nr >= 16);
Quoted 8 lines

src/gallium/drivers/nouveau/nv50/nv50_shader_state.c nv50_constbufs_validate(struct nv50_context *nv50)

Quoted 3 lines
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +1 -1
-               nr = MIN2(MIN2(nr - 3, words), NV04_PFIFO_MAX_PACKET_LEN);
+               unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
  +               PUSH_SPACE(push, nr + 3);

This PUSH_SPACE call doesn't seem to be needed for me because NV50_PUSH_EXPLICIT_SPACE_CHECKING is not set and the following BEGIN_XXX calls will allocate space.

I want to ensure that both of the below commands are in the same batch. Not sure if it's necessary, but... don't want to find out. They were in the same batch before. And this batch stuff is what was causing the M2MF errors I was seeing earlier.

Quoted 71 lines
Quoted 71 lines
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +0 -0
                 BEGIN_NV04(push, NV50_3D(CB_ADDR), 1);
                 PUSH_DATA (push, (start << 8) | b);
                 BEGIN_NI04(push, NV50_3D(CB_DATA(0)), nr);
src/gallium/drivers/nouveau/nv50/nv50_transfer.c +2 -13
index be51407..9a3fd1e 100644
@@ -187,14 +187,7 @@ nv50_sifc_linear_u8(struct nouveau_context *nv,
     PUSH_DATA (push, 0);
       while (count) {
-      unsigned nr;
-
-      if (!PUSH_SPACE(push, 16))
-         break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 1);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
          BEGIN_NI04(push, NV50_2D(SIFC_DATA), nr);
        PUSH_DATAp(push, src, nr);
@@ -395,12 +388,9 @@ nv50_cb_push(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
       while (words) {
-      unsigned nr;
-
-      nr = PUSH_AVAIL(push);
-      nr = MIN2(nr - 7, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
  +      PUSH_SPACE(push, nr + 7);
        BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3);
        PUSH_DATAh(push, bo->offset + base);
        PUSH_DATA (push, bo->offset + base);
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +4 -10
index aaec60a..d459dd6 100644
@@ -188,14 +188,10 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
       while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
  -      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 9))
           break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 9);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
          BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2);
        PUSH_DATAh(push, dst->offset + offset);
@@ -234,14 +230,10 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
       while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1));
  -      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 10))
           break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 8);
-      nr = MIN2(nr, (NV04_PFIFO_MAX_PACKET_LEN - 1));
          BEGIN_NVC0(push, NVE4_P2MF(UPLOAD_DST_ADDRESS_HIGH), 2);
        PUSH_DATAh(push, dst->offset + offset);
@@ -571,9 +563,7 @@ nvc0_cb_bo_push(struct nouveau_context *nv,
Quoted 10 lines

src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c nvc0_cb_bo_push(struct nouveau_context *nv, · line 569

Quoted 8 lines
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +1 -3
     PUSH_DATA (push, bo->offset + base);
       while (words) {
-      unsigned nr = PUSH_AVAIL(push);
-      nr = MIN2(nr, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN - 1);
          PUSH_SPACE(push, nr + 2);
        PUSH_REFN (push, bo, NOUVEAU_BO_WR | domain);

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CAKb7UvgWEKVA1TWqU-Bcu=VmunnXot_Sqp11F7XC_mOowVqTUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw
Quoted 7 lines · Ilia Mirkin
Quoted 3 lines · Samuel Pitoiset

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for PUSH_SPACE calls, sometimes you add it sometimes not.

Meh. We need to get our error checking situation straight, but this isn't the patch to do it in.

Yeah, but this needs to be clarified.

Quoted 4 lines
Quoted 2 lines

Did you run a full piglit test this time ? :)

Nope, but I ran a full piglit before this patch. Almost took down my box. Probably won't be running it again for this patch.

Ok, I'll run a full piglit this night then.

Quoted 42 lines
Quoted 34 lines

See my comment below.

Quoted 29 lines · Ilia Mirkin

We still have to push everything out, might as well kick earlier and flip pushbufs when we know we'll need it. This resolves some issues with the new policy of making sure that we always leave a bit of room at the end for fences.

---
   src/gallium/drivers/nouveau/nv50/nv50_shader_state.c |  9 ++-------
   src/gallium/drivers/nouveau/nv50/nv50_transfer.c     | 16
+++-------------
   src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c     | 20
+++++---------------
   3 files changed, 10 insertions(+), 35 deletions(-)
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +0 -5
index fdde11f..941555f 100644
@@ -65,14 +65,9 @@ nv50_constbufs_validate(struct nv50_context *nv50)
                  PUSH_DATA (push, (b << 12) | (i << 8) | p | 1);
               }
               while (words) {
-               unsigned nr;
-
-               if (!PUSH_SPACE(push, 16))
-                  break;
-               nr = PUSH_AVAIL(push);
Quoted 8 lines

src/gallium/drivers/nouveau/nv50/nv50_shader_state.c nv50_constbufs_validate(struct nv50_context *nv50)

Quoted 4 lines
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +1 -2
-               assert(nr >= 16);
-               nr = MIN2(MIN2(nr - 3, words), NV04_PFIFO_MAX_PACKET_LEN);
+               unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
   +               PUSH_SPACE(push, nr + 3);

This PUSH_SPACE call doesn't seem to be needed for me because NV50_PUSH_EXPLICIT_SPACE_CHECKING is not set and the following BEGIN_XXX calls will allocate space.

Quoted 84 lines

I want to ensure that both of the below commands are in the same batch. Not sure if it's necessary, but... don't want to find out. They were in the same batch before. And this batch stuff is what was causing the M2MF errors I was seeing earlier.

Quoted 79 lines
Quoted 78 lines
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +0 -0
                  BEGIN_NV04(push, NV50_3D(CB_ADDR), 1);
                  PUSH_DATA (push, (start << 8) | b);
                  BEGIN_NI04(push, NV50_3D(CB_DATA(0)), nr);
src/gallium/drivers/nouveau/nv50/nv50_transfer.c +2 -13
index be51407..9a3fd1e 100644
@@ -187,14 +187,7 @@ nv50_sifc_linear_u8(struct nouveau_context *nv,
      PUSH_DATA (push, 0);
        while (count) {
-      unsigned nr;
-
-      if (!PUSH_SPACE(push, 16))
-         break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 1);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
           BEGIN_NI04(push, NV50_2D(SIFC_DATA), nr);
         PUSH_DATAp(push, src, nr);
@@ -395,12 +388,9 @@ nv50_cb_push(struct nouveau_context *nv,
      nouveau_pushbuf_validate(push);
        while (words) {
-      unsigned nr;
-
-      nr = PUSH_AVAIL(push);
-      nr = MIN2(nr - 7, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
   +      PUSH_SPACE(push, nr + 7);
         BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3);
         PUSH_DATAh(push, bo->offset + base);
         PUSH_DATA (push, bo->offset + base);
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +5 -13
index aaec60a..d459dd6 100644
@@ -188,14 +188,10 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
      nouveau_pushbuf_validate(push);
        while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
   -      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 9))
            break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 9);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
           BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2);
         PUSH_DATAh(push, dst->offset + offset);
@@ -234,14 +230,10 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
      nouveau_pushbuf_validate(push);
        while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1));
   -      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 10))
            break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 8);
-      nr = MIN2(nr, (NV04_PFIFO_MAX_PACKET_LEN - 1));
           BEGIN_NVC0(push, NVE4_P2MF(UPLOAD_DST_ADDRESS_HIGH), 2);
         PUSH_DATAh(push, dst->offset + offset);
@@ -571,9 +563,7 @@ nvc0_cb_bo_push(struct nouveau_context *nv,
      PUSH_DATA (push, bo->offset + base);
        while (words) {
-      unsigned nr = PUSH_AVAIL(push);
-      nr = MIN2(nr, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN - 1);
           PUSH_SPACE(push, nr + 2);
         PUSH_REFN (push, bo, NOUVEAU_BO_WR | domain);

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 11 lines · Samuel Pitoiset
Quoted 8 lines · Ilia Mirkin
Quoted 4 lines · Samuel Pitoiset

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for PUSH_SPACE calls, sometimes you add it sometimes not.

Quoted 5 lines
Quoted 2 lines

Meh. We need to get our error checking situation straight, but this isn't the patch to do it in.

Yeah, but this needs to be clarified.

What does?
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CAKb7UvhaZn2tK9ejZ7ard79gHuxoWJRi+hLU=P6+psZSqT-sZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#9 lore raw
Quoted 6 lines · Ilia Mirkin
Quoted 4 lines · Samuel Pitoiset
Quoted 2 lines · Ilia Mirkin

On Sat, Oct 10, 2015 at 3:41 PM, Samuel Pitoiset
<[email protected]> wrote:

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for PUSH_SPACE calls, sometimes you add it sometimes not.

Meh. We need to get our error checking situation straight, but this isn't the patch to do it in.

Yeah, but this needs to be clarified.

What does?

I mean, we should either use PUSH_SPACE everywhere or not at all, and always breaks (or not) when PUSH_SPACE fails. That's really a minor issue.

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 22 lines · Samuel Pitoiset
Quoted 19 lines · Ilia Mirkin
Quoted 16 lines · Samuel Pitoiset
Quoted 11 lines · Ilia Mirkin
Quoted 5 lines · Samuel Pitoiset

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for
PUSH_SPACE calls, sometimes you add it sometimes not.

Meh. We need to get our error checking situation straight, but this isn't the patch to do it in.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Yeah, but this needs to be clarified.

What does?

I mean, we should either use PUSH_SPACE everywhere or not at all, and always breaks (or not) when PUSH_SPACE fails.
That's really a minor issue.

It's actually a major issue. Error-handling is practically non-existent. There are a couple of spots here and there, but it doesn't really scale up. I guess I (semi-)accidentally removed a couple of spots that error checked, but, again, meh. Doing this for real will require some careful thought.

-ilia
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#12 lore raw
Quoted 20 lines · Ilia Mirkin
Quoted 18 lines · Samuel Pitoiset
Quoted 15 lines · Ilia Mirkin
Quoted 4 lines · Samuel Pitoiset
Quoted 2 lines · Ilia Mirkin

On Sat, Oct 10, 2015 at 3:41 PM, Samuel Pitoiset
<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This patch looks fine except that it should be a bit more normalized. I mean, sometimes you break when PUSH_SPACE fails, sometimes not. Same for
PUSH_SPACE calls, sometimes you add it sometimes not.

Meh. We need to get our error checking situation straight, but this isn't the patch to do it in.

Yeah, but this needs to be clarified.

What does?

Quoted 8 lines
Quoted 3 lines

I mean, we should either use PUSH_SPACE everywhere or not at all, and always breaks (or not) when PUSH_SPACE fails.
That's really a minor issue.

It's actually a major issue. Error-handling is practically non-existent. There are a couple of spots here and there, but it doesn't really scale up. I guess I (semi-)accidentally removed a couple of spots that error checked, but, again, meh. Doing this for real will require some careful thought.

Yeah, okay. So we really need to improve error-handling. :)

Quoted 1 line

-ilia

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): 1444468187-13868-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]

Reviewed-by
#14 lore raw

I did a full piglit run on Fermi. There are no regressions and you fixed texelFetch tests and other ones which failed with that assert.

I'm lazy to do it on Tesla, so:

Thanks!

Quoted 108 lines · Ilia Mirkin

We still have to push everything out, might as well kick earlier and flip pushbufs when we know we'll need it. This resolves some issues with the new policy of making sure that we always leave a bit of room at the end for fences.

---
  src/gallium/drivers/nouveau/nv50/nv50_shader_state.c |  9 ++-------
  src/gallium/drivers/nouveau/nv50/nv50_transfer.c     | 16 +++-------------
  src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c     | 20 +++++---------------
  3 files changed, 10 insertions(+), 35 deletions(-)
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +2 -7
index fdde11f..941555f 100644
@@ -65,14 +65,9 @@ nv50_constbufs_validate(struct nv50_context *nv50)
                 PUSH_DATA (push, (b << 12) | (i << 8) | p | 1);
              }
              while (words) {
-               unsigned nr;
-
-               if (!PUSH_SPACE(push, 16))
-                  break;
-               nr = PUSH_AVAIL(push);
-               assert(nr >= 16);
-               nr = MIN2(MIN2(nr - 3, words), NV04_PFIFO_MAX_PACKET_LEN);
+               unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
 
+               PUSH_SPACE(push, nr + 3);
                 BEGIN_NV04(push, NV50_3D(CB_ADDR), 1);
                 PUSH_DATA (push, (start << 8) | b);
                 BEGIN_NI04(push, NV50_3D(CB_DATA(0)), nr);
src/gallium/drivers/nouveau/nv50/nv50_transfer.c +3 -13
index be51407..9a3fd1e 100644
@@ -187,14 +187,7 @@ nv50_sifc_linear_u8(struct nouveau_context *nv,
     PUSH_DATA (push, 0);
 
     while (count) {
-      unsigned nr;
-
-      if (!PUSH_SPACE(push, 16))
-         break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 1);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
 
        BEGIN_NI04(push, NV50_2D(SIFC_DATA), nr);
        PUSH_DATAp(push, src, nr);
@@ -395,12 +388,9 @@ nv50_cb_push(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
 
     while (words) {
-      unsigned nr;
-
-      nr = PUSH_AVAIL(push);
-      nr = MIN2(nr - 7, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN);
 
+      PUSH_SPACE(push, nr + 7);
        BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3);
        PUSH_DATAh(push, bo->offset + base);
        PUSH_DATA (push, bo->offset + base);
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +4 -12
index aaec60a..d459dd6 100644
@@ -188,14 +188,10 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
 
     while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN);
 
-      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 9))
           break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 9);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
 
        BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2);
        PUSH_DATAh(push, dst->offset + offset);
@@ -234,14 +230,10 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
     nouveau_pushbuf_validate(push);
 
     while (count) {
-      unsigned nr;
+      unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1));
 
-      if (!PUSH_SPACE(push, 16))
+      if (!PUSH_SPACE(push, nr + 10))
           break;
-      nr = PUSH_AVAIL(push);
-      assert(nr >= 16);
-      nr = MIN2(count, nr - 8);
-      nr = MIN2(nr, (NV04_PFIFO_MAX_PACKET_LEN - 1));
 
        BEGIN_NVC0(push, NVE4_P2MF(UPLOAD_DST_ADDRESS_HIGH), 2);
        PUSH_DATAh(push, dst->offset + offset);

src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c nvc0_cb_bo_push(struct nouveau_context *nv, · line 569

Quoted 10 lines
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +1 -3
@@ -571,9 +563,7 @@ nvc0_cb_bo_push(struct nouveau_context *nv,
     PUSH_DATA (push, bo->offset + base);
 
     while (words) {
-      unsigned nr = PUSH_AVAIL(push);
-      nr = MIN2(nr, words);
-      nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN - 1);
+      unsigned nr = MIN2(words, NV04_PFIFO_MAX_PACKET_LEN - 1);
 
        PUSH_SPACE(push, nr + 2);
        PUSH_REFN (push, bo, NOUVEAU_BO_WR | domain);

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau