Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexander Usyskin and committed by
Greg Kroah-Hartman
e0cb6b2f fe948dcb

+28 -12
+1 -1
drivers/misc/mei/amthif.c
··· 144 144 dev->iamthif_state = MEI_IAMTHIF_WRITING; 145 145 cl->fp = cb->fp; 146 146 147 - ret = mei_cl_write(cl, cb, false); 147 + ret = mei_cl_write(cl, cb); 148 148 if (ret < 0) 149 149 return ret; 150 150
+2 -1
drivers/misc/mei/bus-fixup.c
··· 162 162 163 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 167 if (ret < 0) { 167 168 dev_err(bus->dev, "Could not send IF version cmd\n"); 168 169 return ret;
+6 -4
drivers/misc/mei/bus.c
··· 36 36 * @cl: host client 37 37 * @buf: buffer to send 38 38 * @length: buffer length 39 - * @blocking: wait for write completion 39 + * @mode: sending mode 40 40 * 41 41 * Return: written size bytes or < 0 on error 42 42 */ 43 43 ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, 44 - bool blocking) 44 + unsigned int mode) 45 45 { 46 46 struct mei_device *bus; 47 47 struct mei_cl_cb *cb; ··· 80 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 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 87 89 out: 88 90 mutex_unlock(&bus->device_lock); ··· 190 188 if (cl == NULL) 191 189 return -ENODEV; 192 190 193 - return __mei_cl_send(cl, buf, length, 1); 191 + return __mei_cl_send(cl, buf, length, MEI_CL_IO_TX_BLOCKING); 194 192 } 195 193 EXPORT_SYMBOL_GPL(mei_cldev_send); 196 194
+3 -3
drivers/misc/mei/client.c
··· 1598 1598 * 1599 1599 * @cl: host client 1600 1600 * @cb: write callback with filled data 1601 - * @blocking: block until completed 1602 1601 * 1603 1602 * Return: number of bytes sent on success, <0 on failure. 1604 1603 */ 1605 - int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) 1604 + int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) 1606 1605 { 1607 1606 struct mei_device *dev; 1608 1607 struct mei_msg_data *buf; 1609 1608 struct mei_msg_hdr mei_hdr; 1610 1609 int size; 1611 1610 int rets; 1612 - 1611 + bool blocking; 1613 1612 1614 1613 if (WARN_ON(!cl || !cl->dev)) 1615 1614 return -ENODEV; ··· 1620 1621 1621 1622 buf = &cb->buf; 1622 1623 size = buf->size; 1624 + blocking = cb->blocking; 1623 1625 1624 1626 cl_dbg(dev, cl, "size=%d\n", size); 1625 1627
+1 -1
drivers/misc/mei/client.h
··· 219 219 int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp); 220 220 int mei_cl_irq_read_msg(struct mei_cl *cl, struct mei_msg_hdr *hdr, 221 221 struct mei_cl_cb *cmpl_list); 222 - int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking); 222 + int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb); 223 223 int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, 224 224 struct mei_cl_cb *cmpl_list); 225 225
+1 -1
drivers/misc/mei/main.c
··· 322 322 goto out; 323 323 } 324 324 325 - rets = mei_cl_write(cl, cb, false); 325 + rets = mei_cl_write(cl, cb); 326 326 out: 327 327 mutex_unlock(&dev->device_lock); 328 328 return rets;
+14 -1
drivers/misc/mei/mei_dev.h
··· 109 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 + */ 118 + enum 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 124 * Intel MEI message data struct 114 125 */ ··· 180 169 * @fp: pointer to file structure 181 170 * @status: io status of the cb 182 171 * @internal: communication between driver and FW flag 172 + * @blocking: transmission blocking mode 183 173 * @completed: the transfer or reception has completed 184 174 */ 185 175 struct mei_cl_cb { ··· 192 180 const struct file *fp; 193 181 int status; 194 182 u32 internal:1; 183 + u32 blocking:1; 195 184 u32 completed:1; 196 185 }; 197 186 ··· 317 304 void mei_cl_bus_rescan_work(struct work_struct *work); 318 305 void mei_cl_bus_dev_fixup(struct mei_cl_device *dev); 319 306 ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, 320 - bool blocking); 307 + unsigned int mode); 321 308 ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); 322 309 bool mei_cl_bus_rx_event(struct mei_cl *cl); 323 310 bool mei_cl_bus_notify_event(struct mei_cl *cl);