summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2016-03-22 17:26:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-22 18:36:02 -0400
commita7b4c636d83034f0e89d58651ef2e9b96564489a (patch)
tree19e8ec4da76c040166f31a1d42265af5605dcb34
parentb7dfca8bd446721cbc23f4a7cf3c407eb42175dc (diff)
rapidio: add lock protection for doorbell list
Add lock protection around doorbell list handling to prevent list corruption on SMP platforms. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Aurelien Jacquiot <a-jacquiot@ti.com> Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rapidio/rio.c9
-rw-r--r--include/linux/rio.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 03b8c5af72bb..e42f97e9e62a 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -362,7 +362,9 @@ rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
362 dbell->dinb = dinb; 362 dbell->dinb = dinb;
363 dbell->dev_id = dev_id; 363 dbell->dev_id = dev_id;
364 364
365 mutex_lock(&mport->lock);
365 list_add_tail(&dbell->node, &mport->dbells); 366 list_add_tail(&dbell->node, &mport->dbells);
367 mutex_unlock(&mport->lock);
366 368
367 out: 369 out:
368 return rc; 370 return rc;
@@ -426,12 +428,15 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)
426 int rc = 0, found = 0; 428 int rc = 0, found = 0;
427 struct rio_dbell *dbell; 429 struct rio_dbell *dbell;
428 430
431 mutex_lock(&mport->lock);
429 list_for_each_entry(dbell, &mport->dbells, node) { 432 list_for_each_entry(dbell, &mport->dbells, node) {
430 if ((dbell->res->start == start) && (dbell->res->end == end)) { 433 if ((dbell->res->start == start) && (dbell->res->end == end)) {
434 list_del(&dbell->node);
431 found = 1; 435 found = 1;
432 break; 436 break;
433 } 437 }
434 } 438 }
439 mutex_unlock(&mport->lock);
435 440
436 /* If we can't find an exact match, fail */ 441 /* If we can't find an exact match, fail */
437 if (!found) { 442 if (!found) {
@@ -439,9 +444,6 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)
439 goto out; 444 goto out;
440 } 445 }
441 446
442 /* Delete from list */
443 list_del(&dbell->node);
444
445 /* Release the doorbell resource */ 447 /* Release the doorbell resource */
446 rc = release_resource(dbell->res); 448 rc = release_resource(dbell->res);
447 449
@@ -2024,6 +2026,7 @@ int rio_mport_initialize(struct rio_mport *mport)
2024 mport->id = next_portid++; 2026 mport->id = next_portid++;
2025 mport->host_deviceid = rio_get_hdid(mport->id); 2027 mport->host_deviceid = rio_get_hdid(mport->id);
2026 mport->nscan = NULL; 2028 mport->nscan = NULL;
2029 mutex_init(&mport->lock);
2027 2030
2028 return 0; 2031 return 0;
2029} 2032}
diff --git a/include/linux/rio.h b/include/linux/rio.h
index f833773cdc68..948f60550ae5 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -248,6 +248,7 @@ enum rio_phy_type {
248 * @node: Node in global list of master ports 248 * @node: Node in global list of master ports
249 * @nnode: Node in network list of master ports 249 * @nnode: Node in network list of master ports
250 * @net: RIO net this mport is attached to 250 * @net: RIO net this mport is attached to
251 * @lock: lock to synchronize lists manipulations
251 * @iores: I/O mem resource that this master port interface owns 252 * @iores: I/O mem resource that this master port interface owns
252 * @riores: RIO resources that this master port interfaces owns 253 * @riores: RIO resources that this master port interfaces owns
253 * @inb_msg: RIO inbound message event descriptors 254 * @inb_msg: RIO inbound message event descriptors
@@ -271,6 +272,7 @@ struct rio_mport {
271 struct list_head node; /* node in global list of ports */ 272 struct list_head node; /* node in global list of ports */
272 struct list_head nnode; /* node in net list of ports */ 273 struct list_head nnode; /* node in net list of ports */
273 struct rio_net *net; /* RIO net this mport is attached to */ 274 struct rio_net *net; /* RIO net this mport is attached to */
275 struct mutex lock;
274 struct resource iores; 276 struct resource iores;
275 struct resource riores[RIO_MAX_MPORT_RESOURCES]; 277 struct resource riores[RIO_MAX_MPORT_RESOURCES];
276 struct rio_msg inb_msg[RIO_MAX_MBOX]; 278 struct rio_msg inb_msg[RIO_MAX_MBOX];