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

    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

    Ezequiel Garcia
     

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

    Gustavo A. R. Silva
     
  • 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

    Baolin Wang
     

22 Jan, 2020

7 commits


29 Dec, 2019

1 commit


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

    Baolin Wang
     
  • 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

    Baolin Wang
     
  • 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

    Baolin Wang
     
  • 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

    Baolin Wang
     

05 Oct, 2019

7 commits


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

    Fabien Dessenne
     
  • 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

    Fabien Dessenne
     
  • 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

    Fabien Dessenne
     
  • 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

    Suman Anna
     
  • 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

    Suman Anna
     

04 Jan, 2019

1 commit


06 Dec, 2018

1 commit


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

    Baolin Wang
     

27 Jun, 2018

4 commits


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

    Linus Torvalds
     

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

    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

    Kees Cook
     

25 May, 2018

2 commits