Skip to content

Commit 5a40837

Browse files
committed
drm/etnaviv: move idle mapping reaping into separate function
The same logic is already used in two different places and now it will also be needed outside of the compilation unit, so split it into a separate function. Cc: [email protected] # 5.19 Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Guido Günther <[email protected]>
1 parent 6cffb1c commit 5a40837

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

drivers/gpu/drm/etnaviv/etnaviv_mmu.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ static void etnaviv_iommu_remove_mapping(struct etnaviv_iommu_context *context,
135135
drm_mm_remove_node(&mapping->vram_node);
136136
}
137137

138+
void etnaviv_iommu_reap_mapping(struct etnaviv_vram_mapping *mapping)
139+
{
140+
struct etnaviv_iommu_context *context = mapping->context;
141+
142+
lockdep_assert_held(&context->lock);
143+
WARN_ON(mapping->use);
144+
145+
etnaviv_iommu_remove_mapping(context, mapping);
146+
etnaviv_iommu_context_put(mapping->context);
147+
mapping->context = NULL;
148+
list_del_init(&mapping->mmu_node);
149+
}
150+
138151
static int etnaviv_iommu_find_iova(struct etnaviv_iommu_context *context,
139152
struct drm_mm_node *node, size_t size)
140153
{
@@ -202,10 +215,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu_context *context,
202215
* this mapping.
203216
*/
204217
list_for_each_entry_safe(m, n, &list, scan_node) {
205-
etnaviv_iommu_remove_mapping(context, m);
206-
etnaviv_iommu_context_put(m->context);
207-
m->context = NULL;
208-
list_del_init(&m->mmu_node);
218+
etnaviv_iommu_reap_mapping(m);
209219
list_del_init(&m->scan_node);
210220
}
211221

@@ -257,10 +267,7 @@ static int etnaviv_iommu_insert_exact(struct etnaviv_iommu_context *context,
257267
}
258268

259269
list_for_each_entry_safe(m, n, &scan_list, scan_node) {
260-
etnaviv_iommu_remove_mapping(context, m);
261-
etnaviv_iommu_context_put(m->context);
262-
m->context = NULL;
263-
list_del_init(&m->mmu_node);
270+
etnaviv_iommu_reap_mapping(m);
264271
list_del_init(&m->scan_node);
265272
}
266273

drivers/gpu/drm/etnaviv/etnaviv_mmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context,
9191
struct etnaviv_vram_mapping *mapping, u64 va);
9292
void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context,
9393
struct etnaviv_vram_mapping *mapping);
94+
void etnaviv_iommu_reap_mapping(struct etnaviv_vram_mapping *mapping);
9495

9596
int etnaviv_iommu_get_suballoc_va(struct etnaviv_iommu_context *ctx,
9697
struct etnaviv_vram_mapping *mapping,

0 commit comments

Comments
 (0)