From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>, shuah@kernel.org
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>,
akpm@linux-foundation.org, keescook@chromium.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
Subject: Re: [PATCH v2 16/23] test_firmware: enable custom fallback testing on limited kernel configs
Date: Thu, 30 Nov 2017 21:31:58 +0100 [thread overview]
Message-ID: <20171130203158.GM729@wotan.suse.de> (raw)
In-Reply-To: <20171129102235.GB11522@kroah.com>
On Wed, Nov 29, 2017 at 11:22:35AM +0100, Greg KH wrote:
> On Mon, Nov 20, 2017 at 10:24:02AM -0800, Luis R. Rodriguez wrote:
> > 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 <mcgrof@kernel.org>
> > ---
> > 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
> > +}
>
> Shouldn't these functions be part of the kselftest core so that all
> tests can take advantage of them instead of having to hand-roll them for
> every individual test?
At a first glance it would seem to be nice.
Note that in our case we'd still need a way to work without CONFIG_IKCONFIG_PROC,
hence that big else condition, to ensure it works for kernels without
CONFIG_IKCONFIG_PROC set, so we'd still end up with our own fw_kconfig_has(),
and if we had a generic helper it'd look very similar... something like:
fw_kconfig_has()
{
if [ has_proc_config ]; then
echo $(kconfig_has("$1"))
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
}
Not sure if there is a big gain then for now.
Shuah, what do you think? Is it worth it? Do we have a generic bash library we
can use? If not, if I add one, so that other scripts can source it, where
should I add it?
> And is there no way at runtime to tell what the options are and just
> not run that type of test?
For CONFIG_FW_LOADER_USER_HELPER=y yes, its handled in that else condition.
For CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y though no, there is no way. The
else condition has a big comment indicating there is no current *easy*
run time heuristic possible. This remains true specially since we have to
support these scripts to run on older kernels as well.
Luis
next prev parent reply other threads:[~2017-11-30 20:32 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 18:23 [PATCH v2 00/23] firmware: cleanup for v4.16 Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 01/23] firmware: rename struct firmware_priv to struct fw_sysfs Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 02/23] firmware: rename struct firmware_buf to struct fw_priv Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 03/23] firmware: rename struct fw_priv->fw_id to fw_name Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 04/23] firmware: move core data structures to the top of file Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 05/23] firmware: remove duplicate fw_state_aborted() Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 06/23] firmware: remove unused __fw_state_is_done() Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 07/23] firmware: use static inlines for state machine checking Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 08/23] firmware: rename sysfs state checks with sysfs prefix Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 09/23] firmware: use static inline for to_fw_priv() Luis R. Rodriguez
2017-11-29 10:14 ` Greg KH
2017-11-20 18:23 ` [PATCH v2 10/23] firmware: add helper to copy built-in data to pre-alloc buffer Luis R. Rodriguez
2017-11-29 10:17 ` Greg KH
2017-11-30 20:18 ` Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 11/23] firmware: provide helper for FW_OPT_USERHELPER Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 12/23] firmware: replace #ifdef over FW_OPT_FALLBACK with function checks Luis R. Rodriguez
2017-11-20 18:23 ` [PATCH v2 13/23] test_firmware: wrap sysfs timeout test into helper Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 14/23] test_firmware: wrap basic sysfs fallback tests " Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 15/23] test_firmware: wrap custom sysfs load " Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 16/23] test_firmware: enable custom fallback testing on limited kernel configs Luis R. Rodriguez
2017-11-29 10:20 ` Greg KH
2017-11-29 10:22 ` Greg KH
2017-11-30 20:31 ` Luis R. Rodriguez [this message]
2017-11-30 21:40 ` Shuah Khan
2017-11-29 10:28 ` Greg KH
2017-11-20 18:24 ` [PATCH v2 17/23] test_firmware: replace syfs fallback check with kconfig_has helper Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 18/23] firmware: enable to split firmware_class into separate target files Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 19/23] firmware: add debug facility to emulate forcing sysfs fallback Luis R. Rodriguez
2017-11-29 10:28 ` Greg KH
2017-11-30 20:35 ` Luis R. Rodriguez
2017-11-30 23:54 ` Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 20/23] firmware: add debug facility to emulate disabling " Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 21/23] test_firmware: add a library for shared helpers Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 22/23] test_firmware: test the 3 firmware kernel configs using debugfs Luis R. Rodriguez
2017-11-20 18:24 ` [PATCH v2 23/23] firmware: cleanup - group and document up private firmware parameters Luis R. Rodriguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171130203158.GM729@wotan.suse.de \
--to=mcgrof@kernel.org \
--cc=Abhay_Salunke@dell.com \
--cc=akpm@linux-foundation.org \
--cc=arend.vanspriel@broadcom.com \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=dhowells@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=jewalt@lgsinnovations.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markivx@codeaurora.org \
--cc=mfuzzey@parkeon.com \
--cc=nbroeking@me.com \
--cc=pali.rohar@gmail.com \
--cc=shuah@kernel.org \
--cc=stephen.boyd@linaro.org \
--cc=tiwai@suse.de \
--cc=torvalds@linux-foundation.org \
--cc=zajec5@gmail.com \
--cc=zohar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome