cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

subdev.h (2551B)


      1/* SPDX-License-Identifier: MIT */
      2#ifndef __NVKM_SUBDEV_H__
      3#define __NVKM_SUBDEV_H__
      4#include <core/device.h>
      5
      6enum nvkm_subdev_type {
      7#define NVKM_LAYOUT_ONCE(t,s,p,...) t,
      8#define NVKM_LAYOUT_INST NVKM_LAYOUT_ONCE
      9#include <core/layout.h>
     10#undef NVKM_LAYOUT_INST
     11#undef NVKM_LAYOUT_ONCE
     12	NVKM_SUBDEV_NR
     13};
     14
     15struct nvkm_subdev {
     16	const struct nvkm_subdev_func *func;
     17	struct nvkm_device *device;
     18	enum nvkm_subdev_type type;
     19	int inst;
     20	char name[16];
     21	u32 debug;
     22	struct list_head head;
     23
     24	void **pself;
     25	bool oneinit;
     26};
     27
     28struct nvkm_subdev_func {
     29	void *(*dtor)(struct nvkm_subdev *);
     30	int (*preinit)(struct nvkm_subdev *);
     31	int (*oneinit)(struct nvkm_subdev *);
     32	int (*info)(struct nvkm_subdev *, u64 mthd, u64 *data);
     33	int (*init)(struct nvkm_subdev *);
     34	int (*fini)(struct nvkm_subdev *, bool suspend);
     35	void (*intr)(struct nvkm_subdev *);
     36};
     37
     38extern const char *nvkm_subdev_type[NVKM_SUBDEV_NR];
     39int nvkm_subdev_new_(const struct nvkm_subdev_func *, struct nvkm_device *, enum nvkm_subdev_type,
     40		     int inst, struct nvkm_subdev **);
     41void nvkm_subdev_ctor(const struct nvkm_subdev_func *, struct nvkm_device *,
     42		      enum nvkm_subdev_type, int inst, struct nvkm_subdev *);
     43void nvkm_subdev_disable(struct nvkm_device *, enum nvkm_subdev_type, int inst);
     44void nvkm_subdev_del(struct nvkm_subdev **);
     45int  nvkm_subdev_preinit(struct nvkm_subdev *);
     46int  nvkm_subdev_init(struct nvkm_subdev *);
     47int  nvkm_subdev_fini(struct nvkm_subdev *, bool suspend);
     48int  nvkm_subdev_info(struct nvkm_subdev *, u64, u64 *);
     49void nvkm_subdev_intr(struct nvkm_subdev *);
     50
     51/* subdev logging */
     52#define nvkm_printk_(s,l,p,f,a...) do {                                        \
     53	const struct nvkm_subdev *_subdev = (s);                               \
     54	if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l))              \
     55		dev_##p(_subdev->device->dev, "%s: "f, _subdev->name, ##a);    \
     56} while(0)
     57#define nvkm_printk(s,l,p,f,a...) nvkm_printk_((s), NV_DBG_##l, p, f, ##a)
     58#define nvkm_fatal(s,f,a...) nvkm_printk((s), FATAL,   crit, f, ##a)
     59#define nvkm_error(s,f,a...) nvkm_printk((s), ERROR,    err, f, ##a)
     60#define nvkm_warn(s,f,a...)  nvkm_printk((s),  WARN, notice, f, ##a)
     61#define nvkm_info(s,f,a...)  nvkm_printk((s),  INFO,   info, f, ##a)
     62#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG,   info, f, ##a)
     63#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE,   info, f, ##a)
     64#define nvkm_spam(s,f,a...)  nvkm_printk((s),  SPAM,    dbg, f, ##a)
     65
     66#define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a)
     67#endif