diff mbox series

[net-next,v3] firmware_loader: Expand Firmware upload error codes with firmware invalid error

Message ID 20231122-feature_firmware_error_code-v3-1-04ec753afb71@bootlin.com (mailing list archive)
State Accepted
Commit a066f906ba396ab00d4af19fc5fad42b2605582a
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] firmware_loader: Expand Firmware upload error codes with firmware invalid error | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3523 this patch: 3523
netdev/cc_maintainers warning 2 maintainers not CCed: dan.carpenter@linaro.org mirsad.todorovac@alu.unizg.hr
netdev/build_clang success Errors and warnings before: 1364 this patch: 1364
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3900 this patch: 3900
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Kory Maincent Nov. 22, 2023, 1:52 p.m. UTC
No error code are available to signal an invalid firmware content.
Drivers that can check the firmware content validity can not return this
specific failure to the user-space

Expand the firmware error code with an additional code:
- "firmware invalid" code which can be used when the provided firmware
  is invalid

Sync lib/test_firmware.c file accordingly.

Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

Changes in v3:
- Add the newly introduced error code to test_firmware.c

This patch was initially submitted as part of a net patch series.
Conor expressed interest in using it in a different subsystem.
https://lore.kernel.org/netdev/20231116-feature_poe-v1-7-be48044bf249@bootlin.com/

Consequently, I extracted it from the series and submitted it separately.
I first tried to send it to driver-core but it seems also not the best
choice:
https://lore.kernel.org/lkml/2023111720-slicer-exes-7d9f@gregkh/

Jakub could you create a stable branch for this patch and share the branch
information? This way other Maintainers can then pull the patch.
---
 drivers/base/firmware_loader/sysfs_upload.c | 1 +
 include/linux/firmware.h                    | 2 ++
 lib/test_firmware.c                         | 1 +
 3 files changed, 4 insertions(+)


---
base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86
change-id: 20231117-feature_firmware_error_code-b8d7af08a8fe

Best regards,

Comments

Simon Horman Nov. 24, 2023, 4:48 p.m. UTC | #1
On Wed, Nov 22, 2023 at 02:52:43PM +0100, Kory Maincent wrote:
> No error code are available to signal an invalid firmware content.
> Drivers that can check the firmware content validity can not return this
> specific failure to the user-space
> 
> Expand the firmware error code with an additional code:
> - "firmware invalid" code which can be used when the provided firmware
>   is invalid
> 
> Sync lib/test_firmware.c file accordingly.
> 
> Acked-by: Luis Chamberlain <mcgrof@kernel.org>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
> 
> Changes in v3:
> - Add the newly introduced error code to test_firmware.c

I verified that the error obvserved in v2 when compiling the above
file with clang-16 has been resolved.

Link: https://lore.kernel.org/all/20231121173022.3cb2fcad@kernel.org/

Reviewed-by: Simon Horman <horms@kernel.org>

...
Jakub Kicinski Nov. 25, 2023, 3:24 a.m. UTC | #2
On Wed, 22 Nov 2023 14:52:43 +0100 Kory Maincent wrote:
> Jakub could you create a stable branch for this patch and share the branch
> information? This way other Maintainers can then pull the patch.

Tagged at:

git://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git firmware_loader-add-upload-error
patchwork-bot+netdevbpf@kernel.org Nov. 25, 2023, 3:30 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 22 Nov 2023 14:52:43 +0100 you wrote:
> No error code are available to signal an invalid firmware content.
> Drivers that can check the firmware content validity can not return this
> specific failure to the user-space
> 
> Expand the firmware error code with an additional code:
> - "firmware invalid" code which can be used when the provided firmware
>   is invalid
> 
> [...]

Here is the summary with links:
  - [net-next,v3] firmware_loader: Expand Firmware upload error codes with firmware invalid error
    https://git.kernel.org/netdev/net-next/c/a066f906ba39

You are awesome, thank you!
Kory Maincent Nov. 27, 2023, 6:35 p.m. UTC | #4
On Fri, 24 Nov 2023 19:24:07 -0800
Jakub Kicinski <kuba@kernel.org> wrote:

> On Wed, 22 Nov 2023 14:52:43 +0100 Kory Maincent wrote:
> > Jakub could you create a stable branch for this patch and share the branch
> > information? This way other Maintainers can then pull the patch.  
> 
> Tagged at:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git
> firmware_loader-add-upload-error

Thank Jakub!
Conor Dooley Dec. 6, 2023, 12:04 p.m. UTC | #5
On Fri, Nov 24, 2023 at 07:24:07PM -0800, Jakub Kicinski wrote:
> On Wed, 22 Nov 2023 14:52:43 +0100 Kory Maincent wrote:
> > Jakub could you create a stable branch for this patch and share the branch
> > information? This way other Maintainers can then pull the patch.
> 
> Tagged at:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git firmware_loader-add-upload-error

It's taken me longer than I would like to get back to this, sorry.
I tried pulling the tag today and I think there's been a mistake - the
tagged commit is the merge commit into net, not the commit adding the
firmware loader change:

commit 53775da0b4768cd7e603d7ac1ad706c383c6f61e (tag: firmware_loader-add-upload-error, korg-kuba/firmware_loader)
Merge: 3a767b482cac a066f906ba39
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri Nov 24 18:09:19 2023 -0800

    Merge branch 'firmware_loader'

commit a066f906ba396ab00d4af19fc5fad42b2605582a
Author: Kory Maincent <kory.maincent@bootlin.com>
Date:   Wed Nov 22 14:52:43 2023 +0100

    firmware_loader: Expand Firmware upload error codes with firmware invalid error

I'm going to merge in a066f906ba39 ("firmware_loader: Expand Firmware
upload error codes with firmware invalid error") so that I don't end
up with a bunch of netdev stuff in my tree.

Have I missed something?

Thanks,
Conor.
Jakub Kicinski Dec. 6, 2023, 3:47 p.m. UTC | #6
On Wed, 6 Dec 2023 12:04:33 +0000 Conor Dooley wrote:
> It's taken me longer than I would like to get back to this, sorry.
> I tried pulling the tag today and I think there's been a mistake - the
> tagged commit is the merge commit into net, not the commit adding the
> firmware loader change:
> 
> commit 53775da0b4768cd7e603d7ac1ad706c383c6f61e (tag: firmware_loader-add-upload-error, korg-kuba/firmware_loader)
> Merge: 3a767b482cac a066f906ba39
> Author: Jakub Kicinski <kuba@kernel.org>
> Date:   Fri Nov 24 18:09:19 2023 -0800
> 
>     Merge branch 'firmware_loader'
> 
> commit a066f906ba396ab00d4af19fc5fad42b2605582a
> Author: Kory Maincent <kory.maincent@bootlin.com>
> Date:   Wed Nov 22 14:52:43 2023 +0100
> 
>     firmware_loader: Expand Firmware upload error codes with firmware invalid error
> 
> I'm going to merge in a066f906ba39 ("firmware_loader: Expand Firmware
> upload error codes with firmware invalid error") so that I don't end
> up with a bunch of netdev stuff in my tree.
> 
> Have I missed something?

You're right, looks like I tagged the wrong thing.
Merging a066f906ba39 will work, sorry!
diff mbox series

Patch

diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/firmware_loader/sysfs_upload.c
index a0af8f5f13d8..829270067d16 100644
--- a/drivers/base/firmware_loader/sysfs_upload.c
+++ b/drivers/base/firmware_loader/sysfs_upload.c
@@ -27,6 +27,7 @@  static const char * const fw_upload_err_str[] = {
 	[FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size",
 	[FW_UPLOAD_ERR_RW_ERROR]     = "read-write-error",
 	[FW_UPLOAD_ERR_WEAROUT]	     = "flash-wearout",
+	[FW_UPLOAD_ERR_FW_INVALID]   = "firmware-invalid",
 };
 
 static const char *fw_upload_progress(struct device *dev,
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index de7fea3bca51..0311858b46ce 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -27,6 +27,7 @@  struct firmware {
  * @FW_UPLOAD_ERR_INVALID_SIZE: invalid firmware image size
  * @FW_UPLOAD_ERR_RW_ERROR: read or write to HW failed, see kernel log
  * @FW_UPLOAD_ERR_WEAROUT: FLASH device is approaching wear-out, wait & retry
+ * @FW_UPLOAD_ERR_FW_INVALID: invalid firmware file
  * @FW_UPLOAD_ERR_MAX: Maximum error code marker
  */
 enum fw_upload_err {
@@ -38,6 +39,7 @@  enum fw_upload_err {
 	FW_UPLOAD_ERR_INVALID_SIZE,
 	FW_UPLOAD_ERR_RW_ERROR,
 	FW_UPLOAD_ERR_WEAROUT,
+	FW_UPLOAD_ERR_FW_INVALID,
 	FW_UPLOAD_ERR_MAX
 };
 
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index add4699fc6cd..9cfdcd6d21db 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -1132,6 +1132,7 @@  static const char * const fw_upload_err_str[] = {
 	[FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size",
 	[FW_UPLOAD_ERR_RW_ERROR]     = "read-write-error",
 	[FW_UPLOAD_ERR_WEAROUT]	     = "flash-wearout",
+	[FW_UPLOAD_ERR_FW_INVALID]   = "firmware-invalid",
 };
 
 static void upload_err_inject_error(struct test_firmware_upload *tst,