Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp274090ybl; Thu, 15 Aug 2019 17:10:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwosfjoFqWlrQe0v+2orwqA95GcFJYlN1sGhLLfWne9qOArDvSphJaYWmVBG/NVADmNB4fb X-Received: by 2002:a63:1:: with SMTP id 1mr5419715pga.162.1565914249802; Thu, 15 Aug 2019 17:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565914249; cv=none; d=google.com; s=arc-20160816; b=XK3tCvNjOwc2HaZ91zkLWIQhTZS5BUkQSb25bQux+2o/Yk/hdBAgh0npvLdVQXpU/c YZhxKapFPmXqwWfY5lc6hBamQ46rI5gtt39mtDCd44N56BN7fQN5spi3Ww9WYPJQFUfX s5RqT8QyEbRLiWJgLSFh09+1CMKe8qob3G1VBW4l1moWJB94iZkpvkWHtbLKX836egVM 7Gvbz7DqonNSXdsQUc+kNqbi1Nxh9KRQifD9FNtxaVaUqgZxq5XUSk2L0o1xZwnKFAFF 7lG7jYYCdeaNkxGtGMIhOQPk3zL1+yMeeTEhfZtutAWJWdMniyVGtTTerIaff3kaY62o iiig== 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=QdO+KVP1+sss46fGBNGuzASBMGiLUw4LDdShHVqVS8g=; b=h78t4mBMdHbgN+ugmlgPwSxLP5Sdbs3voRAeQbfFX9fgmKx0WonZwnDIu+yjAG1yiq DDdaAZ1WphoCk0acPAlAYDpe9ZmJcNOaSMYTa+gLyu/yBmOWjLp5CBlmSUBGVXWGPZIo TyxjQq4wNaXh8lwe8qSuN1hXvFTFU+ibk6tjQ+vVK1eWNeaLHQ4Sx1uMQjy42fb7pCFt 9NJ10aByYmu2FijhxJ1DOggOc/fI/iGVfB+sqg/8dHD1IdfL+CrS44wW9CLdWP/f4Dy8 mKEsEnCIUNqtNrRmqTKxm1CAYjGCSEVOrgNehS210iNYWlazmPtAU+hOxU1+ei90pia+ Qfng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=SiGOxa4o; 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 e23si2635268pgv.528.2019.08.15.17.10.33; Thu, 15 Aug 2019 17:10:49 -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=SiGOxa4o; 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 S1726357AbfHPAJ6 (ORCPT + 99 others); Thu, 15 Aug 2019 20:09:58 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46074 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725983AbfHPAJ4 (ORCPT ); Thu, 15 Aug 2019 20:09:56 -0400 Received: by mail-pf1-f193.google.com with SMTP id w26so2135427pfq.12 for ; Thu, 15 Aug 2019 17:09:56 -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=QdO+KVP1+sss46fGBNGuzASBMGiLUw4LDdShHVqVS8g=; b=SiGOxa4oChRUrJQDP/9WW9hEK3Q7GEDfzQioPwOA4DoanEr7H9XLhn3g4CCzTNjEbR QKg7ZhjgONqSMIffm8B2BmBOv+ICZjEv1O+9dICsOZiFfZgsi7r2pt9T/FS9S9tMq+Tf 4aOvx45ebDQyuYGew9Aw/jjLKO8/yufhC6IuI= 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=QdO+KVP1+sss46fGBNGuzASBMGiLUw4LDdShHVqVS8g=; b=cOZAd74xJZiWQCB6XxxdDJGLvBi8Ccb5aVeNbHmHdoYqc350y/110urhBrFgxYRPaH lWT/GSO676eFNz1mStIDIqT4t0k7VTlCYbNyGIfrhTPq4OqVZEOpX7JbOGfnos8vP5gX a65/OBGpOxIBirOEO5G6nN3lnVxbYeDhgdbPNvIQiL5QU4WFzno5IW9JyATynD19jlL8 hzzPOUjE2CEbB9RUZ0W+of4r7WKp4ovMFO2UDNKqdBusI2vzhW5tjTiLNsYe4QPv0aPR UdEQq4nKoGN1yti3am1Xr4oImfKtrZjcctgUSjh4w8w3jytD9jo+iQp9Cigz69MOofKi q5gQ== X-Gm-Message-State: APjAAAW1lrRWMx6A/bVyTwSO4y1eT/QCJgmoqUTklBco6Gadzl6bbm+X NLEGH8qwhiuiMz9FDcrrPA4YzA== X-Received: by 2002:aa7:97aa:: with SMTP id d10mr8052048pfq.176.1565914196045; Thu, 15 Aug 2019 17:09:56 -0700 (PDT) Received: from lbrmn-lnxub113.broadcom.net ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id g2sm4056916pfi.26.2019.08.15.17.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 17:09:55 -0700 (PDT) From: Scott Branden To: Luis Chamberlain , Greg Kroah-Hartman , Andy Gross , 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 1/3] test_firmware: add support for request_firmware_into_buf Date: Thu, 15 Aug 2019 17:09:43 -0700 Message-Id: <20190816000945.29810-2-scott.branden@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190816000945.29810-1-scott.branden@broadcom.com> References: <20190816000945.29810-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 test config into_buf to allow request_firmware_into_buf to be called instead of request_firmware/request_firmware_direct. The number of parameters differ calling request_firmware_into_buf and support has not been added to test such api in test_firmware until now. Signed-off-by: Scott Branden --- lib/test_firmware.c | 50 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/lib/test_firmware.c b/lib/test_firmware.c index 6ca97a63b3d6..1aa430228ae6 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #define TEST_FIRMWARE_NAME "test-firmware.bin" #define TEST_FIRMWARE_NUM_REQS 4 +#define TEST_FIRMWARE_BUF_SIZE SZ_1K static DEFINE_MUTEX(test_fw_mutex); static const struct firmware *test_firmware; @@ -45,6 +47,8 @@ struct test_batched_req { * test_config - represents configuration for the test for different triggers * * @name: the name of the firmware file to look for + * @into_buf: when the into_buf is used if this is true + * request_firmware_into_buf() will be used instead. * @sync_direct: when the sync trigger is used if this is true * request_firmware_direct() will be used instead. * @send_uevent: whether or not to send a uevent for async requests @@ -83,6 +87,7 @@ struct test_batched_req { */ struct test_config { char *name; + bool into_buf; bool sync_direct; bool send_uevent; u8 num_requests; @@ -176,6 +181,7 @@ static int __test_firmware_config_init(void) test_fw_config->num_requests = TEST_FIRMWARE_NUM_REQS; test_fw_config->send_uevent = true; + test_fw_config->into_buf = false; test_fw_config->sync_direct = false; test_fw_config->req_firmware = request_firmware; test_fw_config->test_result = 0; @@ -244,6 +250,9 @@ static ssize_t config_show(struct device *dev, test_fw_config->send_uevent ? "FW_ACTION_HOTPLUG" : "FW_ACTION_NOHOTPLUG"); + len += scnprintf(buf+len, PAGE_SIZE - len, + "into_buf:\t\t%s\n", + test_fw_config->into_buf ? "true" : "false"); len += scnprintf(buf+len, PAGE_SIZE - len, "sync_direct:\t\t%s\n", test_fw_config->sync_direct ? "true" : "false"); @@ -393,6 +402,23 @@ static ssize_t config_num_requests_show(struct device *dev, } static DEVICE_ATTR_RW(config_num_requests); +static ssize_t config_into_buf_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + return test_dev_config_update_bool(buf, + count, + &test_fw_config->into_buf); +} + +static ssize_t config_into_buf_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return test_dev_config_show_bool(buf, test_fw_config->into_buf); +} +static DEVICE_ATTR_RW(config_into_buf); + static ssize_t config_sync_direct_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -522,7 +548,7 @@ static ssize_t trigger_async_request_store(struct device *dev, rc = count; } else { pr_err("failed to async load firmware\n"); - rc = -ENODEV; + rc = -ENOMEM; } out: @@ -585,7 +611,26 @@ static int test_fw_run_batch_request(void *data) return -EINVAL; } - req->rc = test_fw_config->req_firmware(&req->fw, req->name, req->dev); + if (test_fw_config->into_buf) { + void *test_buf; + + test_buf = kzalloc(TEST_FIRMWARE_BUF_SIZE, GFP_KERNEL); + if (!test_buf) + return -ENOSPC; + + req->rc = request_firmware_into_buf(&req->fw, + req->name, + req->dev, + test_buf, + TEST_FIRMWARE_BUF_SIZE); + if (!req->fw) + kfree(test_buf); + } else { + req->rc = test_fw_config->req_firmware(&req->fw, + req->name, + req->dev); + } + if (req->rc) { pr_info("#%u: batched sync load failed: %d\n", req->idx, req->rc); @@ -849,6 +894,7 @@ static struct attribute *test_dev_attrs[] = { TEST_FW_DEV_ATTR(config), TEST_FW_DEV_ATTR(config_name), TEST_FW_DEV_ATTR(config_num_requests), + TEST_FW_DEV_ATTR(config_into_buf), TEST_FW_DEV_ATTR(config_sync_direct), TEST_FW_DEV_ATTR(config_send_uevent), TEST_FW_DEV_ATTR(config_read_fw_idx), -- 2.17.1