Commit e3891b36 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: cec-adap.c: reconfigure if the PA changes during configuration

If the physical address changes (i.e. becomes invalid, then valid again)
while the adapter is still claiming free logical addresses, then trigger
a reconfiguration since any claimed LAs may now be stale.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 59267fc3
...@@ -1278,6 +1278,10 @@ static int cec_config_log_addr(struct cec_adapter *adap, ...@@ -1278,6 +1278,10 @@ static int cec_config_log_addr(struct cec_adapter *adap,
if (adap->phys_addr == CEC_PHYS_ADDR_INVALID) if (adap->phys_addr == CEC_PHYS_ADDR_INVALID)
return -EINTR; return -EINTR;
/* Also bail out if the PA changed while configuring. */
if (adap->must_reconfigure)
return -EINTR;
if (err) if (err)
return err; return err;
...@@ -1405,6 +1409,7 @@ static int cec_config_thread_func(void *arg) ...@@ -1405,6 +1409,7 @@ static int cec_config_thread_func(void *arg)
if (las->log_addr_type[0] == CEC_LOG_ADDR_TYPE_UNREGISTERED) if (las->log_addr_type[0] == CEC_LOG_ADDR_TYPE_UNREGISTERED)
goto configured; goto configured;
reconfigure:
for (i = 0; i < las->num_log_addrs; i++) { for (i = 0; i < las->num_log_addrs; i++) {
unsigned int type = las->log_addr_type[i]; unsigned int type = las->log_addr_type[i];
const u8 *la_list; const u8 *la_list;
...@@ -1427,6 +1432,13 @@ static int cec_config_thread_func(void *arg) ...@@ -1427,6 +1432,13 @@ static int cec_config_thread_func(void *arg)
last_la = la_list[0]; last_la = la_list[0];
err = cec_config_log_addr(adap, i, last_la); err = cec_config_log_addr(adap, i, last_la);
if (adap->must_reconfigure) {
adap->must_reconfigure = false;
las->log_addr_mask = 0;
goto reconfigure;
}
if (err > 0) /* Reused last LA */ if (err > 0) /* Reused last LA */
continue; continue;
...@@ -1472,6 +1484,7 @@ static int cec_config_thread_func(void *arg) ...@@ -1472,6 +1484,7 @@ static int cec_config_thread_func(void *arg)
las->log_addr[i] = CEC_LOG_ADDR_INVALID; las->log_addr[i] = CEC_LOG_ADDR_INVALID;
adap->is_configured = true; adap->is_configured = true;
adap->is_configuring = false; adap->is_configuring = false;
adap->must_reconfigure = false;
cec_post_state_event(adap); cec_post_state_event(adap);
/* /*
...@@ -1526,6 +1539,7 @@ static int cec_config_thread_func(void *arg) ...@@ -1526,6 +1539,7 @@ static int cec_config_thread_func(void *arg)
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->is_configuring = false;
adap->must_reconfigure = false;
adap->kthread_config = NULL; adap->kthread_config = NULL;
complete(&adap->config_completion); complete(&adap->config_completion);
mutex_unlock(&adap->lock); mutex_unlock(&adap->lock);
...@@ -1649,7 +1663,11 @@ void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block) ...@@ -1649,7 +1663,11 @@ void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block)
adap->phys_addr = phys_addr; adap->phys_addr = phys_addr;
cec_post_state_event(adap); cec_post_state_event(adap);
if (adap->log_addrs.num_log_addrs) if (!adap->log_addrs.num_log_addrs)
return;
if (adap->is_configuring)
adap->must_reconfigure = true;
else
cec_claim_log_addrs(adap, block); cec_claim_log_addrs(adap, block);
} }
......
...@@ -184,6 +184,7 @@ struct cec_adap_ops { ...@@ -184,6 +184,7 @@ struct cec_adap_ops {
* in order to transmit or receive CEC messages. This is usually a HW * in order to transmit or receive CEC messages. This is usually a HW
* limitation. * limitation.
* @is_configuring: the CEC adapter is configuring (i.e. claiming LAs) * @is_configuring: the CEC adapter is configuring (i.e. claiming LAs)
* @must_reconfigure: while configuring, the PA changed, so reclaim LAs
* @is_configured: the CEC adapter is configured (i.e. has claimed LAs) * @is_configured: the CEC adapter is configured (i.e. has claimed LAs)
* @cec_pin_is_high: if true then the CEC pin is high. Only used with the * @cec_pin_is_high: if true then the CEC pin is high. Only used with the
* CEC pin framework. * CEC pin framework.
...@@ -243,6 +244,7 @@ struct cec_adapter { ...@@ -243,6 +244,7 @@ struct cec_adapter {
u16 phys_addr; u16 phys_addr;
bool needs_hpd; bool needs_hpd;
bool is_configuring; bool is_configuring;
bool must_reconfigure;
bool is_configured; bool is_configured;
bool cec_pin_is_high; bool cec_pin_is_high;
bool adap_controls_phys_addr; bool adap_controls_phys_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment