Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] net: rnpm: fix compiler error of rnpm #874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

senbao
Copy link

@senbao senbao commented Jun 12, 2025

fix compiler error of rnpm for mucse N10/N400 4/8 ports ethernet card

Summary by Sourcery

Fix compiler errors in the rnpm driver for mucse Ethernet cards by introducing a 64-bit temporary for DMA address handling, correcting a faulty conditional, and refactoring RX ring reinitialization.

Bug Fixes:

  • Use a u64 address variable to split 64-bit DMA addresses consistently across mailbox commands.
  • Fix the inverted logical check for single_lane_link_evt_ctrl_ablity in lane link change event enable.
  • Correct the sdram simm function to return 0 unconditionally instead of using an unused error variable.

Enhancements:

  • Refactor rnpm_rx_ring_reinit to allocate the temporary ring dynamically with vmalloc/vfree and streamline resource setup and teardown.

fix compiler error of rnpm for mucse 4/8 ports ethernet card

Signed-off-by: gu.huiguang <[email protected]>
Copy link

sourcery-ai bot commented Jun 12, 2025

Reviewer's Guide

This PR addresses compiler errors and improves code robustness by introducing a unified 64-bit DMA address variable for splitting high/low parts, refactoring RX ring reinitialization to use dynamic allocation, and correcting minor logic and return-value issues.

Sequence Diagram for rnpm_rx_ring_reinit Resource Management

sequenceDiagram
    participant Caller
    participant RRI as rnpm_rx_ring_reinit
    participant KMem as Kernel Memory
    participant RxResMgr as RX Resource Mgr
    participant HW as Hardware IO

    Caller->>RRI: rnpm_rx_ring_reinit(adapter, rx_ring)
    opt If ring count not changed (rx_ring->count == rx_ring->reset_count)
      RRI-->>Caller: return 0
    end
    RRI->>KMem: vmalloc(sizeof(struct rnpm_ring))
    KMem-->>RRI: temp_ring_ptr
    alt Allocation Fails (temp_ring_ptr is NULL)
        RRI-->>Caller: return -ENOMEM
    else Allocation Succeeded
        RRI->>HW: rnpm_disable_rx_queue(adapter, rx_ring)
        RRI->>RxResMgr: rnpm_setup_rx_resources(temp_ring_ptr, adapter)
        RxResMgr-->>RRI: setup_status (err)
        alt Setup Failed (err is true)
            RRI->>RxResMgr: rnpm_free_rx_resources(temp_ring_ptr)
            RRI->>KMem: vfree(temp_ring_ptr)
            RRI->>HW: wr32(hw, RNPM_DMA_RX_START(...), 1) // Re-enable queue
            RRI-->>Caller: return 0
        else Setup Succeeded (err is false)
            RRI->>RxResMgr: rnpm_free_rx_resources(rx_ring) // Free old resources
            RRI->>HW: rnpm_configure_rx_ring(adapter, rx_ring) // Configure with new resources
            RRI->>KMem: vfree(temp_ring_ptr)
            RRI->>HW: wr32(hw, RNPM_DMA_RX_START(...), 1) // Re-enable queue
            RRI-->>Caller: return 0
        end
    end
Loading

Updated Class Diagram for rnpm Driver C Modules and Structs

classDiagram
    class rnpm_mbx_fw_c {
        +rnpm_maintain_req(struct rnpm_hw* hw, int cmd, int arg0, int req_data_bytes, int reply_bytes, dma_addr_t dma_phy) int
        +rnpm_mbx_get_dump(struct rnpm_hw* hw, int flags, u8* data_out, int bytes) int
        +rnpm_fw_update(struct rnpm_hw* hw, int partition, const u8* fw_bin, int bytes) int
        +rnpm_mbx_lane_link_changed_event_enable(struct rnpm_hw* hw, int enable) int
        +rnpm_mbx_sdram_simm(struct rnpm_hw* hw, u32 flags, u32 offset, void* dma_buf, dma_addr_t dma_phy, u32 len) int
    }

    class rnpm_mbx_fw_h {
        +build_ddr_csl(struct mbx_fw_cmd_req* req, void* cookie, bool enable, dma_addr_t dma_phy, int bytes) void
    }

    class rnpm_main_c {
        +rnpm_rx_ring_reinit(struct rnpm_adapter* adapter, struct rnpm_ring* rx_ring) int
    }

    class rnpm_hw {
        <<struct>>
    }
    class rnpm_adapter {
        <<struct>>
    }
    class rnpm_ring {
        <<struct>>
    }
    class mbx_fw_cmd_req {
        <<struct>>
    }

    rnpm_mbx_fw_c ..> rnpm_hw : uses
    rnpm_mbx_fw_h ..> mbx_fw_cmd_req : uses
    rnpm_main_c ..> rnpm_adapter : uses
    rnpm_main_c ..> rnpm_ring : uses
    rnpm_adapter --> rnpm_hw : contains
Loading

File-Level Changes

Change Details Files
Introduce local 64-bit address variable for DMA address splitting
  • Declare a u64 address variable in mailbox routines
  • Assign dma_phy to address before masking
  • Update all build_*_req calls to use address & 0xffffffff and (address >> 32)
  • Centralize the pattern in rnpm_mbx_fw.c and rnpm_mbx_fw.h
drivers/net/ethernet/mucse/rnpm/rnpm_mbx_fw.c
drivers/net/ethernet/mucse/rnpm/rnpm_mbx_fw.h
Refactor RX ring reinitialization to dynamic allocation
  • Change temp_ring from a stack struct to a pointer
  • Allocate temp_ring with vmalloc and check for ENOMEM
  • Use pointer-based memset, memcpy, and free routines
  • Release the buffer with vfree after reinit
drivers/net/ethernet/mucse/rnpm/rnpm_main.c
Correct minor logic and return-value issues
  • Fix inverted negation in single_lane_link_evt_ctrl_ablity condition
  • Simplify rnpm_mbx_sdram_simm to always return 0 instead of error-based codes
drivers/net/ethernet/mucse/rnpm/rnpm_mbx_fw.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
Copy link

[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 avenger-285714 for approval. For more information see the Code Review Process.

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

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

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

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

@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 @senbao - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@Avenger-285714 Avenger-285714 merged commit e1691e9 into deepin-community:linux-6.6.y Jun 12, 2025
6 of 7 checks passed
@opsiff opsiff changed the title net: rnpm: fix compiler error of rnpm [Deepin-Kernel-SIG] [linux 6.6-y] net: rnpm: fix compiler error of rnpm Jun 20, 2025
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