root/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. nvkm_sw_chan_mthd
  2. nvkm_sw_chan_event_ctor
  3. nvkm_sw_chan_dtor
  4. nvkm_sw_chan_ctor

   1 /*
   2  * Copyright 2015 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  * Authors: Ben Skeggs <bskeggs@redhat.com>
  23  */
  24 #include "chan.h"
  25 
  26 #include <core/notify.h>
  27 #include <engine/fifo.h>
  28 
  29 #include <nvif/event.h>
  30 #include <nvif/unpack.h>
  31 
  32 bool
  33 nvkm_sw_chan_mthd(struct nvkm_sw_chan *chan, int subc, u32 mthd, u32 data)
  34 {
  35         switch (mthd) {
  36         case 0x0000:
  37                 return true;
  38         case 0x0500:
  39                 nvkm_event_send(&chan->event, 1, 0, NULL, 0);
  40                 return true;
  41         default:
  42                 if (chan->func->mthd)
  43                         return chan->func->mthd(chan, subc, mthd, data);
  44                 break;
  45         }
  46         return false;
  47 }
  48 
  49 static int
  50 nvkm_sw_chan_event_ctor(struct nvkm_object *object, void *data, u32 size,
  51                         struct nvkm_notify *notify)
  52 {
  53         union {
  54                 struct nvif_notify_uevent_req none;
  55         } *req = data;
  56         int ret = -ENOSYS;
  57 
  58         if (!(ret = nvif_unvers(ret, &data, &size, req->none))) {
  59                 notify->size  = sizeof(struct nvif_notify_uevent_rep);
  60                 notify->types = 1;
  61                 notify->index = 0;
  62         }
  63 
  64         return ret;
  65 }
  66 
  67 static const struct nvkm_event_func
  68 nvkm_sw_chan_event = {
  69         .ctor = nvkm_sw_chan_event_ctor,
  70 };
  71 
  72 static void *
  73 nvkm_sw_chan_dtor(struct nvkm_object *object)
  74 {
  75         struct nvkm_sw_chan *chan = nvkm_sw_chan(object);
  76         struct nvkm_sw *sw = chan->sw;
  77         unsigned long flags;
  78         void *data = chan;
  79 
  80         if (chan->func->dtor)
  81                 data = chan->func->dtor(chan);
  82         nvkm_event_fini(&chan->event);
  83 
  84         spin_lock_irqsave(&sw->engine.lock, flags);
  85         list_del(&chan->head);
  86         spin_unlock_irqrestore(&sw->engine.lock, flags);
  87         return data;
  88 }
  89 
  90 static const struct nvkm_object_func
  91 nvkm_sw_chan = {
  92         .dtor = nvkm_sw_chan_dtor,
  93 };
  94 
  95 int
  96 nvkm_sw_chan_ctor(const struct nvkm_sw_chan_func *func, struct nvkm_sw *sw,
  97                   struct nvkm_fifo_chan *fifo, const struct nvkm_oclass *oclass,
  98                   struct nvkm_sw_chan *chan)
  99 {
 100         unsigned long flags;
 101 
 102         nvkm_object_ctor(&nvkm_sw_chan, oclass, &chan->object);
 103         chan->func = func;
 104         chan->sw = sw;
 105         chan->fifo = fifo;
 106         spin_lock_irqsave(&sw->engine.lock, flags);
 107         list_add(&chan->head, &sw->chan);
 108         spin_unlock_irqrestore(&sw->engine.lock, flags);
 109 
 110         return nvkm_event_init(&nvkm_sw_chan_event, 1, 1, &chan->event);
 111 }

/* [<][>][^][v][top][bottom][index][help] */