| .. | .. |
|---|
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * |
|---|
| 4 | | - * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved. |
|---|
| 4 | + * (C) COPYRIGHT 2010-2022 ARM Limited. All rights reserved. |
|---|
| 5 | 5 | * |
|---|
| 6 | 6 | * This program is free software and is provided to you under the terms of the |
|---|
| 7 | 7 | * GNU General Public License version 2 as published by the Free Software |
|---|
| .. | .. |
|---|
| 27 | 27 | #define _UAPI_BASE_KERNEL_H_ |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | #include <linux/types.h> |
|---|
| 30 | | - |
|---|
| 31 | | -struct base_mem_handle { |
|---|
| 32 | | - struct { |
|---|
| 33 | | - __u64 handle; |
|---|
| 34 | | - } basep; |
|---|
| 35 | | -}; |
|---|
| 36 | | - |
|---|
| 37 | 30 | #include "mali_base_mem_priv.h" |
|---|
| 38 | 31 | #include "gpu/mali_kbase_gpu_id.h" |
|---|
| 39 | 32 | #include "gpu/mali_kbase_gpu_coherency.h" |
|---|
| 40 | 33 | |
|---|
| 41 | | -#define BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS 4 |
|---|
| 42 | | - |
|---|
| 43 | 34 | #define BASE_MAX_COHERENT_GROUPS 16 |
|---|
| 44 | | - |
|---|
| 45 | | -#if defined(CDBG_ASSERT) |
|---|
| 46 | | -#define LOCAL_ASSERT CDBG_ASSERT |
|---|
| 47 | | -#elif defined(KBASE_DEBUG_ASSERT) |
|---|
| 48 | | -#define LOCAL_ASSERT KBASE_DEBUG_ASSERT |
|---|
| 49 | | -#else |
|---|
| 50 | | -#if defined(__KERNEL__) |
|---|
| 51 | | -#error assert macro not defined! |
|---|
| 52 | | -#else |
|---|
| 53 | | -#define LOCAL_ASSERT(...) ((void)#__VA_ARGS__) |
|---|
| 54 | | -#endif |
|---|
| 55 | | -#endif |
|---|
| 56 | 35 | |
|---|
| 57 | 36 | #if defined(PAGE_MASK) && defined(PAGE_SHIFT) |
|---|
| 58 | 37 | #define LOCAL_PAGE_SHIFT PAGE_SHIFT |
|---|
| .. | .. |
|---|
| 162 | 141 | #define BASE_MEM_TILER_ALIGN_TOP_EXTENSION_MAX_PAGES \ |
|---|
| 163 | 142 | (1ull << (BASE_MEM_TILER_ALIGN_TOP_EXTENSION_MAX_PAGES_LOG2)) |
|---|
| 164 | 143 | |
|---|
| 165 | | -/* Bit mask of cookies used for for memory allocation setup */ |
|---|
| 144 | +/* Bit mask of cookies used for memory allocation setup */ |
|---|
| 166 | 145 | #define KBASE_COOKIE_MASK ~1UL /* bit 0 is reserved */ |
|---|
| 167 | 146 | |
|---|
| 168 | 147 | /* Maximum size allowed in a single KBASE_IOCTL_MEM_ALLOC call */ |
|---|
| .. | .. |
|---|
| 185 | 164 | /** |
|---|
| 186 | 165 | * struct base_mem_aliasing_info - Memory aliasing info |
|---|
| 187 | 166 | * |
|---|
| 167 | + * @handle: Handle to alias, can be BASE_MEM_WRITE_ALLOC_PAGES_HANDLE |
|---|
| 168 | + * @offset: Offset within the handle to start aliasing from, in pages. |
|---|
| 169 | + * Not used with BASE_MEM_WRITE_ALLOC_PAGES_HANDLE. |
|---|
| 170 | + * @length: Length to alias, in pages. For BASE_MEM_WRITE_ALLOC_PAGES_HANDLE |
|---|
| 171 | + * specifies the number of times the special page is needed. |
|---|
| 172 | + * |
|---|
| 188 | 173 | * Describes a memory handle to be aliased. |
|---|
| 189 | 174 | * A subset of the handle can be chosen for aliasing, given an offset and a |
|---|
| 190 | 175 | * length. |
|---|
| .. | .. |
|---|
| 196 | 181 | * Offset and length are specified in pages. |
|---|
| 197 | 182 | * Offset must be within the size of the handle. |
|---|
| 198 | 183 | * Offset+length must not overrun the size of the handle. |
|---|
| 199 | | - * |
|---|
| 200 | | - * @handle: Handle to alias, can be BASE_MEM_WRITE_ALLOC_PAGES_HANDLE |
|---|
| 201 | | - * @offset: Offset within the handle to start aliasing from, in pages. |
|---|
| 202 | | - * Not used with BASE_MEM_WRITE_ALLOC_PAGES_HANDLE. |
|---|
| 203 | | - * @length: Length to alias, in pages. For BASE_MEM_WRITE_ALLOC_PAGES_HANDLE |
|---|
| 204 | | - * specifies the number of times the special page is needed. |
|---|
| 205 | 184 | */ |
|---|
| 206 | 185 | struct base_mem_aliasing_info { |
|---|
| 207 | 186 | struct base_mem_handle handle; |
|---|
| .. | .. |
|---|
| 217 | 196 | /* Maximum number of concurrent just-in-time memory allocations. |
|---|
| 218 | 197 | */ |
|---|
| 219 | 198 | #define BASE_JIT_ALLOC_COUNT (255) |
|---|
| 220 | | - |
|---|
| 221 | | -/* base_jit_alloc_info in use for kernel driver versions 10.2 to early 11.5 |
|---|
| 222 | | - * |
|---|
| 223 | | - * jit_version is 1 |
|---|
| 224 | | - * |
|---|
| 225 | | - * Due to the lack of padding specified, user clients between 32 and 64-bit |
|---|
| 226 | | - * may have assumed a different size of the struct |
|---|
| 227 | | - * |
|---|
| 228 | | - * An array of structures was not supported |
|---|
| 229 | | - */ |
|---|
| 230 | | -struct base_jit_alloc_info_10_2 { |
|---|
| 231 | | - __u64 gpu_alloc_addr; |
|---|
| 232 | | - __u64 va_pages; |
|---|
| 233 | | - __u64 commit_pages; |
|---|
| 234 | | - __u64 extension; |
|---|
| 235 | | - __u8 id; |
|---|
| 236 | | -}; |
|---|
| 237 | | - |
|---|
| 238 | | -/* base_jit_alloc_info introduced by kernel driver version 11.5, and in use up |
|---|
| 239 | | - * to 11.19 |
|---|
| 240 | | - * |
|---|
| 241 | | - * This structure had a number of modifications during and after kernel driver |
|---|
| 242 | | - * version 11.5, but remains size-compatible throughout its version history, and |
|---|
| 243 | | - * with earlier variants compatible with future variants by requiring |
|---|
| 244 | | - * zero-initialization to the unused space in the structure. |
|---|
| 245 | | - * |
|---|
| 246 | | - * jit_version is 2 |
|---|
| 247 | | - * |
|---|
| 248 | | - * Kernel driver version history: |
|---|
| 249 | | - * 11.5: Initial introduction with 'usage_id' and padding[5]. All padding bytes |
|---|
| 250 | | - * must be zero. Kbase minor version was not incremented, so some |
|---|
| 251 | | - * versions of 11.5 do not have this change. |
|---|
| 252 | | - * 11.5: Added 'bin_id' and 'max_allocations', replacing 2 padding bytes (Kbase |
|---|
| 253 | | - * minor version not incremented) |
|---|
| 254 | | - * 11.6: Added 'flags', replacing 1 padding byte |
|---|
| 255 | | - * 11.10: Arrays of this structure are supported |
|---|
| 256 | | - */ |
|---|
| 257 | | -struct base_jit_alloc_info_11_5 { |
|---|
| 258 | | - __u64 gpu_alloc_addr; |
|---|
| 259 | | - __u64 va_pages; |
|---|
| 260 | | - __u64 commit_pages; |
|---|
| 261 | | - __u64 extension; |
|---|
| 262 | | - __u8 id; |
|---|
| 263 | | - __u8 bin_id; |
|---|
| 264 | | - __u8 max_allocations; |
|---|
| 265 | | - __u8 flags; |
|---|
| 266 | | - __u8 padding[2]; |
|---|
| 267 | | - __u16 usage_id; |
|---|
| 268 | | -}; |
|---|
| 269 | 199 | |
|---|
| 270 | 200 | /** |
|---|
| 271 | 201 | * struct base_jit_alloc_info - Structure which describes a JIT allocation |
|---|
| .. | .. |
|---|
| 296 | 226 | * @heap_info_gpu_addr: Pointer to an object in GPU memory describing |
|---|
| 297 | 227 | * the actual usage of the region. |
|---|
| 298 | 228 | * |
|---|
| 299 | | - * jit_version is 3. |
|---|
| 300 | | - * |
|---|
| 301 | | - * When modifications are made to this structure, it is still compatible with |
|---|
| 302 | | - * jit_version 3 when: a) the size is unchanged, and b) new members only |
|---|
| 303 | | - * replace the padding bytes. |
|---|
| 304 | | - * |
|---|
| 305 | | - * Previous jit_version history: |
|---|
| 306 | | - * jit_version == 1, refer to &base_jit_alloc_info_10_2 |
|---|
| 307 | | - * jit_version == 2, refer to &base_jit_alloc_info_11_5 |
|---|
| 308 | | - * |
|---|
| 309 | 229 | * Kbase version history: |
|---|
| 310 | 230 | * 11.20: added @heap_info_gpu_addr |
|---|
| 311 | 231 | */ |
|---|
| .. | .. |
|---|
| 332 | 252 | __u64 ext_resource; |
|---|
| 333 | 253 | }; |
|---|
| 334 | 254 | |
|---|
| 335 | | - |
|---|
| 336 | 255 | /** |
|---|
| 337 | | - * The maximum number of external resources which can be mapped/unmapped |
|---|
| 338 | | - * in a single request. |
|---|
| 256 | + * BASE_EXT_RES_COUNT_MAX - The maximum number of external resources |
|---|
| 257 | + * which can be mapped/unmapped in a single request. |
|---|
| 339 | 258 | */ |
|---|
| 340 | 259 | #define BASE_EXT_RES_COUNT_MAX 10 |
|---|
| 341 | 260 | |
|---|
| .. | .. |
|---|
| 360 | 279 | #define GPU_MAX_JOB_SLOTS 16 |
|---|
| 361 | 280 | |
|---|
| 362 | 281 | /** |
|---|
| 363 | | - * User-side Base GPU Property Queries |
|---|
| 282 | + * DOC: User-side Base GPU Property Queries |
|---|
| 364 | 283 | * |
|---|
| 365 | 284 | * The User-side Base GPU Property Query interface encapsulates two |
|---|
| 366 | 285 | * sub-modules: |
|---|
| .. | .. |
|---|
| 471 | 390 | * 16 coherent groups, since core groups are typically 4 cores. |
|---|
| 472 | 391 | */ |
|---|
| 473 | 392 | |
|---|
| 474 | | -#define BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS 4 |
|---|
| 475 | | - |
|---|
| 476 | | -#define BASE_MAX_COHERENT_GROUPS 16 |
|---|
| 477 | | -/** |
|---|
| 478 | | - * struct mali_base_gpu_core_props - GPU core props info |
|---|
| 479 | | - * @product_id: Pro specific value. |
|---|
| 480 | | - * @version_status: Status of the GPU release. No defined values, but starts at |
|---|
| 481 | | - * 0 and increases by one for each release status (alpha, beta, EAC, etc.). |
|---|
| 482 | | - * 4 bit values (0-15). |
|---|
| 483 | | - * @minor_revision: Minor release number of the GPU. "P" part of an "RnPn" |
|---|
| 484 | | - * release number. |
|---|
| 485 | | - * 8 bit values (0-255). |
|---|
| 486 | | - * @major_revision: Major release number of the GPU. "R" part of an "RnPn" |
|---|
| 487 | | - * release number. |
|---|
| 488 | | - * 4 bit values (0-15). |
|---|
| 489 | | - * @padding: padding to allign to 8-byte |
|---|
| 490 | | - * @gpu_freq_khz_max: The maximum GPU frequency. Reported to applications by |
|---|
| 491 | | - * clGetDeviceInfo() |
|---|
| 492 | | - * @log2_program_counter_size: Size of the shader program counter, in bits. |
|---|
| 493 | | - * @texture_features: TEXTURE_FEATURES_x registers, as exposed by the GPU. This |
|---|
| 494 | | - * is a bitpattern where a set bit indicates that the format is supported. |
|---|
| 495 | | - * Before using a texture format, it is recommended that the corresponding |
|---|
| 496 | | - * bit be checked. |
|---|
| 497 | | - * @gpu_available_memory_size: Theoretical maximum memory available to the GPU. |
|---|
| 498 | | - * It is unlikely that a client will be able to allocate all of this memory |
|---|
| 499 | | - * for their own purposes, but this at least provides an upper bound on the |
|---|
| 500 | | - * memory available to the GPU. |
|---|
| 501 | | - * This is required for OpenCL's clGetDeviceInfo() call when |
|---|
| 502 | | - * CL_DEVICE_GLOBAL_MEM_SIZE is requested, for OpenCL GPU devices. The |
|---|
| 503 | | - * client will not be expecting to allocate anywhere near this value. |
|---|
| 504 | | - * @num_exec_engines: The number of execution engines. |
|---|
| 505 | | - */ |
|---|
| 506 | | -struct mali_base_gpu_core_props { |
|---|
| 507 | | - __u32 product_id; |
|---|
| 508 | | - __u16 version_status; |
|---|
| 509 | | - __u16 minor_revision; |
|---|
| 510 | | - __u16 major_revision; |
|---|
| 511 | | - __u16 padding; |
|---|
| 512 | | - __u32 gpu_freq_khz_max; |
|---|
| 513 | | - __u32 log2_program_counter_size; |
|---|
| 514 | | - __u32 texture_features[BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS]; |
|---|
| 515 | | - __u64 gpu_available_memory_size; |
|---|
| 516 | | - __u8 num_exec_engines; |
|---|
| 517 | | -}; |
|---|
| 518 | | - |
|---|
| 519 | 393 | /* |
|---|
| 520 | 394 | * More information is possible - but associativity and bus width are not |
|---|
| 521 | 395 | * required by upper-level apis. |
|---|
| .. | .. |
|---|
| 546 | 420 | * field. |
|---|
| 547 | 421 | * @impl_tech: 0 = Not specified, 1 = Silicon, 2 = FPGA, |
|---|
| 548 | 422 | * 3 = SW Model/Emulation |
|---|
| 549 | | - * @padding: padding to allign to 8-byte |
|---|
| 423 | + * @padding: padding to align to 8-byte |
|---|
| 550 | 424 | * @tls_alloc: Number of threads per core that TLS must be |
|---|
| 551 | 425 | * allocated for |
|---|
| 552 | 426 | */ |
|---|
| .. | .. |
|---|
| 566 | 440 | * struct mali_base_gpu_coherent_group - descriptor for a coherent group |
|---|
| 567 | 441 | * @core_mask: Core restriction mask required for the group |
|---|
| 568 | 442 | * @num_cores: Number of cores in the group |
|---|
| 569 | | - * @padding: padding to allign to 8-byte |
|---|
| 443 | + * @padding: padding to align to 8-byte |
|---|
| 570 | 444 | * |
|---|
| 571 | 445 | * \c core_mask exposes all cores in that coherent group, and \c num_cores |
|---|
| 572 | | - * provides a cached population-count for that mask. |
|---|
| 446 | + * provides a cached population-count for that mask. |
|---|
| 573 | 447 | * |
|---|
| 574 | 448 | * @note Whilst all cores are exposed in the mask, not all may be available to |
|---|
| 575 | | - * the application, depending on the Kernel Power policy. |
|---|
| 449 | + * the application, depending on the Kernel Power policy. |
|---|
| 576 | 450 | * |
|---|
| 577 | 451 | * @note if u64s must be 8-byte aligned, then this structure has 32-bits of |
|---|
| 578 | | - * wastage. |
|---|
| 452 | + * wastage. |
|---|
| 579 | 453 | */ |
|---|
| 580 | 454 | struct mali_base_gpu_coherent_group { |
|---|
| 581 | 455 | __u64 core_mask; |
|---|
| .. | .. |
|---|
| 587 | 461 | * struct mali_base_gpu_coherent_group_info - Coherency group information |
|---|
| 588 | 462 | * @num_groups: Number of coherent groups in the GPU. |
|---|
| 589 | 463 | * @num_core_groups: Number of core groups (coherent or not) in the GPU. |
|---|
| 590 | | - * Equivalent to the number of L2 Caches. |
|---|
| 591 | | - * The GPU Counter dumping writes 2048 bytes per core group, regardless |
|---|
| 592 | | - * of whether the core groups are coherent or not. Hence this member is |
|---|
| 593 | | - * needed to calculate how much memory is required for dumping. |
|---|
| 594 | | - * @note Do not use it to work out how many valid elements are in the |
|---|
| 595 | | - * group[] member. Use num_groups instead. |
|---|
| 464 | + * Equivalent to the number of L2 Caches. |
|---|
| 465 | + * The GPU Counter dumping writes 2048 bytes per core group, |
|---|
| 466 | + * regardless of whether the core groups are coherent or not. |
|---|
| 467 | + * Hence this member is needed to calculate how much memory |
|---|
| 468 | + * is required for dumping. |
|---|
| 469 | + * @note Do not use it to work out how many valid elements |
|---|
| 470 | + * are in the group[] member. Use num_groups instead. |
|---|
| 596 | 471 | * @coherency: Coherency features of the memory, accessed by gpu_mem_features |
|---|
| 597 | | - * methods |
|---|
| 598 | | - * @padding: padding to allign to 8-byte |
|---|
| 472 | + * methods |
|---|
| 473 | + * @padding: padding to align to 8-byte |
|---|
| 599 | 474 | * @group: Descriptors of coherent groups |
|---|
| 600 | 475 | * |
|---|
| 601 | 476 | * Note that the sizes of the members could be reduced. However, the \c group |
|---|
| .. | .. |
|---|
| 612 | 487 | __u32 padding; |
|---|
| 613 | 488 | struct mali_base_gpu_coherent_group group[BASE_MAX_COHERENT_GROUPS]; |
|---|
| 614 | 489 | }; |
|---|
| 490 | + |
|---|
| 491 | +#if MALI_USE_CSF |
|---|
| 492 | +#include "csf/mali_base_csf_kernel.h" |
|---|
| 493 | +#else |
|---|
| 494 | +#include "jm/mali_base_jm_kernel.h" |
|---|
| 495 | +#endif |
|---|
| 615 | 496 | |
|---|
| 616 | 497 | /** |
|---|
| 617 | 498 | * struct gpu_raw_gpu_props - A complete description of the GPU's Hardware |
|---|
| .. | .. |
|---|
| 635 | 516 | * @thread_max_barrier_size: Maximum number of threads per barrier |
|---|
| 636 | 517 | * @thread_features: Thread features |
|---|
| 637 | 518 | * @coherency_mode: Note: This is the _selected_ coherency mode rather than the |
|---|
| 638 | | - * available modes as exposed in the coherency_features register |
|---|
| 519 | + * available modes as exposed in the coherency_features register |
|---|
| 639 | 520 | * @thread_tls_alloc: Number of threads per core that TLS must be allocated for |
|---|
| 640 | 521 | * @gpu_features: GPU features |
|---|
| 641 | 522 | * |
|---|
| .. | .. |
|---|
| 699 | 580 | * values from which the value of the other members are derived. The derived |
|---|
| 700 | 581 | * members exist to allow for efficient access and/or shielding the details |
|---|
| 701 | 582 | * of the layout of the registers. |
|---|
| 702 | | - * */ |
|---|
| 583 | + */ |
|---|
| 703 | 584 | struct base_gpu_props { |
|---|
| 704 | 585 | struct mali_base_gpu_core_props core_props; |
|---|
| 705 | 586 | struct mali_base_gpu_l2_cache_props l2_props; |
|---|
| .. | .. |
|---|
| 710 | 591 | struct mali_base_gpu_coherent_group_info coherency_info; |
|---|
| 711 | 592 | }; |
|---|
| 712 | 593 | |
|---|
| 713 | | -#if MALI_USE_CSF |
|---|
| 714 | | -#include "csf/mali_base_csf_kernel.h" |
|---|
| 715 | | -#else |
|---|
| 716 | | -#include "jm/mali_base_jm_kernel.h" |
|---|
| 717 | | -#endif |
|---|
| 594 | +#define BASE_MEM_GROUP_ID_GET(flags) \ |
|---|
| 595 | + ((flags & BASE_MEM_GROUP_ID_MASK) >> BASEP_MEM_GROUP_ID_SHIFT) |
|---|
| 718 | 596 | |
|---|
| 719 | | -/** |
|---|
| 720 | | - * base_mem_group_id_get() - Get group ID from flags |
|---|
| 721 | | - * @flags: Flags to pass to base_mem_alloc |
|---|
| 722 | | - * |
|---|
| 723 | | - * This inline function extracts the encoded group ID from flags |
|---|
| 724 | | - * and converts it into numeric value (0~15). |
|---|
| 725 | | - * |
|---|
| 726 | | - * Return: group ID(0~15) extracted from the parameter |
|---|
| 727 | | - */ |
|---|
| 728 | | -static __inline__ int base_mem_group_id_get(base_mem_alloc_flags flags) |
|---|
| 729 | | -{ |
|---|
| 730 | | - LOCAL_ASSERT((flags & ~BASE_MEM_FLAGS_INPUT_MASK) == 0); |
|---|
| 731 | | - return (int)((flags & BASE_MEM_GROUP_ID_MASK) >> |
|---|
| 732 | | - BASEP_MEM_GROUP_ID_SHIFT); |
|---|
| 733 | | -} |
|---|
| 597 | +#define BASE_MEM_GROUP_ID_SET(id) \ |
|---|
| 598 | + (((base_mem_alloc_flags)((id < 0 || id >= BASE_MEM_GROUP_COUNT) ? \ |
|---|
| 599 | + BASE_MEM_GROUP_DEFAULT : \ |
|---|
| 600 | + id) \ |
|---|
| 601 | + << BASEP_MEM_GROUP_ID_SHIFT) & \ |
|---|
| 602 | + BASE_MEM_GROUP_ID_MASK) |
|---|
| 734 | 603 | |
|---|
| 735 | | -/** |
|---|
| 736 | | - * base_mem_group_id_set() - Set group ID into base_mem_alloc_flags |
|---|
| 737 | | - * @id: group ID(0~15) you want to encode |
|---|
| 738 | | - * |
|---|
| 739 | | - * This inline function encodes specific group ID into base_mem_alloc_flags. |
|---|
| 740 | | - * Parameter 'id' should lie in-between 0 to 15. |
|---|
| 741 | | - * |
|---|
| 742 | | - * Return: base_mem_alloc_flags with the group ID (id) encoded |
|---|
| 743 | | - * |
|---|
| 744 | | - * The return value can be combined with other flags against base_mem_alloc |
|---|
| 745 | | - * to identify a specific memory group. |
|---|
| 746 | | - */ |
|---|
| 747 | | -static __inline__ base_mem_alloc_flags base_mem_group_id_set(int id) |
|---|
| 748 | | -{ |
|---|
| 749 | | - if ((id < 0) || (id >= BASE_MEM_GROUP_COUNT)) { |
|---|
| 750 | | - /* Set to default value when id is out of range. */ |
|---|
| 751 | | - id = BASE_MEM_GROUP_DEFAULT; |
|---|
| 752 | | - } |
|---|
| 604 | +#define BASE_CONTEXT_MMU_GROUP_ID_SET(group_id) \ |
|---|
| 605 | + (BASEP_CONTEXT_MMU_GROUP_ID_MASK & \ |
|---|
| 606 | + ((base_context_create_flags)(group_id) \ |
|---|
| 607 | + << BASEP_CONTEXT_MMU_GROUP_ID_SHIFT)) |
|---|
| 753 | 608 | |
|---|
| 754 | | - return ((base_mem_alloc_flags)id << BASEP_MEM_GROUP_ID_SHIFT) & |
|---|
| 755 | | - BASE_MEM_GROUP_ID_MASK; |
|---|
| 756 | | -} |
|---|
| 757 | | - |
|---|
| 758 | | -/** |
|---|
| 759 | | - * base_context_mmu_group_id_set - Encode a memory group ID in |
|---|
| 760 | | - * base_context_create_flags |
|---|
| 761 | | - * |
|---|
| 762 | | - * Memory allocated for GPU page tables will come from the specified group. |
|---|
| 763 | | - * |
|---|
| 764 | | - * @group_id: Physical memory group ID. Range is 0..(BASE_MEM_GROUP_COUNT-1). |
|---|
| 765 | | - * |
|---|
| 766 | | - * Return: Bitmask of flags to pass to base_context_init. |
|---|
| 767 | | - */ |
|---|
| 768 | | -static __inline__ base_context_create_flags base_context_mmu_group_id_set( |
|---|
| 769 | | - int const group_id) |
|---|
| 770 | | -{ |
|---|
| 771 | | - LOCAL_ASSERT(group_id >= 0); |
|---|
| 772 | | - LOCAL_ASSERT(group_id < BASE_MEM_GROUP_COUNT); |
|---|
| 773 | | - return BASEP_CONTEXT_MMU_GROUP_ID_MASK & |
|---|
| 774 | | - ((base_context_create_flags)group_id << |
|---|
| 775 | | - BASEP_CONTEXT_MMU_GROUP_ID_SHIFT); |
|---|
| 776 | | -} |
|---|
| 777 | | - |
|---|
| 778 | | -/** |
|---|
| 779 | | - * base_context_mmu_group_id_get - Decode a memory group ID from |
|---|
| 780 | | - * base_context_create_flags |
|---|
| 781 | | - * |
|---|
| 782 | | - * Memory allocated for GPU page tables will come from the returned group. |
|---|
| 783 | | - * |
|---|
| 784 | | - * @flags: Bitmask of flags to pass to base_context_init. |
|---|
| 785 | | - * |
|---|
| 786 | | - * Return: Physical memory group ID. Valid range is 0..(BASE_MEM_GROUP_COUNT-1). |
|---|
| 787 | | - */ |
|---|
| 788 | | -static __inline__ int base_context_mmu_group_id_get( |
|---|
| 789 | | - base_context_create_flags const flags) |
|---|
| 790 | | -{ |
|---|
| 791 | | - LOCAL_ASSERT(flags == (flags & BASEP_CONTEXT_CREATE_ALLOWED_FLAGS)); |
|---|
| 792 | | - return (int)((flags & BASEP_CONTEXT_MMU_GROUP_ID_MASK) >> |
|---|
| 793 | | - BASEP_CONTEXT_MMU_GROUP_ID_SHIFT); |
|---|
| 794 | | -} |
|---|
| 609 | +#define BASE_CONTEXT_MMU_GROUP_ID_GET(flags) \ |
|---|
| 610 | + ((flags & BASEP_CONTEXT_MMU_GROUP_ID_MASK) >> \ |
|---|
| 611 | + BASEP_CONTEXT_MMU_GROUP_ID_SHIFT) |
|---|
| 795 | 612 | |
|---|
| 796 | 613 | /* |
|---|
| 797 | 614 | * A number of bit flags are defined for requesting cpu_gpu_timeinfo. These |
|---|