From 11065f8531ed33d5e847a36ad64231ee599d4996 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 17 Jul 2016 11:40:05 -0300 Subject: [media] cec: limit the size of the transmit queue The size of the transmit queue was unlimited, which meant that in non-blocking mode you could flood the CEC adapter with messages to be transmitted. Limit this to 18 messages. Also print the number of pending transmits and the timeout value in the status debugfs file. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include/media/cec.h') diff --git a/include/media/cec.h b/include/media/cec.h index 9a791c08a789..dc7854b855f3 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -126,12 +126,20 @@ struct cec_adap_ops { * With a transfer rate of at most 36 bytes per second this makes 18 messages * per second worst case. * - * We queue at most 3 seconds worth of messages. The CEC specification requires - * that messages are replied to within a second, so 3 seconds should give more - * than enough margin. Since most messages are actually more than 2 bytes, this - * is in practice a lot more than 3 seconds. + * We queue at most 3 seconds worth of received messages. The CEC specification + * requires that messages are replied to within a second, so 3 seconds should + * give more than enough margin. Since most messages are actually more than 2 + * bytes, this is in practice a lot more than 3 seconds. */ -#define CEC_MAX_MSG_QUEUE_SZ (18 * 3) +#define CEC_MAX_MSG_RX_QUEUE_SZ (18 * 3) + +/* + * The transmit queue is limited to 1 second worth of messages (worst case). + * Messages can be transmitted by userspace and kernel space. But for both it + * makes no sense to have a lot of messages queued up. One second seems + * reasonable. + */ +#define CEC_MAX_MSG_TX_QUEUE_SZ (18 * 1) struct cec_adapter { struct module *owner; @@ -141,6 +149,7 @@ struct cec_adapter { struct rc_dev *rc; struct list_head transmit_queue; + unsigned int transmit_queue_sz; struct list_head wait_queue; struct cec_data *transmitting; -- cgit v1.2.1