Commit cccdce1d authored by Chris Wilson's avatar Chris Wilson

drm/i915: Make engine's batch pool safe for use with virtual engines

A virtual engine itself does not have a batch pool, but we can gleefully
use any of its siblings instead.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190827135935.3831-1-chris@chris-wilson.co.uk
parent f52c6d0d
...@@ -1145,7 +1145,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb, ...@@ -1145,7 +1145,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
u32 *cmd; u32 *cmd;
int err; int err;
pool = intel_engine_pool_get(&eb->engine->pool, PAGE_SIZE); pool = intel_engine_get_pool(eb->engine, PAGE_SIZE);
if (IS_ERR(pool)) if (IS_ERR(pool))
return PTR_ERR(pool); return PTR_ERR(pool);
...@@ -1963,7 +1963,7 @@ static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master) ...@@ -1963,7 +1963,7 @@ static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master)
struct i915_vma *vma; struct i915_vma *vma;
int err; int err;
pool = intel_engine_pool_get(&eb->engine->pool, eb->batch_len); pool = intel_engine_get_pool(eb->engine, eb->batch_len);
if (IS_ERR(pool)) if (IS_ERR(pool))
return ERR_CAST(pool); return ERR_CAST(pool);
......
...@@ -32,7 +32,7 @@ struct i915_vma *intel_emit_vma_fill_blt(struct intel_context *ce, ...@@ -32,7 +32,7 @@ struct i915_vma *intel_emit_vma_fill_blt(struct intel_context *ce,
count = div_u64(vma->size, block_size); count = div_u64(vma->size, block_size);
size = (1 + 8 * count) * sizeof(u32); size = (1 + 8 * count) * sizeof(u32);
size = round_up(size, PAGE_SIZE); size = round_up(size, PAGE_SIZE);
pool = intel_engine_pool_get(&ce->engine->pool, size); pool = intel_engine_get_pool(ce->engine, size);
if (IS_ERR(pool)) { if (IS_ERR(pool)) {
err = PTR_ERR(pool); err = PTR_ERR(pool);
goto out_pm; goto out_pm;
...@@ -216,7 +216,7 @@ struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce, ...@@ -216,7 +216,7 @@ struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce,
count = div_u64(dst->size, block_size); count = div_u64(dst->size, block_size);
size = (1 + 11 * count) * sizeof(u32); size = (1 + 11 * count) * sizeof(u32);
size = round_up(size, PAGE_SIZE); size = round_up(size, PAGE_SIZE);
pool = intel_engine_pool_get(&ce->engine->pool, size); pool = intel_engine_get_pool(ce->engine, size);
if (IS_ERR(pool)) { if (IS_ERR(pool)) {
err = PTR_ERR(pool); err = PTR_ERR(pool);
goto out_pm; goto out_pm;
......
...@@ -107,9 +107,19 @@ node_create(struct intel_engine_pool *pool, size_t sz) ...@@ -107,9 +107,19 @@ node_create(struct intel_engine_pool *pool, size_t sz)
return node; return node;
} }
static struct intel_engine_pool *lookup_pool(struct intel_engine_cs *engine)
{
if (intel_engine_is_virtual(engine))
engine = intel_virtual_engine_get_sibling(engine, 0);
GEM_BUG_ON(!engine);
return &engine->pool;
}
struct intel_engine_pool_node * struct intel_engine_pool_node *
intel_engine_pool_get(struct intel_engine_pool *pool, size_t size) intel_engine_get_pool(struct intel_engine_cs *engine, size_t size)
{ {
struct intel_engine_pool *pool = lookup_pool(engine);
struct intel_engine_pool_node *node; struct intel_engine_pool_node *node;
struct list_head *list; struct list_head *list;
unsigned long flags; unsigned long flags;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "i915_request.h" #include "i915_request.h"
struct intel_engine_pool_node * struct intel_engine_pool_node *
intel_engine_pool_get(struct intel_engine_pool *pool, size_t size); intel_engine_get_pool(struct intel_engine_cs *engine, size_t size);
static inline int static inline int
intel_engine_pool_mark_active(struct intel_engine_pool_node *node, intel_engine_pool_mark_active(struct intel_engine_pool_node *node,
......
...@@ -3851,6 +3851,18 @@ int intel_virtual_engine_attach_bond(struct intel_engine_cs *engine, ...@@ -3851,6 +3851,18 @@ int intel_virtual_engine_attach_bond(struct intel_engine_cs *engine,
return 0; return 0;
} }
struct intel_engine_cs *
intel_virtual_engine_get_sibling(struct intel_engine_cs *engine,
unsigned int sibling)
{
struct virtual_engine *ve = to_virtual_engine(engine);
if (sibling >= ve->num_siblings)
return NULL;
return ve->siblings[sibling];
}
void intel_execlists_show_requests(struct intel_engine_cs *engine, void intel_execlists_show_requests(struct intel_engine_cs *engine,
struct drm_printer *m, struct drm_printer *m,
void (*show_request)(struct drm_printer *m, void (*show_request)(struct drm_printer *m,
......
...@@ -131,4 +131,8 @@ int intel_virtual_engine_attach_bond(struct intel_engine_cs *engine, ...@@ -131,4 +131,8 @@ int intel_virtual_engine_attach_bond(struct intel_engine_cs *engine,
const struct intel_engine_cs *master, const struct intel_engine_cs *master,
const struct intel_engine_cs *sibling); const struct intel_engine_cs *sibling);
struct intel_engine_cs *
intel_virtual_engine_get_sibling(struct intel_engine_cs *engine,
unsigned int sibling);
#endif /* _INTEL_LRC_H_ */ #endif /* _INTEL_LRC_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment