From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935622AbcIGAml (ORCPT ); Tue, 6 Sep 2016 20:42:41 -0400 Received: from mail.kernel.org ([198.145.29.136]:55212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934068AbcIGAmf (ORCPT ); Tue, 6 Sep 2016 20:42:35 -0400 From: "Luis R. Rodriguez" To: ming.lei@canonical.com, akpm@linux-foundation.org, gregkh@linuxfoundation.org Cc: daniel.wagner@bmw-carit.de, mmarek@suse.com, linux-kernel@vger.kernel.org, markivx@codeaurora.org, stephen.boyd@linaro.org, zohar@linux.vnet.ibm.com, broonie@kernel.org, tiwai@suse.de, johannes@sipsolutions.net, chunkeey@googlemail.com, hauke@hauke-m.de, jwboyer@fedoraproject.org, dmitry.torokhov@gmail.com, dwmw2@infradead.org, jslaby@suse.com, torvalds@linux-foundation.org, luto@amacapital.net, fengguang.wu@intel.com, rpurdie@rpsys.net, j.anaszewski@samsung.com, Abhay_Salunke@dell.com, Julia.Lawall@lip6.fr, Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, teg@jklm.no, dhowells@redhat.com, bjorn.andersson@linaro.org, arend.vanspriel@broadcom.com, kvalo@codeaurora.org, "Luis R. Rodriguez" Subject: [PATCH v4 5/5] firmware: fix fw cache to avoid usermode helper on suspend Date: Tue, 6 Sep 2016 17:42:10 -0700 Message-Id: <1473208930-6835-6-git-send-email-mcgrof@kernel.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1473208930-6835-1-git-send-email-mcgrof@kernel.org> References: <1471999507-913-1-git-send-email-mcgrof@kernel.org> <1473208930-6835-1-git-send-email-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The firmware cache purposely kills all non-udev (usermode helper) pending requests prior to suspend with kill_requests_without_uevent() right before it calls out to request for firmware for the fw cache. It is pointless to again run into the possible issue of queing up further usermode helpers during suspend, furthermore its actually buggy to have required the usermode helper in some cases where clearly the driver originally had not wanted that. Fix this by simply using the direct call. This doesn't fix any known bug however if it should be an optimization for suspend/resume. While at it extend documentation to ensure folks of the usermode helper are aware that they must cache the firmware on their own for suspend / resume. v3: patch introduced in this series v4: as per Daniel Wagner since we're removing the usermode helper caller on the cache we can remove the timeout resetting on the cache code now as its is pointless. Signed-off-by: Luis R. Rodriguez --- Documentation/firmware_class/README | 3 +++ drivers/base/firmware_class.c | 16 +--------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Documentation/firmware_class/README b/Documentation/firmware_class/README index 9f8b2daf4c7c..173234005f33 100644 --- a/Documentation/firmware_class/README +++ b/Documentation/firmware_class/README @@ -174,3 +174,6 @@ $ make coccicheck MODE=report resume callback, and callers needn't cache the firmware by themselves any more for dealing with firmware loss during system resume. + +The firmware cache is only for non-user mode helper users. Drivers that +require the usermode helper must deal with caching on their own. diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 22d1760a4278..960f8f7c7aa2 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -1412,7 +1412,7 @@ static int cache_firmware(const char *fw_name) pr_debug("%s: %s\n", __func__, fw_name); - ret = request_firmware(&fw, fw_name, NULL); + ret = request_firmware_direct(&fw, fw_name, NULL); if (!ret) kfree(fw); @@ -1622,7 +1622,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__); @@ -1630,17 +1629,6 @@ 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; - mutex_lock(&fw_lock); fwc->state = FW_LOADER_START_CACHE; dpm_for_each_dev(NULL, dev_cache_fw_image); @@ -1648,8 +1636,6 @@ 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; } /** -- 2.9.2