mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 3/7] mei: push credentials inside the irq write handler
Date: Mon, 16 Sep 2013 23:44:44 +0300	[thread overview]
Message-ID: <1379364288-16374-4-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1379364288-16374-1-git-send-email-tomas.winkler@intel.com>

this eventually allows as use a single write queue
both for control and data messages and removing possible
race

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/amthif.c    |  9 +++++++++
 drivers/misc/mei/client.c    | 30 +++++++++++++++++++++++++-----
 drivers/misc/mei/interrupt.c |  5 -----
 3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index e4a4e2e..226c3f3 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -461,6 +461,15 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
 	u32 msg_slots = mei_data2slots(len);
 	int rets;
 
+	rets = mei_cl_flow_ctrl_creds(cl);
+	if (rets < 0)
+		return rets;
+
+	if (rets == 0) {
+		cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
+		return 0;
+	}
+
 	mei_hdr.host_addr = cl->host_client_id;
 	mei_hdr.me_addr = cl->me_client_id;
 	mei_hdr.reserved = 0;
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index c59c8a2..88bcde4 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -696,12 +696,33 @@ err:
 int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
 				     s32 *slots, struct mei_cl_cb *cmpl_list)
 {
-	struct mei_device *dev = cl->dev;
+	struct mei_device *dev;
+	struct mei_msg_data *buf;
 	struct mei_msg_hdr mei_hdr;
-	size_t len = cb->request_buffer.size - cb->buf_idx;
-	u32 msg_slots = mei_data2slots(len);
+	size_t len;
+	u32 msg_slots;
 	int rets;
 
+
+	if (WARN_ON(!cl || !cl->dev))
+		return -ENODEV;
+
+	dev = cl->dev;
+
+	buf = &cb->request_buffer;
+
+	rets = mei_cl_flow_ctrl_creds(cl);
+	if (rets < 0)
+		return rets;
+
+	if (rets == 0) {
+		cl_dbg(dev, cl,	"No flow control credentials: not sending.\n");
+		return 0;
+	}
+
+	len = buf->size - cb->buf_idx;
+	msg_slots = mei_data2slots(len);
+
 	mei_hdr.host_addr = cl->host_client_id;
 	mei_hdr.me_addr = cl->me_client_id;
 	mei_hdr.reserved = 0;
@@ -724,8 +745,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
 			cb->request_buffer.size, cb->buf_idx);
 
 	*slots -=  msg_slots;
-	rets = mei_write_message(dev, &mei_hdr,
-			cb->request_buffer.data + cb->buf_idx);
+	rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx);
 	if (rets) {
 		cl->status = rets;
 		list_move_tail(&cb->list, &cmpl_list->list);
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index e4bb9ae..7a95c07 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -513,11 +513,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
 		cl = cb->cl;
 		if (cl == NULL)
 			continue;
-		if (mei_cl_flow_ctrl_creds(cl) <= 0) {
-			cl_dbg(dev, cl, "No flow control credentials, not sending.\n");
-			continue;
-		}
-
 		if (cl == &dev->iamthif_cl)
 			ret = mei_amthif_irq_write_complete(cl, cb,
 						&slots, cmpl_list);
-- 
1.8.3.1


  parent reply	other threads:[~2013-09-16 20:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16 20:44 [char-misc-next 0/7] mei minor fixes and cleanups Tomas Winkler
2013-09-16 20:44 ` [char-misc-next 1/7] mei: fix function names in debug prints Tomas Winkler
2013-09-26 15:40   ` Greg KH
2013-09-16 20:44 ` [char-misc-next 2/7] mei: propagate error from write routines instead of ENODEV Tomas Winkler
2013-09-16 20:44 ` Tomas Winkler [this message]
2013-09-16 20:44 ` [char-misc-next 4/7] mei: mei_cl_unlink: no need to loop over dev list Tomas Winkler
2013-09-16 20:44 ` [char-misc-next 5/7] mei: simplify mei_open error handling Tomas Winkler
2013-09-16 20:44 ` [char-misc-next 6/7] mei: revamp open handler counts Tomas Winkler
2013-09-16 20:44 ` [char-misc-next 7/7] mei: amthif: mei_amthif_host_init: propagate errors from called functions Tomas Winkler

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=1379364288-16374-4-git-send-email-tomas.winkler@intel.com \
    --to=tomas.winkler@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®