mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
fsi: Prevent multiple concurrent rescans
The bus scanning process isn't terribly good at parallel attempts at rescanning the same bus. Let's have a per-master mutex protecting the scanning process. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
@@ -1203,8 +1203,14 @@ static void fsi_master_unscan(struct fsi_master *master)
|
|||||||
|
|
||||||
int fsi_master_rescan(struct fsi_master *master)
|
int fsi_master_rescan(struct fsi_master *master)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
mutex_lock(&master->scan_lock);
|
||||||
fsi_master_unscan(master);
|
fsi_master_unscan(master);
|
||||||
return fsi_master_scan(master);
|
rc = fsi_master_scan(master);
|
||||||
|
mutex_unlock(&master->scan_lock);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(fsi_master_rescan);
|
EXPORT_SYMBOL_GPL(fsi_master_rescan);
|
||||||
|
|
||||||
@@ -1240,6 +1246,7 @@ int fsi_master_register(struct fsi_master *master)
|
|||||||
int rc;
|
int rc;
|
||||||
struct device_node *np;
|
struct device_node *np;
|
||||||
|
|
||||||
|
mutex_init(&master->scan_lock);
|
||||||
master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
|
master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
|
||||||
dev_set_name(&master->dev, "fsi%d", master->idx);
|
dev_set_name(&master->dev, "fsi%d", master->idx);
|
||||||
|
|
||||||
@@ -1264,8 +1271,11 @@ int fsi_master_register(struct fsi_master *master)
|
|||||||
}
|
}
|
||||||
|
|
||||||
np = dev_of_node(&master->dev);
|
np = dev_of_node(&master->dev);
|
||||||
if (!of_property_read_bool(np, "no-scan-on-init"))
|
if (!of_property_read_bool(np, "no-scan-on-init")) {
|
||||||
|
mutex_lock(&master->scan_lock);
|
||||||
fsi_master_scan(master);
|
fsi_master_scan(master);
|
||||||
|
mutex_unlock(&master->scan_lock);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1278,7 +1288,9 @@ void fsi_master_unregister(struct fsi_master *master)
|
|||||||
master->idx = -1;
|
master->idx = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_lock(&master->scan_lock);
|
||||||
fsi_master_unscan(master);
|
fsi_master_unscan(master);
|
||||||
|
mutex_unlock(&master->scan_lock);
|
||||||
device_unregister(&master->dev);
|
device_unregister(&master->dev);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(fsi_master_unregister);
|
EXPORT_SYMBOL_GPL(fsi_master_unregister);
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#define DRIVERS_FSI_MASTER_H
|
#define DRIVERS_FSI_MASTER_H
|
||||||
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
|
||||||
/* Various protocol delays */
|
/* Various protocol delays */
|
||||||
#define FSI_ECHO_DELAY_CLOCKS 16 /* Number clocks for echo delay */
|
#define FSI_ECHO_DELAY_CLOCKS 16 /* Number clocks for echo delay */
|
||||||
@@ -59,6 +60,7 @@ struct fsi_master {
|
|||||||
int idx;
|
int idx;
|
||||||
int n_links;
|
int n_links;
|
||||||
int flags;
|
int flags;
|
||||||
|
struct mutex scan_lock;
|
||||||
int (*read)(struct fsi_master *, int link, uint8_t id,
|
int (*read)(struct fsi_master *, int link, uint8_t id,
|
||||||
uint32_t addr, void *val, size_t size);
|
uint32_t addr, void *val, size_t size);
|
||||||
int (*write)(struct fsi_master *, int link, uint8_t id,
|
int (*write)(struct fsi_master *, int link, uint8_t id,
|
||||||
|
Reference in New Issue
Block a user