diff options
author | Zuma copybara merger <zuma-automerger@google.com> | 2022-12-06 19:52:47 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-12-06 20:10:39 -0800 |
commit | e3f1d5b556891535c7b79933b15c18d42ab4d666 (patch) | |
tree | 44acbb57e6402788ac02a20b8f60aa180c488753 /drivers/edgetpu/gcip-kernel-driver/include/gcip | |
parent | 281d60c6af15345f0b4b19174cbbc5bd853d498c (diff) | |
download | rio-e3f1d5b556891535c7b79933b15c18d42ab4d666.tar.gz |
[Copybara Auto Merge] Merge branch zuma into android13-gs-pixel-5.15
gcip: fix log style in gcip domain pool
gcip: introduce gcip_kci_offload_chip_type
Bug: 260690355
gcip: add {link,unlink}_offload_vmbox KCI codes
Bug: 260690355 (repeat)
gcip: Add domain pool
Bug: 228907682
edgetpu: Apply gcip domain pool
Bug: 228907682 (repeat)
gcip: Add domain pool
Bug: 228907682 (repeat)
Signed-off-by: Zuma copybara merger <zuma-automerger@google.com>
GitOrigin-RevId: 0140eb032a3631b0b68da5a2ad612bc2ab7803d9
Change-Id: I8cdd19660d5cbcc22e0cee7c915176a8117ed75e
Diffstat (limited to 'drivers/edgetpu/gcip-kernel-driver/include/gcip')
-rw-r--r-- | drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-domain-pool.h | 49 | ||||
-rw-r--r-- | drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-kci.h | 9 |
2 files changed, 56 insertions, 2 deletions
diff --git a/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-domain-pool.h b/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-domain-pool.h new file mode 100644 index 0000000..b740bf9 --- /dev/null +++ b/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-domain-pool.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * GCIP IOMMU domain allocator. + * + * Copyright (C) 2022 Google LLC + */ + +#ifndef __GCIP_DOMAIN_POOL_H__ +#define __GCIP_DOMAIN_POOL_H__ + +#include <linux/idr.h> +#include <linux/iommu.h> + +struct gcip_domain_pool { + struct ida idp; /* ID allocator to keep track of used domains. */ + /* + * Size of the pool. Can be set to 0, in which case the implementation will fall back to + * dynamic domain allocation using the IOMMU API directly. + */ + unsigned int size; + struct iommu_domain **array; /* Array holding the pointers to pre-allocated domains. */ + struct device *dev; /* The device used for logging warnings/errors. */ +}; + +/* + * Initializes a domain pool. + * + * @dev: pointer to device structure. + * @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 gcip_domain_pool_init(struct device *dev, struct gcip_domain_pool *pool, unsigned int size); + +/* + * Allocates a domain from the pool + * returns NULL on error. + */ +struct iommu_domain *gcip_domain_pool_alloc(struct gcip_domain_pool *pool); + +/* Releases a domain from the pool. */ +void gcip_domain_pool_free(struct gcip_domain_pool *pool, struct iommu_domain *domain); + +/* Cleans up all resources used by the domain pool. */ +void gcip_domain_pool_destroy(struct gcip_domain_pool *pool); + +#endif /* __GCIP_DOMAIN_POOL_H__ */ diff --git a/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-kci.h b/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-kci.h index 74e44ae..bda1b40 100644 --- a/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-kci.h +++ b/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-kci.h @@ -93,10 +93,10 @@ enum gcip_kci_code { GCIP_KCI_CODE_GET_USAGE = 12, GCIP_KCI_CODE_NOTIFY_THROTTLING = 13, GCIP_KCI_CODE_BLOCK_BUS_SPEED_CONTROL = 14, - /* TODO(b/237955391): Update this code after decided. */ GCIP_KCI_CODE_ALLOCATE_VMBOX = 15, - /* TODO(b/237955391): Update this code after decided. */ GCIP_KCI_CODE_RELEASE_VMBOX = 16, + GCIP_KCI_CODE_LINK_OFFLOAD_VMBOX = 17, + GCIP_KCI_CODE_UNLINK_OFFLOAD_VMBOX = 18, GCIP_KCI_CODE_RKCI_ACK = 256, }; @@ -140,6 +140,11 @@ enum gcip_kci_error { GCIP_KCI_ERROR_UNAUTHENTICATED = 16, }; +/* Type of the chip of the offload vmbox to be linked. */ +enum gcip_kci_offload_chip_type { + GCIP_KCI_OFFLOAD_CHIP_TYPE_TPU = 0, +}; + /* * Reason for triggering the CMD doorbell. * The CMD doorbell is triggered either when a CMD is pushed or the RESP that might blocks the FW is |