cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

gpfifotu102.c (2867B)


      1/*
      2 * Copyright 2018 Red Hat Inc.
      3 *
      4 * Permission is hereby granted, free of charge, to any person obtaining a
      5 * copy of this software and associated documentation files (the "Software"),
      6 * to deal in the Software without restriction, including without limitation
      7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8 * and/or sell copies of the Software, and to permit persons to whom the
      9 * Software is furnished to do so, subject to the following conditions:
     10 *
     11 * The above copyright notice and this permission notice shall be included in
     12 * all copies or substantial portions of the Software.
     13 *
     14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     20 * OTHER DEALINGS IN THE SOFTWARE.
     21 */
     22#include "changk104.h"
     23#include "cgrp.h"
     24
     25#include <core/client.h>
     26#include <core/gpuobj.h>
     27
     28#include <nvif/clc36f.h>
     29#include <nvif/unpack.h>
     30
     31static u32
     32tu102_fifo_gpfifo_submit_token(struct nvkm_fifo_chan *base)
     33{
     34	struct gk104_fifo_chan *chan = gk104_fifo_chan(base);
     35	return (chan->runl << 16) | chan->base.chid;
     36}
     37
     38static const struct nvkm_fifo_chan_func
     39tu102_fifo_gpfifo = {
     40	.dtor = gk104_fifo_gpfifo_dtor,
     41	.init = gk104_fifo_gpfifo_init,
     42	.fini = gk104_fifo_gpfifo_fini,
     43	.ntfy = gf100_fifo_chan_ntfy,
     44	.engine_ctor = gk104_fifo_gpfifo_engine_ctor,
     45	.engine_dtor = gk104_fifo_gpfifo_engine_dtor,
     46	.engine_init = gv100_fifo_gpfifo_engine_init,
     47	.engine_fini = gv100_fifo_gpfifo_engine_fini,
     48	.submit_token = tu102_fifo_gpfifo_submit_token,
     49};
     50
     51int
     52tu102_fifo_gpfifo_new(struct gk104_fifo *fifo, const struct nvkm_oclass *oclass,
     53		      void *data, u32 size, struct nvkm_object **pobject)
     54{
     55	struct nvkm_object *parent = oclass->parent;
     56	union {
     57		struct volta_channel_gpfifo_a_v0 v0;
     58	} *args = data;
     59	int ret = -ENOSYS;
     60
     61	nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
     62	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
     63		nvif_ioctl(parent, "create channel gpfifo vers %d vmm %llx "
     64				   "ioffset %016llx ilength %08x "
     65				   "runlist %016llx priv %d\n",
     66			   args->v0.version, args->v0.vmm, args->v0.ioffset,
     67			   args->v0.ilength, args->v0.runlist, args->v0.priv);
     68		return gv100_fifo_gpfifo_new_(&tu102_fifo_gpfifo, fifo,
     69					      &args->v0.runlist,
     70					      &args->v0.chid,
     71					       args->v0.vmm,
     72					       args->v0.ioffset,
     73					       args->v0.ilength,
     74					      &args->v0.inst,
     75					       args->v0.priv,
     76					      &args->v0.token,
     77					      oclass, pobject);
     78	}
     79
     80	return ret;
     81}