Skip to content

[linux-6.6.y] ata: ahci: Fix Zhaoxin SATA LED quirk pci_dev refcount handling#1704

Open
leoliu-oc wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
leoliu-oc:linux-6.6.y-121-sata-led-update
Open

[linux-6.6.y] ata: ahci: Fix Zhaoxin SATA LED quirk pci_dev refcount handling#1704
leoliu-oc wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
leoliu-oc:linux-6.6.y-121-sata-led-update

Conversation

@leoliu-oc
Copy link
Copy Markdown
Contributor

@leoliu-oc leoliu-oc commented May 14, 2026

This patch fixes the Zhaoxin SATA LED quirk support by ensuring the pci_dev reference obtained from pci_get_device() is released in both ahci_zx_led_remove_quirk() and ahci_zx_led_init_quirk().

It also adds a pr_info() log when the Zhaoxin LED quirk is initialized, improving diagnostic visibility.

Summary by Sourcery

Fix Zhaoxin AHCI SATA LED quirk PCI device reference handling and improve logging for initialization diagnostics.

Bug Fixes:

  • Release pci_dev references acquired for Zhaoxin SATA LED quirks in both initialization and removal paths to avoid refcount leaks.

Enhancements:

  • Log a pr_info message when the Zhaoxin AHCI LED quirk is initialized to aid debugging.

This patch fixes the Zhaoxin SATA LED quirk support by ensuring the pci_dev
reference obtained from pci_get_device() is released in both
ahci_zx_led_remove_quirk() and ahci_zx_led_init_quirk().

It also adds a pr_info() log when the Zhaoxin LED quirk is initialized,
improving diagnostic visibility.

Signed-off-by: LeoLiu-oc <leoliu-oc@zhaoxin.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes Zhaoxin SATA LED quirk reference counting by releasing pci_dev obtained via pci_get_device() in both init and remove paths, and adds a diagnostic log when the quirk is initialized.

Sequence diagram for ahci_zx_led_init_quirk pci_dev refcount handling

sequenceDiagram
    participant Kernel
    participant ahci_zx_led_init_quirk
    participant pci_get_device
    participant sata_pdev
    participant pci_dev_put

    Kernel->>ahci_zx_led_init_quirk: ahci_zx_led_init_quirk(pdev, hpriv)
    ahci_zx_led_init_quirk->>pci_get_device: pci_get_device(...)
    pci_get_device-->>ahci_zx_led_init_quirk: sata_pdev
    ahci_zx_led_init_quirk->>ahci_zx_led_init_quirk: rdmsr(...)
    ahci_zx_led_init_quirk->>ahci_zx_led_init_quirk: pr_info(ahci: zx led quirk init)
    ahci_zx_led_init_quirk->>ahci_zx_led_init_quirk: configure hpriv fields
    ahci_zx_led_init_quirk->>sata_pdev: access PCI MMIO for LED quirk
    ahci_zx_led_init_quirk->>pci_dev_put: pci_dev_put(sata_pdev)
    pci_dev_put-->>ahci_zx_led_init_quirk: refcount decremented
    ahci_zx_led_init_quirk-->>Kernel: return
Loading

File-Level Changes

Change Details Files
Ensure pci_dev reference from pci_get_device() is properly released in both init and remove paths of the Zhaoxin SATA LED quirk.
  • Add pci_dev_put(sata_pdev) in ahci_zx_led_remove_quirk() after the search loop completes if sata_pdev was acquired
  • Add pci_dev_put(sata_pdev) at the end of ahci_zx_led_init_quirk() if sata_pdev was acquired
drivers/ata/ahci.c
Improve diagnostics for Zhaoxin SATA LED quirk initialization.
  • Log a pr_info() message when ahci_zx_led_init_quirk() runs successfully past the MSR read check
drivers/ata/ahci.c

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 deepin-ci-robot requested a review from BLumia May 14, 2026 02:58
@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

@deepin-ci-robot
Copy link
Copy Markdown

Hi @leoliu-oc. 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.

Copy link
Copy Markdown

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

  • Consider using dev_info(&pdev->dev, ...) or pr_info_once() instead of a bare pr_info() for the zx LED quirk init message so the log is associated with the specific device and avoids spamming logs on systems with multiple controllers or repeated init paths.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using dev_info(&pdev->dev, ...) or pr_info_once() instead of a bare pr_info() for the zx LED quirk init message so the log is associated with the specific device and avoids spamming logs on systems with multiple controllers or repeated init paths.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets the Zhaoxin AHCI SATA LED quirk logic in drivers/ata/ahci.c, aiming to fix pci_dev reference handling around pci_get_device() iteration and to improve diagnostic visibility when the quirk is initialized.

Changes:

  • Adds pci_dev_put() calls after pci_get_device()-based scans in both the quirk init and remove paths to avoid refcount leaks when the scan terminates early.
  • Adds an informational log message during Zhaoxin LED quirk initialization.

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

Comment thread drivers/ata/ahci.c
Comment on lines +1844 to 1848
if (sata_pdev)
pci_dev_put(sata_pdev);

if (target_p0_dev) {
sata_host = pci_get_drvdata(target_p0_dev);
Comment thread drivers/ata/ahci.c
Comment on lines +1872 to +1873
pr_info("ahci: zx led quirk init\n");

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