aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2016-02-07 16:35:38 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-07 17:47:20 -0500
commitf4e06246183f187d1327fdba18a797eb091a7d03 (patch)
tree652e7e81d6983ac57152b70ad983b6a68941fff3
parent06ee536bcb15ca12868289467762130fa0a426f3 (diff)
mei: fixed address clients for the new platforms
Enable by default connection to fixed address clients from user-space for skylake and newer platform. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/debugfs.c31
-rw-r--r--drivers/misc/mei/hbm.c4
-rw-r--r--drivers/misc/mei/hw.h6
-rw-r--r--drivers/misc/mei/main.c18
-rw-r--r--drivers/misc/mei/mei_dev.h4
5 files changed, 57 insertions, 6 deletions
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 6bdd75424fe8..8ad406315741 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -176,6 +176,8 @@ static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf,
176 dev->hbm_f_dot_supported); 176 dev->hbm_f_dot_supported);
177 pos += scnprintf(buf + pos, bufsz - pos, "\tEV: %01d\n", 177 pos += scnprintf(buf + pos, bufsz - pos, "\tEV: %01d\n",
178 dev->hbm_f_ev_supported); 178 dev->hbm_f_ev_supported);
179 pos += scnprintf(buf + pos, bufsz - pos, "\tFA: %01d\n",
180 dev->hbm_f_fa_supported);
179 } 181 }
180 182
181 pos += scnprintf(buf + pos, bufsz - pos, "pg: %s, %s\n", 183 pos += scnprintf(buf + pos, bufsz - pos, "pg: %s, %s\n",
@@ -191,6 +193,30 @@ static const struct file_operations mei_dbgfs_fops_devstate = {
191 .llseek = generic_file_llseek, 193 .llseek = generic_file_llseek,
192}; 194};
193 195
196static ssize_t mei_dbgfs_write_allow_fa(struct file *file,
197 const char __user *user_buf,
198 size_t count, loff_t *ppos)
199{
200 struct mei_device *dev;
201 int ret;
202
203 dev = container_of(file->private_data,
204 struct mei_device, allow_fixed_address);
205
206 ret = debugfs_write_file_bool(file, user_buf, count, ppos);
207 if (ret < 0)
208 return ret;
209 dev->override_fixed_address = true;
210 return ret;
211}
212
213static const struct file_operations mei_dbgfs_fops_allow_fa = {
214 .open = simple_open,
215 .read = debugfs_read_file_bool,
216 .write = mei_dbgfs_write_allow_fa,
217 .llseek = generic_file_llseek,
218};
219
194/** 220/**
195 * mei_dbgfs_deregister - Remove the debugfs files and directories 221 * mei_dbgfs_deregister - Remove the debugfs files and directories
196 * 222 *
@@ -240,8 +266,9 @@ int mei_dbgfs_register(struct mei_device *dev, const char *name)
240 dev_err(dev->dev, "devstate: registration failed\n"); 266 dev_err(dev->dev, "devstate: registration failed\n");
241 goto err; 267 goto err;
242 } 268 }
243 f = debugfs_create_bool("allow_fixed_address", S_IRUSR | S_IWUSR, dir, 269 f = debugfs_create_file("allow_fixed_address", S_IRUSR | S_IWUSR, dir,
244 &dev->allow_fixed_address); 270 &dev->allow_fixed_address,
271 &mei_dbgfs_fops_allow_fa);
245 if (!f) { 272 if (!f) {
246 dev_err(dev->dev, "allow_fixed_address: registration failed\n"); 273 dev_err(dev->dev, "allow_fixed_address: registration failed\n");
247 goto err; 274 goto err;
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index e7b7aad0999b..3915b8e8d0f1 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -979,6 +979,10 @@ static void mei_hbm_config_features(struct mei_device *dev)
979 /* Notification Event Support */ 979 /* Notification Event Support */
980 if (dev->version.major_version >= HBM_MAJOR_VERSION_EV) 980 if (dev->version.major_version >= HBM_MAJOR_VERSION_EV)
981 dev->hbm_f_ev_supported = 1; 981 dev->hbm_f_ev_supported = 1;
982
983 /* Fixed Address Client Support */
984 if (dev->version.major_version >= HBM_MAJOR_VERSION_FA)
985 dev->hbm_f_fa_supported = 1;
982} 986}
983 987
984/** 988/**
diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h
index 4c5d6cfd79b4..459ad596df66 100644
--- a/drivers/misc/mei/hw.h
+++ b/drivers/misc/mei/hw.h
@@ -64,6 +64,12 @@
64#define HBM_MINOR_VERSION_EV 0 64#define HBM_MINOR_VERSION_EV 0
65#define HBM_MAJOR_VERSION_EV 2 65#define HBM_MAJOR_VERSION_EV 2
66 66
67/*
68 * MEI version with fixed address client support
69 */
70#define HBM_MINOR_VERSION_FA 0
71#define HBM_MAJOR_VERSION_FA 2
72
67/* Host bus message command opcode */ 73/* Host bus message command opcode */
68#define MEI_HBM_CMD_OP_MSK 0x7f 74#define MEI_HBM_CMD_OP_MSK 0x7f
69/* Host bus message command RESPONSE */ 75/* Host bus message command RESPONSE */
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index f1fdd65e9678..58fa2c83ee39 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -369,12 +369,22 @@ static int mei_ioctl_connect_client(struct file *file,
369 369
370 /* find ME client we're trying to connect to */ 370 /* find ME client we're trying to connect to */
371 me_cl = mei_me_cl_by_uuid(dev, &data->in_client_uuid); 371 me_cl = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
372 if (!me_cl || 372 if (!me_cl) {
373 (me_cl->props.fixed_address && !dev->allow_fixed_address)) {
374 dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n", 373 dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n",
375 &data->in_client_uuid); 374 &data->in_client_uuid);
376 mei_me_cl_put(me_cl); 375 rets = -ENOTTY;
377 return -ENOTTY; 376 goto end;
377 }
378
379 if (me_cl->props.fixed_address) {
380 bool forbidden = dev->override_fixed_address ?
381 !dev->allow_fixed_address : !dev->hbm_f_fa_supported;
382 if (forbidden) {
383 dev_dbg(dev->dev, "Connection forbidden to FW Client UUID = %pUl\n",
384 &data->in_client_uuid);
385 rets = -ENOTTY;
386 goto end;
387 }
378 } 388 }
379 389
380 dev_dbg(dev->dev, "Connect to FW Client ID = %d\n", 390 dev_dbg(dev->dev, "Connect to FW Client ID = %d\n",
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 70c4da015401..6d97f3335e22 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -396,6 +396,7 @@ const char *mei_pg_state_str(enum mei_pg_state state);
396 * @hbm_f_dc_supported : hbm feature dynamic clients 396 * @hbm_f_dc_supported : hbm feature dynamic clients
397 * @hbm_f_dot_supported : hbm feature disconnect on timeout 397 * @hbm_f_dot_supported : hbm feature disconnect on timeout
398 * @hbm_f_ev_supported : hbm feature event notification 398 * @hbm_f_ev_supported : hbm feature event notification
399 * @hbm_f_fa_supported : hbm feature fixed address client
399 * 400 *
400 * @me_clients_rwsem: rw lock over me_clients list 401 * @me_clients_rwsem: rw lock over me_clients list
401 * @me_clients : list of FW clients 402 * @me_clients : list of FW clients
@@ -404,6 +405,7 @@ const char *mei_pg_state_str(enum mei_pg_state state);
404 * @me_client_index : last FW client index in enumeration 405 * @me_client_index : last FW client index in enumeration
405 * 406 *
406 * @allow_fixed_address: allow user space to connect a fixed client 407 * @allow_fixed_address: allow user space to connect a fixed client
408 * @override_fixed_address: force allow fixed address behavior
407 * 409 *
408 * @amthif_cmd_list : amthif list for cmd waiting 410 * @amthif_cmd_list : amthif list for cmd waiting
409 * @iamthif_fp : file for current amthif operation 411 * @iamthif_fp : file for current amthif operation
@@ -483,6 +485,7 @@ struct mei_device {
483 unsigned int hbm_f_dc_supported:1; 485 unsigned int hbm_f_dc_supported:1;
484 unsigned int hbm_f_dot_supported:1; 486 unsigned int hbm_f_dot_supported:1;
485 unsigned int hbm_f_ev_supported:1; 487 unsigned int hbm_f_ev_supported:1;
488 unsigned int hbm_f_fa_supported:1;
486 489
487 struct rw_semaphore me_clients_rwsem; 490 struct rw_semaphore me_clients_rwsem;
488 struct list_head me_clients; 491 struct list_head me_clients;
@@ -491,6 +494,7 @@ struct mei_device {
491 unsigned long me_client_index; 494 unsigned long me_client_index;
492 495
493 bool allow_fixed_address; 496 bool allow_fixed_address;
497 bool override_fixed_address;
494 498
495 /* amthif list for cmd waiting */ 499 /* amthif list for cmd waiting */
496 struct mei_cl_cb amthif_cmd_list; 500 struct mei_cl_cb amthif_cmd_list;