Changeset 8300c72 in mainline for uspace/lib/drv/generic/driver.c


Ignore:
Timestamp:
2025-03-03T22:58:05Z (13 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
77a0119
Parents:
f35749e
Message:

Quiesce devices before proceeding with shutdown.

Only implemented for e1k, uhci and xhci.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    rf35749e r8300c72  
    237237}
    238238
     239static void driver_dev_quiesce(ipc_call_t *icall)
     240{
     241        devman_handle_t devh = ipc_get_arg1(icall);
     242        ddf_fun_t *fun;
     243        link_t *link;
     244
     245        fibril_mutex_lock(&devices_mutex);
     246        ddf_dev_t *dev = driver_get_device(devh);
     247        if (dev != NULL)
     248                dev_add_ref(dev);
     249        fibril_mutex_unlock(&devices_mutex);
     250
     251        if (dev == NULL) {
     252                async_answer_0(icall, ENOENT);
     253                return;
     254        }
     255
     256        errno_t rc;
     257
     258        if (driver->driver_ops->dev_quiesce != NULL) {
     259                rc = driver->driver_ops->dev_quiesce(dev);
     260        } else {
     261                /*
     262                 * If the driver does not implement quiesce, we will
     263                 * simply request all subordinate functions to quiesce.
     264                 */
     265                fibril_mutex_lock(&functions_mutex);
     266                link = list_first(&functions);
     267                while (link != NULL) {
     268                        fun = list_get_instance(link, ddf_fun_t, link);
     269                        if (fun->dev == dev)
     270                                ddf_fun_quiesce(fun);
     271                        link = list_next(link, &functions);
     272                }
     273                fibril_mutex_unlock(&functions_mutex);
     274                rc = EOK;
     275        }
     276
     277        dev_del_ref(dev);
     278        async_answer_0(icall, rc);
     279}
     280
    239281static void driver_fun_online(ipc_call_t *icall)
    240282{
     
    357399                case DRIVER_DEV_GONE:
    358400                        driver_dev_gone(&call);
     401                        break;
     402                case DRIVER_DEV_QUIESCE:
     403                        driver_dev_quiesce(&call);
    359404                        break;
    360405                case DRIVER_FUN_ONLINE:
     
    903948}
    904949
     950/** Quiesce function.
     951 *
     952 * @param fun Function to quiesce
     953 *
     954 * @return EOK on success or an error code
     955 *
     956 */
     957errno_t ddf_fun_quiesce(ddf_fun_t *fun)
     958{
     959        assert(fun->bound == true);
     960
     961        errno_t res = devman_drv_fun_quiesce(fun->handle);
     962        if (res != EOK)
     963                return res;
     964
     965        return EOK;
     966}
     967
    905968/** Add single match ID to inner function.
    906969 *
Note: See TracChangeset for help on using the changeset viewer.