printf: Remove unused 'bprintf'
[drm/drm-misc.git] / arch / powerpc / include / asm / rtas-work-area.h
blob251a395dbd2e7afb496166127cb5e9e5ab71bb92
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASM_POWERPC_RTAS_WORK_AREA_H
3 #define _ASM_POWERPC_RTAS_WORK_AREA_H
5 #include <linux/build_bug.h>
6 #include <linux/sizes.h>
7 #include <linux/types.h>
9 #include <asm/page.h>
11 /**
12 * struct rtas_work_area - RTAS work area descriptor.
14 * Descriptor for a "work area" in PAPR terminology that satisfies
15 * RTAS addressing requirements.
17 struct rtas_work_area {
18 /* private: Use the APIs provided below. */
19 char *buf;
20 size_t size;
23 enum {
24 /* Maximum allocation size, enforced at build time. */
25 RTAS_WORK_AREA_MAX_ALLOC_SZ = SZ_128K,
28 /**
29 * rtas_work_area_alloc() - Acquire a work area of the requested size.
30 * @size_: Allocation size. Must be compile-time constant and not more
31 * than %RTAS_WORK_AREA_MAX_ALLOC_SZ.
33 * Allocate a buffer suitable for passing to RTAS functions that have
34 * a memory address parameter, often (but not always) referred to as a
35 * "work area" in PAPR. Although callers are allowed to block while
36 * holding a work area, the amount of memory reserved for this purpose
37 * is limited, and allocations should be short-lived. A good guideline
38 * is to release any allocated work area before returning from a
39 * system call.
41 * This function does not fail. It blocks until the allocation
42 * succeeds. To prevent deadlocks, callers are discouraged from
43 * allocating more than one work area simultaneously in a single task
44 * context.
46 * Context: This function may sleep.
47 * Return: A &struct rtas_work_area descriptor for the allocated work area.
49 #define rtas_work_area_alloc(size_) ({ \
50 static_assert(__builtin_constant_p(size_)); \
51 static_assert((size_) > 0); \
52 static_assert((size_) <= RTAS_WORK_AREA_MAX_ALLOC_SZ); \
53 __rtas_work_area_alloc(size_); \
57 * Do not call __rtas_work_area_alloc() directly. Use
58 * rtas_work_area_alloc().
60 struct rtas_work_area *__rtas_work_area_alloc(size_t size);
62 /**
63 * rtas_work_area_free() - Release a work area.
64 * @area: Work area descriptor as returned from rtas_work_area_alloc().
66 * Return a work area buffer to the pool.
68 void rtas_work_area_free(struct rtas_work_area *area);
70 static inline char *rtas_work_area_raw_buf(const struct rtas_work_area *area)
72 return area->buf;
75 static inline size_t rtas_work_area_size(const struct rtas_work_area *area)
77 return area->size;
80 static inline phys_addr_t rtas_work_area_phys(const struct rtas_work_area *area)
82 return __pa(area->buf);
86 * Early setup for the work area allocator. Call from
87 * rtas_initialize() only.
90 #ifdef CONFIG_PPC_PSERIES
91 void rtas_work_area_reserve_arena(phys_addr_t limit);
92 #else /* CONFIG_PPC_PSERIES */
93 static inline void rtas_work_area_reserve_arena(phys_addr_t limit) {}
94 #endif /* CONFIG_PPC_PSERIES */
96 #endif /* _ASM_POWERPC_RTAS_WORK_AREA_H */