drm/edid/firmware: Add built-in edid/1280x720.bin firmware
[platform/kernel/linux-starfive.git] / io_uring / io_uring.h
index 50bc3af..0196005 100644 (file)
@@ -3,7 +3,9 @@
 
 #include <linux/errno.h>
 #include <linux/lockdep.h>
+#include <linux/resume_user_mode.h>
 #include <linux/io_uring_types.h>
+#include <uapi/linux/eventpoll.h>
 #include "io-wq.h"
 #include "slist.h"
 #include "filetable.h"
@@ -32,7 +34,6 @@ int io_run_local_work(struct io_ring_ctx *ctx);
 void io_req_complete_failed(struct io_kiocb *req, s32 res);
 void __io_req_complete(struct io_kiocb *req, unsigned issue_flags);
 void io_req_complete_post(struct io_kiocb *req);
-void __io_req_complete_post(struct io_kiocb *req);
 bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags,
                     bool allow_overflow);
 bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags,
@@ -50,10 +51,9 @@ static inline bool io_req_ffs_set(struct io_kiocb *req)
        return req->flags & REQ_F_FIXED_FILE;
 }
 
+void __io_req_task_work_add(struct io_kiocb *req, bool allow_local);
 bool io_is_uring_fops(struct file *file);
 bool io_alloc_async_data(struct io_kiocb *req);
-void io_req_task_work_add(struct io_kiocb *req);
-void io_req_tw_post_queue(struct io_kiocb *req, s32 res, u32 cflags);
 void io_req_task_queue(struct io_kiocb *req);
 void io_queue_iowq(struct io_kiocb *req, bool *dont_use);
 void io_req_task_complete(struct io_kiocb *req, bool *locked);
@@ -82,6 +82,11 @@ bool __io_alloc_req_refill(struct io_ring_ctx *ctx);
 bool io_match_task_safe(struct io_kiocb *head, struct task_struct *task,
                        bool cancel_all);
 
+static inline void io_req_task_work_add(struct io_kiocb *req)
+{
+       __io_req_task_work_add(req, true);
+}
+
 #define io_for_each_link(pos, head) \
        for (pos = (head); pos; pos = pos->link)
 
@@ -207,12 +212,18 @@ static inline void io_commit_cqring(struct io_ring_ctx *ctx)
 static inline void __io_cqring_wake(struct io_ring_ctx *ctx)
 {
        /*
-        * wake_up_all() may seem excessive, but io_wake_function() and
-        * io_should_wake() handle the termination of the loop and only
-        * wake as many waiters as we need to.
+        * Trigger waitqueue handler on all waiters on our waitqueue. This
+        * won't necessarily wake up all the tasks, io_should_wake() will make
+        * that decision.
+        *
+        * Pass in EPOLLIN|EPOLL_URING_WAKE as the poll wakeup key. The latter
+        * set in the mask so that if we recurse back into our own poll
+        * waitqueue handlers, we know we have a dependency between eventfd or
+        * epoll and should terminate multishot poll at that point.
         */
        if (waitqueue_active(&ctx->cq_wait))
-               wake_up_all(&ctx->cq_wait);
+               __wake_up(&ctx->cq_wait, TASK_NORMAL, 0,
+                               poll_to_key(EPOLL_URING_WAKE | EPOLLIN));
 }
 
 static inline void io_cqring_wake(struct io_ring_ctx *ctx)
@@ -245,6 +256,15 @@ static inline int io_run_task_work(void)
         */
        if (test_thread_flag(TIF_NOTIFY_SIGNAL))
                clear_notify_signal();
+       /*
+        * PF_IO_WORKER never returns to userspace, so check here if we have
+        * notify work that needs processing.
+        */
+       if (current->flags & PF_IO_WORKER &&
+           test_thread_flag(TIF_NOTIFY_RESUME)) {
+               __set_current_state(TASK_RUNNING);
+               resume_user_mode_work(NULL);
+       }
        if (task_work_pending(current)) {
                __set_current_state(TASK_RUNNING);
                task_work_run();
@@ -369,4 +389,11 @@ static inline bool io_allowed_run_tw(struct io_ring_ctx *ctx)
                      ctx->submitter_task == current);
 }
 
+static inline void io_req_queue_tw_complete(struct io_kiocb *req, s32 res)
+{
+       io_req_set_res(req, res, 0);
+       req->io_task_work.func = io_req_task_complete;
+       io_req_task_work_add(req);
+}
+
 #endif