Skip to content

Commit

Permalink
core: remove unused mobj_mm_alloc()
Browse files Browse the repository at this point in the history
Removes the now unused mobj_mm_alloc(), struct mobj_mm, and friends.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
jenswi-linaro authored and jforissier committed Oct 13, 2023
1 parent b6f1536 commit b7de9d8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 103 deletions.
1 change: 0 additions & 1 deletion core/arch/arm/kernel/link_dummies_paged.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ __thread_std_smc_entry(uint32_t a0 __unused, uint32_t a1 __unused,
const struct mobj_ops mobj_reg_shm_ops __rodata_dummy;
const struct mobj_ops mobj_phys_ops __rodata_dummy;
const struct mobj_ops mobj_virt_ops __rodata_dummy;
const struct mobj_ops mobj_mm_ops __rodata_dummy;
const struct mobj_ops mobj_shm_ops __rodata_dummy;
const struct mobj_ops mobj_with_fobj_ops __rodata_dummy;
const struct fobj_ops ops_rwp_paged_iv __rodata_dummy;
Expand Down
3 changes: 0 additions & 3 deletions core/include/mm/mobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ static inline bool mobj_check_offset_and_len(struct mobj *mobj, size_t offset,
end_offs < mobj->size;
}

struct mobj *mobj_mm_alloc(struct mobj *mobj_parent, size_t size,
tee_mm_pool_t *pool);

struct mobj *mobj_phys_alloc(paddr_t pa, size_t size, uint32_t cattr,
enum buf_is_attr battr);

Expand Down
99 changes: 0 additions & 99 deletions core/mm/mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,105 +237,6 @@ static void mobj_virt_assert_type(struct mobj *mobj __maybe_unused)

struct mobj mobj_virt = { .ops = &mobj_virt_ops, .size = SIZE_MAX };

/*
* mobj_mm implementation
*/

struct mobj_mm {
tee_mm_entry_t *mm;
struct mobj *parent_mobj;
struct mobj mobj;
};

static struct mobj_mm *to_mobj_mm(struct mobj *mobj);

static size_t mobj_mm_offs(struct mobj *mobj, size_t offs)
{
tee_mm_entry_t *mm = to_mobj_mm(mobj)->mm;

return (mm->offset << mm->pool->shift) + offs;
}

static void *mobj_mm_get_va(struct mobj *mobj, size_t offs, size_t len)
{
return mobj_get_va(to_mobj_mm(mobj)->parent_mobj,
mobj_mm_offs(mobj, offs), len);
}


static TEE_Result mobj_mm_get_pa(struct mobj *mobj, size_t offs,
size_t granule, paddr_t *pa)
{
return mobj_get_pa(to_mobj_mm(mobj)->parent_mobj,
mobj_mm_offs(mobj, offs), granule, pa);
}
DECLARE_KEEP_PAGER(mobj_mm_get_pa);

static size_t mobj_mm_get_phys_offs(struct mobj *mobj, size_t granule)
{
return mobj_get_phys_offs(to_mobj_mm(mobj)->parent_mobj, granule);
}

static TEE_Result mobj_mm_get_mem_type(struct mobj *mobj, uint32_t *mem_type)
{
return mobj_get_mem_type(to_mobj_mm(mobj)->parent_mobj, mem_type);
}

static bool mobj_mm_matches(struct mobj *mobj, enum buf_is_attr attr)
{
return mobj_matches(to_mobj_mm(mobj)->parent_mobj, attr);
}

static void mobj_mm_free(struct mobj *mobj)
{
struct mobj_mm *m = to_mobj_mm(mobj);

tee_mm_free(m->mm);
free(m);
}

/*
* Note: this variable is weak just to ease breaking its dependency chain
* when added to the unpaged area.
*/
const struct mobj_ops mobj_mm_ops __weak __relrodata_unpaged("mobj_mm_ops") = {
.get_va = mobj_mm_get_va,
.get_pa = mobj_mm_get_pa,
.get_phys_offs = mobj_mm_get_phys_offs,
.get_mem_type = mobj_mm_get_mem_type,
.matches = mobj_mm_matches,
.free = mobj_mm_free,
};

static struct mobj_mm *to_mobj_mm(struct mobj *mobj)
{
assert(mobj->ops == &mobj_mm_ops);
return container_of(mobj, struct mobj_mm, mobj);
}

struct mobj *mobj_mm_alloc(struct mobj *mobj_parent, size_t size,
tee_mm_pool_t *pool)
{
struct mobj_mm *m = calloc(1, sizeof(*m));

if (!m)
return NULL;

m->mm = tee_mm_alloc(pool, size);
if (!m->mm) {
free(m);
return NULL;
}

m->parent_mobj = mobj_parent;
m->mobj.size = size;
m->mobj.ops = &mobj_mm_ops;
refcount_set(&m->mobj.refc, 1);

return &m->mobj;
}


/*
* mobj_shm implementation. mobj_shm represents buffer in predefined shm region
* - it is physically contiguous.
Expand Down

0 comments on commit b7de9d8

Please sign in to comment.