Changeset eebecdc in mainline for uspace/srv
- Timestamp:
- 2025-03-13T18:30:36Z (12 months ago)
- Children:
- e3e53cc
- Parents:
- e494d7b (diff), da54714 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/srv
- Files:
-
- 7 edited
-
devman/client_conn.c (modified) (3 diffs)
-
devman/driver.c (modified) (1 diff)
-
devman/driver.h (modified) (2 diffs)
-
devman/drv_conn.c (modified) (2 diffs)
-
devman/fun.c (modified) (2 diffs)
-
devman/fun.h (modified) (2 diffs)
-
system/system.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/client_conn.c
re494d7b reebecdc 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2013 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 479 479 } 480 480 481 /** Quiesce function. 482 * 483 * Send a request to quiesce a function to the responsible driver. 484 */ 485 static void devman_fun_quiesce(ipc_call_t *icall) 486 { 487 fun_node_t *fun; 488 dev_node_t *child; 489 errno_t rc; 490 491 fun = find_fun_node(&device_tree, ipc_get_arg1(icall)); 492 if (fun == NULL) { 493 async_answer_0(icall, ENOENT); 494 return; 495 } 496 497 fibril_rwlock_read_lock(&device_tree.rwlock); 498 499 /* Check function state */ 500 if (fun->state == FUN_REMOVED) { 501 fibril_rwlock_read_unlock(&device_tree.rwlock); 502 async_answer_0(icall, ENOENT); 503 return; 504 } 505 506 child = fun->child; 507 dev_add_ref(child); 508 fibril_rwlock_read_unlock(&device_tree.rwlock); 509 510 rc = driver_dev_quiesce(&device_tree, child); 511 fun_del_ref(fun); 512 513 async_answer_0(icall, rc); 514 } 515 481 516 /** Find handle for the function instance identified by its service ID. */ 482 517 static void devman_fun_sid_to_handle(ipc_call_t *icall) … … 790 825 devman_fun_offline(&call); 791 826 break; 827 case DEVMAN_FUN_QUIESCE: 828 devman_fun_quiesce(&call); 829 break; 792 830 case DEVMAN_FUN_SID_TO_HANDLE: 793 831 devman_fun_sid_to_handle(&call); -
uspace/srv/devman/driver.c
re494d7b reebecdc 741 741 } 742 742 743 errno_t driver_dev_quiesce(dev_tree_t *tree, dev_node_t *dev) 744 { 745 async_exch_t *exch; 746 errno_t retval; 747 driver_t *drv; 748 devman_handle_t handle; 749 750 assert(dev != NULL); 751 752 log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_dev_quiesce(%p)", dev); 753 754 fibril_rwlock_read_lock(&tree->rwlock); 755 drv = dev->drv; 756 handle = dev->handle; 757 fibril_rwlock_read_unlock(&tree->rwlock); 758 759 exch = async_exchange_begin(drv->sess); 760 retval = async_req_1_0(exch, DRIVER_DEV_QUIESCE, handle); 761 async_exchange_end(exch); 762 763 return retval; 764 } 765 743 766 errno_t driver_dev_gone(dev_tree_t *tree, dev_node_t *dev) 744 767 { -
uspace/srv/devman/driver.h
re494d7b reebecdc 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2013 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 53 53 extern void add_device(driver_t *, dev_node_t *, dev_tree_t *); 54 54 extern errno_t driver_dev_remove(dev_tree_t *, dev_node_t *); 55 extern errno_t driver_dev_quiesce(dev_tree_t *, dev_node_t *); 55 56 extern errno_t driver_dev_gone(dev_tree_t *, dev_node_t *); 56 57 extern errno_t driver_fun_online(dev_tree_t *, fun_node_t *); -
uspace/srv/devman/drv_conn.c
re494d7b reebecdc 444 444 445 445 rc = fun_offline(fun); 446 if (rc != EOK) { 447 fun_busy_unlock(fun); 448 fun_del_ref(fun); 449 async_answer_0(icall, rc); 450 return; 451 } 452 453 fun_busy_unlock(fun); 454 fun_del_ref(fun); 455 async_answer_0(icall, EOK); 456 } 457 458 /** Quiesce function by driver request. 459 * 460 */ 461 static void devman_drv_fun_quiesce(ipc_call_t *icall, driver_t *drv) 462 { 463 fun_node_t *fun; 464 errno_t rc; 465 466 fun = find_fun_node(&device_tree, ipc_get_arg1(icall)); 467 if (fun == NULL) { 468 async_answer_0(icall, ENOENT); 469 return; 470 } 471 472 fun_busy_lock(fun); 473 474 fibril_rwlock_write_lock(&device_tree.rwlock); 475 if (fun->dev == NULL || fun->dev->drv != drv) { 476 fun_busy_unlock(fun); 477 fun_del_ref(fun); 478 async_answer_0(icall, ENOENT); 479 return; 480 } 481 fibril_rwlock_write_unlock(&device_tree.rwlock); 482 483 rc = fun_quiesce(fun); 446 484 if (rc != EOK) { 447 485 fun_busy_unlock(fun); … … 677 715 devman_drv_fun_offline(&call, driver); 678 716 break; 717 case DEVMAN_DRV_FUN_QUIESCE: 718 devman_drv_fun_quiesce(&call, driver); 719 break; 679 720 case DEVMAN_DRV_FUN_WAIT_STABLE: 680 721 devman_drv_fun_wait_stable(&call, driver); -
uspace/srv/devman/fun.c
re494d7b reebecdc 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 4 * All rights reserved. … … 428 429 } 429 430 431 errno_t fun_quiesce(fun_node_t *fun) 432 { 433 errno_t rc; 434 435 log_msg(LOG_DEFAULT, LVL_DEBUG, "fun_quiesce(%s)", fun->pathname); 436 fibril_rwlock_read_lock(&device_tree.rwlock); 437 438 if (fun->state == FUN_OFF_LINE) { 439 fibril_rwlock_read_unlock(&device_tree.rwlock); 440 log_msg(LOG_DEFAULT, LVL_DEBUG, "Function %s is off line.", 441 fun->pathname); 442 return EOK; 443 } 444 445 if (fun->ftype != fun_inner) { 446 /* Nothing to do */ 447 log_msg(LOG_DEFAULT, LVL_DEBUG, "Nothing to do for external " 448 "function %s\n", fun->pathname); 449 fibril_rwlock_read_unlock(&device_tree.rwlock); 450 return EOK; 451 } 452 453 log_msg(LOG_DEFAULT, LVL_DEBUG, "Quiescing inner function %s.", 454 fun->pathname); 455 456 if (fun->child == NULL) { 457 log_msg(LOG_DEFAULT, LVL_DEBUG, "Function %s child is NULL.", 458 fun->pathname); 459 fibril_rwlock_read_unlock(&device_tree.rwlock); 460 return EOK; 461 } 462 463 dev_node_t *dev = fun->child; 464 device_state_t dev_state; 465 466 dev_add_ref(dev); 467 dev_state = dev->state; 468 469 fibril_rwlock_read_unlock(&device_tree.rwlock); 470 471 /* If device is owned by driver, ask driver to quiesce it. */ 472 if (dev_state == DEVICE_USABLE) { 473 log_msg(LOG_DEFAULT, LVL_DEBUG, "Call driver_dev_quiesce() " 474 "for %s.", fun->pathname); 475 rc = driver_dev_quiesce(&device_tree, dev); 476 if (rc != EOK) { 477 log_msg(LOG_DEFAULT, LVL_ERROR, 478 "driver_dev_quiesce() -> %d", (int)rc); 479 dev_del_ref(dev); 480 return ENOTSUP; 481 } 482 } 483 484 dev_del_ref(dev); 485 return EOK; 486 } 487 430 488 /** @} 431 489 */ -
uspace/srv/devman/fun.h
re494d7b reebecdc 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2013 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 51 51 extern errno_t fun_online(fun_node_t *); 52 52 extern errno_t fun_offline(fun_node_t *); 53 extern errno_t fun_quiesce(fun_node_t *); 53 54 54 55 #endif -
uspace/srv/system/system.c
re494d7b reebecdc 35 35 */ 36 36 37 #include <devman.h> 37 38 #include <fibril.h> 38 39 #include <futil.h> … … 48 49 #include <str.h> 49 50 #include <loc.h> 51 #include <shutdown.h> 50 52 #include <str_error.h> 51 53 #include <config.h> … … 84 86 85 87 static void system_srv_conn(ipc_call_t *, void *); 86 static errno_t system_srv_shutdown(void *); 88 static errno_t system_srv_poweroff(void *); 89 static errno_t system_srv_restart(void *); 87 90 88 91 system_ops_t system_srv_ops = { 89 .shutdown = system_srv_shutdown 92 .poweroff = system_srv_poweroff, 93 .restart = system_srv_restart 90 94 }; 91 95 … … 520 524 /* Eject all volumes. */ 521 525 526 log_msg(LOG_DEFAULT, LVL_NOTE, "Ejecting volumes."); 527 522 528 rc = vol_create(&vol); 523 529 if (rc != EOK) { … … 544 550 free(part_ids); 545 551 vol_destroy(vol); 552 546 553 return EOK; 547 554 error: … … 610 617 } 611 618 612 /** System shutdownrequest.619 /** System poweroff request. 613 620 * 614 621 * @param arg Argument (sys_srv_t *) 615 622 */ 616 static errno_t system_srv_ shutdown(void *arg)623 static errno_t system_srv_poweroff(void *arg) 617 624 { 618 625 sys_srv_t *syssrv = (sys_srv_t *)arg; 619 626 errno_t rc; 620 627 621 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_ shutdown");628 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff"); 622 629 623 630 rc = system_sys_shutdown(); 624 631 if (rc != EOK) { 625 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_ shutdownfailed");632 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff failed"); 626 633 system_srv_shutdown_failed(&syssrv->srv); 627 634 } 628 635 629 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown complete"); 636 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff complete"); 637 system_srv_shutdown_complete(&syssrv->srv); 638 return EOK; 639 } 640 641 /** System restart request. 642 * 643 * @param arg Argument (sys_srv_t *) 644 */ 645 static errno_t system_srv_restart(void *arg) 646 { 647 sys_srv_t *syssrv = (sys_srv_t *)arg; 648 errno_t rc; 649 650 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart"); 651 652 rc = system_sys_shutdown(); 653 if (rc != EOK) { 654 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart failed"); 655 system_srv_shutdown_failed(&syssrv->srv); 656 } 657 658 /* Quiesce the device tree. */ 659 660 log_msg(LOG_DEFAULT, LVL_NOTE, "Quiescing devices."); 661 662 rc = devman_quiesce_devices("/hw"); 663 if (rc != EOK) { 664 log_msg(LOG_DEFAULT, LVL_ERROR, 665 "Failed to quiesce device tree."); 666 return rc; 667 } 668 669 sys_reboot(); 670 671 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart complete"); 630 672 system_srv_shutdown_complete(&syssrv->srv); 631 673 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.
