/* * GSC proxy: * The GSC uC needs to communicate with the CSME to perform certain operations. * Since the GSC can't perform this communication directly on platforms where it * is integrated in GT, the graphics driver needs to transfer the messages from * GSC to CSME and back. The proxy flow must be manually started after the GSC * is loaded to signal to GSC that we're ready to handle its messages and allow * it to query its init data from CSME; GSC will then trigger an HECI2 interrupt * if it needs to send messages to CSME again. * The proxy flow is as follow: * 1 - Xe submits a request to GSC asking for the message to CSME * 2 - GSC replies with the proxy header + payload for CSME * 3 - Xe sends the reply from GSC as-is to CSME via the mei proxy component * 4 - CSME replies with the proxy header + payload for GSC * 5 - Xe submits a request to GSC with the reply from CSME * 6 - GSC replies either with a new header + payload (same as step 2, so we * restart from there) or with an end message.
*/
/* * The component should load quite quickly in most cases, but it could take * a bit. Using a very big timeout just to cover the worst case scenario
*/ #define GSC_PROXY_INIT_TIMEOUT_MS 20000
/* 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) { /* * Poison the GSC response header space to make sure we don't * read a stale reply.
*/
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;
msleep(100);
}
mutex_lock(&gsc->proxy.mutex); if (!gsc->proxy.component) {
xe_gt_err(gt, "GSC proxy component not bound!\n");
err = -EIO;
} else { /* * clear the pending interrupt and allow new proxy requests to * be generated while we handle the current one
*/
gsc_proxy_irq_clear(gsc);
err = proxy_query(gsc);
}
mutex_unlock(&gsc->proxy.mutex); return err;
}
/** * xe_gsc_proxy_init() - init objects and MEI component required by GSC proxy * @gsc: the GSC uC * * Return: 0 if the initialization was successful, a negative errno otherwise.
*/ int xe_gsc_proxy_init(struct xe_gsc *gsc)
{ int err; struct xe_gt *gt = gsc_to_gt(gsc); struct xe_tile *tile = gt_to_tile(gt); struct xe_device *xe = tile_to_xe(tile);
mutex_init(&gsc->proxy.mutex);
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;
/** * xe_gsc_proxy_start() - start the proxy by submitting the first request * @gsc: the GSC uC * * Return: 0 if the proxy are now enabled, a negative errno otherwise.
*/ int xe_gsc_proxy_start(struct xe_gsc *gsc)
{ int err;
/* enable the proxy interrupt in the GSC shim layer */
gsc_proxy_irq_toggle(gsc, true);
/* * The handling of the first proxy request must be manually triggered to * notify the GSC that we're ready to support the proxy flow.
*/
err = xe_gsc_proxy_request_handler(gsc); if (err) return err;
if (!xe_gsc_proxy_init_done(gsc)) {
xe_gt_err(gsc_to_gt(gsc), "GSC FW reports proxy init not completed\n"); return -EIO;
}
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.