File: intel_context_param.c

package info (click to toggle)
linux 5.10.46-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,191,996 kB
  • sloc: ansic: 19,502,768; asm: 263,759; sh: 73,960; makefile: 44,724; perl: 34,644; python: 32,387; cpp: 6,070; yacc: 4,755; lex: 2,742; awk: 1,214; ruby: 25; sed: 5
file content (63 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2019 Intel Corporation
 */

#include "i915_active.h"
#include "intel_context.h"
#include "intel_context_param.h"
#include "intel_ring.h"

int intel_context_set_ring_size(struct intel_context *ce, long sz)
{
	int err;

	if (intel_context_lock_pinned(ce))
		return -EINTR;

	err = i915_active_wait(&ce->active);
	if (err < 0)
		goto unlock;

	if (intel_context_is_pinned(ce)) {
		err = -EBUSY; /* In active use, come back later! */
		goto unlock;
	}

	if (test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
		struct intel_ring *ring;

		/* Replace the existing ringbuffer */
		ring = intel_engine_create_ring(ce->engine, sz);
		if (IS_ERR(ring)) {
			err = PTR_ERR(ring);
			goto unlock;
		}

		intel_ring_put(ce->ring);
		ce->ring = ring;

		/* Context image will be updated on next pin */
	} else {
		ce->ring = __intel_context_ring_size(sz);
	}

unlock:
	intel_context_unlock_pinned(ce);
	return err;
}

long intel_context_get_ring_size(struct intel_context *ce)
{
	long sz = (unsigned long)READ_ONCE(ce->ring);

	if (test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
		if (intel_context_lock_pinned(ce))
			return -EINTR;

		sz = ce->ring->size;
		intel_context_unlock_pinned(ce);
	}

	return sz;
}