10 Dec, 2020

2 commits


03 Jul, 2020

1 commit

  • uio_pdrv_genirq and uio_dmem_genirq interrupts are handled in
    userspace. So the condition for the interrupt hasn't normally not been
    cleared when top half returns. disable_irq_nosync is called in top half,
    but since that normally is lazy the irq isn't actually disabled.

    For level triggered interrupts this will always result in a spurious
    additional fire since the level in to the interrupt controller still is
    active. The actual interrupt handler isn't run though since this
    spurious irq is just recorded, and later on discared (for level).

    This commit disables lazy masking for level triggered interrupts. It
    leaves edge triggered interrupts as before, because they work with the
    lazy scheme.

    All other UIO drivers already seem to clear the interrupt cause at
    driver levels.

    Example of double fire. First goes all the way up to
    uio_pdrv_genirq_handler, second is terminated in handle_fasteoi_irq and
    marked as pending.

    -0 [000] d... 8.245870: gic_handle_irq: irq 29
    -0 [000] d.h. 8.245873: uio_pdrv_genirq_handler: disable irq 29
    -0 [000] d... 8.245878: gic_handle_irq: irq 29
    -0 [000] d.h. 8.245880: handle_fasteoi_irq: irq 29 PENDING
    HInt-34 [001] d... 8.245897: uio_pdrv_genirq_irqcontrol: enable irq 29

    Tested on 5.7rc2 using uio_pdrv_genirq and a custom Xilinx MPSoC board.

    Signed-off-by: Thommy Jakobsson
    Link: https://lore.kernel.org/r/20200628141229.16121-1-thommyj@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Thommy Jakobsson
     

28 Apr, 2020

1 commit


14 Jan, 2020

1 commit

  • The driver may sleep while holding a spinlock.
    The function call path (from bottom to top) in Linux 4.19 is:

    kernel/irq/manage.c, 523:
    synchronize_irq in disable_irq
    drivers/uio/uio_dmem_genirq.c, 140:
    disable_irq in uio_dmem_genirq_irqcontrol
    drivers/uio/uio_dmem_genirq.c, 134:
    _raw_spin_lock_irqsave in uio_dmem_genirq_irqcontrol

    synchronize_irq() can sleep at runtime.

    To fix this bug, disable_irq() is called without holding the spinlock.

    This bug is found by a static analysis tool STCheck written by myself.

    Signed-off-by: Jia-Ju Bai
    Link: https://lore.kernel.org/r/20191218094405.6009-1-baijiaju1990@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jia-Ju Bai
     

14 Nov, 2019

1 commit

  • This change also does a bit of a unification for the IRQ init code.

    But the actual problem is that UIO_IRQ_NONE == 0, so for the DT case where
    UIO_IRQ_NONE gets assigned to `uioinfo->irq`, a 2nd initialization will get
    triggered (for the IRQ) and this one will exit via `goto bad1`.

    As far as things seem to go, the only case where UIO_IRQ_NONE seems valid,
    is when using a device-tree. The driver has some legacy support for old
    platform_data structures. It looks like, for platform_data a non-existent
    IRQ is an invalid case (or was considered an invalid case).
    Which is why -ENXIO is treated only when a DT is used.

    Signed-off-by: Dragos Bogdan
    Signed-off-by: Alexandru Ardelean
    Acked-by: Damian Hobson-Garcia
    Link: https://lore.kernel.org/r/20191105073212.16719-1-alexandru.ardelean@analog.com
    Signed-off-by: Greg Kroah-Hartman

    Alexandru Ardelean
     

31 Jul, 2019

1 commit

  • We don't need dev_err() messages when platform_get_irq() fails now that
    platform_get_irq() prints an error message itself when something goes
    wrong. Let's remove these prints with a simple semantic patch.

    //
    @@
    expression ret;
    struct platform_device *E;
    @@

    ret =
    (
    platform_get_irq(E, ...)
    |
    platform_get_irq_byname(E, ...)
    );

    if ( \( ret < 0 \| ret

    While we're here, remove braces on if statements that only have one
    statement (manually).

    Cc: Greg Kroah-Hartman
    Cc: Greg Kroah-Hartman
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20190730181557.90391-46-swboyd@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     

19 Jun, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation #

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 4122 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Enrico Weigelt
    Reviewed-by: Kate Stewart
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

03 Oct, 2018

1 commit


31 Aug, 2016

1 commit

  • The variable i contains a total number of resources (including
    IORESOURCE_IRQ). However, we want the dmem_region_start to point
    after the last resource of type IORESOURCE_MEM. The original behaviour
    leads (very likely) to skipping several UIO mapping regions and makes
    them useless. Fix this by computing dmem_region_start from the uiomem
    which points to the last used UIO mapping.

    Fixes: 0a0c3b5a24bd ("Add new uio device for dynamic memory allocation")

    Signed-off-by: Jan Viktorin
    Signed-off-by: Greg Kroah-Hartman

    Jan Viktorin
     

20 Oct, 2014

1 commit


28 May, 2014

1 commit

  • When platform_get_irq() is failed after "priv" allocated,
    it need to free "priv". But the label of bad0 doesn't try
    to free about "priv". So this patch changes that lable to "bad1".
    But "bad1" has pm_runtime_disable() call, this function should
    be called when uio_register_device() is failed. So it is moved
    into handling error for uio_register_device().

    Signed-off-by: Daeseok Youn
    Signed-off-by: Hans J. Koch
    Signed-off-by: Greg Kroah-Hartman

    Daeseok Youn
     

31 Aug, 2013

1 commit


25 Jun, 2013

1 commit


22 Nov, 2012

4 commits

  • The same condition should be used both when allocating and freeing the
    driver private data. When dev.of_node is non NULL, allocate a new
    private data structure, otherwise use the values from the platform data.

    Reported-by: Fengguang Wu
    Signed-off-by: Damian Hobson-Garcia
    Cc: "Hans J. Koch"
    Signed-off-by: Greg Kroah-Hartman

    Damian Hobson-Garcia
     
  • The uio device should not fail on open just because one memory allocation
    fails. The device might export several regions, the failure of some of
    which may or may not be a problem for the user space driver. Failing
    regions will remain unmapped, and successful regions will be mapped and
    exported to user space. Also deals with the case where failing to map
    a region after successfully allocating others would not unmap the
    successfully allocated regions before dying.

    Signed-off-by: Damian Hobson-Garcia
    Cc: "Hans J. Koch"
    Signed-off-by: Greg Kroah-Hartman

    Damian Hobson-Garcia
     
  • DMA_ERROR_CODE is not defined on all architectures and is architecture
    specific. Instead, use the constant, ~0 to indicate unmapped regions.

    Reported-by: Fengguang Wu
    Reported-by: Geert Uytterhoeven
    Signed-off-by: Damian Hobson-Garcia
    Cc: "Hans J. Koch"
    Signed-off-by: Greg Kroah-Hartman

    Damian Hobson-Garcia
     
  • Assigning the virtual address returned from dma_alloc_coherent to the the
    internal_addr element of uioinfo produces the following sparse errors since
    internal_addr is a void __iomem * and dma_alloc_coherent returns void *.

    + drivers/uio/uio_dmem_genirq.c:65:39: sparse: incorrect type in assignment (different address spaces)
    drivers/uio/uio_dmem_genirq.c:65:39: expected void [noderef] *internal_addr
    drivers/uio/uio_dmem_genirq.c:65:39: got void *[assigned] addr
    + drivers/uio/uio_dmem_genirq.c:93:17: sparse: incorrect type in argument 3 (different address spaces)
    drivers/uio/uio_dmem_genirq.c:93:17: expected void *vaddr
    drivers/uio/uio_dmem_genirq.c:93:17: got void [noderef] *internal_addr

    Store the void * in the driver's private data instead.

    Reported-by: Fengguang Wu
    Signed-off-by: Damian Hobson-Garcia
    Cc: "Hans J. Koch"
    Signed-off-by: Greg Kroah-Hartman

    Damian Hobson-Garcia
     

25 Oct, 2012

1 commit

  • This device extends the uio_pdrv_genirq driver to provide limited
    dynamic memory allocation for UIO devices. This allows UIO devices
    to use CMA and IOMMU allocated memory regions. This driver is based
    on the uio_pdrv_genirq driver and provides the same generic interrupt
    handling capabilities. Like uio_prdv_genirq,
    a fixed number of memory regions, defined in the platform device's
    .resources field are exported to userpace. This driver adds the ability
    to export additional regions whose number and size are known at boot time,
    but whose memory is not allocated until the uio device file is opened for
    the first time. When the device file is closed, the allocated memory block
    is freed. Physical (DMA) addresses for the dynamic regions are provided to
    the userspace via /sys/class/uio/uioX/maps/mapY/addr in the same way as
    static addresses are when the uio device file is open, when no processes
    are holding the device file open, the address returned to userspace is
    DMA_ERROR_CODE.

    Signed-off-by: Damian Hobson-Garcia
    Signed-off-by: "Hans J. Koch"
    Signed-off-by: Greg Kroah-Hartman

    Damian Hobson-Garcia