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()
181 "GSC proxy error: s=0x%x[0x%x], d=0x%x[0x%x], t=%u, l=0x%x, st=0x%x\n", in validate_proxy_header()
209 static int proxy_query(struct xe_gsc *gsc) in proxy_query() argument
211 struct xe_gt *gt = gsc_to_gt(gsc); in proxy_query()
213 struct xe_gsc_proxy_header *to_csme_hdr = gsc->proxy.to_csme; in proxy_query()
214 void *to_csme_payload = gsc->proxy.to_csme + PROXY_HDR_SIZE; in proxy_query()
220 wr_offset = xe_gsc_emit_header(xe, &gsc->proxy.to_gsc, 0, in proxy_query()
222 wr_offset = emit_proxy_header(xe, &gsc->proxy.to_gsc, wr_offset); in proxy_query()
228 * Poison the GSC response header space to make sure we don't in proxy_query()
231 xe_gsc_poison_header(xe, &gsc->proxy.from_gsc, 0); in proxy_query()
233 /* send proxy message to GSC */ in proxy_query()
234 ret = proxy_send_to_gsc(gsc, size); in proxy_query()
238 /* check the reply from GSC */ in proxy_query()
239 ret = xe_gsc_read_out_header(xe, &gsc->proxy.from_gsc, 0, in proxy_query()
242 xe_gt_err(gt, "Invalid gsc header in proxy reply (%pe)\n", in proxy_query()
247 /* copy the proxy header reply from GSC */ in proxy_query()
248 xe_map_memcpy_from(xe, to_csme_hdr, &gsc->proxy.from_gsc, in proxy_query()
260 /* make sure the GSC-to-CSME proxy header is sane */ in proxy_query()
266 xe_gt_err(gt, "invalid GSC to CSME proxy header! (%pe)\n", in proxy_query()
273 xe_map_memcpy_from(xe, to_csme_payload, &gsc->proxy.from_gsc, in proxy_query()
276 /* send the GSC message to the CSME */ in proxy_query()
277 ret = proxy_send_to_csme(gsc, size + PROXY_HDR_SIZE); in proxy_query()
284 xe_gt_err(gt, "CSME to GSC proxy msg too small: 0x%x\n", size); in proxy_query()
289 /* make sure the CSME-to-GSC proxy header is sane */ in proxy_query()
290 ret = validate_proxy_header(gt, gsc->proxy.from_csme, in proxy_query()
295 xe_gt_err(gt, "invalid CSME to GSC proxy header! %d\n", ret); in proxy_query()
299 /* Emit a new header for sending the reply to the GSC */ in proxy_query()
300 wr_offset = xe_gsc_emit_header(xe, &gsc->proxy.to_gsc, 0, in proxy_query()
303 /* copy the CSME reply and update the total msg size to include the GSC header */ in proxy_query()
304 xe_map_memcpy_to(xe, &gsc->proxy.to_gsc, wr_offset, gsc->proxy.from_csme, size); in proxy_query()
313 int xe_gsc_proxy_request_handler(struct xe_gsc *gsc) in xe_gsc_proxy_request_handler() argument
315 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_request_handler()
319 if (!gsc->proxy.component_added) in xe_gsc_proxy_request_handler()
322 /* when GSC is loaded, we can queue this before the component is bound */ in xe_gsc_proxy_request_handler()
324 if (gsc->proxy.component) in xe_gsc_proxy_request_handler()
330 mutex_lock(&gsc->proxy.mutex); in xe_gsc_proxy_request_handler()
331 if (!gsc->proxy.component) { in xe_gsc_proxy_request_handler()
332 xe_gt_err(gt, "GSC proxy component not bound!\n"); in xe_gsc_proxy_request_handler()
339 gsc_proxy_irq_clear(gsc); in xe_gsc_proxy_request_handler()
340 err = proxy_query(gsc); in xe_gsc_proxy_request_handler()
342 mutex_unlock(&gsc->proxy.mutex); in xe_gsc_proxy_request_handler()
346 void xe_gsc_proxy_irq_handler(struct xe_gsc *gsc, u32 iir) in xe_gsc_proxy_irq_handler() argument
348 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_irq_handler()
353 if (!gsc->proxy.component) { in xe_gsc_proxy_irq_handler()
354 xe_gt_err(gt, "GSC proxy irq received without the component being bound!\n"); in xe_gsc_proxy_irq_handler()
358 spin_lock(&gsc->lock); in xe_gsc_proxy_irq_handler()
359 gsc->work_actions |= GSC_ACTION_SW_PROXY; in xe_gsc_proxy_irq_handler()
360 spin_unlock(&gsc->lock); in xe_gsc_proxy_irq_handler()
362 queue_work(gsc->wq, &gsc->work); in xe_gsc_proxy_irq_handler()
370 struct xe_gsc *gsc = >->uc.gsc; in xe_gsc_proxy_component_bind() local
372 mutex_lock(&gsc->proxy.mutex); in xe_gsc_proxy_component_bind()
373 gsc->proxy.component = data; in xe_gsc_proxy_component_bind()
374 gsc->proxy.component->mei_dev = mei_kdev; in xe_gsc_proxy_component_bind()
375 mutex_unlock(&gsc->proxy.mutex); in xe_gsc_proxy_component_bind()
385 struct xe_gsc *gsc = >->uc.gsc; in xe_gsc_proxy_component_unbind() local
387 xe_gsc_wait_for_worker_completion(gsc); in xe_gsc_proxy_component_unbind()
389 mutex_lock(&gsc->proxy.mutex); in xe_gsc_proxy_component_unbind()
390 gsc->proxy.component = NULL; in xe_gsc_proxy_component_unbind()
391 mutex_unlock(&gsc->proxy.mutex); in xe_gsc_proxy_component_unbind()
399 static int proxy_channel_alloc(struct xe_gsc *gsc) in proxy_channel_alloc() argument
401 struct xe_gt *gt = gsc_to_gt(gsc); in proxy_channel_alloc()
417 gsc->proxy.bo = bo; in proxy_channel_alloc()
418 gsc->proxy.to_gsc = IOSYS_MAP_INIT_OFFSET(&bo->vmap, 0); in proxy_channel_alloc()
419 gsc->proxy.from_gsc = IOSYS_MAP_INIT_OFFSET(&bo->vmap, GSC_PROXY_BUFFER_SIZE); in proxy_channel_alloc()
420 gsc->proxy.to_csme = csme; in proxy_channel_alloc()
421 gsc->proxy.from_csme = csme + GSC_PROXY_BUFFER_SIZE; in proxy_channel_alloc()
427 * xe_gsc_proxy_init() - init objects and MEI component required by GSC proxy
428 * @gsc: the GSC uC
432 int xe_gsc_proxy_init(struct xe_gsc *gsc) in xe_gsc_proxy_init() argument
435 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_init()
439 mutex_init(&gsc->proxy.mutex); in xe_gsc_proxy_init()
442 xe_gt_info(gt, "can't init GSC proxy due to missing mei component\n"); in xe_gsc_proxy_init()
448 xe_gt_err(gt, "unexpected GSC proxy init on tile %u\n", tile->id); in xe_gsc_proxy_init()
452 err = proxy_channel_alloc(gsc); in xe_gsc_proxy_init()
463 gsc->proxy.component_added = true; in xe_gsc_proxy_init()
471 * xe_gsc_proxy_remove() - remove the GSC proxy MEI component
472 * @gsc: the GSC uC
474 void xe_gsc_proxy_remove(struct xe_gsc *gsc) in xe_gsc_proxy_remove() argument
476 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_proxy_remove()
480 if (!gsc->proxy.component_added) in xe_gsc_proxy_remove()
487 xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n"); in xe_gsc_proxy_remove()
490 gsc_proxy_irq_toggle(gsc, false); in xe_gsc_proxy_remove()
495 xe_gsc_wait_for_worker_completion(gsc); in xe_gsc_proxy_remove()
498 gsc->proxy.component_added = false; in xe_gsc_proxy_remove()
503 * @gsc: the GSC uC
507 int xe_gsc_proxy_start(struct xe_gsc *gsc) in xe_gsc_proxy_start() argument
511 /* enable the proxy interrupt in the GSC shim layer */ in xe_gsc_proxy_start()
512 gsc_proxy_irq_toggle(gsc, true); in xe_gsc_proxy_start()
516 * notify the GSC that we're ready to support the proxy flow. in xe_gsc_proxy_start()
518 err = xe_gsc_proxy_request_handler(gsc); in xe_gsc_proxy_start()
522 if (!xe_gsc_proxy_init_done(gsc)) { in xe_gsc_proxy_start()
523 xe_gt_err(gsc_to_gt(gsc), "GSC FW reports proxy init not completed\n"); in xe_gsc_proxy_start()