Commit 996f5a08 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/core: pass related object into notify constructor

The event source types/index might need to be derived from it.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent e94654e2
...@@ -91,9 +91,10 @@ nvkm_client_notify_del(struct nouveau_client *client, int index) ...@@ -91,9 +91,10 @@ nvkm_client_notify_del(struct nouveau_client *client, int index)
} }
int int
nvkm_client_notify_new(struct nouveau_client *client, nvkm_client_notify_new(struct nouveau_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_notify *notify; struct nvkm_client_notify *notify;
union { union {
struct nvif_notify_req_v0 v0; struct nvif_notify_req_v0 v0;
...@@ -127,8 +128,8 @@ nvkm_client_notify_new(struct nouveau_client *client, ...@@ -127,8 +128,8 @@ nvkm_client_notify_new(struct nouveau_client *client,
} }
if (ret == 0) { if (ret == 0) {
ret = nvkm_notify_init(event, nvkm_client_notify, false, ret = nvkm_notify_init(object, event, nvkm_client_notify,
data, size, reply, &notify->n); false, data, size, reply, &notify->n);
if (ret == 0) { if (ret == 0) {
client->notify[index] = notify; client->notify[index] = notify;
notify->client = client; notify->client = client;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <core/os.h> #include <core/object.h>
#include <core/event.h> #include <core/event.h>
void void
......
...@@ -349,7 +349,6 @@ nvkm_ioctl_unmap(struct nouveau_handle *handle, void *data, u32 size) ...@@ -349,7 +349,6 @@ nvkm_ioctl_unmap(struct nouveau_handle *handle, void *data, u32 size)
static int static int
nvkm_ioctl_ntfy_new(struct nouveau_handle *handle, void *data, u32 size) nvkm_ioctl_ntfy_new(struct nouveau_handle *handle, void *data, u32 size)
{ {
struct nouveau_client *client = nouveau_client(handle->object);
struct nouveau_object *object = handle->object; struct nouveau_object *object = handle->object;
struct nouveau_ofuncs *ofuncs = object->oclass->ofuncs; struct nouveau_ofuncs *ofuncs = object->oclass->ofuncs;
union { union {
...@@ -365,7 +364,7 @@ nvkm_ioctl_ntfy_new(struct nouveau_handle *handle, void *data, u32 size) ...@@ -365,7 +364,7 @@ nvkm_ioctl_ntfy_new(struct nouveau_handle *handle, void *data, u32 size)
if (ret = -ENODEV, ofuncs->ntfy) if (ret = -ENODEV, ofuncs->ntfy)
ret = ofuncs->ntfy(object, args->v0.event, &event); ret = ofuncs->ntfy(object, args->v0.event, &event);
if (ret == 0) { if (ret == 0) {
ret = nvkm_client_notify_new(client, event, data, size); ret = nvkm_client_notify_new(object, event, data, size);
if (ret >= 0) { if (ret >= 0) {
args->v0.index = ret; args->v0.index = ret;
ret = 0; ret = 0;
......
...@@ -134,14 +134,15 @@ nvkm_notify_fini(struct nvkm_notify *notify) ...@@ -134,14 +134,15 @@ nvkm_notify_fini(struct nvkm_notify *notify)
} }
int int
nvkm_notify_init(struct nvkm_event *event, int (*func)(struct nvkm_notify *), nvkm_notify_init(struct nouveau_object *object, struct nvkm_event *event,
bool work, void *data, u32 size, u32 reply, int (*func)(struct nvkm_notify *), bool work,
void *data, u32 size, u32 reply,
struct nvkm_notify *notify) struct nvkm_notify *notify)
{ {
unsigned long flags; unsigned long flags;
int ret = -ENODEV; int ret = -ENODEV;
if ((notify->event = event), event->refs) { if ((notify->event = event), event->refs) {
ret = event->func->ctor(data, size, notify); ret = event->func->ctor(object, data, size, notify);
if (ret == 0 && (ret = -EINVAL, notify->size == reply)) { if (ret == 0 && (ret = -EINVAL, notify->size == reply)) {
notify->flags = 0; notify->flags = 0;
notify->block = 1; notify->block = 1;
......
...@@ -505,7 +505,8 @@ nouveau_device_sclass[] = { ...@@ -505,7 +505,8 @@ nouveau_device_sclass[] = {
}; };
static int static int
nouveau_device_event_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_device_event_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
if (!WARN_ON(size != 0)) { if (!WARN_ON(size != 0)) {
notify->size = 0; notify->size = 0;
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
#include "conn.h" #include "conn.h"
int int
nouveau_disp_vblank_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_disp_vblank_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
struct nouveau_disp *disp = struct nouveau_disp *disp =
container_of(notify->event, typeof(*disp), vblank); container_of(notify->event, typeof(*disp), vblank);
...@@ -61,7 +62,8 @@ nouveau_disp_vblank(struct nouveau_disp *disp, int head) ...@@ -61,7 +62,8 @@ nouveau_disp_vblank(struct nouveau_disp *disp, int head)
} }
static int static int
nouveau_disp_hpd_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_disp_hpd_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
struct nouveau_disp *disp = struct nouveau_disp *disp =
container_of(notify->event, typeof(*disp), hpd); container_of(notify->event, typeof(*disp), hpd);
......
...@@ -126,8 +126,8 @@ nvkm_connector_create_(struct nouveau_object *parent, ...@@ -126,8 +126,8 @@ nvkm_connector_create_(struct nouveau_object *parent,
return 0; return 0;
} }
ret = nvkm_notify_init(&gpio->event, nvkm_connector_hpd, true, ret = nvkm_notify_init(NULL, &gpio->event, nvkm_connector_hpd,
&(struct nvkm_gpio_ntfy_req) { true, &(struct nvkm_gpio_ntfy_req) {
.mask = NVKM_GPIO_TOGGLED, .mask = NVKM_GPIO_TOGGLED,
.line = func.line, .line = func.line,
}, },
......
...@@ -254,7 +254,7 @@ nvkm_output_dp_create_(struct nouveau_object *parent, ...@@ -254,7 +254,7 @@ nvkm_output_dp_create_(struct nouveau_object *parent,
atomic_set(&outp->lt.done, 0); atomic_set(&outp->lt.done, 0);
/* link maintenance */ /* link maintenance */
ret = nvkm_notify_init(&i2c->event, nvkm_output_dp_irq, true, ret = nvkm_notify_init(NULL, &i2c->event, nvkm_output_dp_irq, true,
&(struct nvkm_i2c_ntfy_req) { &(struct nvkm_i2c_ntfy_req) {
.mask = NVKM_I2C_IRQ, .mask = NVKM_I2C_IRQ,
.port = outp->base.edid->index, .port = outp->base.edid->index,
...@@ -268,7 +268,7 @@ nvkm_output_dp_create_(struct nouveau_object *parent, ...@@ -268,7 +268,7 @@ nvkm_output_dp_create_(struct nouveau_object *parent,
} }
/* hotplug detect, replaces gpio-based mechanism with aux events */ /* hotplug detect, replaces gpio-based mechanism with aux events */
ret = nvkm_notify_init(&i2c->event, nvkm_output_dp_hpd, true, ret = nvkm_notify_init(NULL, &i2c->event, nvkm_output_dp_hpd, true,
&(struct nvkm_i2c_ntfy_req) { &(struct nvkm_i2c_ntfy_req) {
.mask = NVKM_I2C_PLUG | NVKM_I2C_UNPLUG, .mask = NVKM_I2C_PLUG | NVKM_I2C_UNPLUG,
.port = outp->base.edid->index, .port = outp->base.edid->index,
......
...@@ -40,7 +40,8 @@ int _nouveau_disp_fini(struct nouveau_object *, bool); ...@@ -40,7 +40,8 @@ int _nouveau_disp_fini(struct nouveau_object *, bool);
extern struct nouveau_oclass *nvkm_output_oclass; extern struct nouveau_oclass *nvkm_output_oclass;
extern struct nouveau_oclass *nvkm_connector_oclass; extern struct nouveau_oclass *nvkm_connector_oclass;
int nouveau_disp_vblank_ctor(void *data, u32 size, struct nvkm_notify *); int nouveau_disp_vblank_ctor(struct nouveau_object *, void *data, u32 size,
struct nvkm_notify *);
void nouveau_disp_vblank(struct nouveau_disp *, int head); void nouveau_disp_vblank(struct nouveau_disp *, int head);
int nouveau_disp_ntfy(struct nouveau_object *, u32, struct nvkm_event **); int nouveau_disp_ntfy(struct nouveau_object *, u32, struct nvkm_event **);
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
#include <engine/fifo.h> #include <engine/fifo.h>
static int static int
nouveau_fifo_event_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_fifo_event_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
if (size == 0) { if (size == 0) {
notify->size = 0; notify->size = 0;
...@@ -170,7 +171,8 @@ _nouveau_fifo_channel_wr32(struct nouveau_object *object, u64 addr, u32 data) ...@@ -170,7 +171,8 @@ _nouveau_fifo_channel_wr32(struct nouveau_object *object, u64 addr, u32 data)
} }
int int
nouveau_fifo_uevent_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_fifo_uevent_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
union { union {
struct nvif_notify_uevent_req none; struct nvif_notify_uevent_req none;
......
...@@ -175,7 +175,8 @@ nv50_software_context_ctor(struct nouveau_object *parent, ...@@ -175,7 +175,8 @@ nv50_software_context_ctor(struct nouveau_object *parent,
return ret; return ret;
for (i = 0; pdisp && i < pdisp->vblank.index_nr; i++) { for (i = 0; pdisp && i < pdisp->vblank.index_nr; i++) {
ret = nvkm_notify_init(&pdisp->vblank, pclass->vblank, false, ret = nvkm_notify_init(NULL, &pdisp->vblank, pclass->vblank,
false,
&(struct nvif_notify_head_req_v0) { &(struct nvif_notify_head_req_v0) {
.head = i, .head = i,
}, },
......
...@@ -48,7 +48,7 @@ int nouveau_client_init(struct nouveau_client *); ...@@ -48,7 +48,7 @@ int nouveau_client_init(struct nouveau_client *);
int nouveau_client_fini(struct nouveau_client *, bool suspend); int nouveau_client_fini(struct nouveau_client *, bool suspend);
const char *nouveau_client_name(void *obj); const char *nouveau_client_name(void *obj);
int nvkm_client_notify_new(struct nouveau_client *, struct nvkm_event *, int nvkm_client_notify_new(struct nouveau_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 nouveau_client *, int index);
int nvkm_client_notify_get(struct nouveau_client *, int index); int nvkm_client_notify_get(struct nouveau_client *, int index);
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include <core/notify.h> #include <core/notify.h>
struct nvkm_event_func { struct nvkm_event_func {
int (*ctor)(void *data, u32 size, struct nvkm_notify *); int (*ctor)(struct nouveau_object *, void *data, u32 size,
struct nvkm_notify *);
void (*send)(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 (*init)(struct nvkm_event *, int type, int index);
void (*fini)(struct nvkm_event *, int type, int index); void (*fini)(struct nvkm_event *, int type, int index);
......
...@@ -25,8 +25,9 @@ struct nvkm_notify { ...@@ -25,8 +25,9 @@ struct nvkm_notify {
const void *data; const void *data;
}; };
int nvkm_notify_init(struct nvkm_event *, int (*func)(struct nvkm_notify *), int nvkm_notify_init(struct nouveau_object *, struct nvkm_event *,
bool work, void *data, u32 size, u32 reply, int (*func)(struct nvkm_notify *), bool work,
void *data, u32 size, u32 reply,
struct nvkm_notify *); struct nvkm_notify *);
void nvkm_notify_fini(struct nvkm_notify *); void nvkm_notify_fini(struct nvkm_notify *);
void nvkm_notify_get(struct nvkm_notify *); void nvkm_notify_get(struct nvkm_notify *);
......
...@@ -116,7 +116,8 @@ extern struct nouveau_oclass *nve0_fifo_oclass; ...@@ -116,7 +116,8 @@ extern struct nouveau_oclass *nve0_fifo_oclass;
extern struct nouveau_oclass *gk20a_fifo_oclass; extern struct nouveau_oclass *gk20a_fifo_oclass;
extern struct nouveau_oclass *nv108_fifo_oclass; extern struct nouveau_oclass *nv108_fifo_oclass;
int nouveau_fifo_uevent_ctor(void *, u32, struct nvkm_notify *); int nouveau_fifo_uevent_ctor(struct nouveau_object *, void *, u32,
struct nvkm_notify *);
void nouveau_fifo_uevent(struct nouveau_fifo *); void nouveau_fifo_uevent(struct nouveau_fifo *);
void nv04_fifo_intr(struct nouveau_subdev *); void nv04_fifo_intr(struct nouveau_subdev *);
......
...@@ -573,7 +573,7 @@ nouveau_clock_create_(struct nouveau_object *parent, ...@@ -573,7 +573,7 @@ nouveau_clock_create_(struct nouveau_object *parent,
clk->allow_reclock = allow_reclock; clk->allow_reclock = allow_reclock;
ret = nvkm_notify_init(&device->event, nouveau_clock_pwrsrc, true, ret = nvkm_notify_init(NULL, &device->event, nouveau_clock_pwrsrc, true,
NULL, 0, 0, &clk->pwrsrc_ntfy); NULL, 0, 0, &clk->pwrsrc_ntfy);
if (ret) if (ret)
return ret; return ret;
......
...@@ -122,7 +122,8 @@ nouveau_gpio_intr_init(struct nvkm_event *event, int type, int index) ...@@ -122,7 +122,8 @@ nouveau_gpio_intr_init(struct nvkm_event *event, int type, int index)
} }
static int static int
nouveau_gpio_intr_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_gpio_intr_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
struct nvkm_gpio_ntfy_req *req = data; struct nvkm_gpio_ntfy_req *req = data;
if (!WARN_ON(size != sizeof(*req))) { if (!WARN_ON(size != sizeof(*req))) {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
#include <core/option.h> #include <core/option.h>
#include <core/object.h>
#include <core/event.h> #include <core/event.h>
#include <subdev/bios.h> #include <subdev/bios.h>
...@@ -346,7 +347,8 @@ nouveau_i2c_intr_init(struct nvkm_event *event, int type, int index) ...@@ -346,7 +347,8 @@ nouveau_i2c_intr_init(struct nvkm_event *event, int type, int index)
} }
static int static int
nouveau_i2c_intr_ctor(void *data, u32 size, struct nvkm_notify *notify) nouveau_i2c_intr_ctor(struct nouveau_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
struct nvkm_i2c_ntfy_req *req = data; struct nvkm_i2c_ntfy_req *req = data;
if (!WARN_ON(size != sizeof(*req))) { if (!WARN_ON(size != sizeof(*req))) {
......
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