mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
This was done entirely with mindless brute force, using
git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' |
xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/'
to convert the new alloc_obj() users that had a simple GFP_KERNEL
argument to just drop that argument.
Note that due to the extreme simplicity of the scripting, any slightly
more complex cases spread over multiple lines would not be triggered:
they definitely exist, but this covers the vast bulk of the cases, and
the resulting diff is also then easier to check automatically.
For the same reason the 'flex' versions will be done as a separate
conversion.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
71 lines
1.4 KiB
C
71 lines
1.4 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright 2019 Advanced Micro Devices, Inc.
|
|
*/
|
|
|
|
#include <linux/slab.h>
|
|
#include <linux/tee_core.h>
|
|
#include <linux/psp.h>
|
|
#include "amdtee_private.h"
|
|
|
|
static int pool_op_alloc(struct tee_shm_pool *pool, struct tee_shm *shm,
|
|
size_t size, size_t align)
|
|
{
|
|
unsigned int order = get_order(size);
|
|
unsigned long va;
|
|
int rc;
|
|
|
|
/*
|
|
* Ignore alignment since this is already going to be page aligned
|
|
* and there's no need for any larger alignment.
|
|
*/
|
|
va = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
|
|
if (!va)
|
|
return -ENOMEM;
|
|
|
|
shm->kaddr = (void *)va;
|
|
shm->paddr = __psp_pa((void *)va);
|
|
shm->size = PAGE_SIZE << order;
|
|
|
|
/* Map the allocated memory in to TEE */
|
|
rc = amdtee_map_shmem(shm);
|
|
if (rc) {
|
|
free_pages(va, order);
|
|
shm->kaddr = NULL;
|
|
return rc;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void pool_op_free(struct tee_shm_pool *pool, struct tee_shm *shm)
|
|
{
|
|
/* Unmap the shared memory from TEE */
|
|
amdtee_unmap_shmem(shm);
|
|
free_pages((unsigned long)shm->kaddr, get_order(shm->size));
|
|
shm->kaddr = NULL;
|
|
}
|
|
|
|
static void pool_op_destroy_pool(struct tee_shm_pool *pool)
|
|
{
|
|
kfree(pool);
|
|
}
|
|
|
|
static const struct tee_shm_pool_ops pool_ops = {
|
|
.alloc = pool_op_alloc,
|
|
.free = pool_op_free,
|
|
.destroy_pool = pool_op_destroy_pool,
|
|
};
|
|
|
|
struct tee_shm_pool *amdtee_config_shm(void)
|
|
{
|
|
struct tee_shm_pool *pool = kzalloc_obj(*pool);
|
|
|
|
if (!pool)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
pool->ops = &pool_ops;
|
|
|
|
return pool;
|
|
}
|