Skip to content

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

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

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

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 register update in r8152 by using a 16-bit write so the OOBS_POLLING bit is reliably cleared on RTL_VER_15 devices.

[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>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 18, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes how the driver clears the OOBS_POLLING bit in the USB_UPHY_XTAL register for r8156 devices by switching from a byte write to a word write, ensuring the upper byte of the 16‑bit register is updated correctly.

Sequence diagram for updated r8156_ups_en register write

sequenceDiagram
    participant r8156_ups_en
    participant ocp_read_word
    participant ocp_write_word
    participant USB_UPHY_XTAL

    r8156_ups_en->>ocp_read_word: ocp_read_word(tp, MCU_TYPE_USB, USB_UPHY_XTAL)
    ocp_read_word-->>r8156_ups_en: ocp_data
    r8156_ups_en->>r8156_ups_en: ocp_data &= ~OOBS_POLLING
    r8156_ups_en->>ocp_write_word: ocp_write_word(tp, MCU_TYPE_USB, USB_UPHY_XTAL, ocp_data)
    ocp_write_word-->>USB_UPHY_XTAL: update 16_bit_register
Loading

File-Level Changes

Change Details Files
Correct the register write width when clearing the OOBS_POLLING bit in USB_UPHY_XTAL for r8156.
  • Continue reading the USB_UPHY_XTAL register via ocp_read_word into ocp_data.
  • Mask out the OOBS_POLLING bit from ocp_data as before.
  • Change the write helper from ocp_write_byte to ocp_write_word so the full 16-bit register, including the upper byte containing OOBS_POLLING, is written back.
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 an r8152 driver bug where clearing OOBS_POLLING (BIT(8)) in the 16-bit USB_UPHY_XTAL register was incorrectly performed with an 8-bit write, which cannot clear a bit in the upper byte.

Changes:

  • Replace ocp_write_byte() with ocp_write_word() when updating USB_UPHY_XTAL for RTL_VER_13/RTL_VER_15.
  • Ensures OOBS_POLLING (BIT(8)) is correctly cleared in the full 16-bit register value.

💡 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 44981e9 into deepin-community:linux-6.18.y May 18, 2026
10 of 16 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