Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp278809ybl; Fri, 23 Aug 2019 00:21:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEpQD/jqdCQQELjER5wGVXRgAU1W8k7AQopmlir9azrvRm/k5y2WD7+ME4V1H+ncgX2wZg X-Received: by 2002:a17:902:988d:: with SMTP id s13mr3018120plp.139.1566544910324; Fri, 23 Aug 2019 00:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566544910; cv=none; d=google.com; s=arc-20160816; b=RqbpFk+F4DK5jIuT/xLvxOzW+PpvyvSv8LJUjUfPwpvZIBuqEt5WB2aPn7rL9dq5zZ YV+xd1S5T2tJSCS72TNZPWSGKWrJc9JplpNPKEvpluSxWPywSr+NxLJOq0tLjxvW1uVE gJdGazKGVc2Ro+dA9r7beKw6Z3NZkNNZQGsymnGWc1ZRk0TtOOLl11kZ7PKcmuREQEtt wysibBcb1FN70jhFxS8zt4IY3KZmUUo2LQ/PXihhYdeyNCQiOVbjQbvTWYf8B+ste0cY TmIpePqCI4gWMkIXFdTjCtAOsFz2Ba/62VlYio75xyobirxO/wab0vrxBiCYG06Ihu+h CTRw== 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:dkim-signature; bh=IA8z/5AqtCHFT32SY+cIXSmPc0kaoD29PlyZ57NhalY=; b=HRYcSklMWwukUIgjbg6ti/JU2cju994+dMwm8t1TDleiOjOeENKtkMbpucPX1Ntcn5 OYjzjnkkIHwde69RgPYxoz/6LVJvWAduFVId9EC2+aP6VdT0Gb6BV8dmtoWiI2L5lTSk ylV3/2AFW0oO0L6ST/xNM63hKEuW2I7pyb112b/ZBjGdgfK+SOZP0Fv2CcwkRaclidAk ahWBEtedT3816mOzLUitSoX/BBMFQGsFAtpAc9VEfXS/LWWryAljr5dDKAALJ9fKNmZh GdsYgRnRixX4Bk1Es1HJh+xHcV/kC8mF5MgFh43GXh5daSVLU6rl1ZH41Wulwm7eIWWx Ah9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=BgB5KJgR; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si1943911pfg.26.2019.08.23.00.21.34; Fri, 23 Aug 2019 00:21:50 -0700 (PDT) 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; dkim=pass header.i=@broadcom.com header.s=google header.b=BgB5KJgR; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391011AbfHVSkg (ORCPT + 99 others); Thu, 22 Aug 2019 14:40:36 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34230 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390954AbfHVSk1 (ORCPT ); Thu, 22 Aug 2019 14:40:27 -0400 Received: by mail-pf1-f193.google.com with SMTP id b24so4550516pfp.1 for ; Thu, 22 Aug 2019 11:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IA8z/5AqtCHFT32SY+cIXSmPc0kaoD29PlyZ57NhalY=; b=BgB5KJgRI2OAMFO3lQmNArPftpDtD+nVUiJaoL/PL/14HemQ//f8oXX5mmTLwZrVeM UpdaOWdFUaGyxjitCmu4G6tGH22q5Ilv8GjvfFNAiukCsGLnKENYAmgPzQfNG76hKWON znl1GkmY7IAARq4+4slXfINLE8Of4Aji/+3EU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IA8z/5AqtCHFT32SY+cIXSmPc0kaoD29PlyZ57NhalY=; b=O9LxkzLfHhOsKKAwmR1cJRr+IJUm+Dc/i0L5/ymXf37fNaQwC1o1z6vVNb250bhmE3 IZYzVRwqRbZd/51KM9WXYHE/CUfC7gdsWx9Rk5vg6tYONq8BKLOwAfglA8UrIEXEPuDm FDMqE7wd8P4ENfDujB8pxA9BLtipMT3zRjCaIC7PIyiGk9Dv7xy/YTx3zv28/nR0TMjy epNbjhKDKG1hpIcFVkPaAj/Y2RAS62nc4V52i1E4aSxNmAz8XA2lI+KDzzFCugUi8tLY uG0BJe1uQ+YllRYfeGR3ddpk15lb2F5Y04hkSCUhs3SAx1SK5wCeiVUokAPm5xI/1hw6 SNZg== X-Gm-Message-State: APjAAAVO1WGFYzmHx7jD9X6vvN/o3OoyNWhuY9FVuQQeid7+UoPyt24V rTqavA081B0mn4OMvaQOmQdULw== X-Received: by 2002:a17:90a:86c2:: with SMTP id y2mr1144374pjv.46.1566499226035; Thu, 22 Aug 2019 11:40:26 -0700 (PDT) Received: from lbrmn-lnxub113.broadcom.net ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id z19sm51056pgv.35.2019.08.22.11.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 11:40:25 -0700 (PDT) From: Scott Branden To: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org Cc: "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Scott Branden Subject: [PATCH v2 2/2] selftests: firmware: Add request_firmware_into_buf tests Date: Thu, 22 Aug 2019 11:40:05 -0700 Message-Id: <20190822184005.901-3-scott.branden@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190822184005.901-1-scott.branden@broadcom.com> References: <20190822184005.901-1-scott.branden@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add tests cases for checking request_firmware_into_buf api. API was introduced into kernel with no testing present previously. Signed-off-by: Scott Branden Acked-by: Luis Chamberlain Acked-by: Shuah Khan --- .../selftests/firmware/fw_filesystem.sh | 57 ++++++++++++++++++- tools/testing/selftests/firmware/fw_lib.sh | 11 ++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index f901076aa2ea..56894477c8bd 100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh @@ -116,6 +116,16 @@ config_set_name() echo -n $1 > $DIR/config_name } +config_set_into_buf() +{ + echo 1 > $DIR/config_into_buf +} + +config_unset_into_buf() +{ + echo 0 > $DIR/config_into_buf +} + config_set_sync_direct() { echo 1 > $DIR/config_sync_direct @@ -153,11 +163,14 @@ config_set_read_fw_idx() read_firmwares() { - if [ "$1" = "xzonly" ]; then - fwfile="${FW}-orig" + if [ "$(cat $DIR/config_into_buf)" == "1" ]; then + fwfile="$FW_INTO_BUF" else fwfile="$FW" fi + if [ "$1" = "xzonly" ]; then + fwfile="${fwfile}-orig" + fi for i in $(seq 0 3); do config_set_read_fw_idx $i # Verify the contents are what we expect. @@ -194,6 +207,18 @@ test_batched_request_firmware_nofile() echo "OK" } +test_batched_request_firmware_into_buf_nofile() +{ + echo -n "Batched request_firmware_into_buf() nofile try #$1: " + config_reset + config_set_name nope-test-firmware.bin + config_set_into_buf + config_trigger_sync + read_firmwares_expect_nofile + release_all_firmware + echo "OK" +} + test_batched_request_firmware_direct_nofile() { echo -n "Batched request_firmware_direct() nofile try #$1: " @@ -259,6 +284,18 @@ test_batched_request_firmware() echo "OK" } +test_batched_request_firmware_into_buf() +{ + echo -n "Batched request_firmware_into_buf() $2 try #$1: " + config_reset + config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME + config_set_into_buf + config_trigger_sync + read_firmwares $2 + release_all_firmware + echo "OK" +} + test_batched_request_firmware_direct() { echo -n "Batched request_firmware_direct() $2 try #$1: " @@ -307,6 +344,10 @@ for i in $(seq 1 5); do test_batched_request_firmware $i normal done +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf $i normal +done + for i in $(seq 1 5); do test_batched_request_firmware_direct $i normal done @@ -327,6 +368,10 @@ for i in $(seq 1 5); do test_batched_request_firmware_nofile $i done +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_nofile $i +done + for i in $(seq 1 5); do test_batched_request_firmware_direct_nofile $i done @@ -350,6 +395,10 @@ for i in $(seq 1 5); do test_batched_request_firmware $i both done +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf $i both +done + for i in $(seq 1 5); do test_batched_request_firmware_direct $i both done @@ -370,6 +419,10 @@ for i in $(seq 1 5); do test_batched_request_firmware $i xzonly done +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf $i xzonly +done + for i in $(seq 1 5); do test_batched_request_firmware_direct $i xzonly done diff --git a/tools/testing/selftests/firmware/fw_lib.sh b/tools/testing/selftests/firmware/fw_lib.sh index f236cc295450..b879305a766d 100755 --- a/tools/testing/selftests/firmware/fw_lib.sh +++ b/tools/testing/selftests/firmware/fw_lib.sh @@ -9,6 +9,12 @@ DIR=/sys/devices/virtual/misc/test_firmware PROC_CONFIG="/proc/config.gz" TEST_DIR=$(dirname $0) +# We need to load a different file to test request_firmware_into_buf +# I believe the issue is firmware loaded cached vs. non-cached +# with same filename is bungled. +# To reproduce rename this to test-firmware.bin +TEST_FIRMWARE_INTO_BUF_FILENAME=test-firmware-into-buf.bin + # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 @@ -108,6 +114,8 @@ setup_tmp_file() FWPATH=$(mktemp -d) FW="$FWPATH/test-firmware.bin" echo "ABCD0123" >"$FW" + FW_INTO_BUF="$FWPATH/$TEST_FIRMWARE_INTO_BUF_FILENAME" + echo "EFGH4567" >"$FW_INTO_BUF" NAME=$(basename "$FW") if [ "$TEST_REQS_FW_SET_CUSTOM_PATH" = "yes" ]; then echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path @@ -175,6 +183,9 @@ test_finish() if [ -f $FW ]; then rm -f "$FW" fi + if [ -f $FW_INTO_BUF ]; then + rm -f "$FW_INTO_BUF" + fi if [ -d $FWPATH ]; then rm -rf "$FWPATH" fi -- 2.17.1