aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-08-21 07:29:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-24 01:57:48 -0400
commitd880f3294d0576e79dfab4e2cd5a2eb62fe188f0 (patch)
treea36fc7837df60ae8d004524f42c3fd0924c5ee75 /drivers/misc
parent25ca6472b590e87efba314892a76bd5629c8c989 (diff)
mei: add mei_me_cl_by_uuid_id function
When handling dynamic clients there might be a race scenario in which two me clients with the same me address would be linked in the me clients list, therefore we need to search by both uuid and me address. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/amthif.c1
-rw-r--r--drivers/misc/mei/bus.c4
-rw-r--r--drivers/misc/mei/client.c14
-rw-r--r--drivers/misc/mei/client.h4
-rw-r--r--drivers/misc/mei/main.c3
-rw-r--r--drivers/misc/mei/mei_dev.h2
-rw-r--r--drivers/misc/mei/nfc.c6
-rw-r--r--drivers/misc/mei/wd.c1
8 files changed, 26 insertions, 9 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index c1fc6dd8faae..4114758cd1ce 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -83,6 +83,7 @@ int mei_amthif_host_init(struct mei_device *dev)
83 } 83 }
84 84
85 cl->me_client_id = me_cl->client_id; 85 cl->me_client_id = me_cl->client_id;
86 cl->cl_uuid = me_cl->props.protocol_name;
86 87
87 /* Assign iamthif_mtu to the value received from ME */ 88 /* Assign iamthif_mtu to the value received from ME */
88 89
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index c829676c4716..09dad2df7aae 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -147,7 +147,7 @@ static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev,
147 struct mei_cl *cl; 147 struct mei_cl *cl;
148 148
149 list_for_each_entry(cl, &dev->device_list, device_link) { 149 list_for_each_entry(cl, &dev->device_list, device_link) {
150 if (!uuid_le_cmp(uuid, cl->device_uuid)) 150 if (!uuid_le_cmp(uuid, cl->cl_uuid))
151 return cl; 151 return cl;
152 } 152 }
153 153
@@ -242,7 +242,7 @@ static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
242 return -ENODEV; 242 return -ENODEV;
243 243
244 /* Check if we have an ME client device */ 244 /* Check if we have an ME client device */
245 me_cl = mei_me_cl_by_id(dev, cl->me_client_id); 245 me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
246 if (!me_cl) 246 if (!me_cl)
247 return -ENOTTY; 247 return -ENOTTY;
248 248
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 10d0a04f45d6..1a4dafb77205 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -69,6 +69,18 @@ struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
69 return NULL; 69 return NULL;
70} 70}
71 71
72struct mei_me_client *mei_me_cl_by_uuid_id(struct mei_device *dev,
73 const uuid_le *uuid, u8 client_id)
74{
75 struct mei_me_client *me_cl;
76
77 list_for_each_entry(me_cl, &dev->me_clients, list)
78 if (uuid_le_cmp(*uuid, me_cl->props.protocol_name) == 0 &&
79 me_cl->client_id == client_id)
80 return me_cl;
81 return NULL;
82}
83
72/** 84/**
73 * mei_me_cl_remove - remove me client matching uuid and client_id 85 * mei_me_cl_remove - remove me client matching uuid and client_id
74 * 86 *
@@ -753,7 +765,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)
753 cl_dbg(dev, cl, "read is pending.\n"); 765 cl_dbg(dev, cl, "read is pending.\n");
754 return -EBUSY; 766 return -EBUSY;
755 } 767 }
756 me_cl = mei_me_cl_by_id(dev, cl->me_client_id); 768 me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
757 if (!me_cl) { 769 if (!me_cl) {
758 cl_err(dev, cl, "no such me client %d\n", cl->me_client_id); 770 cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
759 return -ENOTTY; 771 return -ENOTTY;
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index 8871a852cfbb..f5d03d622923 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -27,6 +27,10 @@
27struct mei_me_client *mei_me_cl_by_uuid(const struct mei_device *dev, 27struct mei_me_client *mei_me_cl_by_uuid(const struct mei_device *dev,
28 const uuid_le *cuuid); 28 const uuid_le *cuuid);
29struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id); 29struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
30
31struct mei_me_client *mei_me_cl_by_uuid_id(struct mei_device *dev,
32 const uuid_le *uuid, u8 client_id);
33
30void mei_me_cl_remove(struct mei_device *dev, 34void mei_me_cl_remove(struct mei_device *dev,
31 const uuid_le *uuid, u8 client_id); 35 const uuid_le *uuid, u8 client_id);
32 36
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index a65b7cc4a877..957f44aaa97a 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -321,7 +321,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
321 goto out; 321 goto out;
322 } 322 }
323 323
324 me_cl = mei_me_cl_by_id(dev, cl->me_client_id); 324 me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
325 if (!me_cl) { 325 if (!me_cl) {
326 rets = -ENOTTY; 326 rets = -ENOTTY;
327 goto out; 327 goto out;
@@ -459,6 +459,7 @@ static int mei_ioctl_connect_client(struct file *file,
459 } 459 }
460 460
461 cl->me_client_id = me_cl->client_id; 461 cl->me_client_id = me_cl->client_id;
462 cl->cl_uuid = me_cl->props.protocol_name;
462 463
463 dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n", 464 dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
464 cl->me_client_id); 465 cl->me_client_id);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 76d8aa30e90d..9f684b9b3c93 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -212,6 +212,7 @@ struct mei_cl {
212 wait_queue_head_t wait; 212 wait_queue_head_t wait;
213 int status; 213 int status;
214 /* ID of client connected */ 214 /* ID of client connected */
215 uuid_le cl_uuid;
215 u8 host_client_id; 216 u8 host_client_id;
216 u8 me_client_id; 217 u8 me_client_id;
217 u8 mei_flow_ctrl_creds; 218 u8 mei_flow_ctrl_creds;
@@ -223,7 +224,6 @@ struct mei_cl {
223 /* MEI CL bus data */ 224 /* MEI CL bus data */
224 struct mei_cl_device *device; 225 struct mei_cl_device *device;
225 struct list_head device_link; 226 struct list_head device_link;
226 uuid_le device_uuid;
227}; 227};
228 228
229/** struct mei_hw_ops 229/** struct mei_hw_ops
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 964b4c606646..e0e75d429fdf 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -507,12 +507,12 @@ int mei_nfc_host_init(struct mei_device *dev)
507 } 507 }
508 508
509 cl_info->me_client_id = me_cl->client_id; 509 cl_info->me_client_id = me_cl->client_id;
510 cl_info->cl_uuid = me_cl->props.protocol_name;
510 511
511 ret = mei_cl_link(cl_info, MEI_HOST_CLIENT_ID_ANY); 512 ret = mei_cl_link(cl_info, MEI_HOST_CLIENT_ID_ANY);
512 if (ret) 513 if (ret)
513 goto err; 514 goto err;
514 515
515 cl_info->device_uuid = mei_nfc_info_guid;
516 516
517 list_add_tail(&cl_info->device_link, &dev->device_list); 517 list_add_tail(&cl_info->device_link, &dev->device_list);
518 518
@@ -525,14 +525,12 @@ int mei_nfc_host_init(struct mei_device *dev)
525 } 525 }
526 526
527 cl->me_client_id = me_cl->client_id; 527 cl->me_client_id = me_cl->client_id;
528 cl->cl_uuid = me_cl->props.protocol_name;
528 529
529 ret = mei_cl_link(cl, MEI_HOST_CLIENT_ID_ANY); 530 ret = mei_cl_link(cl, MEI_HOST_CLIENT_ID_ANY);
530 if (ret) 531 if (ret)
531 goto err; 532 goto err;
532 533
533 cl->device_uuid = mei_nfc_guid;
534
535
536 list_add_tail(&cl->device_link, &dev->device_list); 534 list_add_tail(&cl->device_link, &dev->device_list);
537 535
538 ndev->req_id = 1; 536 ndev->req_id = 1;
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 8b241eef35d2..40f46e4c2e9c 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -76,6 +76,7 @@ int mei_wd_host_init(struct mei_device *dev)
76 } 76 }
77 77
78 cl->me_client_id = me_cl->client_id; 78 cl->me_client_id = me_cl->client_id;
79 cl->cl_uuid = me_cl->props.protocol_name;
79 80
80 ret = mei_cl_link(cl, MEI_WD_HOST_CLIENT_ID); 81 ret = mei_cl_link(cl, MEI_WD_HOST_CLIENT_ID);
81 82