Lines Matching full:gsc
28 * GSC proxy:
29 * The GSC uC needs to communicate with the CSME to perform certain operations.
30 * Since the GSC can't perform this communication directly on platforms where it
32 * GSC to CSME and back. The proxy flow must be manually started after the GSC
33 * is loaded to signal to GSC that we're ready to handle its messages and allow
34 * it to query its init data from CSME; GSC will then trigger an HECI2 interrupt
37 * 1 - Xe submits a request to GSC asking for the message to CSME
38 * 2 - GSC replies with the proxy header + payload for CSME
39 * 3 - Xe sends the reply from GSC as-is to CSME via the mei proxy component
40 * 4 - CSME replies with the proxy header + payload for GSC
41 * 5 - Xe submits a request to GSC with the reply from CSME
42 * 6 - GSC replies either with a new header + payload (same as step 2, so we
60 gsc_to_gt(struct xe_gsc *gsc) in gsc_to_gt() argument
62 return container_of(gsc, struct xe_gt, uc.gsc); in gsc_to_gt()
65 bool xe_gsc_proxy_init_done(struct xe_gsc *gsc) in xe_gsc_proxy_init_done() argument
67 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_init_done()
74 static void __gsc_proxy_irq_rmw(struct xe_gsc *gsc, u32 clr, u32 set) in __gsc_proxy_irq_rmw() argument
76 struct xe_gt *gt = gsc_to_gt(gsc); in __gsc_proxy_irq_rmw()
84 static void gsc_proxy_irq_clear(struct xe_gsc *gsc) in gsc_proxy_irq_clear() argument
87 __gsc_proxy_irq_rmw(gsc, 0, HECI_H_CSR_IS); in gsc_proxy_irq_clear()
90 static void gsc_proxy_irq_toggle(struct xe_gsc *gsc, bool enabled) in gsc_proxy_irq_toggle() argument
95 __gsc_proxy_irq_rmw(gsc, clr, set); in gsc_proxy_irq_toggle()
98 static int proxy_send_to_csme(struct xe_gsc *gsc, u32 size) in proxy_send_to_csme() argument
100 struct xe_gt *gt = gsc_to_gt(gsc); in proxy_send_to_csme()
101 struct i915_gsc_proxy_component *comp = gsc->proxy.component; in proxy_send_to_csme()
104 ret = comp->ops->send(comp->mei_dev, gsc->proxy.to_csme, size); in proxy_send_to_csme()
110 ret = comp->ops->recv(comp->mei_dev, gsc->proxy.from_csme, GSC_PROXY_BUFFER_SIZE); in proxy_send_to_csme()
119 static int proxy_send_to_gsc(struct xe_gsc *gsc, u32 size) in proxy_send_to_gsc() argument
121 struct xe_gt *gt = gsc_to_gt(gsc); in proxy_send_to_gsc()
122 u64 addr_in = xe_bo_ggtt_addr(gsc->proxy.bo); in proxy_send_to_gsc()
126 /* the message must contain at least the gsc and proxy headers */ in proxy_send_to_gsc()
128 xe_gt_err(gt, "Invalid GSC proxy message size: %u\n", size); in proxy_send_to_gsc()
132 err = xe_gsc_pkt_submit_kernel(gsc, addr_in, size, in proxy_send_to_gsc()
135 xe_gt_err(gt, "Failed to submit gsc proxy rq (%pe)\n", ERR_PTR(err)); in proxy_send_to_gsc()
189 static int proxy_query(struct xe_gsc *gsc) in proxy_query() argument
191 struct xe_gt *gt = gsc_to_gt(gsc); in proxy_query()
193 struct xe_gsc_proxy_header *to_csme_hdr = gsc->proxy.to_csme; in proxy_query()
194 void *to_csme_payload = gsc->proxy.to_csme + PROXY_HDR_SIZE; in proxy_query()
200 wr_offset = xe_gsc_emit_header(xe, &gsc->proxy.to_gsc, 0, in proxy_query()
202 wr_offset = emit_proxy_header(xe, &gsc->proxy.to_gsc, wr_offset); in proxy_query()
208 * Poison the GSC response header space to make sure we don't in proxy_query()
211 xe_gsc_poison_header(xe, &gsc->proxy.from_gsc, 0); in proxy_query()
213 /* send proxy message to GSC */ in proxy_query()
214 ret = proxy_send_to_gsc(gsc, size); in proxy_query()
218 /* check the reply from GSC */ in proxy_query()
219 ret = xe_gsc_read_out_header(xe, &gsc->proxy.from_gsc, 0, in proxy_query()
222 xe_gt_err(gt, "Invalid gsc header in proxy reply (%pe)\n", in proxy_query()
227 /* copy the proxy header reply from GSC */ in proxy_query()
228 xe_map_memcpy_from(xe, to_csme_hdr, &gsc->proxy.from_gsc, in proxy_query()
235 /* make sure the GSC-to-CSME proxy header is sane */ in proxy_query()
241 xe_gt_err(gt, "invalid GSC to CSME proxy header! (%pe)\n", in proxy_query()
248 xe_map_memcpy_from(xe, to_csme_payload, &gsc->proxy.from_gsc, in proxy_query()
251 /* send the GSC message to the CSME */ in proxy_query()
252 ret = proxy_send_to_csme(gsc, size + PROXY_HDR_SIZE); in proxy_query()
259 xe_gt_err(gt, "CSME to GSC proxy msg too small: 0x%x\n", size); in proxy_query()
264 /* make sure the CSME-to-GSC proxy header is sane */ in proxy_query()
265 ret = validate_proxy_header(gsc->proxy.from_csme, in proxy_query()
270 xe_gt_err(gt, "invalid CSME to GSC proxy header! %d\n", ret); in proxy_query()
274 /* Emit a new header for sending the reply to the GSC */ in proxy_query()
275 wr_offset = xe_gsc_emit_header(xe, &gsc->proxy.to_gsc, 0, in proxy_query()
278 /* copy the CSME reply and update the total msg size to include the GSC header */ in proxy_query()
279 xe_map_memcpy_to(xe, &gsc->proxy.to_gsc, wr_offset, gsc->proxy.from_csme, size); in proxy_query()
288 int xe_gsc_proxy_request_handler(struct xe_gsc *gsc) in xe_gsc_proxy_request_handler() argument
290 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_request_handler()
294 if (!gsc->proxy.component_added) in xe_gsc_proxy_request_handler()
297 /* when GSC is loaded, we can queue this before the component is bound */ in xe_gsc_proxy_request_handler()
299 if (gsc->proxy.component) in xe_gsc_proxy_request_handler()
305 mutex_lock(&gsc->proxy.mutex); in xe_gsc_proxy_request_handler()
306 if (!gsc->proxy.component) { in xe_gsc_proxy_request_handler()
307 xe_gt_err(gt, "GSC proxy component not bound!\n"); in xe_gsc_proxy_request_handler()
314 gsc_proxy_irq_clear(gsc); in xe_gsc_proxy_request_handler()
315 err = proxy_query(gsc); in xe_gsc_proxy_request_handler()
317 mutex_unlock(&gsc->proxy.mutex); in xe_gsc_proxy_request_handler()
321 void xe_gsc_proxy_irq_handler(struct xe_gsc *gsc, u32 iir) in xe_gsc_proxy_irq_handler() argument
323 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_irq_handler()
328 if (!gsc->proxy.component) { in xe_gsc_proxy_irq_handler()
329 xe_gt_err(gt, "GSC proxy irq received without the component being bound!\n"); in xe_gsc_proxy_irq_handler()
333 spin_lock(&gsc->lock); in xe_gsc_proxy_irq_handler()
334 gsc->work_actions |= GSC_ACTION_SW_PROXY; in xe_gsc_proxy_irq_handler()
335 spin_unlock(&gsc->lock); in xe_gsc_proxy_irq_handler()
337 queue_work(gsc->wq, &gsc->work); in xe_gsc_proxy_irq_handler()
345 struct xe_gsc *gsc = >->uc.gsc; in xe_gsc_proxy_component_bind() local
347 mutex_lock(&gsc->proxy.mutex); in xe_gsc_proxy_component_bind()
348 gsc->proxy.component = data; in xe_gsc_proxy_component_bind()
349 gsc->proxy.component->mei_dev = mei_kdev; in xe_gsc_proxy_component_bind()
350 mutex_unlock(&gsc->proxy.mutex); in xe_gsc_proxy_component_bind()
360 struct xe_gsc *gsc = >->uc.gsc; in xe_gsc_proxy_component_unbind() local
362 xe_gsc_wait_for_worker_completion(gsc); in xe_gsc_proxy_component_unbind()
364 mutex_lock(&gsc->proxy.mutex); in xe_gsc_proxy_component_unbind()
365 gsc->proxy.component = NULL; in xe_gsc_proxy_component_unbind()
366 mutex_unlock(&gsc->proxy.mutex); in xe_gsc_proxy_component_unbind()
374 static int proxy_channel_alloc(struct xe_gsc *gsc) in proxy_channel_alloc() argument
376 struct xe_gt *gt = gsc_to_gt(gsc); in proxy_channel_alloc()
392 gsc->proxy.bo = bo; in proxy_channel_alloc()
393 gsc->proxy.to_gsc = IOSYS_MAP_INIT_OFFSET(&bo->vmap, 0); in proxy_channel_alloc()
394 gsc->proxy.from_gsc = IOSYS_MAP_INIT_OFFSET(&bo->vmap, GSC_PROXY_BUFFER_SIZE); in proxy_channel_alloc()
395 gsc->proxy.to_csme = csme; in proxy_channel_alloc()
396 gsc->proxy.from_csme = csme + GSC_PROXY_BUFFER_SIZE; in proxy_channel_alloc()
402 * xe_gsc_proxy_init() - init objects and MEI component required by GSC proxy
403 * @gsc: the GSC uC
407 int xe_gsc_proxy_init(struct xe_gsc *gsc) in xe_gsc_proxy_init() argument
410 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_init()
414 mutex_init(&gsc->proxy.mutex); in xe_gsc_proxy_init()
417 xe_gt_info(gt, "can't init GSC proxy due to missing mei component\n"); in xe_gsc_proxy_init()
423 xe_gt_err(gt, "unexpected GSC proxy init on tile %u\n", tile->id); in xe_gsc_proxy_init()
427 err = proxy_channel_alloc(gsc); in xe_gsc_proxy_init()
438 gsc->proxy.component_added = true; in xe_gsc_proxy_init()
446 * xe_gsc_proxy_remove() - remove the GSC proxy MEI component
447 * @gsc: the GSC uC
449 void xe_gsc_proxy_remove(struct xe_gsc *gsc) in xe_gsc_proxy_remove() argument
451 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_remove()
455 if (!gsc->proxy.component_added) in xe_gsc_proxy_remove()
462 xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n"); in xe_gsc_proxy_remove()
465 gsc_proxy_irq_toggle(gsc, false); in xe_gsc_proxy_remove()
471 xe_gsc_wait_for_worker_completion(gsc); in xe_gsc_proxy_remove()
474 gsc->proxy.component_added = false; in xe_gsc_proxy_remove()
479 * @gsc: the GSC uC
483 int xe_gsc_proxy_start(struct xe_gsc *gsc) in xe_gsc_proxy_start() argument
487 /* enable the proxy interrupt in the GSC shim layer */ in xe_gsc_proxy_start()
488 gsc_proxy_irq_toggle(gsc, true); in xe_gsc_proxy_start()
492 * notify the GSC that we're ready to support the proxy flow. in xe_gsc_proxy_start()
494 err = xe_gsc_proxy_request_handler(gsc); in xe_gsc_proxy_start()
498 if (!xe_gsc_proxy_init_done(gsc)) { in xe_gsc_proxy_start()
499 xe_gt_err(gsc_to_gt(gsc), "GSC FW reports proxy init not completed\n"); in xe_gsc_proxy_start()