Shawn Lin da03114d74 PCI: rockchip: dw: Use handle_level_irq for legacy irq
We get a report that a wireless ethernet device which uses legacy interrupt, exposes a
buggy behaviour when patching RT support. It can be observed on RK3588 EVB1 with NVMe under
RT environment when adding pci=nomsi to cmdline. The backtrace looks like below:

echo 3 > /proc/sys/vm/drop_caches && dd if=/dev/nvme0n1 of=/dev/null bs=1M count=50000

[   10.826850] irq 155: nobody cared (try booting with the "irqpoll" option)
[   10.826862] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.160-rt89 #505
[   10.826867] Hardware name: Rockchip RK3588 EVB1 LP4 V10 Board (DT)
[   10.826870] Call trace:
[   10.826871]  dump_backtrace+0x0/0x1e0
[   10.826881]  show_stack+0x18/0x24
[   10.826886]  dump_stack_lvl+0xcc/0xf8
[   10.826891]  dump_stack+0x18/0x54
[   10.826895]  __report_bad_irq+0x4c/0xdc
[   10.826899]  note_interrupt+0x2cc/0x380
[   10.826905]  handle_irq_event+0x10c/0x180
[   10.826909]  handle_simple_irq+0xac/0x120
[   10.826913]  generic_handle_irq+0x30/0x50
[   10.826917]  rk_pcie_legacy_int_handler+0xa8/0x160
[   10.826923]  __handle_domain_irq+0xb8/0x140
[   10.826927]  gic_handle_irq+0xd8/0x2e4
[   10.826932]  el1_irq+0xcc/0x180
[   10.826935]  arch_cpu_idle+0x18/0x3c
[   10.826940]  default_idle_call+0x2c/0x9c
[   10.826944]  do_idle+0x21c/0x2a0
[   10.826949]  cpu_startup_entry+0x24/0x70
[   10.826952]  rest_init+0xd0/0xe0
[   10.826956]  arch_call_rest_init+0x10/0x1c
[   10.826960]  start_kernel+0x50c/0x544
[   10.826963] handlers:
[   10.826965] [<0000000015317c1f>] irq_default_primary_handler threaded [<00000000edb1561e>] pcie_pme_irq
[   10.826977] [<0000000015317c1f>] irq_default_primary_handler threaded [<000000000065643b>] nvme_irq
[   10.826988] [<0000000015317c1f>] irq_default_primary_handler threaded [<000000000065643b>] nvme_irq
[   10.826996] Disabling IRQ #155

And NVMe can't work anymore due to the irq problem. The actual problem looks like:

nvme_irq                                    nvme_irq
 //process the previous request
   -> nvme_process_cq(nvmeq)		    // the previous one is still processing
                                            -> if(nvme_process_cq(nvmeq))
   -> return IRQ_HANDLED                    -> return IRQ_NONE

so a spurious irq was counted and if the irq ack time is short enough to increase the spurious
irq exceeding the limitation, report_bad_irq was triggered. This is why the bug was only observed
under RT environment since the irq was distributed more quickly than ever, but the bug was always there.

root@linaro-alip:/# cat /proc/irq/155/spurious
count 8990
unhandled 24339
last_unhandled 189829 ms

This can be fixed by the drivers as we could see many patches regarding "irq xxx: nobody cared",
and it's the case if we don't allow nvme_irq to nest itself or postpone the handler. However the
legacy interrupt support is also buggy. For legacy interrupt, it's a level irq rather than an edge
one. But it happened to work because Rockchip PCIe RC only generates oneshot irq instead of level,
preventing the irq storm from happening. So changing to use handle_level_irq is correct and should
help mask/unmask the irq when dealing with it in between. That's a decent solution for all.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Change-Id: Ie9499b3dbd19ac053500b4c726294296be537ffd
2023-09-20 15:18:52 +08:00
2023-06-14 16:17:22 +08:00
2021-07-20 19:58:52 +08:00

How do I submit patches to Android Common Kernels

  1. BEST: Make all of your changes to upstream Linux. If appropriate, backport to the stable releases. These patches will be merged automatically in the corresponding common kernels. If the patch is already in upstream Linux, post a backport of the patch that conforms to the patch requirements below.

    • Do not send patches upstream that contain only symbol exports. To be considered for upstream Linux, additions of EXPORT_SYMBOL_GPL() require an in-tree modular driver that uses the symbol -- so include the new driver or changes to an existing driver in the same patchset as the export.
    • When sending patches upstream, the commit message must contain a clear case for why the patch is needed and beneficial to the community. Enabling out-of-tree drivers or functionality is not not a persuasive case.
  2. LESS GOOD: Develop your patches out-of-tree (from an upstream Linux point-of-view). Unless these are fixing an Android-specific bug, these are very unlikely to be accepted unless they have been coordinated with kernel-team@android.com. If you want to proceed, post a patch that conforms to the patch requirements below.

Common Kernel patch requirements

  • All patches must conform to the Linux kernel coding standards and pass script/checkpatch.pl
  • Patches shall not break gki_defconfig or allmodconfig builds for arm, arm64, x86, x86_64 architectures (see https://source.android.com/setup/build/building-kernels)
  • If the patch is not merged from an upstream branch, the subject must be tagged with the type of patch: UPSTREAM:, BACKPORT:, FROMGIT:, FROMLIST:, or ANDROID:.
  • All patches must have a Change-Id: tag (see https://gerrit-review.googlesource.com/Documentation/user-changeid.html)
  • If an Android bug has been assigned, there must be a Bug: tag.
  • All patches must have a Signed-off-by: tag by the author and the submitter

Additional requirements are listed below based on patch type

Requirements for backports from mainline Linux: UPSTREAM:, BACKPORT:

  • If the patch is a cherry-pick from Linux mainline with no changes at all
    • tag the patch subject with UPSTREAM:.
    • add upstream commit information with a (cherry picked from commit ...) line
    • Example:
      • if the upstream commit message is
        important patch from upstream

        This is the detailed description of the important patch

        Signed-off-by: Fred Jones <fred.jones@foo.org>
  • then Joe Smith would upload the patch for the common kernel as
        UPSTREAM: important patch from upstream

        This is the detailed description of the important patch

        Signed-off-by: Fred Jones <fred.jones@foo.org>

        Bug: 135791357
        Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
        (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1)
        Signed-off-by: Joe Smith <joe.smith@foo.org>
  • If the patch requires any changes from the upstream version, tag the patch with BACKPORT: instead of UPSTREAM:.
    • use the same tags as UPSTREAM:
    • add comments about the changes under the (cherry picked from commit ...) line
    • Example:
        BACKPORT: important patch from upstream

        This is the detailed description of the important patch

        Signed-off-by: Fred Jones <fred.jones@foo.org>

        Bug: 135791357
        Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
        (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1)
        [joe: Resolved minor conflict in drivers/foo/bar.c ]
        Signed-off-by: Joe Smith <joe.smith@foo.org>

Requirements for other backports: FROMGIT:, FROMLIST:,

  • If the patch has been merged into an upstream maintainer tree, but has not yet been merged into Linux mainline
    • tag the patch subject with FROMGIT:
    • add info on where the patch came from as (cherry picked from commit <sha1> <repo> <branch>). This must be a stable maintainer branch (not rebased, so don't use linux-next for example).
    • if changes were required, use BACKPORT: FROMGIT:
    • Example:
      • if the commit message in the maintainer tree is
        important patch from upstream

        This is the detailed description of the important patch

        Signed-off-by: Fred Jones <fred.jones@foo.org>
  • then Joe Smith would upload the patch for the common kernel as
        FROMGIT: important patch from upstream

        This is the detailed description of the important patch

        Signed-off-by: Fred Jones <fred.jones@foo.org>

        Bug: 135791357
        (cherry picked from commit 878a2fd9de10b03d11d2f622250285c7e63deace
         https://git.kernel.org/pub/scm/linux/kernel/git/foo/bar.git test-branch)
        Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
        Signed-off-by: Joe Smith <joe.smith@foo.org>
  • If the patch has been submitted to LKML, but not accepted into any maintainer tree
    • tag the patch subject with FROMLIST:
    • add a Link: tag with a link to the submittal on lore.kernel.org
    • add a Bug: tag with the Android bug (required for patches not accepted into a maintainer tree)
    • if changes were required, use BACKPORT: FROMLIST:
    • Example:
        FROMLIST: important patch from upstream

        This is the detailed description of the important patch

        Signed-off-by: Fred Jones <fred.jones@foo.org>

        Bug: 135791357
        Link: https://lore.kernel.org/lkml/20190619171517.GA17557@someone.com/
        Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
        Signed-off-by: Joe Smith <joe.smith@foo.org>

Requirements for Android-specific patches: ANDROID:

  • If the patch is fixing a bug to Android-specific code
    • tag the patch subject with ANDROID:
    • add a Fixes: tag that cites the patch with the bug
    • Example:
        ANDROID: fix android-specific bug in foobar.c

        This is the detailed description of the important fix

        Fixes: 1234abcd2468 ("foobar: add cool feature")
        Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
        Signed-off-by: Joe Smith <joe.smith@foo.org>
  • If the patch is a new feature
    • tag the patch subject with ANDROID:
    • add a Bug: tag with the Android bug (required for android-specific features)
Description
No description provided
Readme 7.9 GiB
Languages
C 97.7%
Assembly 1.6%
Makefile 0.3%
Perl 0.1%