Skip to content

Conversation

@opsiff
Copy link
Member

@opsiff opsiff commented Feb 6, 2025

stable inclusion
from mainline-v6.6.76
category: bugfix

Commit:
LoongArch: Change 8 to 14 for LOONGARCH_MAX_{BRP,WRP}
LoongArch: Fix warnings during S3 suspend

Summary by Sourcery

Increase the maximum number of hardware breakpoints and fix warnings during S3 suspend.

Bug Fixes:

  • Fixed warnings during S3 suspend.

Enhancements:

  • Increased the maximum number of hardware breakpoints from 8 to 14.

chenhuacai and others added 2 commits February 6, 2025 13:39
stable inclusion
from stable-v6.6.76
category: bugfix

[ Upstream commit 26c0a2d ]

The enable_gpe_wakeup() function calls acpi_enable_all_wakeup_gpes(),
and the later one may call the preempt_schedule_common() function,
resulting in a thread switch and causing the CPU to be in an interrupt
enabled state after the enable_gpe_wakeup() function returns, leading
to the warnings as follow.

[ C0] WARNING: ... at kernel/time/timekeeping.c:845 ktime_get+0xbc/0xc8
[ C0]          ...
[ C0] Call Trace:
[ C0] [<90000000002243b4>] show_stack+0x64/0x188
[ C0] [<900000000164673c>] dump_stack_lvl+0x60/0x88
[ C0] [<90000000002687e4>] __warn+0x8c/0x148
[ C0] [<90000000015e9978>] report_bug+0x1c0/0x2b0
[ C0] [<90000000016478e4>] do_bp+0x204/0x3b8
[ C0] [<90000000025b1924>] exception_handlers+0x1924/0x10000
[ C0] [<9000000000343bbc>] ktime_get+0xbc/0xc8
[ C0] [<9000000000354c08>] tick_sched_timer+0x30/0xb0
[ C0] [<90000000003408e0>] __hrtimer_run_queues+0x160/0x378
[ C0] [<9000000000341f14>] hrtimer_interrupt+0x144/0x388
[ C0] [<9000000000228348>] constant_timer_interrupt+0x38/0x48
[ C0] [<90000000002feba4>] __handle_irq_event_percpu+0x64/0x1e8
[ C0] [<90000000002fed48>] handle_irq_event_percpu+0x20/0x80
[ C0] [<9000000000306b9c>] handle_percpu_irq+0x5c/0x98
[ C0] [<90000000002fd4a0>] generic_handle_domain_irq+0x30/0x48
[ C0] [<9000000000d0c7b0>] handle_cpu_irq+0x70/0xa8
[ C0] [<9000000001646b30>] handle_loongarch_irq+0x30/0x48
[ C0] [<9000000001646bc8>] do_vint+0x80/0xe0
[ C0] [<90000000002aea1c>] finish_task_switch.isra.0+0x8c/0x2a8
[ C0] [<900000000164e34c>] __schedule+0x314/0xa48
[ C0] [<900000000164ead8>] schedule+0x58/0xf0
[ C0] [<9000000000294a2c>] worker_thread+0x224/0x498
[ C0] [<900000000029d2f0>] kthread+0xf8/0x108
[ C0] [<9000000000221f28>] ret_from_kernel_thread+0xc/0xa4
[ C0]
[ C0] ---[ end trace 0000000000000000 ]---

The root cause is acpi_enable_all_wakeup_gpes() uses a mutex to protect
acpi_hw_enable_all_wakeup_gpes(), and acpi_ut_acquire_mutex() may cause
a thread switch. Since there is no longer concurrent execution during
loongarch_acpi_suspend(), we can call acpi_hw_enable_all_wakeup_gpes()
directly in enable_gpe_wakeup().

The solution is similar to commit 22db063 ("ACPI: sleep: Avoid
breaking S3 wakeup due to might_sleep()").

Fixes: 366bb35 ("LoongArch: Add suspend (ACPI S3) support")
Signed-off-by: Qunqin Zhao <zhaoqunqin@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
stable inclusion
from stable-v6.6.76
category: bugfix

commit f502ea6 upstream.

The maximum number of load/store watchpoints and fetch instruction
watchpoints is 14 each according to LoongArch Reference Manual, so
change 8 to 14 for the related code.

Link: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#control-and-status-registers-related-to-watchpoints
Cc: stable@vger.kernel.org
Fixes: edffa33 ("LoongArch: Add hardware breakpoints/watchpoints support")
Reviewed-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 6, 2025

Reviewer's Guide by Sourcery

This pull request backports two commits from the stable branch (mainline-v6.6.76). The first commit increases the maximum number of hardware breakpoints for LoongArch architecture. The second commit fixes warnings during S3 suspend.

Class diagram for LoongArch hardware breakpoint changes

classDiagram
    class HardwareBreakpoints {
        +LOONGARCH_MAX_BRP: int
        +LOONGARCH_MAX_WRP: int
    }
    note for HardwareBreakpoints "Changed max breakpoints from 8 to 14"

    class CSRRegisters {
        +DB0-DB13: DataBreakpointRegisters
        +IB0-IB13: InstructionBreakpointRegisters
    }
    note for CSRRegisters "Added DB8-DB13 and IB8-IB13 registers"

    class DataBreakpointRegisters {
        +ADDR: register
        +MASK: register
        +CTRL: register
        +ASID: register
    }

    class InstructionBreakpointRegisters {
        +ADDR: register
        +MASK: register
        +CTRL: register
        +ASID: register
    }

    CSRRegisters *-- DataBreakpointRegisters
    CSRRegisters *-- InstructionBreakpointRegisters
Loading

State diagram for S3 suspend fix

stateDiagram-v2
    [*] --> Running
    Running --> S3_Suspend: Suspend
    S3_Suspend --> EnableWakeupGPEs: acpi_hw_enable_all_wakeup_gpes()
    EnableWakeupGPEs --> S3_Suspended
    S3_Suspended --> Running: Resume
    note right of EnableWakeupGPEs: Fixed warning by using correct function
Loading

File-Level Changes

Change Details Files
Increased the maximum number of hardware breakpoints for LoongArch.
  • Increased LOONGARCH_MAX_{BRP,WRP} from 8 to 14.
  • Added definitions for CSRs DB8-DB13 and IB8-IB13.
  • Added cases for breakpoint registers 8-13 in read_wb_reg and write_wb_reg functions.
arch/loongarch/include/asm/loongarch.h
arch/loongarch/kernel/hw_breakpoint.c
arch/loongarch/include/asm/hw_breakpoint.h
Fixed warnings during S3 suspend.
  • Replaced acpi_enable_all_wakeup_gpes() with acpi_hw_enable_all_wakeup_gpes() in arch/loongarch/power/platform.c.
  • Moved the definition of acpi_hw_enable_all_wakeup_gpes to include/acpi/acpixf.h.
  • Removed acpi_hw_enable_all_wakeup_gpes from drivers/acpi/acpica/achware.h.
arch/loongarch/power/platform.c
drivers/acpi/acpica/achware.h
include/acpi/acpixf.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @opsiff - I've reviewed your changes - here's some feedback:

Overall Comments:

  • There are duplicate declarations of acpi_hw_enable_all_wakeup_gpes in acpixf.h. Please remove the redundant declaration so only one remains to prevent any potential linker or type confusion issues.
  • Ensure that the extended range for hardware breakpoints (new indices 8-13 and MAX_BRP/WRP increased to 14) is fully supported by the LoongArch hardware. Verify that any usage in dependent code or assumptions about the breakpoint count are updated accordingly.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sourcery-ai[bot]
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff opsiff changed the title [Deepin-Kernel-SIG] [Backport] [linux 6.6-y] Loongarch: Sync some patches from stable [Deepin-Kernel-SIG] [Upstream] [linux 6.6-y] Loongarch: Sync some patches from stable Feb 6, 2025
@opsiff opsiff merged commit 40dee6a into deepin-community:linux-6.6.y Feb 6, 2025
4 of 5 checks passed
@opsiff opsiff deleted the linux-6.6.y-2025-02-06-loongarch-stable branch February 6, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants