mirror of
https://github.com/apache/nuttx.git
synced 2026-05-13 02:18:38 +08:00
drivers/rpmsg_port: notify the lower transport when no free buffers
When no free buffers, notify the lower transport, so the lower transports can know this thing and do some work, such as continue to process the rx data to avoid the rx thread is blocked that even can't process the commands. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com> Signed-off-by: liaoao <liaoao@xiaomi.com>
This commit is contained in:
@@ -215,6 +215,8 @@ rpmsg_port_create_queues(FAR struct rpmsg_port_s *port,
|
||||
return ret;
|
||||
}
|
||||
|
||||
port->txq.port = port;
|
||||
port->rxq.port = port;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -608,8 +610,10 @@ FAR struct rpmsg_port_header_s *
|
||||
rpmsg_port_queue_get_available_buffer(FAR struct rpmsg_port_queue_s *queue,
|
||||
bool wait)
|
||||
{
|
||||
FAR struct list_node *node;
|
||||
FAR struct rpmsg_port_s *port = queue->port;
|
||||
FAR struct rpmsg_port_header_s *hdr;
|
||||
FAR struct list_node *node;
|
||||
int ret;
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
@@ -625,7 +629,12 @@ rpmsg_port_queue_get_available_buffer(FAR struct rpmsg_port_queue_s *queue,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nxsem_wait_uninterruptible(&queue->free.sem);
|
||||
ret = port->ops->notify_queue_noavail ?
|
||||
port->ops->notify_queue_noavail(port, queue) : -ENOTSUP;
|
||||
if (ret == -ENOTSUP)
|
||||
{
|
||||
nxsem_wait_uninterruptible(&queue->free.sem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,14 @@ struct rpmsg_port_list_s
|
||||
struct list_node head; /* List head */
|
||||
};
|
||||
|
||||
struct rpmsg_port_s;
|
||||
|
||||
struct rpmsg_port_queue_s
|
||||
{
|
||||
/* Pointer to the rpmsg port handler */
|
||||
|
||||
FAR struct rpmsg_port_s *port;
|
||||
|
||||
/* Indicate buffers current queue managed is dynamic alloced */
|
||||
|
||||
bool alloced;
|
||||
@@ -94,8 +100,6 @@ struct rpmsg_port_queue_s
|
||||
struct rpmsg_port_list_s ready;
|
||||
};
|
||||
|
||||
struct rpmsg_port_s;
|
||||
|
||||
typedef void (*rpmsg_port_rx_cb_t)(FAR struct rpmsg_port_s *port,
|
||||
FAR struct rpmsg_port_header_s *hdr);
|
||||
|
||||
@@ -109,6 +113,11 @@ struct rpmsg_port_ops_s
|
||||
|
||||
CODE void (*notify_rx_free)(FAR struct rpmsg_port_s *port);
|
||||
|
||||
/* Notify driver there is no available buffer */
|
||||
|
||||
CODE int (*notify_queue_noavail)(FAR struct rpmsg_port_s *port,
|
||||
FAR struct rpmsg_port_queue_s *queue);
|
||||
|
||||
/* Register callback function which should be invoked when there is
|
||||
* date received to the rx queue by driver
|
||||
*/
|
||||
|
||||
@@ -140,6 +140,7 @@ static const struct rpmsg_port_ops_s g_rpmsg_port_spi_ops =
|
||||
{
|
||||
rpmsg_port_spi_notify_tx_ready,
|
||||
rpmsg_port_spi_notify_rx_free,
|
||||
NULL,
|
||||
rpmsg_port_spi_register_cb,
|
||||
};
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ static const struct rpmsg_port_ops_s g_rpmsg_port_spi_ops =
|
||||
{
|
||||
rpmsg_port_spi_notify_tx_ready,
|
||||
rpmsg_port_spi_notify_rx_free,
|
||||
NULL,
|
||||
rpmsg_port_spi_register_cb,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user