CLK: microchip: Add clkcfg driver for Microchip PolarFire SoC
Subsystems (3)
[email protected]
maintainerv6 cover CLK: microchip: Add clkcfg driver for Microchip PolarFire SoC
From: Conor Dooley <[email protected]>
This patchset adds support for the Microchip PolarFire clkcfg hardware block.
Changes since v5:
* Dropped clock-output-names property
Major changes since v4:
* Adjusted license for microchip,mpfs-clock.h to match microchip,mpfs.yaml
* Corrected the number of clocks to 33 from 32
Major changes since v3:
* Patch reformatted so microchip,mpfs-clock.h is part of device-tree patch
Major changes since v2:
* In mpfs_cfg_clk_set_rate, return immediately if divider_get_val returns <0
* rebased to v5.12-rc1
Major changes since v1:
* Dependency on SOC_MICROCHIP_POLARFIRE
* All references to PFSOC/pfsoc changed to MPFS/mpfs
* Cleaned error handling in _probe
* Re-ordered code to place structs et al at top
Daire McNamara (2):
dt-bindings: clk: microchip: Add Microchip PolarFire host binding
clk: microchip: Add driver for Microchip PolarFire SoC
.../bindings/clock/microchip,mpfs.yaml | 58 +++ drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 2 +- drivers/clk/microchip/Kconfig | 7 + drivers/clk/microchip/Makefile | 6 +- drivers/clk/microchip/clk-mpfs.c | 444 ++++++++++++++++++ .../dt-bindings/clock/microchip,mpfs-clock.h | 45 ++ 7 files changed, 560 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/microchip,mpfs.yaml create mode 100644 drivers/clk/microchip/Kconfig create mode 100644 drivers/clk/microchip/clk-mpfs.c create mode 100644 include/dt-bindings/clock/microchip,mpfs-clock.h
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v6 1/2 dt-bindings: clk: microchip: Add Microchip PolarFire host binding
From: Daire McNamara <[email protected]>
Add device tree bindings for the Microchip PolarFire system clock controller
--- .../bindings/clock/microchip,mpfs.yaml | 58 +++++++++++++++++++ .../dt-bindings/clock/microchip,mpfs-clock.h | 45 ++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/microchip,mpfs.yaml create mode 100644 include/dt-bindings/clock/microchip,mpfs-clock.h
Documentation/devicetree/bindings/clock/microchip,mpfs.yaml new file +58 -0
@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/microchip,mpfs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip PolarFire Clock Control Module Binding + +maintainers: + - Daire McNamara <[email protected]> + +description: | + Microchip PolarFire clock control (CLKCFG) is an integrated clock controller, + which gates and enables all peripheral clocks. + + This device tree binding describes 33 gate clocks. Clocks are referenced by + user nodes by the CLKCFG node phandle and the clock index in the group, from + 0 to 32. + +properties: + compatible: + const: microchip,mpfs-clkcfg + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + '#clock-cells': + const: 1 + description: | + The clock consumer should specify the desired clock by having the clock + ID in its "clocks" phandle cell. See include/dt-bindings/clock/microchip,mpfs-clock.h + for the full list of PolarFire clock IDs. + +required: + - compatible + - reg + - clocks + - '#clock-cells' + +additionalProperties: false + +examples: + # Clock Config node: + - | + #include <dt-bindings/clock/microchip,mpfs-clock.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + clkcfg: clock-controller@20002000 { + compatible = "microchip,mpfs-clkcfg"; + reg = <0x0 0x20002000 0x0 0x1000>; + clocks = <&ref>; + #clock-cells = <1>; + }; + };
include/dt-bindings/clock/microchip,mpfs-clock.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.33.1
Re: [PATCH v6 1/2] dt-bindings: clk: microchip: Add Microchip PolarFire host binding
Quoted 8 lines · On Tue, Nov 30, 2021 at 3:06 PM <[email protected]> wrote:
From: Daire McNamara <[email protected]>
Add device tree bindings for the Microchip PolarFire system clock controller
Signed-off-by Daire McNamara <[email protected]>Signed-off-by Conor Dooley <[email protected]>Reviewed-by Rob Herring <[email protected]>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[email protected]
maintainerPATCH v6 2/2 clk: microchip: Add driver for Microchip PolarFire SoC
In reply to [email protected]From: Daire McNamara <[email protected]>
Add support for clock configuration on Microchip PolarFire SoC
--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 2 +- drivers/clk/microchip/Kconfig | 7 + drivers/clk/microchip/Makefile | 6 +- drivers/clk/microchip/clk-mpfs.c | 444 +++++++++++++++++++++++++++++++ 5 files changed, 457 insertions(+), 3 deletions(-) create mode 100644 drivers/clk/microchip/Kconfig create mode 100644 drivers/clk/microchip/clk-mpfs.c
drivers/clk/Kconfig +1 -0
@@ -401,6 +401,7 @@ source "drivers/clk/ingenic/Kconfig" source "drivers/clk/keystone/Kconfig" source "drivers/clk/mediatek/Kconfig" source "drivers/clk/meson/Kconfig" +source "drivers/clk/microchip/Kconfig" source "drivers/clk/mstar/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/pistachio/Kconfig"
drivers/clk/Makefile +1 -1
@@ -89,7 +89,7 @@ obj-$(CONFIG_ARCH_KEYSTONE) += keystone/ obj-$(CONFIG_MACH_LOONGSON32) += loongson1/ obj-y += mediatek/ obj-$(CONFIG_ARCH_MESON) += meson/ -obj-$(CONFIG_MACH_PIC32) += microchip/ +obj-y += microchip/ ifeq ($(CONFIG_COMMON_CLK), y) obj-$(CONFIG_ARCH_MMP) += mmp/ endif
drivers/clk/microchip/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +config MCHP_CLK_MPFS + bool "Clk driver for PolarFire SoC" + depends on (RISCV && SOC_MICROCHIP_POLARFIRE) || COMPILE_TEST + help + Supports Clock Configuration for PolarFire SoC
drivers/clk/microchip/Makefile +4 -2
@@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_COMMON_CLK_PIC32) += clk-core.o -obj-$(CONFIG_PIC32MZDA) += clk-pic32mzda.o + +obj-$(CONFIG_COMMON_CLK_PIC32) += clk-core.o +obj-$(CONFIG_PIC32MZDA) += clk-pic32mzda.o +obj-$(CONFIG_MCHP_CLK_MPFS) += clk-mpfs.o
drivers/clk/microchip/clk-mpfs.c new file +444 -0
444 lines not on this page · raw message
Signature · 1 line
2.33.1
Re: [PATCH v6 2/2] clk: microchip: Add driver for Microchip PolarFire SoC
Hi Conor, Daire,
Quoted 6 lines · On Tue, Nov 30, 2021 at 3:06 PM <[email protected]> wrote:
From: Daire McNamara <[email protected]>
Add support for clock configuration on Microchip PolarFire SoC
Signed-off-by Daire McNamara <[email protected]>Signed-off-by Conor Dooley <[email protected]>
Thanks for your patch!
Quoted 17 lines
drivers/clk/microchip/clk-mpfs.c new file +14
-0@@ -0,0 +1,444 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Daire McNamara,<[email protected]> +* Copyright (C) 2020 Microchip Technology Inc. All rights reserved. +*/ +#include <linux/clk-provider.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <dt-bindings/clock/microchip,mpfs-clock.h> + +/* address offset of control registers */ +#define REG_CLOCK_CONFIG_CR 0x08u
drivers/clk/microchip/clk-mpfs.c line 24
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+#define REG_SUBBLK_CLOCK_CR 0x84u +#define REG_SUBBLK_RESET_CR 0x88u + +struct mpfs_clock_data { +void __iomem *base; +struct clk_hw_onecell_data hw_data; +}; + +struct mpfs_cfg_clock { +unsigned int id;
implicit gap of 4 bytes
drivers/clk/microchip/clk-mpfs.c line 27
Quoted 3 lines
drivers/clk/microchip/clk-mpfs.c new file +3
-0+const char *name; +u8 shift; +u8 width;
implicit gap of 6 bytes
drivers/clk/microchip/clk-mpfs.c line 29
Quoted 2 lines
drivers/clk/microchip/clk-mpfs.c new file +2
-0+const struct clk_div_table *table; +unsigned long flags;
Hence you better move id, shift, and width to the end.
Quoted 5 lines
drivers/clk/microchip/clk-mpfs.c new file +5
-0+}; + +struct mpfs_cfg_hw_clock { +struct mpfs_cfg_clock cfg; +void __iomem *sys_base;
drivers/clk/microchip/clk-mpfs.c line 44
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+/* lock is used to prevent multiple writes */ +spinlock_t *lock; +struct clk_hw hw; +struct clk_init_data init; +}; + +#define to_mpfs_cfg_clk (_hw) container_of(_hw, struct mpfs_cfg_hw_clock, hw) + +struct mpfs_periph_clock { +unsigned int id;
implicit gap of 4 bytes
drivers/clk/microchip/clk-mpfs.c line 46
Quoted 2 lines
drivers/clk/microchip/clk-mpfs.c new file +2
-0+const char *name; +u8 shift;
implicit gap of 7 bytes
drivers/clk/microchip/clk-mpfs.c line 54
Quoted 8 lines
drivers/clk/microchip/clk-mpfs.c new file +8
-0+unsigned long flags; +}; + +struct mpfs_periph_hw_clock { +struct mpfs_periph_clock periph; +void __iomem *sys_base; +/* lock is used to prevent multiple writes */ +spinlock_t *lock;
This is not used?
drivers/clk/microchip/clk-mpfs.c line 67
Quoted 13 lines
drivers/clk/microchip/clk-mpfs.c new file +13
-0+struct clk_hw hw; +}; + +#define to_mpfs_periph_clk (_hw) container_of(_hw, struct mpfs_periph_hw_clock, hw) + +/* +* mpfs_clk_lock prevents anything else from writing to the +* mpfs clk block while a software locked register is being written. +*/ +static DEFINE_SPINLOCK (mpfs_clk_lock); + +static struct clk_parent_data mpfs_cfg_parent[] = { + { .fw_name ="msspllclk" , .name ="msspllclk" },
So you rely on the name of the fixed-clock reference clock? That is very fragile. Please instead use devm_clk_get() to get the reference clock from the "clocks" property of the clock-controller node.
drivers/clk/microchip/clk-mpfs.c line 92
Quoted 13 lines
drivers/clk/microchip/clk-mpfs.c new file +13
-0+static unsigned long mpfs_cfg_clk_recalc_rate (struct clk_hw *hw,unsigned long prate) +{ +struct mpfs_cfg_hw_clock *cfg_hw =to_mpfs_cfg_clk (hw); +struct mpfs_cfg_clock *cfg = &cfg_hw->cfg; +void __iomem *base_addr = cfg_hw->sys_base; +unsigned long rate; +u32 val; + + val =readl_relaxed (base_addr +REG_CLOCK_CONFIG_CR ) >> cfg->shift; + val &=clk_div_mask (cfg->width); + rate = prate / (1u << val); + +return rate;
return prate / (1u << val);
Quoted 7 lines
drivers/clk/microchip/clk-mpfs.c new file +6
-0+} +static int mpfs_cfg_clk_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long prate) +{ +struct mpfs_cfg_hw_clock *cfg_hw =to_mpfs_cfg_clk (hw); +struct mpfs_cfg_clock *cfg = &cfg_hw->cfg; +void __iomem *base_addr = cfg_hw->sys_base;
drivers/clk/microchip/clk-mpfs.c line 117
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+unsigned long flags =0 ; +u32 val; +int divider_setting; + + divider_setting =divider_get_val (rate, prate, cfg->table, cfg->width, cfg_hw->cfg.flags); + +if (divider_setting <0 ) +return divider_setting; + +if (cfg_hw->lock)
Isn't this branch always taken?
Quoted 13 lines
drivers/clk/microchip/clk-mpfs.c new file +13
-0+spin_lock_irqsave (cfg_hw->lock, flags); + else + __acquire(cfg_hw->lock); + + val =readl_relaxed (base_addr +REG_CLOCK_CONFIG_CR ); + val &= ~(clk_div_mask (cfg->width) << cfg_hw->cfg.shift); + val |= divider_setting << cfg->shift; +writel_relaxed (val, base_addr +REG_CLOCK_CONFIG_CR ); + +if (cfg_hw->lock) +spin_unlock_irqrestore (cfg_hw->lock, flags); +else +__release (cfg_hw->lock);
drivers/clk/microchip/clk-mpfs.c line 162
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +9
-0+ +return 0 ; +} +static void mpfs_clk_unregister_cfg (struct device *dev,struct clk_hw *hw) +{ +struct mpfs_cfg_hw_clock *cfg_hw =to_mpfs_cfg_clk (hw); + +devm_clk_hw_unregister (dev, hw); +kfree (cfg_hw);
This is freeing a part of the big array allocated with devm_kzalloc()?
Quoted 12 lines
drivers/clk/microchip/clk-mpfs.c new file +12
-0+} + +static struct clk_hw *mpfs_clk_register_cfg (struct device *dev, +struct mpfs_cfg_hw_clock *cfg_hw, +void __iomem *sys_base) +{ +struct clk_hw *hw; +int err; + + cfg_hw->sys_base = sys_base; + cfg_hw->lock = &mpfs_clk_lock; +
drivers/clk/microchip/clk-mpfs.c line 184
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+ hw = &cfg_hw->hw; + err =devm_clk_hw_register (dev, hw); +if (err) +return ERR_PTR (err); + +return hw; +} + +static int mpfs_clk_register_cfgs (struct device *dev,struct mpfs_cfg_hw_clock *cfg_hws, +int num_clks,struct mpfs_clock_data *data)
unsigned int num_clks
drivers/clk/microchip/clk-mpfs.c line 195
Quoted 11 lines
drivers/clk/microchip/clk-mpfs.c new file +11
-0+{ +struct clk_hw *hw; +void __iomem *sys_base = data->base; +unsigned int i, id; + +for (i =0 ; i < num_clks; i++) { +struct mpfs_cfg_hw_clock *cfg_hw = &cfg_hws[i]; + + hw =mpfs_clk_register_cfg (dev, cfg_hw, sys_base); +if (IS_ERR (hw)) { + dev_err(dev, "%s: failed to register clock %s\n", __func__,
I guess the __func__ can be dropped, as the clock name is unique?
Quoted 13 lines
drivers/clk/microchip/clk-mpfs.c new file +13
-0+ cfg_hw->cfg.name); + goto err_clk; + } + + id = cfg_hws[i].cfg.id; + data->hw_data.hws[id] = hw; + } + +return 0 ; + +err_clk: +while (i--) +mpfs_clk_unregister_cfg (dev, data->hw_data.hws[cfg_hws[i].cfg.id]);
drivers/clk/microchip/clk-mpfs.c
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +9
-0+ +return PTR_ERR (hw); +} +static void mpfs_clk_unregister_periph (struct device *dev,struct clk_hw *hw) +{ +struct mpfs_periph_hw_clock *periph_hw =to_mpfs_periph_clk (hw); + +devm_clk_hw_unregister (dev, hw); + kfree(periph_hw);'
This is freeing a part of the big array allocated with devm_kzalloc()?
Quoted 5 lines
drivers/clk/microchip/clk-mpfs.c new file +4
-0+} +static int mpfs_clk_register_periphs (struct device *dev,struct mpfs_periph_hw_clock *periph_hws, +int num_clks,struct mpfs_clock_data *data) +{
drivers/clk/microchip/clk-mpfs.c line 356
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+struct clk_hw *hw; +void __iomem *sys_base = data->base; +unsigned int i, id; + +for (i =0 ; i < num_clks; i++) { +struct mpfs_periph_hw_clock *periph_hw = &periph_hws[i]; + + hw =mpfs_clk_register_periph (dev, periph_hw, sys_base); +if (IS_ERR (hw)) { + dev_err(dev, "%s: failed to register clock %s\n", __func__,
I guess the __func__ can be dropped, as the clock name is unique?
Quoted 13 lines
drivers/clk/microchip/clk-mpfs.c new file +13
-0+ periph_hw->periph.name); + goto err_clk; + } + + id = periph_hws[i].periph.id; + data->hw_data.hws[id] = hw; + } + +return 0 ; + +err_clk: +while (i--) +mpfs_clk_unregister_periph (dev, data->hw_data.hws[periph_hws[i].periph.id]);
drivers/clk/microchip/clk-mpfs.c line 379
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+ +return PTR_ERR (hw); +} + +static int mpfs_clk_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct mpfs_clock_data *clk_data; +struct resource *res; +int num_clks;
unsigned int
drivers/clk/microchip/clk-mpfs.c line 382
Quoted 3 lines
drivers/clk/microchip/clk-mpfs.c new file +3
-0+int ret; + + num_clks =ARRAY_SIZE (mpfs_cfg_clks) +ARRAY_SIZE (mpfs_periph_clks);
As mpfs_periph_clks[] lacks an entry for CLK_RESERVED, num_clks is one too small...
Quoted 8 lines
drivers/clk/microchip/clk-mpfs.c new file +8
-0+ + clk_data =devm_kzalloc (dev,struct_size (clk_data, hw_data.hws, num_clks),GFP_KERNEL ); +if (!clk_data) +return -ENOMEM ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + clk_data->base =devm_ioremap_resource (dev, res); +if (IS_ERR (clk_data->base))
drivers/clk/microchip/clk-mpfs.c line 400
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+return PTR_ERR (clk_data->base); + + clk_data->hw_data.num = num_clks; + + ret =mpfs_clk_register_cfgs (dev, mpfs_cfg_clks,ARRAY_SIZE (mpfs_cfg_clks), clk_data); +if (ret) + goto err_clk; + + ret =mpfs_clk_register_periphs (dev, mpfs_periph_clks,ARRAY_SIZE (mpfs_periph_clks), + clk_data);
... and initializing CLK_CFM will write beyond the end of clk_data[].
Quoted 4 lines
drivers/clk/microchip/clk-mpfs.c new file +4
-0+if (ret) + goto err_clk; + + ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, &clk_data->hw_data);
drivers/clk/microchip/clk-mpfs.c line 414
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+if (ret) + goto err_clk; + +dev_info (dev,"registered MPFS core clocks\n" ); +return ret; + +err_clk: +dev_err (dev,"failed to register MPFS core clocks\n" ); +return ret; +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[email protected]
maintainerRe: [PATCH v6 2/2] clk: microchip: Add driver for Microchip PolarFire SoC
Hi Geert,
Just going to ack the other items you raised for now, but curious about this one:
Quoted 9 lines · Geert Uytterhoeven
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
drivers/clk/microchip/clk-mpfs.c line 162
Quoted 6 lines
drivers/clk/microchip/clk-mpfs.c new file +6
-0+static void mpfs_clk_unregister_cfg (struct device *dev,struct clk_hw *hw) +{ +struct mpfs_cfg_hw_clock *cfg_hw =to_mpfs_cfg_clk (hw); + +devm_clk_hw_unregister (dev, hw); +kfree (cfg_hw);This is freeing a part of the big array allocated with
devm_kzalloc()?
I took a look at this, and I don't think it is freeing the devm allocated array.
To me, what is actually being freed is an element in the array of structs passed to mpfs_clk_register_cfgs in the probe function. However, this struct is statically defined - so its elements shouldn't be freed at all?
drivers/clk/clk-bm1880.c has the same behaviour in the unregister function, where it calls kfree on the elements of a static array of clk structs. So if my understanding is correct it would need fixing there too.
Cheers,
Conor.
Quoted 55 lines
Quoted 12 lines
drivers/clk/microchip/clk-mpfs.c new file +12
-0+} + +static struct clk_hw *mpfs_clk_register_cfg (struct device *dev, +struct mpfs_cfg_hw_clock *cfg_hw, +void __iomem *sys_base) +{ +struct clk_hw *hw; +int err; + + cfg_hw->sys_base = sys_base; + cfg_hw->lock = &mpfs_clk_lock; +drivers/clk/microchip/clk-mpfs.c line 184
Quoted 10 lines
drivers/clk/microchip/clk-mpfs.c new file +10
-0+ hw = &cfg_hw->hw; + err =devm_clk_hw_register (dev, hw); +if (err) +return ERR_PTR (err); + +return hw; +} + +static int mpfs_clk_register_cfgs (struct device *dev,struct mpfs_cfg_hw_clock *cfg_hws, +int num_clks,struct mpfs_clock_data *data)unsigned int
num_clksdrivers/clk/microchip/clk-mpfs.c line 195
Quoted 11 lines
drivers/clk/microchip/clk-mpfs.c new file +11
-0+{ +struct clk_hw *hw; +void __iomem *sys_base = data->base; +unsigned int i, id; + +for (i =0 ; i < num_clks; i++) { +struct mpfs_cfg_hw_clock *cfg_hw = &cfg_hws[i]; + + hw =mpfs_clk_register_cfg (dev, cfg_hw, sys_base); +if (IS_ERR (hw)) { + dev_err(dev, "%s: failed to register clock %s\n", __func__,I guess the
__func__can be dropped, as the clock name is unique?Quoted 16 lines
drivers/clk/microchip/clk-mpfs.c new file +16
-0+ cfg_hw->cfg.name); + goto err_clk; + } + + id = cfg_hws[i].cfg.id; + data->hw_data.hws[id] = hw; + } + +return 0 ; + +err_clk: +while (i--) +mpfs_clk_unregister_cfg (dev, data->hw_data.hws[cfg_hws[i].cfg.id]); + +return PTR_ERR (hw); +}
Re: [PATCH v6 2/2] clk: microchip: Add driver for Microchip PolarFire SoC
Hi Conor,
Quoted 12 lines · On Wed, Dec 8, 2021 at 4:30 PM <[email protected]> wrote:
Just going to ack the other items you raised for now, but curious about this one:
Quoted 9 lines · Geert Uytterhoeven
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
drivers/clk/microchip/clk-mpfs.c line 162
Quoted 6 lines
drivers/clk/microchip/clk-mpfs.c new file +6
-0+static void mpfs_clk_unregister_cfg (struct device *dev,struct clk_hw *hw) +{ +struct mpfs_cfg_hw_clock *cfg_hw =to_mpfs_cfg_clk (hw); + +devm_clk_hw_unregister (dev, hw); +kfree (cfg_hw);This is freeing a part of the big array allocated with
devm_kzalloc()?
Quoted 7 lines
I took a look at this, and I don't think it is freeing the devm allocated array.
To me, what is actually being freed is an element in the array of structs passed to
mpfs_clk_register_cfgsin the probe function. However, this struct is statically defined - so its elements shouldn't be freed at all?
You're right, it's part of the static array. I was misled by the back-and-forth conversions between the different types. Regardless, the kfree() calls should be removed.
Quoted 3 lines
drivers/clk/clk-bm1880.chas the same behaviour in the unregister function, where it calls kfree on the elements of a static array of clk structs. So if my understanding is correct it would need fixing there too.
If that is true (didn't check), it needs to be fixed, too.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds