@@ -271,107 +271,50 @@ npages_in_range(unsigned long start, unsigned long end)
271271}
272272
273273/**
274- * drm_gpusvm_range_find () - Find GPU SVM range from GPU SVM notifier
275- * @notifier : Pointer to the GPU SVM notifier structure.
276- * @start: Start address of the range
277- * @end: End address of the range
274+ * drm_gpusvm_notifier_find () - Find GPU SVM notifier from GPU SVM
275+ * @gpusvm : Pointer to the GPU SVM structure.
276+ * @start: Start address of the notifier
277+ * @end: End address of the notifier
278278 *
279- * Return: A pointer to the drm_gpusvm_range if found or NULL
279+ * Return: A pointer to the drm_gpusvm_notifier if found or NULL
280280 */
281- struct drm_gpusvm_range *
282- drm_gpusvm_range_find (struct drm_gpusvm_notifier * notifier , unsigned long start ,
283- unsigned long end )
281+ struct drm_gpusvm_notifier *
282+ drm_gpusvm_notifier_find (struct drm_gpusvm * gpusvm , unsigned long start ,
283+ unsigned long end )
284284{
285285 struct interval_tree_node * itree ;
286286
287- itree = interval_tree_iter_first (& notifier -> root , start , end - 1 );
287+ itree = interval_tree_iter_first (& gpusvm -> root , start , end - 1 );
288288
289289 if (itree )
290- return container_of (itree , struct drm_gpusvm_range , itree );
290+ return container_of (itree , struct drm_gpusvm_notifier , itree );
291291 else
292292 return NULL ;
293293}
294- EXPORT_SYMBOL_GPL (drm_gpusvm_range_find );
294+ EXPORT_SYMBOL_GPL (drm_gpusvm_notifier_find );
295295
296296/**
297- * drm_gpusvm_for_each_range_safe() - Safely iterate over GPU SVM ranges in a notifier
298- * @range__: Iterator variable for the ranges
299- * @next__: Iterator variable for the ranges temporay storage
300- * @notifier__: Pointer to the GPU SVM notifier
301- * @start__: Start address of the range
302- * @end__: End address of the range
303- *
304- * This macro is used to iterate over GPU SVM ranges in a notifier while
305- * removing ranges from it.
306- */
307- #define drm_gpusvm_for_each_range_safe (range__ , next__ , notifier__ , start__ , end__ ) \
308- for ((range__) = drm_gpusvm_range_find((notifier__), (start__), (end__)), \
309- (next__) = __drm_gpusvm_range_next(range__); \
310- (range__) && (drm_gpusvm_range_start(range__) < (end__)); \
311- (range__) = (next__), (next__) = __drm_gpusvm_range_next(range__))
312-
313- /**
314- * __drm_gpusvm_notifier_next() - get the next drm_gpusvm_notifier in the list
315- * @notifier: a pointer to the current drm_gpusvm_notifier
297+ * drm_gpusvm_range_find() - Find GPU SVM range from GPU SVM notifier
298+ * @notifier: Pointer to the GPU SVM notifier structure.
299+ * @start: Start address of the range
300+ * @end: End address of the range
316301 *
317- * Return: A pointer to the next drm_gpusvm_notifier if available, or NULL if
318- * the current notifier is the last one or if the input notifier is
319- * NULL.
302+ * Return: A pointer to the drm_gpusvm_range if found or NULL
320303 */
321- static struct drm_gpusvm_notifier *
322- __drm_gpusvm_notifier_next (struct drm_gpusvm_notifier * notifier )
323- {
324- if (notifier && !list_is_last (& notifier -> entry ,
325- & notifier -> gpusvm -> notifier_list ))
326- return list_next_entry (notifier , entry );
327-
328- return NULL ;
329- }
330-
331- static struct drm_gpusvm_notifier *
332- notifier_iter_first (struct rb_root_cached * root , unsigned long start ,
333- unsigned long last )
304+ struct drm_gpusvm_range *
305+ drm_gpusvm_range_find (struct drm_gpusvm_notifier * notifier , unsigned long start ,
306+ unsigned long end )
334307{
335308 struct interval_tree_node * itree ;
336309
337- itree = interval_tree_iter_first (root , start , last );
310+ itree = interval_tree_iter_first (& notifier -> root , start , end - 1 );
338311
339312 if (itree )
340- return container_of (itree , struct drm_gpusvm_notifier , itree );
313+ return container_of (itree , struct drm_gpusvm_range , itree );
341314 else
342315 return NULL ;
343316}
344-
345- /**
346- * drm_gpusvm_for_each_notifier() - Iterate over GPU SVM notifiers in a gpusvm
347- * @notifier__: Iterator variable for the notifiers
348- * @notifier__: Pointer to the GPU SVM notifier
349- * @start__: Start address of the notifier
350- * @end__: End address of the notifier
351- *
352- * This macro is used to iterate over GPU SVM notifiers in a gpusvm.
353- */
354- #define drm_gpusvm_for_each_notifier (notifier__ , gpusvm__ , start__ , end__ ) \
355- for ((notifier__) = notifier_iter_first(&(gpusvm__)->root, (start__), (end__) - 1); \
356- (notifier__) && (drm_gpusvm_notifier_start(notifier__) < (end__)); \
357- (notifier__) = __drm_gpusvm_notifier_next(notifier__))
358-
359- /**
360- * drm_gpusvm_for_each_notifier_safe() - Safely iterate over GPU SVM notifiers in a gpusvm
361- * @notifier__: Iterator variable for the notifiers
362- * @next__: Iterator variable for the notifiers temporay storage
363- * @notifier__: Pointer to the GPU SVM notifier
364- * @start__: Start address of the notifier
365- * @end__: End address of the notifier
366- *
367- * This macro is used to iterate over GPU SVM notifiers in a gpusvm while
368- * removing notifiers from it.
369- */
370- #define drm_gpusvm_for_each_notifier_safe (notifier__ , next__ , gpusvm__ , start__ , end__ ) \
371- for ((notifier__) = notifier_iter_first(&(gpusvm__)->root, (start__), (end__) - 1), \
372- (next__) = __drm_gpusvm_notifier_next(notifier__); \
373- (notifier__) && (drm_gpusvm_notifier_start(notifier__) < (end__)); \
374- (notifier__) = (next__), (next__) = __drm_gpusvm_notifier_next(notifier__))
317+ EXPORT_SYMBOL_GPL (drm_gpusvm_range_find );
375318
376319/**
377320 * drm_gpusvm_notifier_invalidate() - Invalidate a GPU SVM notifier.
@@ -472,22 +415,6 @@ int drm_gpusvm_init(struct drm_gpusvm *gpusvm,
472415}
473416EXPORT_SYMBOL_GPL (drm_gpusvm_init );
474417
475- /**
476- * drm_gpusvm_notifier_find() - Find GPU SVM notifier
477- * @gpusvm: Pointer to the GPU SVM structure
478- * @fault_addr: Fault address
479- *
480- * This function finds the GPU SVM notifier associated with the fault address.
481- *
482- * Return: Pointer to the GPU SVM notifier on success, NULL otherwise.
483- */
484- static struct drm_gpusvm_notifier *
485- drm_gpusvm_notifier_find (struct drm_gpusvm * gpusvm ,
486- unsigned long fault_addr )
487- {
488- return notifier_iter_first (& gpusvm -> root , fault_addr , fault_addr + 1 );
489- }
490-
491418/**
492419 * to_drm_gpusvm_notifier() - retrieve the container struct for a given rbtree node
493420 * @node: a pointer to the rbtree node embedded within a drm_gpusvm_notifier struct
@@ -943,7 +870,7 @@ drm_gpusvm_range_find_or_insert(struct drm_gpusvm *gpusvm,
943870 if (!mmget_not_zero (mm ))
944871 return ERR_PTR (- EFAULT );
945872
946- notifier = drm_gpusvm_notifier_find (gpusvm , fault_addr );
873+ notifier = drm_gpusvm_notifier_find (gpusvm , fault_addr , fault_addr + 1 );
947874 if (!notifier ) {
948875 notifier = drm_gpusvm_notifier_alloc (gpusvm , fault_addr );
949876 if (IS_ERR (notifier )) {
@@ -1107,7 +1034,8 @@ void drm_gpusvm_range_remove(struct drm_gpusvm *gpusvm,
11071034 drm_gpusvm_driver_lock_held (gpusvm );
11081035
11091036 notifier = drm_gpusvm_notifier_find (gpusvm ,
1110- drm_gpusvm_range_start (range ));
1037+ drm_gpusvm_range_start (range ),
1038+ drm_gpusvm_range_start (range ) + 1 );
11111039 if (WARN_ON_ONCE (!notifier ))
11121040 return ;
11131041
0 commit comments