Received: by 10.223.185.116 with SMTP id b49csp1422762wrg; Fri, 23 Feb 2018 18:52:36 -0800 (PST) X-Google-Smtp-Source: AH8x226FKynamXC6JsOfRBRPHO5ea6ItKGp3lGGGsC+Imdofk4J0hUuXjIkGJTRWKZxDLxp9fhGY X-Received: by 2002:a17:902:5682:: with SMTP id j2-v6mr3581473pli.441.1519440756889; Fri, 23 Feb 2018 18:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519440756; cv=none; d=google.com; s=arc-20160816; b=QgwHbw5zZ8zu3lLJSBzTHaNepyFwnCw4hM06wrT92klE0o1dpYj0jLOwjXvvuQ5+sO 41ZQ/gBGxPJ0JfZPKN+N3t5NOOrjtO9Sdl2mMywyUT0WW15HzOEjlJutj21/XwrT4ZB+ 5UEERvsKX/mP8Rs+Lvgt5ClOe509QfBdO8VZO1f8AGKu8ONiAT7+8maShyDZ8K14idVo eHqA3mvt2fCXtFh08bYuKrIsmHfxs2WF74kJY2rQdzZgOzgj2qpio2Vt+FL1v+5r8QH6 5Kou1oOhzvQUc/a0ikZSKBrwPc/5w0TgvwTsiI9Bi+rNDpEDtV3s+fgYPo5bhbEc56gS x6Rw== 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=2qUHSU3bw3S0q/LjYbDyATn/valvJNw8YqxkumtocpY=; b=OunkQ5T/jQYh09Qf9Zgt7ZmY6HYpL8HnvNVZ9A+PWJRfDyTdc9UR2iQbr5xd2t42yD VrgdpDWejhpxvVVQe1hp0h+aMLL5p64qJ54w0l+p9bL6A8n3TH2m32bzEKPUpXuSo6i6 +pNn4DqjLlreBASJkl7impBv236TdIai1AK8R0fWzpZixpc6cfEQLZO1BDxvHqcS75VJ WCqVKSIbC0iaqpdhFIemdP+JP5o51O+0GZGRSuKYqhvSxd390Lrj7bAdCf/1c5lnAqaO LXLfNjkaZzkOl0RR7fkG/3+ig8oEAOefrvJSzj54eLiimvrLmIfAo89AkWax4b/KsVvc AybA== 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 s2si2328490pgo.23.2018.02.23.18.52.22; Fri, 23 Feb 2018 18:52:36 -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 S1752912AbeBXCtc (ORCPT + 99 others); Fri, 23 Feb 2018 21:49:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:48444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752768AbeBXCqR (ORCPT ); Fri, 23 Feb 2018 21:46:17 -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 924D2217AD; Sat, 24 Feb 2018 02:46:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 924D2217AD 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 01/11] test_firmware: enable custom fallback testing on limited kernel configs Date: Fri, 23 Feb 2018 18:46:03 -0800 Message-Id: <20180224024613.24078-2-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 When a kernel is not built with: CONFIG_HAS_FW_LOADER_USER_HELPER_FALLBACK=y We don't currently enable testing fw_fallback.sh. For kernels that still enable the fallback mechanism, its possible to use the async request firmware API call request_firmware_nowait() using the custom interface to use the fallback mechanism, so we should be able to test this but we currently cannot. We can enable testing without CONFIG_HAS_FW_LOADER_USER_HELPER_FALLBACK=y by relying on /proc/config.gz (CONFIG_IKCONFIG_PROC), if present. If you don't have this we'll have no option but to rely on old heuristics for now. Signed-off-by: Luis R. Rodriguez --- tools/testing/selftests/firmware/config | 4 +++ tools/testing/selftests/firmware/fw_fallback.sh | 45 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/firmware/config b/tools/testing/selftests/firmware/config index c8137f70e291..bf634dda0720 100644 --- a/tools/testing/selftests/firmware/config +++ b/tools/testing/selftests/firmware/config @@ -1 +1,5 @@ CONFIG_TEST_FIRMWARE=y +CONFIG_FW_LOADER=y +CONFIG_FW_LOADER_USER_HELPER=y +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y diff --git a/tools/testing/selftests/firmware/fw_fallback.sh b/tools/testing/selftests/firmware/fw_fallback.sh index 722cad91df74..a42e437363d9 100755 --- a/tools/testing/selftests/firmware/fw_fallback.sh +++ b/tools/testing/selftests/firmware/fw_fallback.sh @@ -6,7 +6,46 @@ # won't find so that we can do the load ourself manually. set -e +PROC_CONFIG="/proc/config.gz" +TEST_DIR=$(dirname $0) + modprobe test_firmware +if [ ! -f $PROC_CONFIG ]; then + if modprobe configs 2>/dev/null; then + echo "Loaded configs module" + if [ ! -f $PROC_CONFIG ]; then + echo "You must have the following enabled in your kernel:" >&2 + cat $TEST_DIR/config >&2 + echo "Resorting to old heuristics" >&2 + fi + else + echo "Failed to load configs module, using old heuristics" >&2 + fi +fi + +kconfig_has() +{ + if [ -f $PROC_CONFIG ]; then + if zgrep -q $1 $PROC_CONFIG 2>/dev/null; then + echo "yes" + else + echo "no" + fi + else + # We currently don't have easy heuristics to infer this + # so best we can do is just try to use the kernel assuming + # you had enabled it. This matches the old behaviour. + if [ "$1" = "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y" ]; then + echo "yes" + elif [ "$1" = "CONFIG_FW_LOADER_USER_HELPER=y" ]; then + if [ -d /sys/class/firmware/ ]; then + echo yes + else + echo no + fi + fi + fi +} DIR=/sys/devices/virtual/misc/test_firmware @@ -14,6 +53,7 @@ DIR=/sys/devices/virtual/misc/test_firmware # These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that # as an indicator for CONFIG_FW_LOADER_USER_HELPER. HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi) +HAS_FW_LOADER_USER_HELPER_FALLBACK=$(kconfig_has CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y) if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) @@ -286,7 +326,10 @@ run_sysfs_custom_load_tests() fi } -run_sysfs_main_tests +if [ "$HAS_FW_LOADER_USER_HELPER_FALLBACK" = "yes" ]; then + run_sysfs_main_tests +fi + run_sysfs_custom_load_tests exit 0 -- 2.16.2