blob: ad2d38a2b5cc03a4baadf8fb72855d4308b754ac [file] [log] [blame]
Aurora pro automerger35e34032022-05-14 14:55:22 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * IOMMU domain allocator for gxp
4 *
5 * Copyright (C) 2022 Google LLC
6 */
7
8#ifndef __GXP_DOMAIN_POOL_H__
9#define __GXP_DOMAIN_POOL_H__
10
Aurora pro automerger8a4b0d92023-01-06 06:59:41 +000011#include <gcip/gcip-domain-pool.h>
Aurora pro automerger35e34032022-05-14 14:55:22 -070012
Aurora pro automerger8a4b0d92023-01-06 06:59:41 +000013#include "gxp-dma.h"
Aurora pro automerger35e34032022-05-14 14:55:22 -070014
15/*
16 * Initializes a domain pool.
17 *
18 * @gxp: pointer to gxp device.
19 * @pool: caller-allocated pool structure.
20 * @size: size of the pre-allocated domains pool.
21 * Set to zero to fall back to dynamically allocated domains.
22 *
23 * returns 0 on success or negative error value.
24 */
Aurora pro automerger8a4b0d92023-01-06 06:59:41 +000025int gxp_domain_pool_init(struct gxp_dev *gxp, struct gcip_domain_pool *pool,
Aurora pro automerger35e34032022-05-14 14:55:22 -070026 unsigned int size);
27
28/*
29 * Allocates a domain from the pool
30 * returns NULL on error.
31 */
Aurora pro automerger8a4b0d92023-01-06 06:59:41 +000032struct gxp_iommu_domain *gxp_domain_pool_alloc(struct gcip_domain_pool *pool);
Aurora pro automerger35e34032022-05-14 14:55:22 -070033
34/* Releases a domain from the pool. */
Aurora pro automerger8a4b0d92023-01-06 06:59:41 +000035void gxp_domain_pool_free(struct gcip_domain_pool *pool,
36 struct gxp_iommu_domain *gdomain);
Aurora pro automerger35e34032022-05-14 14:55:22 -070037
38/* Cleans up all resources used by the domain pool. */
Aurora pro automerger8a4b0d92023-01-06 06:59:41 +000039void gxp_domain_pool_destroy(struct gcip_domain_pool *pool);
Aurora pro automerger35e34032022-05-14 14:55:22 -070040#endif /* __GXP_DOMAIN_POOL_H__ */