Home | History | Annotate | Line # | Download | only in ce
      1 /*	$NetBSD: nouveau_nvkm_engine_ce_gk104.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2012 Red Hat Inc.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  * Authors: Ben Skeggs
     25  */
     26 #include <sys/cdefs.h>
     27 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_ce_gk104.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $");
     28 
     29 #include "priv.h"
     30 #include <core/enum.h>
     31 
     32 #include <nvif/class.h>
     33 
     34 static const struct nvkm_enum
     35 gk104_ce_launcherr_report[] = {
     36 	{ 0x0, "NO_ERR" },
     37 	{ 0x1, "2D_LAYER_EXCEEDS_DEPTH" },
     38 	{ 0x2, "INVALID_ARGUMENT" },
     39 	{ 0x3, "MEM2MEM_RECT_OUT_OF_BOUNDS" },
     40 	{ 0x4, "SRC_LINE_EXCEEDS_PITCH" },
     41 	{ 0x5, "SRC_LINE_EXCEEDS_NEG_PITCH" },
     42 	{ 0x6, "DST_LINE_EXCEEDS_PITCH" },
     43 	{ 0x7, "DST_LINE_EXCEEDS_NEG_PITCH" },
     44 	{ 0x8, "BAD_SRC_PIXEL_COMP_REF" },
     45 	{ 0x9, "INVALID_VALUE" },
     46 	{ 0xa, "UNUSED_FIELD" },
     47 	{ 0xb, "INVALID_OPERATION" },
     48 	{}
     49 };
     50 
     51 static void
     52 gk104_ce_intr_launcherr(struct nvkm_engine *ce, const u32 base)
     53 {
     54 	struct nvkm_subdev *subdev = &ce->subdev;
     55 	struct nvkm_device *device = subdev->device;
     56 	u32 stat = nvkm_rd32(device, 0x104f14 + base);
     57 	const struct nvkm_enum *en =
     58 		nvkm_enum_find(gk104_ce_launcherr_report, stat & 0x0000000f);
     59 	nvkm_warn(subdev, "LAUNCHERR %08x [%s]\n", stat, en ? en->name : "");
     60 	nvkm_wr32(device, 0x104f14 + base, 0x00000000);
     61 }
     62 
     63 void
     64 gk104_ce_intr(struct nvkm_engine *ce)
     65 {
     66 	const u32 base = (ce->subdev.index - NVKM_ENGINE_CE0) * 0x1000;
     67 	struct nvkm_subdev *subdev = &ce->subdev;
     68 	struct nvkm_device *device = subdev->device;
     69 	u32 mask = nvkm_rd32(device, 0x104904 + base);
     70 	u32 intr = nvkm_rd32(device, 0x104908 + base) & mask;
     71 	if (intr & 0x00000001) {
     72 		nvkm_warn(subdev, "BLOCKPIPE\n");
     73 		nvkm_wr32(device, 0x104908 + base, 0x00000001);
     74 		intr &= ~0x00000001;
     75 	}
     76 	if (intr & 0x00000002) {
     77 		nvkm_warn(subdev, "NONBLOCKPIPE\n");
     78 		nvkm_wr32(device, 0x104908 + base, 0x00000002);
     79 		intr &= ~0x00000002;
     80 	}
     81 	if (intr & 0x00000004) {
     82 		gk104_ce_intr_launcherr(ce, base);
     83 		nvkm_wr32(device, 0x104908 + base, 0x00000004);
     84 		intr &= ~0x00000004;
     85 	}
     86 	if (intr) {
     87 		nvkm_warn(subdev, "intr %08x\n", intr);
     88 		nvkm_wr32(device, 0x104908 + base, intr);
     89 	}
     90 }
     91 
     92 static const struct nvkm_engine_func
     93 gk104_ce = {
     94 	.intr = gk104_ce_intr,
     95 	.sclass = {
     96 		{ -1, -1, KEPLER_DMA_COPY_A },
     97 		{}
     98 	}
     99 };
    100 
    101 int
    102 gk104_ce_new(struct nvkm_device *device, int index,
    103 	     struct nvkm_engine **pengine)
    104 {
    105 	return nvkm_engine_new_(&gk104_ce, device, index, true, pengine);
    106 }
    107