@@ -17,7 +17,6 @@
#include <linux/spinlock.h>
#include <linux/shmem_fs.h>
-#include <linux/dma-buf.h>
#include "etnaviv_drv.h"
#include "etnaviv_gem.h"
@@ -702,57 +701,3 @@ int etnaviv_gem_new_private(struct drm_device *dev, size_t size, uint32_t flags,
return 0;
}
-
-static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
-{
- if (etnaviv_obj->vaddr)
- dma_buf_vunmap(etnaviv_obj->base.import_attach->dmabuf,
- etnaviv_obj->vaddr);
-
- /* Don't drop the pages for imported dmabuf, as they are not
- * ours, just free the array we allocated:
- */
- if (etnaviv_obj->pages)
- drm_free_large(etnaviv_obj->pages);
-
- drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt);
-}
-
-static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = {
- .release = etnaviv_gem_prime_release,
-};
-
-struct drm_gem_object *msm_gem_import(struct drm_device *dev,
- uint32_t size, struct sg_table *sgt)
-{
- struct etnaviv_gem_object *etnaviv_obj;
- int ret, npages;
-
- size = PAGE_ALIGN(size);
-
- ret = etnaviv_gem_new_private(dev, size, ETNA_BO_WC, &etnaviv_obj);
- if (ret < 0)
- return ERR_PTR(ret);
-
- npages = size / PAGE_SIZE;
-
- etnaviv_obj->ops = &etnaviv_gem_prime_ops;
- etnaviv_obj->sgt = sgt;
- etnaviv_obj->pages = drm_malloc_ab(npages, sizeof(struct page *));
- if (!etnaviv_obj->pages) {
- ret = -ENOMEM;
- goto fail;
- }
-
- ret = drm_prime_sg_to_page_addr_arrays(sgt, etnaviv_obj->pages,
- NULL, npages);
- if (ret)
- goto fail;
-
- return &etnaviv_obj->base;
-
-fail:
- drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
-
- return ERR_PTR(ret);
-}
@@ -15,6 +15,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/dma-buf.h>
#include "etnaviv_drv.h"
#include "etnaviv_gem.h"
@@ -56,3 +57,57 @@ void msm_gem_prime_unpin(struct drm_gem_object *obj)
if (!obj->import_attach)
msm_gem_put_pages(obj);
}
+
+static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
+{
+ if (etnaviv_obj->vaddr)
+ dma_buf_vunmap(etnaviv_obj->base.import_attach->dmabuf,
+ etnaviv_obj->vaddr);
+
+ /* Don't drop the pages for imported dmabuf, as they are not
+ * ours, just free the array we allocated:
+ */
+ if (etnaviv_obj->pages)
+ drm_free_large(etnaviv_obj->pages);
+
+ drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt);
+}
+
+static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = {
+ .release = etnaviv_gem_prime_release,
+};
+
+struct drm_gem_object *msm_gem_import(struct drm_device *dev,
+ uint32_t size, struct sg_table *sgt)
+{
+ struct etnaviv_gem_object *etnaviv_obj;
+ int ret, npages;
+
+ size = PAGE_ALIGN(size);
+
+ ret = etnaviv_gem_new_private(dev, size, ETNA_BO_WC, &etnaviv_obj);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ npages = size / PAGE_SIZE;
+
+ etnaviv_obj->ops = &etnaviv_gem_prime_ops;
+ etnaviv_obj->sgt = sgt;
+ etnaviv_obj->pages = drm_malloc_ab(npages, sizeof(struct page *));
+ if (!etnaviv_obj->pages) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ ret = drm_prime_sg_to_page_addr_arrays(sgt, etnaviv_obj->pages,
+ NULL, npages);
+ if (ret)
+ goto fail;
+
+ return &etnaviv_obj->base;
+
+fail:
+ drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
+
+ return ERR_PTR(ret);
+}