mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
	linux-kernel@vger.kernel.org,
	Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 10/12] mei: enqueue consecutive reads
Date: Fri, 22 Jul 2016 15:56:27 +0300	[thread overview]
Message-ID: <1469192189-29042-11-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1469192189-29042-1-git-send-email-tomas.winkler@intel.com>

From: Alexander Usyskin <alexander.usyskin@intel.com>

The FW supports only one pending read per host client, in order to
support  issuing of consecutive reads the driver  queues read requests
internally and send them to the firmware after pending one has
completed.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/interrupt.c |  3 +++
 drivers/misc/mei/main.c      | 39 +++++++++++++++++++--------------------
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 36382d782e20..bf745e03f21e 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -209,6 +209,9 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
 	int slots;
 	int ret;
 
+	if (!list_empty(&cl->rd_pending))
+		return 0;
+
 	msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
 	slots = mei_hbuf_empty_slots(dev);
 
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index d698ba32357c..650061b6ab9b 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -139,9 +139,8 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 	struct mei_cl *cl = file->private_data;
 	struct mei_device *dev;
 	struct mei_cl_cb *cb = NULL;
+	bool nonblock = !!(file->f_flags & O_NONBLOCK);
 	int rets;
-	int err;
-
 
 	if (WARN_ON(!cl || !cl->dev))
 		return -ENODEV;
@@ -177,25 +176,29 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 	if (*offset > 0)
 		*offset = 0;
 
-	err = mei_cl_read_start(cl, length, file);
-	if (err && err != -EBUSY) {
-		cl_dbg(dev, cl, "mei start read failure status = %d\n", err);
-		rets = err;
+	rets = mei_cl_read_start(cl, length, file);
+	if (rets && rets != -EBUSY) {
+		cl_dbg(dev, cl, "mei start read failure status = %d\n", rets);
 		goto out;
 	}
 
-	/* synchronized under device mutex */
-	if (!waitqueue_active(&cl->rx_wait)) {
-		if (file->f_flags & O_NONBLOCK) {
-			rets = -EAGAIN;
-			goto out;
-		}
+	if (nonblock) {
+		rets = -EAGAIN;
+		goto out;
+	}
+
+	if (rets == -EBUSY &&
+	    !mei_cl_enqueue_ctrl_wr_cb(cl, length, MEI_FOP_READ, file)) {
+		rets = -ENOMEM;
+		goto out;
+	}
 
+	do {
 		mutex_unlock(&dev->device_lock);
 
 		if (wait_event_interruptible(cl->rx_wait,
-				(!list_empty(&cl->rd_completed)) ||
-				(!mei_cl_is_connected(cl)))) {
+					     (!list_empty(&cl->rd_completed)) ||
+					     (!mei_cl_is_connected(cl)))) {
 
 			if (signal_pending(current))
 				return -EINTR;
@@ -207,13 +210,9 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 			rets = -ENODEV;
 			goto out;
 		}
-	}
 
-	cb = mei_cl_read_cb(cl, file);
-	if (!cb) {
-		rets = 0;
-		goto out;
-	}
+		cb = mei_cl_read_cb(cl, file);
+	} while (!cb);
 
 copy_buffer:
 	/* now copy the data to user space */
-- 
2.7.4

  parent reply	other threads:[~2016-07-22 12:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 12:56 [char-misc-next 00/12] mei: rx enhancements Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 01/12] mei: move read cb to complete queue if not connected Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 02/12] mei: add file pointer to the host client structure Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 03/12] mei: add read callback on demand for fixed_address clients Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 04/12] mei: amthif: drop mei_clear_lists function Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 05/12] mei: drop redundant krealloc and checks in irq read Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 06/12] mei: prepare read cb for fixed address clients on the receive path only Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 07/12] mei: rx flow control counter Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 08/12] mei: use consistent naming for TX control flow credits Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 09/12] mei: add wrapper for queuing control commands Tomas Winkler
2016-07-22 12:56 ` Tomas Winkler [this message]
2016-07-22 12:56 ` [char-misc-next 11/12] mei: amthif: drop mei_amthif_read Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 12/12] mei: drop unused file transaction states Tomas Winkler
2016-07-24 22:52 ` [char-misc-next 00/12] mei: rx enhancements Winkler, Tomas
2016-07-24 23:28   ` Greg Kroah-Hartman
2016-07-25 21:49     ` Winkler, Tomas
2016-08-29 21:27       ` Winkler, Tomas
2016-08-30  6:11         ` 'Greg Kroah-Hartman'

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=1469192189-29042-11-git-send-email-tomas.winkler@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=alexander.usyskin@intel.com \
    --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®