<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <br>
    <div class="moz-cite-prefix">On 27/10/2015 11:08, Julien Isorce
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAHWPjbXEKmg5ff6TJE8vjS_tNqeyLtf_0-Vs8og-q5my4zseGQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Looks good though what happened to the del around if
          (!oclass)  in nv30_screen_create ?<br>
        </div>
      </div>
    </blockquote>
    <br>
    Yeah, good catch. I think we could use FAIL_SCREEN_INIT() there.<br>
    I'll send a new patch with this fix.<br>
    <br>
    <blockquote
cite="mid:CAHWPjbXEKmg5ff6TJE8vjS_tNqeyLtf_0-Vs8og-q5my4zseGQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Also it seems to fix the other problem around else
        if (dupfd) which was not closed on failure.<br>
      </div>
    </blockquote>
    <br>
    Yes, it fixes both issues.<br>
    <br>
    <blockquote
cite="mid:CAHWPjbXEKmg5ff6TJE8vjS_tNqeyLtf_0-Vs8og-q5my4zseGQ@mail.gmail.com"
      type="cite">
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On 27 October 2015 at 09:10,
          samuel.pitoiset <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">What about
            this one <a moz-do-not-send="true"
              href="http://hastebin.com/uboruxicof.coffee"
              rel="noreferrer" target="_blank">http://hastebin.com/uboruxicof.coffee</a>
            ?<br>
            <br>
            This patch is loosely based on your first attempt, except
            that I removed the call<br>
            to nouveau_device_del() in nouveau_drm_screen_create().
            <div class="HOEnZb">
              <div class="h5"><br>
                <br>
                On 27/10/2015 09:52, Julien Isorce wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  This patch prevents to call nouveau_device_del twice
                  on the same device.<br>
                  <br>
                  Encountered this case when nvc0_screen_create fails
                  with:<br>
                  nvc0_screen_create:717 - Error allocating PGRAPH
                  context for M2MF: -16<br>
                  <br>
                  <a moz-do-not-send="true"
                    href="https://bugs.freedesktop.org/show_bug.cgi?id=70354"
                    rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=70354</a><br>
                  <br>
                  Signed-off-by: Julien Isorce <<a
                    moz-do-not-send="true"
                    href="mailto:j.isorce@samsung.com" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:j.isorce@samsung.com">j.isorce@samsung.com</a></a>><br>
                  ---<br>
                    src/gallium/drivers/nouveau/nouveau_screen.c   | 8
                  ++++++--<br>
                    src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 +<br>
                    src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 +<br>
                    src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 +<br>
                    4 files changed, 9 insertions(+), 2 deletions(-)<br>
                  <br>
                  diff --git
                  a/src/gallium/drivers/nouveau/nouveau_screen.c
                  b/src/gallium/drivers/nouveau/nouveau_screen.c<br>
                  index b2290e7..2bd6d4f 100644<br>
                  --- a/src/gallium/drivers/nouveau/nouveau_screen.c<br>
                  +++ b/src/gallium/drivers/nouveau/nouveau_screen.c<br>
                  @@ -177,13 +177,17 @@ nouveau_screen_init(struct
                  nouveau_screen *screen, struct nouveau_device *dev)<br>
                          screen->device = dev;<br>
                          ret = nouveau_client_new(screen->device,
                  &screen->client);<br>
                  -       if (ret)<br>
                  +       if (ret) {<br>
                  +               screen->device = 0;<br>
                                  return ret;<br>
                  +       }<br>
                          ret = nouveau_pushbuf_new(screen->client,
                  screen->channel,<br>
                                                    4, 512 * 1024, 1,<br>
                                                   
                  &screen->pushbuf);<br>
                  -       if (ret)<br>
                  +       if (ret) {<br>
                  +               screen->device = 0;<br>
                                  return ret;<br>
                  +       }<br>
                              /* getting CPU time first appears to be
                  more accurate */<br>
                            screen->cpu_gpu_time_delta =
                  os_time_get();<br>
                  diff --git
                  a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
                  b/src/gallium/drivers/nouveau/nv30/nv30_screen.c<br>
                  index 0330164..54af655 100644<br>
                  --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c<br>
                  +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c<br>
                  @@ -411,6 +411,7 @@ nv30_screen_destroy(struct
                  pipe_screen *pscreen)<br>
                    #define FAIL_SCREEN_INIT(str, err)                 
                    \<br>
                       do {                                             
                   \<br>
                          NOUVEAU_ERR(str, err);                       
                    \<br>
                  +      screen->base.device = 0;                   
                      \<br>
                          nv30_screen_destroy(pscreen);                 
                   \<br>
                          return NULL;                                 
                    \<br>
                       } while(0)<br>
                  diff --git
                  a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
                  b/src/gallium/drivers/nouveau/nv50/nv50_screen.c<br>
                  index ec51d00..a1fad42 100644<br>
                  --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c<br>
                  +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c<br>
                  @@ -905,6 +905,7 @@ nv50_screen_create(struct
                  nouveau_device *dev)<br>
                       return pscreen;<br>
                      fail:<br>
                  +   screen->base.device = 0;<br>
                       nv50_screen_destroy(pscreen);<br>
                       return NULL;<br>
                    }<br>
                  diff --git
                  a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
                  b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c<br>
                  index af8e5f7..28fee35 100644<br>
                  --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c<br>
                  +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c<br>
                  @@ -609,6 +609,7 @@ nvc0_screen_resize_tls_area(struct
                  nvc0_screen *screen,<br>
                    #define FAIL_SCREEN_INIT(str, err)                 
                    \<br>
                       do {                                             
                   \<br>
                          NOUVEAU_ERR(str, err);                       
                    \<br>
                  +      screen->base.device = 0;                   
                      \<br>
                          nvc0_screen_destroy(pscreen);                 
                   \<br>
                          return NULL;                                 
                    \<br>
                       } while(0)<br>
                </blockquote>
                <br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>