Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core Import drm ...



details:   https://anonhg.NetBSD.org/src/rev/277cf37a975d
branches:  trunk
changeset: 1027753:277cf37a975d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Dec 18 20:23:00 2021 +0000

description:
Import drm from Linux v5.6-rc3 (commit f8788d86ab28f61f7b46eb6be375f8a726783636)

    drivers/gpu/drm     -> sys/external/bsd/drm2/dist/drm
    include/drm         -> sys/external/bsd/drm2/dist/include/drm
    include/uapi/drm    -> sys/external/bsd/drm2/dist/include/uapi/drm

GPL exclusions in dist/drm:

- amd/amdgpu/amdgpu_atpx_handler.c
- arc/
- arm/
- armada/
- aspeed/
- atmel-hlcdc/
- bochs/
- bridge/
- cirrus/
- drm_dp_cec.c
- drm_dp_mst_topology_internal.h
- drm_edid_load.c
- drm_format_helper.c
- drm_gem_cma_helper.c
- drm_gem_framebuffer_helper.c
- drm_gem_shmem_helper.c
- drm_gem_ttm_helper.c
- drm_gem_vram_helper.c
- drm_hdcp.c
- drm_lease.c
- drm_mipi_dbi.c
- drm_simple_kms_helper.c
- drm_sysfs.c
- drm_trace.h
- drm_vram_helper_common.c
- drm_writeback.c
- etnaviv/
- exynos/
- fsl-dcu/
- gma500/
- hisilicon/
- i2c/tda9950.c
- i2c/tda998x_drv.c
- i915/gt/selftest_context.c
- i915/gt/selftest_engine.c
- i915/gt/selftest_engine.h
- i915/gt/selftest_engine_cs.c
- i915/gt/selftest_engine_pm.c
- i915/i915_trace.h
- i915/selftests/i915_live_selftests.h
- i915/selftests/i915_mock_selftests.h
- i915/selftests/i915_perf_selftests.h
- i915/selftests/lib_sw_fence.h
- imx/
- ingenic/
- lima/
- mcde/
- mediatek/
- meson/
- mgag200/
- msm/
- mxsfb/
- omapdrm/
- panel/
- panfrost/
- pl111/
- radeon/radeon_atpx_handler.c
- rcar-du/
- rockchip/
- selftests/drm_cmdline_selftests.h
- selftests/drm_modeset_selftests.h
- selftests/test-drm_cmdline_parser.c
- selftests/test-drm_damage_helper.c
- selftests/test-drm_dp_mst_helper.c
- selftests/test-drm_format.c
- selftests/test-drm_framebuffer.c
- selftests/test-drm_modeset_common.c
- selftests/test-drm_modeset_common.h
- selftests/test-drm_plane_helper.c
- selftests/test-drm_rect.c
- shmobile/
- sti/
- stm/
- sun4i/
- tegra/
- tilcdc/
- tiny/
- tve200/
- udl/
- v3d/
- vc4/
- virtio/virtgpu_trace.h
- virtio/virtgpu_trace_points.c
- vkms/
- vmwgfx/device_include/vmware_pack_begin.h
- vmwgfx/device_include/vmware_pack_end.h
- zte/

  Exceptions -- these all appear to be files to which someone added
  an SPDX license header automatically by a script that is not aware
  of the default MIT licensing under drivers/gpu/drm:

  - ast/ast_dp501.c
  - ast/ast_dram_tables.h
  - lib/drm_random.c
  - lib/drm_random.h
  - i915/display/intel_acpi.c
  - i915/selftests/mock_gem_device.h
  - i915/selftests/i915_mock_selftests.h
  - i915/selftests/i915_live_selftests.h
  - r128/ati_pcigart.h
  - selftests/drm_mm_selftests.h
  - selftests/test-drm_mm.c
  - vmwgfx/device_include/vm_basic_types.h

GPL exclusions in dist/include/drm:

- bridge
- drm_client.h
- drm_fb_cma_helper.h
- drm_format_helper.h
- drm_gem_cma_helper.h
- drm_gem_shmem_helper.h
- drm_gem_ttm_helper.h
- drm_gem_vram_helper.h
- drm_lease.h
- drm_mipi_dbi.h
- drm_mipi_dsi.h
- drm_of.h
- drm_simple_kms_helper.h
- drm_sysfs.h
- drm_writeback.h
- gma_drm.h
- i2c/tda998x.h
- i915_mei_hdcp_interface.h
- intel-gtt.h

  Exceptions:
  - drm_agpsupport.h - was in original drm; wrong spdx header auto-added

GPL exclusions in dist/include/uapi/drm:

- armada_drm.h
- etnaviv_drm.h
- exynos_drm.h
- lima_drm.h
- omap_drm.h

  Exceptions:
  - i810_drm.h - was in original drm; spdx header is wrong

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/falcon.h             |   79 ++++++
 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/firmware.h           |   57 +++++
 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/oclass.h             |   33 ++
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_firmware.c |  113 ++++++++++
 4 files changed, 282 insertions(+), 0 deletions(-)

diffs (298 lines):

diff -r c0025f09e79d -r 277cf37a975d sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/falcon.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/falcon.h Sat Dec 18 20:23:00 2021 +0000
@@ -0,0 +1,79 @@
+/*     $NetBSD: falcon.h,v 1.1.1.1 2021/12/18 20:23:00 riastradh Exp $ */
+
+#ifndef __NVKM_FALCON_H__
+#define __NVKM_FALCON_H__
+#include <engine/falcon.h>
+
+int nvkm_falcon_ctor(const struct nvkm_falcon_func *, struct nvkm_subdev *owner,
+                    const char *name, u32 addr, struct nvkm_falcon *);
+void nvkm_falcon_dtor(struct nvkm_falcon *);
+
+void nvkm_falcon_v1_load_imem(struct nvkm_falcon *,
+                             void *, u32, u32, u16, u8, bool);
+void nvkm_falcon_v1_load_dmem(struct nvkm_falcon *, void *, u32, u32, u8);
+void nvkm_falcon_v1_read_dmem(struct nvkm_falcon *, u32, u32, u8, void *);
+void nvkm_falcon_v1_bind_context(struct nvkm_falcon *, struct nvkm_memory *);
+int nvkm_falcon_v1_wait_for_halt(struct nvkm_falcon *, u32);
+int nvkm_falcon_v1_clear_interrupt(struct nvkm_falcon *, u32);
+void nvkm_falcon_v1_set_start_addr(struct nvkm_falcon *, u32 start_addr);
+void nvkm_falcon_v1_start(struct nvkm_falcon *);
+int nvkm_falcon_v1_enable(struct nvkm_falcon *);
+void nvkm_falcon_v1_disable(struct nvkm_falcon *);
+
+void gp102_sec2_flcn_bind_context(struct nvkm_falcon *, struct nvkm_memory *);
+int gp102_sec2_flcn_enable(struct nvkm_falcon *);
+
+#define FLCN_PRINTK(t,f,fmt,a...) do {                                         \
+       if (nvkm_subdev_name[(f)->owner->index] != (f)->name)                  \
+               nvkm_##t((f)->owner, "%s: "fmt"\n", (f)->name, ##a);           \
+       else                                                                   \
+               nvkm_##t((f)->owner, fmt"\n", ##a);                            \
+} while(0)
+#define FLCN_DBG(f,fmt,a...) FLCN_PRINTK(debug, (f), fmt, ##a)
+#define FLCN_ERR(f,fmt,a...) FLCN_PRINTK(error, (f), fmt, ##a)
+
+/**
+ * struct nv_falcon_msg - header for all messages
+ *
+ * @unit_id:   id of firmware process that sent the message
+ * @size:      total size of message
+ * @ctrl_flags:        control flags
+ * @seq_id:    used to match a message from its corresponding command
+ */
+struct nv_falcon_msg {
+       u8 unit_id;
+       u8 size;
+       u8 ctrl_flags;
+       u8 seq_id;
+};
+
+#define nv_falcon_cmd nv_falcon_msg
+#define NV_FALCON_CMD_UNIT_ID_REWIND                                       0x00
+
+struct nvkm_falcon_qmgr;
+int nvkm_falcon_qmgr_new(struct nvkm_falcon *, struct nvkm_falcon_qmgr **);
+void nvkm_falcon_qmgr_del(struct nvkm_falcon_qmgr **);
+
+typedef int
+(*nvkm_falcon_qmgr_callback)(void *priv, struct nv_falcon_msg *);
+
+struct nvkm_falcon_cmdq;
+int nvkm_falcon_cmdq_new(struct nvkm_falcon_qmgr *, const char *name,
+                        struct nvkm_falcon_cmdq **);
+void nvkm_falcon_cmdq_del(struct nvkm_falcon_cmdq **);
+void nvkm_falcon_cmdq_init(struct nvkm_falcon_cmdq *,
+                          u32 index, u32 offset, u32 size);
+void nvkm_falcon_cmdq_fini(struct nvkm_falcon_cmdq *);
+int nvkm_falcon_cmdq_send(struct nvkm_falcon_cmdq *, struct nv_falcon_cmd *,
+                         nvkm_falcon_qmgr_callback, void *priv,
+                         unsigned long timeout_jiffies);
+
+struct nvkm_falcon_msgq;
+int nvkm_falcon_msgq_new(struct nvkm_falcon_qmgr *, const char *name,
+                        struct nvkm_falcon_msgq **);
+void nvkm_falcon_msgq_del(struct nvkm_falcon_msgq **);
+void nvkm_falcon_msgq_init(struct nvkm_falcon_msgq *,
+                          u32 index, u32 offset, u32 size);
+int nvkm_falcon_msgq_recv_initmsg(struct nvkm_falcon_msgq *, void *, u32 size);
+void nvkm_falcon_msgq_recv(struct nvkm_falcon_msgq *);
+#endif
diff -r c0025f09e79d -r 277cf37a975d sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/firmware.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/firmware.h       Sat Dec 18 20:23:00 2021 +0000
@@ -0,0 +1,57 @@
+/*     $NetBSD: firmware.h,v 1.1.1.1 2021/12/18 20:23:00 riastradh Exp $       */
+
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_FIRMWARE_H__
+#define __NVKM_FIRMWARE_H__
+#include <core/option.h>
+#include <core/subdev.h>
+
+int nvkm_firmware_get(const struct nvkm_subdev *, const char *fwname, int ver,
+                     const struct firmware **);
+void nvkm_firmware_put(const struct firmware *);
+
+int nvkm_firmware_load_blob(const struct nvkm_subdev *subdev, const char *path,
+                           const char *name, int ver, struct nvkm_blob *);
+int nvkm_firmware_load_name(const struct nvkm_subdev *subdev, const char *path,
+                           const char *name, int ver,
+                           const struct firmware **);
+
+#define nvkm_firmware_load(s,l,o,p...) ({                                      \
+       struct nvkm_subdev *_s = (s);                                          \
+       const char *_opts = (o);                                               \
+       char _option[32];                                                      \
+       typeof(l[0]) *_list = (l), *_next, *_fwif = NULL;                      \
+       int _ver, _fwv, _ret = 0;                                              \
+                                                                               \
+       snprintf(_option, sizeof(_option), "Nv%sFw", _opts);                   \
+       _ver = nvkm_longopt(_s->device->cfgopt, _option, -2);                  \
+       if (_ver >= -1) {                                                      \
+               for (_next = _list; !_fwif && _next->load; _next++) {          \
+                       if (_next->version == _ver)                            \
+                               _fwif = _next;                                 \
+               }                                                              \
+               _ret = _fwif ? 0 : -EINVAL;                                    \
+       }                                                                      \
+                                                                               \
+       if (_ret == 0) {                                                       \
+               snprintf(_option, sizeof(_option), "Nv%sFwVer", _opts);        \
+               _fwv = _fwif ? _fwif->version : -1;                            \
+               _ver = nvkm_longopt(_s->device->cfgopt, _option, _fwv);        \
+               for (_next = _fwif ? _fwif : _list; _next->load; _next++) {    \
+                       _fwv = (_ver >= 0) ? _ver : _next->version;            \
+                       _ret = _next->load(p, _fwv, _next);                    \
+                       if (_ret == 0 || _ver >= 0) {                          \
+                               _fwif = _next;                                 \
+                               break;                                         \
+                       }                                                      \
+               }                                                              \
+       }                                                                      \
+                                                                               \
+       if (_ret) {                                                            \
+               nvkm_error(_s, "failed to load firmware\n");                   \
+               _fwif = ERR_PTR(_ret);                                         \
+       }                                                                      \
+                                                                              \
+       _fwif;                                                                 \
+})
+#endif
diff -r c0025f09e79d -r 277cf37a975d sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/oclass.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/oclass.h Sat Dec 18 20:23:00 2021 +0000
@@ -0,0 +1,33 @@
+/*     $NetBSD: oclass.h,v 1.1.1.1 2021/12/18 20:23:00 riastradh Exp $ */
+
+#ifndef __NVKM_OCLASS_H__
+#define __NVKM_OCLASS_H__
+#include <core/os.h>
+#include <core/debug.h>
+struct nvkm_oclass;
+struct nvkm_object;
+
+struct nvkm_sclass {
+       int minver;
+       int maxver;
+       s32 oclass;
+       const struct nvkm_object_func *func;
+       int (*ctor)(const struct nvkm_oclass *, void *data, u32 size,
+                   struct nvkm_object **);
+};
+
+struct nvkm_oclass {
+       int (*ctor)(const struct nvkm_oclass *, void *data, u32 size,
+                   struct nvkm_object **);
+       struct nvkm_sclass base;
+       const void *priv;
+       const void *engn;
+       u32 handle;
+       u8  route;
+       u64 token;
+       u64 object;
+       struct nvkm_client *client;
+       struct nvkm_object *parent;
+       struct nvkm_engine *engine;
+};
+#endif
diff -r c0025f09e79d -r 277cf37a975d sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_firmware.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_firmware.c     Sat Dec 18 20:23:00 2021 +0000
@@ -0,0 +1,113 @@
+/*     $NetBSD: nouveau_nvkm_core_firmware.c,v 1.1.1.1 2021/12/18 20:23:00 riastradh Exp $     */
+
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_firmware.c,v 1.1.1.1 2021/12/18 20:23:00 riastradh Exp $");
+
+#include <core/device.h>
+#include <core/firmware.h>
+
+int
+nvkm_firmware_load_name(const struct nvkm_subdev *subdev, const char *base,
+                       const char *name, int ver, const struct firmware **pfw)
+{
+       char path[64];
+       int ret;
+
+       snprintf(path, sizeof(path), "%s%s", base, name);
+       ret = nvkm_firmware_get(subdev, path, ver, pfw);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+int
+nvkm_firmware_load_blob(const struct nvkm_subdev *subdev, const char *base,
+                       const char *name, int ver, struct nvkm_blob *blob)
+{
+       const struct firmware *fw;
+       int ret;
+
+       ret = nvkm_firmware_load_name(subdev, base, name, ver, &fw);
+       if (ret == 0) {
+               blob->data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+               blob->size = fw->size;
+               nvkm_firmware_put(fw);
+               if (!blob->data)
+                       return -ENOMEM;
+       }
+
+       return ret;
+}
+
+/**
+ * nvkm_firmware_get - load firmware from the official nvidia/chip/ directory
+ * @subdev     subdevice that will use that firmware
+ * @fwname     name of firmware file to load
+ * @fw         firmware structure to load to
+ *
+ * Use this function to load firmware files in the form nvidia/chip/fwname.bin.
+ * Firmware files released by NVIDIA will always follow this format.
+ */
+int
+nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname, int ver,
+                 const struct firmware **fw)
+{
+       struct nvkm_device *device = subdev->device;
+       char f[64];
+       char cname[16];
+       int i;
+
+       /* Convert device name to lowercase */
+       strncpy(cname, device->chip->name, sizeof(cname));
+       cname[sizeof(cname) - 1] = '\0';
+       i = strlen(cname);
+       while (i) {
+               --i;
+               cname[i] = tolower(cname[i]);
+       }
+
+       if (ver != 0)
+               snprintf(f, sizeof(f), "nvidia/%s/%s-%d.bin", cname, fwname, ver);
+       else
+               snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname);
+
+       if (!firmware_request_nowarn(fw, f, device->dev)) {
+               nvkm_debug(subdev, "firmware \"%s\" loaded - %zu byte(s)\n",
+                          f, (*fw)->size);
+               return 0;
+       }
+
+       nvkm_debug(subdev, "firmware \"%s\" unavailable\n", f);
+       return -ENOENT;
+}
+
+/**
+ * nvkm_firmware_put - release firmware loaded with nvkm_firmware_get
+ */
+void
+nvkm_firmware_put(const struct firmware *fw)
+{
+       release_firmware(fw);
+}



Home | Main Index | Thread Index | Old Index