Skip to content

Commit

Permalink
mei: bus: add send and recv api with timeout
Browse files Browse the repository at this point in the history
Add variation of the send and recv functions on bus
that define timeout.
Caller can use such functions in flow that can stuck
to bail out and not to put down the whole system.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20231011110157.247552-2-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
ausyskin authored and gregkh committed Oct 18, 2023
1 parent 931d8c0 commit cf43972
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
88 changes: 86 additions & 2 deletions drivers/misc/mei/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag,
}

/**
* mei_cldev_send_vtag - me device send with vtag (write)
* mei_cldev_send_vtag - me device send with vtag (write)
*
* @cldev: me client device
* @buf: buffer to send
Expand All @@ -278,6 +278,29 @@ ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
}
EXPORT_SYMBOL_GPL(mei_cldev_send_vtag);

/**
* mei_cldev_send_vtag_timeout - me device send with vtag and timeout (write)
*
* @cldev: me client device
* @buf: buffer to send
* @length: buffer length
* @vtag: virtual tag
* @timeout: send timeout in milliseconds, 0 for infinite timeout
*
* Return:
* * written size in bytes
* * < 0 on error
*/

ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf,
size_t length, u8 vtag, unsigned long timeout)
{
struct mei_cl *cl = cldev->cl;

return __mei_cl_send_timeout(cl, buf, length, vtag, MEI_CL_IO_TX_BLOCKING, timeout);
}
EXPORT_SYMBOL_GPL(mei_cldev_send_vtag_timeout);

/**
* mei_cldev_recv_vtag - client receive with vtag (read)
*
Expand Down Expand Up @@ -323,7 +346,49 @@ ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf,
EXPORT_SYMBOL_GPL(mei_cldev_recv_nonblock_vtag);

/**
* mei_cldev_send - me device send (write)
* mei_cldev_recv_timeout - client receive with timeout (read)
*
* @cldev: me client device
* @buf: buffer to receive
* @length: buffer length
* @timeout: send timeout in milliseconds, 0 for infinite timeout
*
* Return:
* * read size in bytes
* * < 0 on error
*/
ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length,
unsigned long timeout)
{
return mei_cldev_recv_vtag_timeout(cldev, buf, length, NULL, timeout);
}
EXPORT_SYMBOL_GPL(mei_cldev_recv_timeout);

/**
* mei_cldev_recv_vtag_timeout - client receive with vtag (read)
*
* @cldev: me client device
* @buf: buffer to receive
* @length: buffer length
* @vtag: virtual tag
* @timeout: recv timeout in milliseconds, 0 for infinite timeout
*
* Return:
* * read size in bytes
* * < 0 on error
*/

ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length,
u8 *vtag, unsigned long timeout)
{
struct mei_cl *cl = cldev->cl;

return __mei_cl_recv(cl, buf, length, vtag, 0, timeout);
}
EXPORT_SYMBOL_GPL(mei_cldev_recv_vtag_timeout);

/**
* mei_cldev_send - me device send (write)
*
* @cldev: me client device
* @buf: buffer to send
Expand All @@ -339,6 +404,25 @@ ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length
}
EXPORT_SYMBOL_GPL(mei_cldev_send);

/**
* mei_cldev_send_timeout - me device send with timeout (write)
*
* @cldev: me client device
* @buf: buffer to send
* @length: buffer length
* @timeout: send timeout in milliseconds, 0 for infinite timeout
*
* Return:
* * written size in bytes
* * < 0 on error
*/
ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf, size_t length,
unsigned long timeout)
{
return mei_cldev_send_vtag_timeout(cldev, buf, length, 0, timeout);
}
EXPORT_SYMBOL_GPL(mei_cldev_send_timeout);

/**
* mei_cldev_recv - client receive (read)
*
Expand Down
8 changes: 8 additions & 0 deletions include/linux/mei_cl_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,23 @@ void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv);

ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf,
size_t length);
ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf,
size_t length, unsigned long timeout);
ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length);
ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf,
size_t length);
ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length,
unsigned long timeout);
ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
size_t length, u8 vtag);
ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf,
size_t length, u8 vtag, unsigned long timeout);
ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length,
u8 *vtag);
ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf,
size_t length, u8 *vtag);
ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length,
u8 *vtag, unsigned long timeout);

int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb);
int mei_cldev_register_notif_cb(struct mei_cl_device *cldev,
Expand Down

0 comments on commit cf43972

Please sign in to comment.