Commit e78c9175 authored by Chris Wilson's avatar Chris Wilson

drm/i915/guc: Allow preempt-client to be NULL

In the next patch, we may only conditionally allocate the preempt-client
if there is a global preempt context and so we need to be prepared in
case the preempt-client itself is NULL.

v2: Grep for more preempt_client.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Michel Thierry <michel.thierry@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180207210544.26351-1-chris@chris-wilson.co.ukReviewed-by: default avatarMichel Thierry <michel.thierry@intel.com>
parent 05273c95
...@@ -2338,7 +2338,6 @@ static int i915_guc_info(struct seq_file *m, void *data) ...@@ -2338,7 +2338,6 @@ static int i915_guc_info(struct seq_file *m, void *data)
return -ENODEV; return -ENODEV;
GEM_BUG_ON(!guc->execbuf_client); GEM_BUG_ON(!guc->execbuf_client);
GEM_BUG_ON(!guc->preempt_client);
seq_printf(m, "Doorbell map:\n"); seq_printf(m, "Doorbell map:\n");
seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap);
...@@ -2346,8 +2345,11 @@ static int i915_guc_info(struct seq_file *m, void *data) ...@@ -2346,8 +2345,11 @@ static int i915_guc_info(struct seq_file *m, void *data)
seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
i915_guc_client_info(m, dev_priv, guc->execbuf_client); i915_guc_client_info(m, dev_priv, guc->execbuf_client);
seq_printf(m, "\nGuC preempt client @ %p:\n", guc->preempt_client); if (guc->preempt_client) {
seq_printf(m, "\nGuC preempt client @ %p:\n",
guc->preempt_client);
i915_guc_client_info(m, dev_priv, guc->preempt_client); i915_guc_client_info(m, dev_priv, guc->preempt_client);
}
i915_guc_log_info(m, dev_priv); i915_guc_log_info(m, dev_priv);
......
...@@ -832,11 +832,13 @@ static int guc_clients_doorbell_init(struct intel_guc *guc) ...@@ -832,11 +832,13 @@ static int guc_clients_doorbell_init(struct intel_guc *guc)
if (ret) if (ret)
return ret; return ret;
if (guc->preempt_client) {
ret = create_doorbell(guc->preempt_client); ret = create_doorbell(guc->preempt_client);
if (ret) { if (ret) {
destroy_doorbell(guc->execbuf_client); destroy_doorbell(guc->execbuf_client);
return ret; return ret;
} }
}
return 0; return 0;
} }
...@@ -848,8 +850,11 @@ static void guc_clients_doorbell_fini(struct intel_guc *guc) ...@@ -848,8 +850,11 @@ static void guc_clients_doorbell_fini(struct intel_guc *guc)
* Instead of trying (in vain) to communicate with it, let's just * Instead of trying (in vain) to communicate with it, let's just
* cleanup the doorbell HW and our internal state. * cleanup the doorbell HW and our internal state.
*/ */
if (guc->preempt_client) {
__destroy_doorbell(guc->preempt_client); __destroy_doorbell(guc->preempt_client);
__update_doorbell_desc(guc->preempt_client, GUC_DOORBELL_INVALID); __update_doorbell_desc(guc->preempt_client,
GUC_DOORBELL_INVALID);
}
__destroy_doorbell(guc->execbuf_client); __destroy_doorbell(guc->execbuf_client);
__update_doorbell_desc(guc->execbuf_client, GUC_DOORBELL_INVALID); __update_doorbell_desc(guc->execbuf_client, GUC_DOORBELL_INVALID);
} }
...@@ -998,10 +1003,11 @@ static void guc_clients_destroy(struct intel_guc *guc) ...@@ -998,10 +1003,11 @@ static void guc_clients_destroy(struct intel_guc *guc)
{ {
struct intel_guc_client *client; struct intel_guc_client *client;
client = fetch_and_zero(&guc->execbuf_client); client = fetch_and_zero(&guc->preempt_client);
if (client)
guc_client_free(client); guc_client_free(client);
client = fetch_and_zero(&guc->preempt_client); client = fetch_and_zero(&guc->execbuf_client);
guc_client_free(client); guc_client_free(client);
} }
...@@ -1160,6 +1166,7 @@ int intel_guc_submission_enable(struct intel_guc *guc) ...@@ -1160,6 +1166,7 @@ int intel_guc_submission_enable(struct intel_guc *guc)
GEM_BUG_ON(!guc->execbuf_client); GEM_BUG_ON(!guc->execbuf_client);
guc_reset_wq(guc->execbuf_client); guc_reset_wq(guc->execbuf_client);
if (guc->preempt_client)
guc_reset_wq(guc->preempt_client); guc_reset_wq(guc->preempt_client);
err = intel_guc_sample_forcewake(guc); err = intel_guc_sample_forcewake(guc);
......
...@@ -87,7 +87,7 @@ static int validate_client(struct intel_guc_client *client, ...@@ -87,7 +87,7 @@ static int validate_client(struct intel_guc_client *client,
static bool client_doorbell_in_sync(struct intel_guc_client *client) static bool client_doorbell_in_sync(struct intel_guc_client *client)
{ {
return doorbell_ok(client->guc, client->doorbell_id); return !client || doorbell_ok(client->guc, client->doorbell_id);
} }
/* /*
...@@ -137,7 +137,6 @@ static int igt_guc_clients(void *args) ...@@ -137,7 +137,6 @@ static int igt_guc_clients(void *args)
goto unlock; goto unlock;
} }
GEM_BUG_ON(!guc->execbuf_client); GEM_BUG_ON(!guc->execbuf_client);
GEM_BUG_ON(!guc->preempt_client);
err = validate_client(guc->execbuf_client, err = validate_client(guc->execbuf_client,
GUC_CLIENT_PRIORITY_KMD_NORMAL, false); GUC_CLIENT_PRIORITY_KMD_NORMAL, false);
...@@ -146,16 +145,18 @@ static int igt_guc_clients(void *args) ...@@ -146,16 +145,18 @@ static int igt_guc_clients(void *args)
goto out; goto out;
} }
if (guc->preempt_client) {
err = validate_client(guc->preempt_client, err = validate_client(guc->preempt_client,
GUC_CLIENT_PRIORITY_KMD_HIGH, true); GUC_CLIENT_PRIORITY_KMD_HIGH, true);
if (err) { if (err) {
pr_err("preempt client validation failed\n"); pr_err("preempt client validation failed\n");
goto out; goto out;
} }
}
/* each client should now have reserved a doorbell */ /* each client should now have reserved a doorbell */
if (!has_doorbell(guc->execbuf_client) || if (!has_doorbell(guc->execbuf_client) ||
!has_doorbell(guc->preempt_client)) { (guc->preempt_client && !has_doorbell(guc->preempt_client))) {
pr_err("guc_clients_create didn't reserve doorbells\n"); pr_err("guc_clients_create didn't reserve doorbells\n");
err = -EINVAL; err = -EINVAL;
goto out; goto out;
...@@ -224,6 +225,7 @@ static int igt_guc_clients(void *args) ...@@ -224,6 +225,7 @@ static int igt_guc_clients(void *args)
* clients during unload. * clients during unload.
*/ */
destroy_doorbell(guc->execbuf_client); destroy_doorbell(guc->execbuf_client);
if (guc->preempt_client)
destroy_doorbell(guc->preempt_client); destroy_doorbell(guc->preempt_client);
guc_clients_destroy(guc); guc_clients_destroy(guc);
guc_clients_create(guc); guc_clients_create(guc);
......
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