diff --git a/src/dpusm.c b/src/dpusm.c index 712f6f7..fd65b59 100644 --- a/src/dpusm.c +++ b/src/dpusm.c @@ -77,7 +77,7 @@ dpusm_init(void) { static void __exit dpusm_exit(void) { - mutex_lock(&dpusm.lock); + while (mutex_lock_interruptible(&dpusm.lock)); const int active = atomic_read(&dpusm.active); if (unlikely(active)) { diff --git a/src/provider.c b/src/provider.c index f2d7022..d77fab7 100644 --- a/src/provider.c +++ b/src/provider.c @@ -265,19 +265,19 @@ dpusm_provider_register(dpusm_t *dpusm, struct module *module, const dpusm_pf_t return -EINVAL; } - mutex_lock(&dpusm->lock);; + while (mutex_lock_interruptible(&dpusm->lock)); dpusm_ph_t **found = find_provider(dpusm, module_name(module)); if (found) { printk("%s: DPUSM Provider with the name \"%s\" (%p) already exists. %zu providers registered.\n", __func__, module_name(module), *found, dpusm->count); - mutex_unlock(&dpusm->lock);; + mutex_unlock(&dpusm->lock); return -EEXIST; } dpusm_ph_t *provider = dpusmph_init(module, funcs); if (!provider) { - mutex_unlock(&dpusm->lock);; + mutex_unlock(&dpusm->lock); return -ECANCELED; } @@ -286,7 +286,7 @@ dpusm_provider_register(dpusm_t *dpusm, struct module *module, const dpusm_pf_t printk("%s: DPUSM Provider \"%s\" (%p) added. Now %zu providers registered.\n", __func__, module_name(module), provider, dpusm->count); - mutex_unlock(&dpusm->lock);; + mutex_unlock(&dpusm->lock); return 0; } @@ -320,12 +320,12 @@ dpusm_provider_unregister_handle(dpusm_t *dpusm, dpusm_ph_t **provider) { int dpusm_provider_unregister(dpusm_t *dpusm, struct module *module) { - mutex_lock(&dpusm->lock);; + while (mutex_lock_interruptible(&dpusm->lock)); dpusm_ph_t **provider = find_provider(dpusm, module_name(module)); if (!provider) { printk("%s: Could not find provider with name \"%s\"\n", __func__, module_name(module)); - mutex_unlock(&dpusm->lock);; + mutex_unlock(&dpusm->lock); return DPUSM_ERROR; } @@ -333,7 +333,7 @@ dpusm_provider_unregister(dpusm_t *dpusm, struct module *module) { const int rc = dpusm_provider_unregister_handle(dpusm, provider); printk("%s: Unregistered \"%s\" (%p): %d\n", __func__, module_name(module), addr, rc); - mutex_unlock(&dpusm->lock);; + mutex_unlock(&dpusm->lock); return rc; } @@ -345,7 +345,7 @@ dpusm_provider_unregister(dpusm_t *dpusm, struct module *module) { /* get a provider by name */ dpusm_ph_t ** dpusm_provider_get(dpusm_t *dpusm, const char *name) { - mutex_lock(&dpusm->lock); + while (mutex_lock_interruptible(&dpusm->lock)); dpusm_ph_t **provider = find_provider(dpusm, name); if (provider) { struct module *module = (*provider)->module; @@ -405,7 +405,7 @@ dpusm_provider_put(dpusm_t *dpusm, void *handle) { } void dpusm_provider_invalidate(dpusm_t *dpusm, const char *name) { - mutex_lock(&dpusm->lock);; + while (mutex_lock_interruptible(&dpusm->lock)); dpusm_ph_t **provider = find_provider(dpusm, name); if (provider && *provider) { (*provider)->funcs = NULL; @@ -418,5 +418,5 @@ void dpusm_provider_invalidate(dpusm_t *dpusm, const char *name) { printk("%s: Error: Did not find provider \"%s\"\n", __func__, name); } - mutex_unlock(&dpusm->lock);; + mutex_unlock(&dpusm->lock); }