// SPDX-License-Identifier: MIT1/*2* Copyright (C) 2012-2014 Canonical Ltd (Maarten Lankhorst)3*4* Based on bo.c which bears the following copyright notice,5* but is dual licensed:6*7* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA8* All Rights Reserved.9*10* Permission is hereby granted, free of charge, to any person obtaining a11* copy of this software and associated documentation files (the12* "Software"), to deal in the Software without restriction, including13* without limitation the rights to use, copy, modify, merge, publish,14* distribute, sub license, and/or sell copies of the Software, and to15* permit persons to whom the Software is furnished to do so, subject to16* the following conditions:17*18* The above copyright notice and this permission notice (including the19* next paragraph) shall be included in all copies or substantial portions20* of the Software.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR23* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,24* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL25* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,26* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR27* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE28* USE OR OTHER DEALINGS IN THE SOFTWARE.29*30**************************************************************************/31/*32* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>33*/3435#include <linux/dma-resv.h>36#include <linux/dma-fence-array.h>37#include <linux/export.h>38#include <linux/mm.h>39#include <linux/sched/mm.h>40#include <linux/mmu_notifier.h>41#include <linux/seq_file.h>4243/**44* DOC: Reservation Object Overview45*46* The reservation object provides a mechanism to manage a container of47* dma_fence object associated with a resource. A reservation object48* can have any number of fences attaches to it. Each fence carries an usage49* parameter determining how the operation represented by the fence is using the50* resource. The RCU mechanism is used to protect read access to fences from51* locked write-side updates.52*53* See struct dma_resv for more details.54*/5556DEFINE_WD_CLASS(reservation_ww_class);57EXPORT_SYMBOL(reservation_ww_class);5859/* Mask for the lower fence pointer bits */60#define DMA_RESV_LIST_MASK 0x36162struct dma_resv_list {63struct rcu_head rcu;64u32 num_fences, max_fences;65struct dma_fence __rcu *table[];66};6768/* Extract the fence and usage flags from an RCU protected entry in the list. */69static void dma_resv_list_entry(struct dma_resv_list *list, unsigned int index,70struct dma_resv *resv, struct dma_fence **fence,71enum dma_resv_usage *usage)72{73long tmp;7475tmp = (long)rcu_dereference_check(list->table[index],76resv ? dma_resv_held(resv) : true);77*fence = (struct dma_fence *)(tmp & ~DMA_RESV_LIST_MASK);78if (usage)79*usage = tmp & DMA_RESV_LIST_MASK;80}8182/* Set the fence and usage flags at the specific index in the list. */83static void dma_resv_list_set(struct dma_resv_list *list,84unsigned int index,85struct dma_fence *fence,86enum dma_resv_usage usage)87{88long tmp = ((long)fence) | usage;8990RCU_INIT_POINTER(list->table[index], (struct dma_fence *)tmp);91}9293/*94* Allocate a new dma_resv_list and make sure to correctly initialize95* max_fences.96*/97static struct dma_resv_list *dma_resv_list_alloc(unsigned int max_fences)98{99struct dma_resv_list *list;100size_t size;101102/* Round up to the next kmalloc bucket size. */103size = kmalloc_size_roundup(struct_size(list, table, max_fences));104105list = kmalloc(size, GFP_KERNEL);106if (!list)107return NULL;108109/* Given the resulting bucket size, recalculated max_fences. */110list->max_fences = (size - offsetof(typeof(*list), table)) /111sizeof(*list->table);112113return list;114}115116/* Free a dma_resv_list and make sure to drop all references. */117static void dma_resv_list_free(struct dma_resv_list *list)118{119unsigned int i;120121if (!list)122return;123124for (i = 0; i < list->num_fences; ++i) {125struct dma_fence *fence;126127dma_resv_list_entry(list, i, NULL, &fence, NULL);128dma_fence_put(fence);129}130kfree_rcu(list, rcu);131}132133/**134* dma_resv_init - initialize a reservation object135* @obj: the reservation object136*/137void dma_resv_init(struct dma_resv *obj)138{139ww_mutex_init(&obj->lock, &reservation_ww_class);140141RCU_INIT_POINTER(obj->fences, NULL);142}143EXPORT_SYMBOL(dma_resv_init);144145/**146* dma_resv_fini - destroys a reservation object147* @obj: the reservation object148*/149void dma_resv_fini(struct dma_resv *obj)150{151/*152* This object should be dead and all references must have153* been released to it, so no need to be protected with rcu.154*/155dma_resv_list_free(rcu_dereference_protected(obj->fences, true));156ww_mutex_destroy(&obj->lock);157}158EXPORT_SYMBOL(dma_resv_fini);159160/* Dereference the fences while ensuring RCU rules */161static inline struct dma_resv_list *dma_resv_fences_list(struct dma_resv *obj)162{163return rcu_dereference_check(obj->fences, dma_resv_held(obj));164}165166/**167* dma_resv_reserve_fences - Reserve space to add fences to a dma_resv object.168* @obj: reservation object169* @num_fences: number of fences we want to add170*171* Should be called before dma_resv_add_fence(). Must be called with @obj172* locked through dma_resv_lock().173*174* Note that the preallocated slots need to be re-reserved if @obj is unlocked175* at any time before calling dma_resv_add_fence(). This is validated when176* CONFIG_DEBUG_MUTEXES is enabled.177*178* RETURNS179* Zero for success, or -errno180*/181int dma_resv_reserve_fences(struct dma_resv *obj, unsigned int num_fences)182{183struct dma_resv_list *old, *new;184unsigned int i, j, k, max;185186dma_resv_assert_held(obj);187188/* Driver and component code should never call this function with189* num_fences=0. If they do it usually points to bugs when calculating190* the number of needed fences dynamically.191*/192if (WARN_ON(!num_fences))193return -EINVAL;194195old = dma_resv_fences_list(obj);196if (old && old->max_fences) {197if ((old->num_fences + num_fences) <= old->max_fences)198return 0;199max = max(old->num_fences + num_fences, old->max_fences * 2);200} else {201max = max(4ul, roundup_pow_of_two(num_fences));202}203204new = dma_resv_list_alloc(max);205if (!new)206return -ENOMEM;207208/*209* no need to bump fence refcounts, rcu_read access210* requires the use of kref_get_unless_zero, and the211* references from the old struct are carried over to212* the new.213*/214for (i = 0, j = 0, k = max; i < (old ? old->num_fences : 0); ++i) {215enum dma_resv_usage usage;216struct dma_fence *fence;217218dma_resv_list_entry(old, i, obj, &fence, &usage);219if (dma_fence_is_signaled(fence))220RCU_INIT_POINTER(new->table[--k], fence);221else222dma_resv_list_set(new, j++, fence, usage);223}224new->num_fences = j;225226/*227* We are not changing the effective set of fences here so can228* merely update the pointer to the new array; both existing229* readers and new readers will see exactly the same set of230* active (unsignaled) fences. Individual fences and the231* old array are protected by RCU and so will not vanish under232* the gaze of the rcu_read_lock() readers.233*/234rcu_assign_pointer(obj->fences, new);235236if (!old)237return 0;238239/* Drop the references to the signaled fences */240for (i = k; i < max; ++i) {241struct dma_fence *fence;242243fence = rcu_dereference_protected(new->table[i],244dma_resv_held(obj));245dma_fence_put(fence);246}247kfree_rcu(old, rcu);248249return 0;250}251EXPORT_SYMBOL(dma_resv_reserve_fences);252253#ifdef CONFIG_DEBUG_MUTEXES254/**255* dma_resv_reset_max_fences - reset fences for debugging256* @obj: the dma_resv object to reset257*258* Reset the number of pre-reserved fence slots to test that drivers do259* correct slot allocation using dma_resv_reserve_fences(). See also260* &dma_resv_list.max_fences.261*/262void dma_resv_reset_max_fences(struct dma_resv *obj)263{264struct dma_resv_list *fences = dma_resv_fences_list(obj);265266dma_resv_assert_held(obj);267268/* Test fence slot reservation */269if (fences)270fences->max_fences = fences->num_fences;271}272EXPORT_SYMBOL(dma_resv_reset_max_fences);273#endif274275/**276* dma_resv_add_fence - Add a fence to the dma_resv obj277* @obj: the reservation object278* @fence: the fence to add279* @usage: how the fence is used, see enum dma_resv_usage280*281* Add a fence to a slot, @obj must be locked with dma_resv_lock(), and282* dma_resv_reserve_fences() has been called.283*284* See also &dma_resv.fence for a discussion of the semantics.285*/286void dma_resv_add_fence(struct dma_resv *obj, struct dma_fence *fence,287enum dma_resv_usage usage)288{289struct dma_resv_list *fobj;290struct dma_fence *old;291unsigned int i, count;292293dma_fence_get(fence);294295dma_resv_assert_held(obj);296297/* Drivers should not add containers here, instead add each fence298* individually.299*/300WARN_ON(dma_fence_is_container(fence));301302fobj = dma_resv_fences_list(obj);303count = fobj->num_fences;304305for (i = 0; i < count; ++i) {306enum dma_resv_usage old_usage;307308dma_resv_list_entry(fobj, i, obj, &old, &old_usage);309if ((old->context == fence->context && old_usage >= usage &&310dma_fence_is_later_or_same(fence, old)) ||311dma_fence_is_signaled(old)) {312dma_resv_list_set(fobj, i, fence, usage);313dma_fence_put(old);314return;315}316}317318BUG_ON(fobj->num_fences >= fobj->max_fences);319count++;320321dma_resv_list_set(fobj, i, fence, usage);322/* fence update must be visible before we extend the num_fences */323smp_wmb();324fobj->num_fences = count;325}326EXPORT_SYMBOL(dma_resv_add_fence);327328/**329* dma_resv_replace_fences - replace fences in the dma_resv obj330* @obj: the reservation object331* @context: the context of the fences to replace332* @replacement: the new fence to use instead333* @usage: how the new fence is used, see enum dma_resv_usage334*335* Replace fences with a specified context with a new fence. Only valid if the336* operation represented by the original fence has no longer access to the337* resources represented by the dma_resv object when the new fence completes.338*339* And example for using this is replacing a preemption fence with a page table340* update fence which makes the resource inaccessible.341*/342void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,343struct dma_fence *replacement,344enum dma_resv_usage usage)345{346struct dma_resv_list *list;347unsigned int i;348349dma_resv_assert_held(obj);350351list = dma_resv_fences_list(obj);352for (i = 0; list && i < list->num_fences; ++i) {353struct dma_fence *old;354355dma_resv_list_entry(list, i, obj, &old, NULL);356if (old->context != context)357continue;358359dma_resv_list_set(list, i, dma_fence_get(replacement), usage);360dma_fence_put(old);361}362}363EXPORT_SYMBOL(dma_resv_replace_fences);364365/* Restart the unlocked iteration by initializing the cursor object. */366static void dma_resv_iter_restart_unlocked(struct dma_resv_iter *cursor)367{368cursor->index = 0;369cursor->num_fences = 0;370cursor->fences = dma_resv_fences_list(cursor->obj);371if (cursor->fences)372cursor->num_fences = cursor->fences->num_fences;373cursor->is_restarted = true;374}375376/* Walk to the next not signaled fence and grab a reference to it */377static void dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor)378{379if (!cursor->fences)380return;381382do {383/* Drop the reference from the previous round */384dma_fence_put(cursor->fence);385386if (cursor->index >= cursor->num_fences) {387cursor->fence = NULL;388break;389390}391392dma_resv_list_entry(cursor->fences, cursor->index++,393cursor->obj, &cursor->fence,394&cursor->fence_usage);395cursor->fence = dma_fence_get_rcu(cursor->fence);396if (!cursor->fence) {397dma_resv_iter_restart_unlocked(cursor);398continue;399}400401if (!dma_fence_is_signaled(cursor->fence) &&402cursor->usage >= cursor->fence_usage)403break;404} while (true);405}406407/**408* dma_resv_iter_first_unlocked - first fence in an unlocked dma_resv obj.409* @cursor: the cursor with the current position410*411* Subsequent fences are iterated with dma_resv_iter_next_unlocked().412*413* Beware that the iterator can be restarted. Code which accumulates statistics414* or similar needs to check for this with dma_resv_iter_is_restarted(). For415* this reason prefer the locked dma_resv_iter_first() whenever possible.416*417* Returns the first fence from an unlocked dma_resv obj.418*/419struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor)420{421rcu_read_lock();422do {423dma_resv_iter_restart_unlocked(cursor);424dma_resv_iter_walk_unlocked(cursor);425} while (dma_resv_fences_list(cursor->obj) != cursor->fences);426rcu_read_unlock();427428return cursor->fence;429}430EXPORT_SYMBOL(dma_resv_iter_first_unlocked);431432/**433* dma_resv_iter_next_unlocked - next fence in an unlocked dma_resv obj.434* @cursor: the cursor with the current position435*436* Beware that the iterator can be restarted. Code which accumulates statistics437* or similar needs to check for this with dma_resv_iter_is_restarted(). For438* this reason prefer the locked dma_resv_iter_next() whenever possible.439*440* Returns the next fence from an unlocked dma_resv obj.441*/442struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor)443{444bool restart;445446rcu_read_lock();447cursor->is_restarted = false;448restart = dma_resv_fences_list(cursor->obj) != cursor->fences;449do {450if (restart)451dma_resv_iter_restart_unlocked(cursor);452dma_resv_iter_walk_unlocked(cursor);453restart = true;454} while (dma_resv_fences_list(cursor->obj) != cursor->fences);455rcu_read_unlock();456457return cursor->fence;458}459EXPORT_SYMBOL(dma_resv_iter_next_unlocked);460461/**462* dma_resv_iter_first - first fence from a locked dma_resv object463* @cursor: cursor to record the current position464*465* Subsequent fences are iterated with dma_resv_iter_next_unlocked().466*467* Return the first fence in the dma_resv object while holding the468* &dma_resv.lock.469*/470struct dma_fence *dma_resv_iter_first(struct dma_resv_iter *cursor)471{472struct dma_fence *fence;473474dma_resv_assert_held(cursor->obj);475476cursor->index = 0;477cursor->fences = dma_resv_fences_list(cursor->obj);478479fence = dma_resv_iter_next(cursor);480cursor->is_restarted = true;481return fence;482}483EXPORT_SYMBOL_GPL(dma_resv_iter_first);484485/**486* dma_resv_iter_next - next fence from a locked dma_resv object487* @cursor: cursor to record the current position488*489* Return the next fences from the dma_resv object while holding the490* &dma_resv.lock.491*/492struct dma_fence *dma_resv_iter_next(struct dma_resv_iter *cursor)493{494struct dma_fence *fence;495496dma_resv_assert_held(cursor->obj);497498cursor->is_restarted = false;499500do {501if (!cursor->fences ||502cursor->index >= cursor->fences->num_fences)503return NULL;504505dma_resv_list_entry(cursor->fences, cursor->index++,506cursor->obj, &fence, &cursor->fence_usage);507} while (cursor->fence_usage > cursor->usage);508509return fence;510}511EXPORT_SYMBOL_GPL(dma_resv_iter_next);512513/**514* dma_resv_copy_fences - Copy all fences from src to dst.515* @dst: the destination reservation object516* @src: the source reservation object517*518* Copy all fences from src to dst. dst-lock must be held.519*/520int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)521{522struct dma_resv_iter cursor;523struct dma_resv_list *list;524struct dma_fence *f;525526dma_resv_assert_held(dst);527528list = NULL;529530dma_resv_iter_begin(&cursor, src, DMA_RESV_USAGE_BOOKKEEP);531dma_resv_for_each_fence_unlocked(&cursor, f) {532533if (dma_resv_iter_is_restarted(&cursor)) {534dma_resv_list_free(list);535536list = dma_resv_list_alloc(cursor.num_fences);537if (!list) {538dma_resv_iter_end(&cursor);539return -ENOMEM;540}541list->num_fences = 0;542}543544dma_fence_get(f);545dma_resv_list_set(list, list->num_fences++, f,546dma_resv_iter_usage(&cursor));547}548dma_resv_iter_end(&cursor);549550list = rcu_replace_pointer(dst->fences, list, dma_resv_held(dst));551dma_resv_list_free(list);552return 0;553}554EXPORT_SYMBOL(dma_resv_copy_fences);555556/**557* dma_resv_get_fences - Get an object's fences558* fences without update side lock held559* @obj: the reservation object560* @usage: controls which fences to include, see enum dma_resv_usage.561* @num_fences: the number of fences returned562* @fences: the array of fence ptrs returned (array is krealloc'd to the563* required size, and must be freed by caller)564*565* Retrieve all fences from the reservation object.566* Returns either zero or -ENOMEM.567*/568int dma_resv_get_fences(struct dma_resv *obj, enum dma_resv_usage usage,569unsigned int *num_fences, struct dma_fence ***fences)570{571struct dma_resv_iter cursor;572struct dma_fence *fence;573574*num_fences = 0;575*fences = NULL;576577dma_resv_iter_begin(&cursor, obj, usage);578dma_resv_for_each_fence_unlocked(&cursor, fence) {579580if (dma_resv_iter_is_restarted(&cursor)) {581struct dma_fence **new_fences;582unsigned int count;583584while (*num_fences)585dma_fence_put((*fences)[--(*num_fences)]);586587count = cursor.num_fences + 1;588589/* Eventually re-allocate the array */590new_fences = krealloc_array(*fences, count,591sizeof(void *),592GFP_KERNEL);593if (count && !new_fences) {594kfree(*fences);595*fences = NULL;596*num_fences = 0;597dma_resv_iter_end(&cursor);598return -ENOMEM;599}600*fences = new_fences;601}602603(*fences)[(*num_fences)++] = dma_fence_get(fence);604}605dma_resv_iter_end(&cursor);606607return 0;608}609EXPORT_SYMBOL_GPL(dma_resv_get_fences);610611/**612* dma_resv_get_singleton - Get a single fence for all the fences613* @obj: the reservation object614* @usage: controls which fences to include, see enum dma_resv_usage.615* @fence: the resulting fence616*617* Get a single fence representing all the fences inside the resv object.618* Returns either 0 for success or -ENOMEM.619*620* Warning: This can't be used like this when adding the fence back to the resv621* object since that can lead to stack corruption when finalizing the622* dma_fence_array.623*624* Returns 0 on success and negative error values on failure.625*/626int dma_resv_get_singleton(struct dma_resv *obj, enum dma_resv_usage usage,627struct dma_fence **fence)628{629struct dma_fence_array *array;630struct dma_fence **fences;631unsigned count;632int r;633634r = dma_resv_get_fences(obj, usage, &count, &fences);635if (r)636return r;637638if (count == 0) {639*fence = NULL;640return 0;641}642643if (count == 1) {644*fence = fences[0];645kfree(fences);646return 0;647}648649array = dma_fence_array_create(count, fences,650dma_fence_context_alloc(1),6511, false);652if (!array) {653while (count--)654dma_fence_put(fences[count]);655kfree(fences);656return -ENOMEM;657}658659*fence = &array->base;660return 0;661}662EXPORT_SYMBOL_GPL(dma_resv_get_singleton);663664/**665* dma_resv_wait_timeout - Wait on reservation's objects fences666* @obj: the reservation object667* @usage: controls which fences to include, see enum dma_resv_usage.668* @intr: if true, do interruptible wait669* @timeout: timeout value in jiffies or zero to return immediately670*671* Callers are not required to hold specific locks, but maybe hold672* dma_resv_lock() already673* RETURNS674* Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or675* greater than zero on success.676*/677long dma_resv_wait_timeout(struct dma_resv *obj, enum dma_resv_usage usage,678bool intr, unsigned long timeout)679{680long ret = timeout ? timeout : 1;681struct dma_resv_iter cursor;682struct dma_fence *fence;683684dma_resv_iter_begin(&cursor, obj, usage);685dma_resv_for_each_fence_unlocked(&cursor, fence) {686687ret = dma_fence_wait_timeout(fence, intr, timeout);688if (ret <= 0)689break;690691/* Even for zero timeout the return value is 1 */692if (timeout)693timeout = ret;694}695dma_resv_iter_end(&cursor);696697return ret;698}699EXPORT_SYMBOL_GPL(dma_resv_wait_timeout);700701/**702* dma_resv_set_deadline - Set a deadline on reservation's objects fences703* @obj: the reservation object704* @usage: controls which fences to include, see enum dma_resv_usage.705* @deadline: the requested deadline (MONOTONIC)706*707* May be called without holding the dma_resv lock. Sets @deadline on708* all fences filtered by @usage.709*/710void dma_resv_set_deadline(struct dma_resv *obj, enum dma_resv_usage usage,711ktime_t deadline)712{713struct dma_resv_iter cursor;714struct dma_fence *fence;715716dma_resv_iter_begin(&cursor, obj, usage);717dma_resv_for_each_fence_unlocked(&cursor, fence) {718dma_fence_set_deadline(fence, deadline);719}720dma_resv_iter_end(&cursor);721}722EXPORT_SYMBOL_GPL(dma_resv_set_deadline);723724/**725* dma_resv_test_signaled - Test if a reservation object's fences have been726* signaled.727* @obj: the reservation object728* @usage: controls which fences to include, see enum dma_resv_usage.729*730* Callers are not required to hold specific locks, but maybe hold731* dma_resv_lock() already.732*733* RETURNS734*735* True if all fences signaled, else false.736*/737bool dma_resv_test_signaled(struct dma_resv *obj, enum dma_resv_usage usage)738{739struct dma_resv_iter cursor;740struct dma_fence *fence;741742dma_resv_iter_begin(&cursor, obj, usage);743dma_resv_for_each_fence_unlocked(&cursor, fence) {744dma_resv_iter_end(&cursor);745return false;746}747dma_resv_iter_end(&cursor);748return true;749}750EXPORT_SYMBOL_GPL(dma_resv_test_signaled);751752/**753* dma_resv_describe - Dump description of the resv object into seq_file754* @obj: the reservation object755* @seq: the seq_file to dump the description into756*757* Dump a textual description of the fences inside an dma_resv object into the758* seq_file.759*/760void dma_resv_describe(struct dma_resv *obj, struct seq_file *seq)761{762static const char *usage[] = { "kernel", "write", "read", "bookkeep" };763struct dma_resv_iter cursor;764struct dma_fence *fence;765766dma_resv_for_each_fence(&cursor, obj, DMA_RESV_USAGE_READ, fence) {767seq_printf(seq, "\t%s fence:",768usage[dma_resv_iter_usage(&cursor)]);769dma_fence_describe(fence, seq);770}771}772EXPORT_SYMBOL_GPL(dma_resv_describe);773774#if IS_ENABLED(CONFIG_LOCKDEP)775static int __init dma_resv_lockdep(void)776{777struct mm_struct *mm = mm_alloc();778struct ww_acquire_ctx ctx;779struct dma_resv obj;780struct address_space mapping;781int ret;782783if (!mm)784return -ENOMEM;785786dma_resv_init(&obj);787address_space_init_once(&mapping);788789mmap_read_lock(mm);790ww_acquire_init(&ctx, &reservation_ww_class);791ret = dma_resv_lock(&obj, &ctx);792if (ret == -EDEADLK)793dma_resv_lock_slow(&obj, &ctx);794fs_reclaim_acquire(GFP_KERNEL);795/* for unmap_mapping_range on trylocked buffer objects in shrinkers */796i_mmap_lock_write(&mapping);797i_mmap_unlock_write(&mapping);798#ifdef CONFIG_MMU_NOTIFIER799lock_map_acquire(&__mmu_notifier_invalidate_range_start_map);800__dma_fence_might_wait();801lock_map_release(&__mmu_notifier_invalidate_range_start_map);802#else803__dma_fence_might_wait();804#endif805fs_reclaim_release(GFP_KERNEL);806ww_mutex_unlock(&obj.lock);807ww_acquire_fini(&ctx);808mmap_read_unlock(mm);809810mmput(mm);811812return 0;813}814subsys_initcall(dma_resv_lockdep);815#endif816817818