Commit 7d4b5d7a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

async: Introduce async_schedule_dev_nocall()

In preparation for subsequent changes, introduce a specialized variant
of async_schedule_dev() that will not invoke the argument function
synchronously when it cannot be scheduled for asynchronous execution.

The new function, async_schedule_dev_nocall(), will be used for fixing
possible deadlocks in the system-wide power management core code.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> for the series.
Tested-by: default avatarYoungmin Nam <youngmin.nam@samsung.com>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 6aa09a5b
...@@ -90,6 +90,8 @@ async_schedule_dev(async_func_t func, struct device *dev) ...@@ -90,6 +90,8 @@ async_schedule_dev(async_func_t func, struct device *dev)
return async_schedule_node(func, dev, dev_to_node(dev)); return async_schedule_node(func, dev, dev_to_node(dev));
} }
bool async_schedule_dev_nocall(async_func_t func, struct device *dev);
/** /**
* async_schedule_dev_domain - A device specific version of async_schedule_domain * async_schedule_dev_domain - A device specific version of async_schedule_domain
* @func: function to execute asynchronously * @func: function to execute asynchronously
......
...@@ -243,6 +243,35 @@ async_cookie_t async_schedule_node(async_func_t func, void *data, int node) ...@@ -243,6 +243,35 @@ async_cookie_t async_schedule_node(async_func_t func, void *data, int node)
} }
EXPORT_SYMBOL_GPL(async_schedule_node); EXPORT_SYMBOL_GPL(async_schedule_node);
/**
* async_schedule_dev_nocall - A simplified variant of async_schedule_dev()
* @func: function to execute asynchronously
* @dev: device argument to be passed to function
*
* @dev is used as both the argument for the function and to provide NUMA
* context for where to run the function.
*
* If the asynchronous execution of @func is scheduled successfully, return
* true. Otherwise, do nothing and return false, unlike async_schedule_dev()
* that will run the function synchronously then.
*/
bool async_schedule_dev_nocall(async_func_t func, struct device *dev)
{
struct async_entry *entry;
entry = kzalloc(sizeof(struct async_entry), GFP_KERNEL);
/* Give up if there is no memory or too much work. */
if (!entry || atomic_read(&entry_count) > MAX_WORK) {
kfree(entry);
return false;
}
__async_schedule_node_domain(func, dev, dev_to_node(dev),
&async_dfl_domain, entry);
return true;
}
/** /**
* async_synchronize_full - synchronize all asynchronous function calls * async_synchronize_full - synchronize all asynchronous function calls
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment