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 {
const struct nvkm_pm_func *func;
struct nvkm_engine engine;
struct nvkm_object *perfmon;
struct {
spinlock_t lock;
struct nvkm_object *object;
} client;
struct list_head domains;
struct list_head sources;
......
......@@ -628,10 +628,10 @@ nvkm_perfmon_dtor(struct nvkm_object *object)
{
struct nvkm_perfmon *perfmon = nvkm_perfmon(object);
struct nvkm_pm *pm = perfmon->pm;
mutex_lock(&pm->engine.subdev.mutex);
if (pm->perfmon == &perfmon->object)
pm->perfmon = NULL;
mutex_unlock(&pm->engine.subdev.mutex);
spin_lock(&pm->client.lock);
if (pm->client.object == &perfmon->object)
pm->client.object = NULL;
spin_unlock(&pm->client.lock);
return perfmon;
}
......@@ -671,11 +671,11 @@ nvkm_pm_oclass_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
if (ret)
return ret;
mutex_lock(&pm->engine.subdev.mutex);
if (pm->perfmon == NULL)
pm->perfmon = *pobject;
ret = (pm->perfmon == *pobject) ? 0 : -EBUSY;
mutex_unlock(&pm->engine.subdev.mutex);
spin_lock(&pm->client.lock);
if (pm->client.object == NULL)
pm->client.object = *pobject;
ret = (pm->client.object == *pobject) ? 0 : -EBUSY;
spin_unlock(&pm->client.lock);
return ret;
}
......@@ -863,5 +863,6 @@ nvkm_pm_ctor(const struct nvkm_pm_func *func, struct nvkm_device *device,
pm->func = func;
INIT_LIST_HEAD(&pm->domains);
INIT_LIST_HEAD(&pm->sources);
spin_lock_init(&pm->client.lock);
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