summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2015-01-20 12:15:19 +0900
committerAlexandre Courbot <acourbot@nvidia.com>2015-02-17 16:31:06 +0900
commit98c97861c207bbc47ee5378904cd7e2158cdbc89 (patch)
treec1aa91de4cfad40f7816d75b6ababc214d3f49eb
parentabfab9dd96f45c860c4bf95261ac584a4b6d318f (diff)
downloadnouveau-98c97861c207bbc47ee5378904cd7e2158cdbc89.tar.gz
ttm: use custom dma_address pointer
-rw-r--r--drm/nouveau/nouveau_bo.c6
-rw-r--r--drm/nouveau/nouveau_sgdma.c49
-rw-r--r--drm/nouveau/nouveau_ttm.h8
3 files changed, 49 insertions, 14 deletions
diff --git a/drm/nouveau/nouveau_bo.c b/drm/nouveau/nouveau_bo.c
index 77326e344..01b2d55fc 100644
--- a/drm/nouveau/nouveau_bo.c
+++ b/drm/nouveau/nouveau_bo.c
@@ -1463,7 +1463,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
static int
nouveau_ttm_tt_populate(struct ttm_tt *ttm)
{
- struct ttm_dma_tt *ttm_dma = (void *)ttm;
+ struct nouveau_ttm_tt *ttm_dma = (void *)ttm;
struct nouveau_drm *drm;
struct nvkm_device *device;
struct drm_device *dev;
@@ -1494,7 +1494,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
*/
if (!nv_device_is_cpu_coherent(device) &&
ttm->caching_state == tt_uncached)
- return ttm_dma_populate(ttm_dma, dev->dev);
+ return ttm_dma_populate(&ttm_dma->ttm_dma, dev->dev);
#if __OS_HAS_AGP
if (drm->agp.stat == ENABLED) {
@@ -1504,7 +1504,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
#ifdef CONFIG_SWIOTLB
if (swiotlb_nr_tbl()) {
- return ttm_dma_populate((void *)ttm, dev->dev);
+ return ttm_dma_populate(&ttm_dma->ttm_dma, dev->dev);
}
#endif
diff --git a/drm/nouveau/nouveau_sgdma.c b/drm/nouveau/nouveau_sgdma.c
index 8c3053a17..1da4efe52 100644
--- a/drm/nouveau/nouveau_sgdma.c
+++ b/drm/nouveau/nouveau_sgdma.c
@@ -1,5 +1,6 @@
#include <linux/pagemap.h>
#include <linux/slab.h>
+#include <drm/drm_mem_util.h>
#include "nouveau_drm.h"
#include "nouveau_ttm.h"
@@ -8,7 +9,7 @@ struct nouveau_sgdma_be {
/* this has to be the first field so populate/unpopulated in
* nouve_bo.c works properly, otherwise have to move them here
*/
- struct ttm_dma_tt ttm;
+ struct nouveau_ttm_tt ttm;
struct nvkm_mem *node;
};
@@ -17,10 +18,18 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm)
{
struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
- if (ttm) {
- ttm_dma_tt_fini(&nvbe->ttm);
- kfree(nvbe);
+ if (!ttm)
+ return;
+
+ if (0) {
+ drm_free_large(nvbe->ttm.dma_address);
+ ttm_tt_fini(&nvbe->ttm.ttm);
+ } else {
+ nvbe->ttm.dma_address = NULL;
+ ttm_dma_tt_fini(&nvbe->ttm.ttm_dma);
}
+
+ kfree(nvbe);
}
static int
@@ -105,12 +114,30 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
else
nvbe->ttm.ttm.func = &nv50_sgdma_backend;
- if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
- /*
- * A failing ttm_dma_tt_init() will call ttm_tt_destroy()
- * and thus our nouveau_sgdma_destroy() hook, so we don't need
- * to free nvbe here.
- */
- return NULL;
+ if (0) {
+ if (ttm_tt_init(&nvbe->ttm.ttm, bdev, size, page_flags, dummy_read_page))
+ /*
+ * A failing ttm_dma_tt_init() will call ttm_tt_destroy()
+ * and thus our nouveau_sgdma_destroy() hook, so we don't need
+ * to free nvbe here.
+ */
+ return NULL;
+ nvbe->ttm.dma_address = drm_calloc_large(nvbe->ttm.ttm.num_pages, sizeof(dma_addr_t));
+ if (!nvbe->ttm.dma_address) {
+ ttm_tt_destroy(&nvbe->ttm.ttm);
+ pr_err("Failed allocating DMA addresses table\n");
+ return NULL;
+ }
+ } else {
+ if (ttm_dma_tt_init(&nvbe->ttm.ttm_dma, bdev, size, page_flags, dummy_read_page))
+ /*
+ * A failing ttm_dma_tt_init() will call ttm_tt_destroy()
+ * and thus our nouveau_sgdma_destroy() hook, so we don't need
+ * to free nvbe here.
+ */
+ return NULL;
+ nvbe->ttm.dma_address = nvbe->ttm.ttm_dma.dma_address;
+ }
+
return &nvbe->ttm.ttm;
}
diff --git a/drm/nouveau/nouveau_ttm.h b/drm/nouveau/nouveau_ttm.h
index 25b0de413..e5d066a03 100644
--- a/drm/nouveau/nouveau_ttm.h
+++ b/drm/nouveau/nouveau_ttm.h
@@ -1,6 +1,14 @@
#ifndef __NOUVEAU_TTM_H__
#define __NOUVEAU_TTM_H__
+struct nouveau_ttm_tt {
+ union {
+ struct ttm_tt ttm;
+ struct ttm_dma_tt ttm_dma;
+ };
+ dma_addr_t *dma_address;
+};
+
static inline struct nouveau_drm *
nouveau_bdev(struct ttm_bo_device *bd)
{