Add support for hwspinlock on A64 SoC
cover Add support for hwspinlock on A64 SoC
Here are a couple of patches that add support for hwspinlock ip block in the A64 SoC. I tested the driver on a pine64-lts and it seems to work - clock gating is disabled and soft reset is de-asserted.
Nikolay Borisov (3):
hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
arm64: dts: allwinner: a64: Add hwspinlock node
dt-bindings: hwlock: Document A64 hwspinlock bindings
.../bindings/hwlock/sunxi-hwspinlock.txt | 27 +++ arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 9 + drivers/hwspinlock/Kconfig | 9 + drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/sunxi_hwspinlock.c | 181 ++++++++++++++++++ 5 files changed, 227 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwlock/sunxi-hwspinlock.txt create mode 100644 drivers/hwspinlock/sunxi_hwspinlock.c
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/3 hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Based on the datasheet this implements support for the hwspinlock IP block.
--- drivers/hwspinlock/Kconfig | 9 ++ drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/sunxi_hwspinlock.c | 181 ++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 drivers/hwspinlock/sunxi_hwspinlock.c
drivers/hwspinlock/Kconfig +9 -0
@@ -68,3 +68,12 @@ config HSEM_U8500 SoC. If unsure, say N. + +config HWSPINLOCK_SUNXI + tristate "Allwinner Hardware Spinlock device" + depends on ARCH_SUNXI + depends on HWSPINLOCK + help + Say y here to support the SUNXI Hardware Spinlock device. + + If unsure, say N.
drivers/hwspinlock/Makefile +1 -0
@@ -8,5 +8,6 @@ obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_QCOM) += qcom_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SIRF) += sirf_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SPRD) += sprd_hwspinlock.o +obj-$(CONFIG_HWSPINLOCK_SUNXI) += sunxi_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_STM32) += stm32_hwspinlock.o obj-$(CONFIG_HSEM_U8500) += u8500_hsem.o
drivers/hwspinlock/sunxi_hwspinlock.c new file +181 -0
181 lines not on this page · raw message
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
On Mon 10 Feb 09:01 PST 2020, Nikolay Borisov wrote:
[..]
Quoted 7 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +1
-0@@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0
drivers/hwspinlock/sunxi_hwspinlock.c line 11
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+/* Author: Nikolay Borisov <[email protected]> */ + +#include <linux/clk.h> +#include <linux/reset.h> +#include <linux/hwspinlock.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h>
Please sort these.
Quoted 13 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +13
-0+ +#include "hwspinlock_internal.h" + +/* Spinlock register offsets */ +#define LOCK_BASE_OFFSET 0x0100 + +#define SPINLOCK_NUMLOCKS_BIT_OFFSET (28) +/* Possible values of SPINLOCK_LOCK_REG */ +#define SPINLOCK_NOTTAKEN (0)/* free */ +#define SPINLOCK_TAKEN (1)/* locked */ + +struct sunxi_hwspinlock { +struct clk *clk;
drivers/hwspinlock/sunxi_hwspinlock.c line 34
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+struct reset_control *reset; +struct hwspinlock_device bank; +}; + +static int sunxi_hwspinlock_trylock (struct hwspinlock *lock) +{ +void __iomem *lock_addr = lock->priv; + +/* attempt to acquire the lock by reading its value */ +return (SPINLOCK_NOTTAKEN ==readl (lock_addr));
Please drop the parenthesis and flip the expression around, i.e. variable == constant.
Quoted 9 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +9
-0+} + +static void sunxi_hwspinlock_unlock (struct hwspinlock *lock) +{ +void __iomem *lock_addr = lock->priv; + +/* release the lock by writing 0 to it */ +writel (SPINLOCK_NOTTAKEN , lock_addr); +}
drivers/hwspinlock/sunxi_hwspinlock.c line 53
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+ +static const struct hwspinlock_ops sunxi_hwspinlock_ops = { + .trylock = sunxi_hwspinlock_trylock, + .unlock = sunxi_hwspinlock_unlock, +}; + +static int sunxi_get_num_locks (void __iomem *io_base) +{ +int i =readl (io_base); + i >>=SPINLOCK_NUMLOCKS_BIT_OFFSET ;
Please make i u32.
Quoted 12 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +12
-0+ +switch (i) { +case 0x1 :return 32 ; +case 0x2 :return 64 ; +case 0x3 :return 128 ; +case 0x4 :return 256 ; + } + +return 0 ; +} + +static int sunxi_hwspinlock_probe (struct platform_device *pdev)
drivers/hwspinlock/sunxi_hwspinlock.c line 75
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+{ +struct sunxi_hwspinlock *hw; +void __iomem *io_base; +struct resource *res; +struct clk *clk; +struct reset_control *reset; +int i, ret, num_locks; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + io_base =devm_ioremap_resource (&pdev->dev, res);
Please use devm_platform_ioremap_resource()
Quoted 14 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +14
-0+if (IS_ERR (io_base)) +return PTR_ERR (io_base); + +/* +* make sure the module is enabled and clocked before reading +* the module SYSSTATUS register +*/ + clk =devm_clk_get (&pdev->dev,NULL ); +if (IS_ERR (clk)) +return PTR_ERR (clk); + + ret =clk_prepare_enable (clk); +if (ret) { +dev_err (&pdev->dev,"Cannot enable clock\n" );
drivers/hwspinlock/sunxi_hwspinlock.c line 99
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+return ret; + } + +/* Disable soft reset */ + reset=devm_reset_control_get_exclusive (&pdev->dev,NULL ); +if (IS_ERR (reset)) { + ret =PTR_ERR (reset); + goto out_declock; + } +reset_control_deassert (reset);
Indentation of this chunk looks off.
drivers/hwspinlock/sunxi_hwspinlock.c line 109
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+ + num_locks =sunxi_get_num_locks (io_base); +if (!num_locks) { +dev_err (&pdev->dev,"Unrecognised sunxi hwspinlock device\n" ); + ret = -EINVAL ; + goto out_reset; + } + + hw =devm_kzalloc (&pdev->dev,sizeof (*hw) + + num_locks *sizeof (struct hwspinlock ),GFP_KERNEL );
Please use struct_size() to calculate the size here.
Quoted 6 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +6
-0+if (!hw) { + ret = -ENOMEM ; + goto out_reset; + } + + hw->clk = clk;
drivers/hwspinlock/sunxi_hwspinlock.c line 125
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+ hw->reset = reset; + + io_base +=LOCK_BASE_OFFSET ; +for (i =0 ; i < num_locks; i++) + hw->bank.lock[i].priv = io_base + i *sizeof (u32); + +platform_set_drvdata (pdev, hw); + + ret =hwspin_lock_register (&hw->bank, &pdev->dev, &sunxi_hwspinlock_ops, +0 , num_locks);
People will likely send patches to replace this with devm_hwspin_lock_register(), but that will create an invalid ordering between the clock disable, reset assert and the hwspinlock unregistration.
You could deal with this using devm_add_action() and devm_add_action_or_reset() for the clock and reset above. That will save us future churn, would clean up your error handling and you could drop the remove function completely.
Quoted 15 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +15
-0+ +if (!ret) +return ret; +out_reset: +reset_control_assert (reset); +out_declock: +clk_disable_unprepare (clk); +return ret; +} + +static int sunxi_hwspinlock_remove (struct platform_device *pdev) +{ +struct sunxi_hwspinlock *hw =platform_get_drvdata (pdev); +int ret; +
drivers/hwspinlock/sunxi_hwspinlock.c line 150
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+ ret =hwspin_lock_unregister (&hw->bank); +if (ret) +dev_err (&pdev->dev,"%s failed: %d\n" , __func__, ret); + +reset_control_assert (hw->reset); +clk_disable_unprepare (hw->clk); + +return 0 ; +} +
Regards,
Bjorn
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 13 lines · Bjorn Andersson
On Mon 10 Feb 09:01 PST 2020, Nikolay Borisov wrote:
[..]Quoted 11 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +5
-0@@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Nikolay Borisov <[email protected]> */ + +#include <linux/clk.h> +#include <linux/reset.h>
Quoted 8 lines
drivers/hwspinlock/sunxi_hwspinlock.c line 11
Quoted 6 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +6
-0+#include <linux/hwspinlock.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> Please sort these.
alphabetically or reverse christmas tree?
Quoted 2 lines
Quoted 2 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +1
-0+
<snip>
Quoted 17 lines
drivers/hwspinlock/sunxi_hwspinlock.c line 125
Quoted 11 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +11
-0+ hw->clk = clk; + hw->reset = reset; + + io_base +=LOCK_BASE_OFFSET ; +for (i =0 ; i < num_locks; i++) + hw->bank.lock[i].priv = io_base + i *sizeof (u32); + +platform_set_drvdata (pdev, hw); + + ret =hwspin_lock_register (&hw->bank, &pdev->dev, &sunxi_hwspinlock_ops, +0 , num_locks);People will likely send patches to replace this with
devm_hwspin_lock_register(), but that will create an invalid ordering between the clock disable, reset assert and the hwspinlock unregistration.
Quoted 4 lines
You could deal with this using
devm_add_action()anddevm_add_action_or_reset()for the clock and reset above. That will save us future churn, would clean up your error handling and you could drop the remove function completely.
This is my first rodeo in device driver land so I'm learning. It looks like what you want here is similar to what there is in sprd_hwspinlock.c. Will rework it.
Quoted 21 lines
Quoted 21 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +20
-0+ +if (!ret) +return ret; +out_reset: +reset_control_assert (reset); +out_declock: +clk_disable_unprepare (clk); +return ret; +} + +static int sunxi_hwspinlock_remove (struct platform_device *pdev) +{ +struct sunxi_hwspinlock *hw =platform_get_drvdata (pdev); +int ret; + + ret =hwspin_lock_unregister (&hw->bank); +if (ret) +dev_err (&pdev->dev,"%s failed: %d\n" , __func__, ret); + +reset_control_assert (hw->reset);
Quoted 9 lines
drivers/hwspinlock/sunxi_hwspinlock.c line 150
Quoted 5 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +5
-0+clk_disable_unprepare (hw->clk); + +return 0 ; +} +Regards,
Bjorn
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 25 lines · Nikolay Borisov
Quoted 13 lines · Bjorn Andersson
On Mon 10 Feb 09:01 PST 2020, Nikolay Borisov wrote:
[..]Quoted 11 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +5
-0@@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Nikolay Borisov <[email protected]> */ + +#include <linux/clk.h> +#include <linux/reset.h> Quoted 8 lines
drivers/hwspinlock/sunxi_hwspinlock.c line 11
Quoted 6 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +6
-0+#include <linux/hwspinlock.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> Please sort these.
Quoted 2 lines
alphabetically or reverse christmas tree?
Alphabetically please.
Quoted 21 lines
Quoted 2 lines
Quoted 2 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +1
-0+<snip>
Quoted 17 lines
drivers/hwspinlock/sunxi_hwspinlock.c line 125
Quoted 11 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +11
-0+ hw->clk = clk; + hw->reset = reset; + + io_base +=LOCK_BASE_OFFSET ; +for (i =0 ; i < num_locks; i++) + hw->bank.lock[i].priv = io_base + i *sizeof (u32); + +platform_set_drvdata (pdev, hw); + + ret =hwspin_lock_register (&hw->bank, &pdev->dev, &sunxi_hwspinlock_ops, +0 , num_locks);People will likely send patches to replace this with
devm_hwspin_lock_register(), but that will create an invalid ordering between the clock disable, reset assert and the hwspinlock unregistration.
Quoted 9 lines
Quoted 4 lines
You could deal with this using
devm_add_action()anddevm_add_action_or_reset()for the clock and reset above. That will save us future churn, would clean up your error handling and you could drop the remove function completely.This is my first rodeo in device driver land so I'm learning. It looks like what you want here is similar to what there is in
sprd_hwspinlock.c. Will rework it.
Exactly like that, forgot that we had an example of this in the sprd driver. That will ensure that we rely solely on devres to unroll the resources in a suitable order.
Regards,
Bjorn
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +21
-0+ +if (!ret) +return ret; +out_reset: +reset_control_assert (reset); +out_declock: +clk_disable_unprepare (clk); +return ret; +} + +static int sunxi_hwspinlock_remove (struct platform_device *pdev) +{ +struct sunxi_hwspinlock *hw =platform_get_drvdata (pdev); +int ret; + + ret =hwspin_lock_unregister (&hw->bank); +if (ret) +dev_err (&pdev->dev,"%s failed: %d\n" , __func__, ret); + +reset_control_assert (hw->reset); +clk_disable_unprepare (hw->clk);
Quoted 8 lines
Quoted 8 lines
drivers/hwspinlock/sunxi_hwspinlock.c line 64
Quoted 4 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +4
-0+ +return 0 ; +} +Regards,
Bjorn
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
In reply to Nikolay BorisovHi,
Quoted 2 lines · Nikolay Borisov
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
There's also a lot of checkpatch issues, make sure you fix those.
Quoted 15 lines
Signed-off-by Nikolay Borisov <[email protected]>--- drivers/hwspinlock/Kconfig | 9 ++ drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/sunxi_hwspinlock.c | 181 ++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 drivers/hwspinlock/sunxi_hwspinlock.cdrivers/hwspinlock/Kconfig +0
-0@@ -68,3 +68,12 @@ config HSEM_U8500 SoC.
drivers/hwspinlock/Kconfig config HSEM_U8500 · line 79
Quoted 10 lines
drivers/hwspinlock/Kconfig +9
-0If unsure, say N. + +config HWSPINLOCK_SUNXI + tristate "Allwinner Hardware Spinlock device" + depends on ARCH_SUNXI + depends on HWSPINLOCK + help + Say y here to support the SUNXI Hardware Spinlock device. + + If unsure, say N.
sunxi doesn't really mean anything though, the A10 is also part of the sunxi family and doesn't have that IP. Similarly, nothing prevents a future SoC from changing that design. The first SoC that used it was the A33 iirc, so let's just use sun8i.
drivers/hwspinlock/Makefile obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o · line 11
Quoted 9 lines
drivers/hwspinlock/Makefile +1
-0@@ -8,5 +8,6 @@ obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_QCOM) += qcom_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SIRF) += sirf_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SPRD) += sprd_hwspinlock.o +obj-$(CONFIG_HWSPINLOCK_SUNXI) += sunxi_hwspinlock.o
Ditto for the name of the file (and basically every symbol in your driver.
Quoted 50 lines
drivers/hwspinlock/Makefile +0
-0obj-$(CONFIG_HWSPINLOCK_STM32) += stm32_hwspinlock.o obj-$(CONFIG_HSEM_U8500) += u8500_hsem.odrivers/hwspinlock/sunxi_hwspinlock.c new file +42
-0@@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Nikolay Borisov <[email protected]> */ + +#include <linux/clk.h> +#include <linux/reset.h> +#include <linux/hwspinlock.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +#include "hwspinlock_internal.h" + +/* Spinlock register offsets */ +#define LOCK_BASE_OFFSET 0x0100 + +#define SPINLOCK_NUMLOCKS_BIT_OFFSET (28) +/* Possible values of SPINLOCK_LOCK_REG */ +#define SPINLOCK_NOTTAKEN (0)/* free */ +#define SPINLOCK_TAKEN (1)/* locked */ + +struct sunxi_hwspinlock { +struct clk *clk; +struct reset_control *reset; +struct hwspinlock_device bank; +}; + +static int sunxi_hwspinlock_trylock (struct hwspinlock *lock) +{ +void __iomem *lock_addr = lock->priv; + +/* attempt to acquire the lock by reading its value */ +return (SPINLOCK_NOTTAKEN ==readl (lock_addr)); +} + +static void sunxi_hwspinlock_unlock (struct hwspinlock *lock) +{ +void __iomem *lock_addr = lock->priv; + +/* release the lock by writing 0 to it */ +writel (SPINLOCK_NOTTAKEN , lock_addr);
drivers/hwspinlock/sunxi_hwspinlock.c line 52
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+} + +static const struct hwspinlock_ops sunxi_hwspinlock_ops = { + .trylock = sunxi_hwspinlock_trylock, + .unlock = sunxi_hwspinlock_unlock, +}; + +static int sunxi_get_num_locks (void __iomem *io_base) +{ +int i =readl (io_base);
readl returns a u32.
drivers/hwspinlock/sunxi_hwspinlock.c line 53
Quoted 1 line
drivers/hwspinlock/sunxi_hwspinlock.c new file +1
-0+ i >>=SPINLOCK_NUMLOCKS_BIT_OFFSET ;
And you probably want to mask the value to avoid other bitfields in the register from messing with that value. FIELD_GET will help you to do so.
Quoted 18 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +18
-0+switch (i) { +case 0x1 :return 32 ; +case 0x2 :return 64 ; +case 0x3 :return 128 ; +case 0x4 :return 256 ; + } + +return 0 ; +} + +static int sunxi_hwspinlock_probe (struct platform_device *pdev) +{ +struct sunxi_hwspinlock *hw; +void __iomem *io_base; +struct resource *res; +struct clk *clk; +struct reset_control *reset; +int i, ret, num_locks;
drivers/hwspinlock/sunxi_hwspinlock.c line 82
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + io_base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (io_base)) +return PTR_ERR (io_base); + +/* +* make sure the module is enabled and clocked before reading +* the module SYSSTATUS register +*/
You don't define that register anywhere?
drivers/hwspinlock/sunxi_hwspinlock.c line 91
Quoted 9 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +9
-0+ clk =devm_clk_get (&pdev->dev,NULL ); +if (IS_ERR (clk)) +return PTR_ERR (clk); + + ret =clk_prepare_enable (clk); +if (ret) { +dev_err (&pdev->dev,"Cannot enable clock\n" ); +return ret; + }
Can't we do that with runtime_pm?
drivers/hwspinlock/sunxi_hwspinlock.c line 99
Quoted 7 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +7
-0+/* Disable soft reset */ + reset=devm_reset_control_get_exclusive (&pdev->dev,NULL ); +if (IS_ERR (reset)) { + ret =PTR_ERR (reset); + goto out_declock; + } +reset_control_deassert (reset);
We might have the same issue than the mailbox driver where the firmware will need to access the block at any time, so we can't really toggle the reset line as we want.
drivers/hwspinlock/sunxi_hwspinlock.c line 113
Quoted 13 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +13
-0+ num_locks =sunxi_get_num_locks (io_base); +if (!num_locks) { +dev_err (&pdev->dev,"Unrecognised sunxi hwspinlock device\n" ); + ret = -EINVAL ; + goto out_reset; + } + + hw =devm_kzalloc (&pdev->dev,sizeof (*hw) + + num_locks *sizeof (struct hwspinlock ),GFP_KERNEL ); +if (!hw) { + ret = -ENOMEM ; + goto out_reset; + }
That looks rather convoluted (especially since the variable length array is at the second level), and can be made more obvious by:
- Removing the hwspinlock_device from sunxi_hwspinlock and allocating both separately.
- And then allocate the hwspinlock_device separately with struct_size
drivers/hwspinlock/sunxi_hwspinlock.c line 116
Quoted 2 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +2
-0+ hw->clk = clk; + hw->reset = reset;
Why not using the structure directly instead of having temporary variables?
drivers/hwspinlock/sunxi_hwspinlock.c line 120
Quoted 3 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +3
-0+ io_base +=LOCK_BASE_OFFSET ; +for (i =0 ; i < num_locks; i++) + hw->bank.lock[i].priv = io_base + i *sizeof (u32);
Using a define for the registers offset would be nice here.
drivers/hwspinlock/sunxi_hwspinlock.c line 128
Quoted 7 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +7
-0+platform_set_drvdata (pdev, hw); + + ret =hwspin_lock_register (&hw->bank, &pdev->dev, &sunxi_hwspinlock_ops, +0 , num_locks); + +if (!ret) +return ret;
That's a slightly weird construct too, since in pretty much all the driver you return early on error and here you return early on success. Just return ret if there's an error just like you're doing everywhere else, and return 0 after that.
Quoted 33 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +33
-0+out_reset: +reset_control_assert (reset); +out_declock: +clk_disable_unprepare (clk); +return ret; +} + +static int sunxi_hwspinlock_remove (struct platform_device *pdev) +{ +struct sunxi_hwspinlock *hw =platform_get_drvdata (pdev); +int ret; + + ret =hwspin_lock_unregister (&hw->bank); +if (ret) +dev_err (&pdev->dev,"%s failed: %d\n" , __func__, ret); + +reset_control_assert (hw->reset); +clk_disable_unprepare (hw->clk); + +return 0 ; +} + +static const struct of_device_id sunxi_hwpinlock_ids[] = { + { .compatible ="allwinner,sun50i-a64-hwspinlock" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, sunxi_hwpinlock_ids); + +static struct platform_driver sunxi_hwspinlock_driver = { + .probe = sunxi_hwspinlock_probe, + .remove = sunxi_hwspinlock_remove, + .driver = { + .name ="sunxi_hwspinlock" ,
drivers/hwspinlock/sunxi_hwspinlock.c line 171
Quoted 10 lines
drivers/hwspinlock/sunxi_hwspinlock.c new file +10
-0+ .of_match_table = sunxi_hwpinlock_ids, + }, +}; + +static int __init sunxi_hwspinlock_init (void ) +{ +return platform_driver_register (&sunxi_hwspinlock_driver); +} +/* board init code might need to reserve hwspinlocks for predefined purposes */ +postcore_initcall (sunxi_hwspinlock_init);
We don't have any board init code. Can't we just use a regular module_platform_driver call here?
Thanks!
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 7 lines · Maxime Ripard
Hi,
Quoted 2 lines · Nikolay Borisov
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
I tested it on my pine64 lts e.g. loading the driver and reading the reset/clock/sysstatus registers to ensure everything is unmasked and has expected values.
Quoted 18 lines
There's also a lot of checkpatch issues, make sure you fix those.
Quoted 15 lines
Signed-off-by Nikolay Borisov <[email protected]>--- drivers/hwspinlock/Kconfig | 9 ++ drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/sunxi_hwspinlock.c | 181 ++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 drivers/hwspinlock/sunxi_hwspinlock.cdrivers/hwspinlock/Kconfig +0
-0@@ -68,3 +68,12 @@ config HSEM_U8500 SoC.
Quoted 15 lines
drivers/hwspinlock/Kconfig config HSEM_U8500 · line 79
Quoted 10 lines
drivers/hwspinlock/Kconfig +9
-0If unsure, say N. + +config HWSPINLOCK_SUNXI + tristate "Allwinner Hardware Spinlock device" + depends on ARCH_SUNXI + depends on HWSPINLOCK + help + Say y here to support the SUNXI Hardware Spinlock device. + + If unsure, say N.sunxi doesn't really mean anything though, the A10 is also part of the sunxi family and doesn't have that IP. Similarly, nothing prevents a future SoC from changing that design. The first SoC that used it was the A33 iirc, so let's just use sun8i.
Fair enough, I will use the same for the symbols as well. TBH the nomenclature is quite confusing in allwinner land...
Actually since this driver will initially support A64 shouldn't the symbols really be prefixed with sun50i, since looking at
https://linux-sunxi.org/Allwinner_SoC_Family sun8i pertains to 32 bit A7 cores?
Quoted 1 line
<snip>
Quoted 8 lines
drivers/hwspinlock/Kconfig
Quoted 5 lines
drivers/hwspinlock/Kconfig +5
-0+ + /* + * make sure the module is enabled and clocked before reading + * the module SYSSTATUS register + */You don't define that register anywhere?
Quoted 11 lines
drivers/hwspinlock/Kconfig
Quoted 9 lines
drivers/hwspinlock/Kconfig +9
-0+ clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + ret = clk_prepare_enable(clk); + if (ret) { + dev_err(&pdev->dev, "Cannot enable clock\n"); + return ret; + }Can't we do that with
runtime_pm?
Probably can but I'm new to device driver development so I don't understand all the implications of using the pm framework. I saw that other drivers did this but atm it's terra incognita to me.
Quoted 12 lines
drivers/hwspinlock/Kconfig
Quoted 8 lines
drivers/hwspinlock/Kconfig +7
-0+ /* Disable soft reset */ + reset= devm_reset_control_get_exclusive(&pdev->dev, NULL); + if (IS_ERR(reset)) { + ret = PTR_ERR(reset); + goto out_declock; + } + reset_control_deassert(reset);We might have the same issue than the mailbox driver where the firmware will need to access the block at any time, so we can't really toggle the reset line as we want.
What should we do then ?
Quoted 18 lines
Quoted 4 lines
drivers/hwspinlock/Kconfig +3
-0+ num_locks = sunxi_get_num_locks(io_base); + if (!num_locks) { + dev_err(&pdev->dev, "Unrecognised sunxi hwspinlock device\n");drivers/hwspinlock/Kconfig
Quoted 10 lines
drivers/hwspinlock/Kconfig +10
-0+ ret = -EINVAL; + goto out_reset; + } + + hw = devm_kzalloc(&pdev->dev, sizeof(*hw) + + num_locks * sizeof(struct hwspinlock), GFP_KERNEL); + if (!hw) { + ret = -ENOMEM; + goto out_reset; + }That looks rather convoluted (especially since the variable length array is at the second level), and can be made more obvious by:
Quoted 4 lines
- Removing the
hwspinlock_devicefromsunxi_hwspinlockand allocating both separately.- And then allocate the
hwspinlock_deviceseparately withstruct_size
Actually this can be allocated via struct_size e.g. struct_size(hw, bank.lock, num_locks).
Quoted 6 lines
drivers/hwspinlock/Kconfig
Quoted 3 lines
drivers/hwspinlock/Kconfig +2
-0+ hw->clk = clk; + hw->reset = reset;Why not using the structure directly instead of having temporary variables?
Because I use the clk/reset before allocating the devmem.
Quoted 6 lines
drivers/hwspinlock/Kconfig
Quoted 4 lines
drivers/hwspinlock/Kconfig +3
-0+ io_base += LOCK_BASE_OFFSET; + for (i = 0; i < num_locks; i++) + hw->bank.lock[i].priv = io_base + i * sizeof(u32);Using a define for the registers offset would be nice here.
you mean something like:
# define LOCK(X) (x * sizeof(u32))
I think this brings more needless indirection than helps but if you insist I won't mind.
Quoted 21 lines
drivers/hwspinlock/Kconfig
Quoted 8 lines
drivers/hwspinlock/Kconfig +7
-0+ platform_set_drvdata(pdev, hw); + + ret = hwspin_lock_register(&hw->bank, &pdev->dev, &sunxi_hwspinlock_ops, + 0, num_locks); + + if (!ret) + return ret;That's a slightly weird construct too, since in pretty much all the driver you return early on error and here you return early on success. Just return ret if there's an error just like you're doing everywhere else, and return 0 after that.
Quoted 7 lines
drivers/hwspinlock/Kconfig +7
-0+out_reset: + reset_control_assert(reset); +out_declock: + clk_disable_unprepare(clk); + return ret; +} +
<snip>
Quoted 5 lines
drivers/hwspinlock/Kconfig
Quoted 2 lines
drivers/hwspinlock/Kconfig +2
-0+/* board init code might need to reserve hwspinlocks for predefined purposes */ +postcore_initcall(sunxi_hwspinlock_init);We don't have any board init code. Can't we just use a regular
module_platform_drivercall here?
Perhaps we can, I will test on my pine64.
Quoted 4 lines
Thanks!
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 4 lines · Nikolay Borisov
Quoted 3 lines · Maxime Ripard
Hi,
On Mon, Feb 10, 2020 at 07:01:41PM +0200, Nikolay Borisov wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
I tested it on my pine64 lts e.g. loading the driver and reading the reset/clock/sysstatus registers to ensure everything is unmasked and has expected values.
Isn't the point of hwspinlocks that it's shared between the ARISC core and the ARM cores. How did you test that the lock was actually taken on the other side just by using the ARM cores?
Quoted 34 lines
Quoted 18 lines
There's also a lot of checkpatch issues, make sure you fix those.
Quoted 15 lines
Signed-off-by Nikolay Borisov <[email protected]>--- drivers/hwspinlock/Kconfig | 9 ++ drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/sunxi_hwspinlock.c | 181 ++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 drivers/hwspinlock/sunxi_hwspinlock.cdrivers/hwspinlock/Kconfig +0
-0@@ -68,3 +68,12 @@ config HSEM_U8500 SoC.Quoted 15 lines
drivers/hwspinlock/Kconfig config HSEM_U8500 · line 79
Quoted 10 lines
drivers/hwspinlock/Kconfig +9
-0If unsure, say N. + +config HWSPINLOCK_SUNXI + tristate "Allwinner Hardware Spinlock device" + depends on ARCH_SUNXI + depends on HWSPINLOCK + help + Say y here to support the SUNXI Hardware Spinlock device. + + If unsure, say N.sunxi doesn't really mean anything though, the A10 is also part of the sunxi family and doesn't have that IP. Similarly, nothing prevents a future SoC from changing that design. The first SoC that used it was the A33 iirc, so let's just use sun8i.
Quoted 7 lines
Fair enough, I will use the same for the symbols as well. TBH the nomenclature is quite confusing in allwinner land...
Actually since this driver will initially support A64 shouldn't the symbols really be prefixed with sun50i, since looking at
https://linux-sunxi.org/Allwinner_SoC_Family sun8i pertains to 32 bit A7 cores?
Not really, the design is the same and we don't want to rename everything.
Quoted 39 lines
Quoted 1 line
<snip>
Quoted 8 lines
drivers/hwspinlock/Kconfig
Quoted 5 lines
drivers/hwspinlock/Kconfig +5
-0+ + /* + * make sure the module is enabled and clocked before reading + * the module SYSSTATUS register + */You don't define that register anywhere?
Quoted 11 lines
drivers/hwspinlock/Kconfig
Quoted 9 lines
drivers/hwspinlock/Kconfig +9
-0+ clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + ret = clk_prepare_enable(clk); + if (ret) { + dev_err(&pdev->dev, "Cannot enable clock\n"); + return ret; + }Can't we do that with
runtime_pm?Probably can but I'm new to device driver development so I don't understand all the implications of using the pm framework. I saw that other drivers did this but atm it's terra incognita to me.
Quoted 12 lines
drivers/hwspinlock/Kconfig
Quoted 8 lines
drivers/hwspinlock/Kconfig +7
-0+ /* Disable soft reset */ + reset= devm_reset_control_get_exclusive(&pdev->dev, NULL); + if (IS_ERR(reset)) { + ret = PTR_ERR(reset); + goto out_declock; + } + reset_control_deassert(reset);We might have the same issue than the mailbox driver where the firmware will need to access the block at any time, so we can't really toggle the reset line as we want.
Quoted 1 line
What should we do then ?
Unless you put a firmware on the ARISC core and see how it interacts between the two, you can't really do anything.
Quoted 26 lines
Quoted 17 lines
drivers/hwspinlock/Kconfig
Quoted 13 lines
drivers/hwspinlock/Kconfig +13
-0+ num_locks = sunxi_get_num_locks(io_base); + if (!num_locks) { + dev_err(&pdev->dev, "Unrecognised sunxi hwspinlock device\n"); + ret = -EINVAL; + goto out_reset; + } + + hw = devm_kzalloc(&pdev->dev, sizeof(*hw) + + num_locks * sizeof(struct hwspinlock), GFP_KERNEL); + if (!hw) { + ret = -ENOMEM; + goto out_reset; + }That looks rather convoluted (especially since the variable length array is at the second level), and can be made more obvious by:
Quoted 4 lines
- Removing the
hwspinlock_devicefromsunxi_hwspinlockand allocating both separately.- And then allocate the
hwspinlock_deviceseparately withstruct_sizeActually this can be allocated via
struct_sizee.g.struct_size(hw, bank.lock, num_locks).Quoted 1 line
Quoted 7 lines
Quoted 5 lines
drivers/hwspinlock/Kconfig
Quoted 2 lines
drivers/hwspinlock/Kconfig +2
-0+ hw->clk = clk; + hw->reset = reset;Why not using the structure directly instead of having temporary variables?
Because I use the clk/reset before allocating the devmem.
Then do it the other way around?
Quoted 7 lines
Quoted 6 lines
drivers/hwspinlock/Kconfig
Quoted 4 lines
drivers/hwspinlock/Kconfig +3
-0+ io_base += LOCK_BASE_OFFSET; + for (i = 0; i < num_locks; i++) + hw->bank.lock[i].priv = io_base + i * sizeof(u32);Using a define for the registers offset would be nice here.
Quoted 6 lines
you mean something like:
# define LOCK(X) (x * sizeof(u32))I think this brings more needless indirection than helps but if you insist I won't mind.
It's not more of an indirection than using a function, and you're doing that all the time already :)
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Nikolay Borisov
Quoted 7 lines · Maxime Ripard
Hi,
Quoted 2 lines · Nikolay Borisov
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
Quoted 7 lines
Quoted 3 lines
I tested it on my pine64 lts e.g. loading the driver and reading the reset/clock/sysstatus registers to ensure everything is unmasked and has expected values.
Isn't the point of hwspinlocks that it's shared between the ARISC core and the ARM cores. How did you test that the lock was actually taken on the other side just by using the ARM cores?
I haven't. I'm really focuse don just enabling this on the linux side of things. True, hw spinlocks are used to synchronize cpu running different OS'es. It's still implementation defined which hwspinlock is used for which component. Additionally if we assume the ARISC core uses spinlock this means by the time linux is booted the spinlocks should already be clocked and out of software reset so perhahps this is also redundant in the driver?
<snip>
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 17 lines · Nikolay Borisov
Quoted 14 lines · Maxime Ripard
Quoted 12 lines · Nikolay Borisov
Quoted 7 lines · Maxime Ripard
Hi,
Quoted 2 lines · Nikolay Borisov
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
I tested it on my pine64 lts e.g. loading the driver and reading the reset/clock/sysstatus registers to ensure everything is unmasked and has expected values.
Quoted 7 lines
Quoted 3 lines
Isn't the point of hwspinlocks that it's shared between the ARISC core and the ARM cores. How did you test that the lock was actually taken on the other side just by using the ARM cores?
I haven't. I'm really focuse don just enabling this on the linux side of things. True, hw spinlocks are used to synchronize cpu running different OS'es.
I'm sorry but this driver hasn't been really tested then. The whole point of it is to synchronise with something. If you tested without that something, it's just like testing a network driver without having anything connected on the network you're testing it on: it probably looks like it's working, but you really can't tell.
Quoted 5 lines
It's still implementation defined which hwspinlock is used for which component. Additionally if we assume the ARISC core uses spinlock this means by the time linux is booted the spinlocks should already be clocked and out of software reset so perhahps this is also redundant in the driver?
Linux also likes to disable the clocks no one is using, so in such a situation, what would happen? Can the ARISC still use them, should we maintain the enabled all the time?
This is exactly the kind of corner-cases that we need a test for.
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 22 lines · Maxime Ripard
Quoted 21 lines · Nikolay Borisov
Quoted 17 lines · Maxime Ripard
Quoted 4 lines · Nikolay Borisov
Quoted 3 lines · Maxime Ripard
Hi,
On Mon, Feb 10, 2020 at 07:01:41PM +0200, Nikolay Borisov wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
I tested it on my pine64 lts e.g. loading the driver and reading the reset/clock/sysstatus registers to ensure everything is unmasked and has expected values.
Isn't the point of hwspinlocks that it's shared between the ARISC core and the ARM cores. How did you test that the lock was actually taken on the other side just by using the ARM cores?
Quoted 6 lines
Quoted 3 lines
I haven't. I'm really focuse don just enabling this on the linux side of things. True, hw spinlocks are used to synchronize cpu running different OS'es.
I'm sorry but this driver hasn't been really tested then. The whole point of it is to synchronise with something. If you tested without
I disagree, the whole point is to expose the facility for other drivers which, in turn, might need to synchronize with that other thing. I see the hwspinlock driver as a dumb provider of the interface. The only pertinent contention point I see is how should the clock/soft reset registers be programmed considering the spinlocks might be accessed outside of linux.
Quoted 10 lines
that something, it's just like testing a network driver without having anything connected on the network you're testing it on: it probably looks like it's working, but you really can't tell.
Quoted 5 lines
It's still implementation defined which hwspinlock is used for which component. Additionally if we assume the ARISC core uses spinlock this means by the time linux is booted the spinlocks should already be clocked and out of software reset so perhahps this is also redundant in the driver?
Quoted 5 lines
Linux also likes to disable the clocks no one is using, so in such a situation, what would happen? Can the ARISC still use them, should we maintain the enabled all the time?
This is exactly the kind of corner-cases that we need a test for.
Fair point BUT, and this is one big BUT. This other thing (the ARISC fw) doesn't have a contract with the kernel on synchronization. So should the test be performed against allwinner's binary blob or against some of the open source alternatives ( I only saw it mentioned on the sunxi web page but no links to such open source alternatives).
Furthermore, if we assume we should be compatible with the binary blob it needs to be RE'd in order to understand which hw spinlocks it's using for synchronization and I'm not aware of any such effort.
Quoted 3 lines
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Quoted 29 lines · Nikolay Borisov
Quoted 26 lines · Maxime Ripard
Quoted 24 lines · Nikolay Borisov
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Nikolay Borisov
Quoted 7 lines · Maxime Ripard
Hi,
Quoted 2 lines · Nikolay Borisov
Based on the datasheet this implements support for the hwspinlock IP block.
How was this tested?
Quoted 7 lines
Quoted 3 lines
I tested it on my pine64 lts e.g. loading the driver and reading the reset/clock/sysstatus registers to ensure everything is unmasked and has expected values.
Isn't the point of hwspinlocks that it's shared between the ARISC core and the ARM cores. How did you test that the lock was actually taken on the other side just by using the ARM cores?
I haven't. I'm really focuse don just enabling this on the linux side of things. True, hw spinlocks are used to synchronize cpu running different OS'es.
Quoted 5 lines
Quoted 2 lines
I'm sorry but this driver hasn't been really tested then. The whole point of it is to synchronise with something. If you tested without
I disagree, the whole point is to expose the facility for other drivers which, in turn, might need to synchronize with that other thing.
And you haven't tested that either.
Quoted 15 lines
I see the hwspinlock driver as a dumb provider of the interface. The only pertinent contention point I see is how should the clock/soft reset registers be programmed considering the spinlocks might be accessed outside of linux.
Quoted 10 lines
that something, it's just like testing a network driver without having anything connected on the network you're testing it on: it probably looks like it's working, but you really can't tell.
Quoted 5 lines
It's still implementation defined which hwspinlock is used for which component. Additionally if we assume the ARISC core uses spinlock this means by the time linux is booted the spinlocks should already be clocked and out of software reset so perhahps this is also redundant in the driver?
Quoted 8 lines
Quoted 5 lines
Linux also likes to disable the clocks no one is using, so in such a situation, what would happen? Can the ARISC still use them, should we maintain the enabled all the time?
This is exactly the kind of corner-cases that we need a test for.
Fair point BUT, and this is one big BUT. This other thing (the ARISC fw) doesn't have a contract with the kernel on synchronization.
You really need two things here:
- A hwspinlock driver that works, and you can see that on the other side you have that lock reported as taken (either taking one on the ARISC and seeing that it's taken on the ARM core, or the other way around). You don't really need a contract for that to do that kind of test, you can hack your own.
- Once that driver is working, indeed, we'll need to come up with that contract. It's not that hard, really, it's just assigning a number to every device that could be shared, and we're even in a position where we can probably force that, and every implementation would have to comply. But that's a second step.
Quoted 8 lines
So should the test be performed against allwinner's binary blob or against some of the open source alternatives ( I only saw it mentioned on the sunxi web page but no links to such open source alternatives).
Furthermore, if we assume we should be compatible with the binary blob it needs to be RE'd in order to understand which hw spinlocks it's using for synchronization and I'm not aware of any such effort.
You don't really need to care about the Allwinner firmware. If they already have a list of devices they have assigned, it's just as good as any and if it makes sense we can use it, but if they don't or if it doesn't make sense, I'm totally fine ignoring that driver as well.
The best thing you should target right now is crust:
https://github.com/crust-firmware/crust
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/3 arm64: dts: allwinner: a64: Add hwspinlock node
In reply to Nikolay BorisovAdd a node describing the hwspinlock on A64.
--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +9 -0
@@ -1182,5 +1182,14 @@ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; clocks = <&osc24M>; }; + + hwspinlock: spinlock@1c18000 { + compatible = "allwinner,sun50i-a64-hwspinlock"; + reg = <0x01c18000 0x1000>; + clocks = <&ccu CLK_BUS_SPINLOCK>; + resets = <&ccu RST_BUS_SPINLOCK>; + #hwlock-cells = <1>; + status = "disabled"; + }; }; };
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/3] arm64: dts: allwinner: a64: Add hwspinlock node
Hi,
Quoted 12 lines · Nikolay Borisov
Add a node describing the hwspinlock on A64.
Signed-off-by Nikolay Borisov <[email protected]>--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +0
-0
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 1186
Quoted 5 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2
-0@@ -1182,5 +1182,14 @@ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; clocks = <&osc24M>; }; + + hwspinlock: spinlock@1c18000 {
Nodes are supposed to be ordered by ascending physical address
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 1192
Quoted 6 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +6
-0+ compatible = "allwinner,sun50i-a64-hwspinlock"; + reg = <0x01c18000 0x1000>; + clocks = <&ccu CLK_BUS_SPINLOCK>; + resets = <&ccu RST_BUS_SPINLOCK>; + #hwlock-cells = <1>; + status = "disabled";
Is there a reason to disable it?
Also, my understanding was that hwspinlocks were meant to be used by client drivers, so surely we must tie them to other device nodes too, right?
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/3] arm64: dts: allwinner: a64: Add hwspinlock node
Quoted 23 lines · Maxime Ripard
Hi,
Quoted 12 lines · Nikolay Borisov
Add a node describing the hwspinlock on A64.
Signed-off-by Nikolay Borisov <[email protected]>--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +0
-0arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 1186
Quoted 5 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2
-0@@ -1182,5 +1182,14 @@ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; clocks = <&osc24M>; }; + + hwspinlock: spinlock@1c18000 {Nodes are supposed to be ordered by ascending physical address
Quoted 8 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 1192
Quoted 6 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +6
-0+ compatible = "allwinner,sun50i-a64-hwspinlock"; + reg = <0x01c18000 0x1000>; + clocks = <&ccu CLK_BUS_SPINLOCK>; + resets = <&ccu RST_BUS_SPINLOCK>; + #hwlock-cells = <1>; + status = "disabled";Is there a reason to disable it?
I wondered about that - on the one hand we can safely leave it always enabled, on the other hand all devices are are disabled in the dtsi.
Quoted 4 lines
Also, my understanding was that hwspinlocks were meant to be used by client drivers, so surely we must tie them to other device nodes too, right?
Perhaps but at this point I'm not sure to which device specifically.
Quoted 3 lines
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/3] arm64: dts: allwinner: a64: Add hwspinlock node
Quoted 35 lines · Nikolay Borisov
Quoted 23 lines · Maxime Ripard
Hi,
Quoted 12 lines · Nikolay Borisov
Add a node describing the hwspinlock on A64.
Signed-off-by Nikolay Borisov <[email protected]>--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +0
-0arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 1186
Quoted 5 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2
-0@@ -1182,5 +1182,14 @@ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; clocks = <&osc24M>; }; + + hwspinlock: spinlock@1c18000 {Nodes are supposed to be ordered by ascending physical address
Quoted 8 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 1192
Quoted 6 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +6
-0+ compatible = "allwinner,sun50i-a64-hwspinlock"; + reg = <0x01c18000 0x1000>; + clocks = <&ccu CLK_BUS_SPINLOCK>; + resets = <&ccu RST_BUS_SPINLOCK>; + #hwlock-cells = <1>; + status = "disabled";Is there a reason to disable it?
Quoted 2 lines
I wondered about that - on the one hand we can safely leave it always enabled, on the other hand all devices are are disabled in the dtsi.
Not all of them, only the one that are connected to external pins. The PMU or GPU aren't for example.
Quoted 5 lines
Quoted 3 lines
Also, my understanding was that hwspinlocks were meant to be used by client drivers, so surely we must tie them to other device nodes too, right?
Perhaps but at this point I'm not sure to which device specifically.
All the one that are shared with the ARISC core and needs some synchronisation with the firmware running there.
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/3 dt-bindings: hwlock: Document A64 hwspinlock bindings
In reply to Nikolay BorisovAdd binding for the hwspinlock found on Allwinner A64 SoC.
--- .../bindings/hwlock/sunxi-hwspinlock.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwlock/sunxi-hwspinlock.txt
Documentation/devicetree/bindings/hwlock/sunxi-hwspinlock.txt new file +27 -0
@@ -0,0 +1,27 @@ +Allwinner HwSpinlock for A64 SoC +========================================= + +Required properties: +- compatible: Should be "allwinner,sun50i-a64-hwspinlock" +- reg: Contains the hwspinlock module register address space + (base address and length) +- resets: phandle to the reset control for the hwspinlock +- clocks: phandle to the clock feeding the hwspinlock +- #hwlock-cells: Should be 1. The A64 hwspinlock users will use a + 0-indexed relative hwlock number as the argument + specifier value for requesting a specific hwspinlock + within a hwspinlock bank. + +Please look at the generic hwlock binding for usage information for consumers, +"Documentation/devicetree/bindings/hwlock/hwlock.txt" + +Example: + +1. Allwinner A64 +hwspinlock: spinlock@1c18000 { + compatible = "allwinner,sun50i-a64-hwspinlock"; + reg = <0x01c18000 0x1000>; + clocks = <&ccu CLK_BUS_SPINLOCK>; + resets = <&ccu RST_BUS_SPINLOCK>; + #hwlock-cells = <1>; +};
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 3/3] dt-bindings: hwlock: Document A64 hwspinlock bindings
Quoted 3 lines · Nikolay Borisov
Add binding for the hwspinlock found on Allwinner A64 SoC.
Signed-off-by Nikolay Borisov <[email protected]>
This does look good, but could you please rewrite this in YAML instead?
We will need review feedback from the devicetree guys, so please include Rob and devicetree@ on your next post (i.e. run get_maintainers.pl).
Regards,
jorn
Quoted 41 lines
--- .../bindings/hwlock/sunxi-hwspinlock.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwlock/sunxi-hwspinlock.txtDocumentation/devicetree/bindings/hwlock/sunxi-hwspinlock.txt new file +27
-0@@ -0,0 +1,27 @@ +Allwinner HwSpinlock for A64 SoC +========================================= + +Required properties: +- compatible: Should be "allwinner,sun50i-a64-hwspinlock" +- reg: Contains the hwspinlock module register address space + (base address and length) +- resets: phandle to the reset control for the hwspinlock +- clocks: phandle to the clock feeding the hwspinlock +- #hwlock-cells: Should be 1. The A64 hwspinlock users will use a + 0-indexed relative hwlock number as the argument + specifier value for requesting a specific hwspinlock + within a hwspinlock bank. + +Please look at the generic hwlock binding for usage information for consumers, +"Documentation/devicetree/bindings/hwlock/hwlock.txt" + +Example: + +1. Allwinner A64 +hwspinlock: spinlock@1c18000 { + compatible = "allwinner,sun50i-a64-hwspinlock"; + reg = <0x01c18000 0x1000>; + clocks = <&ccu CLK_BUS_SPINLOCK>; + resets = <&ccu RST_BUS_SPINLOCK>; + #hwlock-cells = <1>; +};Signature · 1 line
2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel