diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2018-01-12 02:05:03 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2018-02-02 00:24:06 -0500 |
commit | 561464ea543c2f39f07ac2da91043555fa133601 (patch) | |
tree | 81f3a170488fc25bfee5026bc674a7f769c40d3d /drivers | |
parent | 27cda223327505a19d912536dff205ccdc5c5c2a (diff) |
drm/nouveau/bo: add helper functions for handling pinned+mapped buffers
This is a common, awkward sequence. Let's wrap it up!
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h index 7b5cc5c73d20..be8e00b49cde 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.h +++ b/drivers/gpu/drm/nouveau/nouveau_bo.h | |||
@@ -105,4 +105,32 @@ nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo) | |||
105 | return ioptr; | 105 | return ioptr; |
106 | } | 106 | } |
107 | 107 | ||
108 | static inline void | ||
109 | nouveau_bo_unmap_unpin_unref(struct nouveau_bo **pnvbo) | ||
110 | { | ||
111 | if (*pnvbo) { | ||
112 | nouveau_bo_unmap(*pnvbo); | ||
113 | nouveau_bo_unpin(*pnvbo); | ||
114 | nouveau_bo_ref(NULL, pnvbo); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | static inline int | ||
119 | nouveau_bo_new_pin_map(struct nouveau_cli *cli, u64 size, int align, u32 flags, | ||
120 | struct nouveau_bo **pnvbo) | ||
121 | { | ||
122 | int ret = nouveau_bo_new(cli, size, align, flags, | ||
123 | 0, 0, NULL, NULL, pnvbo); | ||
124 | if (ret == 0) { | ||
125 | ret = nouveau_bo_pin(*pnvbo, flags, true); | ||
126 | if (ret == 0) { | ||
127 | ret = nouveau_bo_map(*pnvbo); | ||
128 | if (ret == 0) | ||
129 | return ret; | ||
130 | nouveau_bo_unpin(*pnvbo); | ||
131 | } | ||
132 | nouveau_bo_ref(NULL, pnvbo); | ||
133 | } | ||
134 | return ret; | ||
135 | } | ||
108 | #endif | 136 | #endif |