24 Mar, 2019

1 commit

  • [ Upstream commit d7bf31a0f85faaf63c63c39d55154825a1eaaea9 ]

    RING_CONTROL reg was not written due to wrong address, hence all
    the subsequent ring flush was timing out.

    Fixes: a371c10ea4b3 ("mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence")

    Signed-off-by: Rayagonda Kokatanur
    Signed-off-by: Ray Jui
    Reviewed-by: Scott Branden
    Signed-off-by: Jassi Brar
    Signed-off-by: Sasha Levin

    Rayagonda Kokatanur
     

14 Nov, 2018

1 commit

  • commit afd0b1fb22269f48d68fdf269891c653818c8047 upstream.

    acpi_pcc_probe() calls acpi_table_parse_entries_array() but fails
    to check for an error return. This in turn can result in calling
    kcalloc() with a negative count as well as emitting the following
    misleading erorr message:

    [ 2.642015] Could not allocate space for PCC mbox channels

    Fixes: 8f8027c5f935 (mailbox: PCC: erroneous error message when parsing ACPI PCCT)
    Signed-off-by: David Arcari
    Reviewed-by: Al Stone
    Cc: 4.18+ # 4.18+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    David Arcari
     

15 Aug, 2018

2 commits

  • The i.MX Messaging Unit is a two side block which allows applications
    implement communication over this sides.

    The MU includes the following features:
    - Messaging control by interrupts or by polling
    - Four general-purpose interrupt requests reflected to the other side
    - Three general-purpose flags reflected to the other side
    - Four receive registers with maskable interrupt
    - Four transmit registers with maskable interrupt

    Reviewed-by: Vladimir Zapolskiy
    Reviewed-by: Dong Aisheng
    Signed-off-by: Oleksij Rempel
    Signed-off-by: Jassi Brar

    Oleksij Rempel
     
  • Fix missing MODULE_LICENSE() in mtk-cmdq-mailbox.c:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/mailbox/mtk-cmdq-mailbox.o

    Fixes: 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver")
    Signed-off-by: Randy Dunlap
    Cc:
    Cc: CK Hu
    Cc: Houlong Wei
    Signed-off-by: Jassi Brar

    Randy Dunlap
     

03 Aug, 2018

9 commits

  • This patch is first version of Mediatek Command Queue(CMDQ) driver. The
    CMDQ is used to help write registers with critical time limitation,
    such as updating display configuration during the vblank. It controls
    Global Command Engine (GCE) hardware to achieve this requirement.
    Currently, CMDQ only supports display related hardwares, but we expect
    it can be extended to other hardwares for future requirements.

    Signed-off-by: Houlong Wei
    Signed-off-by: HS Liao
    Signed-off-by: CK Hu
    Signed-off-by: Jassi Brar

    Houlong Wei
     
  • Secure Proxy is another communication scheme in Texas Instrument's
    devices intended to provide an unique communication path from various
    processors in the System on Chip(SoC) to a central System Controller.

    Secure proxy is, in effect, an evolution of current generation Message
    Manager hardware block found in K2G devices. However the following
    changes have taken place:

    Secure Proxy instance exposes "threads" or "proxies" which is
    primary representation of "a" communication channel. Each thread is
    preconfigured by System controller configuration based on SoC usage
    requirements. Secure proxy by itself represents a single "queue" of
    communication but allows the proxies to be independently operated.

    Each Secure proxy thread can uniquely have their own error and threshold
    interrupts allowing for more fine control of IRQ handling.

    Provide the driver support for Secure Proxy and thread instances.

    NOTE: Secure proxy configuration is only done by System Controller,
    hence these are assumed to be pre-configured instances.

    See AM65x Technical Reference Manual (SPRUID7, April 2018)
    for further details: http://www.ti.com/lit/pdf/spruid7

    Signed-off-by: Nishanth Menon
    Signed-off-by: Jassi Brar

    Nishanth Menon
     
  • For newer generation of the hardware, the naming of the region is
    decided at integration level and there could be additional regions
    as well. Hence move the region naming to be described from compatible
    descriptor.

    Signed-off-by: Nishanth Menon
    Signed-off-by: Jassi Brar

    Nishanth Menon
     
  • Change mask used to extract the message count to be descriptor based.

    This is to support changes for count location for various SoC
    solutions.

    Signed-off-by: Nishanth Menon
    Signed-off-by: Jassi Brar

    Nishanth Menon
     
  • In a much bigger system SoCs, the number of Rx channels can be
    many and mostly unused based on the system of choice, and not all
    Rx channels need IRQs and allocating all memory at probe will be
    inefficient. Some SoCs could have total threads in the 100s and usage
    would be just 1 Rx thread.

    Thus, request and map the IRQs and allocate memory only when needed.

    Since these channels are requested by client drivers on need, our
    utilization will be optimal.

    Signed-off-by: Nishanth Menon
    Signed-off-by: Jassi Brar

    Nishanth Menon
     
  • Though q_proxies and q_slices do describe the hardware configuration,
    they are not necessary for operation given that the values are
    always default. Hence drop the same.

    Signed-off-by: Nishanth Menon
    Signed-off-by: Jassi Brar

    Nishanth Menon
     
  • The OMAP Mailbox driver is directly using an integer value as
    match data for distinguishing the interrupt register layout
    between OMAP2 and OMAP4+ SoCs. Introduce a dedicated structure
    for storing this match data, and simplify the probe function by
    using the of_device_get_match_data() function. This allows the
    driver to scale for 64-bit platforms by eliminating the unnecessary
    type-casting between a u32 and a void pointer types.

    Signed-off-by: Suman Anna
    Signed-off-by: Jassi Brar

    Suman Anna
     
  • Use the appropriate SPDX license identifier in the OMAP Mailbox
    driver source files and drop the previous boilerplate license text.

    Signed-off-by: Suman Anna
    Signed-off-by: Jassi Brar

    Suman Anna
     
  • There is a potential execution path in which function
    platform_get_resource() returns NULL. If this happens,
    we will end up having a NULL pointer dereference.

    Fix this by replacing devm_ioremap with devm_ioremap_resource,
    which has the NULL check and the memory region request.

    This code was detected with the help of Coccinelle.

    Cc: stable@vger.kernel.org
    Fixes: f700e84f417b ("mailbox: Add support for APM X-Gene platform mailbox driver")
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Jassi Brar

    Gustavo A. R. Silva
     

13 Jun, 2018

2 commits

  • The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
    This patch replaces cases of:

    devm_kzalloc(handle, a * b, gfp)

    with:
    devm_kcalloc(handle, a * b, gfp)

    as well as handling cases of:

    devm_kzalloc(handle, a * b * c, gfp)

    with:

    devm_kzalloc(handle, array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    devm_kcalloc(handle, array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    devm_kzalloc(handle, 4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    Some manual whitespace fixes were needed in this patch, as Coccinelle
    really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    expression HANDLE;
    type TYPE;
    expression THING, E;
    @@

    (
    devm_kzalloc(HANDLE,
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    devm_kzalloc(HANDLE,
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression HANDLE;
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    devm_kzalloc(HANDLE,
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    expression HANDLE;
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    expression HANDLE;
    identifier SIZE, COUNT;
    @@

    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression HANDLE;
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    devm_kzalloc(HANDLE,
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression HANDLE;
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    devm_kzalloc(HANDLE,
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    devm_kzalloc(HANDLE,
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    expression HANDLE;
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    devm_kzalloc(HANDLE,
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression HANDLE;
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
    |
    devm_kzalloc(HANDLE,
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    devm_kzalloc(HANDLE,
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression HANDLE;
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
    |
    devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
    |
    devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
    |
    devm_kzalloc(HANDLE, C1 * C2, ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - devm_kzalloc
    + devm_kcalloc
    (HANDLE,
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     
  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

08 Jun, 2018

1 commit

  • Pull mailbox updates from Jassi Brar:

    - Remove HAS_DMA config dependencies

    - New STMicroelectronics STM32 IPCC driver

    - Enable QCom driver to run more controllers

    - Fixed return code from null to ptr-err for Brcm driver

    - Fix kconfig dependencies for the HiSilicon driver

    * tag 'mailbox-v4.18' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
    mailbox/drivers/hisi: Consolidate the Kconfig for the MAILBOX
    mailbox: Add support for Qualcomm SDM845 SoCs
    dt-bindings: mailbox: Add APSS shared binding for SDM845 SoCs
    mailbox: bcm2835: Fix of_xlate return value
    mailbox: qcom: Add msm8998 hmss compatible
    mailbox: add STMicroelectronics STM32 IPCC driver
    dt-bindings: mailbox: add STMicroelectronics STM32 IPCC binding
    mailbox: Remove depends on HAS_DMA in case of platform dependency

    Linus Torvalds
     

07 Jun, 2018

6 commits

  • The current defconfig is inconsistent as it selects the mailbox and
    the clock for the hi6220 and the hi3660 without having their Kconfigs
    making sure the dependencies are correct. It ends up when selecting
    different versions for the kernel (for example when git bisecting)
    those options disappear and they don't get back, leading to unexpected
    behaviors. In our case, the cpufreq driver does no longer work because
    the clock fails to initialize due to the clock stub and the mailbox
    missing.

    In order to have the dependencies correctly set when defaulting, let's
    do the same as commit 3a49afb84ca074e ("clk: enable hi655x common clk
    automatically") where we select automatically the driver when the
    parent driver is selected. With sensible defaults in place, we can leave
    other choices for EXPERT.

    Signed-off-by: Daniel Lezcano
    Signed-off-by: Leo Yan
    Signed-off-by: Jassi Brar

    Daniel Lezcano
     
  • Add the corresponding APSS shared offset for SDM845 SoC

    Signed-off-by: Sibi Sankar
    Reviewed-by: Bjorn Andersson
    Signed-off-by: Jassi Brar

    Sibi Sankar
     
  • The bcm2835-mailbox returns NULL instead of an error pointer, which could
    result in a NULL ptr dereference in mbox_request_channel. So fix this
    by returning a proper error pointer.

    Signed-off-by: Stefan Wahren
    Fixes: 0bae6af6d704 ("mailbox: Enable BCM2835 mailbox support")
    Reviewed-by: Eric Anholt
    Signed-off-by: Jassi Brar

    Stefan Wahren
     
  • The Qualcomm MSM8998 platform has a APCS HMSS GLOBAL block, add the
    compatible for this.

    Signed-off-by: Bjorn Andersson
    Reviewed-by: Rob Herring
    Signed-off-by: Jassi Brar

    Bjorn Andersson
     
  • The STMicroelectronics STM32 Inter-Processor Communication Controller
    (IPCC) is used for communicating data between two processors.
    It provides a non blocking signaling mechanism to post and retrieve
    communication data in an atomic way.

    Signed-off-by: Fabien Dessenne
    Signed-off-by: Ludovic Barre
    Signed-off-by: Jassi Brar

    Fabien Dessenne
     
  • Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
    symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
    In most cases this other symbol is an architecture or platform specific
    symbol, or PCI.

    Generic symbols and drivers without platform dependencies keep their
    dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
    cannot work anyway.

    This simplifies the dependencies, and allows to improve compile-testing.

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Mark Brown
    Acked-by: Robin Murphy
    Signed-off-by: Jassi Brar

    Geert Uytterhoeven
     

18 May, 2018

1 commit

  • There have been multiple reports of the following error message:

    [ 0.068293] Error parsing PCC subspaces from PCCT

    This error message is not correct. In multiple cases examined, the PCCT
    (Platform Communications Channel Table) concerned is actually properly
    constructed; the problem is that acpi_pcc_probe() which reads the PCCT
    is making the assumption that the only valid PCCT is one that contains
    subtables of one of two types: ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE or
    ACPI_PCCT_TYPE_HW_REDUCED_TYPE2. The number of subtables of these
    types are counted and as long as there is at least one of the desired
    types, the acpi_pcc_probe() succeeds. When no subtables of these types
    are found, regardless of whether or not any other subtable types are
    present, the error mentioned above is reported.

    In the cases reported to me personally, the PCCT contains exactly one
    subtable of type ACPI_PCCT_TYPE_GENERIC_SUBSPACE. The function
    acpi_pcc_probe() does not count it as a valid subtable, so believes
    there to be no valid subtables, and hence outputs the error message.

    An example of the PCCT being reported as erroneous yet perfectly fine
    is the following:

    Signature : "PCCT"
    Table Length : 0000006E
    Revision : 05
    Checksum : A9
    Oem ID : "XXXXXX"
    Oem Table ID : "XXXXX "
    Oem Revision : 00002280
    Asl Compiler ID : "XXXX"
    Asl Compiler Revision : 00000002

    Flags (decoded below) : 00000001
    Platform : 1
    Reserved : 0000000000000000

    Subtable Type : 00 [Generic Communications Subspace]
    Length : 3E

    Reserved : 000000000000
    Base Address : 00000000DCE43018
    Address Length : 0000000000001000

    Doorbell Register : [Generic Address Structure]
    Space ID : 01 [SystemIO]
    Bit Width : 08
    Bit Offset : 00
    Encoded Access Width : 01 [Byte Access:8]
    Address : 0000000000001842

    Preserve Mask : 00000000000000FD
    Write Mask : 0000000000000002
    Command Latency : 00001388
    Maximum Access Rate : 00000000
    Minimum Turnaround Time : 0000

    To fix this, we count up all of the possible subtable types for the
    PCCT, and only report an error when there are none (which could mean
    either no subtables, or no valid subtables), or there are too many.
    We also change the logic so that if there is a valid subtable, we
    do try to initialize it per the PCCT subtable contents. This is a
    change in functionality; previously, the probe would have returned
    right after the error message and would not have tried to use any
    other subtable definition.

    Tested on my personal laptop which showed the error previously; the
    error message no longer appears and the laptop appears to operate
    normally.

    Signed-off-by: Al Stone
    Reviewed-by: Prashanth Prakash
    Signed-off-by: Rafael J. Wysocki

    Al Stone
     

20 Mar, 2018

1 commit

  • Hi3660 mailbox controller is used to send message within multiple
    processors, MCU, HIFI, etc. It supports 32 mailbox channels and every
    channel can only be used for single transferring direction. Once the
    channel is enabled, it needs to specify the destination interrupt and
    acknowledge interrupt, these two interrupt vectors are used to create
    the connection between the mailbox and interrupt controllers.

    The data transferring supports two modes, one is named as "automatic
    acknowledge" mode so after send message the kernel doesn't need to wait
    for acknowledge from remote and directly return; there have another mode
    is to rely on handling interrupt for acknowledge.

    This commit is for initial version driver, which only supports
    "automatic acknowledge" mode to support CPU clock, which is the only
    one consumer to use mailbox and has been verified. Later may enhance
    this driver for interrupt mode (e.g. for supporting HIFI).

    Signed-off-by: Leo Yan
    Signed-off-by: Ruyi Wang
    Signed-off-by: Kaihua Zhong
    Signed-off-by: Jassi Brar

    Kaihua Zhong
     

15 Mar, 2018

2 commits


12 Feb, 2018

1 commit

  • This is the mindless scripted replacement of kernel use of POLL*
    variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
    L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
    for f in $L; do sed -i "-es/^\([^\"]*\)\(\\)/\\1E\\2/" $f; done
    done

    with de-mangling cleanups yet to come.

    NOTE! On almost all architectures, the EPOLL* constants have the same
    values as the POLL* constants do. But they keyword here is "almost".
    For various bad reasons they aren't the same, and epoll() doesn't
    actually work quite correctly in some cases due to this on Sparc et al.

    The next patch from Al will sort out the final differences, and we
    should be all done.

    Scripted-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

05 Feb, 2018

1 commit

  • Pull mailbox updates from Jassi Brar:
    "Misc driver changes only:

    - TI-MsgMgr: Fix print format for a printk

    - TI-MSgMgr: SPDX license switch for the driver

    - QCOM-IPC: Convert driver to use regmap

    - QCOM-IPC: Spawn sibling clock device from mailbox driver"

    * tag 'mailbox-v4.16' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
    dt-bindings: mailbox: qcom: Document the APCS clock binding
    mailbox: qcom: Create APCS child device for clock controller
    mailbox: qcom: Convert APCS IPC driver to use regmap
    mailbox: ti-msgmgr: Use %zu for size_t print format
    mailbox: ti-msgmgr: Switch to SPDX Licensing

    Linus Torvalds
     

04 Feb, 2018

2 commits


10 Jan, 2018

2 commits


29 Nov, 2017

1 commit


16 Nov, 2017

1 commit

  • Pull mailbox updates from Jassi Brar:
    "Change to POLL api and fixes for FlexRM and OMAP driver.

    Summary:

    - Core: Prefer ACK method over POLL, if both supported

    - Test: use flag instead of special character

    - FlexRM: Usual driver internal minor churn

    - Omap: fix error path"

    * tag 'mailbox-v4.15' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
    mailbox/omap: unregister mbox class
    mailbox: mailbox-test: don't rely on rx_buffer content to signal data ready
    mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone
    mailbox: Build Broadcom FlexRM driver as loadable module for iProc SOCs
    mailbox: bcm-flexrm-mailbox: Use common GPL comment header
    mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC
    mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings
    mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence

    Linus Torvalds
     

14 Nov, 2017

5 commits

  • platform_driver_register() can fail here and we must unregister mbox
    class.

    Signed-off-by: Arvind Yadav
    Acked-by: Suman Anna
    Signed-off-by: Jassi Brar

    Arvind Yadav
     
  • Currently we rely on the first byte of the Rx buffer to check if there's
    any data available to be read. If the first byte of the received buffer
    is zero (i.e. null character), then we fail to signal that data is
    available even when it's available.

    Instead introduce a boolean variable to track the data availability and
    update it in the channel receive callback as ready and clear it when the
    data is read.

    Signed-off-by: Sudeep Holla
    Signed-off-by: Jassi Brar

    Sudeep Holla
     
  • Currently the mailbox framework sets txdone_method to TXDONE_BY_POLL if
    the controller sets txdone_by_poll. However some clients can have a
    mechanism to do TXDONE_BY_ACK which they can specify by knows_txdone.
    However, we endup setting both TXDONE_BY_POLL and TXDONE_BY_ACK in that
    case. In such scenario, we may end up with below warnings as the tx
    ticker is run both by mailbox framework and the client.

    WARNING: CPU: 1 PID: 0 at kernel/time/hrtimer.c:805 hrtimer_forward+0x88/0xd8
    CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.12.0-rc5 #242
    Hardware name: ARM LTD ARM Juno Development Platform
    task: ffff8009768ca700 task.stack: ffff8009768f8000
    PC is at hrtimer_forward+0x88/0xd8
    LR is at txdone_hrtimer+0xd4/0xf8
    Call trace:
    hrtimer_forward+0x88/0xd8
    __hrtimer_run_queues+0xe4/0x158
    hrtimer_interrupt+0xa4/0x220
    arch_timer_handler_phys+0x30/0x40
    handle_percpu_devid_irq+0x78/0x130
    generic_handle_irq+0x24/0x38
    __handle_domain_irq+0x5c/0xb8
    gic_handle_irq+0x54/0xa8

    This patch fixes the issue by resetting TXDONE_BY_POLL if client has set
    knows_txdone.

    Cc: Alexey Klimov
    Signed-off-by: Sudeep Holla
    Signed-off-by: Jassi Brar

    Sudeep Holla
     
  • Pull ACPI updates from Rafael Wysocki:
    "These update ACPICA to upstream revision 20170831, fix APEI to use the
    fixmap instead of ioremap_page_range(), add an operation region driver
    for TI PMIC TPS68470, add support for PCC subspace IDs to the ACPI
    CPPC driver, fix a few assorted issues and clean up some code.

    Specifics:

    - Update the ACPICA code to upstream revision 20170831 including
    * PDTT table header support (Bob Moore).
    * Cleanup and extension of internal string-to-integer conversion
    functions (Bob Moore).
    * Support for 64-bit hardware accesses (Lv Zheng).
    * ACPI PM Timer code adjustment to deal with 64-bit return values
    of acpi_hw_read() (Bob Moore).
    * Support for deferred table verification in acpiexec (Lv Zheng).

    - Fix APEI to use the fixmap instead of ioremap_page_range() which
    cannot work correctly the way the code in there attempted to use it
    and drop some code that's not necessary any more after that change
    (James Morse).

    - Clean up the APEI support code and make it use 64-bit timestamps
    (Arnd Bergmann, Dongjiu Geng, Jan Beulich).

    - Add operation region driver for TI PMIC TPS68470 (Rajmohan Mani).

    - Add support for PCC subspace IDs to the ACPI CPPC driver (George
    Cherian).

    - Fix an ACPI EC driver regression related to the handling of EC
    events during the "noirq" phases of system suspend/resume (Lv
    Zheng).

    - Delay the initialization of the lid state in the ACPI button driver
    to fix issues appearing on some systems (Hans de Goede).

    - Extend the KIOX000A "device always present" quirk to cover all
    affected BIOS versions (Hans de Goede).

    - Clean up some code in the ACPI core and drivers (Colin Ian King,
    Gustavo Silva)"

    * tag 'acpi-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (24 commits)
    ACPI: Mark expected switch fall-throughs
    ACPI / LPSS: Remove redundant initialization of clk
    ACPI / CPPC: Make CPPC ACPI driver aware of PCC subspace IDs
    mailbox: PCC: Move the MAX_PCC_SUBSPACES definition to header file
    ACPI / sysfs: Make function param_set_trace_method_name() static
    ACPI / button: Delay acpi_lid_initialize_state() until first user space open
    ACPI / EC: Fix regression related to triggering source of EC event handling
    APEI / ERST: use 64-bit timestamps
    ACPI / APEI: Remove arch_apei_flush_tlb_one()
    arm64: mm: Remove arch_apei_flush_tlb_one()
    ACPI / APEI: Remove ghes_ioremap_area
    ACPI / APEI: Replace ioremap_page_range() with fixmap
    ACPI / APEI: remove the unused dead-code for SEA/NMI notification type
    ACPI / x86: Extend KIOX000A quirk to cover all affected BIOS versions
    ACPI / APEI: adjust a local variable type in ghes_ioremap_pfn_irq()
    ACPICA: Update version to 20170831
    ACPICA: Update acpi_get_timer for 64-bit interface to acpi_hw_read
    ACPICA: String conversions: Update to add new behaviors
    ACPICA: String conversions: Cleanup/format comments. No functional changes
    ACPICA: Restructure/cleanup all string-to-integer conversion functions
    ...

    Linus Torvalds
     
  • Pull timer updates from Thomas Gleixner:
    "Yet another big pile of changes:

    - More year 2038 work from Arnd slowly reaching the point where we
    need to think about the syscalls themself.

    - A new timer function which allows to conditionally (re)arm a timer
    only when it's either not running or the new expiry time is sooner
    than the armed expiry time. This allows to use a single timer for
    multiple timeout requirements w/o caring about the first expiry
    time at the call site.

    - A new NMI safe accessor to clock real time for the printk timestamp
    work. Can be used by tracing, perf as well if required.

    - A large number of timer setup conversions from Kees which got
    collected here because either maintainers requested so or they
    simply got ignored. As Kees pointed out already there are a few
    trivial merge conflicts and some redundant commits which was
    unavoidable due to the size of this conversion effort.

    - Avoid a redundant iteration in the timer wheel softirq processing.

    - Provide a mechanism to treat RTC implementations depending on their
    hardware properties, i.e. don't inflict the write at the 0.5
    seconds boundary which originates from the PC CMOS RTC to all RTCs.
    No functional change as drivers need to be updated separately.

    - The usual small updates to core code clocksource drivers. Nothing
    really exciting"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (111 commits)
    timers: Add a function to start/reduce a timer
    pstore: Use ktime_get_real_fast_ns() instead of __getnstimeofday()
    timer: Prepare to change all DEFINE_TIMER() callbacks
    netfilter: ipvs: Convert timers to use timer_setup()
    scsi: qla2xxx: Convert timers to use timer_setup()
    block/aoe: discover_timer: Convert timers to use timer_setup()
    ide: Convert timers to use timer_setup()
    drbd: Convert timers to use timer_setup()
    mailbox: Convert timers to use timer_setup()
    crypto: Convert timers to use timer_setup()
    drivers/pcmcia: omap1: Fix error in automated timer conversion
    ARM: footbridge: Fix typo in timer conversion
    drivers/sgi-xp: Convert timers to use timer_setup()
    drivers/pcmcia: Convert timers to use timer_setup()
    drivers/memstick: Convert timers to use timer_setup()
    drivers/macintosh: Convert timers to use timer_setup()
    hwrng/xgene-rng: Convert timers to use timer_setup()
    auxdisplay: Convert timers to use timer_setup()
    sparc/led: Convert timers to use timer_setup()
    mips: ip22/32: Convert timers to use timer_setup()
    ...

    Linus Torvalds
     

09 Nov, 2017

1 commit