From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, alan@linux.intel.com,
linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 18/21] mei: abstract host and device readieness
Date: Tue, 8 Jan 2013 23:07:29 +0200 [thread overview]
Message-ID: <1357679252-12958-19-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1357679252-12958-1-git-send-email-tomas.winkler@intel.com>
Add mei_host_set_ready function to enable the device
and is_ready function to query the host and me readiness
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/hw-me.c | 35 ++++++++++++++++++++++++++++++++++-
drivers/misc/mei/init.c | 14 ++++++--------
drivers/misc/mei/interrupt.c | 19 ++++++++++---------
drivers/misc/mei/mei_dev.h | 4 ++++
4 files changed, 54 insertions(+), 18 deletions(-)
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index ed61659..49b558d 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -172,6 +172,39 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable)
dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", hcsr);
}
+/**
+ * mei_host_set_ready - enable device
+ *
+ * @dev - mei device
+ * returns bool
+ */
+
+void mei_host_set_ready(struct mei_device *dev)
+{
+ dev->host_hw_state |= H_IE | H_IG | H_RDY;
+ mei_hcsr_set(dev);
+}
+/**
+ * mei_host_is_ready - check whether the host has turned ready
+ *
+ * @dev - mei device
+ * returns bool
+ */
+bool mei_host_is_ready(struct mei_device *dev)
+{
+ return (dev->host_hw_state & H_RDY) == H_RDY;
+}
+
+/**
+ * mei_me_is_ready - check whether the me has turned ready
+ *
+ * @dev - mei device
+ * returns bool
+ */
+bool mei_me_is_ready(struct mei_device *dev)
+{
+ return (dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA;
+}
/**
* mei_interrupt_quick_handler - The ISR of the MEI device
@@ -290,7 +323,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,
dev->host_hw_state |= H_IG;
mei_hcsr_set(dev);
dev->me_hw_state = mei_mecsr_read(dev);
- if ((dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
+ if (!mei_me_is_ready(dev))
return -EIO;
return 0;
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 5c2054d..d0ee02a 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -131,18 +131,18 @@ int mei_hw_init(struct mei_device *dev)
goto out;
}
- if (!(((dev->host_hw_state & H_RDY) == H_RDY) &&
- ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) {
+ if (!(mei_host_is_ready(dev) && mei_me_is_ready(dev))) {
dev->dev_state = MEI_DEV_DISABLED;
+
dev_dbg(&dev->pdev->dev,
"host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
dev->host_hw_state, dev->me_hw_state);
- if (!(dev->host_hw_state & H_RDY))
- dev_dbg(&dev->pdev->dev, "host turn off H_RDY.\n");
+ if (!mei_host_is_ready(dev))
+ dev_dbg(&dev->pdev->dev, "host is not ready.\n");
- if (!(dev->me_hw_state & ME_RDY_HRA))
- dev_dbg(&dev->pdev->dev, "ME turn off ME_RDY.\n");
+ if (!mei_me_is_ready(dev))
+ dev_dbg(&dev->pdev->dev, "ME is not ready.\n");
dev_err(&dev->pdev->dev, "link layer initialization failed.\n");
ret = -ENODEV;
@@ -159,9 +159,7 @@ int mei_hw_init(struct mei_device *dev)
dev->recvd_msg = false;
dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
dev->host_hw_state, dev->me_hw_state);
- dev_dbg(&dev->pdev->dev, "ME turn on ME_RDY and host turn on H_RDY.\n");
dev_dbg(&dev->pdev->dev, "link layer has been established.\n");
- dev_dbg(&dev->pdev->dev, "MEI start success.\n");
ret = 0;
out:
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index d7e1b79..27374b6 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -700,7 +700,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
dev->me_hw_state = mei_mecsr_read(dev);
/* check if ME wants a reset */
- if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
+ if (!mei_me_is_ready(dev) &&
dev->dev_state != MEI_DEV_RESETING &&
dev->dev_state != MEI_DEV_INITIALIZING) {
dev_dbg(&dev->pdev->dev, "FW not ready.\n");
@@ -711,16 +711,17 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
dev->host_hw_state = mei_hcsr_read(dev);
/* check if we need to start the dev */
- if ((dev->host_hw_state & H_RDY) == 0) {
- if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
+ if (!mei_host_is_ready(dev)) {
+ if (mei_me_is_ready(dev)) {
dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
- dev->host_hw_state |= (H_IE | H_IG | H_RDY);
- mei_hcsr_set(dev);
- dev->dev_state = MEI_DEV_INIT_CLIENTS;
+
+ mei_host_set_ready(dev);
+
dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
- /* link is established
- * start sending messages.
- */
+ /* link is established * start sending messages. */
+
+ dev->dev_state = MEI_DEV_INIT_CLIENTS;
+
mei_hbm_start_req(dev);
mutex_unlock(&dev->device_lock);
return IRQ_HANDLED;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 8692ac8..7b43659 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -396,6 +396,10 @@ void mei_clear_interrupts(struct mei_device *dev);
void mei_enable_interrupts(struct mei_device *dev);
void mei_disable_interrupts(struct mei_device *dev);
+void mei_host_set_ready(struct mei_device *dev);
+bool mei_host_is_ready(struct mei_device *dev);
+bool mei_me_is_ready(struct mei_device *dev);
+
#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d"
--
1.7.4.4
next prev parent reply other threads:[~2013-01-08 21:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 21:07 [char-misc-next 00/21] MEI restructuring Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 01/21] mei: add new hbm.h header to export hbm protocol Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 02/21] mei: move client functions to client.c Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 03/21] mei: fix client functions names Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 04/21] mei: implement mei_cl_connect function Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 05/21] mei: move watchdog prototypes to mei_dev.h from interface.h Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 06/21] mei: rename interface to hw-me Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 07/21] mei: drop read_pending member form struct mei_cl Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 08/21] mei: move me client storage allocation to hbm.c Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 09/21] mei: mei_dev.h - remove prototypes of dropped functions Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 10/21] mei: rename remaining amthi strings to amthif Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 11/21] mei: normalize me host client linking routines Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 12/21] mei: move MEI_IAMTHIF_IDLE to amthif host init function Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 13/21] mei: hw-me.c fix kernel doc Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 14/21] mei: remove write only need_reset member of struct mei_device Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 15/21] mei: remove mei_csr_clear_his prototype Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 16/21] mei: don't use cached value for hcsr in mei_hw_reset Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 17/21] mei: use non cached hcsr for interrupt enablement Tomas Winkler
2013-01-08 21:07 ` Tomas Winkler [this message]
2013-01-08 21:07 ` [char-misc-next 19/21] mei: reenable mei_hcsr_set abstraction Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 20/21] mei: make host csr and me csr internal to hw-me Tomas Winkler
2013-01-08 21:07 ` [char-misc-next 21/21] mei: move work initialization to mei_device_init 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=1357679252-12958-19-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=alan@linux.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®