drm/i915/guc: Don't GEM_BUG_ON on corrupted G2H CTB

We should never BUG_ON on any corruption in CTB descriptor as
data there can be also modified by the GuC. Instead we can
use flag "is_in_error" to indicate that we will not process
any further messages over this CTB (until reset). While here
move descriptor error reporting to the function that actually
touches that descriptor.

Note that unexpected content of the specific CT messages, that
still complies with generic CT message format, shall not trigger
disabling whole CTB, as that might just indicate new unsupported
message types.

v2: drop redundant message (Daniele)

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200117082039.65644-2-michal.wajdeczko@intel.com
This commit is contained in:
Michal Wajdeczko 2020-01-17 08:20:35 +00:00 committed by Chris Wilson
parent 416d3838f7
commit 1b9fc94a77

View File

@ -578,19 +578,25 @@ static inline bool ct_header_is_response(u32 header)
static int ctb_read(struct intel_guc_ct_buffer *ctb, u32 *data) static int ctb_read(struct intel_guc_ct_buffer *ctb, u32 *data)
{ {
struct guc_ct_buffer_desc *desc = ctb->desc; struct guc_ct_buffer_desc *desc = ctb->desc;
u32 head = desc->head / 4; /* in dwords */ u32 head = desc->head;
u32 tail = desc->tail / 4; /* in dwords */ u32 tail = desc->tail;
u32 size = desc->size / 4; /* in dwords */ u32 size = desc->size;
u32 *cmds = ctb->cmds; u32 *cmds = ctb->cmds;
s32 available; /* in dwords */ s32 available;
unsigned int len; unsigned int len;
unsigned int i; unsigned int i;
GEM_BUG_ON(desc->size % 4); if (unlikely(desc->is_in_error))
GEM_BUG_ON(desc->head % 4); return -EPIPE;
GEM_BUG_ON(desc->tail % 4);
GEM_BUG_ON(tail >= size); if (unlikely(!IS_ALIGNED(head | tail | size, 4) ||
GEM_BUG_ON(head >= size); (tail | head) >= size))
goto corrupted;
/* later calculations will be done in dwords */
head /= 4;
tail /= 4;
size /= 4;
/* tail == head condition indicates empty */ /* tail == head condition indicates empty */
available = tail - head; available = tail - head;
@ -615,7 +621,7 @@ static int ctb_read(struct intel_guc_ct_buffer *ctb, u32 *data)
size - head : available - 1), &cmds[head], size - head : available - 1), &cmds[head],
4 * (head + available - 1 > size ? 4 * (head + available - 1 > size ?
available - 1 - size + head : 0), &cmds[0]); available - 1 - size + head : 0), &cmds[0]);
return -EPROTO; goto corrupted;
} }
for (i = 1; i < len; i++) { for (i = 1; i < len; i++) {
@ -626,6 +632,12 @@ static int ctb_read(struct intel_guc_ct_buffer *ctb, u32 *data)
desc->head = head * 4; desc->head = head * 4;
return 0; return 0;
corrupted:
DRM_ERROR("CT: Corrupted descriptor addr=%#x head=%u tail=%u size=%u\n",
desc->addr, desc->head, desc->tail, desc->size);
desc->is_in_error = 1;
return -EPIPE;
} }
/** /**
@ -836,10 +848,4 @@ void intel_guc_ct_event_handler(struct intel_guc_ct *ct)
else else
err = ct_handle_request(ct, msg); err = ct_handle_request(ct, msg);
} while (!err); } while (!err);
if (GEM_WARN_ON(err == -EPROTO)) {
CT_ERROR(ct, "Corrupted message: %#x\n", msg[0]);
ctb->desc->is_in_error = 1;
}
} }