aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2016-11-08 11:26:08 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-11-10 07:18:02 -0500
commite0cb6b2f878d210441e8ed232e98454ccc7fd812 (patch)
treea91647d2619efa0ac48d57a44585073bbb078542 /drivers/misc
parentfe948dcb2c1223c0da4bc304d87d0253fa06094e (diff)
mei: enable to set the internal flag for client write
Prepare the client write functions to set the internal flag in message header. Carry both blocking and internal modes inside the transmit cb, and call internal bus function __mei_cl_send() with send mode bit mask. The Internal flag should be added only on messages generated by the driver. 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>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/amthif.c2
-rw-r--r--drivers/misc/mei/bus-fixup.c3
-rw-r--r--drivers/misc/mei/bus.c10
-rw-r--r--drivers/misc/mei/client.c6
-rw-r--r--drivers/misc/mei/client.h2
-rw-r--r--drivers/misc/mei/main.c2
-rw-r--r--drivers/misc/mei/mei_dev.h15
7 files changed, 28 insertions, 12 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 7ae89b4a21d5..466afb2611c6 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -144,7 +144,7 @@ int mei_amthif_run_next_cmd(struct mei_device *dev)
144 dev->iamthif_state = MEI_IAMTHIF_WRITING; 144 dev->iamthif_state = MEI_IAMTHIF_WRITING;
145 cl->fp = cb->fp; 145 cl->fp = cb->fp;
146 146
147 ret = mei_cl_write(cl, cb, false); 147 ret = mei_cl_write(cl, cb);
148 if (ret < 0) 148 if (ret < 0)
149 return ret; 149 return ret;
150 150
diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
index e9e6ea3ab73c..db60d57ebda9 100644
--- a/drivers/misc/mei/bus-fixup.c
+++ b/drivers/misc/mei/bus-fixup.c
@@ -162,7 +162,8 @@ static int mei_nfc_if_version(struct mei_cl *cl,
162 162
163 WARN_ON(mutex_is_locked(&bus->device_lock)); 163 WARN_ON(mutex_is_locked(&bus->device_lock));
164 164
165 ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd), 1); 165 ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd),
166 MEI_CL_IO_TX_BLOCKING);
166 if (ret < 0) { 167 if (ret < 0) {
167 dev_err(bus->dev, "Could not send IF version cmd\n"); 168 dev_err(bus->dev, "Could not send IF version cmd\n");
168 return ret; 169 return ret;
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 8a1e813a548d..7c075e9b25e5 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -36,12 +36,12 @@
36 * @cl: host client 36 * @cl: host client
37 * @buf: buffer to send 37 * @buf: buffer to send
38 * @length: buffer length 38 * @length: buffer length
39 * @blocking: wait for write completion 39 * @mode: sending mode
40 * 40 *
41 * Return: written size bytes or < 0 on error 41 * Return: written size bytes or < 0 on error
42 */ 42 */
43ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, 43ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
44 bool blocking) 44 unsigned int mode)
45{ 45{
46 struct mei_device *bus; 46 struct mei_device *bus;
47 struct mei_cl_cb *cb; 47 struct mei_cl_cb *cb;
@@ -80,9 +80,11 @@ ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
80 goto out; 80 goto out;
81 } 81 }
82 82
83 cb->internal = !!(mode & MEI_CL_IO_TX_INTERNAL);
84 cb->blocking = !!(mode & MEI_CL_IO_TX_BLOCKING);
83 memcpy(cb->buf.data, buf, length); 85 memcpy(cb->buf.data, buf, length);
84 86
85 rets = mei_cl_write(cl, cb, blocking); 87 rets = mei_cl_write(cl, cb);
86 88
87out: 89out:
88 mutex_unlock(&bus->device_lock); 90 mutex_unlock(&bus->device_lock);
@@ -188,7 +190,7 @@ ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
188 if (cl == NULL) 190 if (cl == NULL)
189 return -ENODEV; 191 return -ENODEV;
190 192
191 return __mei_cl_send(cl, buf, length, 1); 193 return __mei_cl_send(cl, buf, length, MEI_CL_IO_TX_BLOCKING);
192} 194}
193EXPORT_SYMBOL_GPL(mei_cldev_send); 195EXPORT_SYMBOL_GPL(mei_cldev_send);
194 196
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 6fe02350578d..beb942e6c248 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -1598,18 +1598,17 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1598 * 1598 *
1599 * @cl: host client 1599 * @cl: host client
1600 * @cb: write callback with filled data 1600 * @cb: write callback with filled data
1601 * @blocking: block until completed
1602 * 1601 *
1603 * Return: number of bytes sent on success, <0 on failure. 1602 * Return: number of bytes sent on success, <0 on failure.
1604 */ 1603 */
1605int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) 1604int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
1606{ 1605{
1607 struct mei_device *dev; 1606 struct mei_device *dev;
1608 struct mei_msg_data *buf; 1607 struct mei_msg_data *buf;
1609 struct mei_msg_hdr mei_hdr; 1608 struct mei_msg_hdr mei_hdr;
1610 int size; 1609 int size;
1611 int rets; 1610 int rets;
1612 1611 bool blocking;
1613 1612
1614 if (WARN_ON(!cl || !cl->dev)) 1613 if (WARN_ON(!cl || !cl->dev))
1615 return -ENODEV; 1614 return -ENODEV;
@@ -1621,6 +1620,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
1621 1620
1622 buf = &cb->buf; 1621 buf = &cb->buf;
1623 size = buf->size; 1622 size = buf->size;
1623 blocking = cb->blocking;
1624 1624
1625 cl_dbg(dev, cl, "size=%d\n", size); 1625 cl_dbg(dev, cl, "size=%d\n", size);
1626 1626
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index d2bfabecd882..f2545af9be7b 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -219,7 +219,7 @@ int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
219int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp); 219int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp);
220int mei_cl_irq_read_msg(struct mei_cl *cl, struct mei_msg_hdr *hdr, 220int mei_cl_irq_read_msg(struct mei_cl *cl, struct mei_msg_hdr *hdr,
221 struct mei_cl_cb *cmpl_list); 221 struct mei_cl_cb *cmpl_list);
222int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking); 222int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb);
223int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, 223int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
224 struct mei_cl_cb *cmpl_list); 224 struct mei_cl_cb *cmpl_list);
225 225
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index a1484574cfa8..e1bf54481fd6 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -322,7 +322,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
322 goto out; 322 goto out;
323 } 323 }
324 324
325 rets = mei_cl_write(cl, cb, false); 325 rets = mei_cl_write(cl, cb);
326out: 326out:
327 mutex_unlock(&dev->device_lock); 327 mutex_unlock(&dev->device_lock);
328 return rets; 328 return rets;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 1169fd9e7d02..d50f70b4a05e 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -109,6 +109,17 @@ enum mei_cb_file_ops {
109 MEI_FOP_NOTIFY_STOP, 109 MEI_FOP_NOTIFY_STOP,
110}; 110};
111 111
112/**
113 * enum mei_cl_io_mode - io mode between driver and fw
114 *
115 * @MEI_CL_IO_TX_BLOCKING: send is blocking
116 * @MEI_CL_IO_TX_INTERNAL: internal communication between driver and FW
117 */
118enum mei_cl_io_mode {
119 MEI_CL_IO_TX_BLOCKING = BIT(0),
120 MEI_CL_IO_TX_INTERNAL = BIT(1),
121};
122
112/* 123/*
113 * Intel MEI message data struct 124 * Intel MEI message data struct
114 */ 125 */
@@ -169,6 +180,7 @@ struct mei_cl;
169 * @fp: pointer to file structure 180 * @fp: pointer to file structure
170 * @status: io status of the cb 181 * @status: io status of the cb
171 * @internal: communication between driver and FW flag 182 * @internal: communication between driver and FW flag
183 * @blocking: transmission blocking mode
172 * @completed: the transfer or reception has completed 184 * @completed: the transfer or reception has completed
173 */ 185 */
174struct mei_cl_cb { 186struct mei_cl_cb {
@@ -180,6 +192,7 @@ struct mei_cl_cb {
180 const struct file *fp; 192 const struct file *fp;
181 int status; 193 int status;
182 u32 internal:1; 194 u32 internal:1;
195 u32 blocking:1;
183 u32 completed:1; 196 u32 completed:1;
184}; 197};
185 198
@@ -304,7 +317,7 @@ void mei_cl_bus_rescan(struct mei_device *bus);
304void mei_cl_bus_rescan_work(struct work_struct *work); 317void mei_cl_bus_rescan_work(struct work_struct *work);
305void mei_cl_bus_dev_fixup(struct mei_cl_device *dev); 318void mei_cl_bus_dev_fixup(struct mei_cl_device *dev);
306ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, 319ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
307 bool blocking); 320 unsigned int mode);
308ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); 321ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
309bool mei_cl_bus_rx_event(struct mei_cl *cl); 322bool mei_cl_bus_rx_event(struct mei_cl *cl);
310bool mei_cl_bus_notify_event(struct mei_cl *cl); 323bool mei_cl_bus_notify_event(struct mei_cl *cl);