Lines Matching +full:wakeup +full:- +full:event +full:- +full:action
1 // SPDX-License-Identifier: GPL-2.0-only
3 #define pr_fmt(fmt) "papr-hvpipe: " fmt
17 #include <asm/rtas-work-area.h>
18 #include <asm/papr-sysparm.h>
19 #include <uapi/asm/papr-hvpipe.h>
21 #include "papr-hvpipe.h"
45 * - One hvpipe per partition for all sources.
46 * - Assume the return status of send HVPIPE as delivered to source
47 * - Assume the return status of recv HVPIPE as ACK to source
48 * - Generates HVPIPE event message when the payload is ready
50 * event until the partition read the previous payload which
55 * ex: /dev/papr-indices, /dev/papr-vpd, etc.
56 * - /dev/papr-hvpipe is available for the user space.
57 * - devfd = open("/dev/papr-hvpipe", ..)
58 * - fd = ioctl(fd,HVPIPE_IOC_CREATE_HANDLE,&srcID)-for each source
59 * - write(fd, buf, size) --> Issue send HVPIPE RTAS call and
62 * - poll(fd,..) -> wakeup FD if the payload is available to read.
63 * HVPIPE event message handler wakeup FD based on source ID in
64 * the event message
65 * - read(fd, buf, size) --> Issue recv HVPIPE RTAS call and
71 * ibm,receive-hvpipe-msg RTAS call.
72 * @area: Caller-provided work area buffer for results.
85 return -ENOENT; in rtas_ibm_receive_hvpipe_msg()
101 ret = -EIO; in rtas_ibm_receive_hvpipe_msg()
104 ret = -EINVAL; in rtas_ibm_receive_hvpipe_msg()
107 ret = -EOPNOTSUPP; in rtas_ibm_receive_hvpipe_msg()
110 ret = -EIO; in rtas_ibm_receive_hvpipe_msg()
111 pr_err_ratelimited("unexpected ibm,receive-hvpipe-msg status %d\n", fwrc); in rtas_ibm_receive_hvpipe_msg()
119 * ibm,send-hvpipe-msg RTAS call
120 * @area: Caller-provided work area buffer to send.
130 return -ENOENT; in rtas_ibm_send_hvpipe_msg()
143 ret = -EIO; in rtas_ibm_send_hvpipe_msg()
146 ret = -EINVAL; in rtas_ibm_send_hvpipe_msg()
149 ret = -EPIPE; in rtas_ibm_send_hvpipe_msg()
152 ret = -EOPNOTSUPP; in rtas_ibm_send_hvpipe_msg()
155 ret = -EIO; in rtas_ibm_send_hvpipe_msg()
156 pr_err_ratelimited("unexpected ibm,receive-hvpipe-msg status %d\n", fwrc); in rtas_ibm_send_hvpipe_msg()
168 if (src_info->srcID == srcID) in hvpipe_find_source()
190 return -ENOMEM; in hvpipe_rtas_recv_msg()
200 * so that pipe is not blocked - this func is called in hvpipe_rtas_recv_msg()
216 pr_err("ibm,receive-hvpipe-msg failed with %d\n", in hvpipe_rtas_recv_msg()
225 * papr_hvpipe_handle_write - Issue send HVPIPE RTAS and return
232 struct hvpipe_source_info *src_info = file->private_data; in papr_hvpipe_handle_write()
238 * Return -ENXIO during migration in papr_hvpipe_handle_write()
241 return -ENXIO; in papr_hvpipe_handle_write()
244 return -EIO; in papr_hvpipe_handle_write()
261 * See PAPR 7.3.32.2 ibm,send-hvpipe-msg in papr_hvpipe_handle_write()
273 return -EINVAL; in papr_hvpipe_handle_write()
279 size -= HVPIPE_HDR_LEN; in papr_hvpipe_handle_write()
284 ret = -ENOMEM; in papr_hvpipe_handle_write()
293 ret = -ENOMEM; in papr_hvpipe_handle_write()
302 ret = rtas_ibm_send_hvpipe_msg(work_area, src_info->srcID); in papr_hvpipe_handle_write()
306 ret = -EPERM; in papr_hvpipe_handle_write()
317 * papr_hvpipe_handle_read - If the payload for the specific
322 * hypervisor notifies HVPIPE event with the source ID
323 * and the event handler wakeup FD(s) that are waiting.
329 struct hvpipe_source_info *src_info = file->private_data; in papr_hvpipe_handle_read()
334 * Return -ENXIO during migration in papr_hvpipe_handle_read()
337 return -ENXIO; in papr_hvpipe_handle_read()
340 return -EIO; in papr_hvpipe_handle_read()
347 return -EINVAL; in papr_hvpipe_handle_read()
353 if (!src_info->hvpipe_status) in papr_hvpipe_handle_read()
366 if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) in papr_hvpipe_handle_read()
368 else if (src_info->hvpipe_status & HVPIPE_LOST_CONNECTION) in papr_hvpipe_handle_read()
375 return -EIO; in papr_hvpipe_handle_read()
382 * Message event has payload, so get the payload with in papr_hvpipe_handle_read()
387 size - HVPIPE_HDR_LEN); in papr_hvpipe_handle_read()
389 src_info->hvpipe_status &= ~HVPIPE_MSG_AVAILABLE; in papr_hvpipe_handle_read()
397 src_info->hvpipe_status &= ~HVPIPE_LOST_CONNECTION; in papr_hvpipe_handle_read()
406 * The hypervisor sends HVPIPE event message to the partition
407 * when the payload is available. The event handler wakeup FD
408 * depends on the source ID in the message event.
413 struct hvpipe_source_info *src_info = filp->private_data; in papr_hvpipe_handle_poll()
429 if (src_info->hvpipe_status) in papr_hvpipe_handle_poll()
433 * Wait for the message event in papr_hvpipe_handle_poll()
436 poll_wait(filp, &src_info->recv_wqh, wait); in papr_hvpipe_handle_poll()
437 if (src_info->hvpipe_status) in papr_hvpipe_handle_poll()
451 * with message event IRQ. in papr_hvpipe_handle_release()
454 src_info = file->private_data; in papr_hvpipe_handle_release()
455 list_del(&src_info->list); in papr_hvpipe_handle_release()
456 file->private_data = NULL; in papr_hvpipe_handle_release()
462 if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) { in papr_hvpipe_handle_release()
463 src_info->hvpipe_status = 0; in papr_hvpipe_handle_release()
496 src_info->tsk->pid, srcID); in papr_hvpipe_dev_create_handle()
497 return -EALREADY; in papr_hvpipe_dev_create_handle()
503 return -ENOMEM; in papr_hvpipe_dev_create_handle()
505 src_info->srcID = srcID; in papr_hvpipe_dev_create_handle()
506 src_info->tsk = current; in papr_hvpipe_dev_create_handle()
507 init_waitqueue_head(&src_info->recv_wqh); in papr_hvpipe_dev_create_handle()
515 file = anon_inode_getfile("[papr-hvpipe]", in papr_hvpipe_dev_create_handle()
531 err = -EALREADY; in papr_hvpipe_dev_create_handle()
534 list_add(&src_info->list, &hvpipe_src_list); in papr_hvpipe_dev_create_handle()
550 * Top-level ioctl handler for /dev/papr_hvpipe
563 * Return -ENXIO during migration in papr_hvpipe_dev_ioctl()
566 return -ENXIO; in papr_hvpipe_dev_ioctl()
569 return -EFAULT; in papr_hvpipe_dev_ioctl()
575 return -EINVAL; in papr_hvpipe_dev_ioctl()
582 ret = -ENOIOCTLCMD; in papr_hvpipe_dev_ioctl()
590 * papr_hvpipe_work_fn - called to issue recv HVPIPE RTAS for
600 * HVPIPE event message IRQ handler.
601 * The hypervisor sends event IRQ if the partition has payload
602 * and generates another event only after payload is read with
619 pr_err_ratelimited("unexpected hvpipe-event-notification failed %d\n", rc); in hvpipe_event_interrupt()
625 pr_warn_ratelimited("Unexpected event type %d\n", in hvpipe_event_interrupt()
632 hvpipe_event = (struct hvpipe_event_buf *)pseries_log->data; in hvpipe_event_interrupt()
637 * notify another event for any source until the previous in hvpipe_event_interrupt()
641 * If the source is ready to accept payload and wakeup the in hvpipe_event_interrupt()
652 src_info = hvpipe_find_source(be32_to_cpu(hvpipe_event->srcID)); in hvpipe_event_interrupt()
656 if (hvpipe_event->event_type & HVPIPE_LOST_CONNECTION) in hvpipe_event_interrupt()
658 else if (hvpipe_event->event_type & HVPIPE_MSG_AVAILABLE) in hvpipe_event_interrupt()
661 src_info->hvpipe_status |= flags; in hvpipe_event_interrupt()
662 wake_up(&src_info->recv_wqh); in hvpipe_event_interrupt()
671 if (hvpipe_event->event_type & HVPIPE_MSG_AVAILABLE) in hvpipe_event_interrupt()
691 return -ENOMEM; in set_hvpipe_sys_param()
693 buf->len = cpu_to_be16(1); in set_hvpipe_sys_param()
694 buf->val[0] = val; in set_hvpipe_sys_param()
710 return -ENODEV; in enable_hvpipe_IRQ()
713 np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-events"); in enable_hvpipe_IRQ()
719 pr_err("Can not enable hvpipe event IRQ\n"); in enable_hvpipe_IRQ()
720 return -ENODEV; in enable_hvpipe_IRQ()
726 void hvpipe_migration_handler(int action) in hvpipe_migration_handler() argument
728 pr_info("hvpipe migration event %d\n", action); in hvpipe_migration_handler()
731 * HVPIPE is not used (Failed to create /dev/papr-hvpipe). in hvpipe_migration_handler()
737 switch (action) { in hvpipe_migration_handler()
742 * It will be enabled with RESUME event. in hvpipe_migration_handler()
770 .name = "papr-hvpipe",
778 if (!of_find_property(rtas.dev, "ibm,hypervisor-pipe-capable", in papr_hvpipe_init()
780 return -ENODEV; in papr_hvpipe_init()
784 return -ENODEV; in papr_hvpipe_init()
788 return -ENOMEM; in papr_hvpipe_init()
794 ret = -ENOMEM; in papr_hvpipe_init()