Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2021 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  */
0022 #include "priv.h"
0023 
0024 static int
0025 ga100_top_oneinit(struct nvkm_top *top)
0026 {
0027     struct nvkm_subdev *subdev = &top->subdev;
0028     struct nvkm_device *device = subdev->device;
0029     struct nvkm_top_device *info = NULL;
0030     u32 data, type, inst;
0031     int i, n, size = nvkm_rd32(device, 0x0224fc) >> 20;
0032 
0033     for (i = 0, n = 0; i < size; i++) {
0034         if (!info) {
0035             if (!(info = nvkm_top_device_new(top)))
0036                 return -ENOMEM;
0037             type = ~0;
0038             inst = 0;
0039         }
0040 
0041         data = nvkm_rd32(device, 0x022800 + (i * 0x04));
0042         nvkm_trace(subdev, "%02x: %08x\n", i, data);
0043         if (!data && n == 0)
0044             continue;
0045 
0046         switch (n++) {
0047         case 0:
0048             type          = (data & 0x3f000000) >> 24;
0049             inst          = (data & 0x000f0000) >> 16;
0050             info->fault   = (data & 0x0000007f);
0051             break;
0052         case 1:
0053             info->addr    = (data & 0x00fff000);
0054             info->reset   = (data & 0x0000001f);
0055             break;
0056         case 2:
0057             info->runlist = (data & 0x00fffc00);
0058             info->engine  = (data & 0x00000003);
0059             break;
0060         default:
0061             break;
0062         }
0063 
0064         if (data & 0x80000000)
0065             continue;
0066         n = 0;
0067 
0068         /* Translate engine type to NVKM engine identifier. */
0069 #define I_(T,I) do { info->type = (T); info->inst = (I); } while(0)
0070 #define O_(T,I) do { WARN_ON(inst); I_(T, I); } while (0)
0071         switch (type) {
0072         case 0x00000000: O_(NVKM_ENGINE_GR    ,    0); break;
0073         case 0x0000000d: O_(NVKM_ENGINE_SEC2  ,    0); break;
0074         case 0x0000000e: I_(NVKM_ENGINE_NVENC , inst); break;
0075         case 0x00000010: I_(NVKM_ENGINE_NVDEC , inst); break;
0076         case 0x00000012: I_(NVKM_SUBDEV_IOCTRL, inst); break;
0077         case 0x00000013: I_(NVKM_ENGINE_CE    , inst); break;
0078         case 0x00000014: O_(NVKM_SUBDEV_GSP   ,    0); break;
0079         case 0x00000015: O_(NVKM_ENGINE_NVJPG ,    0); break;
0080         case 0x00000016: O_(NVKM_ENGINE_OFA   ,    0); break;
0081         case 0x00000017: O_(NVKM_SUBDEV_FLA   ,    0); break;
0082             break;
0083         default:
0084             break;
0085         }
0086 
0087         nvkm_debug(subdev, "%02x.%d (%8s): addr %06x fault %2d "
0088                    "runlist %6x engine %2d reset %2d\n", type, inst,
0089                info->type == NVKM_SUBDEV_NR ? "????????" : nvkm_subdev_type[info->type],
0090                info->addr, info->fault, info->runlist < 0 ? 0 : info->runlist,
0091                info->engine, info->reset);
0092         info = NULL;
0093     }
0094 
0095     return 0;
0096 }
0097 
0098 static const struct nvkm_top_func
0099 ga100_top = {
0100     .oneinit = ga100_top_oneinit,
0101 };
0102 
0103 int
0104 ga100_top_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0105           struct nvkm_top **ptop)
0106 {
0107     return nvkm_top_new_(&ga100_top, device, type, inst, ptop);
0108 }