summaryrefslogtreecommitdiff
path: root/gxp-domain-pool.h
blob: 8b2cc67b3969bf4eb4ace9db3bf3f334ab33cf1a (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
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * IOMMU domain allocator for gxp
 *
 * Copyright (C) 2022 Google LLC
 */

#ifndef __GXP_DOMAIN_POOL_H__
#define __GXP_DOMAIN_POOL_H__

#include <gcip/gcip-iommu.h>

#include "gxp-dma.h"

/*
 * Initializes a domain pool.
 *
 * @gxp: pointer to gxp device.
 * @pool: caller-allocated pool structure.
 * @size: size of the pre-allocated domains pool.
 * Set to zero to fall back to dynamically allocated domains.
 *
 * returns 0 on success or negative error value.
 */
int gxp_domain_pool_init(struct gxp_dev *gxp,
			 struct gcip_iommu_domain_pool *pool,
			 unsigned int size);

/*
 * Allocates a domain from the pool
 * returns NULL on error.
 */
struct gcip_iommu_domain *
gxp_domain_pool_alloc(struct gcip_iommu_domain_pool *pool);

/* Releases a domain from the pool. */
void gxp_domain_pool_free(struct gcip_iommu_domain_pool *pool,
			  struct gcip_iommu_domain *gdomain);

/* Cleans up all resources used by the domain pool. */
void gxp_domain_pool_destroy(struct gcip_iommu_domain_pool *pool);
#endif /* __GXP_DOMAIN_POOL_H__ */