All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v3 6/8] test_firmware: Add test support for firmware upload
@ 2022-04-19 11:50 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-04-19 11:50 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4737 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220418223753.639058-7-russell.h.weight@intel.com>
References: <20220418223753.639058-7-russell.h.weight@intel.com>
TO: Russ Weight <russell.h.weight@intel.com>
TO: mcgrof(a)kernel.org
TO: rafael(a)kernel.org
TO: linux-kernel(a)vger.kernel.org
CC: trix(a)redhat.com
CC: lgoncalv(a)redhat.com
CC: yilun.xu(a)intel.com
CC: hao.wu(a)intel.com
CC: matthew.gerlach(a)linux.intel.com
CC: basheer.ahmed.muddebihal(a)intel.com
CC: tianfei.zhang(a)intel.com
CC: Russ Weight <russell.h.weight@intel.com>

Hi Russ,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on shuah-kselftest/next mcgrof/sysctl-next linus/master v5.18-rc3 next-20220419]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Russ-Weight/Extend-FW-framework-for-user-FW-uploads/20220419-064126
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 3123109284176b1532874591f7c81f3837bbdc17
:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago
config: powerpc64-randconfig-c003-20220418 (https://download.01.org/0day-ci/archive/20220419/202204191900.1DwwOU9L-lkp(a)intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


cocci warnings: (new ones prefixed by >>)
>> lib/test_firmware.c:1291:5-8: ERROR: invalid reference to the index variable of the iterator on line 1287

vim +1291 lib/test_firmware.c

c92316bf8e94830a Luis R. Rodriguez 2017-07-20  1273  
cb4d12e8d7596410 Russ Weight       2022-04-18  1274  static ssize_t upload_read_show(struct device *dev,
cb4d12e8d7596410 Russ Weight       2022-04-18  1275  				struct device_attribute *attr,
cb4d12e8d7596410 Russ Weight       2022-04-18  1276  				char *buf)
cb4d12e8d7596410 Russ Weight       2022-04-18  1277  {
cb4d12e8d7596410 Russ Weight       2022-04-18  1278  	struct test_firmware_upload *tst;
cb4d12e8d7596410 Russ Weight       2022-04-18  1279  	int ret = -EINVAL;
cb4d12e8d7596410 Russ Weight       2022-04-18  1280  
cb4d12e8d7596410 Russ Weight       2022-04-18  1281  	if (!test_fw_config->upload_name) {
cb4d12e8d7596410 Russ Weight       2022-04-18  1282  		pr_err("Set config_upload_name before using upload_read\n");
cb4d12e8d7596410 Russ Weight       2022-04-18  1283  		return -EINVAL;
cb4d12e8d7596410 Russ Weight       2022-04-18  1284  	}
cb4d12e8d7596410 Russ Weight       2022-04-18  1285  
cb4d12e8d7596410 Russ Weight       2022-04-18  1286  	mutex_lock(&test_fw_mutex);
cb4d12e8d7596410 Russ Weight       2022-04-18 @1287  	list_for_each_entry(tst, &test_upload_list, node)
cb4d12e8d7596410 Russ Weight       2022-04-18  1288  		if (tst->name == test_fw_config->upload_name)
cb4d12e8d7596410 Russ Weight       2022-04-18  1289  			break;
cb4d12e8d7596410 Russ Weight       2022-04-18  1290  
cb4d12e8d7596410 Russ Weight       2022-04-18 @1291  	if (tst->name != test_fw_config->upload_name) {
cb4d12e8d7596410 Russ Weight       2022-04-18  1292  		pr_err("Firmware name not found: %s\n",
cb4d12e8d7596410 Russ Weight       2022-04-18  1293  		       test_fw_config->upload_name);
cb4d12e8d7596410 Russ Weight       2022-04-18  1294  		goto out;
cb4d12e8d7596410 Russ Weight       2022-04-18  1295  	}
cb4d12e8d7596410 Russ Weight       2022-04-18  1296  
cb4d12e8d7596410 Russ Weight       2022-04-18  1297  	if (tst->size > PAGE_SIZE) {
cb4d12e8d7596410 Russ Weight       2022-04-18  1298  		pr_err("Testing interface must use PAGE_SIZE firmware for now\n");
cb4d12e8d7596410 Russ Weight       2022-04-18  1299  		goto out;
cb4d12e8d7596410 Russ Weight       2022-04-18  1300  	}
cb4d12e8d7596410 Russ Weight       2022-04-18  1301  
cb4d12e8d7596410 Russ Weight       2022-04-18  1302  	memcpy(buf, tst->buf, tst->size);
cb4d12e8d7596410 Russ Weight       2022-04-18  1303  	ret = tst->size;
cb4d12e8d7596410 Russ Weight       2022-04-18  1304  out:
cb4d12e8d7596410 Russ Weight       2022-04-18  1305  	mutex_unlock(&test_fw_mutex);
cb4d12e8d7596410 Russ Weight       2022-04-18  1306  	return ret;
cb4d12e8d7596410 Russ Weight       2022-04-18  1307  }
cb4d12e8d7596410 Russ Weight       2022-04-18  1308  static DEVICE_ATTR_RO(upload_read);
cb4d12e8d7596410 Russ Weight       2022-04-18  1309  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [PATCH v3 0/8] Extend FW framework for user FW uploads
@ 2022-04-18 22:37 Russ Weight
  2022-04-18 22:37 ` [PATCH v3 6/8] test_firmware: Add test support for firmware upload Russ Weight
  0 siblings, 1 reply; 2+ messages in thread
From: Russ Weight @ 2022-04-18 22:37 UTC (permalink / raw)
  To: mcgrof, rafael, linux-kernel
  Cc: trix, lgoncalv, yilun.xu, hao.wu, matthew.gerlach,
	basheer.ahmed.muddebihal, tianfei.zhang, Russ Weight

Extend the firmware loader subsystem to support a persistent sysfs
interface that userspace may use to initiate a firmware update. For
example, FPGA based PCIe cards automatically load firmware and FPGA images
from local FLASH when the card boots. The images in FLASH may be updated
with new images that are uploaded by the user.

A device driver may call firmware_upload_register() to expose persistent
"loading" and "data" sysfs files at /sys/class/firmare/<NAME>/*. These
files are used in the same way as the fallback sysfs "loading" and "data"
files. However, when 0 is written to "loading" to complete the write of
firmware data, the data is also transferred to the lower-level driver
using pre-registered call-back functions. The data transfer is done in
the context of a kernel worker thread.

Additional sysfs nodes are added in the same location as "loading" and
"data" to monitor the transfer of the image data to the device using
callback functions provided by the lower-level device driver and to allow
the data transfer to be cancelled.

Example usage:

$ pwd
/sys/class/firmware/secure-update.1
$ ls
cancel  device  loading  remaining_size  subsystem
data    error   power    status          uevent
$ echo 1 > loading
$ cat /tmp/firmware.bin > data
$ echo 0 > loading
$ while :; do cat status; cat remaining_size ; sleep 3; done
preparing
44590080
<--snip-->
transferring
44459008
transferring
44311552
<--snip-->
transferring
173056
<--snip-->
programming
0
<--snip-->
idle
0
^C
$ cat error

The first two patches in this set make minor changes to enable the
fw_priv data structure and the sysfs interfaces to be used multiple times
during the existence of the device driver instance. The third patch is
mostly a reorganization of existing code in preparation for sharing common
code with the firmware-upload support. The fourth and fifth patches provide
the code for user-initiated firmware uploads. The final 3 patches extend
selftest support to test firmware-upload functionality.


Changelog v2 -> v3:
  - Added Reviewed-by tag
  - Added kdoc support for enum fw_upload_prog progress codes

Changelog v1 -> v2:
  - Rebased to 5.18-rc2.
  - It was discovered that the new function in v1, fw_state_is_done(), is
    equivalent to the existing fw_sysfs_done() function. Renamed
    fw_sysfs_done() and fw_sysfs_loading() to fw_state_is_done() and
    fw_state_is_loading() respectively, and placed them along side companion
    functions in drivers/base/firmware_loader/firmware.h.
  - Removed the "if !fw_sysfs_done(fw_priv))" condition in switch case 1 of
    firmware_loading_store(). It is rendered unnecessary by other changes
    to the function.
  - Updated documentation Date and KernelVersion fields to July 2022
    and 5.19.
  - Unconditionally set fw_priv->is_paged_buf to true in
    firmware_upload_register();

Changelog RFC -> v1:
  - Renamed files fw_sysfs.c and fw_sysfs.h to sysfs.c and sysfs.h
  - Moved "MODULE_IMPORT_NS(FIRMWARE_LOADER_PRIVATE);" from sysfs.c to
    sysfs.h to address an error identified by the kernel test robot
    <lkp@intel.com>
  - renamed fw_upload_register() and fw_upload_unregister() to
    firmware_upload_register() and fw_upload_unregister().
  - Moved ifdef'd section of code out of firmware_loading_store() in sysfs.c
    into a new function, fw_upload_start(), in sysfs_upload.c.
  - Changed #defines to enums for error codes and progress states
  - Added additional kernel-doc supported symbols into the documentation.
    Some rewording in documentation as well.
  - Added module reference counting for the parent module in the
    firmware_upload_register() and firmware_upload_unregister() functions
    to fix problems found when testing with test_firmware module.
  - Removed unnecessary module reference counting for THIS_MODULE.
  - Added a new patch to modify the test_firmware module to support
    testing of the firmware upload mechanism.
  - Added a new patch to modify the test_firmware module to support
    error injection for firmware upload.
  - Added a new patch to extend the existing firmware selftests to cover
    firmware upload.

Russ Weight (8):
  firmware_loader: Clear data and size in fw_free_paged_buf
  firmware_loader: Check fw_state_is_done in loading_store
  firmware_loader: Split sysfs support from fallback
  firmware_loader: Add firmware-upload support
  firmware_loader: Add sysfs nodes to monitor fw_upload
  test_firmware: Add test support for firmware upload
  test_firmware: Error injection for firmware upload
  selftests: firmware: Add firmware upload selftests

 .../ABI/testing/sysfs-class-firmware          |  77 ++++
 .../driver-api/firmware/fw_upload.rst         | 126 +++++
 Documentation/driver-api/firmware/index.rst   |   1 +
 drivers/base/firmware_loader/Kconfig          |  18 +
 drivers/base/firmware_loader/Makefile         |   2 +
 drivers/base/firmware_loader/fallback.c       | 430 ------------------
 drivers/base/firmware_loader/fallback.h       |  46 +-
 drivers/base/firmware_loader/firmware.h       |  16 +
 drivers/base/firmware_loader/main.c           |  18 +-
 drivers/base/firmware_loader/sysfs.c          | 423 +++++++++++++++++
 drivers/base/firmware_loader/sysfs.h          | 100 ++++
 drivers/base/firmware_loader/sysfs_upload.c   | 397 ++++++++++++++++
 drivers/base/firmware_loader/sysfs_upload.h   |  54 +++
 include/linux/firmware.h                      |  82 ++++
 lib/test_firmware.c                           | 378 +++++++++++++++
 tools/testing/selftests/firmware/Makefile     |   2 +-
 tools/testing/selftests/firmware/config       |   1 +
 tools/testing/selftests/firmware/fw_lib.sh    |   7 +
 .../selftests/firmware/fw_run_tests.sh        |   4 +
 tools/testing/selftests/firmware/fw_upload.sh | 214 +++++++++
 20 files changed, 1910 insertions(+), 486 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-firmware
 create mode 100644 Documentation/driver-api/firmware/fw_upload.rst
 create mode 100644 drivers/base/firmware_loader/sysfs.c
 create mode 100644 drivers/base/firmware_loader/sysfs.h
 create mode 100644 drivers/base/firmware_loader/sysfs_upload.c
 create mode 100644 drivers/base/firmware_loader/sysfs_upload.h
 create mode 100755 tools/testing/selftests/firmware/fw_upload.sh

-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-19 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 11:50 [PATCH v3 6/8] test_firmware: Add test support for firmware upload kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-04-18 22:37 [PATCH v3 0/8] Extend FW framework for user FW uploads Russ Weight
2022-04-18 22:37 ` [PATCH v3 6/8] test_firmware: Add test support for firmware upload Russ Weight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.