Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a1d7752 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Prefer list_first_entry_or_null

parent 4a50d20e
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -2736,14 +2736,12 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node,
	if (node->color != color)
		*start += 4096;

	if (!list_empty(&node->node_list)) {
		node = list_entry(node->node_list.next,
	node = list_first_entry_or_null(&node->node_list,
					struct drm_mm_node,
					node_list);
		if (node->allocated && node->color != color)
	if (node && node->allocated && node->color != color)
		*end -= 4096;
}
}

static int i915_gem_setup_global_gtt(struct drm_device *dev,
				     u64 start,
+3 −5
Original line number Diff line number Diff line
@@ -317,12 +317,10 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
		return ret;

	/* Move the oldest request to the slab-cache (if not in use!) */
	if (!list_empty(&engine->request_list)) {
		req = list_first_entry(&engine->request_list,
	req = list_first_entry_or_null(&engine->request_list,
				       typeof(*req), list);
		if (i915_gem_request_completed(req))
	if (req && i915_gem_request_completed(req))
		i915_gem_request_retire(req);
	}

	req = kmem_cache_zalloc(dev_priv->requests, GFP_KERNEL);
	if (!req)
+5 −4
Original line number Diff line number Diff line
@@ -163,17 +163,18 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
	 */
	for (phase = phases; phase->list; phase++) {
		struct list_head still_in_list;
		struct drm_i915_gem_object *obj;

		if ((flags & phase->bit) == 0)
			continue;

		INIT_LIST_HEAD(&still_in_list);
		while (count < target && !list_empty(phase->list)) {
			struct drm_i915_gem_object *obj;
		while (count < target &&
		       (obj = list_first_entry_or_null(phase->list,
						       typeof(*obj),
						       global_list))) {
			struct i915_vma *vma, *v;

			obj = list_first_entry(phase->list,
					       typeof(*obj), global_list);
			list_move_tail(&obj->global_list, &still_in_list);

			if (flags & I915_SHRINK_PURGEABLE &&