lkml.org 
[lkml]   [2013]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/3] firmware: Avoid superfluous usermodehelper lock
    Date
    When a firmware file can be loaded directly, there is no good reason
    to lock usermodehelper. It's needed only when the direct fw load
    fails and falls back to the user-mode helper.

    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    ---
    drivers/base/firmware_class.c | 42 +++++++++++++++++++++++-------------------
    1 file changed, 23 insertions(+), 19 deletions(-)

    diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
    index 4b1f926..9e1d39e 100644
    --- a/drivers/base/firmware_class.c
    +++ b/drivers/base/firmware_class.c
    @@ -1006,7 +1006,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
    struct device *device, bool uevent, bool nowait)
    {
    struct firmware *fw;
    - long timeout;
    + bool usermode_locked = false;
    int ret;

    if (!firmware_p)
    @@ -1017,31 +1017,35 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
    goto out;

    ret = 0;
    - timeout = firmware_loading_timeout();
    - if (nowait) {
    - timeout = usermodehelper_read_lock_wait(timeout);
    - if (!timeout) {
    - dev_dbg(device, "firmware: %s loading timed out\n",
    - name);
    - ret = -EBUSY;
    - goto out;
    - }
    - } else {
    - ret = usermodehelper_read_trylock();
    - if (WARN_ON(ret)) {
    - dev_err(device, "firmware: %s will not be loaded\n",
    - name);
    - goto out;
    + if (!fw_get_filesystem_firmware(device, fw->priv)) {
    + long timeout = firmware_loading_timeout();
    + if (nowait) {
    + timeout = usermodehelper_read_lock_wait(timeout);
    + if (!timeout) {
    + dev_dbg(device, "firmware: %s loading timed out\n",
    + name);
    + ret = -EBUSY;
    + goto out;
    + }
    + } else {
    + ret = usermodehelper_read_trylock();
    + if (WARN_ON(ret)) {
    + dev_err(device, "firmware: %s will not be loaded\n",
    + name);
    + goto out;
    + }
    }
    - }

    - if (!fw_get_filesystem_firmware(device, fw->priv))
    + usermode_locked = true;
    ret = fw_load_from_user_helper(fw, name, device,
    uevent, nowait, timeout);
    + }
    +
    if (!ret)
    ret = assign_firmware_buf(fw, device);

    - usermodehelper_read_unlock();
    + if (usermode_locked)
    + usermodehelper_read_unlock();

    out:
    if (ret < 0) {
    --
    1.8.2.1


    \
     
     \ /
      Last update: 2013-05-08 09:41    [W:2.800 / U:0.352 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site