Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * DMA BUF PagePool implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Based on earlier ION code by Google
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2011 Google, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright (C) 2020 Linaro Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef _DMABUF_PAGE_POOL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _DMABUF_PAGE_POOL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mm_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/shrinker.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* page types we track in the pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	POOL_LOWPAGE,      /* Clean lowmem pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	POOL_HIGHPAGE,     /* Clean highmem pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	POOL_TYPE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  * struct dmabuf_page_pool - pagepool struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)  * @count[]:		array of number of pages of that type in the pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)  * @items[]:		array of list of pages of the specific type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)  * @mutex:		lock protecting this struct and especially the count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  *			item list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)  * @gfp_mask:		gfp_mask to use from alloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  * @order:		order of pages in the pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  * @list:		list node for list of pools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  * Allows you to keep a pool of pre allocated pages to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct dmabuf_page_pool {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	int count[POOL_TYPE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	struct list_head items[POOL_TYPE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	gfp_t gfp_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	unsigned int order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct dmabuf_page_pool *dmabuf_page_pool_create(gfp_t gfp_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 						 unsigned int order);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) void dmabuf_page_pool_destroy(struct dmabuf_page_pool *pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct page *dmabuf_page_pool_alloc(struct dmabuf_page_pool *pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void dmabuf_page_pool_free(struct dmabuf_page_pool *pool, struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #endif /* _DMABUF_PAGE_POOL_H */