drm/nouveau/abi16: introduce locked variant of nouveau_abi16_get()
authorBen Skeggs <bskeggs@redhat.com>
Tue, 3 Nov 2015 00:55:45 +0000 (10:55 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 3 Nov 2015 05:02:18 +0000 (15:02 +1000)
USIF already takes the client mutex, but will need access to ABI16 data
in order to provide some limited interoperability.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_abi16.c

index c3dea3331e12703b0183d87d4f514a8d42fdb71a..998f5cb2dfac24fbacb1a1c2f075cf38d5c02a0d 100644 (file)
 #include "nouveau_chan.h"
 #include "nouveau_abi16.h"
 
-struct nouveau_abi16 *
-nouveau_abi16_get(struct drm_file *file_priv)
+static struct nouveau_abi16 *
+nouveau_abi16(struct drm_file *file_priv)
 {
        struct nouveau_cli *cli = nouveau_cli(file_priv);
-       mutex_lock(&cli->mutex);
        if (!cli->abi16) {
                struct nouveau_abi16 *abi16;
                cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL);
@@ -59,12 +58,21 @@ nouveau_abi16_get(struct drm_file *file_priv)
                        kfree(cli->abi16);
                        cli->abi16 = NULL;
                }
-
-               mutex_unlock(&cli->mutex);
        }
        return cli->abi16;
 }
 
+struct nouveau_abi16 *
+nouveau_abi16_get(struct drm_file *file_priv)
+{
+       struct nouveau_cli *cli = nouveau_cli(file_priv);
+       mutex_lock(&cli->mutex);
+       if (nouveau_abi16(file_priv))
+               return cli->abi16;
+       mutex_unlock(&cli->mutex);
+       return NULL;
+}
+
 int
 nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret)
 {