drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c
Extension
.c
Size
7544 bytes
Lines
321
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (handle_table[i].count == 0) {
				*handle = &handle_table[i];
				break;
			}
		}
		/* if the loop dus not break and *handle == NULL
		 * this is an error handle and report it.
		 */
		if (!*handle) {
			ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
					    "ia_css_i_host_refcount_retain_vbuf() failed to find empty slot!\n");
			return;
		}
		(*handle)->vptr = h->vptr;
		(*handle)->size = h->size;
	}
	(*handle)->count++;
}

/*
 * @brief Release the reference count for a handle (host, vbuf)
 *
 * @param handle	The pointer to the handle
 */
void ia_css_rmgr_refcount_release_vbuf(struct ia_css_rmgr_vbuf_handle **handle)
{
	if ((!handle) || ((*handle) == NULL) || (((*handle)->count) == 0)) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR, "%s invalid arguments!\n", __func__);
		return;
	}
	/* decrease reference count */
	(*handle)->count--;
	/* remove from admin */
	if ((*handle)->count == 0) {
		(*handle)->vptr = 0x0;
		(*handle)->size = 0;
		*handle = NULL;
	}
}

/*
 * @brief Initialize the resource pool (host, vbuf)
 *
 * @param pool	The pointer to the pool
 */
int ia_css_rmgr_init_vbuf(struct ia_css_rmgr_vbuf_pool *pool)
{
	int err = 0;
	size_t bytes_needed;

	rmgr_refcount_init_vbuf();
	assert(pool);
	if (!pool)
		return -EINVAL;
	/* initialize the recycle pool if used */
	if (pool->recycle && pool->size) {
		/* allocate memory for storing the handles */
		bytes_needed =
		    sizeof(void *) *
		    pool->size;
		pool->handles = kvmalloc(bytes_needed, GFP_KERNEL);
		if (pool->handles)
			memset(pool->handles, 0, bytes_needed);
		else
			err = -ENOMEM;
	} else {
		/* just in case, set the size to 0 */
		pool->size = 0;
		pool->handles = NULL;
	}
	return err;
}

/*
 * @brief Uninitialize the resource pool (host, vbuf)
 *
 * @param pool	The pointer to the pool
 */
void ia_css_rmgr_uninit_vbuf(struct ia_css_rmgr_vbuf_pool *pool)
{
	u32 i;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "%s\n", __func__);
	if (!pool) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR, "%s NULL argument\n", __func__);
		return;
	}
	if (pool->handles) {
		/* free the hmm buffers */
		for (i = 0; i < pool->size; i++) {

Annotation

Implementation Notes