Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] [FROMLIST] PCI: switchtec: backport upstream fixes and Gen6 support#1745

Open
Avenger-285714 wants to merge 3 commits into
deepin-community:linux-6.6.yfrom
Avenger-285714:switchgen6-6.6
Open

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] [FROMLIST] PCI: switchtec: backport upstream fixes and Gen6 support#1745
Avenger-285714 wants to merge 3 commits into
deepin-community:linux-6.6.yfrom
Avenger-285714:switchgen6-6.6

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

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

This PR backports three upstream PCI switchtec driver patches:

  1. PCI: switchtec: Replace manual locks with guard
    Replace lock/unlock pairs with guards to simplify and tidy up the code.

  2. PCI: switchtec: Make switchtec_class constant
    Place 'class' structures into read-only memory instead of dynamically
    allocating them at runtime.

  3. PCI: switchtec: Add Gen6 Device IDs
    Add device IDs for the next generation of switchtec products.
    No driver changes were required for the new hardware version.

Summary by Sourcery

Backport upstream improvements to the PCI switchtec driver, including const-ifying its device class, adopting scoped mutex guards, and adding support for Gen6 devices.

New Features:

  • Add PCI IDs and generation enum entry to enable support for Switchtec Gen6 devices.

Enhancements:

  • Make the global switchtec device class a statically defined const structure registered with the driver core instead of being created dynamically.
  • Replace manual mutex lock/unlock pairs in the MRPC handling paths with guard-based scoped locking for clearer and safer synchronization.

Erickkaranja and others added 3 commits May 18, 2026 20:20
[Upstream commit f2543da]

Replace lock/unlock pairs with guards to simplify and tidy up the code.

Generated-by: Coccinelle SmPL

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Link: https://patch.msgid.link/20250828093556.810911-1-karanja99erick@gmail.com
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 8a74e4e]

Now that the driver core allows for struct class to be in read-only memory,
we should make all 'class' structures declared at build time placing them
into read-only memory, instead of having to be dynamically allocated at
runtime.

Link: https://lore.kernel.org/r/2024061053-online-unwound-b173@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-By: Logan Gunthorpe <logang@deltatee.com>
Cc: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
Cc: Jon Mason <jdmason@kudzu.us>
Cc: Allen Hubbe <allenbh@gmail.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Add device IDs for the next generation of switchtec products.

No changes to the driver were required with the new version of the
hardware.

[logang: rewrote commit message]

Signed-off-by: Ben Reed <Ben.Reed@microchip.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260505161633.67454-1-logang@deltatee.com
Link: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=next&id=5e6c21c56998e1e58d2f314e70779989ea0fee5d
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@Avenger-285714 Avenger-285714 requested review from Copilot and opsiff May 18, 2026 12:37
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 18, 2026

Reviewer's Guide

Backports upstream improvements to the PCI switchtec driver by converting manual mutex handling to guard helpers, making the switchtec device class a static const and adjusting registration accordingly, and adding Gen6 support via new enum and PCI Device IDs, plus wiring the NTB switchtec interface to the new class definition.

File-Level Changes

Change Details Files
Replace manual mutex lock/unlock pairs in MRPC paths with guard-based helpers for safer, cleaner lifetime management.
  • Convert mrpc_event_work() to use guard(mutex) around mrpc_timeout cancellation and command completion instead of explicit mutex_lock/mutex_unlock
  • Wrap the stdev_kill() MRPC teardown section in scoped_guard(mutex, &stdev->mrpc_mutex) to ensure the mutex is always released while marking the device dead and waking/killing queued users
drivers/pci/switch/switchtec.c
Make the switchtec device class a global const structure registered/unregistered explicitly, and adjust users to reference it directly.
  • Replace the global struct class* switchtec_class with a global const struct class switchtec_class initialized with name="switchtec"
  • Change device class assignment in stdev_create() to take &switchtec_class instead of a pointer variable
  • In switchtec_init()/switchtec_exit(), replace class_create()/class_destroy() with class_register()/class_unregister() on &switchtec_class and update error handling paths accordingly
  • Update the switchtec_class declaration in the public header to match the new const struct class definition
  • Adjust the NTB switchtec interface setup to assign &switchtec_class to switchtec_interface.class
drivers/pci/switch/switchtec.c
include/linux/switchtec.h
drivers/ntb/hw/mscc/ntb_hw_switchtec.c
Add Switchtec Gen6 support by extending the generation enum and PCI device ID table.
  • Extend enum switchtec_gen with SWITCHTEC_GEN6
  • Add multiple SWITCHTEC_PCI_DEVICE() entries for various Gen6 PFXs/PSXs/PFX/PSX device IDs to switchtec_pci_tbl[]
include/linux/switchtec.h
drivers/pci/switch/switchtec.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

@Avenger-285714 Avenger-285714 changed the title [Deepin-Kernel-SIG] [linux 6.18.y] [Upstream] [FROMLIST] PCI: switchtec: backport upstream fixes and Gen6 support [Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] [FROMLIST] PCI: switchtec: backport upstream fixes and Gen6 support May 18, 2026
@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 ask for approval from avenger-285714. 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

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

Backports three upstream PCI switchtec driver patches to the 6.18.y tree: a refactor to use guard()/scoped_guard() mutex helpers, conversion of switchtec_class to a constant struct class, and addition of Gen6 device IDs.

Changes:

  • Replace manual mutex_lock/mutex_unlock pairs with guard(mutex) and scoped_guard(mutex) in mrpc_event_work() and stdev_kill().
  • Convert switchtec_class from a dynamically allocated struct class * to a statically defined const struct class, and update the dependent NTB driver accordingly.
  • Add SWITCHTEC_GEN6 enum value and 16 new Gen6 PCI device IDs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
include/linux/switchtec.h Adds SWITCHTEC_GEN6 enum value and changes switchtec_class declaration to const struct class.
drivers/pci/switch/switchtec.c Replaces manual mutex locking with guard helpers, statically defines switchtec_class, and registers new Gen6 device IDs.
drivers/ntb/hw/mscc/ntb_hw_switchtec.c Updates NTB driver to use the address of the new static switchtec_class.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants