Commit d8186dd2 authored by Michal Wajdeczko's avatar Michal Wajdeczko Committed by Chris Wilson

drm/i915/guc: Simpler CT message size calculation

We need CT message size in bytes so just use that in helper var.
Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200111231114.59208-2-michal.wajdeczko@intel.com
parent e88e9f8e
...@@ -627,7 +627,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg) ...@@ -627,7 +627,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg)
{ {
u32 header = msg[0]; u32 header = msg[0];
u32 len = ct_header_get_len(header); u32 len = ct_header_get_len(header);
u32 msglen = len + 1; /* total message length including header */ u32 msgsize = (len + 1) * sizeof(u32); /* msg size in bytes w/header */
u32 fence; u32 fence;
u32 status; u32 status;
u32 datalen; u32 datalen;
...@@ -639,7 +639,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg) ...@@ -639,7 +639,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg)
/* Response payload shall at least include fence and status */ /* Response payload shall at least include fence and status */
if (unlikely(len < 2)) { if (unlikely(len < 2)) {
DRM_ERROR("CT: corrupted response %*ph\n", 4 * msglen, msg); DRM_ERROR("CT: corrupted response %*ph\n", msgsize, msg);
return -EPROTO; return -EPROTO;
} }
...@@ -649,7 +649,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg) ...@@ -649,7 +649,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg)
/* Format of the status follows RESPONSE message */ /* Format of the status follows RESPONSE message */
if (unlikely(!INTEL_GUC_MSG_IS_RESPONSE(status))) { if (unlikely(!INTEL_GUC_MSG_IS_RESPONSE(status))) {
DRM_ERROR("CT: corrupted response %*ph\n", 4 * msglen, msg); DRM_ERROR("CT: corrupted response %*ph\n", msgsize, msg);
return -EPROTO; return -EPROTO;
} }
...@@ -664,7 +664,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg) ...@@ -664,7 +664,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg)
} }
if (unlikely(datalen > req->response_len)) { if (unlikely(datalen > req->response_len)) {
DRM_ERROR("CT: response %u too long %*ph\n", DRM_ERROR("CT: response %u too long %*ph\n",
req->fence, 4 * msglen, msg); req->fence, msgsize, msg);
datalen = 0; datalen = 0;
} }
if (datalen) if (datalen)
...@@ -677,7 +677,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg) ...@@ -677,7 +677,7 @@ static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg)
spin_unlock(&ct->requests.lock); spin_unlock(&ct->requests.lock);
if (!found) if (!found)
DRM_ERROR("CT: unsolicited response %*ph\n", 4 * msglen, msg); DRM_ERROR("CT: unsolicited response %*ph\n", msgsize, msg);
return 0; return 0;
} }
...@@ -767,18 +767,18 @@ static int ct_handle_request(struct intel_guc_ct *ct, const u32 *msg) ...@@ -767,18 +767,18 @@ static int ct_handle_request(struct intel_guc_ct *ct, const u32 *msg)
{ {
u32 header = msg[0]; u32 header = msg[0];
u32 len = ct_header_get_len(header); u32 len = ct_header_get_len(header);
u32 msglen = len + 1; /* total message length including header */ u32 msgsize = (len + 1) * sizeof(u32); /* msg size in bytes w/header */
struct ct_incoming_request *request; struct ct_incoming_request *request;
unsigned long flags; unsigned long flags;
GEM_BUG_ON(ct_header_is_response(header)); GEM_BUG_ON(ct_header_is_response(header));
request = kmalloc(sizeof(*request) + 4 * msglen, GFP_ATOMIC); request = kmalloc(sizeof(*request) + msgsize, GFP_ATOMIC);
if (unlikely(!request)) { if (unlikely(!request)) {
DRM_ERROR("CT: dropping request %*ph\n", 4 * msglen, msg); DRM_ERROR("CT: dropping request %*ph\n", msgsize, msg);
return 0; /* XXX: -ENOMEM ? */ return 0; /* XXX: -ENOMEM ? */
} }
memcpy(request->msg, msg, 4 * msglen); memcpy(request->msg, msg, msgsize);
spin_lock_irqsave(&ct->requests.lock, flags); spin_lock_irqsave(&ct->requests.lock, flags);
list_add_tail(&request->link, &ct->requests.incoming); list_add_tail(&request->link, &ct->requests.incoming);
......
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