Received: by 10.223.185.116 with SMTP id b49csp1420212wrg; Fri, 23 Feb 2018 18:48:56 -0800 (PST) X-Google-Smtp-Source: AH8x2241JVxKxWpmpN8y8ZwIYs2x5uGx7jKN5WAxiXTzeBn6kz5KjZU0BGoOyrDH+O83pOZeyGQc X-Received: by 10.99.117.26 with SMTP id q26mr3089490pgc.46.1519440536257; Fri, 23 Feb 2018 18:48:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519440536; cv=none; d=google.com; s=arc-20160816; b=WvZRn0xvuhppW2YK/aIRc7ZWGg6+EVnycVmfB3ql+UdVMDx0oYSnK6REGm+iPDEWrM ii2U7KNNtUSjM5u2soZ9cd4oZIAbB0Wr1JAQvd6QLl0Sy/v658KAkr+OGhdpoe5COCvh JuxT05Zy2J2j7VDwSTOWSOqo/dYznQzBNaqDHU50nV/srwDl+kh6bbAEVMHs8eG1Li3U wiKSNzOaQRgDuFIsWhXc+9C+tHjJkiYhIg1vUDh8zxwPZWMZxRbaQ1yf1MARe23tAg+f S0IXV8cWEWbfDG1/JQvKEhNWOi79awnOT/QAQxfqDq9eCj5h/lTmgm/H7jClHZHQRwq5 khoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=OJ9oLOCTche13eUmPma6vKjfv98wmzd0WEodHhAgIms=; b=LdXEh5yS5zq59QIDCJMPOophISe49OWLvTA1bgbtQTwPskW1ittqVVT/a94rDYy380 /d24+kbrBsXWxjwBMMpdZjEY1iYT0zi/t0GoMfGrwkTdFZbiewYOwr4smKObmGThgwfB OpRlWQrK77Ubox0WFsUM0N+HiyLyuZQHBtRWAaOJ8I7mZGG2GM7ijGnjWyDprZy0Pata 6h+WLqq4bAqARpIXgnf2fEKh1iqCMW0WSLhii8OBomdwN5k+OozvOHgBjVTa15v7vKVF ZDKbwwYFH87pBAQ+zBTJZ6o2WioOtrEUw/YunoZO+Qj3gIYd3sLmsSGbURmx+EknEkFk I4vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si2811173pfj.124.2018.02.23.18.48.42; Fri, 23 Feb 2018 18:48:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752607AbeBXCq3 (ORCPT + 99 others); Fri, 23 Feb 2018 21:46:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:48662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbeBXCqW (ORCPT ); Fri, 23 Feb 2018 21:46:22 -0500 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9EFDC217CA; Sat, 24 Feb 2018 02:46:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EFDC217CA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org Cc: akpm@linux-foundation.org, keescook@chromium.org, shuah@kernel.org, mfuzzey@parkeon.com, zohar@linux.vnet.ibm.com, dhowells@redhat.com, pali.rohar@gmail.com, tiwai@suse.de, arend.vanspriel@broadcom.com, zajec5@gmail.com, nbroeking@me.com, markivx@codeaurora.org, stephen.boyd@linaro.org, broonie@kernel.org, dmitry.torokhov@gmail.com, dwmw2@infradead.org, torvalds@linux-foundation.org, Abhay_Salunke@dell.com, bjorn.andersson@linaro.org, jewalt@lgsinnovations.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v2 05/11] firmware: use helpers for setting up a temporary cache timeout Date: Fri, 23 Feb 2018 18:46:07 -0800 Message-Id: <20180224024613.24078-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20180224024613.24078-1-mcgrof@kernel.org> References: <20180224024613.24078-1-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We only use the timeout for the firmware fallback mechanism except for trying to set the timeout during the cache setup for resume/suspend. For those cases, setting the timeout should be a no-op, so just reflect this in code by adding helpers for it. This change introduces no functional changes. Signed-off-by: Luis R. Rodriguez --- drivers/base/firmware_loader.c | 49 ++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/base/firmware_loader.c b/drivers/base/firmware_loader.c index 59dba794ce1a..2d819875348d 100644 --- a/drivers/base/firmware_loader.c +++ b/drivers/base/firmware_loader.c @@ -191,13 +191,6 @@ static inline bool fw_is_builtin_firmware(const struct firmware *fw) } #endif -static int loading_timeout = 60; /* In seconds */ - -static inline long firmware_loading_timeout(void) -{ - return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET; -} - static void fw_state_init(struct fw_priv *fw_priv) { struct fw_state *fw_st = &fw_priv->fw_st; @@ -282,6 +275,32 @@ static const struct firmware_fallback_config fw_fallback_config = { .force_sysfs_fallback = IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK), }; +static int old_timeout; +static int loading_timeout = 60; /* In seconds */ + +static inline long firmware_loading_timeout(void) +{ + return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET; +} + +/* + * use small loading timeout for caching devices' firmware because all these + * firmware images have been loaded successfully at lease once, also system is + * ready for completing firmware loading now. The maximum size of firmware in + * current distributions is about 2M bytes, so 10 secs should be enough. + */ +static void fw_fallback_set_cache_timeout(void) +{ + old_timeout = loading_timeout; + loading_timeout = 10; +} + +/* Restores the timeout to the value last configured during normal operation */ +static void fw_fallback_set_default_timeout(void) +{ + loading_timeout = old_timeout; +} + static inline bool fw_sysfs_done(struct fw_priv *fw_priv) { return __fw_state_check(fw_priv, FW_STATUS_DONE); @@ -1206,6 +1225,8 @@ static int fw_sysfs_fallback(struct firmware *fw, const char *name, } static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { } +static inline void fw_fallback_set_cache_timeout(void) { } +static inline void fw_fallback_set_default_timeout(void) { } static inline int register_sysfs_loader(void) { @@ -1752,7 +1773,6 @@ static void __device_uncache_fw_images(void) static void device_cache_fw_images(void) { struct firmware_cache *fwc = &fw_cache; - int old_timeout; DEFINE_WAIT(wait); pr_debug("%s\n", __func__); @@ -1760,16 +1780,7 @@ static void device_cache_fw_images(void) /* cancel uncache work */ cancel_delayed_work_sync(&fwc->work); - /* - * use small loading timeout for caching devices' firmware - * because all these firmware images have been loaded - * successfully at lease once, also system is ready for - * completing firmware loading now. The maximum size of - * firmware in current distributions is about 2M bytes, - * so 10 secs should be enough. - */ - old_timeout = loading_timeout; - loading_timeout = 10; + fw_fallback_set_cache_timeout(); mutex_lock(&fw_lock); fwc->state = FW_LOADER_START_CACHE; @@ -1779,7 +1790,7 @@ static void device_cache_fw_images(void) /* wait for completion of caching firmware for all devices */ async_synchronize_full_domain(&fw_cache_domain); - loading_timeout = old_timeout; + fw_fallback_set_default_timeout(); } /** -- 2.16.2