14 Jul, 2020
1 commit
-
In modern Qualcomm platforms the mutex region of the TCSR is forked off
into its own block, all with a offset of 0 and stride of 4096, and in
some of these platforms no other registers in this region is accessed
from Linux.So add support for directly memory mapping this register space, to avoid
the need to represent this block using a syscon.Reviewed-by: Baolin Wang
Reviewed-by: Vinod Koul
Signed-off-by: Bjorn Andersson
Link: https://lore.kernel.org/r/20200622075956.171058-4-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson
21 Jun, 2020
1 commit
-
Every hwspinlock driver is expected to depend on the
hwspinlock core, so it's possible to simplify the
Kconfig, factoring out the HWSPINLOCK dependency.Reviewed-by: Baolin Wang
Signed-off-by: Ezequiel Garcia
Link: https://lore.kernel.org/r/20200414220943.6203-1-ezequiel@collabora.com
Signed-off-by: Bjorn Andersson
26 Mar, 2020
2 commits
-
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:struct foo {
int stuff;
struct boo array[];
};By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.Also, notice that, dynamic memory allocations won't be affected by
this change:"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")Reviewed-by: Baolin Wang
Signed-off-by: Gustavo A. R. Silva
Link: https://lore.kernel.org/r/20200319213839.GA10669@embeddedor.com
Signed-off-by: Bjorn Andersson -
Allow drivers to be built with COMPILE_TEST.
Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/5a95c3de07ef020a4e2f2776fa5adb00637ee387.1581324976.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson
22 Jan, 2020
7 commits
-
Use devm_hwspin_lock_register() to register the hwlock controller instead of
unregistering the hwlock controller explicitly when removing the device.Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/8f94e67b5f9af20a93418a2fc9cc71b194f1285c.1578453662.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson -
Since the hwspinlock core has changed the PM runtime to be optional, and
the SIRF hardware spinlock has no pm runtime requirement, thus remove
these redundant PM runtime functions.Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/c921e391aa2a652d8d6ae0e4041202cec9d917e7.1578453662.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson -
Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together, which can simpify the code.Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/dfa043f317c609a6172468ac11598968dd751bce.1578453662.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson -
Use devm_kzalloc() to allocate memory, which can simplify the error
handling.Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/c066ad704c1a5fd52c3002cac80ddd59b3901b01.1578453062.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson -
Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together, which can simpify the code.
Meanwhile renaming the error label to make more sense after removing
iounmap().Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/6c09c5034a7e68fdfc22d2cb5daa375bccb33a66.1578453062.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson -
Use devm_hwspin_lock_register() to register the hwlock controller instead of
unregistering the hwlock controller explicitly when removing the device.Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/d69ad8611a68b0cac3c927d19901f3c113c5435c.1578452735.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson -
Since the hwspinlock core has changed the PM runtime to be optional, and
the Qualcomm hardware spinlock has no pm runtime requirement, thus remove
these redundant PM runtime functions.Signed-off-by: Baolin Wang
Link: https://lore.kernel.org/r/e0bb751feb7af709f92e52a07d0e8ebcf1ee44ff.1578452735.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson
29 Dec, 2019
1 commit
-
Use devm_platform_ioremap_resource() to simplify code.
Signed-off-by: Yangtao Li
Link: https://lore.kernel.org/r/20191228191541.26999-1-tiny.windzz@gmail.com
Signed-off-by: Bjorn Andersson
09 Nov, 2019
4 commits
-
Since the hwspinlock core has changed the PM runtime to be optional, thus
remove the redundant PM runtime implementation in the u8500 HWSEM driver.Reviewed-by: Linus Walleij
Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Since the hwspinlock core has changed the PM runtime to be optional, thus
remove the redundant PM runtime implementation in the Spreadtrum hwlock
driver.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Now some hwspinlock controllers did not have the requirement to implement
the PM runtime, but drivers must enable the PM runtime to comply with the
hwspinlock core.Thus we can change the PM runtime support to be optional by validating
the -EACCES error number which means the PM runtime is not enabled, and
removing the return value validating of pm_runtime_put(). So that we
can remove some redundant PM runtime code in drivers.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
The original code use BUG_ON() to validate the parameters when locking
or unlocking one hardware lock, but we should not crash the whole kernel
though the hwlock parameters are incorrect, instead we can return
the error number for users and give some warning.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson
05 Oct, 2019
7 commits
-
Use devm_hwspin_lock_register() to register the hwlock controller instead of
unregistering the hwlock controller explicitly when removing the device.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
We must check the return value of clk_prepare_enable() to make sure the
hardware spinlock controller can be enabled successfully, otherwise we
should return error.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together, which can simpify the code.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Use devm_hwspin_lock_register() to register the hwlock controller instead of
unregistering the hwlock controller explicitly when removing the device.Reviewed-by: Linus Walleij
Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Use devm_kzalloc() to allocate memory.
Reviewed-by: Linus Walleij
Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together, which can simpify the code.Reviewed-by: Linus Walleij
Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson
30 Jun, 2019
5 commits
-
Add the 'in_atomic' mode which can be called from an atomic context.
This mode relies on the existing 'raw' mode (no lock, no preemption/irq
disabling) with the difference that the timeout is not based on jiffies
(jiffies won't increase when irq are disabled) but handled with
busy-waiting udelay() calls.Signed-off-by: Fabien Dessenne
Signed-off-by: Bjorn Andersson -
Implement this optional ops, called by hwspinlock core while spinning on
a lock, between two successive invocations of trylock().Reviewed-by: Benjamin Gaignard
Signed-off-by: Fabien Dessenne
Signed-off-by: Bjorn Andersson -
Do not wait for hwspinlock device registration if it is not available
for use.Acked-by: Suman Anna
Signed-off-by: Fabien Dessenne
Signed-off-by: Bjorn Andersson -
Add a debug level trace statement in the OMAP HwSpinlock driver
probe function to print the number of hwlocks on a successful
registration.Signed-off-by: Suman Anna
Signed-off-by: Bjorn Andersson -
A HwSpinlock IP is also present on the newer TI K3 AM65x and J721E
family of SoCs within the Main NavSS sub-module. Reuse the existing
OMAP Hwspinlock driver to extend the support for this IP on K3 AM65x
SoCs as well. The IP has slightly different bit-fields in the
SYSCONFIG and SYSSTATUS registers.Signed-off-by: Suman Anna
Signed-off-by: Bjorn Andersson
04 Jan, 2019
1 commit
-
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().Fixes: f24fcff1d267 ("hwspinlock: add STM32 hwspinlock device")
Acked-by: Benjamin Gaignard
Signed-off-by: Wei Yongjun
Signed-off-by: Bjorn Andersson
06 Dec, 2018
1 commit
-
This patch adds support of hardware semaphores for stm32mp1 SoC.
The hardware block provides 32 semaphores.Signed-off-by: Benjamin Gaignard
Signed-off-by: Benjamin Gaignard
Signed-off-by: Bjorn Andersson
31 Jul, 2018
1 commit
-
The commit 4f1acd758b08 ("hwspinlock: Add devm_xxx() APIs to request/free
hwlock") introduces one bug, that will return one error pointer if failed
to request one hwlock, but we expect NULL pointer on error for consumers.
This patch will fix this issue.Reported-by: Dan Carpenter
Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson
27 Jun, 2018
4 commits
-
Fix one comment mistake with correct function names.
Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
This patch introduces devm_hwspin_lock_register() and devm_hwspin_lock_unregister()
interfaces to help to register or unregister one hardware spinlock controller, that
will help to simplify the cleanup code for hwspinlock drivers.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
This patch introduces some devm_xxx() APIs to help to request or free
the hwlocks, which will help to simplify the cleanup code for drivers
requesting one hwlock, ensuring that the hwlock is automatically freed
whenever the device is unbound.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson -
The hardware spinlock binding already supplied the 'hwlock-names' property
to match and get a specific hwlock, but did not supply one API for users
to get a specific hwlock by the hwlock name. So this patch introduces one
API to support this requirement.Signed-off-by: Baolin Wang
Signed-off-by: Bjorn Andersson
12 Jun, 2018
1 commit
-
Pull hwspinlock updates from Bjorn Andersson:
"In addition to migrating the files to use SPDX license headers this
introduces the ability for clients to operate a hwlock without the
framework taking any additional locks"* tag 'hwlock-v4.18' of git://github.com/andersson/remoteproc:
hwspinlock/u8500: Switch to SPDX license identifier
hwspinlock: sprd: Switch to SPDX license identifier
hwspinlock/sirf: Switch to SPDX license identifier
hwspinlock: qcom: Switch to SPDX license identifier
hwspinlock/omap: Switch to SPDX license identifier
hwspinlock/core: Switch to SPDX license identifier
hwspinlock: Introduce one new mode for hwspinlock
hwspinlock: Convert to use 'switch' statement
07 Jun, 2018
2 commits
-
Replaces open-coded struct size calculations with struct_size() for
devm_*, f2fs_*, and sock_* allocations. Automatically generated (and
manually adjusted) from the following Coccinelle script:// Direct reference to struct field.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@- alloc(HANDLE, sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(HANDLE, CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)Signed-off-by: Kees Cook
-
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:struct foo {
int stuff;
void *entry[];
};instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
// sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)Signed-off-by: Kees Cook
25 May, 2018
2 commits
-
Use the appropriate SPDX license identifier in the U8500 HWSEM
driver source file and drop the previous boilerplate license text.Cc: Mathieu J. Poirier
Reviewed-by: Linus Walleij
Signed-off-by: Suman Anna
Signed-off-by: Bjorn Andersson -
Use the appropriate SPDX license identifiers in the Spreadtrum hardware
spinlock driver source file and drop the previous boilerplate license text.Cc: Baolin Wang
Signed-off-by: Suman Anna
Signed-off-by: Bjorn Andersson