blob: 2ff0a7c55c6f5ab28aa18aab517073854582012b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// SPDX-License-Identifier: GPL-2.0
/*
* GXP client structure.
*
* Copyright (C) 2021 Google LLC
*/
#include <linux/slab.h>
#include <linux/types.h>
#include "gxp-client.h"
#include "gxp-dma.h"
#include "gxp-internal.h"
#include "gxp-pm.h"
#include "gxp-vd.h"
#include "gxp-wakelock.h"
struct gxp_client *gxp_client_create(struct gxp_dev *gxp)
{
struct gxp_client *client;
client = kmalloc(sizeof(*client), GFP_KERNEL);
if (!client)
return ERR_PTR(-ENOMEM);
client->gxp = gxp;
init_rwsem(&client->semaphore);
client->has_block_wakelock = false;
client->requested_power_state = AUR_OFF;
client->requested_memory_power_state = 0;
client->vd = NULL;
client->tpu_mbx_allocated = false;
return client;
}
void gxp_client_destroy(struct gxp_client *client)
{
struct gxp_dev *gxp = client->gxp;
down_write(&gxp->vd_semaphore);
#if IS_ENABLED(CONFIG_ANDROID) && !IS_ENABLED(CONFIG_GXP_GEM5)
/*
* Unmap TPU buffers, if the mapping is already removed, this
* is a no-op.
*/
gxp_dma_unmap_tpu_buffer(gxp, client->mbx_desc);
#endif // CONFIG_ANDROID && !CONFIG_GXP_GEM5
if (client->has_vd_wakelock)
gxp_vd_stop(client->vd);
up_write(&gxp->vd_semaphore);
if (client->has_block_wakelock)
gxp_wakelock_release(client->gxp);
gxp_vd_release(client->vd);
kfree(client);
}
|