nvmem: fixes for 7.2
Subsystems (4)
[email protected]
maintainercover nvmem: fixes for 7.2
From: Srinivas Kandagatla <[email protected]>
Hi Greg,
Here are two fixes that can go into v7.2 release
Could you please queue them as 7.2 material.
Thanks,
Srini
Aelin Reidel (1):
nvmem: apple-spmi-nvmem: wrap regmap calls to satisfy CFI
Mathieu Dubois-Briand (1):
nvmem: layouts: Add fixed-layout driver
MAINTAINERS | 5 +++ drivers/nvmem/apple-spmi-nvmem.c | 20 +++++++++- drivers/nvmem/core.c | 24 +----------- drivers/nvmem/internals.h | 2 + drivers/nvmem/layouts.c | 11 ------ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/fixed-layout.c | 58 ++++++++++++++++++++++++++++ include/linux/nvmem-provider.h | 6 +++ 8 files changed, 92 insertions(+), 35 deletions(-) create mode 100644 drivers/nvmem/layouts/fixed-layout.c
Signature · 1 line
2.53.0
[email protected]
maintainerPATCH 1/2 nvmem: apple-spmi-nvmem: wrap regmap calls to satisfy CFI
From: Aelin Reidel <[email protected]>
The Apple SPMI NVMEM driver previously cast regmap_bulk_read/write to void * when assigning them to nvmem_config's reg_read/reg_write function pointers.
This cast breaks the expected function signature of nvmem_reg_read_t and nvmem_reg_write_t. With CFI enabled, indirect calls through these pointers fail:
CFI failure at nvmem_reg_write+0x194/0x1e4 (target: regmap_bulk_write+0x0/0x2c8; expected type: 0x83a189c3)
...
Call trace: nvmem_reg_write+0x194/0x1e4 (P) __nvmem_cell_entry_write+0x298/0x2e8 nvmem_cell_write+0x24/0x34 macsmc_reboot_probe+0x1dc/0x454 [macsmc_reboot] ...
Introduce thin wrapper functions with the correct nvmem function pointer types to satisfy the CFI checks.
--- drivers/nvmem/apple-spmi-nvmem.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/nvmem/apple-spmi-nvmem.c +18 -2
@@ -18,6 +18,22 @@ static const struct regmap_config apple_spmi_regmap_config = { .max_register = 0xffff, }; +static int apple_spmi_nvmem_read (void *priv,unsigned int offset,void *val, +size_t bytes) +{ +struct regmap *map = priv; + +return regmap_bulk_read (map, offset, val, bytes); +} + +static int apple_spmi_nvmem_write (void *priv,unsigned int offset,void *val, +size_t bytes) +{ +struct regmap *map = priv; + +return regmap_bulk_write (map, offset, val, bytes); +} +static int apple_spmi_nvmem_probe (struct spmi_device *sdev) {struct regmap *regmap;
@@ -28,8 +44,8 @@ static int apple_spmi_nvmem_probe(struct spmi_device *sdev) .word_size = 1, .stride = 1, .size = 0xffff, - .reg_read = (void *)regmap_bulk_read, - .reg_write = (void *)regmap_bulk_write, + .reg_read = apple_spmi_nvmem_read, + .reg_write = apple_spmi_nvmem_write, }; regmap =devm_regmap_init_spmi_ext (sdev, &apple_spmi_regmap_config);
Signature · 1 line
2.53.0
[email protected]
maintainerPATCH 2/2 nvmem: layouts: Add fixed-layout driver
In reply to [email protected]From: Mathieu Dubois-Briand <[email protected]>
Current implementation isn't working well when device tree nodes have a phandle on a fixed-layout nvmem node. As the fixed layout is handled in nvmem core, no driver is ever associated with the layout, and the device consumer driver probe is deferred indefinitely.
Remove the specific handling of fixed-layout and add a layout driver. This makes the fixed-layout similar to all other layouts, fixing the whole issue.
--- MAINTAINERS | 5 +++ drivers/nvmem/core.c | 24 +----------- drivers/nvmem/internals.h | 2 + drivers/nvmem/layouts.c | 11 ------ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/fixed-layout.c | 58 ++++++++++++++++++++++++++++ include/linux/nvmem-provider.h | 6 +++ 7 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 drivers/nvmem/layouts/fixed-layout.c
MAINTAINERS +5 -0
@@ -10133,6 +10133,11 @@ F: drivers/base/firmware_loader/ F: rust/kernel/firmware.rs F: include/linux/firmware.h +FIXED-LAYOUT NVMEM LAYOUT DRIVER +M: Mathieu Dubois-Briand <[email protected]> +S: Maintained +F: drivers/nvmem/layouts/fixed-layout.c + FLEXTIMER FTM-QUADDEC DRIVER M: Patrick Havelange <[email protected]> L: [email protected]
drivers/nvmem/core.c +2 -22
@@ -786,7 +786,7 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem)return 0 ; } -static int nvmem_add_cells_from_dt (struct nvmem_device *nvmem,struct device_node *np) +int nvmem_add_cells_from_dt (struct nvmem_device *nvmem,struct device_node *np) {struct device *dev = &nvmem->dev;const __be32 *addr;
@@ -834,29 +834,13 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nodreturn 0 ; } +EXPORT_SYMBOL_GPL (nvmem_add_cells_from_dt);static int nvmem_add_cells_from_legacy_of (struct nvmem_device *nvmem) {return nvmem_add_cells_from_dt (nvmem, nvmem->dev.of_node); } -static int nvmem_add_cells_from_fixed_layout (struct nvmem_device *nvmem) -{ -struct device_node *layout_np; -int err =0 ; - - layout_np =of_nvmem_layout_get_container (nvmem); -if (!layout_np) -return 0 ; - -if (of_device_is_compatible (layout_np,"fixed-layout" )) - err =nvmem_add_cells_from_dt (nvmem, layout_np); - -of_node_put (layout_np); - -return err; -} -int nvmem_layout_register (struct nvmem_layout *layout) {int ret;
@@ -1005,10 +989,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) goto err_remove_cells; } - rval =nvmem_add_cells_from_fixed_layout (nvmem); -if (rval) - goto err_remove_cells; -dev_dbg (&nvmem->dev,"Registering nvmem device %s\n" , config->name); rval =device_add (&nvmem->dev);
drivers/nvmem/internals.h +2 -0
@@ -35,6 +35,8 @@ struct nvmem_device {bool sysfs_cells_populated; }; +int nvmem_add_cells_from_dt (struct nvmem_device *nvmem,struct device_node *np); +#if IS_ENABLED (CONFIG_OF )int nvmem_layout_bus_register (void );void nvmem_layout_bus_unregister (void );
drivers/nvmem/layouts.c +0 -11
@@ -125,11 +125,6 @@ static int nvmem_layout_create_device(struct nvmem_device *nvmem,return 0 ; } -static const struct of_device_id of_nvmem_layout_skip_table[] = { - { .compatible ="fixed-layout" , }, - {} -}; -static int nvmem_layout_bus_populate (struct nvmem_device *nvmem,struct device_node *layout_dn) {
@@ -142,12 +137,6 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,return 0 ; } -/* Fixed layouts are parsed manually somewhere else for now */ -if (of_match_node (of_nvmem_layout_skip_table, layout_dn)) { -pr_debug ("%s() - skipping %pOF node\n" , __func__, layout_dn); -return 0 ; - } -if (of_node_check_flag (layout_dn,OF_POPULATED_BUS )) {pr_debug ("%s() - skipping %pOF, already populated\n" , __func__, layout_dn);
drivers/nvmem/layouts/Makefile +1 -0
@@ -3,6 +3,7 @@ # Makefile for nvmem layouts. # +obj-$(CONFIG_NVMEM_LAYOUTS) += fixed-layout.o obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o
drivers/nvmem/layouts/fixed-layout.c new file +58 -0
58 lines not on this page · raw message
include/linux/nvmem-provider.h +6 -0
@@ -214,6 +214,12 @@ static inline int nvmem_layout_register(struct nvmem_layout *layout)static inline void nvmem_layout_unregister (struct nvmem_layout *layout) {} +static inline int nvmem_add_cells_from_dt (struct nvmem_device *nvmem, +struct device_node *np) +{ +return -EOPNOTSUPP ; +} +#endif /* CONFIG_NVMEM */ #if IS_ENABLED (CONFIG_NVMEM ) &&IS_ENABLED (CONFIG_OF )
Signature · 1 line
2.53.0