提交 cd7b7f50 编写于 作者: H Hans Verkuil 提交者: Greg Kroah-Hartman

media: cec: check for non-OK/NACK conditions while claiming a LA

[ Upstream commit 55623b4169056d7bb493d1c6f715991f8db67302 ]

During the configuration phase of a CEC adapter it is trying to claim a
free logical address by polling.

However, the code doesn't check if there were errors other than OK or NACK,
those are just treated as if the poll was NACKed.

Instead check for such errors and retry the poll. And if the problem persists
then don't claim this LA since there is something weird going on.
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: NHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 35eaa0ee
...@@ -1167,6 +1167,8 @@ static int cec_config_log_addr(struct cec_adapter *adap, ...@@ -1167,6 +1167,8 @@ static int cec_config_log_addr(struct cec_adapter *adap,
{ {
struct cec_log_addrs *las = &adap->log_addrs; struct cec_log_addrs *las = &adap->log_addrs;
struct cec_msg msg = { }; struct cec_msg msg = { };
const unsigned int max_retries = 2;
unsigned int i;
int err; int err;
if (cec_has_log_addr(adap, log_addr)) if (cec_has_log_addr(adap, log_addr))
...@@ -1175,19 +1177,44 @@ static int cec_config_log_addr(struct cec_adapter *adap, ...@@ -1175,19 +1177,44 @@ static int cec_config_log_addr(struct cec_adapter *adap,
/* Send poll message */ /* Send poll message */
msg.len = 1; msg.len = 1;
msg.msg[0] = (log_addr << 4) | log_addr; msg.msg[0] = (log_addr << 4) | log_addr;
err = cec_transmit_msg_fh(adap, &msg, NULL, true);
/* for (i = 0; i < max_retries; i++) {
* While trying to poll the physical address was reset err = cec_transmit_msg_fh(adap, &msg, NULL, true);
* and the adapter was unconfigured, so bail out.
*/
if (!adap->is_configuring)
return -EINTR;
if (err) /*
return err; * While trying to poll the physical address was reset
* and the adapter was unconfigured, so bail out.
*/
if (!adap->is_configuring)
return -EINTR;
if (err)
return err;
if (msg.tx_status & CEC_TX_STATUS_OK) /*
* The message was aborted due to a disconnect or
* unconfigure, just bail out.
*/
if (msg.tx_status & CEC_TX_STATUS_ABORTED)
return -EINTR;
if (msg.tx_status & CEC_TX_STATUS_OK)
return 0;
if (msg.tx_status & CEC_TX_STATUS_NACK)
break;
/*
* Retry up to max_retries times if the message was neither
* OKed or NACKed. This can happen due to e.g. a Lost
* Arbitration condition.
*/
}
/*
* If we are unable to get an OK or a NACK after max_retries attempts
* (and note that each attempt already consists of four polls), then
* then we assume that something is really weird and that it is not a
* good idea to try and claim this logical address.
*/
if (i == max_retries)
return 0; return 0;
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册