Commit 5025407b authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/core: namespace + nvidia gpu names (no binary change)

The namespace of NVKM is being changed to nvkm_ instead of nouveau_,
which will be used for the DRM part of the driver.  This is being
done in order to make it very clear as to what part of the driver a
given symbol belongs to, and as a minor step towards splitting the
DRM driver out to be able to stand on its own (for virt).

Because there's already a large amount of churn here anyway, this is
as good a time as any to also switch to NVIDIA's device and chipset
naming to ease collaboration with them.

A comparison of objdump disassemblies proves no code changes.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 989aa5b7
#ifndef __NOUVEAU_CLIENT_H__ #ifndef __NVKM_CLIENT_H__
#define __NOUVEAU_CLIENT_H__ #define __NVKM_CLIENT_H__
#include <core/namedb.h> #include <core/namedb.h>
struct nouveau_client { struct nvkm_client {
struct nouveau_namedb namedb; struct nvkm_namedb namedb;
struct nouveau_handle *root; struct nvkm_handle *root;
struct nouveau_object *device; struct nvkm_object *device;
char name[32]; char name[32];
u32 debug; u32 debug;
struct nouveau_vm *vm; struct nvkm_vm *vm;
bool super; bool super;
void *data; void *data;
...@@ -17,7 +16,7 @@ struct nouveau_client { ...@@ -17,7 +16,7 @@ struct nouveau_client {
struct nvkm_client_notify *notify[16]; struct nvkm_client_notify *notify[16];
}; };
static inline struct nouveau_client * static inline struct nvkm_client *
nv_client(void *obj) nv_client(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -27,31 +26,30 @@ nv_client(void *obj) ...@@ -27,31 +26,30 @@ nv_client(void *obj)
return obj; return obj;
} }
static inline struct nouveau_client * static inline struct nvkm_client *
nouveau_client(void *obj) nvkm_client(void *obj)
{ {
struct nouveau_object *client = nv_object(obj); struct nvkm_object *client = nv_object(obj);
while (client && !(nv_iclass(client, NV_CLIENT_CLASS))) while (client && !(nv_iclass(client, NV_CLIENT_CLASS)))
client = client->parent; client = client->parent;
return (void *)client; return (void *)client;
} }
#define nouveau_client_create(n,c,oc,od,d) \ #define nvkm_client_create(n,c,oc,od,d) \
nouveau_client_create_((n), (c), (oc), (od), sizeof(**d), (void **)d) nvkm_client_create_((n), (c), (oc), (od), sizeof(**d), (void **)d)
int nouveau_client_create_(const char *name, u64 device, const char *cfg, int nvkm_client_create_(const char *name, u64 device, const char *cfg,
const char *dbg, int, void **); const char *dbg, int, void **);
#define nouveau_client_destroy(p) \ #define nvkm_client_destroy(p) \
nouveau_namedb_destroy(&(p)->base) nvkm_namedb_destroy(&(p)->base)
int nouveau_client_init(struct nouveau_client *); int nvkm_client_init(struct nvkm_client *);
int nouveau_client_fini(struct nouveau_client *, bool suspend); int nvkm_client_fini(struct nvkm_client *, bool suspend);
const char *nouveau_client_name(void *obj); const char *nvkm_client_name(void *obj);
int nvkm_client_notify_new(struct nouveau_object *, struct nvkm_event *, int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
void *data, u32 size); void *data, u32 size);
int nvkm_client_notify_del(struct nouveau_client *, int index); int nvkm_client_notify_del(struct nvkm_client *, int index);
int nvkm_client_notify_get(struct nouveau_client *, int index); int nvkm_client_notify_get(struct nvkm_client *, int index);
int nvkm_client_notify_put(struct nouveau_client *, int index); int nvkm_client_notify_put(struct nvkm_client *, int index);
#endif #endif
#ifndef __NOUVEAU_DEBUG_H__ #ifndef __NVKM_DEBUG_H__
#define __NOUVEAU_DEBUG_H__ #define __NVKM_DEBUG_H__
extern int nv_info_debug_level; extern int nv_info_debug_level;
#define NV_DBG_FATAL 0 #define NV_DBG_FATAL 0
...@@ -16,5 +15,4 @@ extern int nv_info_debug_level; ...@@ -16,5 +15,4 @@ extern int nv_info_debug_level;
#define NV_DBG_INFO_SILENT NV_DBG_DEBUG #define NV_DBG_INFO_SILENT NV_DBG_DEBUG
#define nv_debug_level(a) nv_info_debug_level = NV_DBG_INFO_##a #define nv_debug_level(a) nv_info_debug_level = NV_DBG_INFO_##a
#endif #endif
#ifndef __NOUVEAU_DEVICE_H__ #ifndef __NVKM_DEVICE_H__
#define __NOUVEAU_DEVICE_H__ #define __NVKM_DEVICE_H__
#include <core/object.h>
#include <core/subdev.h>
#include <core/engine.h> #include <core/engine.h>
#include <core/event.h> #include <core/event.h>
struct nouveau_device { struct nvkm_device {
struct nouveau_engine engine; struct nvkm_engine engine;
struct list_head head; struct list_head head;
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -38,53 +35,53 @@ struct nouveau_device { ...@@ -38,53 +35,53 @@ struct nouveau_device {
u8 chiprev; u8 chiprev;
u32 crystal; u32 crystal;
struct nouveau_oclass *oclass[NVDEV_SUBDEV_NR]; struct nvkm_oclass *oclass[NVDEV_SUBDEV_NR];
struct nouveau_object *subdev[NVDEV_SUBDEV_NR]; struct nvkm_object *subdev[NVDEV_SUBDEV_NR];
struct { struct {
struct notifier_block nb; struct notifier_block nb;
} acpi; } acpi;
}; };
int nouveau_device_list(u64 *name, int size); struct nvkm_device *nvkm_device_find(u64 name);
int nvkm_device_list(u64 *name, int size);
struct nouveau_device *nv_device(void *obj); struct nvkm_device *nv_device(void *obj);
static inline bool static inline bool
nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub) nv_device_match(struct nvkm_object *object, u16 dev, u16 ven, u16 sub)
{ {
struct nouveau_device *device = nv_device(object); struct nvkm_device *device = nv_device(object);
return device->pdev->device == dev && return device->pdev->device == dev &&
device->pdev->subsystem_vendor == ven && device->pdev->subsystem_vendor == ven &&
device->pdev->subsystem_device == sub; device->pdev->subsystem_device == sub;
} }
static inline bool static inline bool
nv_device_is_pci(struct nouveau_device *device) nv_device_is_pci(struct nvkm_device *device)
{ {
return device->pdev != NULL; return device->pdev != NULL;
} }
static inline bool static inline bool
nv_device_is_cpu_coherent(struct nouveau_device *device) nv_device_is_cpu_coherent(struct nvkm_device *device)
{ {
return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device)); return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device));
} }
static inline struct device * static inline struct device *
nv_device_base(struct nouveau_device *device) nv_device_base(struct nvkm_device *device)
{ {
return nv_device_is_pci(device) ? &device->pdev->dev : return nv_device_is_pci(device) ? &device->pdev->dev :
&device->platformdev->dev; &device->platformdev->dev;
} }
resource_size_t resource_size_t
nv_device_resource_start(struct nouveau_device *device, unsigned int bar); nv_device_resource_start(struct nvkm_device *device, unsigned int bar);
resource_size_t resource_size_t
nv_device_resource_len(struct nouveau_device *device, unsigned int bar); nv_device_resource_len(struct nvkm_device *device, unsigned int bar);
int int
nv_device_get_irq(struct nouveau_device *device, bool stall); nv_device_get_irq(struct nvkm_device *device, bool stall);
#endif #endif
#ifndef __NOUVEAU_ENGCTX_H__ #ifndef __NVKM_ENGCTX_H__
#define __NOUVEAU_ENGCTX_H__ #define __NVKM_ENGCTX_H__
#include <core/object.h>
#include <core/gpuobj.h> #include <core/gpuobj.h>
#include <subdev/mmu.h> #include <subdev/mmu.h>
...@@ -9,15 +7,15 @@ ...@@ -9,15 +7,15 @@
#define NV_ENGCTX_(eng,var) (NV_ENGCTX_CLASS | ((var) << 8) | (eng)) #define NV_ENGCTX_(eng,var) (NV_ENGCTX_CLASS | ((var) << 8) | (eng))
#define NV_ENGCTX(name,var) NV_ENGCTX_(NVDEV_ENGINE_##name, (var)) #define NV_ENGCTX(name,var) NV_ENGCTX_(NVDEV_ENGINE_##name, (var))
struct nouveau_engctx { struct nvkm_engctx {
struct nouveau_gpuobj gpuobj; struct nvkm_gpuobj gpuobj;
struct nouveau_vma vma; struct nvkm_vma vma;
struct list_head head; struct list_head head;
unsigned long save; unsigned long save;
u64 addr; u64 addr;
}; };
static inline struct nouveau_engctx * static inline struct nvkm_engctx *
nv_engctx(void *obj) nv_engctx(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -27,28 +25,27 @@ nv_engctx(void *obj) ...@@ -27,28 +25,27 @@ nv_engctx(void *obj)
return obj; return obj;
} }
#define nouveau_engctx_create(p,e,c,g,s,a,f,d) \ #define nvkm_engctx_create(p,e,c,g,s,a,f,d) \
nouveau_engctx_create_((p), (e), (c), (g), (s), (a), (f), \ nvkm_engctx_create_((p), (e), (c), (g), (s), (a), (f), \
sizeof(**d), (void **)d) sizeof(**d), (void **)d)
int nouveau_engctx_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_engctx_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, struct nouveau_object *, struct nvkm_oclass *, struct nvkm_object *,
u32 size, u32 align, u32 flags, u32 size, u32 align, u32 flags,
int length, void **data); int length, void **data);
void nouveau_engctx_destroy(struct nouveau_engctx *); void nvkm_engctx_destroy(struct nvkm_engctx *);
int nouveau_engctx_init(struct nouveau_engctx *); int nvkm_engctx_init(struct nvkm_engctx *);
int nouveau_engctx_fini(struct nouveau_engctx *, bool suspend); int nvkm_engctx_fini(struct nvkm_engctx *, bool suspend);
int _nouveau_engctx_ctor(struct nouveau_object *, struct nouveau_object *, int _nvkm_engctx_ctor(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, void *, u32, struct nvkm_oclass *, void *, u32,
struct nouveau_object **); struct nvkm_object **);
void _nouveau_engctx_dtor(struct nouveau_object *); void _nvkm_engctx_dtor(struct nvkm_object *);
int _nouveau_engctx_init(struct nouveau_object *); int _nvkm_engctx_init(struct nvkm_object *);
int _nouveau_engctx_fini(struct nouveau_object *, bool suspend); int _nvkm_engctx_fini(struct nvkm_object *, bool suspend);
#define _nouveau_engctx_rd32 _nouveau_gpuobj_rd32 #define _nvkm_engctx_rd32 _nvkm_gpuobj_rd32
#define _nouveau_engctx_wr32 _nouveau_gpuobj_wr32 #define _nvkm_engctx_wr32 _nvkm_gpuobj_wr32
struct nouveau_object *nouveau_engctx_get(struct nouveau_engine *, u64 addr); struct nvkm_object *nvkm_engctx_get(struct nvkm_engine *, u64 addr);
void nouveau_engctx_put(struct nouveau_object *); void nvkm_engctx_put(struct nvkm_object *);
#endif #endif
#ifndef __NOUVEAU_ENGINE_H__ #ifndef __NVKM_ENGINE_H__
#define __NOUVEAU_ENGINE_H__ #define __NVKM_ENGINE_H__
#include <core/object.h>
#include <core/subdev.h> #include <core/subdev.h>
#define NV_ENGINE_(eng,var) (NV_ENGINE_CLASS | ((var) << 8) | (eng)) #define NV_ENGINE_(eng,var) (NV_ENGINE_CLASS | ((var) << 8) | (eng))
#define NV_ENGINE(name,var) NV_ENGINE_(NVDEV_ENGINE_##name, (var)) #define NV_ENGINE(name,var) NV_ENGINE_(NVDEV_ENGINE_##name, (var))
struct nouveau_engine { struct nvkm_engine {
struct nouveau_subdev subdev; struct nvkm_subdev subdev;
struct nouveau_oclass *cclass; struct nvkm_oclass *cclass;
struct nouveau_oclass *sclass; struct nvkm_oclass *sclass;
struct list_head contexts; struct list_head contexts;
spinlock_t lock; spinlock_t lock;
void (*tile_prog)(struct nouveau_engine *, int region); void (*tile_prog)(struct nvkm_engine *, int region);
int (*tlb_flush)(struct nouveau_engine *); int (*tlb_flush)(struct nvkm_engine *);
}; };
static inline struct nouveau_engine * static inline struct nvkm_engine *
nv_engine(void *obj) nv_engine(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -30,30 +28,29 @@ nv_engine(void *obj) ...@@ -30,30 +28,29 @@ nv_engine(void *obj)
} }
static inline int static inline int
nv_engidx(struct nouveau_engine *engine) nv_engidx(struct nvkm_engine *engine)
{ {
return nv_subidx(&engine->subdev); return nv_subidx(&engine->subdev);
} }
struct nouveau_engine *nouveau_engine(void *obj, int idx); struct nvkm_engine *nvkm_engine(void *obj, int idx);
#define nouveau_engine_create(p,e,c,d,i,f,r) \ #define nvkm_engine_create(p,e,c,d,i,f,r) \
nouveau_engine_create_((p), (e), (c), (d), (i), (f), \ nvkm_engine_create_((p), (e), (c), (d), (i), (f), \
sizeof(**r),(void **)r) sizeof(**r),(void **)r)
#define nouveau_engine_destroy(p) \ #define nvkm_engine_destroy(p) \
nouveau_subdev_destroy(&(p)->subdev) nvkm_subdev_destroy(&(p)->subdev)
#define nouveau_engine_init(p) \ #define nvkm_engine_init(p) \
nouveau_subdev_init(&(p)->subdev) nvkm_subdev_init(&(p)->subdev)
#define nouveau_engine_fini(p,s) \ #define nvkm_engine_fini(p,s) \
nouveau_subdev_fini(&(p)->subdev, (s)) nvkm_subdev_fini(&(p)->subdev, (s))
int nouveau_engine_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_engine_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, bool, const char *, struct nvkm_oclass *, bool, const char *,
const char *, int, void **); const char *, int, void **);
#define _nouveau_engine_dtor _nouveau_subdev_dtor #define _nvkm_engine_dtor _nvkm_subdev_dtor
#define _nouveau_engine_init _nouveau_subdev_init #define _nvkm_engine_init _nvkm_subdev_init
#define _nouveau_engine_fini _nouveau_subdev_fini #define _nvkm_engine_fini _nvkm_subdev_fini
#endif #endif
#ifndef __NOUVEAU_ENUM_H__ #ifndef __NVKM_ENUM_H__
#define __NOUVEAU_ENUM_H__ #define __NVKM_ENUM_H__
#include <core/os.h>
struct nouveau_enum { struct nvkm_enum {
u32 value; u32 value;
const char *name; const char *name;
const void *data; const void *data;
u32 data2; u32 data2;
}; };
const struct nouveau_enum * const struct nvkm_enum *nvkm_enum_find(const struct nvkm_enum *, u32 value);
nouveau_enum_find(const struct nouveau_enum *, u32 value); const struct nvkm_enum *nvkm_enum_print(const struct nvkm_enum *, u32 value);
const struct nouveau_enum * struct nvkm_bitfield {
nouveau_enum_print(const struct nouveau_enum *en, u32 value);
struct nouveau_bitfield {
u32 mask; u32 mask;
const char *name; const char *name;
}; };
void nouveau_bitfield_print(const struct nouveau_bitfield *, u32 value); void nvkm_bitfield_print(const struct nvkm_bitfield *, u32 value);
#endif #endif
#ifndef __NVKM_EVENT_H__ #ifndef __NVKM_EVENT_H__
#define __NVKM_EVENT_H__ #define __NVKM_EVENT_H__
#include <core/os.h>
#include <core/notify.h> struct nvkm_notify;
struct nvkm_object;
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 { struct nvkm_event {
const struct nvkm_event_func *func; const struct nvkm_event_func *func;
...@@ -23,13 +16,19 @@ struct nvkm_event { ...@@ -23,13 +16,19 @@ struct nvkm_event {
int *refs; int *refs;
}; };
int nvkm_event_init(const struct nvkm_event_func *func, struct nvkm_event_func {
int types_nr, int index_nr, int (*ctor)(struct nvkm_object *, void *data, u32 size,
struct nvkm_event *); 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);
};
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_fini(struct nvkm_event *);
void nvkm_event_get(struct nvkm_event *, u32 types, int index); 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_put(struct nvkm_event *, u32 types, int index);
void nvkm_event_send(struct nvkm_event *, u32 types, int index, void nvkm_event_send(struct nvkm_event *, u32 types, int index,
void *data, u32 size); void *data, u32 size);
#endif #endif
#ifndef __NOUVEAU_GPUOBJ_H__ #ifndef __NVKM_GPUOBJ_H__
#define __NOUVEAU_GPUOBJ_H__ #define __NVKM_GPUOBJ_H__
#include <core/object.h> #include <core/object.h>
#include <core/device.h>
#include <core/parent.h>
#include <core/mm.h> #include <core/mm.h>
struct nvkm_vma;
struct nouveau_vma; struct nvkm_vm;
struct nouveau_vm;
#define NVOBJ_FLAG_ZERO_ALLOC 0x00000001 #define NVOBJ_FLAG_ZERO_ALLOC 0x00000001
#define NVOBJ_FLAG_ZERO_FREE 0x00000002 #define NVOBJ_FLAG_ZERO_FREE 0x00000002
#define NVOBJ_FLAG_HEAP 0x00000004 #define NVOBJ_FLAG_HEAP 0x00000004
struct nouveau_gpuobj { struct nvkm_gpuobj {
struct nouveau_object object; struct nvkm_object object;
struct nouveau_object *parent; struct nvkm_object *parent;
struct nouveau_mm_node *node; struct nvkm_mm_node *node;
struct nouveau_mm heap; struct nvkm_mm heap;
u32 flags; u32 flags;
u64 addr; u64 addr;
u32 size; u32 size;
}; };
static inline struct nouveau_gpuobj * static inline struct nvkm_gpuobj *
nv_gpuobj(void *obj) nv_gpuobj(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -34,38 +30,35 @@ nv_gpuobj(void *obj) ...@@ -34,38 +30,35 @@ nv_gpuobj(void *obj)
return obj; return obj;
} }
#define nouveau_gpuobj_create(p,e,c,v,g,s,a,f,d) \ #define nvkm_gpuobj_create(p,e,c,v,g,s,a,f,d) \
nouveau_gpuobj_create_((p), (e), (c), (v), (g), (s), (a), (f), \ nvkm_gpuobj_create_((p), (e), (c), (v), (g), (s), (a), (f), \
sizeof(**d), (void **)d) sizeof(**d), (void **)d)
#define nouveau_gpuobj_init(p) nouveau_object_init(&(p)->object) #define nvkm_gpuobj_init(p) nvkm_object_init(&(p)->object)
#define nouveau_gpuobj_fini(p,s) nouveau_object_fini(&(p)->object, (s)) #define nvkm_gpuobj_fini(p,s) nvkm_object_fini(&(p)->object, (s))
int nouveau_gpuobj_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_gpuobj_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, u32 pclass, struct nvkm_oclass *, u32 pclass,
struct nouveau_object *, u32 size, u32 align, struct nvkm_object *, u32 size, u32 align,
u32 flags, int length, void **); u32 flags, int length, void **);
void nouveau_gpuobj_destroy(struct nouveau_gpuobj *); void nvkm_gpuobj_destroy(struct nvkm_gpuobj *);
int nouveau_gpuobj_new(struct nouveau_object *, struct nouveau_object *, int nvkm_gpuobj_new(struct nvkm_object *, struct nvkm_object *, u32 size,
u32 size, u32 align, u32 flags, u32 align, u32 flags, struct nvkm_gpuobj **);
struct nouveau_gpuobj **); int nvkm_gpuobj_dup(struct nvkm_object *, struct nvkm_gpuobj *,
int nouveau_gpuobj_dup(struct nouveau_object *, struct nouveau_gpuobj *, struct nvkm_gpuobj **);
struct nouveau_gpuobj **); int nvkm_gpuobj_map(struct nvkm_gpuobj *, u32 acc, struct nvkm_vma *);
int nvkm_gpuobj_map_vm(struct nvkm_gpuobj *, struct nvkm_vm *, u32 access,
int nouveau_gpuobj_map(struct nouveau_gpuobj *, u32 acc, struct nouveau_vma *); struct nvkm_vma *);
int nouveau_gpuobj_map_vm(struct nouveau_gpuobj *, struct nouveau_vm *, void nvkm_gpuobj_unmap(struct nvkm_vma *);
u32 access, struct nouveau_vma *);
void nouveau_gpuobj_unmap(struct nouveau_vma *);
static inline void static inline void
nouveau_gpuobj_ref(struct nouveau_gpuobj *obj, struct nouveau_gpuobj **ref) nvkm_gpuobj_ref(struct nvkm_gpuobj *obj, struct nvkm_gpuobj **ref)
{ {
nouveau_object_ref(&obj->object, (struct nouveau_object **)ref); nvkm_object_ref(&obj->object, (struct nvkm_object **)ref);
} }
void _nouveau_gpuobj_dtor(struct nouveau_object *); void _nvkm_gpuobj_dtor(struct nvkm_object *);
int _nouveau_gpuobj_init(struct nouveau_object *); int _nvkm_gpuobj_init(struct nvkm_object *);
int _nouveau_gpuobj_fini(struct nouveau_object *, bool); int _nvkm_gpuobj_fini(struct nvkm_object *, bool);
u32 _nouveau_gpuobj_rd32(struct nouveau_object *, u64); u32 _nvkm_gpuobj_rd32(struct nvkm_object *, u64);
void _nouveau_gpuobj_wr32(struct nouveau_object *, u64, u32); void _nvkm_gpuobj_wr32(struct nvkm_object *, u64, u32);
#endif #endif
#ifndef __NOUVEAU_HANDLE_H__ #ifndef __NVKM_HANDLE_H__
#define __NOUVEAU_HANDLE_H__ #define __NVKM_HANDLE_H__
#include <core/os.h>
struct nvkm_object;
struct nouveau_handle { struct nvkm_handle {
struct nouveau_namedb *namedb; struct nvkm_namedb *namedb;
struct list_head node; struct list_head node;
struct list_head head; struct list_head head;
...@@ -13,22 +15,20 @@ struct nouveau_handle { ...@@ -13,22 +15,20 @@ struct nouveau_handle {
u8 route; u8 route;
u64 token; u64 token;
struct nouveau_handle *parent; struct nvkm_handle *parent;
struct nouveau_object *object; struct nvkm_object *object;
}; };
int nouveau_handle_create(struct nouveau_object *, u32 parent, u32 handle, int nvkm_handle_create(struct nvkm_object *, u32 parent, u32 handle,
struct nouveau_object *, struct nouveau_handle **); struct nvkm_object *, struct nvkm_handle **);
void nouveau_handle_destroy(struct nouveau_handle *); void nvkm_handle_destroy(struct nvkm_handle *);
int nouveau_handle_init(struct nouveau_handle *); int nvkm_handle_init(struct nvkm_handle *);
int nouveau_handle_fini(struct nouveau_handle *, bool suspend); int nvkm_handle_fini(struct nvkm_handle *, bool suspend);
struct nouveau_object * struct nvkm_object *nvkm_handle_ref(struct nvkm_object *, u32 name);
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 *);
struct nvkm_handle *nvkm_handle_get_class(struct nvkm_object *, u16);
struct nvkm_handle *nvkm_handle_get_vinst(struct nvkm_object *, u64);
struct nvkm_handle *nvkm_handle_get_cinst(struct nvkm_object *, u32);
void nvkm_handle_put(struct nvkm_handle *);
#endif #endif
#ifndef __NVKM_IOCTL_H__ #ifndef __NVKM_IOCTL_H__
#define __NVKM_IOCTL_H__ #define __NVKM_IOCTL_H__
#include <core/os.h>
struct nvkm_client;
int nvkm_ioctl(struct nouveau_client *, bool, void *, u32, void **); int nvkm_ioctl(struct nvkm_client *, bool, void *, u32, void **);
#endif #endif
#ifndef __NOUVEAU_MM_H__ #ifndef __NVKM_MM_H__
#define __NOUVEAU_MM_H__ #define __NVKM_MM_H__
#include <core/os.h>
struct nouveau_mm_node { struct nvkm_mm_node {
struct list_head nl_entry; struct list_head nl_entry;
struct list_head fl_entry; struct list_head fl_entry;
struct list_head rl_entry; struct list_head rl_entry;
...@@ -15,7 +16,7 @@ struct nouveau_mm_node { ...@@ -15,7 +16,7 @@ struct nouveau_mm_node {
u32 length; u32 length;
}; };
struct nouveau_mm { struct nvkm_mm {
struct list_head nodes; struct list_head nodes;
struct list_head free; struct list_head free;
...@@ -24,17 +25,16 @@ struct nouveau_mm { ...@@ -24,17 +25,16 @@ struct nouveau_mm {
}; };
static inline bool static inline bool
nouveau_mm_initialised(struct nouveau_mm *mm) nvkm_mm_initialised(struct nvkm_mm *mm)
{ {
return mm->block_size != 0; return mm->block_size != 0;
} }
int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block); int nvkm_mm_init(struct nvkm_mm *, u32 offset, u32 length, u32 block);
int nouveau_mm_fini(struct nouveau_mm *); int nvkm_mm_fini(struct nvkm_mm *);
int nouveau_mm_head(struct nouveau_mm *, u8 heap, u8 type, u32 size_max, int nvkm_mm_head(struct nvkm_mm *, u8 heap, u8 type, u32 size_max,
u32 size_min, u32 align, struct nouveau_mm_node **); u32 size_min, u32 align, struct nvkm_mm_node **);
int nouveau_mm_tail(struct nouveau_mm *, u8 heap, u8 type, u32 size_max, int nvkm_mm_tail(struct nvkm_mm *, u8 heap, u8 type, u32 size_max,
u32 size_min, u32 align, struct nouveau_mm_node **); u32 size_min, u32 align, struct nvkm_mm_node **);
void nouveau_mm_free(struct nouveau_mm *, struct nouveau_mm_node **); void nvkm_mm_free(struct nvkm_mm *, struct nvkm_mm_node **);
#endif #endif
#ifndef __NOUVEAU_NAMEDB_H__ #ifndef __NVKM_NAMEDB_H__
#define __NOUVEAU_NAMEDB_H__ #define __NVKM_NAMEDB_H__
#include <core/parent.h> #include <core/parent.h>
struct nvkm_handle;
struct nouveau_handle; struct nvkm_namedb {
struct nvkm_parent parent;
struct nouveau_namedb {
struct nouveau_parent parent;
rwlock_t lock; rwlock_t lock;
struct list_head list; struct list_head list;
}; };
static inline struct nouveau_namedb * static inline struct nvkm_namedb *
nv_namedb(void *obj) nv_namedb(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -21,36 +19,35 @@ nv_namedb(void *obj) ...@@ -21,36 +19,35 @@ nv_namedb(void *obj)
return obj; return obj;
} }
#define nouveau_namedb_create(p,e,c,v,s,m,d) \ #define nvkm_namedb_create(p,e,c,v,s,m,d) \
nouveau_namedb_create_((p), (e), (c), (v), (s), (m), \ nvkm_namedb_create_((p), (e), (c), (v), (s), (m), \
sizeof(**d), (void **)d) sizeof(**d), (void **)d)
#define nouveau_namedb_init(p) \ #define nvkm_namedb_init(p) \
nouveau_parent_init(&(p)->parent) nvkm_parent_init(&(p)->parent)
#define nouveau_namedb_fini(p,s) \ #define nvkm_namedb_fini(p,s) \
nouveau_parent_fini(&(p)->parent, (s)) nvkm_parent_fini(&(p)->parent, (s))
#define nouveau_namedb_destroy(p) \ #define nvkm_namedb_destroy(p) \
nouveau_parent_destroy(&(p)->parent) nvkm_parent_destroy(&(p)->parent)
int nouveau_namedb_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_namedb_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, u32 pclass, struct nvkm_oclass *, u32 pclass,
struct nouveau_oclass *, u64 engcls, struct nvkm_oclass *, u64 engcls,
int size, void **); int size, void **);
int _nouveau_namedb_ctor(struct nouveau_object *, struct nouveau_object *, int _nvkm_namedb_ctor(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, void *, u32, struct nvkm_oclass *, void *, u32,
struct nouveau_object **); struct nvkm_object **);
#define _nouveau_namedb_dtor _nouveau_parent_dtor #define _nvkm_namedb_dtor _nvkm_parent_dtor
#define _nouveau_namedb_init _nouveau_parent_init #define _nvkm_namedb_init _nvkm_parent_init
#define _nouveau_namedb_fini _nouveau_parent_fini #define _nvkm_namedb_fini _nvkm_parent_fini
int nouveau_namedb_insert(struct nouveau_namedb *, u32 name, int nvkm_namedb_insert(struct nvkm_namedb *, u32 name, struct nvkm_object *,
struct nouveau_object *, struct nouveau_handle *); struct nvkm_handle *);
void nouveau_namedb_remove(struct nouveau_handle *); void nvkm_namedb_remove(struct nvkm_handle *);
struct nouveau_handle *nouveau_namedb_get(struct nouveau_namedb *, u32); struct nvkm_handle *nvkm_namedb_get(struct nvkm_namedb *, u32);
struct nouveau_handle *nouveau_namedb_get_class(struct nouveau_namedb *, u16); struct nvkm_handle *nvkm_namedb_get_class(struct nvkm_namedb *, u16);
struct nouveau_handle *nouveau_namedb_get_vinst(struct nouveau_namedb *, u64); struct nvkm_handle *nvkm_namedb_get_vinst(struct nvkm_namedb *, u64);
struct nouveau_handle *nouveau_namedb_get_cinst(struct nouveau_namedb *, u32); struct nvkm_handle *nvkm_namedb_get_cinst(struct nvkm_namedb *, u32);
void nouveau_namedb_put(struct nouveau_handle *); void nvkm_namedb_put(struct nvkm_handle *);
#endif #endif
#ifndef __NVKM_NOTIFY_H__ #ifndef __NVKM_NOTIFY_H__
#define __NVKM_NOTIFY_H__ #define __NVKM_NOTIFY_H__
#include <core/os.h>
struct nvkm_object;
struct nvkm_notify { struct nvkm_notify {
struct nvkm_event *event; struct nvkm_event *event;
...@@ -25,7 +27,7 @@ struct nvkm_notify { ...@@ -25,7 +27,7 @@ struct nvkm_notify {
const void *data; const void *data;
}; };
int nvkm_notify_init(struct nouveau_object *, struct nvkm_event *, int nvkm_notify_init(struct nvkm_object *, struct nvkm_event *,
int (*func)(struct nvkm_notify *), bool work, int (*func)(struct nvkm_notify *), bool work,
void *data, u32 size, u32 reply, void *data, u32 size, u32 reply,
struct nvkm_notify *); struct nvkm_notify *);
...@@ -33,5 +35,4 @@ void nvkm_notify_fini(struct nvkm_notify *); ...@@ -33,5 +35,4 @@ void nvkm_notify_fini(struct nvkm_notify *);
void nvkm_notify_get(struct nvkm_notify *); void nvkm_notify_get(struct nvkm_notify *);
void nvkm_notify_put(struct nvkm_notify *); void nvkm_notify_put(struct nvkm_notify *);
void nvkm_notify_send(struct nvkm_notify *, void *data, u32 size); void nvkm_notify_send(struct nvkm_notify *, void *data, u32 size);
#endif #endif
#ifndef __NOUVEAU_OBJECT_H__ #ifndef __NVKM_OBJECT_H__
#define __NOUVEAU_OBJECT_H__ #define __NVKM_OBJECT_H__
#include <core/os.h> #include <core/os.h>
#include <core/printk.h> #include <core/printk.h>
...@@ -14,52 +13,52 @@ ...@@ -14,52 +13,52 @@
#define NV_ENGCTX_CLASS 0x01000000 #define NV_ENGCTX_CLASS 0x01000000
#define NV_OBJECT_CLASS 0x0000ffff #define NV_OBJECT_CLASS 0x0000ffff
struct nouveau_object { struct nvkm_object {
struct nouveau_oclass *oclass; struct nvkm_oclass *oclass;
struct nouveau_object *parent; struct nvkm_object *parent;
struct nouveau_engine *engine; struct nvkm_engine *engine;
atomic_t refcount; atomic_t refcount;
atomic_t usecount; atomic_t usecount;
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
#define NOUVEAU_OBJECT_MAGIC 0x75ef0bad #define NVKM_OBJECT_MAGIC 0x75ef0bad
struct list_head list; struct list_head list;
u32 _magic; u32 _magic;
#endif #endif
}; };
static inline struct nouveau_object * static inline struct nvkm_object *
nv_object(void *obj) nv_object(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
if (likely(obj)) { if (likely(obj)) {
struct nouveau_object *object = obj; struct nvkm_object *object = obj;
if (unlikely(object->_magic != NOUVEAU_OBJECT_MAGIC)) if (unlikely(object->_magic != NVKM_OBJECT_MAGIC))
nv_assert("BAD CAST -> NvObject, invalid magic"); nv_assert("BAD CAST -> NvObject, invalid magic");
} }
#endif #endif
return obj; return obj;
} }
#define nouveau_object_create(p,e,c,s,d) \ #define nvkm_object_create(p,e,c,s,d) \
nouveau_object_create_((p), (e), (c), (s), sizeof(**d), (void **)d) nvkm_object_create_((p), (e), (c), (s), sizeof(**d), (void **)d)
int nouveau_object_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_object_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, u32, int size, void **); struct nvkm_oclass *, u32, int size, void **);
void nouveau_object_destroy(struct nouveau_object *); void nvkm_object_destroy(struct nvkm_object *);
int nouveau_object_init(struct nouveau_object *); int nvkm_object_init(struct nvkm_object *);
int nouveau_object_fini(struct nouveau_object *, bool suspend); int nvkm_object_fini(struct nvkm_object *, bool suspend);
int _nouveau_object_ctor(struct nouveau_object *, struct nouveau_object *, int _nvkm_object_ctor(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, void *, u32, struct nvkm_oclass *, void *, u32,
struct nouveau_object **); struct nvkm_object **);
extern struct nouveau_ofuncs nouveau_object_ofuncs; extern struct nvkm_ofuncs nvkm_object_ofuncs;
/* Don't allocate dynamically, because lockdep needs lock_class_keys to be in /* Don't allocate dynamically, because lockdep needs lock_class_keys to be in
* ".data". */ * ".data". */
struct nouveau_oclass { struct nvkm_oclass {
u32 handle; u32 handle;
struct nouveau_ofuncs * const ofuncs; struct nvkm_ofuncs * const ofuncs;
struct nouveau_omthds * const omthds; struct nvkm_omthds * const omthds;
struct lock_class_key lock_class_key; struct lock_class_key lock_class_key;
}; };
...@@ -68,58 +67,57 @@ struct nouveau_oclass { ...@@ -68,58 +67,57 @@ struct nouveau_oclass {
#define nv_iclass(o,i) (nv_hclass(o) & (i)) #define nv_iclass(o,i) (nv_hclass(o) & (i))
#define nv_mclass(o) nv_iclass(o, NV_OBJECT_CLASS) #define nv_mclass(o) nv_iclass(o, NV_OBJECT_CLASS)
static inline struct nouveau_object * static inline struct nvkm_object *
nv_pclass(struct nouveau_object *parent, u32 oclass) nv_pclass(struct nvkm_object *parent, u32 oclass)
{ {
while (parent && !nv_iclass(parent, oclass)) while (parent && !nv_iclass(parent, oclass))
parent = parent->parent; parent = parent->parent;
return parent; return parent;
} }
struct nouveau_omthds { struct nvkm_omthds {
u32 start; u32 start;
u32 limit; u32 limit;
int (*call)(struct nouveau_object *, u32, void *, u32); int (*call)(struct nvkm_object *, u32, void *, u32);
}; };
struct nvkm_event; struct nvkm_event;
struct nouveau_ofuncs { struct nvkm_ofuncs {
int (*ctor)(struct nouveau_object *, struct nouveau_object *, int (*ctor)(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, void *data, u32 size, struct nvkm_oclass *, void *data, u32 size,
struct nouveau_object **); struct nvkm_object **);
void (*dtor)(struct nouveau_object *); void (*dtor)(struct nvkm_object *);
int (*init)(struct nouveau_object *); int (*init)(struct nvkm_object *);
int (*fini)(struct nouveau_object *, bool suspend); int (*fini)(struct nvkm_object *, bool suspend);
int (*mthd)(struct nouveau_object *, u32, void *, u32); int (*mthd)(struct nvkm_object *, u32, void *, u32);
int (*ntfy)(struct nouveau_object *, u32, struct nvkm_event **); int (*ntfy)(struct nvkm_object *, u32, struct nvkm_event **);
int (* map)(struct nouveau_object *, u64 *, u32 *); int (* map)(struct nvkm_object *, u64 *, u32 *);
u8 (*rd08)(struct nouveau_object *, u64 offset); u8 (*rd08)(struct nvkm_object *, u64 offset);
u16 (*rd16)(struct nouveau_object *, u64 offset); u16 (*rd16)(struct nvkm_object *, u64 offset);
u32 (*rd32)(struct nouveau_object *, u64 offset); u32 (*rd32)(struct nvkm_object *, u64 offset);
void (*wr08)(struct nouveau_object *, u64 offset, u8 data); void (*wr08)(struct nvkm_object *, u64 offset, u8 data);
void (*wr16)(struct nouveau_object *, u64 offset, u16 data); void (*wr16)(struct nvkm_object *, u64 offset, u16 data);
void (*wr32)(struct nouveau_object *, u64 offset, u32 data); void (*wr32)(struct nvkm_object *, u64 offset, u32 data);
}; };
static inline struct nouveau_ofuncs * static inline struct nvkm_ofuncs *
nv_ofuncs(void *obj) nv_ofuncs(void *obj)
{ {
return nv_oclass(obj)->ofuncs; return nv_oclass(obj)->ofuncs;
} }
int nouveau_object_ctor(struct nouveau_object *, struct nouveau_object *, int nvkm_object_ctor(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, void *, u32, struct nvkm_oclass *, void *, u32,
struct nouveau_object **); struct nvkm_object **);
void nouveau_object_ref(struct nouveau_object *, struct nouveau_object **); void nvkm_object_ref(struct nvkm_object *, struct nvkm_object **);
int nouveau_object_inc(struct nouveau_object *); int nvkm_object_inc(struct nvkm_object *);
int nouveau_object_dec(struct nouveau_object *, bool suspend); int nvkm_object_dec(struct nvkm_object *, bool suspend);
void nvkm_object_debug(void);
void nouveau_object_debug(void);
static inline int static inline int
nv_exec(void *obj, u32 mthd, void *data, u32 size) nv_exec(void *obj, u32 mthd, void *data, u32 size)
{ {
struct nouveau_omthds *method = nv_oclass(obj)->omthds; struct nvkm_omthds *method = nv_oclass(obj)->omthds;
while (method && method->call) { while (method && method->call) {
if (mthd >= method->start && mthd <= method->limit) if (mthd >= method->start && mthd <= method->limit)
...@@ -202,5 +200,4 @@ nv_memcmp(void *obj, u32 addr, const char *str, u32 len) ...@@ -202,5 +200,4 @@ nv_memcmp(void *obj, u32 addr, const char *str, u32 len)
} }
return 0; return 0;
} }
#endif #endif
#ifndef __NOUVEAU_OPTION_H__ #ifndef __NVKM_OPTION_H__
#define __NOUVEAU_OPTION_H__ #define __NVKM_OPTION_H__
#include <core/os.h> #include <core/os.h>
const char *nouveau_stropt(const char *optstr, const char *opt, int *len); const char *nvkm_stropt(const char *optstr, const char *opt, int *len);
bool nouveau_boolopt(const char *optstr, const char *opt, bool value); bool nvkm_boolopt(const char *optstr, const char *opt, bool value);
int nvkm_dbgopt(const char *optstr, const char *sub);
int nouveau_dbgopt(const char *optstr, const char *sub);
/* compares unterminated string 'str' with zero-terminated string 'cmp' */ /* compares unterminated string 'str' with zero-terminated string 'cmp' */
static inline int static inline int
...@@ -16,5 +14,4 @@ strncasecmpz(const char *str, const char *cmp, size_t len) ...@@ -16,5 +14,4 @@ strncasecmpz(const char *str, const char *cmp, size_t len)
return len; return len;
return strncasecmp(str, cmp, len); return strncasecmp(str, cmp, len);
} }
#endif #endif
#ifndef __NVKM_OS_H__ #ifndef __NVKM_OS_H__
#define __NVKM_OS_H__ #define __NVKM_OS_H__
#include <nvif/os.h> #include <nvif/os.h>
#define nouveau_client nvkm_client
#define nouveau_client_name nvkm_client_name
#define nouveau_client_create nvkm_client_create
#define nouveau_client_init nvkm_client_init
#define nouveau_client_fini nvkm_client_fini
#define nouveau_engctx nvkm_engctx
#define nouveau_engctx_create nvkm_engctx_create
#define nouveau_engctx_create_ nvkm_engctx_create_
#define nouveau_engctx_destroy nvkm_engctx_destroy
#define nouveau_engctx_init nvkm_engctx_init
#define nouveau_engctx_fini nvkm_engctx_fini
#define _nouveau_engctx_ctor _nvkm_engctx_ctor
#define _nouveau_engctx_dtor _nvkm_engctx_dtor
#define _nouveau_engctx_init _nvkm_engctx_init
#define _nouveau_engctx_fini _nvkm_engctx_fini
#define _nouveau_engctx_rd32 _nvkm_engctx_rd32
#define _nouveau_engctx_wr32 _nvkm_engctx_wr32
#define nouveau_engctx_get nvkm_engctx_get
#define nouveau_engctx_put nvkm_engctx_put
#define nouveau_engine nvkm_engine
#define nouveau_engine_create nvkm_engine_create
#define nouveau_engine_create_ nvkm_engine_create_
#define nouveau_engine_destroy nvkm_engine_destroy
#define nouveau_engine_init nvkm_engine_init
#define nouveau_engine_fini nvkm_engine_fini
#define _nouveau_engine_ctor _nvkm_engine_ctor
#define _nouveau_engine_dtor _nvkm_engine_dtor
#define _nouveau_engine_init _nvkm_engine_init
#define _nouveau_engine_fini _nvkm_engine_fini
#define nouveau_enum nvkm_enum
#define nouveau_gpuobj nvkm_gpuobj
#define nouveau_gpuobj_create nvkm_gpuobj_create
#define nouveau_gpuobj_destroy nvkm_gpuobj_destroy
#define _nouveau_gpuobj_ctor _nvkm_gpuobj_ctor
#define _nouveau_gpuobj_dtor _nvkm_gpuobj_dtor
#define _nouveau_gpuobj_init _nvkm_gpuobj_init
#define _nouveau_gpuobj_fini _nvkm_gpuobj_fini
#define _nouveau_gpuobj_rd32 _nvkm_gpuobj_rd32
#define _nouveau_gpuobj_wr32 _nvkm_gpuobj_wr32
#define nouveau_gpuobj_new nvkm_gpuobj_new
#define nouveau_gpuobj_dup nvkm_gpuobj_dup
#define nouveau_gpuobj_ref nvkm_gpuobj_ref
#define nouveau_gpuobj_map nvkm_gpuobj_map
#define nouveau_gpuobj_map_vm nvkm_gpuobj_map_vm
#define nouveau_gpuobj_unmap nvkm_gpuobj_unmap
#define nouveau_handle nvkm_handle
#define nouveau_handle_ref nvkm_handle_ref
#define nouveau_handle_put nvkm_handle_put
#define nouveau_handle_get_class nvkm_handle_get_class
#define nouveau_handle_get_vinst nvkm_handle_get_vinst
#define nouveau_handle_get_cinst nvkm_handle_get_cinst
#define nouveau_mm nvkm_mm
#define nouveau_mm_node nvkm_mm_node
#define nouveau_mm_init nvkm_mm_init
#define nouveau_mm_fini nvkm_mm_fini
#define nouveau_mm_head nvkm_mm_head
#define nouveau_mm_tail nvkm_mm_tail
#define nouveau_mm_free nvkm_mm_free
#define nouveau_mm_initialised nvkm_mm_initialised
#define nouveau_namedb nvkm_namedb
#define nouveau_namedb_create nvkm_namedb_create
#define nouveau_namedb_create_ nvkm_namedb_create_
#define nouveau_namedb_destroy nvkm_namedb_destroy
#define nouveau_namedb_init nvkm_namedb_init
#define nouveau_namedb_fini nvkm_namedb_fini
#define _nouveau_namedb_ctor _nvkm_namedb_ctor
#define _nouveau_namedb_dtor _nvkm_namedb_dtor
#define _nouveau_namedb_init _nvkm_namedb_init
#define _nouveau_namedb_fini _nvkm_namedb_fini
#define nouveau_namedb_ref nvkm_namedb_ref
#define nouveau_namedb_put nvkm_namedb_put
#define nouveau_namedb_get nvkm_namedb_get
#define nouveau_namedb_get_class nvkm_namedb_get_class
#define nouveau_namedb_get_vinst nvkm_namedb_get_vinst
#define nouveau_namedb_get_cinst nvkm_namedb_get_cinst
#define nouveau_object_debug nvkm_object_debug
#define nouveau_object nvkm_object
#define nouveau_object_create nvkm_object_create
#define nouveau_object_create_ nvkm_object_create_
#define nouveau_object_destroy nvkm_object_destroy
#define nouveau_object_init nvkm_object_init
#define nouveau_object_fini nvkm_object_fini
#define _nouveau_object_ctor _nvkm_object_ctor
#define nouveau_object_ctor nvkm_object_ctor
#define nouveau_object_ref nvkm_object_ref
#define nouveau_object_ofuncs nvkm_object_ofuncs
#define nouveau_object_inc nvkm_object_inc
#define nouveau_object_dec nvkm_object_dec
#define nouveau_ofuncs nvkm_ofuncs
#define nouveau_oclass nvkm_oclass
#define nouveau_omthds nvkm_omthds
#define nouveau_parent nvkm_parent
#define nouveau_parent_create nvkm_parent_create
#define nouveau_parent_create_ nvkm_parent_create_
#define nouveau_parent_destroy nvkm_parent_destroy
#define nouveau_parent_init nvkm_parent_init
#define nouveau_parent_fini nvkm_parent_fini
#define _nouveau_parent_ctor _nvkm_parent_ctor
#define _nouveau_parent_dtor _nvkm_parent_dtor
#define _nouveau_parent_init _nvkm_parent_init
#define _nouveau_parent_fini _nvkm_parent_fini
#define nouveau_printk nvkm_printk
#define nouveau_ramht nvkm_ramht
#define nouveau_ramht_new nvkm_ramht_new
#define nouveau_ramht_ref nvkm_ramht_ref
#define nouveau_ramht_insert nvkm_ramht_insert
#define nouveau_ramht_remove nvkm_ramht_remove
#define nouveau_subdev nvkm_subdev
#define nouveau_subdev_create nvkm_subdev_create
#define nouveau_subdev_create_ nvkm_subdev_create_
#define nouveau_subdev_destroy nvkm_subdev_destroy
#define nouveau_subdev_init nvkm_subdev_init
#define nouveau_subdev_fini nvkm_subdev_fini
#define _nouveau_subdev_ctor _nvkm_subdev_ctor
#define _nouveau_subdev_dtor _nvkm_subdev_dtor
#define _nouveau_subdev_init _nvkm_subdev_init
#define _nouveau_subdev_fini _nvkm_subdev_fini
#define nouveau_subdev_reset nvkm_subdev_reset
#define nouveau_bitfield nvkm_bitfield
#define nouveau_bitfield_print nvkm_bitfield_print
#define nouveau_enum nvkm_enum
#define nouveau_enum_find nvkm_enum_find
#define nouveau_enum_print nvkm_enum_print
#define nouveau_stropt nvkm_stropt
#define nouveau_boolopt nvkm_boolopt
#define nouveau_dbgopt nvkm_dbgopt
#define nouveau_device nvkm_device
#define nouveau_device_find nvkm_device_find
#define nouveau_device_list nvkm_device_list
#define nouveau_vma nvkm_vma
#define nouveau_vm nvkm_vm
#define nouveau_vm_get nvkm_vm_get
#define nouveau_vm_put nvkm_vm_put
#define nouveau_vm_map nvkm_vm_map
#define nouveau_vm_unmap nvkm_vm_unmap
#define nouveau_instmem nvkm_instmem
#define nouveau_instobj nvkm_instobj
#define nouveau_mem nvkm_mem
#define nouveau_bar nvkm_bar
#define nouveau_falcon nvkm_falcon
#define nouveau_falcon_create nvkm_falcon_create
#define nouveau_falcon_create_ nvkm_falcon_create_
#define nouveau_falcon_destroy nvkm_falcon_destroy
#define nouveau_falcon_init nvkm_falcon_init
#define nouveau_falcon_fini nvkm_falcon_fini
#define _nouveau_falcon_ctor _nvkm_falcon_ctor
#define _nouveau_falcon_dtor _nvkm_falcon_dtor
#define _nouveau_falcon_init _nvkm_falcon_init
#define _nouveau_falcon_fini _nvkm_falcon_fini
#define _nouveau_falcon_rd32 _nvkm_falcon_rd32
#define _nouveau_falcon_wr32 _nvkm_falcon_wr32
#define nouveau_falcon_context nvkm_falcon_context
#define nouveau_falcon_context_create nvkm_falcon_context_create
#define nouveau_falcon_context_create_ nvkm_falcon_context_create_
#define nouveau_falcon_context_destroy nvkm_falcon_context_destroy
#define nouveau_falcon_context_init nvkm_falcon_context_init
#define nouveau_falcon_context_fini nvkm_falcon_context_fini
#define _nouveau_falcon_context_ctor _nvkm_falcon_context_ctor
#define _nouveau_falcon_context_dtor _nvkm_falcon_context_dtor
#define _nouveau_falcon_context_init _nvkm_falcon_context_init
#define _nouveau_falcon_context_fini _nvkm_falcon_context_fini
#define _nouveau_falcon_context_rd32 _nvkm_falcon_context_rd32
#define _nouveau_falcon_context_wr32 _nvkm_falcon_context_wr32
#define nouveau_falcon_intr nvkm_falcon_intr
#define nouveau_xtensa nvkm_xtensa
#define nouveau_xtensa_create nvkm_xtensa_create
#define nouveau_xtensa_create_ nvkm_xtensa_create_
#define nouveau_xtensa_destroy nvkm_xtensa_destroy
#define nouveau_xtensa_init nvkm_xtensa_init
#define nouveau_xtensa_fini nvkm_xtensa_fini
#define _nouveau_xtensa_ctor _nvkm_xtensa_ctor
#define _nouveau_xtensa_dtor _nvkm_xtensa_dtor
#define _nouveau_xtensa_init _nvkm_xtensa_init
#define _nouveau_xtensa_fini _nvkm_xtensa_fini
#define _nouveau_xtensa_rd32 _nvkm_xtensa_rd32
#define _nouveau_xtensa_wr32 _nvkm_xtensa_wr32
#define nouveau_xtensa_context nvkm_xtensa_context
#define nouveau_xtensa_context_create nvkm_xtensa_context_create
#define nouveau_xtensa_context_create_ nvkm_xtensa_context_create_
#define nouveau_xtensa_context_destroy nvkm_xtensa_context_destroy
#define nouveau_xtensa_context_init nvkm_xtensa_context_init
#define nouveau_xtensa_context_fini nvkm_xtensa_context_fini
#define _nouveau_xtensa_engctx_ctor _nvkm_xtensa_engctx_ctor
#define _nouveau_xtensa_context_dtor _nvkm_xtensa_context_dtor
#define _nouveau_xtensa_context_init _nvkm_xtensa_context_init
#define _nouveau_xtensa_context_fini _nvkm_xtensa_context_fini
#define _nouveau_xtensa_context_rd32 _nvkm_xtensa_context_rd32
#define _nouveau_xtensa_context_wr32 _nvkm_xtensa_context_wr32
#define nouveau_xtensa_intr nvkm_xtensa_intr
#endif #endif
#ifndef __NOUVEAU_PARENT_H__ #ifndef __NVKM_PARENT_H__
#define __NOUVEAU_PARENT_H__ #define __NVKM_PARENT_H__
#include <core/device.h>
#include <core/object.h> #include <core/object.h>
struct nouveau_sclass { struct nvkm_sclass {
struct nouveau_sclass *sclass; struct nvkm_sclass *sclass;
struct nouveau_engine *engine; struct nvkm_engine *engine;
struct nouveau_oclass *oclass; struct nvkm_oclass *oclass;
}; };
struct nouveau_parent { struct nvkm_parent {
struct nouveau_object object; struct nvkm_object object;
struct nouveau_sclass *sclass; struct nvkm_sclass *sclass;
u64 engine; u64 engine;
int (*context_attach)(struct nouveau_object *, int (*context_attach)(struct nvkm_object *, struct nvkm_object *);
struct nouveau_object *); int (*context_detach)(struct nvkm_object *, bool suspend,
int (*context_detach)(struct nouveau_object *, bool suspend, struct nvkm_object *);
struct nouveau_object *);
int (*object_attach)(struct nouveau_object *parent, int (*object_attach)(struct nvkm_object *parent,
struct nouveau_object *object, u32 name); struct nvkm_object *object, u32 name);
void (*object_detach)(struct nouveau_object *parent, int cookie); void (*object_detach)(struct nvkm_object *parent, int cookie);
}; };
static inline struct nouveau_parent * static inline struct nvkm_parent *
nv_parent(void *obj) nv_parent(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -36,27 +33,26 @@ nv_parent(void *obj) ...@@ -36,27 +33,26 @@ nv_parent(void *obj)
return obj; return obj;
} }
#define nouveau_parent_create(p,e,c,v,s,m,d) \ #define nvkm_parent_create(p,e,c,v,s,m,d) \
nouveau_parent_create_((p), (e), (c), (v), (s), (m), \ nvkm_parent_create_((p), (e), (c), (v), (s), (m), \
sizeof(**d), (void **)d) sizeof(**d), (void **)d)
#define nouveau_parent_init(p) \ #define nvkm_parent_init(p) \
nouveau_object_init(&(p)->object) nvkm_object_init(&(p)->object)
#define nouveau_parent_fini(p,s) \ #define nvkm_parent_fini(p,s) \
nouveau_object_fini(&(p)->object, (s)) nvkm_object_fini(&(p)->object, (s))
int nouveau_parent_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_parent_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, u32 pclass, struct nvkm_oclass *, u32 pclass,
struct nouveau_oclass *, u64 engcls, struct nvkm_oclass *, u64 engcls,
int size, void **); int size, void **);
void nouveau_parent_destroy(struct nouveau_parent *); void nvkm_parent_destroy(struct nvkm_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, void _nvkm_parent_dtor(struct nvkm_object *);
struct nouveau_object **pengine, #define _nvkm_parent_init nvkm_object_init
struct nouveau_oclass **poclass); #define _nvkm_parent_fini nvkm_object_fini
int nouveau_parent_lclass(struct nouveau_object *, u32 *, int);
int nvkm_parent_sclass(struct nvkm_object *, u16 handle,
struct nvkm_object **pengine,
struct nvkm_oclass **poclass);
int nvkm_parent_lclass(struct nvkm_object *, u32 *, int);
#endif #endif
#ifndef __NOUVEAU_PRINTK_H__ #ifndef __NVKM_PRINTK_H__
#define __NOUVEAU_PRINTK_H__ #define __NVKM_PRINTK_H__
#include <core/os.h> #include <core/os.h>
#include <core/debug.h> #include <core/debug.h>
struct nvkm_object;
struct nouveau_object;
void __printf(3, 4) void __printf(3, 4)
nv_printk_(struct nouveau_object *, int, const char *, ...); nv_printk_(struct nvkm_object *, int, const char *, ...);
#define nv_printk(o,l,f,a...) do { \ #define nv_printk(o,l,f,a...) do { \
if (NV_DBG_##l <= CONFIG_NOUVEAU_DEBUG) \ if (NV_DBG_##l <= CONFIG_NOUVEAU_DEBUG) \
...@@ -21,12 +19,11 @@ nv_printk_(struct nouveau_object *, int, const char *, ...); ...@@ -21,12 +19,11 @@ nv_printk_(struct nouveau_object *, int, const char *, ...);
#define nv_debug(o,f,a...) nv_printk((o), DEBUG, 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_trace(o,f,a...) nv_printk((o), TRACE, f, ##a)
#define nv_spam(o,f,a...) nv_printk((o), SPAM, 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_ioctl(o,f,a...) nv_trace(nvkm_client(o), "ioctl: "f, ##a)
#define nv_assert(f,a...) do { \ #define nv_assert(f,a...) do { \
if (NV_DBG_FATAL <= CONFIG_NOUVEAU_DEBUG) \ if (NV_DBG_FATAL <= CONFIG_NOUVEAU_DEBUG) \
nv_printk_(NULL, NV_DBG_FATAL, f "\n", ##a); \ nv_printk_(NULL, NV_DBG_FATAL, f "\n", ##a); \
BUG_ON(1); \ BUG_ON(1); \
} while(0) } while(0)
#endif #endif
#ifndef __NOUVEAU_RAMHT_H__ #ifndef __NVKM_RAMHT_H__
#define __NOUVEAU_RAMHT_H__ #define __NVKM_RAMHT_H__
#include <core/gpuobj.h> #include <core/gpuobj.h>
struct nouveau_ramht { struct nvkm_ramht {
struct nouveau_gpuobj gpuobj; struct nvkm_gpuobj gpuobj;
int bits; int bits;
}; };
int nouveau_ramht_insert(struct nouveau_ramht *, int chid, int nvkm_ramht_insert(struct nvkm_ramht *, int chid, u32 handle, u32 context);
u32 handle, u32 context); void nvkm_ramht_remove(struct nvkm_ramht *, int cookie);
void nouveau_ramht_remove(struct nouveau_ramht *, int cookie); int nvkm_ramht_new(struct nvkm_object *, struct nvkm_object *, u32 size,
int nouveau_ramht_new(struct nouveau_object *, struct nouveau_object *, u32 align, struct nvkm_ramht **);
u32 size, u32 align, struct nouveau_ramht **);
static inline void static inline void
nouveau_ramht_ref(struct nouveau_ramht *obj, struct nouveau_ramht **ref) nvkm_ramht_ref(struct nvkm_ramht *obj, struct nvkm_ramht **ref)
{ {
nouveau_gpuobj_ref(&obj->gpuobj, (struct nouveau_gpuobj **)ref); nvkm_gpuobj_ref(&obj->gpuobj, (struct nvkm_gpuobj **)ref);
} }
#endif #endif
#ifndef __NOUVEAU_SUBDEV_H__ #ifndef __NVKM_SUBDEV_H__
#define __NOUVEAU_SUBDEV_H__ #define __NVKM_SUBDEV_H__
#include <core/object.h> #include <core/object.h>
#include <core/devidx.h> #include <core/devidx.h>
#define NV_SUBDEV_(sub,var) (NV_SUBDEV_CLASS | ((var) << 8) | (sub)) #define NV_SUBDEV_(sub,var) (NV_SUBDEV_CLASS | ((var) << 8) | (sub))
#define NV_SUBDEV(name,var) NV_SUBDEV_(NVDEV_SUBDEV_##name, (var)) #define NV_SUBDEV(name,var) NV_SUBDEV_(NVDEV_SUBDEV_##name, (var))
struct nouveau_subdev { struct nvkm_subdev {
struct nouveau_object object; struct nvkm_object object;
struct mutex mutex; struct mutex mutex;
const char *name; const char *name;
void __iomem *mmio; void __iomem *mmio;
u32 debug; u32 debug;
u32 unit; u32 unit;
void (*intr)(struct nouveau_subdev *); void (*intr)(struct nvkm_subdev *);
}; };
static inline struct nouveau_subdev * static inline struct nvkm_subdev *
nv_subdev(void *obj) nv_subdev(void *obj)
{ {
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
...@@ -29,29 +28,29 @@ nv_subdev(void *obj) ...@@ -29,29 +28,29 @@ nv_subdev(void *obj)
} }
static inline int static inline int
nv_subidx(struct nouveau_subdev *subdev) nv_subidx(struct nvkm_subdev *subdev)
{ {
return nv_hclass(subdev) & 0xff; return nv_hclass(subdev) & 0xff;
} }
struct nouveau_subdev *nouveau_subdev(void *obj, int idx); struct nvkm_subdev *nvkm_subdev(void *obj, int idx);
#define nouveau_subdev_create(p,e,o,v,s,f,d) \ #define nvkm_subdev_create(p,e,o,v,s,f,d) \
nouveau_subdev_create_((p), (e), (o), (v), (s), (f), \ nvkm_subdev_create_((p), (e), (o), (v), (s), (f), \
sizeof(**d),(void **)d) sizeof(**d),(void **)d)
int nouveau_subdev_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_subdev_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, u32 pclass, struct nvkm_oclass *, u32 pclass,
const char *sname, const char *fname, const char *sname, const char *fname,
int size, void **); int size, void **);
void nouveau_subdev_destroy(struct nouveau_subdev *); void nvkm_subdev_destroy(struct nvkm_subdev *);
int nouveau_subdev_init(struct nouveau_subdev *); int nvkm_subdev_init(struct nvkm_subdev *);
int nouveau_subdev_fini(struct nouveau_subdev *, bool suspend); int nvkm_subdev_fini(struct nvkm_subdev *, bool suspend);
void nouveau_subdev_reset(struct nouveau_object *); void nvkm_subdev_reset(struct nvkm_object *);
void _nouveau_subdev_dtor(struct nouveau_object *); void _nvkm_subdev_dtor(struct nvkm_object *);
int _nouveau_subdev_init(struct nouveau_object *); int _nvkm_subdev_init(struct nvkm_object *);
int _nouveau_subdev_fini(struct nouveau_object *, bool suspend); int _nvkm_subdev_fini(struct nvkm_object *, bool suspend);
#define s_printk(s,l,f,a...) do { \ #define s_printk(s,l,f,a...) do { \
if ((s)->debug >= OS_DBG_##l) { \ if ((s)->debug >= OS_DBG_##l) { \
...@@ -62,7 +61,7 @@ int _nouveau_subdev_fini(struct nouveau_object *, bool suspend); ...@@ -62,7 +61,7 @@ int _nouveau_subdev_fini(struct nouveau_object *, bool suspend);
static inline u8 static inline u8
nv_rd08(void *obj, u32 addr) nv_rd08(void *obj, u32 addr)
{ {
struct nouveau_subdev *subdev = nv_subdev(obj); struct nvkm_subdev *subdev = nv_subdev(obj);
u8 data = ioread8(subdev->mmio + addr); u8 data = ioread8(subdev->mmio + addr);
nv_spam(subdev, "nv_rd08 0x%06x 0x%02x\n", addr, data); nv_spam(subdev, "nv_rd08 0x%06x 0x%02x\n", addr, data);
return data; return data;
...@@ -71,7 +70,7 @@ nv_rd08(void *obj, u32 addr) ...@@ -71,7 +70,7 @@ nv_rd08(void *obj, u32 addr)
static inline u16 static inline u16
nv_rd16(void *obj, u32 addr) nv_rd16(void *obj, u32 addr)
{ {
struct nouveau_subdev *subdev = nv_subdev(obj); struct nvkm_subdev *subdev = nv_subdev(obj);
u16 data = ioread16_native(subdev->mmio + addr); u16 data = ioread16_native(subdev->mmio + addr);
nv_spam(subdev, "nv_rd16 0x%06x 0x%04x\n", addr, data); nv_spam(subdev, "nv_rd16 0x%06x 0x%04x\n", addr, data);
return data; return data;
...@@ -80,7 +79,7 @@ nv_rd16(void *obj, u32 addr) ...@@ -80,7 +79,7 @@ nv_rd16(void *obj, u32 addr)
static inline u32 static inline u32
nv_rd32(void *obj, u32 addr) nv_rd32(void *obj, u32 addr)
{ {
struct nouveau_subdev *subdev = nv_subdev(obj); struct nvkm_subdev *subdev = nv_subdev(obj);
u32 data = ioread32_native(subdev->mmio + addr); u32 data = ioread32_native(subdev->mmio + addr);
nv_spam(subdev, "nv_rd32 0x%06x 0x%08x\n", addr, data); nv_spam(subdev, "nv_rd32 0x%06x 0x%08x\n", addr, data);
return data; return data;
...@@ -89,7 +88,7 @@ nv_rd32(void *obj, u32 addr) ...@@ -89,7 +88,7 @@ nv_rd32(void *obj, u32 addr)
static inline void static inline void
nv_wr08(void *obj, u32 addr, u8 data) nv_wr08(void *obj, u32 addr, u8 data)
{ {
struct nouveau_subdev *subdev = nv_subdev(obj); struct nvkm_subdev *subdev = nv_subdev(obj);
nv_spam(subdev, "nv_wr08 0x%06x 0x%02x\n", addr, data); nv_spam(subdev, "nv_wr08 0x%06x 0x%02x\n", addr, data);
iowrite8(data, subdev->mmio + addr); iowrite8(data, subdev->mmio + addr);
} }
...@@ -97,7 +96,7 @@ nv_wr08(void *obj, u32 addr, u8 data) ...@@ -97,7 +96,7 @@ nv_wr08(void *obj, u32 addr, u8 data)
static inline void static inline void
nv_wr16(void *obj, u32 addr, u16 data) nv_wr16(void *obj, u32 addr, u16 data)
{ {
struct nouveau_subdev *subdev = nv_subdev(obj); struct nvkm_subdev *subdev = nv_subdev(obj);
nv_spam(subdev, "nv_wr16 0x%06x 0x%04x\n", addr, data); nv_spam(subdev, "nv_wr16 0x%06x 0x%04x\n", addr, data);
iowrite16_native(data, subdev->mmio + addr); iowrite16_native(data, subdev->mmio + addr);
} }
...@@ -105,7 +104,7 @@ nv_wr16(void *obj, u32 addr, u16 data) ...@@ -105,7 +104,7 @@ nv_wr16(void *obj, u32 addr, u16 data)
static inline void static inline void
nv_wr32(void *obj, u32 addr, u32 data) nv_wr32(void *obj, u32 addr, u32 data)
{ {
struct nouveau_subdev *subdev = nv_subdev(obj); struct nvkm_subdev *subdev = nv_subdev(obj);
nv_spam(subdev, "nv_wr32 0x%06x 0x%08x\n", addr, data); nv_spam(subdev, "nv_wr32 0x%06x 0x%08x\n", addr, data);
iowrite32_native(data, subdev->mmio + addr); iowrite32_native(data, subdev->mmio + addr);
} }
...@@ -117,5 +116,4 @@ nv_mask(void *obj, u32 addr, u32 mask, u32 data) ...@@ -117,5 +116,4 @@ nv_mask(void *obj, u32 addr, u32 mask, u32 data)
nv_wr32(obj, addr, (temp & ~mask) | data); nv_wr32(obj, addr, (temp & ~mask) | data);
return temp; return temp;
} }
#endif #endif
...@@ -27,7 +27,4 @@ int nv50_identify(struct nouveau_device *); ...@@ -27,7 +27,4 @@ int nv50_identify(struct nouveau_device *);
int nvc0_identify(struct nouveau_device *); int nvc0_identify(struct nouveau_device *);
int nve0_identify(struct nouveau_device *); int nve0_identify(struct nouveau_device *);
int gm100_identify(struct nouveau_device *); int gm100_identify(struct nouveau_device *);
struct nouveau_device *nouveau_device_find(u64 name);
#endif #endif
#ifndef __NOUVEAU_FALCON_H__ #ifndef __NVKM_FALCON_H__
#define __NOUVEAU_FALCON_H__ #define __NVKM_FALCON_H__
#include <core/engine.h>
#include <core/engctx.h> #include <core/engctx.h>
#include <core/gpuobj.h>
struct nouveau_falcon_chan { struct nvkm_falcon_chan {
struct nouveau_engctx base; struct nvkm_engctx base;
}; };
#define nouveau_falcon_context_create(p,e,c,g,s,a,f,d) \ #define nvkm_falcon_context_create(p,e,c,g,s,a,f,d) \
nouveau_engctx_create((p), (e), (c), (g), (s), (a), (f), (d)) nvkm_engctx_create((p), (e), (c), (g), (s), (a), (f), (d))
#define nouveau_falcon_context_destroy(d) \ #define nvkm_falcon_context_destroy(d) \
nouveau_engctx_destroy(&(d)->base) nvkm_engctx_destroy(&(d)->base)
#define nouveau_falcon_context_init(d) \ #define nvkm_falcon_context_init(d) \
nouveau_engctx_init(&(d)->base) nvkm_engctx_init(&(d)->base)
#define nouveau_falcon_context_fini(d,s) \ #define nvkm_falcon_context_fini(d,s) \
nouveau_engctx_fini(&(d)->base, (s)) nvkm_engctx_fini(&(d)->base, (s))
#define _nouveau_falcon_context_ctor _nouveau_engctx_ctor #define _nvkm_falcon_context_ctor _nvkm_engctx_ctor
#define _nouveau_falcon_context_dtor _nouveau_engctx_dtor #define _nvkm_falcon_context_dtor _nvkm_engctx_dtor
#define _nouveau_falcon_context_init _nouveau_engctx_init #define _nvkm_falcon_context_init _nvkm_engctx_init
#define _nouveau_falcon_context_fini _nouveau_engctx_fini #define _nvkm_falcon_context_fini _nvkm_engctx_fini
#define _nouveau_falcon_context_rd32 _nouveau_engctx_rd32 #define _nvkm_falcon_context_rd32 _nvkm_engctx_rd32
#define _nouveau_falcon_context_wr32 _nouveau_engctx_wr32 #define _nvkm_falcon_context_wr32 _nvkm_engctx_wr32
struct nouveau_falcon_data { struct nvkm_falcon_data {
bool external; bool external;
}; };
struct nouveau_falcon { #include <core/engine.h>
struct nouveau_engine base;
struct nvkm_falcon {
struct nvkm_engine base;
u32 addr; u32 addr;
u8 version; u8 version;
u8 secret; u8 secret;
struct nouveau_gpuobj *core; struct nvkm_gpuobj *core;
bool external; bool external;
struct { struct {
...@@ -54,30 +53,29 @@ struct nouveau_falcon { ...@@ -54,30 +53,29 @@ struct nouveau_falcon {
#define nv_falcon(priv) (&(priv)->base) #define nv_falcon(priv) (&(priv)->base)
#define nouveau_falcon_create(p,e,c,b,d,i,f,r) \ #define nvkm_falcon_create(p,e,c,b,d,i,f,r) \
nouveau_falcon_create_((p), (e), (c), (b), (d), (i), (f), \ nvkm_falcon_create_((p), (e), (c), (b), (d), (i), (f), \
sizeof(**r),(void **)r) sizeof(**r),(void **)r)
#define nouveau_falcon_destroy(p) \ #define nvkm_falcon_destroy(p) \
nouveau_engine_destroy(&(p)->base) nvkm_engine_destroy(&(p)->base)
#define nouveau_falcon_init(p) ({ \ #define nvkm_falcon_init(p) ({ \
struct nouveau_falcon *falcon = (p); \ struct nvkm_falcon *falcon = (p); \
_nouveau_falcon_init(nv_object(falcon)); \ _nvkm_falcon_init(nv_object(falcon)); \
}) })
#define nouveau_falcon_fini(p,s) ({ \ #define nvkm_falcon_fini(p,s) ({ \
struct nouveau_falcon *falcon = (p); \ struct nvkm_falcon *falcon = (p); \
_nouveau_falcon_fini(nv_object(falcon), (s)); \ _nvkm_falcon_fini(nv_object(falcon), (s)); \
}) })
int nouveau_falcon_create_(struct nouveau_object *, struct nouveau_object *, int nvkm_falcon_create_(struct nvkm_object *, struct nvkm_object *,
struct nouveau_oclass *, u32, bool, const char *, struct nvkm_oclass *, u32, bool, const char *,
const char *, int, void **); const char *, int, void **);
void nouveau_falcon_intr(struct nouveau_subdev *subdev); void nvkm_falcon_intr(struct nvkm_subdev *subdev);
#define _nouveau_falcon_dtor _nouveau_engine_dtor
int _nouveau_falcon_init(struct nouveau_object *);
int _nouveau_falcon_fini(struct nouveau_object *, bool);
u32 _nouveau_falcon_rd32(struct nouveau_object *, u64);
void _nouveau_falcon_wr32(struct nouveau_object *, u64, u32);
#define _nvkm_falcon_dtor _nvkm_engine_dtor
int _nvkm_falcon_init(struct nvkm_object *);
int _nvkm_falcon_fini(struct nvkm_object *, bool);
u32 _nvkm_falcon_rd32(struct nvkm_object *, u64);
void _nvkm_falcon_wr32(struct nvkm_object *, u64, u32);
#endif #endif
#ifndef __NOUVEAU_XTENSA_H__ #ifndef __NVKM_XTENSA_H__
#define __NOUVEAU_XTENSA_H__ #define __NVKM_XTENSA_H__
#include <core/engine.h> #include <core/engine.h>
#include <core/engctx.h> struct nvkm_gpuobj;
#include <core/gpuobj.h>
struct nouveau_xtensa { struct nvkm_xtensa {
struct nouveau_engine base; struct nvkm_engine base;
u32 addr; u32 addr;
struct nouveau_gpuobj *gpu_fw; struct nvkm_gpuobj *gpu_fw;
u32 fifo_val; u32 fifo_val;
u32 unkd28; u32 unkd28;
}; };
#define nouveau_xtensa_create(p,e,c,b,d,i,f,r) \ #define nvkm_xtensa_create(p,e,c,b,d,i,f,r) \
nouveau_xtensa_create_((p), (e), (c), (b), (d), (i), (f), \ nvkm_xtensa_create_((p), (e), (c), (b), (d), (i), (f), \
sizeof(**r),(void **)r) sizeof(**r),(void **)r)
int _nouveau_xtensa_engctx_ctor(struct nouveau_object *, int _nvkm_xtensa_engctx_ctor(struct nvkm_object *,
struct nouveau_object *, struct nvkm_object *,
struct nouveau_oclass *, void *, u32, struct nvkm_oclass *, void *, u32,
struct nouveau_object **); struct nvkm_object **);
void _nouveau_xtensa_intr(struct nouveau_subdev *); void _nvkm_xtensa_intr(struct nvkm_subdev *);
int nouveau_xtensa_create_(struct nouveau_object *, int nvkm_xtensa_create_(struct nvkm_object *,
struct nouveau_object *, struct nvkm_object *,
struct nouveau_oclass *, u32, bool, struct nvkm_oclass *, u32, bool,
const char *, const char *, const char *, const char *,
int, void **); int, void **);
#define _nouveau_xtensa_dtor _nouveau_engine_dtor #define _nvkm_xtensa_dtor _nvkm_engine_dtor
int _nouveau_xtensa_init(struct nouveau_object *); int _nvkm_xtensa_init(struct nvkm_object *);
int _nouveau_xtensa_fini(struct nouveau_object *, bool); int _nvkm_xtensa_fini(struct nvkm_object *, bool);
u32 _nouveau_xtensa_rd32(struct nouveau_object *, u64); u32 _nvkm_xtensa_rd32(struct nvkm_object *, u64);
void _nouveau_xtensa_wr32(struct nouveau_object *, u64, u32); void _nvkm_xtensa_wr32(struct nvkm_object *, u64, u32);
#endif #endif
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define __NOUVEAU_CLK_H__ #define __NOUVEAU_CLK_H__
#include <core/device.h> #include <core/device.h>
#include <core/notify.h>
#include <core/subdev.h> #include <core/subdev.h>
struct nouveau_pll_vals; struct nouveau_pll_vals;
......
...@@ -70,7 +70,7 @@ nvkm_client_suspend(void *priv) ...@@ -70,7 +70,7 @@ nvkm_client_suspend(void *priv)
} }
static void static void
nvkm_client_fini(void *priv) nvkm_client_driver_fini(void *priv)
{ {
struct nouveau_object *client = priv; struct nouveau_object *client = priv;
nouveau_client_fini(nv_client(client), false); nouveau_client_fini(nv_client(client), false);
...@@ -107,8 +107,8 @@ nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size) ...@@ -107,8 +107,8 @@ nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size)
} }
static int static int
nvkm_client_init(const char *name, u64 device, const char *cfg, nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
const char *dbg, void **ppriv) const char *dbg, void **ppriv)
{ {
struct nouveau_client *client; struct nouveau_client *client;
int ret; int ret;
...@@ -125,8 +125,8 @@ nvkm_client_init(const char *name, u64 device, const char *cfg, ...@@ -125,8 +125,8 @@ nvkm_client_init(const char *name, u64 device, const char *cfg,
const struct nvif_driver const struct nvif_driver
nvif_driver_nvkm = { nvif_driver_nvkm = {
.name = "nvkm", .name = "nvkm",
.init = nvkm_client_init, .init = nvkm_client_driver_init,
.fini = nvkm_client_fini, .fini = nvkm_client_driver_fini,
.suspend = nvkm_client_suspend, .suspend = nvkm_client_suspend,
.resume = nvkm_client_resume, .resume = nvkm_client_resume,
.ioctl = nvkm_client_ioctl, .ioctl = nvkm_client_ioctl,
......
...@@ -92,7 +92,7 @@ nvif_notify_func(struct nvif_notify *notify, bool keep) ...@@ -92,7 +92,7 @@ nvif_notify_func(struct nvif_notify *notify, bool keep)
{ {
int ret = notify->func(notify); int ret = notify->func(notify);
if (ret == NVIF_NOTIFY_KEEP || if (ret == NVIF_NOTIFY_KEEP ||
!test_and_clear_bit(NVKM_NOTIFY_USER, &notify->flags)) { !test_and_clear_bit(NVIF_NOTIFY_USER, &notify->flags)) {
if (!keep) if (!keep)
atomic_dec(&notify->putcnt); atomic_dec(&notify->putcnt);
else else
......
...@@ -21,21 +21,18 @@ ...@@ -21,21 +21,18 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/client.h> #include <core/client.h>
#include <core/device.h>
#include <core/handle.h> #include <core/handle.h>
#include <core/notify.h>
#include <core/option.h> #include <core/option.h>
#include <nvif/unpack.h>
#include <nvif/class.h>
#include <nvif/unpack.h> #include <nvif/class.h>
#include <nvif/event.h> #include <nvif/event.h>
#include <nvif/unpack.h>
#include <engine/device.h>
struct nvkm_client_notify { struct nvkm_client_notify {
struct nouveau_client *client; struct nvkm_client *client;
struct nvkm_notify n; struct nvkm_notify n;
u8 version; u8 version;
u8 size; u8 size;
...@@ -48,12 +45,12 @@ static int ...@@ -48,12 +45,12 @@ static int
nvkm_client_notify(struct nvkm_notify *n) nvkm_client_notify(struct nvkm_notify *n)
{ {
struct nvkm_client_notify *notify = container_of(n, typeof(*notify), n); struct nvkm_client_notify *notify = container_of(n, typeof(*notify), n);
struct nouveau_client *client = notify->client; struct nvkm_client *client = notify->client;
return client->ntfy(&notify->rep, notify->size, n->data, n->size); return client->ntfy(&notify->rep, notify->size, n->data, n->size);
} }
int int
nvkm_client_notify_put(struct nouveau_client *client, int index) nvkm_client_notify_put(struct nvkm_client *client, int index)
{ {
if (index < ARRAY_SIZE(client->notify)) { if (index < ARRAY_SIZE(client->notify)) {
if (client->notify[index]) { if (client->notify[index]) {
...@@ -65,7 +62,7 @@ nvkm_client_notify_put(struct nouveau_client *client, int index) ...@@ -65,7 +62,7 @@ nvkm_client_notify_put(struct nouveau_client *client, int index)
} }
int int
nvkm_client_notify_get(struct nouveau_client *client, int index) nvkm_client_notify_get(struct nvkm_client *client, int index)
{ {
if (index < ARRAY_SIZE(client->notify)) { if (index < ARRAY_SIZE(client->notify)) {
if (client->notify[index]) { if (client->notify[index]) {
...@@ -77,7 +74,7 @@ nvkm_client_notify_get(struct nouveau_client *client, int index) ...@@ -77,7 +74,7 @@ nvkm_client_notify_get(struct nouveau_client *client, int index)
} }
int int
nvkm_client_notify_del(struct nouveau_client *client, int index) nvkm_client_notify_del(struct nvkm_client *client, int index)
{ {
if (index < ARRAY_SIZE(client->notify)) { if (index < ARRAY_SIZE(client->notify)) {
if (client->notify[index]) { if (client->notify[index]) {
...@@ -91,10 +88,10 @@ nvkm_client_notify_del(struct nouveau_client *client, int index) ...@@ -91,10 +88,10 @@ nvkm_client_notify_del(struct nouveau_client *client, int index)
} }
int int
nvkm_client_notify_new(struct nouveau_object *object, nvkm_client_notify_new(struct nvkm_object *object,
struct nvkm_event *event, void *data, u32 size) struct nvkm_event *event, void *data, u32 size)
{ {
struct nouveau_client *client = nouveau_client(object); struct nvkm_client *client = nvkm_client(object);
struct nvkm_client_notify *notify; struct nvkm_client_notify *notify;
union { union {
struct nvif_notify_req_v0 v0; struct nvif_notify_req_v0 v0;
...@@ -142,7 +139,7 @@ nvkm_client_notify_new(struct nouveau_object *object, ...@@ -142,7 +139,7 @@ nvkm_client_notify_new(struct nouveau_object *object,
} }
static int static int
nouveau_client_devlist(struct nouveau_object *object, void *data, u32 size) nvkm_client_mthd_devlist(struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nv_client_devlist_v0 v0; struct nv_client_devlist_v0 v0;
...@@ -154,8 +151,7 @@ nouveau_client_devlist(struct nouveau_object *object, void *data, u32 size) ...@@ -154,8 +151,7 @@ nouveau_client_devlist(struct nouveau_object *object, void *data, u32 size)
nv_ioctl(object, "client devlist vers %d count %d\n", nv_ioctl(object, "client devlist vers %d count %d\n",
args->v0.version, args->v0.count); args->v0.version, args->v0.count);
if (size == sizeof(args->v0.device[0]) * args->v0.count) { if (size == sizeof(args->v0.device[0]) * args->v0.count) {
ret = nouveau_device_list(args->v0.device, ret = nvkm_device_list(args->v0.device, args->v0.count);
args->v0.count);
if (ret >= 0) { if (ret >= 0) {
args->v0.count = ret; args->v0.count = ret;
ret = 0; ret = 0;
...@@ -169,12 +165,11 @@ nouveau_client_devlist(struct nouveau_object *object, void *data, u32 size) ...@@ -169,12 +165,11 @@ nouveau_client_devlist(struct nouveau_object *object, void *data, u32 size)
} }
static int static int
nouveau_client_mthd(struct nouveau_object *object, u32 mthd, nvkm_client_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
void *data, u32 size)
{ {
switch (mthd) { switch (mthd) {
case NV_CLIENT_DEVLIST: case NV_CLIENT_DEVLIST:
return nouveau_client_devlist(object, data, size); return nvkm_client_mthd_devlist(object, data, size);
default: default:
break; break;
} }
...@@ -182,71 +177,71 @@ nouveau_client_mthd(struct nouveau_object *object, u32 mthd, ...@@ -182,71 +177,71 @@ nouveau_client_mthd(struct nouveau_object *object, u32 mthd,
} }
static void static void
nouveau_client_dtor(struct nouveau_object *object) nvkm_client_dtor(struct nvkm_object *object)
{ {
struct nouveau_client *client = (void *)object; struct nvkm_client *client = (void *)object;
int i; int i;
for (i = 0; i < ARRAY_SIZE(client->notify); i++) for (i = 0; i < ARRAY_SIZE(client->notify); i++)
nvkm_client_notify_del(client, i); nvkm_client_notify_del(client, i);
nouveau_object_ref(NULL, &client->device); nvkm_object_ref(NULL, &client->device);
nouveau_handle_destroy(client->root); nvkm_handle_destroy(client->root);
nouveau_namedb_destroy(&client->namedb); nvkm_namedb_destroy(&client->namedb);
} }
static struct nouveau_oclass static struct nvkm_oclass
nouveau_client_oclass = { nvkm_client_oclass = {
.ofuncs = &(struct nouveau_ofuncs) { .ofuncs = &(struct nvkm_ofuncs) {
.dtor = nouveau_client_dtor, .dtor = nvkm_client_dtor,
.mthd = nouveau_client_mthd, .mthd = nvkm_client_mthd,
}, },
}; };
int int
nouveau_client_create_(const char *name, u64 devname, const char *cfg, nvkm_client_create_(const char *name, u64 devname, const char *cfg,
const char *dbg, int length, void **pobject) const char *dbg, int length, void **pobject)
{ {
struct nouveau_object *device; struct nvkm_object *device;
struct nouveau_client *client; struct nvkm_client *client;
int ret; int ret;
device = (void *)nouveau_device_find(devname); device = (void *)nvkm_device_find(devname);
if (!device) if (!device)
return -ENODEV; return -ENODEV;
ret = nouveau_namedb_create_(NULL, NULL, &nouveau_client_oclass, ret = nvkm_namedb_create_(NULL, NULL, &nvkm_client_oclass,
NV_CLIENT_CLASS, NULL, NV_CLIENT_CLASS, NULL,
(1ULL << NVDEV_ENGINE_DEVICE), (1ULL << NVDEV_ENGINE_DEVICE),
length, pobject); length, pobject);
client = *pobject; client = *pobject;
if (ret) if (ret)
return ret; return ret;
ret = nouveau_handle_create(nv_object(client), ~0, ~0, ret = nvkm_handle_create(nv_object(client), ~0, ~0, nv_object(client),
nv_object(client), &client->root); &client->root);
if (ret) if (ret)
return ret; return ret;
/* prevent init/fini being called, os in in charge of this */ /* prevent init/fini being called, os in in charge of this */
atomic_set(&nv_object(client)->usecount, 2); atomic_set(&nv_object(client)->usecount, 2);
nouveau_object_ref(device, &client->device); nvkm_object_ref(device, &client->device);
snprintf(client->name, sizeof(client->name), "%s", name); snprintf(client->name, sizeof(client->name), "%s", name);
client->debug = nouveau_dbgopt(dbg, "CLIENT"); client->debug = nvkm_dbgopt(dbg, "CLIENT");
return 0; return 0;
} }
int int
nouveau_client_init(struct nouveau_client *client) nvkm_client_init(struct nvkm_client *client)
{ {
int ret; int ret;
nv_debug(client, "init running\n"); nv_debug(client, "init running\n");
ret = nouveau_handle_init(client->root); ret = nvkm_handle_init(client->root);
nv_debug(client, "init completed with %d\n", ret); nv_debug(client, "init completed with %d\n", ret);
return ret; return ret;
} }
int int
nouveau_client_fini(struct nouveau_client *client, bool suspend) nvkm_client_fini(struct nvkm_client *client, bool suspend)
{ {
const char *name[2] = { "fini", "suspend" }; const char *name[2] = { "fini", "suspend" };
int ret, i; int ret, i;
...@@ -255,16 +250,16 @@ nouveau_client_fini(struct nouveau_client *client, bool suspend) ...@@ -255,16 +250,16 @@ nouveau_client_fini(struct nouveau_client *client, bool suspend)
for (i = 0; i < ARRAY_SIZE(client->notify); i++) for (i = 0; i < ARRAY_SIZE(client->notify); i++)
nvkm_client_notify_put(client, i); nvkm_client_notify_put(client, i);
nv_debug(client, "%s object\n", name[suspend]); nv_debug(client, "%s object\n", name[suspend]);
ret = nouveau_handle_fini(client->root, suspend); ret = nvkm_handle_fini(client->root, suspend);
nv_debug(client, "%s completed with %d\n", name[suspend], ret); nv_debug(client, "%s completed with %d\n", name[suspend], ret);
return ret; return ret;
} }
const char * const char *
nouveau_client_name(void *obj) nvkm_client_name(void *obj)
{ {
const char *client_name = "unknown"; const char *client_name = "unknown";
struct nouveau_client *client = nouveau_client(obj); struct nvkm_client *client = nvkm_client(obj);
if (client) if (client)
client_name = client->name; client_name = client->name;
return client_name; return client_name;
......
...@@ -21,21 +21,15 @@ ...@@ -21,21 +21,15 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/namedb.h>
#include <core/handle.h>
#include <core/client.h>
#include <core/engctx.h> #include <core/engctx.h>
#include <core/client.h>
#include <subdev/mmu.h>
static inline int static inline int
nouveau_engctx_exists(struct nouveau_object *parent, nvkm_engctx_exists(struct nvkm_object *parent,
struct nouveau_engine *engine, void **pobject) struct nvkm_engine *engine, void **pobject)
{ {
struct nouveau_engctx *engctx; struct nvkm_engctx *engctx;
struct nouveau_object *parctx; struct nvkm_object *parctx;
list_for_each_entry(engctx, &engine->contexts, head) { list_for_each_entry(engctx, &engine->contexts, head) {
parctx = nv_pclass(nv_object(engctx), NV_PARENT_CLASS); parctx = nv_pclass(nv_object(engctx), NV_PARENT_CLASS);
...@@ -50,16 +44,13 @@ nouveau_engctx_exists(struct nouveau_object *parent, ...@@ -50,16 +44,13 @@ nouveau_engctx_exists(struct nouveau_object *parent,
} }
int int
nouveau_engctx_create_(struct nouveau_object *parent, nvkm_engctx_create_(struct nvkm_object *parent, struct nvkm_object *engobj,
struct nouveau_object *engobj, struct nvkm_oclass *oclass, struct nvkm_object *pargpu,
struct nouveau_oclass *oclass, u32 size, u32 align, u32 flags, int length, void **pobject)
struct nouveau_object *pargpu,
u32 size, u32 align, u32 flags,
int length, void **pobject)
{ {
struct nouveau_client *client = nouveau_client(parent); struct nvkm_client *client = nvkm_client(parent);
struct nouveau_engine *engine = nv_engine(engobj); struct nvkm_engine *engine = nv_engine(engobj);
struct nouveau_object *engctx; struct nvkm_object *engctx;
unsigned long save; unsigned long save;
int ret; int ret;
...@@ -67,7 +58,7 @@ nouveau_engctx_create_(struct nouveau_object *parent, ...@@ -67,7 +58,7 @@ nouveau_engctx_create_(struct nouveau_object *parent,
* and reference it instead of creating a new one * and reference it instead of creating a new one
*/ */
spin_lock_irqsave(&engine->lock, save); spin_lock_irqsave(&engine->lock, save);
ret = nouveau_engctx_exists(parent, engine, pobject); ret = nvkm_engctx_exists(parent, engine, pobject);
spin_unlock_irqrestore(&engine->lock, save); spin_unlock_irqrestore(&engine->lock, save);
if (ret) if (ret)
return ret; return ret;
...@@ -76,13 +67,12 @@ nouveau_engctx_create_(struct nouveau_object *parent, ...@@ -76,13 +67,12 @@ nouveau_engctx_create_(struct nouveau_object *parent,
* objects backed by instance memory * objects backed by instance memory
*/ */
if (size) { if (size) {
ret = nouveau_gpuobj_create_(parent, engobj, oclass, ret = nvkm_gpuobj_create_(parent, engobj, oclass,
NV_ENGCTX_CLASS, NV_ENGCTX_CLASS, pargpu, size,
pargpu, size, align, flags, align, flags, length, pobject);
length, pobject);
} else { } else {
ret = nouveau_object_create_(parent, engobj, oclass, ret = nvkm_object_create_(parent, engobj, oclass,
NV_ENGCTX_CLASS, length, pobject); NV_ENGCTX_CLASS, length, pobject);
} }
engctx = *pobject; engctx = *pobject;
...@@ -94,10 +84,10 @@ nouveau_engctx_create_(struct nouveau_object *parent, ...@@ -94,10 +84,10 @@ nouveau_engctx_create_(struct nouveau_object *parent,
* it's not possible to allocate the object with it held. * it's not possible to allocate the object with it held.
*/ */
spin_lock_irqsave(&engine->lock, save); spin_lock_irqsave(&engine->lock, save);
ret = nouveau_engctx_exists(parent, engine, pobject); ret = nvkm_engctx_exists(parent, engine, pobject);
if (ret) { if (ret) {
spin_unlock_irqrestore(&engine->lock, save); spin_unlock_irqrestore(&engine->lock, save);
nouveau_object_ref(NULL, &engctx); nvkm_object_ref(NULL, &engctx);
return ret; return ret;
} }
...@@ -110,13 +100,13 @@ nouveau_engctx_create_(struct nouveau_object *parent, ...@@ -110,13 +100,13 @@ nouveau_engctx_create_(struct nouveau_object *parent,
} }
void void
nouveau_engctx_destroy(struct nouveau_engctx *engctx) nvkm_engctx_destroy(struct nvkm_engctx *engctx)
{ {
struct nouveau_engine *engine = engctx->gpuobj.object.engine; struct nvkm_engine *engine = engctx->gpuobj.object.engine;
struct nouveau_client *client = nouveau_client(engctx); struct nvkm_client *client = nvkm_client(engctx);
unsigned long save; unsigned long save;
nouveau_gpuobj_unmap(&engctx->vma); nvkm_gpuobj_unmap(&engctx->vma);
spin_lock_irqsave(&engine->lock, save); spin_lock_irqsave(&engine->lock, save);
list_del(&engctx->head); list_del(&engctx->head);
spin_unlock_irqrestore(&engine->lock, save); spin_unlock_irqrestore(&engine->lock, save);
...@@ -125,21 +115,21 @@ nouveau_engctx_destroy(struct nouveau_engctx *engctx) ...@@ -125,21 +115,21 @@ nouveau_engctx_destroy(struct nouveau_engctx *engctx)
atomic_dec(&client->vm->engref[nv_engidx(engine)]); atomic_dec(&client->vm->engref[nv_engidx(engine)]);
if (engctx->gpuobj.size) if (engctx->gpuobj.size)
nouveau_gpuobj_destroy(&engctx->gpuobj); nvkm_gpuobj_destroy(&engctx->gpuobj);
else else
nouveau_object_destroy(&engctx->gpuobj.object); nvkm_object_destroy(&engctx->gpuobj.object);
} }
int int
nouveau_engctx_init(struct nouveau_engctx *engctx) nvkm_engctx_init(struct nvkm_engctx *engctx)
{ {
struct nouveau_object *object = nv_object(engctx); struct nvkm_object *object = nv_object(engctx);
struct nouveau_subdev *subdev = nv_subdev(object->engine); struct nvkm_subdev *subdev = nv_subdev(object->engine);
struct nouveau_object *parent; struct nvkm_object *parent;
struct nouveau_subdev *pardev; struct nvkm_subdev *pardev;
int ret; int ret;
ret = nouveau_gpuobj_init(&engctx->gpuobj); ret = nvkm_gpuobj_init(&engctx->gpuobj);
if (ret) if (ret)
return ret; return ret;
...@@ -162,12 +152,12 @@ nouveau_engctx_init(struct nouveau_engctx *engctx) ...@@ -162,12 +152,12 @@ nouveau_engctx_init(struct nouveau_engctx *engctx)
} }
int int
nouveau_engctx_fini(struct nouveau_engctx *engctx, bool suspend) nvkm_engctx_fini(struct nvkm_engctx *engctx, bool suspend)
{ {
struct nouveau_object *object = nv_object(engctx); struct nvkm_object *object = nv_object(engctx);
struct nouveau_subdev *subdev = nv_subdev(object->engine); struct nvkm_subdev *subdev = nv_subdev(object->engine);
struct nouveau_object *parent; struct nvkm_object *parent;
struct nouveau_subdev *pardev; struct nvkm_subdev *pardev;
int ret = 0; int ret = 0;
parent = nv_pclass(object->parent, NV_PARENT_CLASS); parent = nv_pclass(object->parent, NV_PARENT_CLASS);
...@@ -185,47 +175,45 @@ nouveau_engctx_fini(struct nouveau_engctx *engctx, bool suspend) ...@@ -185,47 +175,45 @@ nouveau_engctx_fini(struct nouveau_engctx *engctx, bool suspend)
} }
nv_debug(parent, "detached %s context\n", subdev->name); nv_debug(parent, "detached %s context\n", subdev->name);
return nouveau_gpuobj_fini(&engctx->gpuobj, suspend); return nvkm_gpuobj_fini(&engctx->gpuobj, suspend);
} }
int int
_nouveau_engctx_ctor(struct nouveau_object *parent, _nvkm_engctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, void *data, u32 size,
struct nouveau_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject)
struct nouveau_object **pobject)
{ {
struct nouveau_engctx *engctx; struct nvkm_engctx *engctx;
int ret; int ret;
ret = nouveau_engctx_create(parent, engine, oclass, NULL, 256, 256, ret = nvkm_engctx_create(parent, engine, oclass, NULL, 256, 256,
NVOBJ_FLAG_ZERO_ALLOC, &engctx); NVOBJ_FLAG_ZERO_ALLOC, &engctx);
*pobject = nv_object(engctx); *pobject = nv_object(engctx);
return ret; return ret;
} }
void void
_nouveau_engctx_dtor(struct nouveau_object *object) _nvkm_engctx_dtor(struct nvkm_object *object)
{ {
nouveau_engctx_destroy(nv_engctx(object)); nvkm_engctx_destroy(nv_engctx(object));
} }
int int
_nouveau_engctx_init(struct nouveau_object *object) _nvkm_engctx_init(struct nvkm_object *object)
{ {
return nouveau_engctx_init(nv_engctx(object)); return nvkm_engctx_init(nv_engctx(object));
} }
int int
_nouveau_engctx_fini(struct nouveau_object *object, bool suspend) _nvkm_engctx_fini(struct nvkm_object *object, bool suspend)
{ {
return nouveau_engctx_fini(nv_engctx(object), suspend); return nvkm_engctx_fini(nv_engctx(object), suspend);
} }
struct nouveau_object * struct nvkm_object *
nouveau_engctx_get(struct nouveau_engine *engine, u64 addr) nvkm_engctx_get(struct nvkm_engine *engine, u64 addr)
{ {
struct nouveau_engctx *engctx; struct nvkm_engctx *engctx;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&engine->lock, flags); spin_lock_irqsave(&engine->lock, flags);
...@@ -240,11 +228,11 @@ nouveau_engctx_get(struct nouveau_engine *engine, u64 addr) ...@@ -240,11 +228,11 @@ nouveau_engctx_get(struct nouveau_engine *engine, u64 addr)
} }
void void
nouveau_engctx_put(struct nouveau_object *object) nvkm_engctx_put(struct nvkm_object *object)
{ {
if (object) { if (object) {
struct nouveau_engine *engine = nv_engine(object->engine); struct nvkm_engine *engine = nv_engine(object->engine);
struct nouveau_engctx *engctx = nv_engctx(object); struct nvkm_engctx *engctx = nv_engctx(object);
spin_unlock_irqrestore(&engine->lock, engctx->save); spin_unlock_irqrestore(&engine->lock, engctx->save);
} }
} }
...@@ -21,42 +21,40 @@ ...@@ -21,42 +21,40 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/device.h>
#include <core/engine.h> #include <core/engine.h>
#include <core/device.h>
#include <core/option.h> #include <core/option.h>
struct nouveau_engine * struct nvkm_engine *
nouveau_engine(void *obj, int idx) nvkm_engine(void *obj, int idx)
{ {
obj = nouveau_subdev(obj, idx); obj = nvkm_subdev(obj, idx);
if (obj && nv_iclass(obj, NV_ENGINE_CLASS)) if (obj && nv_iclass(obj, NV_ENGINE_CLASS))
return nv_engine(obj); return nv_engine(obj);
return NULL; return NULL;
} }
int int
nouveau_engine_create_(struct nouveau_object *parent, nvkm_engine_create_(struct nvkm_object *parent, struct nvkm_object *engobj,
struct nouveau_object *engobj, struct nvkm_oclass *oclass, bool enable,
struct nouveau_oclass *oclass, bool enable, const char *iname, const char *fname,
const char *iname, const char *fname, int length, void **pobject)
int length, void **pobject)
{ {
struct nouveau_engine *engine; struct nvkm_engine *engine;
int ret; int ret;
ret = nouveau_subdev_create_(parent, engobj, oclass, NV_ENGINE_CLASS, ret = nvkm_subdev_create_(parent, engobj, oclass, NV_ENGINE_CLASS,
iname, fname, length, pobject); iname, fname, length, pobject);
engine = *pobject; engine = *pobject;
if (ret) if (ret)
return ret; return ret;
if (parent) { if (parent) {
struct nouveau_device *device = nv_device(parent); struct nvkm_device *device = nv_device(parent);
int engidx = nv_engidx(engine); int engidx = nv_engidx(engine);
if (device->disable_mask & (1ULL << engidx)) { if (device->disable_mask & (1ULL << engidx)) {
if (!nouveau_boolopt(device->cfgopt, iname, false)) { if (!nvkm_boolopt(device->cfgopt, iname, false)) {
nv_debug(engine, "engine disabled by hw/fw\n"); nv_debug(engine, "engine disabled by hw/fw\n");
return -ENODEV; return -ENODEV;
} }
...@@ -64,7 +62,7 @@ nouveau_engine_create_(struct nouveau_object *parent, ...@@ -64,7 +62,7 @@ nouveau_engine_create_(struct nouveau_object *parent,
nv_warn(engine, "ignoring hw/fw engine disable\n"); nv_warn(engine, "ignoring hw/fw engine disable\n");
} }
if (!nouveau_boolopt(device->cfgopt, iname, enable)) { if (!nvkm_boolopt(device->cfgopt, iname, enable)) {
if (!enable) if (!enable)
nv_warn(engine, "disabled, %s=1 to enable\n", iname); nv_warn(engine, "disabled, %s=1 to enable\n", iname);
return -ENODEV; return -ENODEV;
......
...@@ -24,12 +24,10 @@ ...@@ -24,12 +24,10 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
*/ */
#include <core/os.h>
#include <core/enum.h> #include <core/enum.h>
const struct nouveau_enum * const struct nvkm_enum *
nouveau_enum_find(const struct nouveau_enum *en, u32 value) nvkm_enum_find(const struct nvkm_enum *en, u32 value)
{ {
while (en->name) { while (en->name) {
if (en->value == value) if (en->value == value)
...@@ -40,10 +38,10 @@ nouveau_enum_find(const struct nouveau_enum *en, u32 value) ...@@ -40,10 +38,10 @@ nouveau_enum_find(const struct nouveau_enum *en, u32 value)
return NULL; return NULL;
} }
const struct nouveau_enum * const struct nvkm_enum *
nouveau_enum_print(const struct nouveau_enum *en, u32 value) nvkm_enum_print(const struct nvkm_enum *en, u32 value)
{ {
en = nouveau_enum_find(en, value); en = nvkm_enum_find(en, value);
if (en) if (en)
pr_cont("%s", en->name); pr_cont("%s", en->name);
else else
...@@ -52,7 +50,7 @@ nouveau_enum_print(const struct nouveau_enum *en, u32 value) ...@@ -52,7 +50,7 @@ nouveau_enum_print(const struct nouveau_enum *en, u32 value)
} }
void void
nouveau_bitfield_print(const struct nouveau_bitfield *bf, u32 value) nvkm_bitfield_print(const struct nvkm_bitfield *bf, u32 value)
{ {
while (bf->name) { while (bf->name) {
if (value & bf->mask) { if (value & bf->mask) {
......
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <core/object.h>
#include <core/event.h> #include <core/event.h>
#include <core/notify.h>
void void
nvkm_event_put(struct nvkm_event *event, u32 types, int index) nvkm_event_put(struct nvkm_event *event, u32 types, int index)
......
This diff is collapsed.
...@@ -21,31 +21,29 @@ ...@@ -21,31 +21,29 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/handle.h> #include <core/handle.h>
#include <core/client.h> #include <core/client.h>
#define hprintk(h,l,f,a...) do { \ #define hprintk(h,l,f,a...) do { \
struct nouveau_client *c = nouveau_client((h)->object); \ struct nvkm_client *c = nvkm_client((h)->object); \
struct nouveau_handle *p = (h)->parent; u32 n = p ? p->name : ~0; \ struct nvkm_handle *p = (h)->parent; u32 n = p ? p->name : ~0; \
nv_printk((c), l, "0x%08x:0x%08x "f, n, (h)->name, ##a); \ nv_printk((c), l, "0x%08x:0x%08x "f, n, (h)->name, ##a); \
} while(0) } while(0)
int int
nouveau_handle_init(struct nouveau_handle *handle) nvkm_handle_init(struct nvkm_handle *handle)
{ {
struct nouveau_handle *item; struct nvkm_handle *item;
int ret; int ret;
hprintk(handle, TRACE, "init running\n"); hprintk(handle, TRACE, "init running\n");
ret = nouveau_object_inc(handle->object); ret = nvkm_object_inc(handle->object);
if (ret) if (ret)
return ret; return ret;
hprintk(handle, TRACE, "init children\n"); hprintk(handle, TRACE, "init children\n");
list_for_each_entry(item, &handle->tree, head) { list_for_each_entry(item, &handle->tree, head) {
ret = nouveau_handle_init(item); ret = nvkm_handle_init(item);
if (ret) if (ret)
goto fail; goto fail;
} }
...@@ -55,30 +53,30 @@ nouveau_handle_init(struct nouveau_handle *handle) ...@@ -55,30 +53,30 @@ nouveau_handle_init(struct nouveau_handle *handle)
fail: fail:
hprintk(handle, ERROR, "init failed with %d\n", ret); hprintk(handle, ERROR, "init failed with %d\n", ret);
list_for_each_entry_continue_reverse(item, &handle->tree, head) { list_for_each_entry_continue_reverse(item, &handle->tree, head) {
nouveau_handle_fini(item, false); nvkm_handle_fini(item, false);
} }
nouveau_object_dec(handle->object, false); nvkm_object_dec(handle->object, false);
return ret; return ret;
} }
int int
nouveau_handle_fini(struct nouveau_handle *handle, bool suspend) nvkm_handle_fini(struct nvkm_handle *handle, bool suspend)
{ {
static char *name[2] = { "fini", "suspend" }; static char *name[2] = { "fini", "suspend" };
struct nouveau_handle *item; struct nvkm_handle *item;
int ret; int ret;
hprintk(handle, TRACE, "%s children\n", name[suspend]); hprintk(handle, TRACE, "%s children\n", name[suspend]);
list_for_each_entry(item, &handle->tree, head) { list_for_each_entry(item, &handle->tree, head) {
ret = nouveau_handle_fini(item, suspend); ret = nvkm_handle_fini(item, suspend);
if (ret && suspend) if (ret && suspend)
goto fail; goto fail;
} }
hprintk(handle, TRACE, "%s running\n", name[suspend]); hprintk(handle, TRACE, "%s running\n", name[suspend]);
if (handle->object) { if (handle->object) {
ret = nouveau_object_dec(handle->object, suspend); ret = nvkm_object_dec(handle->object, suspend);
if (ret && suspend) if (ret && suspend)
goto fail; goto fail;
} }
...@@ -88,7 +86,7 @@ nouveau_handle_fini(struct nouveau_handle *handle, bool suspend) ...@@ -88,7 +86,7 @@ nouveau_handle_fini(struct nouveau_handle *handle, bool suspend)
fail: fail:
hprintk(handle, ERROR, "%s failed with %d\n", name[suspend], ret); hprintk(handle, ERROR, "%s failed with %d\n", name[suspend], ret);
list_for_each_entry_continue_reverse(item, &handle->tree, head) { list_for_each_entry_continue_reverse(item, &handle->tree, head) {
int rret = nouveau_handle_init(item); int rret = nvkm_handle_init(item);
if (rret) if (rret)
hprintk(handle, FATAL, "failed to restart, %d\n", rret); hprintk(handle, FATAL, "failed to restart, %d\n", rret);
} }
...@@ -97,12 +95,11 @@ nouveau_handle_fini(struct nouveau_handle *handle, bool suspend) ...@@ -97,12 +95,11 @@ nouveau_handle_fini(struct nouveau_handle *handle, bool suspend)
} }
int int
nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle, nvkm_handle_create(struct nvkm_object *parent, u32 _parent, u32 _handle,
struct nouveau_object *object, struct nvkm_object *object, struct nvkm_handle **phandle)
struct nouveau_handle **phandle)
{ {
struct nouveau_object *namedb; struct nvkm_object *namedb;
struct nouveau_handle *handle; struct nvkm_handle *handle;
int ret; int ret;
namedb = parent; namedb = parent;
...@@ -118,7 +115,7 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle, ...@@ -118,7 +115,7 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle,
handle->name = _handle; handle->name = _handle;
handle->priv = ~0; handle->priv = ~0;
ret = nouveau_namedb_insert(nv_namedb(namedb), _handle, object, handle); ret = nvkm_namedb_insert(nv_namedb(namedb), _handle, object, handle);
if (ret) { if (ret) {
kfree(handle); kfree(handle);
return ret; return ret;
...@@ -127,7 +124,7 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle, ...@@ -127,7 +124,7 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle,
if (nv_parent(parent)->object_attach) { if (nv_parent(parent)->object_attach) {
ret = nv_parent(parent)->object_attach(parent, object, _handle); ret = nv_parent(parent)->object_attach(parent, object, _handle);
if (ret < 0) { if (ret < 0) {
nouveau_handle_destroy(handle); nvkm_handle_destroy(handle);
return ret; return ret;
} }
...@@ -138,10 +135,10 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle, ...@@ -138,10 +135,10 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle,
while (!nv_iclass(namedb, NV_CLIENT_CLASS)) while (!nv_iclass(namedb, NV_CLIENT_CLASS))
namedb = namedb->parent; namedb = namedb->parent;
handle->parent = nouveau_namedb_get(nv_namedb(namedb), _parent); handle->parent = nvkm_namedb_get(nv_namedb(namedb), _parent);
if (handle->parent) { if (handle->parent) {
list_add(&handle->head, &handle->parent->tree); list_add(&handle->head, &handle->parent->tree);
nouveau_namedb_put(handle->parent); nvkm_namedb_put(handle->parent);
} }
} }
...@@ -151,74 +148,74 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle, ...@@ -151,74 +148,74 @@ nouveau_handle_create(struct nouveau_object *parent, u32 _parent, u32 _handle,
} }
void void
nouveau_handle_destroy(struct nouveau_handle *handle) nvkm_handle_destroy(struct nvkm_handle *handle)
{ {
struct nouveau_handle *item, *temp; struct nvkm_handle *item, *temp;
hprintk(handle, TRACE, "destroy running\n"); hprintk(handle, TRACE, "destroy running\n");
list_for_each_entry_safe(item, temp, &handle->tree, head) { list_for_each_entry_safe(item, temp, &handle->tree, head) {
nouveau_handle_destroy(item); nvkm_handle_destroy(item);
} }
list_del(&handle->head); list_del(&handle->head);
if (handle->priv != ~0) { if (handle->priv != ~0) {
struct nouveau_object *parent = handle->parent->object; struct nvkm_object *parent = handle->parent->object;
nv_parent(parent)->object_detach(parent, handle->priv); nv_parent(parent)->object_detach(parent, handle->priv);
} }
hprintk(handle, TRACE, "destroy completed\n"); hprintk(handle, TRACE, "destroy completed\n");
nouveau_namedb_remove(handle); nvkm_namedb_remove(handle);
kfree(handle); kfree(handle);
} }
struct nouveau_object * struct nvkm_object *
nouveau_handle_ref(struct nouveau_object *parent, u32 name) nvkm_handle_ref(struct nvkm_object *parent, u32 name)
{ {
struct nouveau_object *object = NULL; struct nvkm_object *object = NULL;
struct nouveau_handle *handle; struct nvkm_handle *handle;
while (!nv_iclass(parent, NV_NAMEDB_CLASS)) while (!nv_iclass(parent, NV_NAMEDB_CLASS))
parent = parent->parent; parent = parent->parent;
handle = nouveau_namedb_get(nv_namedb(parent), name); handle = nvkm_namedb_get(nv_namedb(parent), name);
if (handle) { if (handle) {
nouveau_object_ref(handle->object, &object); nvkm_object_ref(handle->object, &object);
nouveau_namedb_put(handle); nvkm_namedb_put(handle);
} }
return object; return object;
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_handle_get_class(struct nouveau_object *engctx, u16 oclass) nvkm_handle_get_class(struct nvkm_object *engctx, u16 oclass)
{ {
struct nouveau_namedb *namedb; struct nvkm_namedb *namedb;
if (engctx && (namedb = (void *)nv_pclass(engctx, NV_NAMEDB_CLASS))) if (engctx && (namedb = (void *)nv_pclass(engctx, NV_NAMEDB_CLASS)))
return nouveau_namedb_get_class(namedb, oclass); return nvkm_namedb_get_class(namedb, oclass);
return NULL; return NULL;
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_handle_get_vinst(struct nouveau_object *engctx, u64 vinst) nvkm_handle_get_vinst(struct nvkm_object *engctx, u64 vinst)
{ {
struct nouveau_namedb *namedb; struct nvkm_namedb *namedb;
if (engctx && (namedb = (void *)nv_pclass(engctx, NV_NAMEDB_CLASS))) if (engctx && (namedb = (void *)nv_pclass(engctx, NV_NAMEDB_CLASS)))
return nouveau_namedb_get_vinst(namedb, vinst); return nvkm_namedb_get_vinst(namedb, vinst);
return NULL; return NULL;
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_handle_get_cinst(struct nouveau_object *engctx, u32 cinst) nvkm_handle_get_cinst(struct nvkm_object *engctx, u32 cinst)
{ {
struct nouveau_namedb *namedb; struct nvkm_namedb *namedb;
if (engctx && (namedb = (void *)nv_pclass(engctx, NV_NAMEDB_CLASS))) if (engctx && (namedb = (void *)nv_pclass(engctx, NV_NAMEDB_CLASS)))
return nouveau_namedb_get_cinst(namedb, cinst); return nvkm_namedb_get_cinst(namedb, cinst);
return NULL; return NULL;
} }
void void
nouveau_handle_put(struct nouveau_handle *handle) nvkm_handle_put(struct nvkm_handle *handle)
{ {
if (handle) if (handle)
nouveau_namedb_put(handle); nvkm_namedb_put(handle);
} }
This diff is collapsed.
...@@ -21,39 +21,37 @@ ...@@ -21,39 +21,37 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/mm.h>
#include "core/os.h" #define node(root, dir) ((root)->nl_entry.dir == &mm->nodes) ? NULL : \
#include "core/mm.h" list_entry((root)->nl_entry.dir, struct nvkm_mm_node, nl_entry)
#define node(root, dir) ((root)->nl_entry.dir == &mm->nodes) ? NULL : \
list_entry((root)->nl_entry.dir, struct nouveau_mm_node, nl_entry)
static void static void
nouveau_mm_dump(struct nouveau_mm *mm, const char *header) nvkm_mm_dump(struct nvkm_mm *mm, const char *header)
{ {
struct nouveau_mm_node *node; struct nvkm_mm_node *node;
printk(KERN_ERR "nouveau: %s\n", header); printk(KERN_ERR "nvkm: %s\n", header);
printk(KERN_ERR "nouveau: node list:\n"); printk(KERN_ERR "nvkm: node list:\n");
list_for_each_entry(node, &mm->nodes, nl_entry) { list_for_each_entry(node, &mm->nodes, nl_entry) {
printk(KERN_ERR "nouveau: \t%08x %08x %d\n", printk(KERN_ERR "nvkm: \t%08x %08x %d\n",
node->offset, node->length, node->type); node->offset, node->length, node->type);
} }
printk(KERN_ERR "nouveau: free list:\n"); printk(KERN_ERR "nvkm: free list:\n");
list_for_each_entry(node, &mm->free, fl_entry) { list_for_each_entry(node, &mm->free, fl_entry) {
printk(KERN_ERR "nouveau: \t%08x %08x %d\n", printk(KERN_ERR "nvkm: \t%08x %08x %d\n",
node->offset, node->length, node->type); node->offset, node->length, node->type);
} }
} }
void void
nouveau_mm_free(struct nouveau_mm *mm, struct nouveau_mm_node **pthis) nvkm_mm_free(struct nvkm_mm *mm, struct nvkm_mm_node **pthis)
{ {
struct nouveau_mm_node *this = *pthis; struct nvkm_mm_node *this = *pthis;
if (this) { if (this) {
struct nouveau_mm_node *prev = node(this, prev); struct nvkm_mm_node *prev = node(this, prev);
struct nouveau_mm_node *next = node(this, next); struct nvkm_mm_node *next = node(this, next);
if (prev && prev->type == NVKM_MM_TYPE_NONE) { if (prev && prev->type == NVKM_MM_TYPE_NONE) {
prev->length += this->length; prev->length += this->length;
...@@ -84,10 +82,10 @@ nouveau_mm_free(struct nouveau_mm *mm, struct nouveau_mm_node **pthis) ...@@ -84,10 +82,10 @@ nouveau_mm_free(struct nouveau_mm *mm, struct nouveau_mm_node **pthis)
*pthis = NULL; *pthis = NULL;
} }
static struct nouveau_mm_node * static struct nvkm_mm_node *
region_head(struct nouveau_mm *mm, struct nouveau_mm_node *a, u32 size) region_head(struct nvkm_mm *mm, struct nvkm_mm_node *a, u32 size)
{ {
struct nouveau_mm_node *b; struct nvkm_mm_node *b;
if (a->length == size) if (a->length == size)
return a; return a;
...@@ -105,14 +103,15 @@ region_head(struct nouveau_mm *mm, struct nouveau_mm_node *a, u32 size) ...@@ -105,14 +103,15 @@ region_head(struct nouveau_mm *mm, struct nouveau_mm_node *a, u32 size)
list_add_tail(&b->nl_entry, &a->nl_entry); list_add_tail(&b->nl_entry, &a->nl_entry);
if (b->type == NVKM_MM_TYPE_NONE) if (b->type == NVKM_MM_TYPE_NONE)
list_add_tail(&b->fl_entry, &a->fl_entry); list_add_tail(&b->fl_entry, &a->fl_entry);
return b; return b;
} }
int int
nouveau_mm_head(struct nouveau_mm *mm, u8 heap, u8 type, u32 size_max, nvkm_mm_head(struct nvkm_mm *mm, u8 heap, u8 type, u32 size_max, u32 size_min,
u32 size_min, u32 align, struct nouveau_mm_node **pnode) u32 align, struct nvkm_mm_node **pnode)
{ {
struct nouveau_mm_node *prev, *this, *next; struct nvkm_mm_node *prev, *this, *next;
u32 mask = align - 1; u32 mask = align - 1;
u32 splitoff; u32 splitoff;
u32 s, e; u32 s, e;
...@@ -157,10 +156,10 @@ nouveau_mm_head(struct nouveau_mm *mm, u8 heap, u8 type, u32 size_max, ...@@ -157,10 +156,10 @@ nouveau_mm_head(struct nouveau_mm *mm, u8 heap, u8 type, u32 size_max,
return -ENOSPC; return -ENOSPC;
} }
static struct nouveau_mm_node * static struct nvkm_mm_node *
region_tail(struct nouveau_mm *mm, struct nouveau_mm_node *a, u32 size) region_tail(struct nvkm_mm *mm, struct nvkm_mm_node *a, u32 size)
{ {
struct nouveau_mm_node *b; struct nvkm_mm_node *b;
if (a->length == size) if (a->length == size)
return a; return a;
...@@ -178,14 +177,15 @@ region_tail(struct nouveau_mm *mm, struct nouveau_mm_node *a, u32 size) ...@@ -178,14 +177,15 @@ region_tail(struct nouveau_mm *mm, struct nouveau_mm_node *a, u32 size)
list_add(&b->nl_entry, &a->nl_entry); list_add(&b->nl_entry, &a->nl_entry);
if (b->type == NVKM_MM_TYPE_NONE) if (b->type == NVKM_MM_TYPE_NONE)
list_add(&b->fl_entry, &a->fl_entry); list_add(&b->fl_entry, &a->fl_entry);
return b; return b;
} }
int int
nouveau_mm_tail(struct nouveau_mm *mm, u8 heap, u8 type, u32 size_max, nvkm_mm_tail(struct nvkm_mm *mm, u8 heap, u8 type, u32 size_max, u32 size_min,
u32 size_min, u32 align, struct nouveau_mm_node **pnode) u32 align, struct nvkm_mm_node **pnode)
{ {
struct nouveau_mm_node *prev, *this, *next; struct nvkm_mm_node *prev, *this, *next;
u32 mask = align - 1; u32 mask = align - 1;
BUG_ON(type == NVKM_MM_TYPE_NONE || type == NVKM_MM_TYPE_HOLE); BUG_ON(type == NVKM_MM_TYPE_NONE || type == NVKM_MM_TYPE_HOLE);
...@@ -235,12 +235,12 @@ nouveau_mm_tail(struct nouveau_mm *mm, u8 heap, u8 type, u32 size_max, ...@@ -235,12 +235,12 @@ nouveau_mm_tail(struct nouveau_mm *mm, u8 heap, u8 type, u32 size_max,
} }
int int
nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block) nvkm_mm_init(struct nvkm_mm *mm, u32 offset, u32 length, u32 block)
{ {
struct nouveau_mm_node *node, *prev; struct nvkm_mm_node *node, *prev;
u32 next; u32 next;
if (nouveau_mm_initialised(mm)) { if (nvkm_mm_initialised(mm)) {
prev = list_last_entry(&mm->nodes, typeof(*node), nl_entry); prev = list_last_entry(&mm->nodes, typeof(*node), nl_entry);
next = prev->offset + prev->length; next = prev->offset + prev->length;
if (next != offset) { if (next != offset) {
...@@ -277,18 +277,18 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block) ...@@ -277,18 +277,18 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block)
} }
int int
nouveau_mm_fini(struct nouveau_mm *mm) nvkm_mm_fini(struct nvkm_mm *mm)
{ {
struct nouveau_mm_node *node, *temp; struct nvkm_mm_node *node, *temp;
int nodes = 0; int nodes = 0;
if (!nouveau_mm_initialised(mm)) if (!nvkm_mm_initialised(mm))
return 0; return 0;
list_for_each_entry(node, &mm->nodes, nl_entry) { list_for_each_entry(node, &mm->nodes, nl_entry) {
if (node->type != NVKM_MM_TYPE_HOLE) { if (node->type != NVKM_MM_TYPE_HOLE) {
if (++nodes > mm->heap_nodes) { if (++nodes > mm->heap_nodes) {
nouveau_mm_dump(mm, "mm not clean!"); nvkm_mm_dump(mm, "mm not clean!");
return -EBUSY; return -EBUSY;
} }
} }
...@@ -298,6 +298,7 @@ nouveau_mm_fini(struct nouveau_mm *mm) ...@@ -298,6 +298,7 @@ nouveau_mm_fini(struct nouveau_mm *mm)
list_del(&node->nl_entry); list_del(&node->nl_entry);
kfree(node); kfree(node);
} }
mm->heap_nodes = 0; mm->heap_nodes = 0;
return 0; return 0;
} }
...@@ -21,16 +21,14 @@ ...@@ -21,16 +21,14 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/namedb.h> #include <core/namedb.h>
#include <core/handle.h>
#include <core/gpuobj.h> #include <core/gpuobj.h>
#include <core/handle.h>
static struct nouveau_handle * static struct nvkm_handle *
nouveau_namedb_lookup(struct nouveau_namedb *namedb, u32 name) nvkm_namedb_lookup(struct nvkm_namedb *namedb, u32 name)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
list_for_each_entry(handle, &namedb->list, node) { list_for_each_entry(handle, &namedb->list, node) {
if (handle->name == name) if (handle->name == name)
...@@ -40,10 +38,10 @@ nouveau_namedb_lookup(struct nouveau_namedb *namedb, u32 name) ...@@ -40,10 +38,10 @@ nouveau_namedb_lookup(struct nouveau_namedb *namedb, u32 name)
return NULL; return NULL;
} }
static struct nouveau_handle * static struct nvkm_handle *
nouveau_namedb_lookup_class(struct nouveau_namedb *namedb, u16 oclass) nvkm_namedb_lookup_class(struct nvkm_namedb *namedb, u16 oclass)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
list_for_each_entry(handle, &namedb->list, node) { list_for_each_entry(handle, &namedb->list, node) {
if (nv_mclass(handle->object) == oclass) if (nv_mclass(handle->object) == oclass)
...@@ -53,10 +51,10 @@ nouveau_namedb_lookup_class(struct nouveau_namedb *namedb, u16 oclass) ...@@ -53,10 +51,10 @@ nouveau_namedb_lookup_class(struct nouveau_namedb *namedb, u16 oclass)
return NULL; return NULL;
} }
static struct nouveau_handle * static struct nvkm_handle *
nouveau_namedb_lookup_vinst(struct nouveau_namedb *namedb, u64 vinst) nvkm_namedb_lookup_vinst(struct nvkm_namedb *namedb, u64 vinst)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
list_for_each_entry(handle, &namedb->list, node) { list_for_each_entry(handle, &namedb->list, node) {
if (nv_iclass(handle->object, NV_GPUOBJ_CLASS)) { if (nv_iclass(handle->object, NV_GPUOBJ_CLASS)) {
...@@ -68,10 +66,10 @@ nouveau_namedb_lookup_vinst(struct nouveau_namedb *namedb, u64 vinst) ...@@ -68,10 +66,10 @@ nouveau_namedb_lookup_vinst(struct nouveau_namedb *namedb, u64 vinst)
return NULL; return NULL;
} }
static struct nouveau_handle * static struct nvkm_handle *
nouveau_namedb_lookup_cinst(struct nouveau_namedb *namedb, u32 cinst) nvkm_namedb_lookup_cinst(struct nvkm_namedb *namedb, u32 cinst)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
list_for_each_entry(handle, &namedb->list, node) { list_for_each_entry(handle, &namedb->list, node) {
if (nv_iclass(handle->object, NV_GPUOBJ_CLASS)) { if (nv_iclass(handle->object, NV_GPUOBJ_CLASS)) {
...@@ -85,14 +83,14 @@ nouveau_namedb_lookup_cinst(struct nouveau_namedb *namedb, u32 cinst) ...@@ -85,14 +83,14 @@ nouveau_namedb_lookup_cinst(struct nouveau_namedb *namedb, u32 cinst)
} }
int int
nouveau_namedb_insert(struct nouveau_namedb *namedb, u32 name, nvkm_namedb_insert(struct nvkm_namedb *namedb, u32 name,
struct nouveau_object *object, struct nvkm_object *object,
struct nouveau_handle *handle) struct nvkm_handle *handle)
{ {
int ret = -EEXIST; int ret = -EEXIST;
write_lock_irq(&namedb->lock); write_lock_irq(&namedb->lock);
if (!nouveau_namedb_lookup(namedb, name)) { if (!nvkm_namedb_lookup(namedb, name)) {
nouveau_object_ref(object, &handle->object); nvkm_object_ref(object, &handle->object);
handle->namedb = namedb; handle->namedb = namedb;
list_add(&handle->node, &namedb->list); list_add(&handle->node, &namedb->list);
ret = 0; ret = 0;
...@@ -102,80 +100,79 @@ nouveau_namedb_insert(struct nouveau_namedb *namedb, u32 name, ...@@ -102,80 +100,79 @@ nouveau_namedb_insert(struct nouveau_namedb *namedb, u32 name,
} }
void void
nouveau_namedb_remove(struct nouveau_handle *handle) nvkm_namedb_remove(struct nvkm_handle *handle)
{ {
struct nouveau_namedb *namedb = handle->namedb; struct nvkm_namedb *namedb = handle->namedb;
struct nouveau_object *object = handle->object; struct nvkm_object *object = handle->object;
write_lock_irq(&namedb->lock); write_lock_irq(&namedb->lock);
list_del(&handle->node); list_del(&handle->node);
write_unlock_irq(&namedb->lock); write_unlock_irq(&namedb->lock);
nouveau_object_ref(NULL, &object); nvkm_object_ref(NULL, &object);
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_namedb_get(struct nouveau_namedb *namedb, u32 name) nvkm_namedb_get(struct nvkm_namedb *namedb, u32 name)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
read_lock(&namedb->lock); read_lock(&namedb->lock);
handle = nouveau_namedb_lookup(namedb, name); handle = nvkm_namedb_lookup(namedb, name);
if (handle == NULL) if (handle == NULL)
read_unlock(&namedb->lock); read_unlock(&namedb->lock);
return handle; return handle;
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_namedb_get_class(struct nouveau_namedb *namedb, u16 oclass) nvkm_namedb_get_class(struct nvkm_namedb *namedb, u16 oclass)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
read_lock(&namedb->lock); read_lock(&namedb->lock);
handle = nouveau_namedb_lookup_class(namedb, oclass); handle = nvkm_namedb_lookup_class(namedb, oclass);
if (handle == NULL) if (handle == NULL)
read_unlock(&namedb->lock); read_unlock(&namedb->lock);
return handle; return handle;
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_namedb_get_vinst(struct nouveau_namedb *namedb, u64 vinst) nvkm_namedb_get_vinst(struct nvkm_namedb *namedb, u64 vinst)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
read_lock(&namedb->lock); read_lock(&namedb->lock);
handle = nouveau_namedb_lookup_vinst(namedb, vinst); handle = nvkm_namedb_lookup_vinst(namedb, vinst);
if (handle == NULL) if (handle == NULL)
read_unlock(&namedb->lock); read_unlock(&namedb->lock);
return handle; return handle;
} }
struct nouveau_handle * struct nvkm_handle *
nouveau_namedb_get_cinst(struct nouveau_namedb *namedb, u32 cinst) nvkm_namedb_get_cinst(struct nvkm_namedb *namedb, u32 cinst)
{ {
struct nouveau_handle *handle; struct nvkm_handle *handle;
read_lock(&namedb->lock); read_lock(&namedb->lock);
handle = nouveau_namedb_lookup_cinst(namedb, cinst); handle = nvkm_namedb_lookup_cinst(namedb, cinst);
if (handle == NULL) if (handle == NULL)
read_unlock(&namedb->lock); read_unlock(&namedb->lock);
return handle; return handle;
} }
void void
nouveau_namedb_put(struct nouveau_handle *handle) nvkm_namedb_put(struct nvkm_handle *handle)
{ {
if (handle) if (handle)
read_unlock(&handle->namedb->lock); read_unlock(&handle->namedb->lock);
} }
int int
nouveau_namedb_create_(struct nouveau_object *parent, nvkm_namedb_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, u32 pclass,
struct nouveau_oclass *oclass, u32 pclass, struct nvkm_oclass *sclass, u64 engcls,
struct nouveau_oclass *sclass, u64 engcls, int length, void **pobject)
int length, void **pobject)
{ {
struct nouveau_namedb *namedb; struct nvkm_namedb *namedb;
int ret; int ret;
ret = nouveau_parent_create_(parent, engine, oclass, pclass | ret = nvkm_parent_create_(parent, engine, oclass, pclass |
NV_NAMEDB_CLASS, sclass, engcls, NV_NAMEDB_CLASS, sclass, engcls,
length, pobject); length, pobject);
namedb = *pobject; namedb = *pobject;
if (ret) if (ret)
return ret; return ret;
...@@ -186,15 +183,14 @@ nouveau_namedb_create_(struct nouveau_object *parent, ...@@ -186,15 +183,14 @@ nouveau_namedb_create_(struct nouveau_object *parent,
} }
int int
_nouveau_namedb_ctor(struct nouveau_object *parent, _nvkm_namedb_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, void *data, u32 size,
struct nouveau_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject)
struct nouveau_object **pobject)
{ {
struct nouveau_namedb *object; struct nvkm_namedb *object;
int ret; int ret;
ret = nouveau_namedb_create(parent, engine, oclass, 0, NULL, 0, &object); ret = nvkm_namedb_create(parent, engine, oclass, 0, NULL, 0, &object);
*pobject = nv_object(object); *pobject = nv_object(object);
if (ret) if (ret)
return ret; return ret;
......
...@@ -21,13 +21,8 @@ ...@@ -21,13 +21,8 @@
* *
* Authors: Ben Skeggs <bskeggs@redhat.com> * Authors: Ben Skeggs <bskeggs@redhat.com>
*/ */
#include <core/client.h>
#include <core/event.h>
#include <core/notify.h> #include <core/notify.h>
#include <core/event.h>
#include <nvif/unpack.h>
#include <nvif/event.h>
static inline void static inline void
nvkm_notify_put_locked(struct nvkm_notify *notify) nvkm_notify_put_locked(struct nvkm_notify *notify)
...@@ -134,7 +129,7 @@ nvkm_notify_fini(struct nvkm_notify *notify) ...@@ -134,7 +129,7 @@ nvkm_notify_fini(struct nvkm_notify *notify)
} }
int int
nvkm_notify_init(struct nouveau_object *object, struct nvkm_event *event, nvkm_notify_init(struct nvkm_object *object, struct nvkm_event *event,
int (*func)(struct nvkm_notify *), bool work, int (*func)(struct nvkm_notify *), bool work,
void *data, u32 size, u32 reply, void *data, u32 size, u32 reply,
struct nvkm_notify *notify) struct nvkm_notify *notify)
......
...@@ -21,36 +21,34 @@ ...@@ -21,36 +21,34 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h> #include <core/object.h>
#include <core/engine.h> #include <core/engine.h>
#ifdef NOUVEAU_OBJECT_MAGIC #ifdef NVKM_OBJECT_MAGIC
static struct list_head _objlist = LIST_HEAD_INIT(_objlist); static struct list_head _objlist = LIST_HEAD_INIT(_objlist);
static DEFINE_SPINLOCK(_objlist_lock); static DEFINE_SPINLOCK(_objlist_lock);
#endif #endif
int int
nouveau_object_create_(struct nouveau_object *parent, nvkm_object_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, u32 pclass,
struct nouveau_oclass *oclass, u32 pclass, int size, void **pobject)
int size, void **pobject)
{ {
struct nouveau_object *object; struct nvkm_object *object;
object = *pobject = kzalloc(size, GFP_KERNEL); object = *pobject = kzalloc(size, GFP_KERNEL);
if (!object) if (!object)
return -ENOMEM; return -ENOMEM;
nouveau_object_ref(parent, &object->parent); nvkm_object_ref(parent, &object->parent);
nouveau_object_ref(engine, (struct nouveau_object **)&object->engine); nvkm_object_ref(engine, (struct nvkm_object **)&object->engine);
object->oclass = oclass; object->oclass = oclass;
object->oclass->handle |= pclass; object->oclass->handle |= pclass;
atomic_set(&object->refcount, 1); atomic_set(&object->refcount, 1);
atomic_set(&object->usecount, 0); atomic_set(&object->usecount, 0);
#ifdef NOUVEAU_OBJECT_MAGIC #ifdef NVKM_OBJECT_MAGIC
object->_magic = NOUVEAU_OBJECT_MAGIC; object->_magic = NVKM_OBJECT_MAGIC;
spin_lock(&_objlist_lock); spin_lock(&_objlist_lock);
list_add(&object->list, &_objlist); list_add(&object->list, &_objlist);
spin_unlock(&_objlist_lock); spin_unlock(&_objlist_lock);
...@@ -59,57 +57,55 @@ nouveau_object_create_(struct nouveau_object *parent, ...@@ -59,57 +57,55 @@ nouveau_object_create_(struct nouveau_object *parent,
} }
int int
_nouveau_object_ctor(struct nouveau_object *parent, _nvkm_object_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, void *data, u32 size,
struct nouveau_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject)
struct nouveau_object **pobject)
{ {
if (size != 0) if (size != 0)
return -ENOSYS; return -ENOSYS;
return nouveau_object_create(parent, engine, oclass, 0, pobject); return nvkm_object_create(parent, engine, oclass, 0, pobject);
} }
void void
nouveau_object_destroy(struct nouveau_object *object) nvkm_object_destroy(struct nvkm_object *object)
{ {
#ifdef NOUVEAU_OBJECT_MAGIC #ifdef NVKM_OBJECT_MAGIC
spin_lock(&_objlist_lock); spin_lock(&_objlist_lock);
list_del(&object->list); list_del(&object->list);
spin_unlock(&_objlist_lock); spin_unlock(&_objlist_lock);
#endif #endif
nouveau_object_ref(NULL, (struct nouveau_object **)&object->engine); nvkm_object_ref(NULL, (struct nvkm_object **)&object->engine);
nouveau_object_ref(NULL, &object->parent); nvkm_object_ref(NULL, &object->parent);
kfree(object); kfree(object);
} }
int int
nouveau_object_init(struct nouveau_object *object) nvkm_object_init(struct nvkm_object *object)
{ {
return 0; return 0;
} }
int int
nouveau_object_fini(struct nouveau_object *object, bool suspend) nvkm_object_fini(struct nvkm_object *object, bool suspend)
{ {
return 0; return 0;
} }
struct nouveau_ofuncs struct nvkm_ofuncs
nouveau_object_ofuncs = { nvkm_object_ofuncs = {
.ctor = _nouveau_object_ctor, .ctor = _nvkm_object_ctor,
.dtor = nouveau_object_destroy, .dtor = nvkm_object_destroy,
.init = nouveau_object_init, .init = nvkm_object_init,
.fini = nouveau_object_fini, .fini = nvkm_object_fini,
}; };
int int
nouveau_object_ctor(struct nouveau_object *parent, nvkm_object_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, void *data, u32 size,
struct nouveau_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject)
struct nouveau_object **pobject)
{ {
struct nouveau_ofuncs *ofuncs = oclass->ofuncs; struct nvkm_ofuncs *ofuncs = oclass->ofuncs;
struct nouveau_object *object = NULL; struct nvkm_object *object = NULL;
int ret; int ret;
ret = ofuncs->ctor(parent, engine, oclass, data, size, &object); ret = ofuncs->ctor(parent, engine, oclass, data, size, &object);
...@@ -137,14 +133,14 @@ nouveau_object_ctor(struct nouveau_object *parent, ...@@ -137,14 +133,14 @@ nouveau_object_ctor(struct nouveau_object *parent,
} }
static void static void
nouveau_object_dtor(struct nouveau_object *object) nvkm_object_dtor(struct nvkm_object *object)
{ {
nv_trace(object, "destroying\n"); nv_trace(object, "destroying\n");
nv_ofuncs(object)->dtor(object); nv_ofuncs(object)->dtor(object);
} }
void void
nouveau_object_ref(struct nouveau_object *obj, struct nouveau_object **ref) nvkm_object_ref(struct nvkm_object *obj, struct nvkm_object **ref)
{ {
if (obj) { if (obj) {
atomic_inc(&obj->refcount); atomic_inc(&obj->refcount);
...@@ -155,14 +151,14 @@ nouveau_object_ref(struct nouveau_object *obj, struct nouveau_object **ref) ...@@ -155,14 +151,14 @@ nouveau_object_ref(struct nouveau_object *obj, struct nouveau_object **ref)
int dead = atomic_dec_and_test(&(*ref)->refcount); int dead = atomic_dec_and_test(&(*ref)->refcount);
nv_trace(*ref, "dec() == %d\n", atomic_read(&(*ref)->refcount)); nv_trace(*ref, "dec() == %d\n", atomic_read(&(*ref)->refcount));
if (dead) if (dead)
nouveau_object_dtor(*ref); nvkm_object_dtor(*ref);
} }
*ref = obj; *ref = obj;
} }
int int
nouveau_object_inc(struct nouveau_object *object) nvkm_object_inc(struct nvkm_object *object)
{ {
int ref = atomic_add_return(1, &object->usecount); int ref = atomic_add_return(1, &object->usecount);
int ret; int ret;
...@@ -173,7 +169,7 @@ nouveau_object_inc(struct nouveau_object *object) ...@@ -173,7 +169,7 @@ nouveau_object_inc(struct nouveau_object *object)
nv_trace(object, "initialising...\n"); nv_trace(object, "initialising...\n");
if (object->parent) { if (object->parent) {
ret = nouveau_object_inc(object->parent); ret = nvkm_object_inc(object->parent);
if (ret) { if (ret) {
nv_error(object, "parent failed, %d\n", ret); nv_error(object, "parent failed, %d\n", ret);
goto fail_parent; goto fail_parent;
...@@ -182,7 +178,7 @@ nouveau_object_inc(struct nouveau_object *object) ...@@ -182,7 +178,7 @@ nouveau_object_inc(struct nouveau_object *object)
if (object->engine) { if (object->engine) {
mutex_lock(&nv_subdev(object->engine)->mutex); mutex_lock(&nv_subdev(object->engine)->mutex);
ret = nouveau_object_inc(&object->engine->subdev.object); ret = nvkm_object_inc(&object->engine->subdev.object);
mutex_unlock(&nv_subdev(object->engine)->mutex); mutex_unlock(&nv_subdev(object->engine)->mutex);
if (ret) { if (ret) {
nv_error(object, "engine failed, %d\n", ret); nv_error(object, "engine failed, %d\n", ret);
...@@ -203,19 +199,19 @@ nouveau_object_inc(struct nouveau_object *object) ...@@ -203,19 +199,19 @@ nouveau_object_inc(struct nouveau_object *object)
fail_self: fail_self:
if (object->engine) { if (object->engine) {
mutex_lock(&nv_subdev(object->engine)->mutex); mutex_lock(&nv_subdev(object->engine)->mutex);
nouveau_object_dec(&object->engine->subdev.object, false); nvkm_object_dec(&object->engine->subdev.object, false);
mutex_unlock(&nv_subdev(object->engine)->mutex); mutex_unlock(&nv_subdev(object->engine)->mutex);
} }
fail_engine: fail_engine:
if (object->parent) if (object->parent)
nouveau_object_dec(object->parent, false); nvkm_object_dec(object->parent, false);
fail_parent: fail_parent:
atomic_dec(&object->usecount); atomic_dec(&object->usecount);
return ret; return ret;
} }
static int static int
nouveau_object_decf(struct nouveau_object *object) nvkm_object_decf(struct nvkm_object *object)
{ {
int ret; int ret;
...@@ -228,19 +224,19 @@ nouveau_object_decf(struct nouveau_object *object) ...@@ -228,19 +224,19 @@ nouveau_object_decf(struct nouveau_object *object)
if (object->engine) { if (object->engine) {
mutex_lock(&nv_subdev(object->engine)->mutex); mutex_lock(&nv_subdev(object->engine)->mutex);
nouveau_object_dec(&object->engine->subdev.object, false); nvkm_object_dec(&object->engine->subdev.object, false);
mutex_unlock(&nv_subdev(object->engine)->mutex); mutex_unlock(&nv_subdev(object->engine)->mutex);
} }
if (object->parent) if (object->parent)
nouveau_object_dec(object->parent, false); nvkm_object_dec(object->parent, false);
nv_trace(object, "stopped\n"); nv_trace(object, "stopped\n");
return 0; return 0;
} }
static int static int
nouveau_object_decs(struct nouveau_object *object) nvkm_object_decs(struct nvkm_object *object)
{ {
int ret, rret; int ret, rret;
...@@ -255,7 +251,7 @@ nouveau_object_decs(struct nouveau_object *object) ...@@ -255,7 +251,7 @@ nouveau_object_decs(struct nouveau_object *object)
if (object->engine) { if (object->engine) {
mutex_lock(&nv_subdev(object->engine)->mutex); mutex_lock(&nv_subdev(object->engine)->mutex);
ret = nouveau_object_dec(&object->engine->subdev.object, true); ret = nvkm_object_dec(&object->engine->subdev.object, true);
mutex_unlock(&nv_subdev(object->engine)->mutex); mutex_unlock(&nv_subdev(object->engine)->mutex);
if (ret) { if (ret) {
nv_warn(object, "engine failed suspend, %d\n", ret); nv_warn(object, "engine failed suspend, %d\n", ret);
...@@ -264,7 +260,7 @@ nouveau_object_decs(struct nouveau_object *object) ...@@ -264,7 +260,7 @@ nouveau_object_decs(struct nouveau_object *object)
} }
if (object->parent) { if (object->parent) {
ret = nouveau_object_dec(object->parent, true); ret = nvkm_object_dec(object->parent, true);
if (ret) { if (ret) {
nv_warn(object, "parent failed suspend, %d\n", ret); nv_warn(object, "parent failed suspend, %d\n", ret);
goto fail_parent; goto fail_parent;
...@@ -277,7 +273,7 @@ nouveau_object_decs(struct nouveau_object *object) ...@@ -277,7 +273,7 @@ nouveau_object_decs(struct nouveau_object *object)
fail_parent: fail_parent:
if (object->engine) { if (object->engine) {
mutex_lock(&nv_subdev(object->engine)->mutex); mutex_lock(&nv_subdev(object->engine)->mutex);
rret = nouveau_object_inc(&object->engine->subdev.object); rret = nvkm_object_inc(&object->engine->subdev.object);
mutex_unlock(&nv_subdev(object->engine)->mutex); mutex_unlock(&nv_subdev(object->engine)->mutex);
if (rret) if (rret)
nv_fatal(object, "engine failed to reinit, %d\n", rret); nv_fatal(object, "engine failed to reinit, %d\n", rret);
...@@ -292,7 +288,7 @@ nouveau_object_decs(struct nouveau_object *object) ...@@ -292,7 +288,7 @@ nouveau_object_decs(struct nouveau_object *object)
} }
int int
nouveau_object_dec(struct nouveau_object *object, bool suspend) nvkm_object_dec(struct nvkm_object *object, bool suspend)
{ {
int ref = atomic_add_return(-1, &object->usecount); int ref = atomic_add_return(-1, &object->usecount);
int ret; int ret;
...@@ -301,9 +297,9 @@ nouveau_object_dec(struct nouveau_object *object, bool suspend) ...@@ -301,9 +297,9 @@ nouveau_object_dec(struct nouveau_object *object, bool suspend)
if (ref == 0) { if (ref == 0) {
if (suspend) if (suspend)
ret = nouveau_object_decs(object); ret = nvkm_object_decs(object);
else else
ret = nouveau_object_decf(object); ret = nvkm_object_decf(object);
if (ret) { if (ret) {
atomic_inc(&object->usecount); atomic_inc(&object->usecount);
...@@ -315,10 +311,10 @@ nouveau_object_dec(struct nouveau_object *object, bool suspend) ...@@ -315,10 +311,10 @@ nouveau_object_dec(struct nouveau_object *object, bool suspend)
} }
void void
nouveau_object_debug(void) nvkm_object_debug(void)
{ {
#ifdef NOUVEAU_OBJECT_MAGIC #ifdef NVKM_OBJECT_MAGIC
struct nouveau_object *object; struct nvkm_object *object;
if (!list_empty(&_objlist)) { if (!list_empty(&_objlist)) {
nv_fatal(NULL, "*******************************************\n"); nv_fatal(NULL, "*******************************************\n");
nv_fatal(NULL, "* AIIIII! object(s) still exist!!!\n"); nv_fatal(NULL, "* AIIIII! object(s) still exist!!!\n");
......
...@@ -21,12 +21,11 @@ ...@@ -21,12 +21,11 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/option.h> #include <core/option.h>
#include <core/debug.h> #include <core/debug.h>
const char * const char *
nouveau_stropt(const char *optstr, const char *opt, int *arglen) nvkm_stropt(const char *optstr, const char *opt, int *arglen)
{ {
while (optstr && *optstr != '\0') { while (optstr && *optstr != '\0') {
int len = strcspn(optstr, ",="); int len = strcspn(optstr, ",=");
...@@ -52,11 +51,11 @@ nouveau_stropt(const char *optstr, const char *opt, int *arglen) ...@@ -52,11 +51,11 @@ nouveau_stropt(const char *optstr, const char *opt, int *arglen)
} }
bool bool
nouveau_boolopt(const char *optstr, const char *opt, bool value) nvkm_boolopt(const char *optstr, const char *opt, bool value)
{ {
int arglen; int arglen;
optstr = nouveau_stropt(optstr, opt, &arglen); optstr = nvkm_stropt(optstr, opt, &arglen);
if (optstr) { if (optstr) {
if (!strncasecmpz(optstr, "0", arglen) || if (!strncasecmpz(optstr, "0", arglen) ||
!strncasecmpz(optstr, "no", arglen) || !strncasecmpz(optstr, "no", arglen) ||
...@@ -75,7 +74,7 @@ nouveau_boolopt(const char *optstr, const char *opt, bool value) ...@@ -75,7 +74,7 @@ nouveau_boolopt(const char *optstr, const char *opt, bool value)
} }
int int
nouveau_dbgopt(const char *optstr, const char *sub) nvkm_dbgopt(const char *optstr, const char *sub)
{ {
int mode = 1, level = CONFIG_NOUVEAU_DEBUG_DEFAULT; int mode = 1, level = CONFIG_NOUVEAU_DEBUG_DEFAULT;
......
...@@ -21,19 +21,18 @@ ...@@ -21,19 +21,18 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/parent.h> #include <core/parent.h>
#include <core/client.h> #include <core/client.h>
#include <core/engine.h>
int int
nouveau_parent_sclass(struct nouveau_object *parent, u16 handle, nvkm_parent_sclass(struct nvkm_object *parent, u16 handle,
struct nouveau_object **pengine, struct nvkm_object **pengine,
struct nouveau_oclass **poclass) struct nvkm_oclass **poclass)
{ {
struct nouveau_sclass *sclass; struct nvkm_sclass *sclass;
struct nouveau_engine *engine; struct nvkm_engine *engine;
struct nouveau_oclass *oclass; struct nvkm_oclass *oclass;
u64 mask; u64 mask;
sclass = nv_parent(parent)->sclass; sclass = nv_parent(parent)->sclass;
...@@ -54,7 +53,7 @@ nouveau_parent_sclass(struct nouveau_object *parent, u16 handle, ...@@ -54,7 +53,7 @@ nouveau_parent_sclass(struct nouveau_object *parent, u16 handle,
if (nv_iclass(parent, NV_CLIENT_CLASS)) if (nv_iclass(parent, NV_CLIENT_CLASS))
engine = nv_engine(nv_client(parent)->device); engine = nv_engine(nv_client(parent)->device);
else else
engine = nouveau_engine(parent, i); engine = nvkm_engine(parent, i);
if (engine) { if (engine) {
oclass = engine->sclass; oclass = engine->sclass;
...@@ -75,11 +74,11 @@ nouveau_parent_sclass(struct nouveau_object *parent, u16 handle, ...@@ -75,11 +74,11 @@ nouveau_parent_sclass(struct nouveau_object *parent, u16 handle,
} }
int int
nouveau_parent_lclass(struct nouveau_object *parent, u32 *lclass, int size) nvkm_parent_lclass(struct nvkm_object *parent, u32 *lclass, int size)
{ {
struct nouveau_sclass *sclass; struct nvkm_sclass *sclass;
struct nouveau_engine *engine; struct nvkm_engine *engine;
struct nouveau_oclass *oclass; struct nvkm_oclass *oclass;
int nr = -1, i; int nr = -1, i;
u64 mask; u64 mask;
...@@ -92,7 +91,7 @@ nouveau_parent_lclass(struct nouveau_object *parent, u32 *lclass, int size) ...@@ -92,7 +91,7 @@ nouveau_parent_lclass(struct nouveau_object *parent, u32 *lclass, int size)
mask = nv_parent(parent)->engine; mask = nv_parent(parent)->engine;
while (i = __ffs64(mask), mask) { while (i = __ffs64(mask), mask) {
engine = nouveau_engine(parent, i); engine = nvkm_engine(parent, i);
if (engine && (oclass = engine->sclass)) { if (engine && (oclass = engine->sclass)) {
while (oclass->ofuncs) { while (oclass->ofuncs) {
if (++nr < size) if (++nr < size)
...@@ -108,18 +107,17 @@ nouveau_parent_lclass(struct nouveau_object *parent, u32 *lclass, int size) ...@@ -108,18 +107,17 @@ nouveau_parent_lclass(struct nouveau_object *parent, u32 *lclass, int size)
} }
int int
nouveau_parent_create_(struct nouveau_object *parent, nvkm_parent_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, u32 pclass,
struct nouveau_oclass *oclass, u32 pclass, struct nvkm_oclass *sclass, u64 engcls,
struct nouveau_oclass *sclass, u64 engcls, int size, void **pobject)
int size, void **pobject)
{ {
struct nouveau_parent *object; struct nvkm_parent *object;
struct nouveau_sclass *nclass; struct nvkm_sclass *nclass;
int ret; int ret;
ret = nouveau_object_create_(parent, engine, oclass, pclass | ret = nvkm_object_create_(parent, engine, oclass, pclass |
NV_PARENT_CLASS, size, pobject); NV_PARENT_CLASS, size, pobject);
object = *pobject; object = *pobject;
if (ret) if (ret)
return ret; return ret;
...@@ -141,21 +139,21 @@ nouveau_parent_create_(struct nouveau_object *parent, ...@@ -141,21 +139,21 @@ nouveau_parent_create_(struct nouveau_object *parent,
} }
void void
nouveau_parent_destroy(struct nouveau_parent *parent) nvkm_parent_destroy(struct nvkm_parent *parent)
{ {
struct nouveau_sclass *sclass; struct nvkm_sclass *sclass;
while ((sclass = parent->sclass)) { while ((sclass = parent->sclass)) {
parent->sclass = sclass->sclass; parent->sclass = sclass->sclass;
kfree(sclass); kfree(sclass);
} }
nouveau_object_destroy(&parent->object); nvkm_object_destroy(&parent->object);
} }
void void
_nouveau_parent_dtor(struct nouveau_object *object) _nvkm_parent_dtor(struct nvkm_object *object)
{ {
nouveau_parent_destroy(nv_parent(object)); nvkm_parent_destroy(nv_parent(object));
} }
...@@ -21,16 +21,14 @@ ...@@ -21,16 +21,14 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/client.h>
#include <core/subdev.h>
#include <core/printk.h> #include <core/printk.h>
#include <core/client.h>
#include <core/device.h>
int nv_info_debug_level = NV_DBG_INFO_NORMAL; int nv_info_debug_level = NV_DBG_INFO_NORMAL;
void void
nv_printk_(struct nouveau_object *object, int level, const char *fmt, ...) nv_printk_(struct nvkm_object *object, int level, const char *fmt, ...)
{ {
static const char name[] = { '!', 'E', 'W', ' ', 'D', 'T', 'P', 'S' }; static const char name[] = { '!', 'E', 'W', ' ', 'D', 'T', 'P', 'S' };
const char *pfx; const char *pfx;
...@@ -60,8 +58,8 @@ nv_printk_(struct nouveau_object *object, int level, const char *fmt, ...) ...@@ -60,8 +58,8 @@ nv_printk_(struct nouveau_object *object, int level, const char *fmt, ...)
} }
if (object && !nv_iclass(object, NV_CLIENT_CLASS)) { if (object && !nv_iclass(object, NV_CLIENT_CLASS)) {
struct nouveau_object *device; struct nvkm_object *device;
struct nouveau_object *subdev; struct nvkm_object *subdev;
char obuf[64], *ofmt = ""; char obuf[64], *ofmt = "";
if (object->engine == NULL) { if (object->engine == NULL) {
......
...@@ -19,14 +19,12 @@ ...@@ -19,14 +19,12 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <core/object.h>
#include <core/ramht.h> #include <core/ramht.h>
#include <subdev/bar.h> #include <subdev/bar.h>
static u32 static u32
nouveau_ramht_hash(struct nouveau_ramht *ramht, int chid, u32 handle) nvkm_ramht_hash(struct nvkm_ramht *ramht, int chid, u32 handle)
{ {
u32 hash = 0; u32 hash = 0;
...@@ -41,13 +39,12 @@ nouveau_ramht_hash(struct nouveau_ramht *ramht, int chid, u32 handle) ...@@ -41,13 +39,12 @@ nouveau_ramht_hash(struct nouveau_ramht *ramht, int chid, u32 handle)
} }
int int
nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, nvkm_ramht_insert(struct nvkm_ramht *ramht, int chid, u32 handle, u32 context)
u32 handle, u32 context)
{ {
struct nouveau_bar *bar = nouveau_bar(ramht); struct nvkm_bar *bar = nvkm_bar(ramht);
u32 co, ho; u32 co, ho;
co = ho = nouveau_ramht_hash(ramht, chid, handle); co = ho = nvkm_ramht_hash(ramht, chid, handle);
do { do {
if (!nv_ro32(ramht, co + 4)) { if (!nv_ro32(ramht, co + 4)) {
nv_wo32(ramht, co + 0, handle); nv_wo32(ramht, co + 0, handle);
...@@ -66,39 +63,39 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, ...@@ -66,39 +63,39 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid,
} }
void void
nouveau_ramht_remove(struct nouveau_ramht *ramht, int cookie) nvkm_ramht_remove(struct nvkm_ramht *ramht, int cookie)
{ {
struct nouveau_bar *bar = nouveau_bar(ramht); struct nvkm_bar *bar = nvkm_bar(ramht);
nv_wo32(ramht, cookie + 0, 0x00000000); nv_wo32(ramht, cookie + 0, 0x00000000);
nv_wo32(ramht, cookie + 4, 0x00000000); nv_wo32(ramht, cookie + 4, 0x00000000);
if (bar) if (bar)
bar->flush(bar); bar->flush(bar);
} }
static struct nouveau_oclass static struct nvkm_oclass
nouveau_ramht_oclass = { nvkm_ramht_oclass = {
.handle = 0x0000abcd, .handle = 0x0000abcd,
.ofuncs = &(struct nouveau_ofuncs) { .ofuncs = &(struct nvkm_ofuncs) {
.ctor = NULL, .ctor = NULL,
.dtor = _nouveau_gpuobj_dtor, .dtor = _nvkm_gpuobj_dtor,
.init = _nouveau_gpuobj_init, .init = _nvkm_gpuobj_init,
.fini = _nouveau_gpuobj_fini, .fini = _nvkm_gpuobj_fini,
.rd32 = _nouveau_gpuobj_rd32, .rd32 = _nvkm_gpuobj_rd32,
.wr32 = _nouveau_gpuobj_wr32, .wr32 = _nvkm_gpuobj_wr32,
}, },
}; };
int int
nouveau_ramht_new(struct nouveau_object *parent, struct nouveau_object *pargpu, nvkm_ramht_new(struct nvkm_object *parent, struct nvkm_object *pargpu,
u32 size, u32 align, struct nouveau_ramht **pramht) u32 size, u32 align, struct nvkm_ramht **pramht)
{ {
struct nouveau_ramht *ramht; struct nvkm_ramht *ramht;
int ret; int ret;
ret = nouveau_gpuobj_create(parent, parent->engine ? ret = nvkm_gpuobj_create(parent, parent->engine ?
&parent->engine->subdev.object : parent, /* <nv50 ramht */ &parent->engine->subdev.object : parent, /* <nv50 ramht */
&nouveau_ramht_oclass, 0, pargpu, size, &nvkm_ramht_oclass, 0, pargpu, size,
align, NVOBJ_FLAG_ZERO_ALLOC, &ramht); align, NVOBJ_FLAG_ZERO_ALLOC, &ramht);
*pramht = ramht; *pramht = ramht;
if (ret) if (ret)
return ret; return ret;
......
...@@ -21,16 +21,14 @@ ...@@ -21,16 +21,14 @@
* *
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/object.h>
#include <core/subdev.h> #include <core/subdev.h>
#include <core/device.h> #include <core/device.h>
#include <core/option.h> #include <core/option.h>
struct nouveau_subdev * struct nvkm_subdev *
nouveau_subdev(void *obj, int idx) nvkm_subdev(void *obj, int idx)
{ {
struct nouveau_object *object = nv_object(obj); struct nvkm_object *object = nv_object(obj);
while (object && !nv_iclass(object, NV_SUBDEV_CLASS)) while (object && !nv_iclass(object, NV_SUBDEV_CLASS))
object = object->parent; object = object->parent;
if (object == NULL || nv_subidx(nv_subdev(object)) != idx) if (object == NULL || nv_subidx(nv_subdev(object)) != idx)
...@@ -39,7 +37,7 @@ nouveau_subdev(void *obj, int idx) ...@@ -39,7 +37,7 @@ nouveau_subdev(void *obj, int idx)
} }
void void
nouveau_subdev_reset(struct nouveau_object *subdev) nvkm_subdev_reset(struct nvkm_object *subdev)
{ {
nv_trace(subdev, "resetting...\n"); nv_trace(subdev, "resetting...\n");
nv_ofuncs(subdev)->fini(subdev, false); nv_ofuncs(subdev)->fini(subdev, false);
...@@ -47,65 +45,64 @@ nouveau_subdev_reset(struct nouveau_object *subdev) ...@@ -47,65 +45,64 @@ nouveau_subdev_reset(struct nouveau_object *subdev)
} }
int int
nouveau_subdev_init(struct nouveau_subdev *subdev) nvkm_subdev_init(struct nvkm_subdev *subdev)
{ {
int ret = nouveau_object_init(&subdev->object); int ret = nvkm_object_init(&subdev->object);
if (ret) if (ret)
return ret; return ret;
nouveau_subdev_reset(&subdev->object); nvkm_subdev_reset(&subdev->object);
return 0; return 0;
} }
int int
_nouveau_subdev_init(struct nouveau_object *object) _nvkm_subdev_init(struct nvkm_object *object)
{ {
return nouveau_subdev_init(nv_subdev(object)); return nvkm_subdev_init(nv_subdev(object));
} }
int int
nouveau_subdev_fini(struct nouveau_subdev *subdev, bool suspend) nvkm_subdev_fini(struct nvkm_subdev *subdev, bool suspend)
{ {
if (subdev->unit) { if (subdev->unit) {
nv_mask(subdev, 0x000200, subdev->unit, 0x00000000); nv_mask(subdev, 0x000200, subdev->unit, 0x00000000);
nv_mask(subdev, 0x000200, subdev->unit, subdev->unit); nv_mask(subdev, 0x000200, subdev->unit, subdev->unit);
} }
return nouveau_object_fini(&subdev->object, suspend); return nvkm_object_fini(&subdev->object, suspend);
} }
int int
_nouveau_subdev_fini(struct nouveau_object *object, bool suspend) _nvkm_subdev_fini(struct nvkm_object *object, bool suspend)
{ {
return nouveau_subdev_fini(nv_subdev(object), suspend); return nvkm_subdev_fini(nv_subdev(object), suspend);
} }
void void
nouveau_subdev_destroy(struct nouveau_subdev *subdev) nvkm_subdev_destroy(struct nvkm_subdev *subdev)
{ {
int subidx = nv_hclass(subdev) & 0xff; int subidx = nv_hclass(subdev) & 0xff;
nv_device(subdev)->subdev[subidx] = NULL; nv_device(subdev)->subdev[subidx] = NULL;
nouveau_object_destroy(&subdev->object); nvkm_object_destroy(&subdev->object);
} }
void void
_nouveau_subdev_dtor(struct nouveau_object *object) _nvkm_subdev_dtor(struct nvkm_object *object)
{ {
nouveau_subdev_destroy(nv_subdev(object)); nvkm_subdev_destroy(nv_subdev(object));
} }
int int
nouveau_subdev_create_(struct nouveau_object *parent, nvkm_subdev_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, u32 pclass,
struct nouveau_oclass *oclass, u32 pclass, const char *subname, const char *sysname,
const char *subname, const char *sysname, int size, void **pobject)
int size, void **pobject)
{ {
struct nouveau_subdev *subdev; struct nvkm_subdev *subdev;
int ret; int ret;
ret = nouveau_object_create_(parent, engine, oclass, pclass | ret = nvkm_object_create_(parent, engine, oclass, pclass |
NV_SUBDEV_CLASS, size, pobject); NV_SUBDEV_CLASS, size, pobject);
subdev = *pobject; subdev = *pobject;
if (ret) if (ret)
return ret; return ret;
...@@ -114,8 +111,8 @@ nouveau_subdev_create_(struct nouveau_object *parent, ...@@ -114,8 +111,8 @@ nouveau_subdev_create_(struct nouveau_object *parent,
subdev->name = subname; subdev->name = subname;
if (parent) { if (parent) {
struct nouveau_device *device = nv_device(parent); struct nvkm_device *device = nv_device(parent);
subdev->debug = nouveau_dbgopt(device->dbgopt, subname); subdev->debug = nvkm_dbgopt(device->dbgopt, subname);
subdev->mmio = nv_subdev(device)->mmio; subdev->mmio = nv_subdev(device)->mmio;
} }
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <engine/xtensa.h> #include <engine/xtensa.h>
#include <engine/bsp.h> #include <engine/bsp.h>
#include <core/engctx.h>
/******************************************************************************* /*******************************************************************************
* BSP object classes * BSP object classes
******************************************************************************/ ******************************************************************************/
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/notify.h>
#include <core/object.h> #include <core/object.h>
#include <core/device.h> #include <core/device.h>
#include <core/client.h> #include <core/client.h>
......
#ifndef __NVKM_DISP_CONN_H__ #ifndef __NVKM_DISP_CONN_H__
#define __NVKM_DISP_CONN_H__ #define __NVKM_DISP_CONN_H__
#include "priv.h" #include "priv.h"
#include <core/notify.h>
struct nvkm_connector { struct nvkm_connector {
struct nouveau_object base; struct nouveau_object base;
struct list_head head; struct list_head head;
......
#ifndef __NVKM_DISP_OUTP_DP_H__ #ifndef __NVKM_DISP_OUTP_DP_H__
#define __NVKM_DISP_OUTP_DP_H__ #define __NVKM_DISP_OUTP_DP_H__
#include <core/notify.h>
#include <subdev/bios.h> #include <subdev/bios.h>
#include <subdev/bios/dp.h> #include <subdev/bios/dp.h>
......
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <engine/falcon.h> #include <engine/falcon.h>
#include <subdev/timer.h> #include <subdev/timer.h>
void void
nouveau_falcon_intr(struct nouveau_subdev *subdev) nvkm_falcon_intr(struct nvkm_subdev *subdev)
{ {
struct nouveau_falcon *falcon = (void *)subdev; struct nvkm_falcon *falcon = (void *)subdev;
u32 dispatch = nv_ro32(falcon, 0x01c); u32 dispatch = nv_ro32(falcon, 0x01c);
u32 intr = nv_ro32(falcon, 0x008) & dispatch & ~(dispatch >> 16); u32 intr = nv_ro32(falcon, 0x008) & dispatch & ~(dispatch >> 16);
...@@ -43,16 +43,16 @@ nouveau_falcon_intr(struct nouveau_subdev *subdev) ...@@ -43,16 +43,16 @@ nouveau_falcon_intr(struct nouveau_subdev *subdev)
} }
u32 u32
_nouveau_falcon_rd32(struct nouveau_object *object, u64 addr) _nvkm_falcon_rd32(struct nvkm_object *object, u64 addr)
{ {
struct nouveau_falcon *falcon = (void *)object; struct nvkm_falcon *falcon = (void *)object;
return nv_rd32(falcon, falcon->addr + addr); return nv_rd32(falcon, falcon->addr + addr);
} }
void void
_nouveau_falcon_wr32(struct nouveau_object *object, u64 addr, u32 data) _nvkm_falcon_wr32(struct nvkm_object *object, u64 addr, u32 data)
{ {
struct nouveau_falcon *falcon = (void *)object; struct nvkm_falcon *falcon = (void *)object;
nv_wr32(falcon, falcon->addr + addr, data); nv_wr32(falcon, falcon->addr + addr, data);
} }
...@@ -67,17 +67,17 @@ vmemdup(const void *src, size_t len) ...@@ -67,17 +67,17 @@ vmemdup(const void *src, size_t len)
} }
int int
_nouveau_falcon_init(struct nouveau_object *object) _nvkm_falcon_init(struct nvkm_object *object)
{ {
struct nouveau_device *device = nv_device(object); struct nvkm_device *device = nv_device(object);
struct nouveau_falcon *falcon = (void *)object; struct nvkm_falcon *falcon = (void *)object;
const struct firmware *fw; const struct firmware *fw;
char name[32] = "internal"; char name[32] = "internal";
int ret, i; int ret, i;
u32 caps; u32 caps;
/* enable engine, and determine its capabilities */ /* enable engine, and determine its capabilities */
ret = nouveau_engine_init(&falcon->base); ret = nvkm_engine_init(&falcon->base);
if (ret) if (ret)
return ret; return ret;
...@@ -171,9 +171,8 @@ _nouveau_falcon_init(struct nouveau_object *object) ...@@ -171,9 +171,8 @@ _nouveau_falcon_init(struct nouveau_object *object)
/* ensure any "self-bootstrapping" firmware image is in vram */ /* ensure any "self-bootstrapping" firmware image is in vram */
if (!falcon->data.data && !falcon->core) { if (!falcon->data.data && !falcon->core) {
ret = nouveau_gpuobj_new(object->parent, NULL, ret = nvkm_gpuobj_new(object->parent, NULL, falcon->code.size,
falcon->code.size, 256, 0, 256, 0, &falcon->core);
&falcon->core);
if (ret) { if (ret) {
nv_error(falcon, "core allocation failed, %d\n", ret); nv_error(falcon, "core allocation failed, %d\n", ret);
return ret; return ret;
...@@ -238,12 +237,12 @@ _nouveau_falcon_init(struct nouveau_object *object) ...@@ -238,12 +237,12 @@ _nouveau_falcon_init(struct nouveau_object *object)
} }
int int
_nouveau_falcon_fini(struct nouveau_object *object, bool suspend) _nvkm_falcon_fini(struct nvkm_object *object, bool suspend)
{ {
struct nouveau_falcon *falcon = (void *)object; struct nvkm_falcon *falcon = (void *)object;
if (!suspend) { if (!suspend) {
nouveau_gpuobj_ref(NULL, &falcon->core); nvkm_gpuobj_ref(NULL, &falcon->core);
if (falcon->external) { if (falcon->external) {
vfree(falcon->data.data); vfree(falcon->data.data);
vfree(falcon->code.data); vfree(falcon->code.data);
...@@ -254,21 +253,20 @@ _nouveau_falcon_fini(struct nouveau_object *object, bool suspend) ...@@ -254,21 +253,20 @@ _nouveau_falcon_fini(struct nouveau_object *object, bool suspend)
nv_mo32(falcon, 0x048, 0x00000003, 0x00000000); nv_mo32(falcon, 0x048, 0x00000003, 0x00000000);
nv_wo32(falcon, 0x014, 0xffffffff); nv_wo32(falcon, 0x014, 0xffffffff);
return nouveau_engine_fini(&falcon->base, suspend); return nvkm_engine_fini(&falcon->base, suspend);
} }
int int
nouveau_falcon_create_(struct nouveau_object *parent, nvkm_falcon_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, u32 addr, bool enable,
struct nouveau_oclass *oclass, u32 addr, bool enable, const char *iname, const char *fname,
const char *iname, const char *fname, int length, void **pobject)
int length, void **pobject)
{ {
struct nouveau_falcon *falcon; struct nvkm_falcon *falcon;
int ret; int ret;
ret = nouveau_engine_create_(parent, engine, oclass, enable, iname, ret = nvkm_engine_create_(parent, engine, oclass, enable, iname,
fname, length, pobject); fname, length, pobject);
falcon = *pobject; falcon = *pobject;
if (ret) if (ret)
return ret; return ret;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
*/ */
#include <core/client.h> #include <core/client.h>
#include <core/device.h>
#include <core/notify.h>
#include <core/object.h> #include <core/object.h>
#include <core/handle.h> #include <core/handle.h>
#include <core/event.h> #include <core/event.h>
......
#ifndef __NV50_GR_H__ #ifndef __NV50_GR_H__
#define __NV50_GR_H__ #define __NV50_GR_H__
struct nvkm_device;
int nv50_grctx_init(struct nouveau_device *, u32 *size); int nv50_grctx_init(struct nouveau_device *, u32 *size);
void nv50_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *); void nv50_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *);
#endif #endif
#ifndef __NVKM_SW_NV50_H__ #ifndef __NVKM_SW_NV50_H__
#define __NVKM_SW_NV50_H__ #define __NVKM_SW_NV50_H__
#include <engine/sw.h> #include <engine/sw.h>
#include <core/notify.h>
struct nv50_sw_oclass { struct nv50_sw_oclass {
struct nouveau_oclass base; struct nouveau_oclass base;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <engine/xtensa.h> #include <engine/xtensa.h>
#include <engine/vp.h> #include <engine/vp.h>
#include <core/engctx.h>
/******************************************************************************* /*******************************************************************************
* VP object classes * VP object classes
******************************************************************************/ ******************************************************************************/
......
...@@ -19,43 +19,42 @@ ...@@ -19,43 +19,42 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <engine/xtensa.h> #include <engine/xtensa.h>
#include <core/engctx.h>
u32 u32
_nouveau_xtensa_rd32(struct nouveau_object *object, u64 addr) _nvkm_xtensa_rd32(struct nvkm_object *object, u64 addr)
{ {
struct nouveau_xtensa *xtensa = (void *)object; struct nvkm_xtensa *xtensa = (void *)object;
return nv_rd32(xtensa, xtensa->addr + addr); return nv_rd32(xtensa, xtensa->addr + addr);
} }
void void
_nouveau_xtensa_wr32(struct nouveau_object *object, u64 addr, u32 data) _nvkm_xtensa_wr32(struct nvkm_object *object, u64 addr, u32 data)
{ {
struct nouveau_xtensa *xtensa = (void *)object; struct nvkm_xtensa *xtensa = (void *)object;
nv_wr32(xtensa, xtensa->addr + addr, data); nv_wr32(xtensa, xtensa->addr + addr, data);
} }
int int
_nouveau_xtensa_engctx_ctor(struct nouveau_object *parent, _nvkm_xtensa_engctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, void *data, u32 size,
struct nouveau_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject)
struct nouveau_object **pobject)
{ {
struct nouveau_engctx *engctx; struct nvkm_engctx *engctx;
int ret; int ret;
ret = nouveau_engctx_create(parent, engine, oclass, NULL, ret = nvkm_engctx_create(parent, engine, oclass, NULL, 0x10000, 0x1000,
0x10000, 0x1000, NVOBJ_FLAG_ZERO_ALLOC, &engctx);
NVOBJ_FLAG_ZERO_ALLOC, &engctx);
*pobject = nv_object(engctx); *pobject = nv_object(engctx);
return ret; return ret;
} }
void void
_nouveau_xtensa_intr(struct nouveau_subdev *subdev) _nvkm_xtensa_intr(struct nvkm_subdev *subdev)
{ {
struct nouveau_xtensa *xtensa = (void *)subdev; struct nvkm_xtensa *xtensa = (void *)subdev;
u32 unk104 = nv_ro32(xtensa, 0xd04); u32 unk104 = nv_ro32(xtensa, 0xd04);
u32 intr = nv_ro32(xtensa, 0xc20); u32 intr = nv_ro32(xtensa, 0xc20);
u32 chan = nv_ro32(xtensa, 0xc28); u32 chan = nv_ro32(xtensa, 0xc28);
...@@ -72,39 +71,36 @@ _nouveau_xtensa_intr(struct nouveau_subdev *subdev) ...@@ -72,39 +71,36 @@ _nouveau_xtensa_intr(struct nouveau_subdev *subdev)
} }
int int
nouveau_xtensa_create_(struct nouveau_object *parent, nvkm_xtensa_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nouveau_object *engine, struct nvkm_oclass *oclass, u32 addr, bool enable,
struct nouveau_oclass *oclass, u32 addr, bool enable, const char *iname, const char *fname,
const char *iname, const char *fname, int length, void **pobject)
int length, void **pobject)
{ {
struct nouveau_xtensa *xtensa; struct nvkm_xtensa *xtensa;
int ret; int ret;
ret = nouveau_engine_create_(parent, engine, oclass, enable, iname, ret = nvkm_engine_create_(parent, engine, oclass, enable, iname,
fname, length, pobject); fname, length, pobject);
xtensa = *pobject; xtensa = *pobject;
if (ret) if (ret)
return ret; return ret;
nv_subdev(xtensa)->intr = _nouveau_xtensa_intr; nv_subdev(xtensa)->intr = _nvkm_xtensa_intr;
xtensa->addr = addr; xtensa->addr = addr;
return 0; return 0;
} }
int int
_nouveau_xtensa_init(struct nouveau_object *object) _nvkm_xtensa_init(struct nvkm_object *object)
{ {
struct nouveau_device *device = nv_device(object); struct nvkm_device *device = nv_device(object);
struct nouveau_xtensa *xtensa = (void *)object; struct nvkm_xtensa *xtensa = (void *)object;
const struct firmware *fw; const struct firmware *fw;
char name[32]; char name[32];
int i, ret; int i, ret;
u32 tmp; u32 tmp;
ret = nouveau_engine_init(&xtensa->base); ret = nvkm_engine_init(&xtensa->base);
if (ret) if (ret)
return ret; return ret;
...@@ -124,8 +120,8 @@ _nouveau_xtensa_init(struct nouveau_object *object) ...@@ -124,8 +120,8 @@ _nouveau_xtensa_init(struct nouveau_object *object)
return -EINVAL; return -EINVAL;
} }
ret = nouveau_gpuobj_new(object, NULL, 0x40000, 0x1000, 0, ret = nvkm_gpuobj_new(object, NULL, 0x40000, 0x1000, 0,
&xtensa->gpu_fw); &xtensa->gpu_fw);
if (ret) { if (ret) {
release_firmware(fw); release_firmware(fw);
return ret; return ret;
...@@ -157,20 +153,19 @@ _nouveau_xtensa_init(struct nouveau_object *object) ...@@ -157,20 +153,19 @@ _nouveau_xtensa_init(struct nouveau_object *object)
nv_wo32(xtensa, 0xc20, 0x3f); /* INTR */ nv_wo32(xtensa, 0xc20, 0x3f); /* INTR */
nv_wo32(xtensa, 0xd84, 0x3f); /* INTR_EN */ nv_wo32(xtensa, 0xd84, 0x3f); /* INTR_EN */
return 0; return 0;
} }
int int
_nouveau_xtensa_fini(struct nouveau_object *object, bool suspend) _nvkm_xtensa_fini(struct nvkm_object *object, bool suspend)
{ {
struct nouveau_xtensa *xtensa = (void *)object; struct nvkm_xtensa *xtensa = (void *)object;
nv_wo32(xtensa, 0xd84, 0); /* INTR_EN */ nv_wo32(xtensa, 0xd84, 0); /* INTR_EN */
nv_wo32(xtensa, 0xd94, 0); /* FIFO_CTRL */ nv_wo32(xtensa, 0xd94, 0); /* FIFO_CTRL */
if (!suspend) if (!suspend)
nouveau_gpuobj_ref(NULL, &xtensa->gpu_fw); nvkm_gpuobj_ref(NULL, &xtensa->gpu_fw);
return nouveau_engine_fini(&xtensa->base, suspend); return nvkm_engine_fini(&xtensa->base, suspend);
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/notify.h>
#include <subdev/bios.h> #include <subdev/bios.h>
#include <subdev/bios/gpio.h> #include <subdev/bios/gpio.h>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <core/notify.h>
#include <core/option.h> #include <core/option.h>
#include <core/object.h> #include <core/object.h>
#include <core/event.h> #include <core/event.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment