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

6 commits


18 Apr, 2018

2 commits

  • In some scenarios, user need do some time-consuming or sleepable
    operations under the hardware spinlock protection for synchronization
    between the multiple subsystems.

    For example, there is one PMIC efuse on Spreadtrum platform, which
    need to be accessed under one hardware lock. But during the hardware
    lock protection, the efuse operation is time-consuming to almost 5 ms,
    so we can not disable the interrupts or preemption so long in this case.

    Thus we can introduce one new mode to indicate that we just acquire the
    hardware lock and do not disable interrupts or preemption, meanwhile we
    should force user to protect the hardware lock with mutex or spinlock to
    avoid dead-lock.

    Signed-off-by: Baolin Wang
    Signed-off-by: Bjorn Andersson

    Baolin Wang
     
  • We have different hwspinlock modes to select, thus it will be more
    readable to handle different modes with using 'switch' statement
    instead of 'if' statement.

    Signed-off-by: Baolin Wang
    Signed-off-by: Bjorn Andersson

    Baolin Wang
     

18 Nov, 2017

1 commit


07 Nov, 2017

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

18 May, 2017

2 commits


07 Jul, 2016

1 commit


21 May, 2016

1 commit

  • radix_tree_is_indirect_ptr() is an internal API. The correct call to
    use is radix_tree_deref_retry() which has the appropriate unlikely()
    annotation.

    Fixes: c6400ba7e13a ("drivers/hwspinlock: fix race between radix tree insertion and lookup")
    Signed-off-by: Matthew Wilcox
    Cc: Konstantin Khlebnikov
    Cc: Kirill Shutemov
    Cc: Jan Kara
    Cc: Neil Brown
    Cc: Ross Zwisler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

04 Feb, 2016

1 commit

  • of_hwspin_lock_get_id() is protected by the RCU lock, which means that
    insertions can occur simultaneously with the lookup. If the radix tree
    transitions from a height of 0, we can see a slot with the indirect_ptr
    bit set, which will cause us to at least read random memory, and could
    cause other havoc.

    Fix this by using the newly introduced radix_tree_iter_retry().

    Signed-off-by: Matthew Wilcox
    Cc: Hugh Dickins
    Cc: Ohad Ben-Cohen
    Cc: Konstantin Khlebnikov
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

01 Jul, 2015

1 commit


12 Jun, 2015

1 commit

  • Add hwspinlock support for the CSR atlas7 SoC.

    The Hardware Spinlock device on atlas7 provides hardware assistance
    for synchronization between the multiple processors in the system
    (dual Cortex-A7, CAN bus Cortex-M3 and audio DSP).

    Reviewed-by: Suman Anna
    Reviewed-by: Bjorn Andersson
    Signed-off-by: Wei Chen
    Signed-off-by: Barry Song
    Signed-off-by: Ohad Ben-Cohen

    Wei Chen
     

02 May, 2015

3 commits

  • Add driver for Qualcomm Hardware Mutex block found in many Qualcomm
    SoCs.

    Based on initial effort by Kumar Gala

    Signed-off-by: Bjorn Andersson
    Reviewed-by: Andy Gross
    Reviewed-by: Jeffrey Hugo
    Signed-off-by: Ohad Ben-Cohen

    Bjorn Andersson
     
  • HwSpinlock IP is present only on OMAP4 and other newer SoCs,
    which are all device-tree boot only. This patch adds the
    base support for parsing the DT nodes, and removes the code
    dealing with the traditional platform device instantiation.

    Signed-off-by: Suman Anna
    [tony@atomide.com: ack for legacy file removal]
    Acked-by: Tony Lindgren
    [comment on the imperfect always-zero base_id]
    Signed-off-by: Ohad Ben-Cohen

    Suman Anna
     
  • This patch adds a new OF-friendly API of_hwspin_lock_get_id()
    for hwspinlock clients to use/request locks from a hwspinlock
    device instantiated through a device-tree blob. This new API
    can be used by hwspinlock clients to get the id for a specific
    lock using the phandle + args specifier, so that it can be
    requested using the available hwspin_lock_request_specific()
    API.

    Signed-off-by: Suman Anna
    Reviewed-by: Bjorn Andersson
    [small comment clarification]
    Signed-off-by: Ohad Ben-Cohen

    Suman Anna
     

20 Oct, 2014

1 commit


29 Jul, 2014

2 commits

  • HwSpinlocks are supported on TI's AM33xx, AM43xx and DRA7xx SoC
    device families as well. The IPs are identical to that of
    OMAP4/OMAP5, except for the number of locks.

    Add a depends on to the above family of SoCs to enable the
    build support for OMAP hwspinlock driver for any of the above
    SoC configs.

    Signed-off-by: Suman Anna
    [small commit log changes]
    Signed-off-by: Ohad Ben-Cohen

    Suman Anna
     
  • The number of hwspinlocks are determined based on the value read
    from the IP block's SYSSTATUS register. However, the module may
    not be enabled and clocked, and the read may result in a bus error.

    This particular issue is seen rather easily on AM33XX, since the
    module wakeup is software controlled, and it is disabled out of
    reset. Make sure the module is enabled and clocked before reading
    the SYSSTATUS register.

    Signed-off-by: Suman Anna
    [replace pm_runtime_put_sync with lenient pm_runtime_put]
    Signed-off-by: Ohad Ben-Cohen

    Suman Anna
     

08 May, 2013

1 commit