Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] r8152: fix incorrect register write to USB_UPHY_XTAL#1747

Merged
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:RTL8159-6.6
May 18, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] r8152: fix incorrect register write to USB_UPHY_XTAL#1747
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:RTL8159-6.6

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

@Avenger-285714 Avenger-285714 commented May 18, 2026

[Upstream commit 48afd5124fd6129c46fd12cb06155384b1c4a0c4]

The old code used ocp_write_byte() to clear the OOBS_POLLING bit (BIT(8)) in the USB_UPHY_XTAL register, but this doesn't correctly clear a bit in the upper byte of the 16-bit register.

Fix this by using ocp_write_word() instead.

Fixes: 195aae3 ("r8152: support new chips")

Reviewed-by: Hayes Wang hayeswang@realtek.com
Link: https://patch.msgid.link/20260326073925.32976-454-nic_swsd@realtek.com

Summary by Sourcery

Bug Fixes:

  • Correct USB_UPHY_XTAL OOBS_POLLING bit clearing by writing the full 16-bit word instead of a single byte.

[Upstream commit 48afd5124fd6129c46fd12cb06155384b1c4a0c4]

The old code used ocp_write_byte() to clear the OOBS_POLLING bit
(BIT(8)) in the USB_UPHY_XTAL register, but this doesn't correctly
clear a bit in the upper byte of the 16-bit register.

Fix this by using ocp_write_word() instead.

Fixes: 195aae3 ("r8152: support new chips")
Signed-off-by: Chih Kai Hsu <hsu.chih.kai@realtek.com>
Reviewed-by: Hayes Wang <hayeswang@realtek.com>
Link: https://patch.msgid.link/20260326073925.32976-454-nic_swsd@realtek.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@Avenger-285714 Avenger-285714 requested review from Copilot and opsiff May 18, 2026 13:50
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 18, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the r8152 USB network driver to correctly clear a 16-bit register bit by switching from a byte write helper to a word write helper when modifying USB_UPHY_XTAL for certain chip revisions.

Sequence diagram for updated r8156_ups_en register write

sequenceDiagram
    participant Driver as r8156_ups_en
    participant USBMCU as MCU_TYPE_USB

    Driver->>USBMCU: ocp_read_word(USB_UPHY_XTAL)
    USBMCU-->>Driver: ocp_data
    Driver->>Driver: ocp_data &= ~OOBS_POLLING
    Driver->>USBMCU: ocp_write_word(USB_UPHY_XTAL, ocp_data)
Loading

File-Level Changes

Change Details Files
Use a 16-bit register write helper when clearing the OOBS_POLLING bit in USB_UPHY_XTAL for RTL_VER_15 in r8156_ups_en().
  • Read USB_UPHY_XTAL with ocp_read_word and mask out OOBS_POLLING as before
  • Replace ocp_write_byte with ocp_write_word to write back the full 16-bit value, ensuring the upper byte bit is cleared correctly
drivers/net/usb/r8152.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

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 reviewed your changes and they look great!


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

Fixes a Realtek r8152/r8156 USB OCP register programming bug where clearing OOBS_POLLING (BIT(8)) in the 16-bit USB_UPHY_XTAL register incorrectly used an 8-bit write, preventing the upper-byte bit from being cleared.

Changes:

  • Replace ocp_write_byte() with ocp_write_word() when updating USB_UPHY_XTAL in r8156_ups_en().
  • Ensure the OOBS_POLLING bit (BIT(8)) is actually cleared in the 16-bit register value read via ocp_read_word().

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

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: opsiff

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

The pull request process is described 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 merged commit 1c48063 into deepin-community:linux-6.6.y May 18, 2026
17 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants