-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drm/i915: Allow userspace to specify ringsize on construction
No good reason why we must always use a static ringsize, so let userspace select one during construction. Link: intel/compute-runtime#261 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Steve Carbonari <steven.carbonari@intel.com> Reviewed-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200225192206.1107336-2-chris@chris-wilson.co.uk
- Loading branch information
Showing
6 changed files
with
202 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
/* | ||
* Copyright © 2019 Intel Corporation | ||
*/ | ||
|
||
#ifndef INTEL_CONTEXT_PARAM_H | ||
#define INTEL_CONTEXT_PARAM_H | ||
|
||
struct intel_context; | ||
|
||
int intel_context_set_ring_size(struct intel_context *ce, long sz); | ||
long intel_context_get_ring_size(struct intel_context *ce); | ||
|
||
#endif /* INTEL_CONTEXT_PARAM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters