18e7e1586SBen Skeggs /*
28e7e1586SBen Skeggs * Copyright 2015 Red Hat Inc.
38e7e1586SBen Skeggs *
48e7e1586SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
58e7e1586SBen Skeggs * copy of this software and associated documentation files (the "Software"),
68e7e1586SBen Skeggs * to deal in the Software without restriction, including without limitation
78e7e1586SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88e7e1586SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
98e7e1586SBen Skeggs * Software is furnished to do so, subject to the following conditions:
108e7e1586SBen Skeggs *
118e7e1586SBen Skeggs * The above copyright notice and this permission notice shall be included in
128e7e1586SBen Skeggs * all copies or substantial portions of the Software.
138e7e1586SBen Skeggs *
148e7e1586SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158e7e1586SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168e7e1586SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
178e7e1586SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188e7e1586SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198e7e1586SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208e7e1586SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
218e7e1586SBen Skeggs *
228e7e1586SBen Skeggs * Authors: Ben Skeggs
238e7e1586SBen Skeggs */
248e7e1586SBen Skeggs #include "priv.h"
258e7e1586SBen Skeggs #include <core/enum.h>
268e7e1586SBen Skeggs
278e7e1586SBen Skeggs #include <nvif/class.h>
288e7e1586SBen Skeggs
298e7e1586SBen Skeggs static const struct nvkm_enum
308e7e1586SBen Skeggs gp100_ce_launcherr_report[] = {
318e7e1586SBen Skeggs { 0x0, "NO_ERR" },
328e7e1586SBen Skeggs { 0x1, "2D_LAYER_EXCEEDS_DEPTH" },
338e7e1586SBen Skeggs { 0x2, "INVALID_ALIGNMENT" },
348e7e1586SBen Skeggs { 0x3, "MEM2MEM_RECT_OUT_OF_BOUNDS" },
358e7e1586SBen Skeggs { 0x4, "SRC_LINE_EXCEEDS_PITCH" },
368e7e1586SBen Skeggs { 0x5, "SRC_LINE_EXCEEDS_NEG_PITCH" },
378e7e1586SBen Skeggs { 0x6, "DST_LINE_EXCEEDS_PITCH" },
388e7e1586SBen Skeggs { 0x7, "DST_LINE_EXCEEDS_NEG_PITCH" },
398e7e1586SBen Skeggs { 0x8, "BAD_SRC_PIXEL_COMP_REF" },
408e7e1586SBen Skeggs { 0x9, "INVALID_VALUE" },
418e7e1586SBen Skeggs { 0xa, "UNUSED_FIELD" },
428e7e1586SBen Skeggs { 0xb, "INVALID_OPERATION" },
438e7e1586SBen Skeggs { 0xc, "NO_RESOURCES" },
448e7e1586SBen Skeggs { 0xd, "INVALID_CONFIG" },
458e7e1586SBen Skeggs {}
468e7e1586SBen Skeggs };
478e7e1586SBen Skeggs
488e7e1586SBen Skeggs static void
gp100_ce_intr_launcherr(struct nvkm_engine * ce,const u32 base)498e7e1586SBen Skeggs gp100_ce_intr_launcherr(struct nvkm_engine *ce, const u32 base)
508e7e1586SBen Skeggs {
518e7e1586SBen Skeggs struct nvkm_subdev *subdev = &ce->subdev;
528e7e1586SBen Skeggs struct nvkm_device *device = subdev->device;
538e7e1586SBen Skeggs u32 stat = nvkm_rd32(device, 0x104418 + base);
548e7e1586SBen Skeggs const struct nvkm_enum *en =
558e7e1586SBen Skeggs nvkm_enum_find(gp100_ce_launcherr_report, stat & 0x0000000f);
568e7e1586SBen Skeggs nvkm_warn(subdev, "LAUNCHERR %08x [%s]\n", stat, en ? en->name : "");
578e7e1586SBen Skeggs }
588e7e1586SBen Skeggs
598e7e1586SBen Skeggs void
gp100_ce_intr(struct nvkm_engine * ce)608e7e1586SBen Skeggs gp100_ce_intr(struct nvkm_engine *ce)
618e7e1586SBen Skeggs {
628e7e1586SBen Skeggs struct nvkm_subdev *subdev = &ce->subdev;
638e7e1586SBen Skeggs struct nvkm_device *device = subdev->device;
64*608a29c2SBen Skeggs const u32 base = subdev->inst * 0x80;
658e7e1586SBen Skeggs u32 mask = nvkm_rd32(device, 0x10440c + base);
668e7e1586SBen Skeggs u32 intr = nvkm_rd32(device, 0x104410 + base) & mask;
678e7e1586SBen Skeggs if (intr & 0x00000001) { //XXX: guess
688e7e1586SBen Skeggs nvkm_warn(subdev, "BLOCKPIPE\n");
698e7e1586SBen Skeggs nvkm_wr32(device, 0x104410 + base, 0x00000001);
708e7e1586SBen Skeggs intr &= ~0x00000001;
718e7e1586SBen Skeggs }
728e7e1586SBen Skeggs if (intr & 0x00000002) { //XXX: guess
738e7e1586SBen Skeggs nvkm_warn(subdev, "NONBLOCKPIPE\n");
748e7e1586SBen Skeggs nvkm_wr32(device, 0x104410 + base, 0x00000002);
758e7e1586SBen Skeggs intr &= ~0x00000002;
768e7e1586SBen Skeggs }
778e7e1586SBen Skeggs if (intr & 0x00000004) {
788e7e1586SBen Skeggs gp100_ce_intr_launcherr(ce, base);
798e7e1586SBen Skeggs nvkm_wr32(device, 0x104410 + base, 0x00000004);
808e7e1586SBen Skeggs intr &= ~0x00000004;
818e7e1586SBen Skeggs }
828e7e1586SBen Skeggs if (intr) {
838e7e1586SBen Skeggs nvkm_warn(subdev, "intr %08x\n", intr);
848e7e1586SBen Skeggs nvkm_wr32(device, 0x104410 + base, intr);
858e7e1586SBen Skeggs }
868e7e1586SBen Skeggs }
878e7e1586SBen Skeggs
888e7e1586SBen Skeggs static const struct nvkm_engine_func
898e7e1586SBen Skeggs gp100_ce = {
908e7e1586SBen Skeggs .intr = gp100_ce_intr,
918e7e1586SBen Skeggs .sclass = {
928e7e1586SBen Skeggs { -1, -1, PASCAL_DMA_COPY_A },
938e7e1586SBen Skeggs {}
948e7e1586SBen Skeggs }
958e7e1586SBen Skeggs };
968e7e1586SBen Skeggs
978e7e1586SBen Skeggs int
gp100_ce_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_engine ** pengine)9850551b15SBen Skeggs gp100_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
998e7e1586SBen Skeggs struct nvkm_engine **pengine)
1008e7e1586SBen Skeggs {
10150551b15SBen Skeggs return nvkm_engine_new_(&gp100_ce, device, type, inst, true, pengine);
1028e7e1586SBen Skeggs }
103