Skip to content

[linux-6.6.y] LoongArch Stage Patch Synchronization 260727#2018

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

[linux-6.6.y] LoongArch Stage Patch Synchronization 260727#2018
AaronDot wants to merge 9 commits into
deepin-community:linux-6.6.yfrom
AaronDot:loongarch-sync-260727

Conversation

@AaronDot

@AaronDot AaronDot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Introduction to the patchset:

Patch 1-2: backported from upstream;
Patch 3: Fix LS7A GPU access hang;
Patch 4-5: Fix lockdep WARN in wangxun and yt6801;
Patch 6: Add a barrier to avoid get invalid smid;
Patch 7: Fix Loongson hda sound pin sense status;
Patch 8-9: Update loongarch configs.

Summary by Sourcery

Synchronize LoongArch-specific fixes and config updates, addressing GPU, audio, storage, and networking issues while improving generic device-tree handling on LoongArch.

Bug Fixes:

  • Add a Loongson GPU display PCI quirk to prevent DMA and display-related hangs on affected devices.
  • Introduce a Loongson-specific HDMI codec patch that disables 44.1kHz audio and switches pin sense to ELD-based jack detection on affected PCI revisions to work around hardware defects.
  • Propagate the new ELD-based jack detection path into generic HDA jack pin-sense handling via a codec flag.
  • Ensure write-protecting LoongArch page table entries records the modified state when the dirty bit is set, avoiding loss of writeback information.
  • Insert a LoongArch-specific read memory barrier in megaraid SAS Fusion completion processing to prevent reading invalid SMID values.
  • Fix a lockdep warning in the Motorcomm YT6801 driver by properly initializing the PHY link-poll timer with a dedicated lock class key and callback.
  • Fix a lockdep-related issue in the Wangxun txgbe driver by initializing sysfs attributes before device_create_file().

Enhancements:

  • Refactor the generic IRQ UIO platform driver to use firmware-node and generic device-property APIs instead of Open Firmware-specific helpers, improving platform neutrality.
  • Extend LoongArch PCI handling with a display-class-wide quirk registration for Loongson GPUs to cover additional display devices.
  • Add an HDA codec flag to allow machine drivers to opt into ELD-based jack detection logic.

Chores:

  • Update LoongArch defconfig variants to reflect the new driver and platform configuration changes.

cpackham-atlnz and others added 9 commits July 27, 2026 14:37
commit 90fa028 upstream.

Convert the uio_pdrv_genirq driver to use the device_property_* APIs
instead of the of_property_* ones. This allows UIO interrupts to be
defined via an ACPI overlay using the Device Tree namespace linkage.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20240408234050.2056374-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
commit 018e982 upstram.

When hardware page table walker (PTW) is enabled on LoongArch, the CPU
may set _PAGE_DIRTY directly in the page table entry during a write TLB
miss, without going through the software TLB store handler. The software
TLB store handler (tlbex.S:254) sets both _PAGE_DIRTY and_PAGE_MODIFIED
together:

    ori t0, t0, (_PAGE_VALID | _PAGE_DIRTY | _PAGE_MODIFIED)

Since hardware PTW only sets _PAGE_DIRTY, the software-only bit, i.e.
_PAGE_MODIFIED is left unchanged. This creates a window where a PTE has
_PAGE_DIRTY set (hardware knows the page is dirty) but _PAGE_MODIFIED
clear (software is unaware).

When fork()/clone() triggers copy-on-write, __copy_present_ptes() calls
pte_wrprotect(), which unconditionally clears both the _PAGE_WRITE and
_PAGE_DIRTY bits:

    pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_DIRTY);

Since _PAGE_MODIFIED was never set, the dirtiness information is lost
completely. Subsequently, when memory pressure triggers page reclaim,
page_mkclean() / try_to_unmap() sees the page as clean (i.e. pte_dirty()
returns false) and the page may be freed without writeback, causing data
corruption.

Fix this by propagating the _PAGE_DIRTY bit to the _PAGE_MODIFIED bit in
both pte_wrprotect() and pmd_wrprotect() before clearing writeable bits:

    if (pte_val(pte) & _PAGE_DIRTY)
        pte_val(pte) |= _PAGE_MODIFIED;

The pmd_wrprotect() fix handles the CONFIG_TRANSPARENT_HUGEPAGE case,
where pmd entries need the same treatment.

This ensures the software dirty tracking bit (checked by pte_dirty() and
pmd_dirty(), which read both the _PAGE_DIRTY and _PAGE_MODIFIED bits) is
preserved across fork COW write-protection.

The issue was found by the LTP madvise09 test case, which exercises page
reclaim after "madvise(MADV_FREE), write and fork" operation sequence on
private anonymous mappings.

Cc: stable@vger.kernel.org
Fixes: 09cfefb ("LoongArch: Add memory management")
Co-developed-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
On Loongson LS7A1000/LS7A2000 bridge chipsets, the system may hang at
the boot screen (e.g. Kylin logo) due to a deadlock in the HT non-posted
(NONPOST) channel. The root cause is a SEQ ID collision: when the CPU
issues both SATA register reads and heavy framebuffer writes, they can
be assigned the same sequence ID in the NONPOST channel. If the SATA
controller concurrently has pending DMA write requests, it can
probabilistically block the non-posted channel, creating a deadlock
between the two transaction streams.

Fix this by adding a PCI final quirk that programs the GPU device BAR
base address and mask into chipset registers (0xefdfb000174/170),
ensuring proper DMA window configuration and avoiding the deadlock
condition.

Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
…r key

init_timer_key() was called with a NULL lock_class_key, which
triggers DEBUG_LOCKS_WARN_ON(!key) in lockdep_init_map_type
when CONFIG_LOCKDEP is enabled.

Fix by providing a local static lock_class_key via init_timer_key()
for kernel >= 4.15, so the custom timer name 'fuxi_phy_link_update_timer'
is preserved; keep the old code path for < 4.15 unchanged.

Fixes: 11c878908ad9 ("net: update yt6801 driver")
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
The hwmon_attr.dev_attr struct attribute is dynamically allocated,
so its lockdep key is neither static nor registered via
lockdep_register_key().

lockdep_init_map_type() checks:
  !static_obj(lock->key) && !is_dynamic_key(lock->key)
and triggers DEBUG_LOCKS_WARN_ON(1) because both conditions are true.

Fix by calling sysfs_attr_init() before device_create_file() to
point the attribute's key to a static struct lock_class_key.

Fixes: d07bd4fa0db8 ("net: wangxun: Update driver to version 1.3.6.4")
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
…tion

Add a barrier instruction to ensure data consistency between the CPU and
DMA; tests have proven that it can effectively eliminate some sporadic
data errors.

Signed-off-by: zhangtianyang <zhangtianyang@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Due to a hardware defect, for PCI devices with a reversion ID of 2,
the pin sense status must be determined via the ELD.

Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Haowei Zheng <zhenghaowei@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
The TPM device (/dev/tpm0) is not created in virtual machines due to
CONFIG_TCG_TIS_CORE being built as a module (m) and CONFIG_TCG_TIS
being disabled.

This resolves the issue of missing /dev/tpm0 in VM environments.

Signed-off-by: zhuyunfei <zhuyunfei@loongson.cn>
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

Signed-off-by: wanghongliang <wanghongliang@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
@sourcery-ai

sourcery-ai Bot commented Jul 27, 2026

Copy link
Copy Markdown

🧙 Sourcery has finished reviewing your pull request!


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

@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 dongert 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

@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.

@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 left some high level feedback:

  • In loongson_display_quirk(), consider replacing the hard-coded MMIO addresses (0xefdfb000174/170) with named constants or documented macros and double-checking the BAR size/mask computation (end - start vs end - start + 1) to avoid subtle off-by-one issues when programming the mask.
  • In uio_pdrv_genirq_probe(), dev_fwnode(&pdev->dev) can be NULL; using "%pfwP" on a NULL fwnode may produce an unhelpful name, so it would be safer to fall back to dev_name(&pdev->dev) or a static string when node is missing.
  • In fxgmac_phy_timer_init(), init_timer_key() is now passed fxgmac_phy_link_poll, but the code still overrides phy_poll_tm.function later with a casted (void *) callback; it would be cleaner and less error-prone either to rely solely on init_timer_key() for the function or to drop the function parameter there to avoid redundant and inconsistent setup.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In loongson_display_quirk(), consider replacing the hard-coded MMIO addresses (0xefdfb000174/170) with named constants or documented macros and double-checking the BAR size/mask computation (end - start vs end - start + 1) to avoid subtle off-by-one issues when programming the mask.
- In uio_pdrv_genirq_probe(), dev_fwnode(&pdev->dev) can be NULL; using "%pfwP" on a NULL fwnode may produce an unhelpful name, so it would be safer to fall back to dev_name(&pdev->dev) or a static string when node is missing.
- In fxgmac_phy_timer_init(), init_timer_key() is now passed fxgmac_phy_link_poll, but the code still overrides phy_poll_tm.function later with a casted (void *) callback; it would be cleaner and less error-prone either to rely solely on init_timer_key() for the function or to drop the function parameter there to avoid redundant and inconsistent setup.

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.

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

Synchronizes a set of LoongArch-focused fixes and config updates against the linux-6.6.y tree, including platform quirks (GPU/audio), low-level memory-management fixes, and several driver correctness/lockdep cleanups.

Changes:

  • Add Loongson HDMI codec quirks (disable 44.1kHz rates; enable ELD-based jack detection on affected revisions) and plumb ELD-based presence into generic HDA pin-sense handling.
  • Add/extend LoongArch PCI display quirks, fix LoongArch page-table write-protect handling, and add a LoongArch barrier in megaraid fusion completion.
  • Fix driver lockdep warnings (txgbe sysfs attrs, yt6801 timer lock class) and refresh LoongArch defconfigs.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
sound/pci/hda/patch_hdmi.c Adds a Loongson HDMI codec patch hook and enables ELD-based jack detection on specific PCI revisions.
sound/pci/hda/hda_jack.c Adjusts generic HDA pin-sense presence handling to optionally derive presence from ELD validity.
include/sound/hda_codec.h Introduces a codec flag to select ELD-based jack detection behavior.
drivers/uio/uio_pdrv_genirq.c Refactors UIO genirq probe path to use firmware-node + device-property APIs.
drivers/scsi/megaraid/megaraid_sas_fusion.c Adds a LoongArch read barrier before reading SMID from reply descriptors.
drivers/net/ethernet/wangxun/txgbe/txgbe_sysfs.c Initializes sysfs attributes before device_create_file() to address lockdep expectations.
drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-phy.c Updates timer initialization with a dedicated lock class key and callback.
arch/loongarch/pci/pci.c Adds a display-class quirk path for Loongson GPUs (register programming based on BAR sizing/topology).
arch/loongarch/include/asm/pgtable.h Preserves “modified” state when write-protecting dirty PTE/PMD entries.
arch/loongarch/configs/loongson3_defconfig Enables TPM TIS core/TIS built-in and CRYPTO_XTS.
arch/loongarch/configs/deepin_loongarch_desktop_defconfig Enables TPM TIS core/TIS built-in and CRYPTO_XTS.

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

Comment on lines +4534 to +4537
/*
* Due to a hardware defect, for PCI devices with a reversion ID
* of 2, the pin sense status must be determined via the ELD.
*/
Comment on lines +4538 to +4539
if (codec->bus && codec->bus->pci->revision == 0x2)
codec->eld_jack_detect = 1;
Comment thread sound/pci/hda/hda_jack.c
Comment on lines 8 to 14
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/pci.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/jack.h>
Comment thread sound/pci/hda/hda_jack.c
Comment on lines +63 to +66
if (codec->eld_jack_detect) {
val &= ~AC_PINSENSE_PRESENCE;
val |= !!(val & AC_PINSENSE_ELDV) << 31;
}
Comment on lines +3593 to +3595
#ifdef CONFIG_LOONGARCH
__smp_rmb();
#endif
Comment on lines 322 to 323
pdata->expansion.phy_poll_tm.expires = jiffies + HZ / 2;
pdata->expansion.phy_poll_tm.function = (void *)(fxgmac_phy_link_poll);
Comment thread arch/loongarch/pci/pci.c
Comment on lines +199 to +211
if (!dev->bus->number) {
if (!(dev->vendor == PCI_VENDOR_ID_LOONGSON &&
(dev->device == 0x7a15 || dev->device == 0x7a25)))
return;
} else {
while (!pci_is_root_bus(bus->parent))
bus = bus->parent;

/* ensure slot is 7a2000 */
if (bus->self->vendor != PCI_VENDOR_ID_LOONGSON ||
bus->self->device < 0x7a39)
return;
}
Comment thread arch/loongarch/pci/pci.c
Comment on lines +213 to +224
max_size = 0;
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
if (dev->resource[i].flags & IORESOURCE_MEM) {
size = dev->resource[i].end - dev->resource[i].start;
if (size > max_size) {
max_size = size;
num = i;
}
}
}

mask = ~(dev->resource[num].end - dev->resource[num].start);
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.

8 participants