diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-10-08 00:34:35 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-11-28 18:56:39 -0500 |
commit | 80fe155ba6844f3cf2f083cbd34be12bb391ec4a (patch) | |
tree | f78fcfbcca1b4c6b7f279c5d5d2016d4ecf26867 | |
parent | f756944a219cb2d38b0859e8af680f9b216de1e3 (diff) |
drm/nvc0/dmaobj: implement initial bind() method
Currently unused.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/engine/dmaobj/nvc0.c | 59 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/include/core/class.h | 11 |
2 files changed, 69 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/core/engine/dmaobj/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/dmaobj/nvc0.c index 6fe20d21158f..b261a8ffe494 100644 --- a/drivers/gpu/drm/nouveau/core/engine/dmaobj/nvc0.c +++ b/drivers/gpu/drm/nouveau/core/engine/dmaobj/nvc0.c | |||
@@ -39,7 +39,9 @@ nvc0_dmaobj_bind(struct nouveau_dmaeng *dmaeng, | |||
39 | struct nouveau_dmaobj *dmaobj, | 39 | struct nouveau_dmaobj *dmaobj, |
40 | struct nouveau_gpuobj **pgpuobj) | 40 | struct nouveau_gpuobj **pgpuobj) |
41 | { | 41 | { |
42 | int ret = 0; | 42 | u32 flags0 = nv_mclass(dmaobj); |
43 | u32 flags5 = 0x00000000; | ||
44 | int ret; | ||
43 | 45 | ||
44 | if (!nv_iclass(parent, NV_ENGCTX_CLASS)) { | 46 | if (!nv_iclass(parent, NV_ENGCTX_CLASS)) { |
45 | switch (nv_mclass(parent->parent)) { | 47 | switch (nv_mclass(parent->parent)) { |
@@ -49,6 +51,61 @@ nvc0_dmaobj_bind(struct nouveau_dmaeng *dmaeng, | |||
49 | } else | 51 | } else |
50 | return 0; | 52 | return 0; |
51 | 53 | ||
54 | if (!(dmaobj->conf0 & NVC0_DMA_CONF0_ENABLE)) { | ||
55 | if (dmaobj->target == NV_MEM_TARGET_VM) { | ||
56 | dmaobj->conf0 = NVC0_DMA_CONF0_PRIV_VM; | ||
57 | dmaobj->conf0 |= NVC0_DMA_CONF0_TYPE_VM; | ||
58 | } else { | ||
59 | dmaobj->conf0 = NVC0_DMA_CONF0_PRIV_US; | ||
60 | dmaobj->conf0 |= NVC0_DMA_CONF0_TYPE_LINEAR; | ||
61 | dmaobj->conf0 |= 0x00020000; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | flags0 |= (dmaobj->conf0 & NVC0_DMA_CONF0_TYPE) << 22; | ||
66 | flags0 |= (dmaobj->conf0 & NVC0_DMA_CONF0_PRIV); | ||
67 | flags5 |= (dmaobj->conf0 & NVC0_DMA_CONF0_UNKN); | ||
68 | |||
69 | switch (dmaobj->target) { | ||
70 | case NV_MEM_TARGET_VM: | ||
71 | flags0 |= 0x00000000; | ||
72 | break; | ||
73 | case NV_MEM_TARGET_VRAM: | ||
74 | flags0 |= 0x00010000; | ||
75 | break; | ||
76 | case NV_MEM_TARGET_PCI: | ||
77 | flags0 |= 0x00020000; | ||
78 | break; | ||
79 | case NV_MEM_TARGET_PCI_NOSNOOP: | ||
80 | flags0 |= 0x00030000; | ||
81 | break; | ||
82 | default: | ||
83 | return -EINVAL; | ||
84 | } | ||
85 | |||
86 | switch (dmaobj->access) { | ||
87 | case NV_MEM_ACCESS_VM: | ||
88 | break; | ||
89 | case NV_MEM_ACCESS_RO: | ||
90 | flags0 |= 0x00040000; | ||
91 | break; | ||
92 | case NV_MEM_ACCESS_WO: | ||
93 | case NV_MEM_ACCESS_RW: | ||
94 | flags0 |= 0x00080000; | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | ret = nouveau_gpuobj_new(parent, parent, 24, 32, 0, pgpuobj); | ||
99 | if (ret == 0) { | ||
100 | nv_wo32(*pgpuobj, 0x00, flags0); | ||
101 | nv_wo32(*pgpuobj, 0x04, lower_32_bits(dmaobj->limit)); | ||
102 | nv_wo32(*pgpuobj, 0x08, lower_32_bits(dmaobj->start)); | ||
103 | nv_wo32(*pgpuobj, 0x0c, upper_32_bits(dmaobj->limit) << 24 | | ||
104 | upper_32_bits(dmaobj->start)); | ||
105 | nv_wo32(*pgpuobj, 0x10, 0x00000000); | ||
106 | nv_wo32(*pgpuobj, 0x14, flags5); | ||
107 | } | ||
108 | |||
52 | return ret; | 109 | return ret; |
53 | } | 110 | } |
54 | 111 | ||
diff --git a/drivers/gpu/drm/nouveau/core/include/core/class.h b/drivers/gpu/drm/nouveau/core/include/core/class.h index 445a4bad2936..ab4ab662a8ba 100644 --- a/drivers/gpu/drm/nouveau/core/include/core/class.h +++ b/drivers/gpu/drm/nouveau/core/include/core/class.h | |||
@@ -69,6 +69,17 @@ struct nv_device_class { | |||
69 | #define NV50_DMA_CONF0_TYPE_LINEAR 0x00000000 | 69 | #define NV50_DMA_CONF0_TYPE_LINEAR 0x00000000 |
70 | #define NV50_DMA_CONF0_TYPE_VM 0x0000007f | 70 | #define NV50_DMA_CONF0_TYPE_VM 0x0000007f |
71 | 71 | ||
72 | /* NVC0:NVD9 */ | ||
73 | #define NVC0_DMA_CONF0_ENABLE 0x80000000 | ||
74 | #define NVC0_DMA_CONF0_PRIV 0x00300000 | ||
75 | #define NVC0_DMA_CONF0_PRIV_VM 0x00000000 | ||
76 | #define NVC0_DMA_CONF0_PRIV_US 0x00100000 | ||
77 | #define NVC0_DMA_CONF0_PRIV__S 0x00200000 | ||
78 | #define NVC0_DMA_CONF0_UNKN /* PART? */ 0x00030000 | ||
79 | #define NVC0_DMA_CONF0_TYPE 0x000000ff | ||
80 | #define NVC0_DMA_CONF0_TYPE_LINEAR 0x00000000 | ||
81 | #define NVC0_DMA_CONF0_TYPE_VM 0x000000ff | ||
82 | |||
72 | struct nv_dma_class { | 83 | struct nv_dma_class { |
73 | u32 flags; | 84 | u32 flags; |
74 | u32 pad0; | 85 | u32 pad0; |