diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/core/include/core')
19 files changed, 0 insertions, 1136 deletions
diff --git a/drivers/gpu/drm/nouveau/core/include/core/client.h b/drivers/gpu/drm/nouveau/core/include/core/client.h deleted file mode 100644 index b0ce9f6680b5..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/client.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __NOUVEAU_CLIENT_H__ -#define __NOUVEAU_CLIENT_H__ - -#include <core/namedb.h> - -struct nouveau_client { - struct nouveau_namedb base; - struct nouveau_handle *root; - struct nouveau_object *device; - char name[32]; - u32 debug; - struct nouveau_vm *vm; - bool super; - void *data; - - int (*ntfy)(const void *, u32, const void *, u32); - struct nvkm_client_notify *notify[16]; -}; - -static inline struct nouveau_client * -nv_client(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(obj, NV_CLIENT_CLASS))) - nv_assert("BAD CAST -> NvClient, %08x", nv_hclass(obj)); -#endif - return obj; -} - -static inline struct nouveau_client * -nouveau_client(void *obj) -{ - struct nouveau_object *client = nv_object(obj); - while (client && !(nv_iclass(client, NV_CLIENT_CLASS))) - client = client->parent; - return (void *)client; -} - -#define nouveau_client_create(n,c,oc,od,d) \ - nouveau_client_create_((n), (c), (oc), (od), sizeof(**d), (void **)d) - -int nouveau_client_create_(const char *name, u64 device, const char *cfg, - const char *dbg, int, void **); -#define nouveau_client_destroy(p) \ - nouveau_namedb_destroy(&(p)->base) - -int nouveau_client_init(struct nouveau_client *); -int nouveau_client_fini(struct nouveau_client *, bool suspend); -const char *nouveau_client_name(void *obj); - -int nvkm_client_notify_new(struct nouveau_object *, struct nvkm_event *, - void *data, u32 size); -int nvkm_client_notify_del(struct nouveau_client *, int index); -int nvkm_client_notify_get(struct nouveau_client *, int index); -int nvkm_client_notify_put(struct nouveau_client *, int index); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/debug.h b/drivers/gpu/drm/nouveau/core/include/core/debug.h deleted file mode 100644 index 8092e2e90323..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/debug.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __NOUVEAU_DEBUG_H__ -#define __NOUVEAU_DEBUG_H__ - -extern int nv_info_debug_level; - -#define NV_DBG_FATAL 0 -#define NV_DBG_ERROR 1 -#define NV_DBG_WARN 2 -#define NV_DBG_INFO nv_info_debug_level -#define NV_DBG_DEBUG 4 -#define NV_DBG_TRACE 5 -#define NV_DBG_PARANOIA 6 -#define NV_DBG_SPAM 7 - -#define NV_DBG_INFO_NORMAL 3 -#define NV_DBG_INFO_SILENT NV_DBG_DEBUG - -#define nv_debug_level(a) nv_info_debug_level = NV_DBG_INFO_##a - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/device.h b/drivers/gpu/drm/nouveau/core/include/core/device.h deleted file mode 100644 index 2ec2e50d3676..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/device.h +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef __NOUVEAU_DEVICE_H__ -#define __NOUVEAU_DEVICE_H__ - -#include <core/object.h> -#include <core/subdev.h> -#include <core/engine.h> -#include <core/event.h> - -enum nv_subdev_type { - NVDEV_ENGINE_DEVICE, - NVDEV_SUBDEV_VBIOS, - - /* All subdevs from DEVINIT to DEVINIT_LAST will be created before - * *any* of them are initialised. This subdev category is used - * for any subdevs that the VBIOS init table parsing may call out - * to during POST. - */ - NVDEV_SUBDEV_DEVINIT, - NVDEV_SUBDEV_IBUS, - NVDEV_SUBDEV_GPIO, - NVDEV_SUBDEV_I2C, - NVDEV_SUBDEV_DEVINIT_LAST = NVDEV_SUBDEV_I2C, - - /* This grouping of subdevs are initialised right after they've - * been created, and are allowed to assume any subdevs in the - * list above them exist and have been initialised. - */ - NVDEV_SUBDEV_FUSE, - NVDEV_SUBDEV_MXM, - NVDEV_SUBDEV_MC, - NVDEV_SUBDEV_BUS, - NVDEV_SUBDEV_TIMER, - NVDEV_SUBDEV_FB, - NVDEV_SUBDEV_LTC, - NVDEV_SUBDEV_INSTMEM, - NVDEV_SUBDEV_VM, - NVDEV_SUBDEV_BAR, - NVDEV_SUBDEV_PWR, - NVDEV_SUBDEV_VOLT, - NVDEV_SUBDEV_THERM, - NVDEV_SUBDEV_CLOCK, - - NVDEV_ENGINE_FIRST, - NVDEV_ENGINE_DMAOBJ = NVDEV_ENGINE_FIRST, - NVDEV_ENGINE_IFB, - NVDEV_ENGINE_FIFO, - NVDEV_ENGINE_SW, - NVDEV_ENGINE_GR, - NVDEV_ENGINE_MPEG, - NVDEV_ENGINE_ME, - NVDEV_ENGINE_VP, - NVDEV_ENGINE_CRYPT, - NVDEV_ENGINE_BSP, - NVDEV_ENGINE_PPP, - NVDEV_ENGINE_COPY0, - NVDEV_ENGINE_COPY1, - NVDEV_ENGINE_COPY2, - NVDEV_ENGINE_VIC, - NVDEV_ENGINE_VENC, - NVDEV_ENGINE_DISP, - NVDEV_ENGINE_PERFMON, - - NVDEV_SUBDEV_NR, -}; - -struct nouveau_device { - struct nouveau_engine base; - struct list_head head; - - struct pci_dev *pdev; - struct platform_device *platformdev; - u64 handle; - - struct nvkm_event event; - - const char *cfgopt; - const char *dbgopt; - const char *name; - const char *cname; - u64 disable_mask; - - enum { - NV_04 = 0x04, - NV_10 = 0x10, - NV_11 = 0x11, - NV_20 = 0x20, - NV_30 = 0x30, - NV_40 = 0x40, - NV_50 = 0x50, - NV_C0 = 0xc0, - NV_E0 = 0xe0, - GM100 = 0x110, - } card_type; - u32 chipset; - u8 chiprev; - u32 crystal; - - struct nouveau_oclass *oclass[NVDEV_SUBDEV_NR]; - struct nouveau_object *subdev[NVDEV_SUBDEV_NR]; - - struct { - struct notifier_block nb; - } acpi; -}; - -int nouveau_device_list(u64 *name, int size); - -static inline struct nouveau_device * -nv_device(void *obj) -{ - struct nouveau_object *object = nv_object(obj); - struct nouveau_object *device = object; - - if (device->engine) - device = device->engine; - if (device->parent) - device = device->parent; - -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(device, NV_SUBDEV_CLASS) || - (nv_hclass(device) & 0xff) != NVDEV_ENGINE_DEVICE)) { - nv_assert("BAD CAST -> NvDevice, 0x%08x 0x%08x", - nv_hclass(object), nv_hclass(device)); - } -#endif - - return (void *)device; -} - -static inline struct nouveau_subdev * -nouveau_subdev(void *obj, int sub) -{ - if (nv_device(obj)->subdev[sub]) - return nv_subdev(nv_device(obj)->subdev[sub]); - return NULL; -} - -static inline struct nouveau_engine * -nouveau_engine(void *obj, int sub) -{ - struct nouveau_subdev *subdev = nouveau_subdev(obj, sub); - if (subdev && nv_iclass(subdev, NV_ENGINE_CLASS)) - return nv_engine(subdev); - return NULL; -} - -static inline bool -nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub) -{ - struct nouveau_device *device = nv_device(object); - return device->pdev->device == dev && - device->pdev->subsystem_vendor == ven && - device->pdev->subsystem_device == sub; -} - -static inline bool -nv_device_is_pci(struct nouveau_device *device) -{ - return device->pdev != NULL; -} - -static inline bool -nv_device_is_cpu_coherent(struct nouveau_device *device) -{ - return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device)); -} - -static inline struct device * -nv_device_base(struct nouveau_device *device) -{ - return nv_device_is_pci(device) ? &device->pdev->dev : - &device->platformdev->dev; -} - -resource_size_t -nv_device_resource_start(struct nouveau_device *device, unsigned int bar); - -resource_size_t -nv_device_resource_len(struct nouveau_device *device, unsigned int bar); - -int -nv_device_get_irq(struct nouveau_device *device, bool stall); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/engctx.h b/drivers/gpu/drm/nouveau/core/include/core/engctx.h deleted file mode 100644 index 2fd48b564c7d..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/engctx.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __NOUVEAU_ENGCTX_H__ -#define __NOUVEAU_ENGCTX_H__ - -#include <core/object.h> -#include <core/gpuobj.h> - -#include <subdev/vm.h> - -#define NV_ENGCTX_(eng,var) (NV_ENGCTX_CLASS | ((var) << 8) | (eng)) -#define NV_ENGCTX(name,var) NV_ENGCTX_(NVDEV_ENGINE_##name, (var)) - -struct nouveau_engctx { - struct nouveau_gpuobj base; - struct nouveau_vma vma; - struct list_head head; - unsigned long save; - u64 addr; -}; - -static inline struct nouveau_engctx * -nv_engctx(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(obj, NV_ENGCTX_CLASS))) - nv_assert("BAD CAST -> NvEngCtx, %08x", nv_hclass(obj)); -#endif - return obj; -} - -#define nouveau_engctx_create(p,e,c,g,s,a,f,d) \ - nouveau_engctx_create_((p), (e), (c), (g), (s), (a), (f), \ - sizeof(**d), (void **)d) - -int nouveau_engctx_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, struct nouveau_object *, - u32 size, u32 align, u32 flags, - int length, void **data); -void nouveau_engctx_destroy(struct nouveau_engctx *); -int nouveau_engctx_init(struct nouveau_engctx *); -int nouveau_engctx_fini(struct nouveau_engctx *, bool suspend); - -int _nouveau_engctx_ctor(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, void *, u32, - struct nouveau_object **); -void _nouveau_engctx_dtor(struct nouveau_object *); -int _nouveau_engctx_init(struct nouveau_object *); -int _nouveau_engctx_fini(struct nouveau_object *, bool suspend); -#define _nouveau_engctx_rd32 _nouveau_gpuobj_rd32 -#define _nouveau_engctx_wr32 _nouveau_gpuobj_wr32 - -struct nouveau_object *nouveau_engctx_get(struct nouveau_engine *, u64 addr); -void nouveau_engctx_put(struct nouveau_object *); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/engine.h b/drivers/gpu/drm/nouveau/core/include/core/engine.h deleted file mode 100644 index 666d06de77ec..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/engine.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __NOUVEAU_ENGINE_H__ -#define __NOUVEAU_ENGINE_H__ - -#include <core/object.h> -#include <core/subdev.h> - -#define NV_ENGINE_(eng,var) (NV_ENGINE_CLASS | ((var) << 8) | (eng)) -#define NV_ENGINE(name,var) NV_ENGINE_(NVDEV_ENGINE_##name, (var)) - -struct nouveau_engine { - struct nouveau_subdev base; - struct nouveau_oclass *cclass; - struct nouveau_oclass *sclass; - - struct list_head contexts; - spinlock_t lock; - - void (*tile_prog)(struct nouveau_engine *, int region); - int (*tlb_flush)(struct nouveau_engine *); -}; - -static inline struct nouveau_engine * -nv_engine(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(obj, NV_ENGINE_CLASS))) - nv_assert("BAD CAST -> NvEngine, %08x", nv_hclass(obj)); -#endif - return obj; -} - -static inline int -nv_engidx(struct nouveau_object *object) -{ - return nv_subidx(object); -} - -#define nouveau_engine_create(p,e,c,d,i,f,r) \ - nouveau_engine_create_((p), (e), (c), (d), (i), (f), \ - sizeof(**r),(void **)r) - -#define nouveau_engine_destroy(p) \ - nouveau_subdev_destroy(&(p)->base) -#define nouveau_engine_init(p) \ - nouveau_subdev_init(&(p)->base) -#define nouveau_engine_fini(p,s) \ - nouveau_subdev_fini(&(p)->base, (s)) - -int nouveau_engine_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, bool, const char *, - const char *, int, void **); - -#define _nouveau_engine_dtor _nouveau_subdev_dtor -#define _nouveau_engine_init _nouveau_subdev_init -#define _nouveau_engine_fini _nouveau_subdev_fini - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/enum.h b/drivers/gpu/drm/nouveau/core/include/core/enum.h deleted file mode 100644 index 4fc62bb8c1f0..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/enum.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __NOUVEAU_ENUM_H__ -#define __NOUVEAU_ENUM_H__ - -struct nouveau_enum { - u32 value; - const char *name; - const void *data; - u32 data2; -}; - -const struct nouveau_enum * -nouveau_enum_find(const struct nouveau_enum *, u32 value); - -const struct nouveau_enum * -nouveau_enum_print(const struct nouveau_enum *en, u32 value); - -struct nouveau_bitfield { - u32 mask; - const char *name; -}; - -void nouveau_bitfield_print(const struct nouveau_bitfield *, u32 value); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/event.h b/drivers/gpu/drm/nouveau/core/include/core/event.h deleted file mode 100644 index 92876528972f..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/event.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __NVKM_EVENT_H__ -#define __NVKM_EVENT_H__ - -#include <core/notify.h> - -struct nvkm_event_func { - int (*ctor)(struct nouveau_object *, void *data, u32 size, - struct nvkm_notify *); - void (*send)(void *data, u32 size, struct nvkm_notify *); - void (*init)(struct nvkm_event *, int type, int index); - void (*fini)(struct nvkm_event *, int type, int index); -}; - -struct nvkm_event { - const struct nvkm_event_func *func; - - int types_nr; - int index_nr; - - spinlock_t refs_lock; - spinlock_t list_lock; - struct list_head list; - int *refs; -}; - -int nvkm_event_init(const struct nvkm_event_func *func, - int types_nr, int index_nr, - struct nvkm_event *); -void nvkm_event_fini(struct nvkm_event *); -void nvkm_event_get(struct nvkm_event *, u32 types, int index); -void nvkm_event_put(struct nvkm_event *, u32 types, int index); -void nvkm_event_send(struct nvkm_event *, u32 types, int index, - void *data, u32 size); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h deleted file mode 100644 index b3b9ce4e9d38..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __NOUVEAU_GPUOBJ_H__ -#define __NOUVEAU_GPUOBJ_H__ - -#include <core/object.h> -#include <core/device.h> -#include <core/parent.h> -#include <core/mm.h> - -struct nouveau_vma; -struct nouveau_vm; - -#define NVOBJ_FLAG_ZERO_ALLOC 0x00000001 -#define NVOBJ_FLAG_ZERO_FREE 0x00000002 -#define NVOBJ_FLAG_HEAP 0x00000004 - -struct nouveau_gpuobj { - struct nouveau_object base; - struct nouveau_object *parent; - struct nouveau_mm_node *node; - struct nouveau_mm heap; - - u32 flags; - u64 addr; - u32 size; -}; - -static inline struct nouveau_gpuobj * -nv_gpuobj(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(obj, NV_GPUOBJ_CLASS))) - nv_assert("BAD CAST -> NvGpuObj, %08x", nv_hclass(obj)); -#endif - return obj; -} - -#define nouveau_gpuobj_create(p,e,c,v,g,s,a,f,d) \ - nouveau_gpuobj_create_((p), (e), (c), (v), (g), (s), (a), (f), \ - sizeof(**d), (void **)d) -#define nouveau_gpuobj_init(p) nouveau_object_init(&(p)->base) -#define nouveau_gpuobj_fini(p,s) nouveau_object_fini(&(p)->base, (s)) -int nouveau_gpuobj_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, u32 pclass, - struct nouveau_object *, u32 size, u32 align, - u32 flags, int length, void **); -void nouveau_gpuobj_destroy(struct nouveau_gpuobj *); - -int nouveau_gpuobj_new(struct nouveau_object *, struct nouveau_object *, - u32 size, u32 align, u32 flags, - struct nouveau_gpuobj **); -int nouveau_gpuobj_dup(struct nouveau_object *, struct nouveau_gpuobj *, - struct nouveau_gpuobj **); - -int nouveau_gpuobj_map(struct nouveau_gpuobj *, u32 acc, struct nouveau_vma *); -int nouveau_gpuobj_map_vm(struct nouveau_gpuobj *, struct nouveau_vm *, - u32 access, struct nouveau_vma *); -void nouveau_gpuobj_unmap(struct nouveau_vma *); - -static inline void -nouveau_gpuobj_ref(struct nouveau_gpuobj *obj, struct nouveau_gpuobj **ref) -{ - nouveau_object_ref(&obj->base, (struct nouveau_object **)ref); -} - -void _nouveau_gpuobj_dtor(struct nouveau_object *); -int _nouveau_gpuobj_init(struct nouveau_object *); -int _nouveau_gpuobj_fini(struct nouveau_object *, bool); -u32 _nouveau_gpuobj_rd32(struct nouveau_object *, u64); -void _nouveau_gpuobj_wr32(struct nouveau_object *, u64, u32); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/handle.h b/drivers/gpu/drm/nouveau/core/include/core/handle.h deleted file mode 100644 index d22a59138a9b..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/handle.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __NOUVEAU_HANDLE_H__ -#define __NOUVEAU_HANDLE_H__ - -struct nouveau_handle { - struct nouveau_namedb *namedb; - struct list_head node; - - struct list_head head; - struct list_head tree; - u32 name; - u32 priv; - - u8 route; - u64 token; - - struct nouveau_handle *parent; - struct nouveau_object *object; -}; - -int nouveau_handle_create(struct nouveau_object *, u32 parent, u32 handle, - struct nouveau_object *, struct nouveau_handle **); -void nouveau_handle_destroy(struct nouveau_handle *); -int nouveau_handle_init(struct nouveau_handle *); -int nouveau_handle_fini(struct nouveau_handle *, bool suspend); - -struct nouveau_object * -nouveau_handle_ref(struct nouveau_object *, u32 name); - -struct nouveau_handle *nouveau_handle_get_class(struct nouveau_object *, u16); -struct nouveau_handle *nouveau_handle_get_vinst(struct nouveau_object *, u64); -struct nouveau_handle *nouveau_handle_get_cinst(struct nouveau_object *, u32); -void nouveau_handle_put(struct nouveau_handle *); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/ioctl.h b/drivers/gpu/drm/nouveau/core/include/core/ioctl.h deleted file mode 100644 index ac7935c2474e..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/ioctl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __NVKM_IOCTL_H__ -#define __NVKM_IOCTL_H__ - -int nvkm_ioctl(struct nouveau_client *, bool, void *, u32, void **); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/mm.h b/drivers/gpu/drm/nouveau/core/include/core/mm.h deleted file mode 100644 index bfe6931544fe..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/mm.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __NOUVEAU_MM_H__ -#define __NOUVEAU_MM_H__ - -struct nouveau_mm_node { - struct list_head nl_entry; - struct list_head fl_entry; - struct list_head rl_entry; - -#define NVKM_MM_HEAP_ANY 0x00 - u8 heap; -#define NVKM_MM_TYPE_NONE 0x00 -#define NVKM_MM_TYPE_HOLE 0xff - u8 type; - u32 offset; - u32 length; -}; - -struct nouveau_mm { - struct list_head nodes; - struct list_head free; - - u32 block_size; - int heap_nodes; -}; - -static inline bool -nouveau_mm_initialised(struct nouveau_mm *mm) -{ - return mm->block_size != 0; -} - -int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block); -int nouveau_mm_fini(struct nouveau_mm *); -int nouveau_mm_head(struct nouveau_mm *, u8 heap, u8 type, u32 size_max, - u32 size_min, u32 align, struct nouveau_mm_node **); -int nouveau_mm_tail(struct nouveau_mm *, u8 heap, u8 type, u32 size_max, - u32 size_min, u32 align, struct nouveau_mm_node **); -void nouveau_mm_free(struct nouveau_mm *, struct nouveau_mm_node **); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/namedb.h b/drivers/gpu/drm/nouveau/core/include/core/namedb.h deleted file mode 100644 index f5b5fd8e1fc9..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/namedb.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __NOUVEAU_NAMEDB_H__ -#define __NOUVEAU_NAMEDB_H__ - -#include <core/parent.h> - -struct nouveau_handle; - -struct nouveau_namedb { - struct nouveau_parent base; - rwlock_t lock; - struct list_head list; -}; - -static inline struct nouveau_namedb * -nv_namedb(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(obj, NV_NAMEDB_CLASS))) - nv_assert("BAD CAST -> NvNameDB, %08x", nv_hclass(obj)); -#endif - return obj; -} - -#define nouveau_namedb_create(p,e,c,v,s,m,d) \ - nouveau_namedb_create_((p), (e), (c), (v), (s), (m), \ - sizeof(**d), (void **)d) -#define nouveau_namedb_init(p) \ - nouveau_parent_init(&(p)->base) -#define nouveau_namedb_fini(p,s) \ - nouveau_parent_fini(&(p)->base, (s)) -#define nouveau_namedb_destroy(p) \ - nouveau_parent_destroy(&(p)->base) - -int nouveau_namedb_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, u32 pclass, - struct nouveau_oclass *, u64 engcls, - int size, void **); - -int _nouveau_namedb_ctor(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, void *, u32, - struct nouveau_object **); -#define _nouveau_namedb_dtor _nouveau_parent_dtor -#define _nouveau_namedb_init _nouveau_parent_init -#define _nouveau_namedb_fini _nouveau_parent_fini - -int nouveau_namedb_insert(struct nouveau_namedb *, u32 name, - struct nouveau_object *, struct nouveau_handle *); -void nouveau_namedb_remove(struct nouveau_handle *); - -struct nouveau_handle *nouveau_namedb_get(struct nouveau_namedb *, u32); -struct nouveau_handle *nouveau_namedb_get_class(struct nouveau_namedb *, u16); -struct nouveau_handle *nouveau_namedb_get_vinst(struct nouveau_namedb *, u64); -struct nouveau_handle *nouveau_namedb_get_cinst(struct nouveau_namedb *, u32); -void nouveau_namedb_put(struct nouveau_handle *); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/notify.h b/drivers/gpu/drm/nouveau/core/include/core/notify.h deleted file mode 100644 index a7c3c5f578cc..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/notify.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __NVKM_NOTIFY_H__ -#define __NVKM_NOTIFY_H__ - -struct nvkm_notify { - struct nvkm_event *event; - struct list_head head; -#define NVKM_NOTIFY_USER 0 -#define NVKM_NOTIFY_WORK 1 - unsigned long flags; - int block; -#define NVKM_NOTIFY_DROP 0 -#define NVKM_NOTIFY_KEEP 1 - int (*func)(struct nvkm_notify *); - - /* set by nvkm_event ctor */ - u32 types; - int index; - u32 size; - - struct work_struct work; - /* this is const for a *very* good reason - the data might be on the - * stack from an irq handler. if you're not core/notify.c then you - * should probably think twice before casting it away... - */ - const void *data; -}; - -int nvkm_notify_init(struct nouveau_object *, struct nvkm_event *, - int (*func)(struct nvkm_notify *), bool work, - void *data, u32 size, u32 reply, - struct nvkm_notify *); -void nvkm_notify_fini(struct nvkm_notify *); -void nvkm_notify_get(struct nvkm_notify *); -void nvkm_notify_put(struct nvkm_notify *); -void nvkm_notify_send(struct nvkm_notify *, void *data, u32 size); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/object.h b/drivers/gpu/drm/nouveau/core/include/core/object.h deleted file mode 100644 index 2e2afa502c99..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/object.h +++ /dev/null @@ -1,206 +0,0 @@ -#ifndef __NOUVEAU_OBJECT_H__ -#define __NOUVEAU_OBJECT_H__ - -#include <core/os.h> -#include <core/printk.h> - -#define NV_PARENT_CLASS 0x80000000 -#define NV_NAMEDB_CLASS 0x40000000 -#define NV_CLIENT_CLASS 0x20000000 -#define NV_SUBDEV_CLASS 0x10000000 -#define NV_ENGINE_CLASS 0x08000000 -#define NV_MEMOBJ_CLASS 0x04000000 -#define NV_GPUOBJ_CLASS 0x02000000 -#define NV_ENGCTX_CLASS 0x01000000 -#define NV_OBJECT_CLASS 0x0000ffff - -struct nouveau_object { - struct nouveau_oclass *oclass; - struct nouveau_object *parent; - struct nouveau_object *engine; - atomic_t refcount; - atomic_t usecount; -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA -#define NOUVEAU_OBJECT_MAGIC 0x75ef0bad - struct list_head list; - u32 _magic; -#endif -}; - -static inline struct nouveau_object * -nv_object(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (likely(obj)) { - struct nouveau_object *object = obj; - if (unlikely(object->_magic != NOUVEAU_OBJECT_MAGIC)) - nv_assert("BAD CAST -> NvObject, invalid magic"); - } -#endif - return obj; -} - -#define nouveau_object_create(p,e,c,s,d) \ - nouveau_object_create_((p), (e), (c), (s), sizeof(**d), (void **)d) -int nouveau_object_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, u32, int size, void **); -void nouveau_object_destroy(struct nouveau_object *); -int nouveau_object_init(struct nouveau_object *); -int nouveau_object_fini(struct nouveau_object *, bool suspend); - -int _nouveau_object_ctor(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, void *, u32, - struct nouveau_object **); - -extern struct nouveau_ofuncs nouveau_object_ofuncs; - -/* Don't allocate dynamically, because lockdep needs lock_class_keys to be in - * ".data". */ -struct nouveau_oclass { - u32 handle; - struct nouveau_ofuncs * const ofuncs; - struct nouveau_omthds * const omthds; - struct lock_class_key lock_class_key; -}; - -#define nv_oclass(o) nv_object(o)->oclass -#define nv_hclass(o) nv_oclass(o)->handle -#define nv_iclass(o,i) (nv_hclass(o) & (i)) -#define nv_mclass(o) nv_iclass(o, NV_OBJECT_CLASS) - -static inline struct nouveau_object * -nv_pclass(struct nouveau_object *parent, u32 oclass) -{ - while (parent && !nv_iclass(parent, oclass)) - parent = parent->parent; - return parent; -} - -struct nouveau_omthds { - u32 start; - u32 limit; - int (*call)(struct nouveau_object *, u32, void *, u32); -}; - -struct nvkm_event; -struct nouveau_ofuncs { - int (*ctor)(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, void *data, u32 size, - struct nouveau_object **); - void (*dtor)(struct nouveau_object *); - int (*init)(struct nouveau_object *); - int (*fini)(struct nouveau_object *, bool suspend); - int (*mthd)(struct nouveau_object *, u32, void *, u32); - int (*ntfy)(struct nouveau_object *, u32, struct nvkm_event **); - int (* map)(struct nouveau_object *, u64 *, u32 *); - u8 (*rd08)(struct nouveau_object *, u64 offset); - u16 (*rd16)(struct nouveau_object *, u64 offset); - u32 (*rd32)(struct nouveau_object *, u64 offset); - void (*wr08)(struct nouveau_object *, u64 offset, u8 data); - void (*wr16)(struct nouveau_object *, u64 offset, u16 data); - void (*wr32)(struct nouveau_object *, u64 offset, u32 data); -}; - -static inline struct nouveau_ofuncs * -nv_ofuncs(void *obj) -{ - return nv_oclass(obj)->ofuncs; -} - -int nouveau_object_ctor(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, void *, u32, - struct nouveau_object **); -void nouveau_object_ref(struct nouveau_object *, struct nouveau_object **); -int nouveau_object_inc(struct nouveau_object *); -int nouveau_object_dec(struct nouveau_object *, bool suspend); - -void nouveau_object_debug(void); - -static inline int -nv_exec(void *obj, u32 mthd, void *data, u32 size) -{ - struct nouveau_omthds *method = nv_oclass(obj)->omthds; - - while (method && method->call) { - if (mthd >= method->start && mthd <= method->limit) - return method->call(obj, mthd, data, size); - method++; - } - - return -EINVAL; -} - -static inline int -nv_call(void *obj, u32 mthd, u32 data) -{ - return nv_exec(obj, mthd, &data, sizeof(data)); -} - -static inline u8 -nv_ro08(void *obj, u64 addr) -{ - u8 data = nv_ofuncs(obj)->rd08(obj, addr); - nv_spam(obj, "nv_ro08 0x%08llx 0x%02x\n", addr, data); - return data; -} - -static inline u16 -nv_ro16(void *obj, u64 addr) -{ - u16 data = nv_ofuncs(obj)->rd16(obj, addr); - nv_spam(obj, "nv_ro16 0x%08llx 0x%04x\n", addr, data); - return data; -} - -static inline u32 -nv_ro32(void *obj, u64 addr) -{ - u32 data = nv_ofuncs(obj)->rd32(obj, addr); - nv_spam(obj, "nv_ro32 0x%08llx 0x%08x\n", addr, data); - return data; -} - -static inline void -nv_wo08(void *obj, u64 addr, u8 data) -{ - nv_spam(obj, "nv_wo08 0x%08llx 0x%02x\n", addr, data); - nv_ofuncs(obj)->wr08(obj, addr, data); -} - -static inline void -nv_wo16(void *obj, u64 addr, u16 data) -{ - nv_spam(obj, "nv_wo16 0x%08llx 0x%04x\n", addr, data); - nv_ofuncs(obj)->wr16(obj, addr, data); -} - -static inline void -nv_wo32(void *obj, u64 addr, u32 data) -{ - nv_spam(obj, "nv_wo32 0x%08llx 0x%08x\n", addr, data); - nv_ofuncs(obj)->wr32(obj, addr, data); -} - -static inline u32 -nv_mo32(void *obj, u64 addr, u32 mask, u32 data) -{ - u32 temp = nv_ro32(obj, addr); - nv_wo32(obj, addr, (temp & ~mask) | data); - return temp; -} - -static inline int -nv_memcmp(void *obj, u32 addr, const char *str, u32 len) -{ - unsigned char c1, c2; - - while (len--) { - c1 = nv_ro08(obj, addr++); - c2 = *(str++); - if (c1 != c2) - return c1 - c2; - } - return 0; -} - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/option.h b/drivers/gpu/drm/nouveau/core/include/core/option.h deleted file mode 100644 index ed055847887e..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/option.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __NOUVEAU_OPTION_H__ -#define __NOUVEAU_OPTION_H__ - -#include <core/os.h> - -const char *nouveau_stropt(const char *optstr, const char *opt, int *len); -bool nouveau_boolopt(const char *optstr, const char *opt, bool value); - -int nouveau_dbgopt(const char *optstr, const char *sub); - -/* compares unterminated string 'str' with zero-terminated string 'cmp' */ -static inline int -strncasecmpz(const char *str, const char *cmp, size_t len) -{ - if (strlen(cmp) != len) - return len; - return strncasecmp(str, cmp, len); -} - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/parent.h b/drivers/gpu/drm/nouveau/core/include/core/parent.h deleted file mode 100644 index 12da418ec70a..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/parent.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __NOUVEAU_PARENT_H__ -#define __NOUVEAU_PARENT_H__ - -#include <core/device.h> -#include <core/object.h> - -struct nouveau_sclass { - struct nouveau_sclass *sclass; - struct nouveau_engine *engine; - struct nouveau_oclass *oclass; -}; - -struct nouveau_parent { - struct nouveau_object base; - - struct nouveau_sclass *sclass; - u64 engine; - - int (*context_attach)(struct nouveau_object *, - struct nouveau_object *); - int (*context_detach)(struct nouveau_object *, bool suspend, - struct nouveau_object *); - - int (*object_attach)(struct nouveau_object *parent, - struct nouveau_object *object, u32 name); - void (*object_detach)(struct nouveau_object *parent, int cookie); -}; - -static inline struct nouveau_parent * -nv_parent(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!(nv_iclass(obj, NV_PARENT_CLASS)))) - nv_assert("BAD CAST -> NvParent, %08x", nv_hclass(obj)); -#endif - return obj; -} - -#define nouveau_parent_create(p,e,c,v,s,m,d) \ - nouveau_parent_create_((p), (e), (c), (v), (s), (m), \ - sizeof(**d), (void **)d) -#define nouveau_parent_init(p) \ - nouveau_object_init(&(p)->base) -#define nouveau_parent_fini(p,s) \ - nouveau_object_fini(&(p)->base, (s)) - -int nouveau_parent_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, u32 pclass, - struct nouveau_oclass *, u64 engcls, - int size, void **); -void nouveau_parent_destroy(struct nouveau_parent *); - -void _nouveau_parent_dtor(struct nouveau_object *); -#define _nouveau_parent_init nouveau_object_init -#define _nouveau_parent_fini nouveau_object_fini - -int nouveau_parent_sclass(struct nouveau_object *, u16 handle, - struct nouveau_object **pengine, - struct nouveau_oclass **poclass); -int nouveau_parent_lclass(struct nouveau_object *, u32 *, int); - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/printk.h b/drivers/gpu/drm/nouveau/core/include/core/printk.h deleted file mode 100644 index 451b6ed20b7e..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/printk.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __NOUVEAU_PRINTK_H__ -#define __NOUVEAU_PRINTK_H__ - -#include <core/os.h> -#include <core/debug.h> - -struct nouveau_object; - -void __printf(3, 4) -nv_printk_(struct nouveau_object *, int, const char *, ...); - -#define nv_printk(o,l,f,a...) do { \ - if (NV_DBG_##l <= CONFIG_NOUVEAU_DEBUG) \ - nv_printk_(nv_object(o), NV_DBG_##l, f, ##a); \ -} while(0) - -#define nv_fatal(o,f,a...) nv_printk((o), FATAL, f, ##a) -#define nv_error(o,f,a...) nv_printk((o), ERROR, f, ##a) -#define nv_warn(o,f,a...) nv_printk((o), WARN, f, ##a) -#define nv_info(o,f,a...) nv_printk((o), INFO, f, ##a) -#define nv_debug(o,f,a...) nv_printk((o), DEBUG, f, ##a) -#define nv_trace(o,f,a...) nv_printk((o), TRACE, f, ##a) -#define nv_spam(o,f,a...) nv_printk((o), SPAM, f, ##a) -#define nv_ioctl(o,f,a...) nv_trace(nouveau_client(o), "ioctl: "f, ##a) - -#define nv_assert(f,a...) do { \ - if (NV_DBG_FATAL <= CONFIG_NOUVEAU_DEBUG) \ - nv_printk_(NULL, NV_DBG_FATAL, f "\n", ##a); \ - BUG_ON(1); \ -} while(0) - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/ramht.h b/drivers/gpu/drm/nouveau/core/include/core/ramht.h deleted file mode 100644 index 47e4cacbca37..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/ramht.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __NOUVEAU_RAMHT_H__ -#define __NOUVEAU_RAMHT_H__ - -#include <core/gpuobj.h> - -struct nouveau_ramht { - struct nouveau_gpuobj base; - int bits; -}; - -int nouveau_ramht_insert(struct nouveau_ramht *, int chid, - u32 handle, u32 context); -void nouveau_ramht_remove(struct nouveau_ramht *, int cookie); -int nouveau_ramht_new(struct nouveau_object *, struct nouveau_object *, - u32 size, u32 align, struct nouveau_ramht **); - -static inline void -nouveau_ramht_ref(struct nouveau_ramht *obj, struct nouveau_ramht **ref) -{ - nouveau_gpuobj_ref(&obj->base, (struct nouveau_gpuobj **)ref); -} - -#endif diff --git a/drivers/gpu/drm/nouveau/core/include/core/subdev.h b/drivers/gpu/drm/nouveau/core/include/core/subdev.h deleted file mode 100644 index e9632e931616..000000000000 --- a/drivers/gpu/drm/nouveau/core/include/core/subdev.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef __NOUVEAU_SUBDEV_H__ -#define __NOUVEAU_SUBDEV_H__ - -#include <core/object.h> - -#define NV_SUBDEV_(sub,var) (NV_SUBDEV_CLASS | ((var) << 8) | (sub)) -#define NV_SUBDEV(name,var) NV_SUBDEV_(NVDEV_SUBDEV_##name, (var)) - -struct nouveau_subdev { - struct nouveau_object base; - struct mutex mutex; - const char *name; - void __iomem *mmio; - u32 debug; - u32 unit; - - void (*intr)(struct nouveau_subdev *); -}; - -static inline struct nouveau_subdev * -nv_subdev(void *obj) -{ -#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA - if (unlikely(!nv_iclass(obj, NV_SUBDEV_CLASS))) - nv_assert("BAD CAST -> NvSubDev, %08x", nv_hclass(obj)); -#endif - return obj; -} - -static inline int -nv_subidx(struct nouveau_object *object) -{ - return nv_hclass(nv_subdev(object)) & 0xff; -} - -#define nouveau_subdev_create(p,e,o,v,s,f,d) \ - nouveau_subdev_create_((p), (e), (o), (v), (s), (f), \ - sizeof(**d),(void **)d) - -int nouveau_subdev_create_(struct nouveau_object *, struct nouveau_object *, - struct nouveau_oclass *, u32 pclass, - const char *sname, const char *fname, - int size, void **); -void nouveau_subdev_destroy(struct nouveau_subdev *); -int nouveau_subdev_init(struct nouveau_subdev *); -int nouveau_subdev_fini(struct nouveau_subdev *, bool suspend); -void nouveau_subdev_reset(struct nouveau_object *); - -void _nouveau_subdev_dtor(struct nouveau_object *); -int _nouveau_subdev_init(struct nouveau_object *); -int _nouveau_subdev_fini(struct nouveau_object *, bool suspend); - -#define s_printk(s,l,f,a...) do { \ - if ((s)->debug >= OS_DBG_##l) { \ - nv_printk((s)->base.parent, (s)->name, l, f, ##a); \ - } \ -} while(0) - -static inline u8 -nv_rd08(void *obj, u32 addr) -{ - struct nouveau_subdev *subdev = nv_subdev(obj); - u8 data = ioread8(subdev->mmio + addr); - nv_spam(subdev, "nv_rd08 0x%06x 0x%02x\n", addr, data); - return data; -} - -static inline u16 -nv_rd16(void *obj, u32 addr) -{ - struct nouveau_subdev *subdev = nv_subdev(obj); - u16 data = ioread16_native(subdev->mmio + addr); - nv_spam(subdev, "nv_rd16 0x%06x 0x%04x\n", addr, data); - return data; -} - -static inline u32 -nv_rd32(void *obj, u32 addr) -{ - struct nouveau_subdev *subdev = nv_subdev(obj); - u32 data = ioread32_native(subdev->mmio + addr); - nv_spam(subdev, "nv_rd32 0x%06x 0x%08x\n", addr, data); - return data; -} - -static inline void -nv_wr08(void *obj, u32 addr, u8 data) -{ - struct nouveau_subdev *subdev = nv_subdev(obj); - nv_spam(subdev, "nv_wr08 0x%06x 0x%02x\n", addr, data); - iowrite8(data, subdev->mmio + addr); -} - -static inline void -nv_wr16(void *obj, u32 addr, u16 data) -{ - struct nouveau_subdev *subdev = nv_subdev(obj); - nv_spam(subdev, "nv_wr16 0x%06x 0x%04x\n", addr, data); - iowrite16_native(data, subdev->mmio + addr); -} - -static inline void -nv_wr32(void *obj, u32 addr, u32 data) -{ - struct nouveau_subdev *subdev = nv_subdev(obj); - nv_spam(subdev, "nv_wr32 0x%06x 0x%08x\n", addr, data); - iowrite32_native(data, subdev->mmio + addr); -} - -static inline u32 -nv_mask(void *obj, u32 addr, u32 mask, u32 data) -{ - u32 temp = nv_rd32(obj, addr); - nv_wr32(obj, addr, (temp & ~mask) | data); - return temp; -} - -#endif |