2012-05-01 10:48:08 +00:00
|
|
|
/*
|
2012-07-19 22:17:34 +00:00
|
|
|
* Copyright 2012 Red Hat Inc.
|
2012-05-01 10:48:08 +00:00
|
|
|
*
|
2012-07-19 22:17:34 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2012-05-01 10:48:08 +00:00
|
|
|
*
|
2012-07-19 22:17:34 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
2012-05-01 10:48:08 +00:00
|
|
|
*
|
2012-07-19 22:17:34 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
2012-05-01 10:48:08 +00:00
|
|
|
*
|
2012-07-19 22:17:34 +00:00
|
|
|
* Authors: Ben Skeggs
|
2012-05-01 10:48:08 +00:00
|
|
|
*/
|
2015-01-14 05:28:47 +00:00
|
|
|
#include "nv04.h"
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
#include <core/client.h>
|
2012-07-19 22:17:34 +00:00
|
|
|
#include <core/engctx.h>
|
2012-07-04 13:44:54 +00:00
|
|
|
#include <core/ramht.h>
|
2015-08-20 04:54:17 +00:00
|
|
|
#include <subdev/instmem.h>
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-01-14 05:28:47 +00:00
|
|
|
#include <nvif/class.h>
|
|
|
|
#include <nvif/unpack.h>
|
2012-07-19 22:17:34 +00:00
|
|
|
|
|
|
|
static struct ramfc_desc
|
|
|
|
nv17_ramfc[] = {
|
2012-05-01 10:48:08 +00:00
|
|
|
{ 32, 0, 0x00, 0, NV04_PFIFO_CACHE1_DMA_PUT },
|
|
|
|
{ 32, 0, 0x04, 0, NV04_PFIFO_CACHE1_DMA_GET },
|
|
|
|
{ 32, 0, 0x08, 0, NV10_PFIFO_CACHE1_REF_CNT },
|
|
|
|
{ 16, 0, 0x0c, 0, NV04_PFIFO_CACHE1_DMA_INSTANCE },
|
|
|
|
{ 16, 16, 0x0c, 0, NV04_PFIFO_CACHE1_DMA_DCOUNT },
|
|
|
|
{ 32, 0, 0x10, 0, NV04_PFIFO_CACHE1_DMA_STATE },
|
|
|
|
{ 32, 0, 0x14, 0, NV04_PFIFO_CACHE1_DMA_FETCH },
|
|
|
|
{ 32, 0, 0x18, 0, NV04_PFIFO_CACHE1_ENGINE },
|
|
|
|
{ 32, 0, 0x1c, 0, NV04_PFIFO_CACHE1_PULL1 },
|
|
|
|
{ 32, 0, 0x20, 0, NV10_PFIFO_CACHE1_ACQUIRE_VALUE },
|
|
|
|
{ 32, 0, 0x24, 0, NV10_PFIFO_CACHE1_ACQUIRE_TIMESTAMP },
|
|
|
|
{ 32, 0, 0x28, 0, NV10_PFIFO_CACHE1_ACQUIRE_TIMEOUT },
|
|
|
|
{ 32, 0, 0x2c, 0, NV10_PFIFO_CACHE1_SEMAPHORE },
|
|
|
|
{ 32, 0, 0x30, 0, NV10_PFIFO_CACHE1_DMA_SUBROUTINE },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* FIFO channel objects
|
|
|
|
******************************************************************************/
|
2012-05-01 10:48:08 +00:00
|
|
|
|
|
|
|
static int
|
2015-01-14 05:28:47 +00:00
|
|
|
nv17_fifo_chan_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-05-01 10:48:08 +00:00
|
|
|
{
|
2014-08-09 18:10:25 +00:00
|
|
|
union {
|
|
|
|
struct nv03_channel_dma_v0 v0;
|
|
|
|
} *args = data;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv04_fifo *fifo = (void *)engine;
|
2012-07-19 22:17:34 +00:00
|
|
|
struct nv04_fifo_chan *chan;
|
2012-05-01 10:48:08 +00:00
|
|
|
int ret;
|
|
|
|
|
2015-08-20 04:54:13 +00:00
|
|
|
nvif_ioctl(parent, "create channel dma size %d\n", size);
|
2014-08-09 18:10:25 +00:00
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
2015-08-20 04:54:16 +00:00
|
|
|
nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
|
2015-08-20 04:54:16 +00:00
|
|
|
"offset %08x\n", args->v0.version,
|
2015-08-20 04:54:13 +00:00
|
|
|
args->v0.pushbuf, args->v0.offset);
|
2014-08-09 18:10:25 +00:00
|
|
|
} else
|
|
|
|
return ret;
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-01-14 05:28:47 +00:00
|
|
|
ret = nvkm_fifo_channel_create(parent, engine, oclass, 0, 0x800000,
|
|
|
|
0x10000, args->v0.pushbuf,
|
|
|
|
(1ULL << NVDEV_ENGINE_DMAOBJ) |
|
|
|
|
(1ULL << NVDEV_ENGINE_SW) |
|
|
|
|
(1ULL << NVDEV_ENGINE_GR) |
|
|
|
|
(1ULL << NVDEV_ENGINE_MPEG), /* NV31- */
|
|
|
|
&chan);
|
2012-07-19 22:17:34 +00:00
|
|
|
*pobject = nv_object(chan);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
args->v0.chid = chan->base.chid;
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
nv_parent(chan)->object_attach = nv04_fifo_object_attach;
|
|
|
|
nv_parent(chan)->object_detach = nv04_fifo_object_detach;
|
2012-08-10 05:10:34 +00:00
|
|
|
nv_parent(chan)->context_attach = nv04_fifo_context_attach;
|
2012-07-19 22:17:34 +00:00
|
|
|
chan->ramfc = chan->base.chid * 64;
|
|
|
|
|
2015-08-20 04:54:14 +00:00
|
|
|
nvkm_kmap(fifo->ramfc);
|
|
|
|
nvkm_wo32(fifo->ramfc, chan->ramfc + 0x00, args->v0.offset);
|
|
|
|
nvkm_wo32(fifo->ramfc, chan->ramfc + 0x04, args->v0.offset);
|
|
|
|
nvkm_wo32(fifo->ramfc, chan->ramfc + 0x0c, chan->base.pushgpu->addr >> 4);
|
|
|
|
nvkm_wo32(fifo->ramfc, chan->ramfc + 0x14,
|
2012-07-13 06:49:49 +00:00
|
|
|
NV_PFIFO_CACHE1_DMA_FETCH_TRIG_128_BYTES |
|
|
|
|
NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES |
|
2012-05-01 10:48:08 +00:00
|
|
|
#ifdef __BIG_ENDIAN
|
2012-07-13 06:49:49 +00:00
|
|
|
NV_PFIFO_CACHE1_BIG_ENDIAN |
|
2012-05-01 10:48:08 +00:00
|
|
|
#endif
|
2012-07-13 06:49:49 +00:00
|
|
|
NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8);
|
2015-08-20 04:54:14 +00:00
|
|
|
nvkm_done(fifo->ramfc);
|
2012-07-19 22:17:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-01-14 05:28:47 +00:00
|
|
|
static struct nvkm_ofuncs
|
2012-07-19 22:17:34 +00:00
|
|
|
nv17_fifo_ofuncs = {
|
|
|
|
.ctor = nv17_fifo_chan_ctor,
|
|
|
|
.dtor = nv04_fifo_chan_dtor,
|
|
|
|
.init = nv04_fifo_chan_init,
|
|
|
|
.fini = nv04_fifo_chan_fini,
|
2015-01-14 05:28:47 +00:00
|
|
|
.map = _nvkm_fifo_channel_map,
|
|
|
|
.rd32 = _nvkm_fifo_channel_rd32,
|
|
|
|
.wr32 = _nvkm_fifo_channel_wr32,
|
|
|
|
.ntfy = _nvkm_fifo_channel_ntfy
|
2012-07-19 22:17:34 +00:00
|
|
|
};
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-01-14 05:28:47 +00:00
|
|
|
static struct nvkm_oclass
|
2012-07-19 22:17:34 +00:00
|
|
|
nv17_fifo_sclass[] = {
|
2014-08-09 18:10:25 +00:00
|
|
|
{ NV17_CHANNEL_DMA, &nv17_fifo_ofuncs },
|
2012-07-19 22:17:34 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* FIFO context - basically just the instmem reserved for the channel
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-01-14 05:28:47 +00:00
|
|
|
static struct nvkm_oclass
|
2012-07-19 22:17:34 +00:00
|
|
|
nv17_fifo_cclass = {
|
|
|
|
.handle = NV_ENGCTX(FIFO, 0x17),
|
2015-01-14 05:28:47 +00:00
|
|
|
.ofuncs = &(struct nvkm_ofuncs) {
|
2012-07-19 22:17:34 +00:00
|
|
|
.ctor = nv04_fifo_context_ctor,
|
2015-01-14 05:28:47 +00:00
|
|
|
.dtor = _nvkm_fifo_context_dtor,
|
|
|
|
.init = _nvkm_fifo_context_init,
|
|
|
|
.fini = _nvkm_fifo_context_fini,
|
|
|
|
.rd32 = _nvkm_fifo_context_rd32,
|
|
|
|
.wr32 = _nvkm_fifo_context_wr32,
|
2012-07-19 22:17:34 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* PFIFO engine
|
|
|
|
******************************************************************************/
|
2012-05-01 10:48:08 +00:00
|
|
|
|
|
|
|
static int
|
2015-01-14 05:28:47 +00:00
|
|
|
nv17_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-05-01 10:48:08 +00:00
|
|
|
{
|
2015-08-20 04:54:17 +00:00
|
|
|
struct nvkm_device *device = (void *)parent;
|
|
|
|
struct nvkm_instmem *imem = device->imem;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv04_fifo *fifo;
|
2012-07-19 22:17:34 +00:00
|
|
|
int ret;
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
ret = nvkm_fifo_create(parent, engine, oclass, 0, 31, &fifo);
|
|
|
|
*pobject = nv_object(fifo);
|
2012-07-19 22:17:34 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nvkm_ramht_ref(imem->ramht, &fifo->ramht);
|
|
|
|
nvkm_gpuobj_ref(imem->ramro, &fifo->ramro);
|
|
|
|
nvkm_gpuobj_ref(imem->ramfc, &fifo->ramfc);
|
|
|
|
|
|
|
|
nv_subdev(fifo)->unit = 0x00000100;
|
|
|
|
nv_subdev(fifo)->intr = nv04_fifo_intr;
|
|
|
|
nv_engine(fifo)->cclass = &nv17_fifo_cclass;
|
|
|
|
nv_engine(fifo)->sclass = nv17_fifo_sclass;
|
|
|
|
fifo->base.pause = nv04_fifo_pause;
|
|
|
|
fifo->base.start = nv04_fifo_start;
|
|
|
|
fifo->ramfc_desc = nv17_ramfc;
|
2012-07-19 22:17:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
static int
|
2015-01-14 05:28:47 +00:00
|
|
|
nv17_fifo_init(struct nvkm_object *object)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv04_fifo *fifo = (void *)object;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = fifo->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
int ret;
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
ret = nvkm_fifo_init(&fifo->base);
|
2012-07-19 22:17:34 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV04_PFIFO_DELAY_0, 0x000000ff);
|
|
|
|
nvkm_wr32(device, NV04_PFIFO_DMA_TIMESLICE, 0x0101ffff);
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PFIFO_RAMHT, (0x03 << 24) /* search 128 */ |
|
2015-08-20 04:54:07 +00:00
|
|
|
((fifo->ramht->bits - 9) << 16) |
|
|
|
|
(fifo->ramht->gpuobj.addr >> 8));
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PFIFO_RAMRO, fifo->ramro->addr >> 8);
|
|
|
|
nvkm_wr32(device, NV03_PFIFO_RAMFC, fifo->ramfc->addr >> 8 | 0x00010000);
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PFIFO_CACHE1_PUSH1, fifo->base.max);
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PFIFO_INTR_0, 0xffffffff);
|
|
|
|
nvkm_wr32(device, NV03_PFIFO_INTR_EN_0, 0xffffffff);
|
2012-05-01 10:48:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PFIFO_CACHE1_PUSH0, 1);
|
|
|
|
nvkm_wr32(device, NV04_PFIFO_CACHE1_PULL0, 1);
|
|
|
|
nvkm_wr32(device, NV03_PFIFO_CACHES, 1);
|
2012-05-01 10:48:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-14 05:28:47 +00:00
|
|
|
struct nvkm_oclass *
|
|
|
|
nv17_fifo_oclass = &(struct nvkm_oclass) {
|
2012-07-19 22:17:34 +00:00
|
|
|
.handle = NV_ENGINE(FIFO, 0x17),
|
2015-01-14 05:28:47 +00:00
|
|
|
.ofuncs = &(struct nvkm_ofuncs) {
|
2012-07-19 22:17:34 +00:00
|
|
|
.ctor = nv17_fifo_ctor,
|
|
|
|
.dtor = nv04_fifo_dtor,
|
|
|
|
.init = nv17_fifo_init,
|
2015-01-14 05:28:47 +00:00
|
|
|
.fini = _nvkm_fifo_fini,
|
2012-07-19 22:17:34 +00:00
|
|
|
},
|
|
|
|
};
|