[PATCH v4 05/16] arm64/mm: Remove dependency on MM in new_context
Shameer Kolothum
shameerali.kolothum.thodi at huawei.com
Wed Apr 14 12:23:01 BST 2021
From: Julien Grall <julien.grall at arm.com>
The function new_context will be part of a generic ASID allocator. At
the moment, the MM structure is currently used to fetch the ASID and
pinned refcount.
To remove the dependency on MM, it is possible to just pass a pointer to
the current ASID and pinned refcount. Also please note that 'pinned' may
be NULL if the user doesn't require the pinned asid support.
Signed-off-by: Julien Grall <julien.grall at arm.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi at huawei.com>
---
v3-->v4:
Changes related to Pinned ASID refcount.
---
arch/arm64/mm/context.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c
index 139ebc161acb..628304e0d3b1 100644
--- a/arch/arm64/mm/context.c
+++ b/arch/arm64/mm/context.c
@@ -165,9 +165,10 @@ static bool check_update_reserved_asid(struct asid_info *info, u64 asid,
return hit;
}
-static u64 new_context(struct asid_info *info, struct mm_struct *mm)
+static u64 new_context(struct asid_info *info, atomic64_t *pasid,
+ refcount_t *pinned)
{
- u64 asid = atomic64_read(&mm->context.id);
+ u64 asid = atomic64_read(pasid);
u64 generation = atomic64_read(&info->generation);
if (asid != 0) {
@@ -185,7 +186,7 @@ static u64 new_context(struct asid_info *info, struct mm_struct *mm)
* takes priority, because even if it is also pinned, we need to
* update the generation into the reserved_asids.
*/
- if (refcount_read(&mm->context.pinned))
+ if (pinned && refcount_read(pinned))
return newasid;
/*
@@ -257,7 +258,7 @@ void check_and_switch_context(struct mm_struct *mm)
/* Check that our ASID belongs to the current generation. */
asid = atomic64_read(&mm->context.id);
if (!asid_gen_match(asid, info)) {
- asid = new_context(info, mm);
+ asid = new_context(info, &mm->context.id, &mm->context.pinned);
atomic64_set(&mm->context.id, asid);
}
@@ -306,7 +307,7 @@ unsigned long arm64_mm_context_get(struct mm_struct *mm)
* We went through one or more rollover since that ASID was
* used. Ensure that it is still valid, or generate a new one.
*/
- asid = new_context(info, mm);
+ asid = new_context(info, &mm->context.id, &mm->context.pinned);
atomic64_set(&mm->context.id, asid);
}
--
2.17.1
More information about the linux-arm-kernel
mailing list