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 12/14] mei: extract supported features from the hbm version
Date: Thu, 21 Aug 2014 14:29:21 +0300	[thread overview]
Message-ID: <1408620563-25834-12-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1408620563-25834-1-git-send-email-tomas.winkler@intel.com>

extract supported hbm features and commands from the hbm version

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/hbm.c     | 25 ++++++++++++++++++++++++-
 drivers/misc/mei/hw-me.c   |  6 +-----
 drivers/misc/mei/mei_dev.h |  4 ++++
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 280befc..9fc051b 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -372,7 +372,8 @@ static int mei_hbm_prop_req(struct mei_device *dev)
  * @dev: the device structure
  * @pg_cmd: the pg command code
  *
- * This function returns -EIO on write failure
+ * returns -EIO on write failure
+ *         -EOPNOTSUPP if the operation is not supported by the protocol
  */
 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
 {
@@ -381,6 +382,9 @@ int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
 	const size_t len = sizeof(struct hbm_power_gate);
 	int ret;
 
+	if (!dev->hbm_f_pg_supported)
+		return -EOPNOTSUPP;
+
 	mei_hbm_hdr(mei_hdr, len);
 
 	req = (struct hbm_power_gate *)dev->wr_msg.data;
@@ -660,6 +664,23 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
 	return 0;
 }
 
+/**
+ * mei_hbm_config_features: check what hbm features and commands
+ *        are supported by the fw
+ *
+ * @dev: the device structure
+ */
+static void mei_hbm_config_features(struct mei_device *dev)
+{
+	/* Power Gating Isolation Support */
+	dev->hbm_f_pg_supported = 0;
+	if (dev->version.major_version > HBM_MAJOR_VERSION_PGI)
+		dev->hbm_f_pg_supported = 1;
+
+	if (dev->version.major_version == HBM_MAJOR_VERSION_PGI &&
+	    dev->version.minor_version >= HBM_MINOR_VERSION_PGI)
+		dev->hbm_f_pg_supported = 1;
+}
 
 /**
  * mei_hbm_version_is_supported - checks whether the driver can
@@ -743,6 +764,8 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
 			break;
 		}
 
+		mei_hbm_config_features(dev);
+
 		if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
 		    dev->hbm_state != MEI_HBM_STARTING) {
 			dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index caf0da3..498bd42 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -574,11 +574,7 @@ static bool mei_me_pg_is_enabled(struct mei_device *dev)
 	if ((reg & ME_PGIC_HRA) == 0)
 		goto notsupported;
 
-	if (dev->version.major_version < HBM_MAJOR_VERSION_PGI)
-		goto notsupported;
-
-	if (dev->version.major_version == HBM_MAJOR_VERSION_PGI &&
-	    dev->version.minor_version < HBM_MINOR_VERSION_PGI)
+	if (!dev->hbm_f_pg_supported)
 		goto notsupported;
 
 	return true;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 79124ae..719edee 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -402,6 +402,9 @@ struct mei_cfg {
  *
  * @reset_count - limits the number of consecutive resets
  * @hbm_state - state of host bus message protocol
+ *
+ * @hbm_f_pg_supported - hbm feature pgi protocol
+ *
  * @pg_event - power gating event
  * @mem_addr - mem mapped base register address
 
@@ -476,6 +479,7 @@ struct mei_device {
 	} wr_msg;
 
 	struct hbm_version version;
+	unsigned int hbm_f_pg_supported:1;
 
 	struct list_head me_clients;
 	DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
-- 
1.9.3


  parent reply	other threads:[~2014-08-21 11:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21 11:29 [char-misc-next 01/14] mei: use consistently me_addr in the hbm structures Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 02/14] mei: use wrapper for simple hbm client message Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 03/14] mei: me_client lookup function to return me_client object Tomas Winkler
2014-08-21 12:32   ` Josh Boyer
2014-08-21 13:14     ` Winkler, Tomas
2014-08-21 11:29 ` [char-misc-next 04/14] mei: use list for me clients book keeping Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 05/14] mei: add me client remove functions Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 06/14] mei: add mei_me_cl_by_uuid_id function Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 07/14] mei: add hbm commands return status values Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 08/14] mei: use disconnect name consistently Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 09/14] mei: revamp connect and disconnect response handling Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 10/14] mei: wait for hbm start non-interruptible Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 11/14] mei: simplify handling of hbm client events Tomas Winkler
2014-08-21 11:29 ` Tomas Winkler [this message]
2014-08-21 11:29 ` [char-misc-next 13/14] mei: enable adding more IOCTL handlers Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 14/14] mei: use connect_data on the stack 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=1408620563-25834-12-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®