Skip to content

[linux-6.6.y] LoongArch Stage Patch Synchronization 260611#1846

Open
AaronDot wants to merge 23 commits into
deepin-community:linux-6.6.yfrom
AaronDot:loongarch-sync-0611
Open

[linux-6.6.y] LoongArch Stage Patch Synchronization 260611#1846
AaronDot wants to merge 23 commits into
deepin-community:linux-6.6.yfrom
AaronDot:loongarch-sync-0611

Conversation

@AaronDot

@AaronDot AaronDot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Introduction to the patchset:

Patch 1-2: backported from upstream;
Patch 3: fix acpi gpe error after S3;
Patch 4-5: fix amdgpu timeout issues;
Patch 6: fix rtlwifi cpu stall;
Patch 7: fix cdrom kernel panic;
Patch 8: enable usb wakeup;
Patch 9-20: backport Loongson-2K0500 BMC from upstream;
Patch 21-24: Default config enabled.

Summary by Sourcery

Synchronize LoongArch-specific kernel support with upstream, including new BMC/IPMI support, refinements to CPU and interrupt capabilities, and multiple platform power-management and device-stability fixes.

New Features:

  • Add a Loongson-2K BMC MFD core driver that exposes a framebuffer and multiple IPMI channels over PCIe and recovers after BMC reset.
  • Introduce an LS2K-specific IPMI SI platform driver providing a memory-mapped KCS interface used by the BMC.
  • Enable USB remote wakeup on suspend by toggling root-hub wake capability, improving system wake-on-USB behavior.

Bug Fixes:

  • Restore ACPI GPE enable state after S3 on LoongArch to prevent wakeup errors.
  • Adjust amdgpu ring sizes and fence emission on LoongArch to avoid compute and VM flush timeouts.
  • Ensure cdrom device exit callbacks run on release instead of unregister to avoid kernel panics.
  • Prevent SCSI error handling from dereferencing null scsi_device hosts during recovery.
  • Avoid rtl8723be interrupt handling races by enabling the IRQ flag before programming interrupt masks.
  • Fix USB suspend/resume by explicitly enabling and later disabling remote-wakeup on the root hub when needed.
  • Guard IPMI I/O-space setup and PCI probe paths when CONFIG_HAS_IOPORT is disabled to avoid invalid access.

Enhancements:

  • Add LoongArch-specific handling to re-enable ACPI wakeup GPEs and register a PM notifier during late init.
  • Refine LoongArch platform GPE wakeup logic to selectively enable GPEs for wake-capable ACPI devices.
  • Extend LoongArch CPU feature and probing support for message interrupts and interrupt remapping capabilities.
  • Improve amdgpu power management on LoongArch by forcing high-performance DPM on device init when sysfs is ready.
  • Harden IPMI SI core to be configurable per bus backend and to support a new LS2K memory-mapped transport.
  • Tighten IPMI SI setup logic to respect CONFIG_HAS_IOPORT and structure the build around Kconfig-driven objects.

Build:

  • Introduce Kconfig and Makefile wiring for the new LS2K BMC core, IPMI, and framebuffer options, and remove the obsolete LS2K500 framebuffer driver.

Chores:

  • Update LoongArch defconfigs and MAINTAINERS to reflect new BMC/IPMI support and configuration defaults.
  • Remove unused or obsolete LS2K500-specific IPMI and framebuffer support files.

@sourcery-ai

sourcery-ai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

LoongArch-focused patchset that adds a new LS2K BMC core and IPMI backend, refines LoongArch CPU feature probing, fixes several platform-specific power-management and device issues (ACPI GPE after S3, USB wake, amdgpu timeouts, rtlwifi stall, cdrom panic, SCSI error handling), and updates configs/Makefiles/Kconfig to enable the new hardware and defaults.

Sequence diagram for LS2K BMC reset recovery flow

sequenceDiagram
  participant GPIO as GPIO_IRQ
  participant Work as bmc_reset_work
  participant SM as stop_machine
  participant Rec as ls2k_bmc_recover_pci_data
  participant PBridge as LS7A_bridge_pci
  participant PBMC as LS2K_BMC_pci

  GPIO->>Work: ls2k_bmc_interrupt (schedule_work)
  Work->>SM: stop_machine(ls2k_bmc_recover_pci_data)
  SM->>Rec: run on isolated CPU
  Rec->>PBridge: pci_write_config_dword(PCI_BASE_ADDRESS_2..4, 0)
  Rec->>PBridge: ls2k_bmc_bar0_addr_is_set()
  Rec->>PBridge: ls2k_bmc_restore_bridge_pci_data()
  Rec->>PBridge: ls2k_bmc_pcie_is_connected()
  Rec->>PBMC: pci_write_config_dword(PCI_COMMAND, base_address0, interrupt_line)
  SM-->>Work: return
  Work->>Work: vt_move_to_console / set_console (if CONFIG_VT)
Loading

File-Level Changes

Change Details Files
Fix ACPI GPE handling on LoongArch suspend/resume and make GPE-based wake configuration explicit.
  • Include ACPICA local headers in LoongArch power code and share ACPI GPE event info via a global pointer
  • Record initial GPE enable mask at late init and register a PM notifier to restore per-GPE enable bits after suspend (PM_POST_SUSPEND)
  • Replace generic acpi_hw_enable_all_wakeup_gpes() with custom logic that walks acpi_wakeup_device_list and sets the GPE enable register bits only for valid wake-capable devices
arch/loongarch/power/suspend.c
arch/loongarch/power/platform.c
Mitigate amdgpu timeouts on LoongArch by enlarging ring buffers and aggressively emitting cache-flushing fences, with corresponding ring size accounting changes.
  • On LoongArch, double GFX and compute ring sizes passed to amdgpu_ring_init from 1024 to 2048 entries
  • In gfx_v8_0_ring_emit_fence_gfx, emit multiple EVENT_WRITE_EOP packets (loop of 9) to flush caches repeatedly on LoongArch
  • Adjust gfx_v8_0_ring_funcs_gfx.emit_fence and emit_pipeline_sync sizes to account for the larger fence emission sequences when CONFIG_LOONGARCH is set
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
Add a helper to force amdgpu DPM into high-performance mode on LoongArch and call it at device init.
  • Introduce amdgpu_set_high_power_dpm_force_performance_level() (LoongArch-only) that sets the sysfs DPM performance level to "high" if sysfs is initialized
  • Export the helper in amdgpu_pm.h and invoke it at the end of amdgpu_device_init when CONFIG_LOONGARCH is enabled
drivers/gpu/drm/amd/pm/amdgpu_pm.c
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Introduce LS2K BMC core MFD driver and Loongson-2K IPMI interface and wire them into the IPMI and MFD subsystems.
  • Add ls2k-bmc-core MFD PCI driver that exposes a simple-framebuffer and multiple LS2K IPMI KCS child devices backed by fixed MMIO resources
  • Implement BMC reset handling by saving/restoring parent bridge and BMC PCI config registers, re-training the PCIe link, and re-pushing the console after reset via a watchdog-like GPIO interrupt
  • Parse BMC-provided video mode string from BAR0 tail and register a simple-framebuffer after removing conflicting firmware framebuffers
  • Add LS2K-specific IPMI SI backend (ipmi_si_ls2k.c) that implements KCS over MMIO with two hardware versions, providing custom inb/outb and setup/cleanup hooks
  • Replace ls2k500-specific IPMI/Facebook framebuffer drivers with generic LS2K BMC core and LS2K IPMI SI; update ipmi_si Makefile and Kconfig to use CONFIG_IPMI_LS2K, adjust init/shutdown flows, and add new MFD Kconfig/Makefile entries
drivers/mfd/ls2k-bmc-core.c
drivers/char/ipmi/ipmi_si_ls2k.c
drivers/char/ipmi/ipmi_si.h
drivers/char/ipmi/Makefile
drivers/char/ipmi/ipmi_si_intf.c
drivers/char/ipmi/ipmi_si_pci.c
drivers/mfd/Makefile
drivers/mfd/Kconfig
drivers/char/ipmi/Kconfig
drivers/video/fbdev/Makefile
drivers/video/fbdev/Kconfig
drivers/char/ipmi/btlock.h
drivers/char/ipmi/ipmi_si_ls2k500.c
drivers/char/ipmi/kcs_bmc_ls2k500.h
drivers/video/fbdev/ls2k500sfb.c
Extend LoongArch CPU feature set and probing to cover message interrupts and interrupt remapping capabilities.
  • Reserve and define new CPU_FEATURE_MSGINT and CPU_FEATURE_REDIRECTINT bits and corresponding LOONGARCH_CPU_* option flags
  • In cpu_probe_common, detect MSGINT via CPUCFG1 and REDIRECTINT via IOCSR flags and set options accordingly
  • Expose cpu_has_msgint and cpu_has_redirectint macros in cpu-features.h and define IOCSRF_REDIRECT bit in loongarch.h
arch/loongarch/include/asm/cpu.h
arch/loongarch/kernel/cpu-probe.c
arch/loongarch/include/asm/cpu-features.h
arch/loongarch/include/asm/loongarch.h
Fix cdrom unregister kernel panic by deferring the device-specific exit callback to release time.
  • Remove invocation of cdi->exit() from unregister_cdrom, leaving list removal and logging only
  • Invoke cdi->exit() from cdrom_release after write-close handling but before door-unlock, ensuring resources are torn down only when the device is actually closed
drivers/cdrom/cdrom.c
Avoid rtlwifi RTL8723BE CPU stalls by marking interrupts enabled before programming interrupt mask registers.
  • Move assignment of rtlpci->irq_enabled = true before writing HIMR and HIMRE interrupt mask registers in rtl8723be_enable_interrupt
drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
Enable USB-based wakeups more robustly by adjusting remote wake handling on suspend.
  • Enable remote wakeup on the root hub when suspending a device that supports remote wake (usb_port_suspend)
  • On error paths, if remote wakeup was enabled on the device, also disable it on the root hub when disabling it on the device
drivers/usb/core/hub.c
Harden SCSI error handling to avoid null-pointer dereferences when checking host recovery state.
  • Add null checks for sdev and sdev->host in scsi_block_when_processing_errors and return 0 early if missing
drivers/scsi/scsi_error.c
Minor cleanups and configuration updates for LoongArch defaults and fs crypto.
  • Update LoongArch desktop and loongson3 defconfig files to enable new LS2K BMC/IPMI, GPU, and related options as default
  • Adjust MAINTAINERS and fs/crypto Kconfig to reflect new components and enable them by default on this platform
MAINTAINERS
arch/loongarch/configs/deepin_loongarch_desktop_defconfig
arch/loongarch/configs/loongson3_defconfig
fs/crypto/Kconfig

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!

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The new LoongArch ACPI GPE handling reaches into ACPICA internals (aclocal.h, acpi_ev_get_gpe_event_info, direct readl/writel on enable_address) and shares a global gpe_info across translation units; consider restructuring this to use exported ACPI APIs and avoid cross-file globals and direct MMIO on ACPICA-managed registers to reduce layering violations and potential race issues.
  • In ls2k_bmc_recover_pci_data() you perform multiple mdelay() calls (including a fixed 10s wait) inside stop_machine(), which will stall all CPUs for a long period during BMC reset; it would be safer to redesign this recovery path to avoid long busy-waits under stop_machine (e.g. shorter polling windows, asynchronous completion, or a different synchronization primitive).
  • Several changes introduce CONFIG_LOONGARCH ifdefs directly into generic drivers (e.g., amdgpu ring sizes and extra fence packets, PM hooks), which makes the code harder to maintain; consider expressing these differences via existing ASIC/feature hooks or driver-specific conditionals instead of arch ifdefs so the LoongArch behavior remains encapsulated within the driver’s abstraction layers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new LoongArch ACPI GPE handling reaches into ACPICA internals (aclocal.h, acpi_ev_get_gpe_event_info, direct readl/writel on enable_address) and shares a global gpe_info across translation units; consider restructuring this to use exported ACPI APIs and avoid cross-file globals and direct MMIO on ACPICA-managed registers to reduce layering violations and potential race issues.
- In ls2k_bmc_recover_pci_data() you perform multiple mdelay() calls (including a fixed 10s wait) inside stop_machine(), which will stall all CPUs for a long period during BMC reset; it would be safer to redesign this recovery path to avoid long busy-waits under stop_machine (e.g. shorter polling windows, asynchronous completion, or a different synchronization primitive).
- Several changes introduce CONFIG_LOONGARCH ifdefs directly into generic drivers (e.g., amdgpu ring sizes and extra fence packets, PM hooks), which makes the code harder to maintain; consider expressing these differences via existing ASIC/feature hooks or driver-specific conditionals instead of arch ifdefs so the LoongArch behavior remains encapsulated within the driver’s abstraction layers.

## Individual Comments

### Comment 1
<location path="drivers/mfd/ls2k-bmc-core.c" line_range="410-419" />
<code_context>
+	 * acpi_register_gsi() is used to obtain the GPIO IRQ. The GPIO interrupt is a
+	 * watchdog interrupt that is triggered when the BMC resets.
+	 */
+	gpio_irq = acpi_register_gsi(NULL, LS2K_BMC_RESET_GPIO_GSI, ACPI_EDGE_SENSITIVE,
+				     ACPI_ACTIVE_LOW);
+	if (gpio_irq < 0)
+		return gpio_irq;
+
+	ret = devm_request_irq(ddata->dev, gpio_irq, ls2k_bmc_interrupt,
+			       IRQF_SHARED | IRQF_TRIGGER_FALLING, "ls2kbmc gpio", ddata);
+	if (ret)
+		dev_err(ddata->dev, "Failed to request LS2KBMC GPIO IRQ %d.\n", gpio_irq);
+
+	acpi_unregister_gsi(LS2K_BMC_RESET_GPIO_GSI);
+	return ret;
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid calling acpi_unregister_gsi() while the IRQ is still in use

Here the GSI is registered, an IRQ is requested on the resulting Linux IRQ, and then the GSI is immediately unregistered while the IRQ remains active. acpi_unregister_gsi() is normally part of teardown, not paired directly after registration, and doing so risks corrupting ACPI’s GSI-to-IRQ mapping for this line. Please move acpi_unregister_gsi() to the IRQ shutdown/cleanup path, or drop it if the GSI does not need explicit unmapping.
</issue_to_address>

### Comment 2
<location path="drivers/mfd/ls2k-bmc-core.c" line_range="434-438" />
<code_context>
+	int depth, ret;
+
+	/* The last 16M of PCI BAR0 is used to store the resolution string. */
+	mode = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0) + SZ_16M, SZ_16M);
+	if (!mode)
+		return -ENOMEM;
+
+	/* The resolution field starts with the flag "video=". */
+	if (!strncmp(mode, "video=", 6))
+		mode = mode + 6;
</code_context>
<issue_to_address>
**issue (bug_risk):** Validate BAR size before mapping a fixed 16M offset for the mode string

`ls2k_bmc_parse_mode` always maps `pci_resource_start(pdev, 0) + SZ_16M` with size `SZ_16M`. If BAR0 is < 32M, this accesses beyond the MMIO region, which is undefined and may fault on some platforms. Please check `pci_resource_len(pdev, 0)` is at least `SZ_16M * 2` (or the required layout) before mapping, and abort if the BAR is too small.
</issue_to_address>

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.

Comment on lines +410 to +419
gpio_irq = acpi_register_gsi(NULL, LS2K_BMC_RESET_GPIO_GSI, ACPI_EDGE_SENSITIVE,
ACPI_ACTIVE_LOW);
if (gpio_irq < 0)
return gpio_irq;

ret = devm_request_irq(ddata->dev, gpio_irq, ls2k_bmc_interrupt,
IRQF_SHARED | IRQF_TRIGGER_FALLING, "ls2kbmc gpio", ddata);
if (ret)
dev_err(ddata->dev, "Failed to request LS2KBMC GPIO IRQ %d.\n", gpio_irq);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Avoid calling acpi_unregister_gsi() while the IRQ is still in use

Here the GSI is registered, an IRQ is requested on the resulting Linux IRQ, and then the GSI is immediately unregistered while the IRQ remains active. acpi_unregister_gsi() is normally part of teardown, not paired directly after registration, and doing so risks corrupting ACPI’s GSI-to-IRQ mapping for this line. Please move acpi_unregister_gsi() to the IRQ shutdown/cleanup path, or drop it if the GSI does not need explicit unmapping.

Comment on lines +434 to +438
mode = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0) + SZ_16M, SZ_16M);
if (!mode)
return -ENOMEM;

/* The resolution field starts with the flag "video=". */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Validate BAR size before mapping a fixed 16M offset for the mode string

ls2k_bmc_parse_mode always maps pci_resource_start(pdev, 0) + SZ_16M with size SZ_16M. If BAR0 is < 32M, this accesses beyond the MMIO region, which is undefined and may fault on some platforms. Please check pci_resource_len(pdev, 0) is at least SZ_16M * 2 (or the required layout) before mapping, and abort if the BAR is too small.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This patchset synchronizes LoongArch-specific support with upstream and includes multiple platform/device stability fixes plus new Loongson-2K BMC/IPMI enablement. It removes obsolete LS2K500 framebuffer/IPMI glue, wires in a new LS2K BMC MFD core + LS2K IPMI SI backend, and adjusts several core subsystems (USB suspend wake, SCSI EH, rtlwifi IRQ enabling, amdgpu LoongArch workarounds), along with defconfig updates.

Changes:

  • Add Loongson-2K BMC core MFD driver and LS2K IPMI SI platform backend; update Kconfig/Makefile wiring and MAINTAINERS; remove old LS2K500 fb/IPMI bits.
  • LoongArch power-management updates around ACPI GPE wakeup handling and late PM notifier registration.
  • Targeted fixes in USB suspend wake, SCSI error handling null-guard, rtl8723be IRQ enable ordering, amdgpu LoongArch-specific ring/fence/DPM behavior, plus config updates.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
MAINTAINERS Add maintainers entry for LS2K BMC core driver.
fs/crypto/Kconfig Switch fscrypt algorithm deps from imply to select.
drivers/video/fbdev/Makefile Stop building LS2K500 framebuffer driver.
drivers/video/fbdev/ls2k500sfb.c Remove obsolete LS2K500 framebuffer driver implementation.
drivers/video/fbdev/Kconfig Remove FB_LS2K500 Kconfig option.
drivers/usb/core/hub.c Enable/disable root-hub remote wake during port suspend error paths.
drivers/scsi/scsi_error.c Guard against NULL sdev / sdev->host in EH blocking helper.
drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c Set irq_enabled before programming HIMR/HIMRE.
drivers/mfd/Makefile Build LS2K BMC core driver when enabled.
drivers/mfd/ls2k-bmc-core.c New LS2K BMC core MFD driver (display + multi-channel IPMI + reset recovery).
drivers/mfd/Kconfig New MFD_LS2K_BMC_CORE Kconfig option.
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h Add LoongArch-only helper prototype for forcing high DPM.
drivers/gpu/drm/amd/pm/amdgpu_pm.c Add LoongArch-only helper implementation for forcing high DPM.
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c LoongArch ring-size adjustments + extra fence/EOP emission for cache flush workaround.
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c Call LoongArch DPM “high” helper during device init.
drivers/char/ipmi/Makefile Restructure IPMI SI object selection; add LS2K backend; gate port I/O by HAS_IOPORT.
drivers/char/ipmi/kcs_bmc_ls2k500.h Remove LS2K500 KCS header.
drivers/char/ipmi/Kconfig Add IPMI_LS2K option.
drivers/char/ipmi/ipmi_si.h Replace LS2K500 hooks with LS2K hooks.
drivers/char/ipmi/ipmi_si_pci.c Guard IORESOURCE_IO path when CONFIG_HAS_IOPORT=n.
drivers/char/ipmi/ipmi_si_ls2k500.c Remove LS2K500 IPMI SI implementation.
drivers/char/ipmi/ipmi_si_ls2k.c New LS2K memory-mapped KCS transport backend.
drivers/char/ipmi/ipmi_si_intf.c Use HAS_IOPORT guard; init/shutdown LS2K backend.
drivers/char/ipmi/btlock.h Remove LS2K500 btlock helper header.
drivers/cdrom/cdrom.c Move cdi->exit() from unregister to release.
arch/loongarch/power/suspend.c Add GPE enable-state restore handling via PM notifier (LoongArch ACPI S3).
arch/loongarch/power/platform.c Refine GPE wake enable logic for wake-capable ACPI devices.
arch/loongarch/kernel/cpu-probe.c Detect/report MSGINT and redirect interrupt capabilities.
arch/loongarch/include/asm/loongarch.h Add IOCSRF_REDIRECT bit definition.
arch/loongarch/include/asm/cpu.h Add CPU feature bits for MSGINT and redirect interrupts.
arch/loongarch/include/asm/cpu-features.h Add cpu_has_msgint / cpu_has_redirectint helpers.
arch/loongarch/configs/loongson3_defconfig Enable LS2K BMC/IPMI, SIMPLEDRM, fscrypt, adjust EFI RTC module setting, etc.
arch/loongarch/configs/deepin_loongarch_desktop_defconfig Enable LS2K BMC/IPMI, adjust EFI RTC module setting, remove LS2K500 fb config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#include <asm/time.h>
#include <asm/tlbflush.h>

#include "../drivers/acpi/acpica/aclocal.h"
#include <asm/bootinfo.h>
#include <asm/loongson.h>

#include "../drivers/acpi/acpica/aclocal.h"
Comment on lines +12 to +23
#include <linux/aperture.h>
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/iopoll.h>
#include <linux/kbd_kern.h>
#include <linux/kernel.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pci_ids.h>
Comment on lines +485 to +496
ls2k_bmc_cells[LS2K_BMC_DISPLAY].platform_data = &pd;
ls2k_bmc_cells[LS2K_BMC_DISPLAY].pdata_size = sizeof(pd);
base = pci_resource_start(dev, 0) + LS2K_DISPLAY_RES_START;

/* Remove conflicting efifb device */
ret = aperture_remove_conflicting_devices(base, SZ_4M, "simple-framebuffer");
if (ret)
return dev_err_probe(&dev->dev, ret, "Failed to removed firmware framebuffers\n");

return devm_mfd_add_devices(&dev->dev, PLATFORM_DEVID_AUTO,
ls2k_bmc_cells, ARRAY_SIZE(ls2k_bmc_cells),
pci_resource_n(dev, 0), 0, NULL);
Comment on lines +316 to +320
/* Skip interrupt in LS2K_BMC_INT_INTERVAL */
if (time_after(jiffies, last_jiffies + LS2K_BMC_INT_INTERVAL)) {
schedule_work(&ddata->bmc_reset_work);
last_jiffies = jiffies;
}
Comment on lines +181 to +185
void ipmi_si_ls2k_init(void)
{
platform_driver_register(&ipmi_ls2k_platform_driver);
ls2k_registered = true;
}
Comment on lines +332 to +338
ssize_t amdgpu_set_high_power_dpm_force_performance_level(struct amdgpu_device *adev)
{
if (adev->pm.sysfs_initialized)
return amdgpu_set_power_dpm_force_performance_level(adev->dev, NULL, "high", 0);

DRM_INFO("Failed to config dpm to high performance level\n");
return -EINVAL;
Comment on lines +433 to +455
/* The last 16M of PCI BAR0 is used to store the resolution string. */
mode = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0) + SZ_16M, SZ_16M);
if (!mode)
return -ENOMEM;

/* The resolution field starts with the flag "video=". */
if (!strncmp(mode, "video=", 6))
mode = mode + 6;

ret = kstrtoint(strsep(&mode, "x"), 10, &pd->width);
if (ret)
return ret;

ret = kstrtoint(strsep(&mode, "-"), 10, &pd->height);
if (ret)
return ret;

ret = kstrtoint(strsep(&mode, "@"), 10, &depth);
if (ret)
return ret;

pd->stride = pd->width * depth / 8;
pd->format = depth == 32 ? "a8r8g8b8" : "r5g6b5";
Comment on lines +342 to +352
pci_read_config_dword(parent, parent->msi_cap + PCI_MSI_ADDRESS_LO,
&ddata->bridge_pci_data.msi_lo);
pci_read_config_dword(parent, parent->msi_cap + PCI_MSI_ADDRESS_HI,
&ddata->bridge_pci_data.msi_hi);

pci_read_config_dword(parent, parent->pcie_cap + PCI_EXP_DEVCTL,
&ddata->bridge_pci_data.devctl);
pci_read_config_dword(parent, parent->pcie_cap + PCI_EXP_LNKCAP,
&ddata->bridge_pci_data.linkcap);
pci_read_config_dword(parent, parent->pcie_cap + PCI_EXP_LNKCTL,
&ddata->bridge_pci_data.linkctl_sts);
DATA_SEL(write64bit ? 2 : 1) | INT_SEL(0));
amdgpu_ring_write(ring, lower_32_bits(seq));
amdgpu_ring_write(ring, upper_32_bits(seq));
int i;
@deepin-ci-robot

Copy link
Copy Markdown

Hi @AaronDot. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign opsiff for approval. 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

1 similar comment
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign opsiff for approval. 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

@AaronDot AaronDot force-pushed the loongarch-sync-0611 branch from 49d7007 to 0e8e183 Compare June 12, 2026 03:08
AaronDot added 14 commits June 12, 2026 11:14
commit 75eb8b9 upstream.

This mostly reverts commit a0fc203.
Keep the relevant parts of the comment added by that commit.

The problem with that commit is that it allowed people to create broken
configurations that enabled FS_ENCRYPTION but not the mandatory
algorithms.  An example of this can be found here:
https://lore.kernel.org/r/1207325.1737387826@warthog.procyon.org.uk/

The commit did allow people to disable specific generic algorithm
implementations that aren't needed.  But that at best allowed saving a
bit of code.  In the real world people are unlikely to intentionally and
correctly make such a tweak anyway, as they tend to just be confused by
what all the different crypto kconfig options mean.

Of course we really need the crypto API to enable the correct
implementations automatically, but that's for a later fix.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://lore.kernel.org/r/20250217185314.27345-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit f28abb9 upstream.

LoongArch's MSG interrupt features are used across multiple subsystems.
Clarify these features to avoid misuse, existing users will be adjusted
if necessary.

MSGINT: Infrastructure, means the CPU core supports message interrupts.
Indicated by CPUCFG1.MSGINT.

AVECINT: AVEC interrupt controller based on MSGINT, means the CPU chip
supports direct message interrupts. Indicated by IOCSR.FEATURES.DMSI.

REDIRECTINT: REDIRECT interrupt controller based on MSGINT and AVECINT,
means the CPU chip supports redirect message interrupts. Indicated by
IOCSR.FEATURES.RMSI.

For example:
Loongson-3A5000/3C5000 doesn't support MSGINT/AVECINT/REDIRECTINT;
Loongson-3A6000 supports MSGINT but doesn't support AVECINT/REDIRECTINT;
Loongson-3C6000 supports MSGINT/AVECINT/REDIRECTINT.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
7A1000 ACPI GPE register 8 bit write is not supported, so that it cannot
be recovered correctly when resume, it need to recover the GPE enable
bit after S3.

Signed-off-by: Qunqin Zhao <zhaoqunqin@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
To solve "rx550 gfx timeout error" because of pcie order dislocation in
loongson platform, the old fence may cover new fence when gpu write on
fence when gpu write on fence mem, it will cause cpu get the ge the
wrong fence number.

Signed-off-by: zhaotianrui <zhaotianrui@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
In our platform, there will be some problems such as 'amdgpu timeout'
when amdgpu switch high-performance and low-performance mode.

Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
…enablement

Move the setting of the software flag `rtlpci->irq_enabled = true`
(this flag is checked in interrupt handler) to before enabling
hardware interrupts to prevent a race condition that can cause CPU stall.

Signed-off-by: tangyulong <tangyulong@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
When a USB optical drive is unplugged while in use (e.g. during burning),
the driver teardown process triggers a NULL pointer dereference in
scsi_block_when_processing_errors(). This happens because
unregister_cdrom() attempts to send SCSI commands (to exit MRW mode)
when the underlying scsi_device and its host are already being destroyed.

This patch fixes the issue via two approaches to ensure both stability
and kABI compatibility:

1. cdrom: Move the cdi->exit(cdi) call out of unregister_cdrom() and into
   cdrom_release(). This avoids sending block commands to a disconnected
   device during driver unloading, performing the cleanup safely when the
   file is closed.

2. scsi_error: Add a defensive NULL check for sdev and sdev->host in
   scsi_block_when_processing_errors() to prevent any potential panics
   during device teardown.

Note: Unlike the upstream commit 5ec9d26 ("cdrom: Call cdrom_mrw_exit
from cdrom_release function"), this patch retains the exit function
pointer in 'struct cdrom_device_info' to preserve kABI compatibility.

Signed-off-by: Ming Wang <wangming01@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Now we only enable the remote wakeup function for the USB wakeup source
itself at usb_port_suspend(). But on pre-XHCI controllers this is not
enough to enable the S3 wakeup function for USB keyboards, so we also
enable the root_hub's remote wakeup (and disable it on error). Frankly
this is unnecessary for XHCI, but enable it unconditionally make code
simple and seems harmless.

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
This reverts commit e020f90.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
This reverts commit 0d6b46e.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit 0d64f6d upstream.

The Loongson-2K Board Management Controller provides an PCIe interface
to the host to access the feature implemented in the BMC.

The BMC is assembled on a server similar to the server machine with
Loongson-3 CPU. It supports multiple sub-devices like DRM and IPMI.

Co-developed-by: Chong Qiao <qiaochong@loongson.cn>
Signed-off-by: Chong Qiao <qiaochong@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Acked-by: Corey Minyard <corey@minyard.net>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/0dc1fd53020ce2562453961ffed2cd9eb8f359e1.1756987761.git.zhoubinbin@loongson.cn
Signed-off-by: Lee Jones <lee@kernel.org>
(cherry picked from commit 0d64f6d)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
commit d952bba upstream.

Since the display is a sub-function of the Loongson-2K BMC, when the
BMC reset, the entire BMC PCIe is disconnected, including the display
which is interrupted.

Quick overview of the entire LS2K BMC reset process:

There are two types of reset methods: soft reset (BMC-initiated reboot
of IPMI reset command) and BMC watchdog reset (watchdog timeout).

First, regardless of the method, an interrupt is generated (PCIe interrupt
for soft reset/GPIO interrupt for watchdog reset);

Second, during the interrupt process, the system enters bmc_reset_work,
clears the bus/IO/mem resources of the LS7A PCI-E bridge, waits for the BMC
reset to begin, then restores the parent device's PCI configuration space,
waits for the BMC reset to complete, and finally restores the BMC PCI
configuration space.

Display restoration occurs last.

Co-developed-by: Chong Qiao <qiaochong@loongson.cn>
Signed-off-by: Chong Qiao <qiaochong@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Acked-by: Corey Minyard <corey@minyard.net>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/de4e04b42ff9ee282f86f9bb9efbf959a9848205.1756987761.git.zhoubinbin@loongson.cn
Signed-off-by: Lee Jones <lee@kernel.org>
(cherry picked from commit d952bba)
Signed-off-by: zhuyunfei <zhuyunfei@loongson-pc>
commit c5c76d8 upstream.

In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
compile time. We thus need to add this dependency and ifdef sections of
code using inb()/outb() as alternative access methods.

Acked-by: Corey Minyard <cminyard@mvista.com>
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Message-Id: <20240404104506.3352637-2-schnelle@linux.ibm.com>
Signed-off-by: Corey Minyard <minyard@acm.org>
(cherry picked from commit c5c76d8)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit d46651d upstream.

This patch adds Loongson-2K BMC IPMI support.

According to the existing design, we use software simulation to
implement the KCS interface registers: Stauts/Command/Data_Out/Data_In.

Also since both host side and BMC side read and write kcs status, fifo flag
is used to ensure data consistency.

The single KCS message block is as follows:

+-------------------------------------------------------------------------+
|FIFO flags| KCS register data | CMD data | KCS version | WR REQ | WR ACK |
+-------------------------------------------------------------------------+

Co-developed-by: Chong Qiao <qiaochong@loongson.cn>
Signed-off-by: Chong Qiao <qiaochong@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Acked-by: Corey Minyard <corey@minyard.net>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Message-ID: <8f9ffb6f0405345af8f04193ce1510aacd075e72.1756987761.git.zhoubinbin@loongson.cn>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit d46651d)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
AaronDot added 9 commits June 12, 2026 11:14
commit 6b157b4 upstream.

No need for it to be global.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202601170753.3zDBerGP-lkp@intel.com/
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 6b157b4)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit 0892507 stream.

The devm_kzalloc() function returns NULL on error so check for that
instead of error pointers.

Fixes: d952bba ("mfd: ls2kbmc: Add Loongson-2K BMC reset function support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Message-ID: <df80c6d61229eb8f877c3694525c0f97e64a43e8.1759478975.git.dan.carpenter@linaro.org>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 0892507)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit 4af66c2 upstream.

Call pci_disable_device() if devm_mfd_add_devices() fails.

Fixes: 0d64f6d ("mfd: ls2kbmc: Introduce Loongson-2K BMC core driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Message-ID: <e3e7cf2cfded48c9fca8bc981c54bbcb7edb9580.1759478975.git.dan.carpenter@linaro.org>
Signed-off-by: Corey Minyard <corey@minyard.net>
(cherry picked from commit 4af66c2)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit 3696ac1 upstream.

Remove unnecessary semicolons reported by Coccinelle/coccicheck and the
semantic patch at scripts/coccinelle/misc/semicolon.cocci.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Link: https://patch.msgid.link/20251111052451.3687740-1-nichen@iscas.ac.cn
Signed-off-by: Lee Jones <lee@kernel.org>
(cherry picked from commit 3696ac1)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit e11a9ad upstream.

The mixing of managed and non-managed resources may lead to possible
use-after-free bugs. In this driver the problematic part is the device
functionality that may just have gone behind the functions back, e.g.,
when interrupt is being served. Fix this by switching to managed resources
for PCI.

Fixes: 91a3e1f5453a ("mfd: ls2kbmc: Check for devm_mfd_add_devices() failure")
Fixes: d952bba ("mfd: ls2kbmc: Add Loongson-2K BMC reset function support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://patch.msgid.link/20251030113735.3741913-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
(cherry picked from commit e11a9ad)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit 9e87c8b upstream.

There is a PCI API to access device resources. Use it instead of
direct accesses.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://patch.msgid.link/20251030113735.3741913-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
(cherry picked from commit 9e87c8b)
Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Enable Loongson-2K0500 BMC with simpledrm.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Fix the issue of below:

sudo cryptsetup open /dev/sda mydata
device-mapper: ioctl: error adding target to table
device-mapper: table: 253:0: crypt: Error allocating crypto tfm (-ENOENT)
device-mapper: ioctl: error adding target to table

The error is due to the lack of CONFIG_CRYPTO_XTS.
Enable CONFIG_FS_ENCRYPTION can select FS_ENCRYPTION_ALGS in
config EXT4_FS, then select CONFIG_CRYPTO_XTS in
config FS_ENCRYPTION_ALGS.

Signed-off-by: wanghongliang <wanghongliang@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Enable CONFIG_SCSI_LPFC as module

Signed-off-by: zhangtianyang <zhangtianyang@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
@AaronDot AaronDot force-pushed the loongarch-sync-0611 branch from 9271c60 to 997838c Compare June 12, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants