Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 1 | /* 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 automerger | 8a4b0d9 | 2023-01-06 06:59:41 +0000 | [diff] [blame] | 11 | #include <gcip/gcip-domain-pool.h> |
Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 12 | |
Aurora pro automerger | 8a4b0d9 | 2023-01-06 06:59:41 +0000 | [diff] [blame] | 13 | #include "gxp-dma.h" |
Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 14 | |
| 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 automerger | 8a4b0d9 | 2023-01-06 06:59:41 +0000 | [diff] [blame] | 25 | int gxp_domain_pool_init(struct gxp_dev *gxp, struct gcip_domain_pool *pool, |
Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 26 | unsigned int size); |
| 27 | |
| 28 | /* |
| 29 | * Allocates a domain from the pool |
| 30 | * returns NULL on error. |
| 31 | */ |
Aurora pro automerger | 8a4b0d9 | 2023-01-06 06:59:41 +0000 | [diff] [blame] | 32 | struct gxp_iommu_domain *gxp_domain_pool_alloc(struct gcip_domain_pool *pool); |
Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 33 | |
| 34 | /* Releases a domain from the pool. */ |
Aurora pro automerger | 8a4b0d9 | 2023-01-06 06:59:41 +0000 | [diff] [blame] | 35 | void gxp_domain_pool_free(struct gcip_domain_pool *pool, |
| 36 | struct gxp_iommu_domain *gdomain); |
Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 37 | |
| 38 | /* Cleans up all resources used by the domain pool. */ |
Aurora pro automerger | 8a4b0d9 | 2023-01-06 06:59:41 +0000 | [diff] [blame] | 39 | void gxp_domain_pool_destroy(struct gcip_domain_pool *pool); |
Aurora pro automerger | 35e3403 | 2022-05-14 14:55:22 -0700 | [diff] [blame] | 40 | #endif /* __GXP_DOMAIN_POOL_H__ */ |