提交 41a13551 编写于 作者: H Hans Verkuil 提交者: Zheng Zengkai

media: cec-adap.c: fix is_configuring state

stable inclusion
from stable-v5.10.121
commit 22cdbb1354985acf9a650e01bca987d0615330ac
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=22cdbb1354985acf9a650e01bca987d0615330ac

--------------------------------

[ Upstream commit 59267fc3 ]

If an adapter is trying to claim a free logical address then it is
in the 'is_configuring' state. If during that process the cable is
disconnected (HPD goes low, which in turn invalidates the physical
address), then cec_adap_unconfigure() is called, and that set the
is_configuring boolean to false, even though the thread that's
trying to claim an LA is still running.

Don't touch the is_configuring bool in cec_adap_unconfigure(), it
will eventually be cleared by the thread. By making that change
the cec_config_log_addr() function also had to change: it was
aborting if is_configuring became false (since that is what
cec_adap_unconfigure() did), but that no longer works. Instead
check if the physical address is invalid. That is a much
more appropriate check anyway.

This fixes a bug where the the adapter could be disabled even
though the device was still configuring. This could cause POLL
transmits to time out.
Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 e5eb9837
...@@ -1271,7 +1271,7 @@ static int cec_config_log_addr(struct cec_adapter *adap, ...@@ -1271,7 +1271,7 @@ static int cec_config_log_addr(struct cec_adapter *adap,
* While trying to poll the physical address was reset * While trying to poll the physical address was reset
* and the adapter was unconfigured, so bail out. * and the adapter was unconfigured, so bail out.
*/ */
if (!adap->is_configuring) if (adap->phys_addr == CEC_PHYS_ADDR_INVALID)
return -EINTR; return -EINTR;
if (err) if (err)
...@@ -1328,7 +1328,6 @@ static void cec_adap_unconfigure(struct cec_adapter *adap) ...@@ -1328,7 +1328,6 @@ static void cec_adap_unconfigure(struct cec_adapter *adap)
adap->phys_addr != CEC_PHYS_ADDR_INVALID) adap->phys_addr != CEC_PHYS_ADDR_INVALID)
WARN_ON(adap->ops->adap_log_addr(adap, CEC_LOG_ADDR_INVALID)); WARN_ON(adap->ops->adap_log_addr(adap, CEC_LOG_ADDR_INVALID));
adap->log_addrs.log_addr_mask = 0; adap->log_addrs.log_addr_mask = 0;
adap->is_configuring = false;
adap->is_configured = false; adap->is_configured = false;
cec_flush(adap); cec_flush(adap);
wake_up_interruptible(&adap->kthread_waitq); wake_up_interruptible(&adap->kthread_waitq);
...@@ -1520,9 +1519,10 @@ static int cec_config_thread_func(void *arg) ...@@ -1520,9 +1519,10 @@ static int cec_config_thread_func(void *arg)
for (i = 0; i < las->num_log_addrs; i++) for (i = 0; i < las->num_log_addrs; i++)
las->log_addr[i] = CEC_LOG_ADDR_INVALID; las->log_addr[i] = CEC_LOG_ADDR_INVALID;
cec_adap_unconfigure(adap); cec_adap_unconfigure(adap);
adap->is_configuring = false;
adap->kthread_config = NULL; adap->kthread_config = NULL;
mutex_unlock(&adap->lock);
complete(&adap->config_completion); complete(&adap->config_completion);
mutex_unlock(&adap->lock);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册