* [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5
@ 2024-12-03 13:55 Théo Lebrun
2024-12-03 13:55 ` [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config Théo Lebrun
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
Hi,
This series is two-fold.
- First some cleanup to nvmem/rmem.
[PATCH 2/6] nvmem: specify ->reg_read/reg_write() expected return values
[PATCH 3/6] nvmem: rmem: make ->reg_read() straight forward code
[PATCH 4/6] nvmem: rmem: remove unused struct rmem::size field
Those patches were sent on the 2024-07-24 [0] and saw no feedback.
There are small improvements to the commit messages but the commit
bodies stayed the same. I did not label this as V2 as the EyeQ5
compatible (see below) wasn't part of V1, and I wouldn't want people
to think it has been through a round of lkml review.
- Second, add a new compatible to rmem for the EyeQ5-specific usecase;
it parses a header and does checksumming at probe.
[PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config
[PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
[PATCH 6/6] MIPS: mobileye: eyeq5: add bootloader config reserved memory
Code is tested on real hardware, an EyeQ5 evaluation board.
Have a nice day,
Thanks,
Théo
[0]: https://lore.kernel.org/lkml/20240724-nvmem-rmem-v1-0-d2e3a97349a0@bootlin.com/
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
Théo Lebrun (6):
dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config
nvmem: specify ->reg_read/reg_write() expected return values
nvmem: rmem: make ->reg_read() straight forward code
nvmem: rmem: remove unused struct rmem::size field
nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
MIPS: mobileye: eyeq5: add bootloader config reserved memory
Documentation/devicetree/bindings/nvmem/rmem.yaml | 1 +
arch/mips/boot/dts/mobileye/eyeq5.dtsi | 22 ++++++
drivers/nvmem/rmem.c | 95 ++++++++++++++++++++---
include/linux/nvmem-provider.h | 4 +-
4 files changed, 110 insertions(+), 12 deletions(-)
---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241203-rmem-15df9301cf0b
Best regards,
--
Théo Lebrun <theo.lebrun@bootlin.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
@ 2024-12-03 13:55 ` Théo Lebrun
2024-12-04 15:08 ` Rob Herring (Arm)
2024-12-03 13:55 ` [PATCH 2/6] nvmem: specify ->reg_read/reg_write() expected return values Théo Lebrun
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
On Mobileye EyeQ5, the bootloader will put MAC addresses into memory.
Declare that as reserved memory to be used by the kernel, exposing
nvmem cells. That region has a 12-byte header and a 4-byte trailing CRC.
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
Documentation/devicetree/bindings/nvmem/rmem.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/nvmem/rmem.yaml b/Documentation/devicetree/bindings/nvmem/rmem.yaml
index 1ec0d09bcafa857c05ae722834c9e13bf63ee851..85f9f5de3906d2f1afce74ce001cf5db06e50806 100644
--- a/Documentation/devicetree/bindings/nvmem/rmem.yaml
+++ b/Documentation/devicetree/bindings/nvmem/rmem.yaml
@@ -16,6 +16,7 @@ properties:
compatible:
items:
- enum:
+ - mobileye,eyeq5-bootloader-config
- raspberrypi,bootloader-config
- raspberrypi,bootloader-public-key
- const: nvmem-rmem
--
2.47.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/6] nvmem: specify ->reg_read/reg_write() expected return values
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
2024-12-03 13:55 ` [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config Théo Lebrun
@ 2024-12-03 13:55 ` Théo Lebrun
2024-12-03 13:55 ` [PATCH 3/6] nvmem: rmem: make ->reg_read() straight forward code Théo Lebrun
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
Both ->reg_read() and ->reg_write() return values are not easy to
deduce. Explicit that they should return zero on success (and negative
values otherwise).
Such callbacks, in some alternative world, could return the number of
bytes in the success case. That would be translated to errors in the
nvmem core because of checks like:
ret = nvmem->reg_write(nvmem->priv, offset, val, bytes);
if (ret) {
// error case
}
This mistake is not just theoretical, see commit
28b008751aa2 ("nvmem: rmem: Fix return value of rmem_read()").
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
include/linux/nvmem-provider.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 3ebeaa0ded00c8d12230e5be7eed045a89a82669..515676ebe59875fa0ab8a4e772542bdc90ead8e3 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -92,8 +92,8 @@ struct nvmem_cell_info {
* @read_only: Device is read-only.
* @root_only: Device is accessibly to root only.
* @of_node: If given, this will be used instead of the parent's of_node.
- * @reg_read: Callback to read data.
- * @reg_write: Callback to write data.
+ * @reg_read: Callback to read data; return zero if successful.
+ * @reg_write: Callback to write data; return zero if successful.
* @size: Device size.
* @word_size: Minimum read/write access granularity.
* @stride: Minimum read/write access stride.
--
2.47.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/6] nvmem: rmem: make ->reg_read() straight forward code
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
2024-12-03 13:55 ` [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config Théo Lebrun
2024-12-03 13:55 ` [PATCH 2/6] nvmem: specify ->reg_read/reg_write() expected return values Théo Lebrun
@ 2024-12-03 13:55 ` Théo Lebrun
2024-12-03 13:55 ` [PATCH 4/6] nvmem: rmem: remove unused struct rmem::size field Théo Lebrun
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
memory_read_from_buffer() is a weird choice; it:
- is made for iteration with ppos a pointer.
- does futile error checking in our case.
- does NOT ensure we read exactly N bytes.
Replace it by:
1. A check that (offset + bytes) lands inside the region and,
2. a plain memcpy().
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/nvmem/rmem.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c
index 7f907c5a445e7865c8626e00362df0040fe52241..0dc5c8237c7538efe4597c182d7bdb709b945851 100644
--- a/drivers/nvmem/rmem.c
+++ b/drivers/nvmem/rmem.c
@@ -21,10 +21,10 @@ static int rmem_read(void *context, unsigned int offset,
void *val, size_t bytes)
{
struct rmem *priv = context;
- size_t available = priv->mem->size;
- loff_t off = offset;
void *addr;
- int count;
+
+ if ((phys_addr_t)offset + bytes > priv->mem->size)
+ return -EIO;
/*
* Only map the reserved memory at this point to avoid potential rogue
@@ -36,20 +36,17 @@ static int rmem_read(void *context, unsigned int offset,
* An alternative would be setting the memory as RO, set_memory_ro(),
* but as of Dec 2020 this isn't possible on arm64.
*/
- addr = memremap(priv->mem->base, available, MEMREMAP_WB);
+ addr = memremap(priv->mem->base, priv->mem->size, MEMREMAP_WB);
if (!addr) {
dev_err(priv->dev, "Failed to remap memory region\n");
return -ENOMEM;
}
- count = memory_read_from_buffer(val, bytes, &off, addr, available);
+ memcpy(val, addr + offset, bytes);
memunmap(addr);
- if (count < 0)
- return count;
-
- return count == bytes ? 0 : -EIO;
+ return 0;
}
static int rmem_probe(struct platform_device *pdev)
--
2.47.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/6] nvmem: rmem: remove unused struct rmem::size field
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
` (2 preceding siblings ...)
2024-12-03 13:55 ` [PATCH 3/6] nvmem: rmem: make ->reg_read() straight forward code Théo Lebrun
@ 2024-12-03 13:55 ` Théo Lebrun
2024-12-03 13:55 ` [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM Théo Lebrun
2024-12-03 13:55 ` [PATCH 6/6] MIPS: mobileye: eyeq5: add bootloader config reserved memory Théo Lebrun
5 siblings, 0 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
The private structure used by the rmem driver contains
a `size` field that is unused. Remove it.
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/nvmem/rmem.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c
index 0dc5c8237c7538efe4597c182d7bdb709b945851..ca89c2689031534ff316a48e03360aeec823b025 100644
--- a/drivers/nvmem/rmem.c
+++ b/drivers/nvmem/rmem.c
@@ -13,8 +13,6 @@ struct rmem {
struct device *dev;
struct nvmem_device *nvmem;
struct reserved_mem *mem;
-
- phys_addr_t size;
};
static int rmem_read(void *context, unsigned int offset,
--
2.47.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
` (3 preceding siblings ...)
2024-12-03 13:55 ` [PATCH 4/6] nvmem: rmem: remove unused struct rmem::size field Théo Lebrun
@ 2024-12-03 13:55 ` Théo Lebrun
2024-12-04 7:58 ` kernel test robot
2024-12-04 8:29 ` kernel test robot
2024-12-03 13:55 ` [PATCH 6/6] MIPS: mobileye: eyeq5: add bootloader config reserved memory Théo Lebrun
5 siblings, 2 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
Mobileye EyeQ5 has a non-volatile memory region which
gets used to store MAC addresses. Its format includes
a prefix 12-byte header and a suffix 4-byte CRC.
Add an optional ->checksum() callback inside match data;
it runs CRC32 onto the content.
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/nvmem/rmem.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c
index ca89c2689031534ff316a48e03360aeec823b025..04796f4fa8ae708387013fa260afb901a14e24ff 100644
--- a/drivers/nvmem/rmem.c
+++ b/drivers/nvmem/rmem.c
@@ -3,6 +3,7 @@
* Copyright (C) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
*/
+#include <linux/crc32.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/nvmem-provider.h>
@@ -15,6 +16,18 @@ struct rmem {
struct reserved_mem *mem;
};
+struct rmem_match_data {
+ int (*checksum)(struct rmem *priv);
+};
+
+struct __packed rmem_eyeq5_header {
+ u32 magic;
+ u32 version;
+ u32 size;
+};
+
+#define RMEM_EYEQ5_MAGIC ((u32)0xDABBAD00)
+
static int rmem_read(void *context, unsigned int offset,
void *val, size_t bytes)
{
@@ -47,10 +60,66 @@ static int rmem_read(void *context, unsigned int offset,
return 0;
}
+static int rmem_eyeq5_checksum(struct rmem *priv)
+{
+ struct rmem_eyeq5_header header;
+ void *buf __free(kfree) = NULL;
+ u32 computed_crc, *target_crc;
+ size_t data_size;
+ int ret;
+
+ ret = rmem_read(priv, 0, &header, sizeof(header));
+ if (ret)
+ return ret;
+
+ if (header.magic != RMEM_EYEQ5_MAGIC)
+ return -EINVAL;
+
+ /*
+ * Avoid massive kmalloc() if header read is invalid;
+ * the check would be done by the next rmem_read() anyway.
+ */
+ if (header.size > priv->mem->size)
+ return -EINVAL;
+
+ /*
+ * 0 +-------------------+
+ * | Header (12 bytes) | \
+ * +-------------------+ |
+ * | | | data to be CRCed
+ * | ... | |
+ * | | /
+ * data_size +-------------------+
+ * | CRC (4 bytes) |
+ * header.size +-------------------+
+ */
+
+ buf = kmalloc(header.size, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ ret = rmem_read(priv, 0, buf, header.size);
+ if (ret)
+ return ret;
+
+ data_size = header.size - sizeof(*target_crc);
+ target_crc = buf + data_size;
+ computed_crc = crc32(U32_MAX, buf, data_size) ^ U32_MAX;
+
+ if (computed_crc == *target_crc)
+ return 0;
+
+ dev_err(priv->dev,
+ "checksum failed: computed %#x, expected %#x, header (%#x, %#x, %#x)\n",
+ computed_crc, *target_crc, header.magic, header.version, header.size);
+ return -EINVAL;
+}
+
static int rmem_probe(struct platform_device *pdev)
{
struct nvmem_config config = { };
struct device *dev = &pdev->dev;
+ const struct rmem_match_data *match_data = device_get_match_data(dev);
struct reserved_mem *mem;
struct rmem *priv;
@@ -73,10 +142,21 @@ static int rmem_probe(struct platform_device *pdev)
config.size = mem->size;
config.reg_read = rmem_read;
+ if (match_data && match_data->checksum) {
+ int ret = match_data->checksum(priv);
+ if (ret)
+ return ret;
+ }
+
return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
}
+static const struct rmem_match_data rmem_eyeq5_match_data = {
+ .checksum = rmem_eyeq5_checksum,
+};
+
static const struct of_device_id rmem_match[] = {
+ { .compatible = "mobileye,eyeq5-bootloader-config", .data = &rmem_eyeq5_match_data },
{ .compatible = "nvmem-rmem", },
{ /* sentinel */ },
};
--
2.47.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 6/6] MIPS: mobileye: eyeq5: add bootloader config reserved memory
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
` (4 preceding siblings ...)
2024-12-03 13:55 ` [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM Théo Lebrun
@ 2024-12-03 13:55 ` Théo Lebrun
5 siblings, 0 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-03 13:55 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: devicetree, linux-kernel, linux-mips, Vladimir Kondratiev,
Grégory Clement, Thomas Petazzoni, Tawfik Bayouk,
Théo Lebrun
Add a new reserved-memory node, containing bootloader config with MAC
addresses for both ethernet instances of the SoC.
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
arch/mips/boot/dts/mobileye/eyeq5.dtsi | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/mips/boot/dts/mobileye/eyeq5.dtsi b/arch/mips/boot/dts/mobileye/eyeq5.dtsi
index 5d73e8320b8efc1b4f68923482bf188c4345f1cb..a84e6e720619ef99e1405ae6296d8bad1aa3fa23 100644
--- a/arch/mips/boot/dts/mobileye/eyeq5.dtsi
+++ b/arch/mips/boot/dts/mobileye/eyeq5.dtsi
@@ -49,6 +49,28 @@ mini_coredump0_reserved: mini-coredump0@806200000 {
mhm_reserved_0: the-mhm-reserved-0@0 {
reg = <0x8 0x00000000 0x0 0x0000800>;
};
+
+ nvram@461fe00 {
+ compatible = "mobileye,eyeq5-bootloader-config", "nvmem-rmem";
+ reg = <0x0 0x0461fe00 0x0 0x200>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ no-map;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eth0_mac: mac@7c {
+ reg = <0x7c 0x6>;
+ };
+
+ eth1_mac: mac@82 {
+ reg = <0x82 0x6>;
+ };
+ };
+ };
};
aliases {
--
2.47.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
2024-12-03 13:55 ` [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM Théo Lebrun
@ 2024-12-04 7:58 ` kernel test robot
2024-12-04 17:04 ` Théo Lebrun
2024-12-04 8:29 ` kernel test robot
1 sibling, 1 reply; 11+ messages in thread
From: kernel test robot @ 2024-12-04 7:58 UTC (permalink / raw)
To: =?unknown-8bit?B?VGjDqW8=?= Lebrun, Srinivas Kandagatla,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: oe-kbuild-all, devicetree, linux-kernel, linux-mips,
Vladimir Kondratiev, =?unknown-8bit?Q?Gr=C3=A9gory?= Clement,
Thomas Petazzoni, Tawfik Bayouk,
=?unknown-8bit?B?VGjDqW8=?= Lebrun
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 3674 bytes --]
Hi Théo,
kernel test robot noticed the following build errors:
[auto build test ERROR on 40384c840ea1944d7c5a392e8975ed088ecf0b37]
url: https://github.com/intel-lab-lkp/linux/commits/Th-o-Lebrun/dt-bindings-nvmem-rmem-Add-mobileye-eyeq5-bootloader-config/20241204-103417
base: 40384c840ea1944d7c5a392e8975ed088ecf0b37
patch link: https://lore.kernel.org/r/20241203-rmem-v1-5-24f4970cf14e%40bootlin.com
patch subject: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
config: arm-randconfig-002 (https://download.01.org/0day-ci/archive/20241204/202412041522.01H5Kj6F-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241204/202412041522.01H5Kj6F-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412041522.01H5Kj6F-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/nvmem/rmem.c: In function 'rmem_eyeq5_checksum':
drivers/nvmem/rmem.c:66:9: error: cleanup argument not a function
66 | void *buf __free(kfree) = NULL;
| ^~~~
drivers/nvmem/rmem.c:97:15: error: implicit declaration of function 'kmalloc'; did you mean 'mm_alloc'? [-Wimplicit-function-declaration]
97 | buf = kmalloc(header.size, GFP_KERNEL);
| ^~~~~~~
| mm_alloc
>> drivers/nvmem/rmem.c:97:13: error: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
97 | buf = kmalloc(header.size, GFP_KERNEL);
| ^
vim +97 drivers/nvmem/rmem.c
62
63 static int rmem_eyeq5_checksum(struct rmem *priv)
64 {
65 struct rmem_eyeq5_header header;
66 void *buf __free(kfree) = NULL;
67 u32 computed_crc, *target_crc;
68 size_t data_size;
69 int ret;
70
71 ret = rmem_read(priv, 0, &header, sizeof(header));
72 if (ret)
73 return ret;
74
75 if (header.magic != RMEM_EYEQ5_MAGIC)
76 return -EINVAL;
77
78 /*
79 * Avoid massive kmalloc() if header read is invalid;
80 * the check would be done by the next rmem_read() anyway.
81 */
82 if (header.size > priv->mem->size)
83 return -EINVAL;
84
85 /*
86 * 0 +-------------------+
87 * | Header (12 bytes) | \
88 * +-------------------+ |
89 * | | | data to be CRCed
90 * | ... | |
91 * | | /
92 * data_size +-------------------+
93 * | CRC (4 bytes) |
94 * header.size +-------------------+
95 */
96
> 97 buf = kmalloc(header.size, GFP_KERNEL);
98 if (!buf)
99 return -ENOMEM;
100
101 ret = rmem_read(priv, 0, buf, header.size);
102 if (ret)
103 return ret;
104
105 data_size = header.size - sizeof(*target_crc);
106 target_crc = buf + data_size;
107 computed_crc = crc32(U32_MAX, buf, data_size) ^ U32_MAX;
108
109 if (computed_crc == *target_crc)
110 return 0;
111
112 dev_err(priv->dev,
113 "checksum failed: computed %#x, expected %#x, header (%#x, %#x, %#x)\n",
114 computed_crc, *target_crc, header.magic, header.version, header.size);
115 return -EINVAL;
116 }
117
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
2024-12-03 13:55 ` [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM Théo Lebrun
2024-12-04 7:58 ` kernel test robot
@ 2024-12-04 8:29 ` kernel test robot
1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-12-04 8:29 UTC (permalink / raw)
To: =?unknown-8bit?B?VGjDqW8=?= Lebrun, Srinivas Kandagatla,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nicolas Saenz Julienne, Thomas Bogendoerfer
Cc: oe-kbuild-all, devicetree, linux-kernel, linux-mips,
Vladimir Kondratiev, =?unknown-8bit?Q?Gr=C3=A9gory?= Clement,
Thomas Petazzoni, Tawfik Bayouk,
=?unknown-8bit?B?VGjDqW8=?= Lebrun
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 3726 bytes --]
Hi Théo,
kernel test robot noticed the following build errors:
[auto build test ERROR on 40384c840ea1944d7c5a392e8975ed088ecf0b37]
url: https://github.com/intel-lab-lkp/linux/commits/Th-o-Lebrun/dt-bindings-nvmem-rmem-Add-mobileye-eyeq5-bootloader-config/20241204-103417
base: 40384c840ea1944d7c5a392e8975ed088ecf0b37
patch link: https://lore.kernel.org/r/20241203-rmem-v1-5-24f4970cf14e%40bootlin.com
patch subject: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
config: arc-randconfig-001 (https://download.01.org/0day-ci/archive/20241204/202412041614.WGhDRXyh-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241204/202412041614.WGhDRXyh-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412041614.WGhDRXyh-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
drivers/nvmem/rmem.c: In function 'rmem_eyeq5_checksum':
>> drivers/nvmem/rmem.c:66:9: error: cleanup argument not a function
66 | void *buf __free(kfree) = NULL;
| ^~~~
>> drivers/nvmem/rmem.c:97:15: error: implicit declaration of function 'kmalloc'; did you mean 'mm_alloc'? [-Werror=implicit-function-declaration]
97 | buf = kmalloc(header.size, GFP_KERNEL);
| ^~~~~~~
| mm_alloc
>> drivers/nvmem/rmem.c:97:13: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
97 | buf = kmalloc(header.size, GFP_KERNEL);
| ^
cc1: some warnings being treated as errors
vim +66 drivers/nvmem/rmem.c
62
63 static int rmem_eyeq5_checksum(struct rmem *priv)
64 {
65 struct rmem_eyeq5_header header;
> 66 void *buf __free(kfree) = NULL;
67 u32 computed_crc, *target_crc;
68 size_t data_size;
69 int ret;
70
71 ret = rmem_read(priv, 0, &header, sizeof(header));
72 if (ret)
73 return ret;
74
75 if (header.magic != RMEM_EYEQ5_MAGIC)
76 return -EINVAL;
77
78 /*
79 * Avoid massive kmalloc() if header read is invalid;
80 * the check would be done by the next rmem_read() anyway.
81 */
82 if (header.size > priv->mem->size)
83 return -EINVAL;
84
85 /*
86 * 0 +-------------------+
87 * | Header (12 bytes) | \
88 * +-------------------+ |
89 * | | | data to be CRCed
90 * | ... | |
91 * | | /
92 * data_size +-------------------+
93 * | CRC (4 bytes) |
94 * header.size +-------------------+
95 */
96
> 97 buf = kmalloc(header.size, GFP_KERNEL);
98 if (!buf)
99 return -ENOMEM;
100
101 ret = rmem_read(priv, 0, buf, header.size);
102 if (ret)
103 return ret;
104
105 data_size = header.size - sizeof(*target_crc);
106 target_crc = buf + data_size;
107 computed_crc = crc32(U32_MAX, buf, data_size) ^ U32_MAX;
108
109 if (computed_crc == *target_crc)
110 return 0;
111
112 dev_err(priv->dev,
113 "checksum failed: computed %#x, expected %#x, header (%#x, %#x, %#x)\n",
114 computed_crc, *target_crc, header.magic, header.version, header.size);
115 return -EINVAL;
116 }
117
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config
2024-12-03 13:55 ` [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config Théo Lebrun
@ 2024-12-04 15:08 ` Rob Herring (Arm)
0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring (Arm) @ 2024-12-04 15:08 UTC (permalink / raw)
To: Théo Lebrun
Cc: Thomas Petazzoni, Srinivas Kandagatla, Grégory Clement,
devicetree, linux-kernel, Conor Dooley, linux-mips,
Nicolas Saenz Julienne, Vladimir Kondratiev, Krzysztof Kozlowski,
Tawfik Bayouk, Thomas Bogendoerfer
On Tue, 03 Dec 2024 14:55:44 +0100, Théo Lebrun wrote:
> On Mobileye EyeQ5, the bootloader will put MAC addresses into memory.
> Declare that as reserved memory to be used by the kernel, exposing
> nvmem cells. That region has a 12-byte header and a 4-byte trailing CRC.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
> ---
> Documentation/devicetree/bindings/nvmem/rmem.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
2024-12-04 7:58 ` kernel test robot
@ 2024-12-04 17:04 ` Théo Lebrun
0 siblings, 0 replies; 11+ messages in thread
From: Théo Lebrun @ 2024-12-04 17:04 UTC (permalink / raw)
To: kernel test robot
Cc: oe-kbuild-all, devicetree, linux-kernel, linux-mips,
Vladimir Kondratiev, Grégory Clement, Thomas Petazzoni,
Tawfik Bayouk, Théo Lebrun, Srinivas Kandagatla,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nicolas Saenz Julienne, Thomas Bogendoerfer
On Wed Dec 4, 2024 at 8:58 AM CET, kernel test robot wrote:
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on 40384c840ea1944d7c5a392e8975ed088ecf0b37]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Th-o-Lebrun/dt-bindings-nvmem-rmem-Add-mobileye-eyeq5-bootloader-config/20241204-103417
> base: 40384c840ea1944d7c5a392e8975ed088ecf0b37
> patch link: https://lore.kernel.org/r/20241203-rmem-v1-5-24f4970cf14e%40bootlin.com
> patch subject: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
> config: arm-randconfig-002 (https://download.01.org/0day-ci/archive/20241204/202412041522.01H5Kj6F-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241204/202412041522.01H5Kj6F-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202412041522.01H5Kj6F-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> drivers/nvmem/rmem.c: In function 'rmem_eyeq5_checksum':
> drivers/nvmem/rmem.c:66:9: error: cleanup argument not a function
> 66 | void *buf __free(kfree) = NULL;
> | ^~~~
> drivers/nvmem/rmem.c:97:15: error: implicit declaration of function 'kmalloc'; did you mean 'mm_alloc'? [-Wimplicit-function-declaration]
> 97 | buf = kmalloc(header.size, GFP_KERNEL);
> | ^~~~~~~
> | mm_alloc
> >> drivers/nvmem/rmem.c:97:13: error: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> 97 | buf = kmalloc(header.size, GFP_KERNEL);
> | ^
Will fix with the following.
V2 incoming in a few days to avoid spam.
diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c
index 04796f4fa8ae..1f0caf1d2dc1 100644
--- a/drivers/nvmem/rmem.c
+++ b/drivers/nvmem/rmem.c
@@ -9,6 +9,7 @@
#include <linux/nvmem-provider.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
+#include <linux/slab.h>
struct rmem {
struct device *dev;
Regards,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-12-04 17:04 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-03 13:55 [PATCH 0/6] nvmem: rmem: cleanup & add checksumming support for Mobileye EyeQ5 Théo Lebrun
2024-12-03 13:55 ` [PATCH 1/6] dt-bindings: nvmem: rmem: Add mobileye,eyeq5-bootloader-config Théo Lebrun
2024-12-04 15:08 ` Rob Herring (Arm)
2024-12-03 13:55 ` [PATCH 2/6] nvmem: specify ->reg_read/reg_write() expected return values Théo Lebrun
2024-12-03 13:55 ` [PATCH 3/6] nvmem: rmem: make ->reg_read() straight forward code Théo Lebrun
2024-12-03 13:55 ` [PATCH 4/6] nvmem: rmem: remove unused struct rmem::size field Théo Lebrun
2024-12-03 13:55 ` [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM Théo Lebrun
2024-12-04 7:58 ` kernel test robot
2024-12-04 17:04 ` Théo Lebrun
2024-12-04 8:29 ` kernel test robot
2024-12-03 13:55 ` [PATCH 6/6] MIPS: mobileye: eyeq5: add bootloader config reserved memory Théo Lebrun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®