File Index
Files and directories
Sign in
FILE

client.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/client.c C
 1/* SPDX-License-Identifier: MIT
 2 *
 3 * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
 4 */
 5#include "rm.h"
 6
 7void
 8nvkm_gsp_client_dtor(struct nvkm_gsp_client *client)
 9{
10	const unsigned int id = client->object.handle - NVKM_RM_CLIENT(0);
11	struct nvkm_gsp *gsp = client->gsp;
12
13	if (!gsp)
14		return;
15
16	if (client->object.client)
17		nvkm_gsp_rm_free(&client->object);
18
19	mutex_lock(&gsp->client_id.mutex);
20	idr_remove(&gsp->client_id.idr, id);
21	mutex_unlock(&gsp->client_id.mutex);
22
23	client->gsp = NULL;
24}
25
26int
27nvkm_gsp_client_ctor(struct nvkm_gsp *gsp, struct nvkm_gsp_client *client)
28{
29	int id, ret;
30
31	if (WARN_ON(!gsp->rm))
32		return -ENOSYS;
33
34	mutex_lock(&gsp->client_id.mutex);
35	id = idr_alloc(&gsp->client_id.idr, client, 0, NVKM_RM_CLIENT_MASK + 1, GFP_KERNEL);
36	mutex_unlock(&gsp->client_id.mutex);
37	if (id < 0)
38		return id;
39
40	client->gsp = gsp;
41	client->object.client = client;
42	INIT_LIST_HEAD(&client->events);
43
44	ret = gsp->rm->api->client->ctor(client, NVKM_RM_CLIENT(id));
45	if (ret)
46		nvkm_gsp_client_dtor(client);
47
48	return ret;
49}
~/ Read-only file preview.