From: Tomas Winkler <tomas.winkler@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: arnd@arndb.de, Alexander Usyskin <alexander.usyskin@intel.com>,
linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 8/9 RESEND] mei: implement fasync for event notification
Date: Sun, 26 Jul 2015 09:54:22 +0300 [thread overview]
Message-ID: <1437893663-2068-9-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1437893663-2068-1-git-send-email-tomas.winkler@intel.com>
A process can be informed about client notification also via
SIGIO with POLL_PRI event.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/client.c | 27 +++++++++++++++++++++++++++
drivers/misc/mei/client.h | 1 +
drivers/misc/mei/hbm.c | 6 ++----
drivers/misc/mei/main.c | 21 +++++++++++++++++++++
drivers/misc/mei/mei_dev.h | 2 ++
5 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index d9396838774c..db2436aee2dc 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -1351,6 +1351,33 @@ out:
}
/**
+ * mei_cl_notify - raise notification
+ *
+ * @cl: host client
+ *
+ * Locking: called under "dev->device_lock" lock
+ */
+void mei_cl_notify(struct mei_cl *cl)
+{
+ struct mei_device *dev;
+
+ if (!cl || !cl->dev)
+ return;
+
+ dev = cl->dev;
+
+ if (!cl->notify_en)
+ return;
+
+ cl_dbg(dev, cl, "notify event");
+ cl->notify_ev = true;
+ wake_up_interruptible_all(&cl->ev_wait);
+
+ if (cl->ev_async)
+ kill_fasync(&cl->ev_async, SIGIO, POLL_PRI);
+}
+
+/**
* mei_cl_notify_get - get or wait for notification event
*
* @cl: host client
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index 58a4b49701fe..1c7cad07d731 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -225,6 +225,7 @@ int mei_cl_notify_request(struct mei_cl *cl, struct file *file, u8 request);
int mei_cl_irq_notify(struct mei_cl *cl, struct mei_cl_cb *cb,
struct mei_cl_cb *cmpl_list);
int mei_cl_notify_get(struct mei_cl *cl, bool block, bool *notify_ev);
+void mei_cl_notify(struct mei_cl *cl);
void mei_cl_all_disconnect(struct mei_device *dev);
void mei_cl_all_wakeup(struct mei_device *dev);
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 70c94a9cd905..7f53597e697a 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -514,10 +514,8 @@ static void mei_hbm_cl_notify(struct mei_device *dev,
struct mei_cl *cl;
cl = mei_hbm_cl_find_by_cmd(dev, cmd);
- if (cl && cl->notify_en) {
- cl->notify_ev = true;
- wake_up_interruptible(&cl->ev_wait);
- }
+ if (cl)
+ mei_cl_notify(cl);
}
/**
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 17b356f26686..b2f2486b3d75 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -651,6 +651,26 @@ out:
}
/**
+ * mei_fasync - asynchronous io support
+ *
+ * @fd: file descriptor
+ * @file: pointer to file structure
+ * @band: band bitmap
+ *
+ * Return: poll mask
+ */
+static int mei_fasync(int fd, struct file *file, int band)
+{
+
+ struct mei_cl *cl = file->private_data;
+
+ if (!mei_cl_is_connected(cl))
+ return POLLERR;
+
+ return fasync_helper(fd, file, band, &cl->ev_async);
+}
+
+/**
* fw_status_show - mei device attribute show method
*
* @device: device pointer
@@ -702,6 +722,7 @@ static const struct file_operations mei_fops = {
.release = mei_release,
.write = mei_write,
.poll = mei_poll,
+ .fasync = mei_fasync,
.llseek = no_llseek
};
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 6f8f5e1e909e..c960aaa538c0 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -236,6 +236,7 @@ struct mei_cl_cb {
* @rx_wait: wait queue for rx completion
* @wait: wait queue for management operation
* @ev_wait: notification wait queue
+ * @ev_async: event async notification
* @status: connection status
* @me_cl: fw client connected
* @host_client_id: host id
@@ -258,6 +259,7 @@ struct mei_cl {
wait_queue_head_t rx_wait;
wait_queue_head_t wait;
wait_queue_head_t ev_wait;
+ struct fasync_struct *ev_async;
int status;
struct mei_me_client *me_cl;
u8 host_client_id;
--
2.4.3
next prev parent reply other threads:[~2015-07-26 6:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-26 6:54 [char-misc-next 0/9 RESEND] mei: support for async event notifications Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 1/9 RESEND] mei: define async notification hbm commands Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 2/9 RESEND] mei: implement async notification hbm messages Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 3/9 RESEND] mei: enable async event notifications only from hbm version 2.0 Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 4/9 RESEND] mei: add mei_cl_notify_request command Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 5/9 RESEND] mei: add a handler that waits for notification on event Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 6/9 RESEND] mei: add async event notification ioctls Tomas Winkler
2015-07-26 6:54 ` [char-misc-next 7/9 RESEND] mei: support polling for event notification Tomas Winkler
2015-07-26 6:54 ` Tomas Winkler [this message]
2015-07-26 6:54 ` [char-misc-next 9/9 RESEND] mei: bus: add and call callback on notify event Tomas Winkler
2015-07-26 17:45 ` [char-misc-next 0/9 RESEND] mei: support for async event notifications Greg Kroah-Hartman
2015-07-27 6:36 ` Winkler, Tomas
2015-08-04 0:18 ` Greg Kroah-Hartman
2015-08-04 10:59 ` Winkler, Tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437893663-2068-9-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®