/* the protocol supports up to 32K in each direction */ #define GSC_PROXY_BUFFER_SIZE SZ_32K #define GSC_PROXY_CHANNEL_SIZE (GSC_PROXY_BUFFER_SIZE * 2)
int xe_gsc_wait_for_proxy_init_done(struct xe_gsc *gsc)
{ struct xe_gt *gt = gsc_to_gt(gsc);
/* Proxy init can take up to 500ms, so wait double that for safety */ return xe_mmio_wait32(>->mmio, HECI_FWSTS1(MTL_GSC_HECI1_BASE),
HECI1_FWSTS1_CURRENT_STATE,
HECI1_FWSTS1_PROXY_STATE_NORMAL,
USEC_PER_SEC, NULL, false);
}
/* the message must contain at least the gsc and proxy headers */ if (size > GSC_PROXY_BUFFER_SIZE) {
xe_gt_err(gt, "Invalid GSC proxy message size: %u\n", size); return -EINVAL;
}
staticint validate_proxy_header(struct xe_gt *gt, struct xe_gsc_proxy_header *header,
u32 source, u32 dest, u32 max_size)
{
u32 type = FIELD_GET(GSC_PROXY_TYPE, header->hdr);
u32 length = FIELD_GET(GSC_PROXY_PAYLOAD_LENGTH, header->hdr); int ret = 0;
if (header->destination != dest || header->source != source) {
ret = -ENOEXEC; goto out;
}
if (length + PROXY_HDR_SIZE > max_size) {
ret = -E2BIG; goto out;
}
/* We only care about the status if this is a message for the driver */ if (dest == GSC_PROXY_ADDRESSING_KMD && header->status != 0) {
ret = -EIO; goto out;
}
switch (type) { case GSC_PROXY_MSG_TYPE_PROXY_PAYLOAD: if (length > 0) break;
fallthrough; case GSC_PROXY_MSG_TYPE_PROXY_INVALID:
ret = -EIO; break; default: break;
}
while (1) { /* *PoisontheGSCresponseheaderspacetomakesurewedon't *readastalereply.
*/
xe_gsc_poison_header(xe, &gsc->proxy.from_gsc, 0);
/* send proxy message to GSC */
ret = proxy_send_to_gsc(gsc, size); if (ret) goto proxy_error;
/* check the reply from GSC */
ret = xe_gsc_read_out_header(xe, &gsc->proxy.from_gsc, 0,
PROXY_HDR_SIZE, &reply_offset); if (ret) {
xe_gt_err(gt, "Invalid gsc header in proxy reply (%pe)\n",
ERR_PTR(ret)); goto proxy_error;
}
/* copy the proxy header reply from GSC */
xe_map_memcpy_from(xe, to_csme_hdr, &gsc->proxy.from_gsc,
reply_offset, PROXY_HDR_SIZE);
/* Check the status and stop if this was the last message */ if (FIELD_GET(GSC_PROXY_TYPE, to_csme_hdr->hdr) == GSC_PROXY_MSG_TYPE_PROXY_END) {
ret = validate_proxy_header(gt, to_csme_hdr,
GSC_PROXY_ADDRESSING_GSC,
GSC_PROXY_ADDRESSING_KMD,
GSC_PROXY_BUFFER_SIZE - reply_offset); break;
}
/* make sure the GSC-to-CSME proxy header is sane */
ret = validate_proxy_header(gt, to_csme_hdr,
GSC_PROXY_ADDRESSING_GSC,
GSC_PROXY_ADDRESSING_CSME,
GSC_PROXY_BUFFER_SIZE - reply_offset); if (ret) {
xe_gt_err(gt, "invalid GSC to CSME proxy header! (%pe)\n",
ERR_PTR(ret)); goto proxy_error;
}
/* copy the rest of the message */
size = FIELD_GET(GSC_PROXY_PAYLOAD_LENGTH, to_csme_hdr->hdr);
xe_map_memcpy_from(xe, to_csme_payload, &gsc->proxy.from_gsc,
reply_offset + PROXY_HDR_SIZE, size);
/* send the GSC message to the CSME */
ret = proxy_send_to_csme(gsc, size + PROXY_HDR_SIZE); if (ret < 0) goto proxy_error;
/* reply size from CSME, including the proxy header */
size = ret; if (size < PROXY_HDR_SIZE) {
xe_gt_err(gt, "CSME to GSC proxy msg too small: 0x%x\n", size);
ret = -EPROTO; goto proxy_error;
}
/* make sure the CSME-to-GSC proxy header is sane */
ret = validate_proxy_header(gt, gsc->proxy.from_csme,
GSC_PROXY_ADDRESSING_CSME,
GSC_PROXY_ADDRESSING_GSC,
GSC_PROXY_BUFFER_SIZE - reply_offset); if (ret) {
xe_gt_err(gt, "invalid CSME to GSC proxy header! %d\n", ret); goto proxy_error;
}
/* Emit a new header for sending the reply to the GSC */
wr_offset = xe_gsc_emit_header(xe, &gsc->proxy.to_gsc, 0,
HECI_MEADDRESS_PROXY, 0, size);
/* copy the CSME reply and update the total msg size to include the GSC header */
xe_map_memcpy_to(xe, &gsc->proxy.to_gsc, wr_offset, gsc->proxy.from_csme, size);
size += wr_offset;
}
proxy_error: return ret < 0 ? ret : 0;
}
int xe_gsc_proxy_request_handler(struct xe_gsc *gsc)
{ struct xe_gt *gt = gsc_to_gt(gsc); int slept; int err;
if (!gsc->proxy.component_added) return -ENODEV;
/* when GSC is loaded, we can queue this before the component is bound */ for (slept = 0; slept < GSC_PROXY_INIT_TIMEOUT_MS; slept += 100) { if (gsc->proxy.component) break;
if (!IS_ENABLED(CONFIG_INTEL_MEI_GSC_PROXY)) {
xe_gt_info(gt, "can't init GSC proxy due to missing mei component\n"); return -ENODEV;
}
/* no multi-tile devices with this feature yet */ if (!xe_tile_is_root(tile)) {
xe_gt_err(gt, "unexpected GSC proxy init on tile %u\n", tile->id); return -EINVAL;
}
err = proxy_channel_alloc(gsc); if (err) return err;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.