Changeset 4820360 in mainline
- Timestamp:
- 2012-08-13T14:44:07Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 14c5005, 4802dd7, 72cf064
- Parents:
- cd529c4
- Location:
- uspace/srv/devman
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
rcd529c4 r4820360 1052 1052 } 1053 1053 1054 1055 1054 /** Find the device node structure of the device witch has the specified handle. 1056 1055 * … … 1142 1141 fun->state = FUN_INIT; 1143 1142 atomic_set(&fun->refcnt, 0); 1143 fibril_mutex_initialize(&fun->busy_lock); 1144 1144 link_initialize(&fun->dev_functions); 1145 1145 list_initialize(&fun->match_ids.ids); … … 1184 1184 if (atomic_predec(&fun->refcnt) == 0) 1185 1185 delete_fun_node(fun); 1186 } 1187 1188 /** Make function busy for reconfiguration operations. */ 1189 void fun_busy_lock(fun_node_t *fun) 1190 { 1191 fibril_mutex_lock(&fun->busy_lock); 1192 } 1193 1194 /** Mark end of reconfiguration operation. */ 1195 void fun_busy_unlock(fun_node_t *fun) 1196 { 1197 fibril_mutex_unlock(&fun->busy_lock); 1186 1198 } 1187 1199 -
uspace/srv/devman/devman.h
rcd529c4 r4820360 174 174 /** State */ 175 175 fun_state_t state; 176 /** Locked while performing reconfiguration operations */ 177 fibril_mutex_t busy_lock; 176 178 177 179 /** The global unique identifier of the function */ … … 279 281 extern void dev_add_ref(dev_node_t *); 280 282 extern void dev_del_ref(dev_node_t *); 283 281 284 extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree, 282 285 devman_handle_t handle); … … 290 293 extern void fun_add_ref(fun_node_t *); 291 294 extern void fun_del_ref(fun_node_t *); 295 extern void fun_busy_lock(fun_node_t *); 296 extern void fun_busy_unlock(fun_node_t *); 292 297 extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree, 293 298 devman_handle_t handle); -
uspace/srv/devman/main.c
rcd529c4 r4820360 432 432 433 433 fun_node_t *fun = create_fun_node(); 434 /* One reference for creation, one for us */ 435 fun_add_ref(fun); 434 436 fun_add_ref(fun); 435 437 fun->ftype = ftype; 438 439 /* 440 * We can lock the function here even when holding the tree because 441 * we know it cannot be held by anyone else yet. 442 */ 443 fun_busy_lock(fun); 436 444 437 445 if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) { 438 446 fibril_rwlock_write_unlock(&tree->rwlock); 439 447 dev_del_ref(pdev); 448 fun_busy_unlock(fun); 449 fun_del_ref(fun); 440 450 delete_fun_node(fun); 441 451 async_answer_0(callid, ENOMEM); … … 450 460 rc = online_function(fun); 451 461 if (rc != EOK) { 452 /* XXX clean up */ 462 /* XXX Set some failed state? */ 463 fun_busy_unlock(fun); 464 fun_del_ref(fun); 453 465 async_answer_0(callid, rc); 454 466 return; 455 467 } 468 469 fun_busy_unlock(fun); 470 fun_del_ref(fun); 456 471 457 472 /* Return device handle to parent's driver. */ … … 522 537 } 523 538 539 fun_busy_lock(fun); 540 524 541 fibril_rwlock_read_lock(&device_tree.rwlock); 525 542 if (fun->dev == NULL || fun->dev->drv != drv) { 526 543 fibril_rwlock_read_unlock(&device_tree.rwlock); 544 fun_busy_unlock(fun); 527 545 fun_del_ref(fun); 528 546 async_answer_0(iid, ENOENT); … … 533 551 rc = online_function(fun); 534 552 if (rc != EOK) { 553 fun_busy_unlock(fun); 535 554 fun_del_ref(fun); 536 555 async_answer_0(iid, (sysarg_t) rc); … … 538 557 } 539 558 559 fun_busy_unlock(fun); 540 560 fun_del_ref(fun); 541 561 … … 559 579 } 560 580 581 fun_busy_lock(fun); 582 561 583 fibril_rwlock_write_lock(&device_tree.rwlock); 562 584 if (fun->dev == NULL || fun->dev->drv != drv) { 585 fun_busy_unlock(fun); 563 586 fun_del_ref(fun); 564 587 async_answer_0(iid, ENOENT); … … 569 592 rc = offline_function(fun); 570 593 if (rc != EOK) { 594 fun_busy_unlock(fun); 571 595 fun_del_ref(fun); 572 596 async_answer_0(iid, (sysarg_t) rc); … … 574 598 } 575 599 600 fun_busy_unlock(fun); 576 601 fun_del_ref(fun); 577 602 async_answer_0(iid, (sysarg_t) EOK); … … 591 616 } 592 617 618 fun_busy_lock(fun); 619 593 620 fibril_rwlock_write_lock(&tree->rwlock); 594 621 … … 598 625 if (fun->state == FUN_REMOVED) { 599 626 fibril_rwlock_write_unlock(&tree->rwlock); 627 fun_busy_unlock(fun); 628 fun_del_ref(fun); 600 629 async_answer_0(callid, ENOENT); 601 630 return; … … 638 667 if (gone_rc == EOK) 639 668 gone_rc = ENOTSUP; 669 fun_busy_unlock(fun); 670 fun_del_ref(fun); 640 671 async_answer_0(callid, gone_rc); 641 672 return; … … 664 695 "service."); 665 696 fibril_rwlock_write_unlock(&tree->rwlock); 697 fun_busy_unlock(fun); 666 698 fun_del_ref(fun); 667 699 async_answer_0(callid, EIO); … … 673 705 remove_fun_node(&device_tree, fun); 674 706 fibril_rwlock_write_unlock(&tree->rwlock); 707 fun_busy_unlock(fun); 675 708 676 709 /* Delete ref added when inserting function into tree */
Note:
See TracChangeset
for help on using the changeset viewer.