Commit e155d4ee authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Dmitry Torokhov

Input: synaptics-rmi4 - remove mutex calls while updating the firmware

This partially reverts commit 29fd0ec2 ("Input: synaptics-rmi4 -
add support for F34 device reflash")

irq_mutex should be used only to protect data->current_irq_mask, not
preventing incoming input to be processed while the upgrade of the
firmware is happening. We can simply disable the irqs when we don't
want them to interfere with the upgrade process.

Tested on S7300 and S7800 (with F34 v7 patch added)
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarNick Dyer <nick@shmanahar.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent a64ea311
...@@ -42,8 +42,6 @@ void rmi_free_function_list(struct rmi_device *rmi_dev) ...@@ -42,8 +42,6 @@ void rmi_free_function_list(struct rmi_device *rmi_dev)
rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, "Freeing function list\n"); rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, "Freeing function list\n");
mutex_lock(&data->irq_mutex);
devm_kfree(&rmi_dev->dev, data->irq_memory); devm_kfree(&rmi_dev->dev, data->irq_memory);
data->irq_memory = NULL; data->irq_memory = NULL;
data->irq_status = NULL; data->irq_status = NULL;
...@@ -60,8 +58,6 @@ void rmi_free_function_list(struct rmi_device *rmi_dev) ...@@ -60,8 +58,6 @@ void rmi_free_function_list(struct rmi_device *rmi_dev)
list_del(&fn->node); list_del(&fn->node);
rmi_unregister_function(fn); rmi_unregister_function(fn);
} }
mutex_unlock(&data->irq_mutex);
} }
EXPORT_SYMBOL_GPL(rmi_free_function_list); EXPORT_SYMBOL_GPL(rmi_free_function_list);
...@@ -160,25 +156,24 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev) ...@@ -160,25 +156,24 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
if (!data) if (!data)
return 0; return 0;
mutex_lock(&data->irq_mutex);
if (!data->irq_status || !data->f01_container) {
mutex_unlock(&data->irq_mutex);
return 0;
}
if (!rmi_dev->xport->attn_data) { if (!rmi_dev->xport->attn_data) {
error = rmi_read_block(rmi_dev, error = rmi_read_block(rmi_dev,
data->f01_container->fd.data_base_addr + 1, data->f01_container->fd.data_base_addr + 1,
data->irq_status, data->num_of_irq_regs); data->irq_status, data->num_of_irq_regs);
if (error < 0) { if (error < 0) {
dev_err(dev, "Failed to read irqs, code=%d\n", error); dev_err(dev, "Failed to read irqs, code=%d\n", error);
mutex_unlock(&data->irq_mutex);
return error; return error;
} }
} }
mutex_lock(&data->irq_mutex);
bitmap_and(data->irq_status, data->irq_status, data->current_irq_mask, bitmap_and(data->irq_status, data->irq_status, data->current_irq_mask,
data->irq_count); data->irq_count);
/*
* At this point, irq_status has all bits that are set in the
* interrupt status register and are enabled.
*/
mutex_unlock(&data->irq_mutex);
/* /*
* It would be nice to be able to use irq_chip to handle these * It would be nice to be able to use irq_chip to handle these
...@@ -194,8 +189,6 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev) ...@@ -194,8 +189,6 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
if (data->input) if (data->input)
input_sync(data->input); input_sync(data->input);
mutex_unlock(&data->irq_mutex);
return 0; return 0;
} }
...@@ -263,17 +256,11 @@ static int rmi_suspend_functions(struct rmi_device *rmi_dev) ...@@ -263,17 +256,11 @@ static int rmi_suspend_functions(struct rmi_device *rmi_dev)
struct rmi_function *entry; struct rmi_function *entry;
int retval; int retval;
mutex_lock(&data->irq_mutex);
list_for_each_entry(entry, &data->function_list, node) { list_for_each_entry(entry, &data->function_list, node) {
retval = suspend_one_function(entry); retval = suspend_one_function(entry);
if (retval < 0) { if (retval < 0)
mutex_unlock(&data->irq_mutex);
return retval; return retval;
} }
}
mutex_unlock(&data->irq_mutex);
return 0; return 0;
} }
...@@ -303,17 +290,11 @@ static int rmi_resume_functions(struct rmi_device *rmi_dev) ...@@ -303,17 +290,11 @@ static int rmi_resume_functions(struct rmi_device *rmi_dev)
struct rmi_function *entry; struct rmi_function *entry;
int retval; int retval;
mutex_lock(&data->irq_mutex);
list_for_each_entry(entry, &data->function_list, node) { list_for_each_entry(entry, &data->function_list, node) {
retval = resume_one_function(entry); retval = resume_one_function(entry);
if (retval < 0) { if (retval < 0)
mutex_unlock(&data->irq_mutex);
return retval; return retval;
} }
}
mutex_unlock(&data->irq_mutex);
return 0; return 0;
} }
...@@ -1043,8 +1024,6 @@ int rmi_init_functions(struct rmi_driver_data *data) ...@@ -1043,8 +1024,6 @@ int rmi_init_functions(struct rmi_driver_data *data)
int irq_count; int irq_count;
int retval; int retval;
mutex_lock(&data->irq_mutex);
irq_count = 0; irq_count = 0;
rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Creating functions.\n", __func__); rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Creating functions.\n", __func__);
retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function); retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function);
...@@ -1069,13 +1048,10 @@ int rmi_init_functions(struct rmi_driver_data *data) ...@@ -1069,13 +1048,10 @@ int rmi_init_functions(struct rmi_driver_data *data)
goto err_destroy_functions; goto err_destroy_functions;
} }
mutex_unlock(&data->irq_mutex);
return 0; return 0;
err_destroy_functions: err_destroy_functions:
rmi_free_function_list(rmi_dev); rmi_free_function_list(rmi_dev);
mutex_unlock(&data->irq_mutex);
return retval; return retval;
} }
EXPORT_SYMBOL_GPL(rmi_init_functions); EXPORT_SYMBOL_GPL(rmi_init_functions);
......
...@@ -282,7 +282,8 @@ int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw) ...@@ -282,7 +282,8 @@ int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw)
static int rmi_firmware_update(struct rmi_driver_data *data, static int rmi_firmware_update(struct rmi_driver_data *data,
const struct firmware *fw) const struct firmware *fw)
{ {
struct device *dev = &data->rmi_dev->dev; struct rmi_device *rmi_dev = data->rmi_dev;
struct device *dev = &rmi_dev->dev;
struct f34_data *f34; struct f34_data *f34;
int ret; int ret;
...@@ -305,8 +306,10 @@ static int rmi_firmware_update(struct rmi_driver_data *data, ...@@ -305,8 +306,10 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
if (ret) if (ret)
return ret; return ret;
rmi_disable_irq(rmi_dev, false);
/* Tear down functions and re-probe */ /* Tear down functions and re-probe */
rmi_free_function_list(data->rmi_dev); rmi_free_function_list(rmi_dev);
ret = rmi_probe_interrupts(data); ret = rmi_probe_interrupts(data);
if (ret) if (ret)
...@@ -322,6 +325,8 @@ static int rmi_firmware_update(struct rmi_driver_data *data, ...@@ -322,6 +325,8 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
return -EINVAL; return -EINVAL;
} }
rmi_enable_irq(rmi_dev, false);
f34 = dev_get_drvdata(&data->f34_container->dev); f34 = dev_get_drvdata(&data->f34_container->dev);
/* Perform firmware update */ /* Perform firmware update */
...@@ -329,11 +334,13 @@ static int rmi_firmware_update(struct rmi_driver_data *data, ...@@ -329,11 +334,13 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret); dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret);
rmi_disable_irq(rmi_dev, false);
/* Re-probe */ /* Re-probe */
rmi_dbg(RMI_DEBUG_FN, dev, "Re-probing device\n"); rmi_dbg(RMI_DEBUG_FN, dev, "Re-probing device\n");
rmi_free_function_list(data->rmi_dev); rmi_free_function_list(rmi_dev);
ret = rmi_scan_pdt(data->rmi_dev, NULL, rmi_initial_reset); ret = rmi_scan_pdt(rmi_dev, NULL, rmi_initial_reset);
if (ret < 0) if (ret < 0)
dev_warn(dev, "RMI reset failed!\n"); dev_warn(dev, "RMI reset failed!\n");
...@@ -345,9 +352,11 @@ static int rmi_firmware_update(struct rmi_driver_data *data, ...@@ -345,9 +352,11 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
if (ret) if (ret)
return ret; return ret;
rmi_enable_irq(rmi_dev, false);
if (data->f01_container->dev.driver) if (data->f01_container->dev.driver)
/* Driver already bound, so enable ATTN now. */ /* Driver already bound, so enable ATTN now. */
return rmi_enable_sensor(data->rmi_dev); return rmi_enable_sensor(rmi_dev);
rmi_dbg(RMI_DEBUG_FN, dev, "%s complete\n", __func__); rmi_dbg(RMI_DEBUG_FN, dev, "%s complete\n", __func__);
......
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