Commit f8106922 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/perfmon: use private spinlock to control exclusive access to perfmon

nvkm_subdev.mutex is going away.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent a6419360
...@@ -7,7 +7,10 @@ struct nvkm_pm { ...@@ -7,7 +7,10 @@ struct nvkm_pm {
const struct nvkm_pm_func *func; const struct nvkm_pm_func *func;
struct nvkm_engine engine; struct nvkm_engine engine;
struct nvkm_object *perfmon; struct {
spinlock_t lock;
struct nvkm_object *object;
} client;
struct list_head domains; struct list_head domains;
struct list_head sources; struct list_head sources;
......
...@@ -628,10 +628,10 @@ nvkm_perfmon_dtor(struct nvkm_object *object) ...@@ -628,10 +628,10 @@ nvkm_perfmon_dtor(struct nvkm_object *object)
{ {
struct nvkm_perfmon *perfmon = nvkm_perfmon(object); struct nvkm_perfmon *perfmon = nvkm_perfmon(object);
struct nvkm_pm *pm = perfmon->pm; struct nvkm_pm *pm = perfmon->pm;
mutex_lock(&pm->engine.subdev.mutex); spin_lock(&pm->client.lock);
if (pm->perfmon == &perfmon->object) if (pm->client.object == &perfmon->object)
pm->perfmon = NULL; pm->client.object = NULL;
mutex_unlock(&pm->engine.subdev.mutex); spin_unlock(&pm->client.lock);
return perfmon; return perfmon;
} }
...@@ -671,11 +671,11 @@ nvkm_pm_oclass_new(struct nvkm_device *device, const struct nvkm_oclass *oclass, ...@@ -671,11 +671,11 @@ nvkm_pm_oclass_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
if (ret) if (ret)
return ret; return ret;
mutex_lock(&pm->engine.subdev.mutex); spin_lock(&pm->client.lock);
if (pm->perfmon == NULL) if (pm->client.object == NULL)
pm->perfmon = *pobject; pm->client.object = *pobject;
ret = (pm->perfmon == *pobject) ? 0 : -EBUSY; ret = (pm->client.object == *pobject) ? 0 : -EBUSY;
mutex_unlock(&pm->engine.subdev.mutex); spin_unlock(&pm->client.lock);
return ret; return ret;
} }
...@@ -863,5 +863,6 @@ nvkm_pm_ctor(const struct nvkm_pm_func *func, struct nvkm_device *device, ...@@ -863,5 +863,6 @@ nvkm_pm_ctor(const struct nvkm_pm_func *func, struct nvkm_device *device,
pm->func = func; pm->func = func;
INIT_LIST_HEAD(&pm->domains); INIT_LIST_HEAD(&pm->domains);
INIT_LIST_HEAD(&pm->sources); INIT_LIST_HEAD(&pm->sources);
spin_lock_init(&pm->client.lock);
return nvkm_engine_ctor(&nvkm_pm, device, index, true, &pm->engine); return nvkm_engine_ctor(&nvkm_pm, device, index, true, &pm->engine);
} }
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