rpmsg updates for v4.16
This fixes a few issues found in the SMD and GLINK drivers and corrects the handling of SMD channels that are found in an (previously) unexpected state. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJaeJV5AAoJEAsfOT8Nma3FN8YP/1UjlQmor7yTeWUg37nordmy ELjpNdjhBI6570XbeUdtBLi5LZLdYxkAxqt2J67YdnBkyL+EedlYS3tto7Rupo0e P/kLokPJ6I+6FxwKftBi27mt8uyNdIx2nXXof2QhnjtVvXChoOj4e3BEi9KTfuMk 1LPOjldIXHN8ORibcYT5beEcyhZKdOJIsgC5qVsxJ27sLtFPVT9YHpSVVUPZIqO8 EAmSMUqzwCOaiOoEztl29izobYfBH2zR1wvLkq6TWyJXT9uhzkMuyBALbEzwzdBz pgOm1YadEL8rHoSc2TI1sOGAfsQLxHN2h2/QwSeMeRGI1bF7w1EEmjlTKJkDdUug +1om6t8XL08oodrCnkltSF2GGhVHaNOkdm0+sYySsWr6fPDAGO8rd4SimzMr1+9J xIhOBeFfj4Q1xlreVgvvGPlJu1UBaJO9xK8bNShNy3irRLLRKObIAy9RkKfVD+qq sW7xjjsDZ94rSSVGq7vs041ozBZKwa67YBn3eRuZvRHJqKyfVVIGduNx5Ld28qJJ 0Au8a4+g7fxXA0NdxYhwmHGOVEi7pb39U4aREzlJjy4fw1dGlTaEOCfjTXG2DRhs TOuCpn2Rr9fbWjDDXUUEVQCNl8R3IoQfqUDF1VyXdPrGVeDtQvFgn9rlQFPZirt6 b184EJEuQCylkMTRqwV3 =J7N0 -----END PGP SIGNATURE----- Merge tag 'rpmsg-v4.16' of git://github.com/andersson/remoteproc Pull rpmsg updates from Bjorn Andersson: "This fixes a few issues found in the SMD and GLINK drivers and corrects the handling of SMD channels that are found in an (previously) unexpected state" * tag 'rpmsg-v4.16' of git://github.com/andersson/remoteproc: rpmsg: smd: Fix double unlock in __qcom_smd_send() rpmsg: glink: Fix missing mutex_init() in qcom_glink_alloc_channel() rpmsg: smd: Don't hold the tx lock during wait rpmsg: smd: Fail send on a closed channel rpmsg: smd: Wake up all waiters rpmsg: smd: Create device for all channels rpmsg: smd: Perform handshake during open rpmsg: glink: smem: Ensure ordering during tx drivers: rpmsg: remove duplicate includes remoteproc: qcom: Use PTR_ERR_OR_ZERO() in glink prob
This commit is contained in:
Коммит
67fb3b92b0
|
@ -57,7 +57,7 @@ static int glink_subdev_probe(struct rproc_subdev *subdev)
|
|||
|
||||
glink->edge = qcom_glink_smem_register(glink->dev, glink->node);
|
||||
|
||||
return IS_ERR(glink->edge) ? PTR_ERR(glink->edge) : 0;
|
||||
return PTR_ERR_OR_ZERO(glink->edge);
|
||||
}
|
||||
|
||||
static void glink_subdev_remove(struct rproc_subdev *subdev)
|
||||
|
|
|
@ -221,6 +221,7 @@ static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink,
|
|||
/* Setup glink internal glink_channel data */
|
||||
spin_lock_init(&channel->recv_lock);
|
||||
spin_lock_init(&channel->intent_lock);
|
||||
mutex_init(&channel->intent_req_lock);
|
||||
|
||||
channel->glink = glink;
|
||||
channel->name = kstrdup(name, GFP_KERNEL);
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <linux/workqueue.h>
|
||||
#include <linux/list.h>
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/rpmsg.h>
|
||||
#include <linux/rpmsg/qcom_glink.h>
|
||||
|
||||
#include "qcom_glink_native.h"
|
||||
|
@ -185,6 +183,9 @@ static void glink_smem_tx_write(struct qcom_glink_pipe *glink_pipe,
|
|||
if (head >= pipe->native.length)
|
||||
head -= pipe->native.length;
|
||||
|
||||
/* Ensure ordering of fifo and head update */
|
||||
wmb();
|
||||
|
||||
*pipe->head = cpu_to_le32(head);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ struct qcom_smd_channel {
|
|||
char *name;
|
||||
enum smd_channel_state state;
|
||||
enum smd_channel_state remote_state;
|
||||
wait_queue_head_t state_change_event;
|
||||
|
||||
struct smd_channel_info_pair *info;
|
||||
struct smd_channel_info_word_pair *info_word;
|
||||
|
@ -570,13 +571,15 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel)
|
|||
if (remote_state != channel->remote_state) {
|
||||
channel->remote_state = remote_state;
|
||||
need_state_scan = true;
|
||||
|
||||
wake_up_interruptible_all(&channel->state_change_event);
|
||||
}
|
||||
/* Indicate that we have seen any state change */
|
||||
SET_RX_CHANNEL_FLAG(channel, fSTATE, 0);
|
||||
|
||||
/* Signal waiting qcom_smd_send() about the interrupt */
|
||||
if (!GET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR))
|
||||
wake_up_interruptible(&channel->fblockread_event);
|
||||
wake_up_interruptible_all(&channel->fblockread_event);
|
||||
|
||||
/* Don't consume any data until we've opened the channel */
|
||||
if (channel->state != SMD_CHANNEL_OPENED)
|
||||
|
@ -740,28 +743,37 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
while (qcom_smd_get_tx_avail(channel) < tlen) {
|
||||
while (qcom_smd_get_tx_avail(channel) < tlen &&
|
||||
channel->state == SMD_CHANNEL_OPENED) {
|
||||
if (!wait) {
|
||||
ret = -EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (channel->state != SMD_CHANNEL_OPENED) {
|
||||
ret = -EPIPE;
|
||||
goto out;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 0);
|
||||
|
||||
/* Wait without holding the tx_lock */
|
||||
mutex_unlock(&channel->tx_lock);
|
||||
|
||||
ret = wait_event_interruptible(channel->fblockread_event,
|
||||
qcom_smd_get_tx_avail(channel) >= tlen ||
|
||||
channel->state != SMD_CHANNEL_OPENED);
|
||||
if (ret)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
ret = mutex_lock_interruptible(&channel->tx_lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 1);
|
||||
}
|
||||
|
||||
/* Fail if the channel was closed */
|
||||
if (channel->state != SMD_CHANNEL_OPENED) {
|
||||
ret = -EPIPE;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
SET_TX_CHANNEL_FLAG(channel, fTAIL, 0);
|
||||
|
||||
qcom_smd_write_fifo(channel, hdr, sizeof(hdr));
|
||||
|
@ -774,7 +786,7 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data,
|
|||
|
||||
qcom_smd_signal_channel(channel);
|
||||
|
||||
out:
|
||||
out_unlock:
|
||||
mutex_unlock(&channel->tx_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -786,7 +798,9 @@ out:
|
|||
static int qcom_smd_channel_open(struct qcom_smd_channel *channel,
|
||||
rpmsg_rx_cb_t cb)
|
||||
{
|
||||
struct qcom_smd_edge *edge = channel->edge;
|
||||
size_t bb_size;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Packets are maximum 4k, but reduce if the fifo is smaller
|
||||
|
@ -798,9 +812,33 @@ static int qcom_smd_channel_open(struct qcom_smd_channel *channel,
|
|||
|
||||
qcom_smd_channel_set_callback(channel, cb);
|
||||
qcom_smd_channel_set_state(channel, SMD_CHANNEL_OPENING);
|
||||
|
||||
/* Wait for remote to enter opening or opened */
|
||||
ret = wait_event_interruptible_timeout(channel->state_change_event,
|
||||
channel->remote_state == SMD_CHANNEL_OPENING ||
|
||||
channel->remote_state == SMD_CHANNEL_OPENED,
|
||||
HZ);
|
||||
if (!ret) {
|
||||
dev_err(&edge->dev, "remote side did not enter opening state\n");
|
||||
goto out_close_timeout;
|
||||
}
|
||||
|
||||
qcom_smd_channel_set_state(channel, SMD_CHANNEL_OPENED);
|
||||
|
||||
/* Wait for remote to enter opened */
|
||||
ret = wait_event_interruptible_timeout(channel->state_change_event,
|
||||
channel->remote_state == SMD_CHANNEL_OPENED,
|
||||
HZ);
|
||||
if (!ret) {
|
||||
dev_err(&edge->dev, "remote side did not enter open state\n");
|
||||
goto out_close_timeout;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out_close_timeout:
|
||||
qcom_smd_channel_set_state(channel, SMD_CHANNEL_CLOSED);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1055,6 +1093,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
|
|||
mutex_init(&channel->tx_lock);
|
||||
spin_lock_init(&channel->recv_lock);
|
||||
init_waitqueue_head(&channel->fblockread_event);
|
||||
init_waitqueue_head(&channel->state_change_event);
|
||||
|
||||
info = qcom_smem_get(edge->remote_pid, smem_info_item, &info_size);
|
||||
if (IS_ERR(info)) {
|
||||
|
@ -1161,7 +1200,7 @@ static void qcom_channel_scan_worker(struct work_struct *work)
|
|||
dev_dbg(&edge->dev, "new channel found: '%s'\n", channel->name);
|
||||
set_bit(i, edge->allocated[tbl]);
|
||||
|
||||
wake_up_interruptible(&edge->new_channel_event);
|
||||
wake_up_interruptible_all(&edge->new_channel_event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1195,11 +1234,6 @@ static void qcom_channel_state_worker(struct work_struct *work)
|
|||
if (channel->state != SMD_CHANNEL_CLOSED)
|
||||
continue;
|
||||
|
||||
remote_state = GET_RX_CHANNEL_INFO(channel, state);
|
||||
if (remote_state != SMD_CHANNEL_OPENING &&
|
||||
remote_state != SMD_CHANNEL_OPENED)
|
||||
continue;
|
||||
|
||||
if (channel->registered)
|
||||
continue;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче