diff options
| -rw-r--r-- | drivers/rapidio/rio-scan.c | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 02e686b4c19a..0a27253c9215 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
| 32 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
| 33 | #include <linux/timer.h> | 33 | #include <linux/timer.h> |
| 34 | #include <linux/sched.h> | ||
| 34 | #include <linux/jiffies.h> | 35 | #include <linux/jiffies.h> |
| 35 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
| 36 | 37 | ||
| @@ -39,8 +40,6 @@ | |||
| 39 | LIST_HEAD(rio_devices); | 40 | LIST_HEAD(rio_devices); |
| 40 | static LIST_HEAD(rio_switches); | 41 | static LIST_HEAD(rio_switches); |
| 41 | 42 | ||
| 42 | static void rio_enum_timeout(unsigned long); | ||
| 43 | |||
| 44 | static void rio_init_em(struct rio_dev *rdev); | 43 | static void rio_init_em(struct rio_dev *rdev); |
| 45 | 44 | ||
| 46 | DEFINE_SPINLOCK(rio_global_list_lock); | 45 | DEFINE_SPINLOCK(rio_global_list_lock); |
| @@ -49,9 +48,6 @@ static int next_destid = 0; | |||
| 49 | static int next_net = 0; | 48 | static int next_net = 0; |
| 50 | static int next_comptag = 1; | 49 | static int next_comptag = 1; |
| 51 | 50 | ||
| 52 | static struct timer_list rio_enum_timer = | ||
| 53 | TIMER_INITIALIZER(rio_enum_timeout, 0, 0); | ||
| 54 | |||
| 55 | static int rio_mport_phys_table[] = { | 51 | static int rio_mport_phys_table[] = { |
| 56 | RIO_EFB_PAR_EP_ID, | 52 | RIO_EFB_PAR_EP_ID, |
| 57 | RIO_EFB_PAR_EP_REC_ID, | 53 | RIO_EFB_PAR_EP_REC_ID, |
| @@ -1234,20 +1230,6 @@ static void rio_build_route_tables(void) | |||
| 1234 | } | 1230 | } |
| 1235 | 1231 | ||
| 1236 | /** | 1232 | /** |
| 1237 | * rio_enum_timeout- Signal that enumeration timed out | ||
| 1238 | * @data: Address of timeout flag. | ||
| 1239 | * | ||
| 1240 | * When the enumeration complete timer expires, set a flag that | ||
| 1241 | * signals to the discovery process that enumeration did not | ||
| 1242 | * complete in a sane amount of time. | ||
| 1243 | */ | ||
| 1244 | static void rio_enum_timeout(unsigned long data) | ||
| 1245 | { | ||
| 1246 | /* Enumeration timed out, set flag */ | ||
| 1247 | *(int *)data = 1; | ||
| 1248 | } | ||
| 1249 | |||
| 1250 | /** | ||
| 1251 | * rio_disc_mport- Start discovery through a master port | 1233 | * rio_disc_mport- Start discovery through a master port |
| 1252 | * @mport: Master port to send transactions | 1234 | * @mport: Master port to send transactions |
| 1253 | * | 1235 | * |
| @@ -1260,34 +1242,33 @@ static void rio_enum_timeout(unsigned long data) | |||
| 1260 | int __devinit rio_disc_mport(struct rio_mport *mport) | 1242 | int __devinit rio_disc_mport(struct rio_mport *mport) |
| 1261 | { | 1243 | { |
| 1262 | struct rio_net *net = NULL; | 1244 | struct rio_net *net = NULL; |
| 1263 | int enum_timeout_flag = 0; | 1245 | unsigned long to_end; |
| 1264 | 1246 | ||
| 1265 | printk(KERN_INFO "RIO: discover master port %d, %s\n", mport->id, | 1247 | printk(KERN_INFO "RIO: discover master port %d, %s\n", mport->id, |
| 1266 | mport->name); | 1248 | mport->name); |
| 1267 | 1249 | ||
| 1268 | /* If master port has an active link, allocate net and discover peers */ | 1250 | /* If master port has an active link, allocate net and discover peers */ |
| 1269 | if (rio_mport_is_active(mport)) { | 1251 | if (rio_mport_is_active(mport)) { |
| 1270 | if (!(net = rio_alloc_net(mport))) { | 1252 | pr_debug("RIO: wait for enumeration to complete...\n"); |
| 1271 | printk(KERN_ERR "RIO: Failed to allocate new net\n"); | ||
| 1272 | goto bail; | ||
| 1273 | } | ||
| 1274 | 1253 | ||
| 1275 | pr_debug("RIO: wait for enumeration complete..."); | 1254 | to_end = jiffies + CONFIG_RAPIDIO_DISC_TIMEOUT * HZ; |
| 1276 | 1255 | while (time_before(jiffies, to_end)) { | |
| 1277 | rio_enum_timer.expires = | 1256 | if (rio_enum_complete(mport)) |
| 1278 | jiffies + CONFIG_RAPIDIO_DISC_TIMEOUT * HZ; | 1257 | goto enum_done; |
| 1279 | rio_enum_timer.data = (unsigned long)&enum_timeout_flag; | 1258 | schedule_timeout_uninterruptible(msecs_to_jiffies(10)); |
| 1280 | add_timer(&rio_enum_timer); | ||
| 1281 | while (!rio_enum_complete(mport)) { | ||
| 1282 | mdelay(1); | ||
| 1283 | if (enum_timeout_flag) { | ||
| 1284 | del_timer_sync(&rio_enum_timer); | ||
| 1285 | goto timeout; | ||
| 1286 | } | ||
| 1287 | } | 1259 | } |
| 1288 | del_timer_sync(&rio_enum_timer); | ||
| 1289 | 1260 | ||
| 1290 | pr_debug("done\n"); | 1261 | pr_debug("RIO: discovery timeout on mport %d %s\n", |
| 1262 | mport->id, mport->name); | ||
| 1263 | goto bail; | ||
| 1264 | enum_done: | ||
| 1265 | pr_debug("RIO: ... enumeration done\n"); | ||
| 1266 | |||
| 1267 | net = rio_alloc_net(mport); | ||
| 1268 | if (!net) { | ||
| 1269 | printk(KERN_ERR "RIO: Failed to allocate new net\n"); | ||
| 1270 | goto bail; | ||
| 1271 | } | ||
| 1291 | 1272 | ||
| 1292 | /* Read DestID assigned by enumerator */ | 1273 | /* Read DestID assigned by enumerator */ |
| 1293 | rio_local_read_config_32(mport, RIO_DID_CSR, | 1274 | rio_local_read_config_32(mport, RIO_DID_CSR, |
| @@ -1307,9 +1288,6 @@ int __devinit rio_disc_mport(struct rio_mport *mport) | |||
| 1307 | } | 1288 | } |
| 1308 | 1289 | ||
| 1309 | return 0; | 1290 | return 0; |
| 1310 | 1291 | bail: | |
| 1311 | timeout: | ||
| 1312 | pr_debug("timeout\n"); | ||
| 1313 | bail: | ||
| 1314 | return -EBUSY; | 1292 | return -EBUSY; |
| 1315 | } | 1293 | } |
