diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_sgdma.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_sgdma.c | 68 |
1 files changed, 10 insertions, 58 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index 464beda94c58..ca5492ac2da5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c | |||
@@ -1,11 +1,10 @@ | |||
1 | #include "drmP.h" | ||
2 | #include "nouveau_drv.h" | ||
3 | #include <linux/pagemap.h> | 1 | #include <linux/pagemap.h> |
4 | #include <linux/slab.h> | 2 | #include <linux/slab.h> |
5 | 3 | ||
6 | #define NV_CTXDMA_PAGE_SHIFT 12 | 4 | #include <subdev/fb.h> |
7 | #define NV_CTXDMA_PAGE_SIZE (1 << NV_CTXDMA_PAGE_SHIFT) | 5 | |
8 | #define NV_CTXDMA_PAGE_MASK (NV_CTXDMA_PAGE_SIZE - 1) | 6 | #include "nouveau_drm.h" |
7 | #include "nouveau_ttm.h" | ||
9 | 8 | ||
10 | struct nouveau_sgdma_be { | 9 | struct nouveau_sgdma_be { |
11 | /* this has to be the first field so populate/unpopulated in | 10 | /* this has to be the first field so populate/unpopulated in |
@@ -22,7 +21,6 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm) | |||
22 | struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm; | 21 | struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm; |
23 | 22 | ||
24 | if (ttm) { | 23 | if (ttm) { |
25 | NV_DEBUG(nvbe->dev, "\n"); | ||
26 | ttm_dma_tt_fini(&nvbe->ttm); | 24 | ttm_dma_tt_fini(&nvbe->ttm); |
27 | kfree(nvbe); | 25 | kfree(nvbe); |
28 | } | 26 | } |
@@ -93,16 +91,18 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, | |||
93 | unsigned long size, uint32_t page_flags, | 91 | unsigned long size, uint32_t page_flags, |
94 | struct page *dummy_read_page) | 92 | struct page *dummy_read_page) |
95 | { | 93 | { |
96 | struct drm_nouveau_private *dev_priv = nouveau_bdev(bdev); | 94 | struct nouveau_drm *drm = nouveau_bdev(bdev); |
97 | struct drm_device *dev = dev_priv->dev; | ||
98 | struct nouveau_sgdma_be *nvbe; | 95 | struct nouveau_sgdma_be *nvbe; |
99 | 96 | ||
100 | nvbe = kzalloc(sizeof(*nvbe), GFP_KERNEL); | 97 | nvbe = kzalloc(sizeof(*nvbe), GFP_KERNEL); |
101 | if (!nvbe) | 98 | if (!nvbe) |
102 | return NULL; | 99 | return NULL; |
103 | 100 | ||
104 | nvbe->dev = dev; | 101 | nvbe->dev = drm->dev; |
105 | nvbe->ttm.ttm.func = dev_priv->gart_info.func; | 102 | if (nv_device(drm->device)->card_type < NV_50) |
103 | nvbe->ttm.ttm.func = &nv04_sgdma_backend; | ||
104 | else | ||
105 | nvbe->ttm.ttm.func = &nv50_sgdma_backend; | ||
106 | 106 | ||
107 | if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) { | 107 | if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) { |
108 | kfree(nvbe); | 108 | kfree(nvbe); |
@@ -110,51 +110,3 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, | |||
110 | } | 110 | } |
111 | return &nvbe->ttm.ttm; | 111 | return &nvbe->ttm.ttm; |
112 | } | 112 | } |
113 | |||
114 | int | ||
115 | nouveau_sgdma_init(struct drm_device *dev) | ||
116 | { | ||
117 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
118 | u32 aper_size; | ||
119 | |||
120 | if (dev_priv->card_type >= NV_50) | ||
121 | aper_size = 512 * 1024 * 1024; | ||
122 | else | ||
123 | aper_size = 128 * 1024 * 1024; | ||
124 | |||
125 | if (dev_priv->card_type >= NV_50) { | ||
126 | dev_priv->gart_info.aper_base = 0; | ||
127 | dev_priv->gart_info.aper_size = aper_size; | ||
128 | dev_priv->gart_info.type = NOUVEAU_GART_HW; | ||
129 | dev_priv->gart_info.func = &nv50_sgdma_backend; | ||
130 | } else { | ||
131 | dev_priv->gart_info.aper_base = 0; | ||
132 | dev_priv->gart_info.aper_size = aper_size; | ||
133 | dev_priv->gart_info.type = NOUVEAU_GART_PDMA; | ||
134 | dev_priv->gart_info.func = &nv04_sgdma_backend; | ||
135 | dev_priv->gart_info.sg_ctxdma = nv04vm_refdma(dev); | ||
136 | } | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | void | ||
142 | nouveau_sgdma_takedown(struct drm_device *dev) | ||
143 | { | ||
144 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
145 | |||
146 | nouveau_gpuobj_ref(NULL, &dev_priv->gart_info.sg_ctxdma); | ||
147 | } | ||
148 | |||
149 | uint32_t | ||
150 | nouveau_sgdma_get_physical(struct drm_device *dev, uint32_t offset) | ||
151 | { | ||
152 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
153 | struct nouveau_gpuobj *gpuobj = dev_priv->gart_info.sg_ctxdma; | ||
154 | int pte = (offset >> NV_CTXDMA_PAGE_SHIFT) + 2; | ||
155 | |||
156 | BUG_ON(dev_priv->card_type >= NV_50); | ||
157 | |||
158 | return (nv_ro32(gpuobj, 4 * pte) & ~NV_CTXDMA_PAGE_MASK) | | ||
159 | (offset & NV_CTXDMA_PAGE_MASK); | ||
160 | } | ||