Skip to content

Conversation

wqiao-intel
Copy link

@wqiao-intel wqiao-intel commented Jan 29, 2024

Add telit modems fn990 support。

Those are out of tree patches.

Summary by Sourcery

Add support for Telit FN980 v2 and FN990 modems by extending MHI channel configurations, PCI ID mappings, firmware flashing controls, and WWAN port capabilities.

New Features:

  • Introduce AMSS_SBL UL/DL channel config macros and apply them to Telit modems
  • Add Telit FN980 hardware revision v2 MHI device configuration and make it the default for QCOM PCI ID 0x0306
  • Add PCI device ID entry for Telit FN990 modem
  • Expose a 'fw_update' sysfs attribute to trigger and monitor firmware flashing state
  • Add support for tracking and handling XFP flashing states in the MHI controller
  • Implement a simple WWAN DTR driver (mhi_wwan_dtr) for IP_CTRL channel to control DTR/RTS signals
  • Extend WWAN core to recognize SAHARA and NMEA port types and provide a port type retrieval API

Enhancements:

  • Halve the MHI health check interval and introduce a 40-second delay during PCI recovery
  • Update MHI power-up and mission-mode logic to consider the SBL execution environment
  • Automatically set and unset DTR/RTS for AT WWAN ports in mhi_wwan_ctrl on start and stop

Build:

  • Add mhi_wwan_dtr.o to the WWAN build for the new DTR driver

…55 variant"

This reverts commit 46af287.

Removed since it binds FN980 V2 to MBIM.

deepin-Intel-SIG: Revert "bus: mhi: host: pci_generic: add support for sc8280xp-crd SDX55 variant".

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
deepin-Intel-SIG: wwan: add SAHARA device.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
There are situations in which SBL is a legitimate initial execution
environment (e.g. modem stuck in SBL due to a firmware failure...), but
mhi refuses to start:

mhi-pci-generic 0000:01:00.0: MHI PCI device found: foxconn-sdx55
mhi-pci-generic 0000:01:00.0: BAR 0: assigned
mhi-pci-generic 0000:01:00.0: enabling device (0000 -> 0002)
mhi mhi0: Requested to power ON
mhi mhi0: SECONDARY BOOTLOADER is not a valid EE for power on
mhi-pci-generic 0000:01:00.0: failed to power up MHI controller
mhi-pci-generic: probe of 0000:01:00.0 failed with error -5

Fix this by adding SBL as an allowed initial execution environment.

deepin-Intel-SIG: bus: mhi: host: allow SBL as initial EE.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
After performing the firmware update in SBL through the XFP
protocol, FN980 resets and is not detected anymore by the host.

Add a new controller file to be used when performing the firmware update
in order to:

- Make the mhi stack aware of the process and not to reset the
function during the update.
- Force a reset of the mhi stack at the end of the process in order to
detect the modem again.

This file should be used both when performing the update through the USB
composition 0x1055 (FN980 old hw revision) that through PCIe (both FN980
and FN990).

For PCIe the flow is the following:

- Disable runtime power management on the mhi pci device
- Write 1 to the fw_update sysfs file to races between
  the recovery work and other mhi operations
- Start the firmware update
- Write 0 to the fw_update sysfs file to reset the mhi stack

Firmware update requires also upstream commit
d651ce8("bus: mhi: core: Fix race while handling SYS_ERR at power up")

deepin-Intel-SIG: drivers: bus: mhi: let userspace manage xfp fw update states.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
deepin-Intel-SIG: wwan: add NMEA type.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
deepin-Intel-SIG: drivers: bus: mhi: add FN980 v2 support.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
deepin-Intel-SIG: drivers: bus: mhi: add FN990 NMEA and DIAG in SBL devices.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
Telit modem requires DTR to be set in virtual serial ports for
properly receiving unsolicited indications.

Add a simple WWAN driver for setting DTR and RTS at port opening
and removing at port closing (just AT channels).

deepin-Intel-SIG: drivers: net: wwan: add simple DTR driver.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
It could happen that when the modem reboots it is not immediately
able to cope with PCIe requests.

Add a delay in the recovery procedure as a safe guard.

deepin-Intel-SIG: drivers: bus: mhi: host: fix recovery process when modem reboots.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Wei Qiao <wei.qiao@intel.com>
@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 utsweetyfish 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 @pangqiao. 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.

@wqiao-intel wqiao-intel changed the title Add telit modems fn990 support add [Intel-SIG] [Meteor Lake] Add telit modems fn990 support Jan 29, 2024
@wqiao-intel wqiao-intel changed the title add [Intel-SIG] [Meteor Lake] Add telit modems fn990 support [Intel-SIG] [Meteor Lake] Add telit modems fn990 support Jan 29, 2024
@matrix-wsk matrix-wsk merged commit 0957833 into deepin-community:linux-6.6.y Jan 30, 2024
Avenger-285714 pushed a commit that referenced this pull request Sep 2, 2024
commit 9a2fa14 upstream.

copy_fd_bitmaps(new, old, count) is expected to copy the first
count/BITS_PER_LONG bits from old->full_fds_bits[] and fill
the rest with zeroes.  What it does is copying enough words
(BITS_TO_LONGS(count/BITS_PER_LONG)), then memsets the rest.
That works fine, *if* all bits past the cutoff point are
clear.  Otherwise we are risking garbage from the last word
we'd copied.

For most of the callers that is true - expand_fdtable() has
count equal to old->max_fds, so there's no open descriptors
past count, let alone fully occupied words in ->open_fds[],
which is what bits in ->full_fds_bits[] correspond to.

The other caller (dup_fd()) passes sane_fdtable_size(old_fdt, max_fds),
which is the smallest multiple of BITS_PER_LONG that covers all
opened descriptors below max_fds.  In the common case (copying on
fork()) max_fds is ~0U, so all opened descriptors will be below
it and we are fine, by the same reasons why the call in expand_fdtable()
is safe.

Unfortunately, there is a case where max_fds is less than that
and where we might, indeed, end up with junk in ->full_fds_bits[] -
close_range(from, to, CLOSE_RANGE_UNSHARE) with
	* descriptor table being currently shared
	* 'to' being above the current capacity of descriptor table
	* 'from' being just under some chunk of opened descriptors.
In that case we end up with observably wrong behaviour - e.g. spawn
a child with CLONE_FILES, get all descriptors in range 0..127 open,
then close_range(64, ~0U, CLOSE_RANGE_UNSHARE) and watch dup(0) ending
up with descriptor #128, despite #64 being observably not open.

The minimally invasive fix would be to deal with that in dup_fd().
If this proves to add measurable overhead, we can go that way, but
let's try to fix copy_fd_bitmaps() first.

* new helper: bitmap_copy_and_expand(to, from, bits_to_copy, size).
* make copy_fd_bitmaps() take the bitmap size in words, rather than
bits; it's 'count' argument is always a multiple of BITS_PER_LONG,
so we are not losing any information, and that way we can use the
same helper for all three bitmaps - compiler will see that count
is a multiple of BITS_PER_LONG for the large ones, so it'll generate
plain memcpy()+memset().

Reproducer added to tools/testing/selftests/core/close_range_test.c

Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Feb 22, 2025
[ Upstream commit 1ddee69 ]

Some of the platforms may connect the INT pin via inversion logic
effectively make the triggering to be active-low.
Remove explicit trigger flag to respect the settings from firmware.

Without this change even idling chip produces spurious interrupts
and kernel disables the line in the result:

  irq 33: nobody cared (try booting with the "irqpoll" option)
  CPU: 0 UID: 0 PID: 125 Comm: irq/33-i2c-INT3 Not tainted 6.12.0-00236-g8b874ed11dae deepin-community#64
  Hardware name: Intel Corp. QUARK/Galileo, BIOS 0x01000900 01/01/2014
  ...
  handlers:
  [<86e86bea>] irq_default_primary_handler threaded [<d153e44a>] cy8c95x0_irq_handler [pinctrl_cy8c95x0]
  Disabling IRQ deepin-community#33

Fixes: e6cbbe4 ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/20250117142304.596106-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c5d46ae)
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Feb 23, 2025
[ Upstream commit 1ddee69 ]

Some of the platforms may connect the INT pin via inversion logic
effectively make the triggering to be active-low.
Remove explicit trigger flag to respect the settings from firmware.

Without this change even idling chip produces spurious interrupts
and kernel disables the line in the result:

  irq 33: nobody cared (try booting with the "irqpoll" option)
  CPU: 0 UID: 0 PID: 125 Comm: irq/33-i2c-INT3 Not tainted 6.12.0-00236-g8b874ed11dae deepin-community#64
  Hardware name: Intel Corp. QUARK/Galileo, BIOS 0x01000900 01/01/2014
  ...
  handlers:
  [<86e86bea>] irq_default_primary_handler threaded [<d153e44a>] cy8c95x0_irq_handler [pinctrl_cy8c95x0]
  Disabling IRQ deepin-community#33

Fixes: e6cbbe4 ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/20250117142304.596106-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c5d46ae)
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Feb 26, 2025
[ Upstream commit 1ddee69 ]

Some of the platforms may connect the INT pin via inversion logic
effectively make the triggering to be active-low.
Remove explicit trigger flag to respect the settings from firmware.

Without this change even idling chip produces spurious interrupts
and kernel disables the line in the result:

  irq 33: nobody cared (try booting with the "irqpoll" option)
  CPU: 0 UID: 0 PID: 125 Comm: irq/33-i2c-INT3 Not tainted 6.12.0-00236-g8b874ed11dae deepin-community#64
  Hardware name: Intel Corp. QUARK/Galileo, BIOS 0x01000900 01/01/2014
  ...
  handlers:
  [<86e86bea>] irq_default_primary_handler threaded [<d153e44a>] cy8c95x0_irq_handler [pinctrl_cy8c95x0]
  Disabling IRQ deepin-community#33

Fixes: e6cbbe4 ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/20250117142304.596106-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c5d46ae)
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Feb 26, 2025
[ Upstream commit 1ddee69 ]

Some of the platforms may connect the INT pin via inversion logic
effectively make the triggering to be active-low.
Remove explicit trigger flag to respect the settings from firmware.

Without this change even idling chip produces spurious interrupts
and kernel disables the line in the result:

  irq 33: nobody cared (try booting with the "irqpoll" option)
  CPU: 0 UID: 0 PID: 125 Comm: irq/33-i2c-INT3 Not tainted 6.12.0-00236-g8b874ed11dae deepin-community#64
  Hardware name: Intel Corp. QUARK/Galileo, BIOS 0x01000900 01/01/2014
  ...
  handlers:
  [<86e86bea>] irq_default_primary_handler threaded [<d153e44a>] cy8c95x0_irq_handler [pinctrl_cy8c95x0]
  Disabling IRQ deepin-community#33

Fixes: e6cbbe4 ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/20250117142304.596106-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c5d46ae)
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Feb 28, 2025
[ Upstream commit 1ddee69 ]

Some of the platforms may connect the INT pin via inversion logic
effectively make the triggering to be active-low.
Remove explicit trigger flag to respect the settings from firmware.

Without this change even idling chip produces spurious interrupts
and kernel disables the line in the result:

  irq 33: nobody cared (try booting with the "irqpoll" option)
  CPU: 0 UID: 0 PID: 125 Comm: irq/33-i2c-INT3 Not tainted 6.12.0-00236-g8b874ed11dae deepin-community#64
  Hardware name: Intel Corp. QUARK/Galileo, BIOS 0x01000900 01/01/2014
  ...
  handlers:
  [<86e86bea>] irq_default_primary_handler threaded [<d153e44a>] cy8c95x0_irq_handler [pinctrl_cy8c95x0]
  Disabling IRQ deepin-community#33

Fixes: e6cbbe4 ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/20250117142304.596106-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c5d46ae)
opsiff pushed a commit that referenced this pull request Mar 1, 2025
[ Upstream commit 1ddee69 ]

Some of the platforms may connect the INT pin via inversion logic
effectively make the triggering to be active-low.
Remove explicit trigger flag to respect the settings from firmware.

Without this change even idling chip produces spurious interrupts
and kernel disables the line in the result:

  irq 33: nobody cared (try booting with the "irqpoll" option)
  CPU: 0 UID: 0 PID: 125 Comm: irq/33-i2c-INT3 Not tainted 6.12.0-00236-g8b874ed11dae #64
  Hardware name: Intel Corp. QUARK/Galileo, BIOS 0x01000900 01/01/2014
  ...
  handlers:
  [<86e86bea>] irq_default_primary_handler threaded [<d153e44a>] cy8c95x0_irq_handler [pinctrl_cy8c95x0]
  Disabling IRQ #33

Fixes: e6cbbe4 ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/20250117142304.596106-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c5d46ae)
@Avenger-285714
Copy link
Member

@sourcery-ai review

Copy link

@Copilot 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 adds support for Telit FN990 modems by introducing new WWAN ports, a dedicated DTR control driver, and extending the MHI host framework with flashing state management and updated channel/PCI configurations.

  • Added WWAN port types SAHARA and NMEA, plus wwan_port_get_type().
  • Implemented a new mhi_wwan_dtr driver and integrated DTR/RTS handling into the control driver.
  • Extended MHI host (xfp flashing states, health‐check logic, channel configs, PCI IDs).

Reviewed Changes

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

Show a summary per file
File Description
include/linux/wwan.h New port types and wwan_port_get_type() prototype
include/linux/mhi.h Added xfp_state enum and config field
drivers/net/wwan/wwan_core.c Implemented wwan_port_get_type()
drivers/net/wwan/mhi_wwan_dtr.c New MHI WWAN DTR driver
drivers/net/wwan/mhi_wwan_ctrl.c Integrated DTR calls based on port type
drivers/net/wwan/Makefile Added mhi_wwan_dtr.o to build
drivers/net/wwan/Kconfig Added MHI_WWAN_DTR config entry
drivers/bus/mhi/host/pm.c Consider SBL in power‐up logic
drivers/bus/mhi/host/pci_generic.c Updated health period; new channel macros & configs
drivers/bus/mhi/host/main.c Track IP_CTRL device reference
drivers/bus/mhi/host/internal.h Extended MHI_POWER_UP_CAPABLE macro
drivers/bus/mhi/host/init.c Exposed fw_update sysfs attribute
Comments suppressed due to low confidence (5)

include/linux/wwan.h:150

  • [nitpick] The doc comment for wwan_port_get_type lacks a @return description. Add a brief description of the return value.
enum wwan_port_type wwan_port_get_type(struct wwan_port *port);

drivers/net/wwan/mhi_wwan_dtr.c:38

  • alloc_skb() return value is not checked; if allocation fails, skb will be NULL and subsequent operations will dereference it. Add a NULL check and handle the error.
		skb = alloc_skb(sizeof(dtr_msg), GFP_KERNEL);

drivers/net/wwan/mhi_wwan_dtr.c:48

  • The function always returns 0, swallowing any error from mhi_queue_skb. Consider returning ret when non-zero to propagate failures.
	return 0;

drivers/net/wwan/mhi_wwan_ctrl.c:107

  • struct wwan_port is used but <linux/wwan.h> is not included in this file, leading to an undefined type error. Add #include <linux/wwan.h> at the top.
int mhi_wwan_dtr_set(struct wwan_port *port, int dtr, int rts);

drivers/bus/mhi/host/pci_generic.c:24

  • [nitpick] Reducing the health-check interval from 2 seconds to 0.5 seconds may increase CPU wakeups and overhead. Verify that this frequency is necessary.
#define HEALTH_CHECK_PERIOD (HZ / 2)

Copy link

sourcery-ai bot commented Jul 9, 2025

Reviewer's Guide

This pull request adds support for Telit FN990 and FN980 V2 modems by extending PCI channel/event configurations and device tables, introduces firmware flashing state management via an xfp state and sysfs interface, refines power‐up logic to handle SBL execution environments, and implements WWAN DTR/RTS control through a new MHI WWAN DTR driver and port‐type enhancements.

Sequence diagram for DTR/RTS control via mhi_wwan_dtr_set

sequenceDiagram
    participant User as actor User
    participant WWAN as wwan_port
    participant DTR as mhi_wwan_dtr_set
    participant MHIWWAN as mhi_wwan_dev
    participant MHI as mhi_device
    participant CNTRL as mhi_controller
    participant IP_CTRL as mhi_device (IP_CTRL)

    User->>WWAN: Start AT port
    WWAN->>DTR: mhi_wwan_dtr_set(port, 1, 1)
    DTR->>MHIWWAN: wwan_port_get_drvdata(port)
    MHIWWAN->>MHI: access mhi_dev
    MHI->>CNTRL: access mhi_cntrl
    CNTRL->>IP_CTRL: check mhi_dev_ip_ctrl
    DTR->>IP_CTRL: mhi_queue_skb(..., DTR/RTS msg)
    Note right of IP_CTRL: DTR/RTS message sent to modem
Loading

ER diagram for new and updated PCI device and channel/event configurations

erDiagram
    MHI_PCI_DEV_INFO ||--o{ MHI_CONTROLLER_CONFIG : config
    MHI_CONTROLLER_CONFIG ||--o{ MHI_CHANNEL_CONFIG : ch_cfg
    MHI_CONTROLLER_CONFIG ||--o{ MHI_EVENT_CONFIG : event_cfg
    MHI_PCI_DEV_INFO {
        string name
        string fw
        string edl
        int bar_num
        int dma_data_width
        int mru_default
        bool sideband_wake
    }
    MHI_CONTROLLER_CONFIG {
        int max_channels
        int timeout_ms
        int num_channels
        int num_events
    }
    MHI_CHANNEL_CONFIG {
        int num
        string name
        int num_elements
        int event_ring
    }
    MHI_EVENT_CONFIG {
        int id
        int num_elements
        int data_size
        int hw_id
    }
Loading

Class diagram for new and updated MHI controller and WWAN structures

classDiagram
    class mhi_controller {
        +struct device *cntrl_dev
        +struct mhi_device *mhi_dev
        +struct dentry *debugfs_dentry
        +struct mhi_device *mhi_dev_ip_ctrl
        +void __iomem *regs
        +void __iomem *bhi
        +void __iomem *bhie
        +bool wake_set
        +unsigned long irq_flags
        +u32 mru
        +enum xfp_state xfp
    }
    class mhi_controller_config {
        +bool m2_no_db
    }
    class mhi_pci_dev_info {
        +const char *name
        +const char *fw
        +const char *edl
        +const struct mhi_controller_config *config
        +int bar_num
        +int dma_data_width
        +int mru_default
        +bool sideband_wake
    }
    class mhi_channel_config {
        +int num
        +const char *name
        +int num_elements
        +int event_ring
        +enum dma_data_direction dir
        +u32 ee_mask
        +int pollcfg
        +int doorbell
        +bool lpm_notify
        +bool offload_channel
        +bool doorbell_mode_switch
    }
    class mhi_event_config {
        +int id
        +int num_elements
        +int data_size
        +int hw_id
    }
    class mhi_device {
        +struct mhi_controller *mhi_cntrl
        +int ul_chan_id
        +struct device dev
    }
    class mhi_wwan_dev {
        +struct mhi_device *mhi_dev
    }
    class wwan_port {
        +enum wwan_port_type type
    }
    class wwan_port_type {
        <<enum>>
        WWAN_PORT_QMI
        WWAN_PORT_QCDM
        WWAN_PORT_FIREHOSE
        WWAN_PORT_XMMRPC
        WWAN_PORT_SAHARA
        WWAN_PORT_NMEA
    }
    class xfp_state {
        <<enum>>
        XFP_STATE_IDLE
        XFP_STATE_FLASHING
        XFP_STATE_NEED_RESET
    }
    mhi_controller o-- mhi_device
    mhi_device o-- mhi_wwan_dev
    wwan_port --> wwan_port_type
    mhi_controller --> xfp_state
Loading

Class diagram for new MHI WWAN DTR driver

classDiagram
    class mhi_wwan_dev {
        +struct mhi_device *mhi_dev
    }
    class mhi_device {
        +struct mhi_controller *mhi_cntrl
        +int ul_chan_id
        +struct device dev
    }
    class wwan_port {
        +enum wwan_port_type type
    }
    mhi_wwan_dev o-- mhi_device
    wwan_port --> mhi_wwan_dev : get_drvdata(port)
    mhi_device o-- mhi_controller
Loading

File-Level Changes

Change Details Files
Support for Telit FN980 V2 and FN990 modems
  • Introduced AMSS/SBL UL and DL channel configuration macros
  • Defined channel, event, and controller config structs for FN980 V2
  • Updated FN990 channel list to use new macros and added IP_CTRL and NMEA channels
  • Modified PCI ID table to register Telit FN980 V2 and FN990 entries
  • Added debug logs and a 40 s msleep in recovery flow
drivers/bus/mhi/host/pci_generic.c
Firmware flashing state added via xfp and sysfs interface
  • Defined enum xfp_state and added xfp field in mhi_controller and config
  • Implemented fw_update sysfs show/store handlers and registered DEVICE_ATTR_RW
  • Hooked health_check timer to defer or trigger recovery based on XFP_STATE_FLASHING/NEED_RESET
drivers/bus/mhi/host/init.c
drivers/bus/mhi/host/pci_generic.c
include/linux/mhi.h
Refine MHI power‐up sequence to include SBL stage
  • Extended POWER_UP_CAPABLE macro to consider MHI_EE_SBL
  • Adjusted pm_sync_power_up to treat SBL as successful mission mode
  • Updated wait_event condition in mhi_sync_power_up to include ee==SBL
drivers/bus/mhi/host/pm.c
drivers/bus/mhi/host/internal.h
Implement WWAN DTR/RTS control with new MHI WWAN DTR driver
  • Added new mhi_wwan_dtr.c driver and built it via Makefile entry
  • Declared and exported wwan_port_get_type and mhi_wwan_dtr_set
  • Updated mhi_wwan_ctrl to set/unset DTR and RTS on AT ports
  • Extended WWAN_PORT enum with SAHARA and NMEA and updated match tables
  • Tracked IP_CTRL device in main.c to reference for DTR transfers
drivers/net/wwan/mhi_wwan_dtr.c
drivers/net/wwan/Makefile
drivers/net/wwan/mhi_wwan_ctrl.c
drivers/net/wwan/wwan_core.c
include/linux/wwan.h
drivers/bus/mhi/host/main.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

@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 @wqiao-intel - I've reviewed your changes - here's some feedback:

  • The 40 s msleep in mhi_pci_recovery_work will block the system_long_wq workqueue thread—consider using a delayed work or timer instead of a long blocking sleep.
  • The new fw_update sysfs attribute is always writable and unvalidated—you should specify appropriate file permissions and validate input values before changing the controller state.
  • You’ve added CONFIG_MHI_WWAN_DTR in the Makefile but didn’t provide a corresponding Kconfig entry—add a Kconfig definition so the new DTR driver can be enabled properly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The 40 s msleep in mhi_pci_recovery_work will block the system_long_wq workqueue thread—consider using a delayed work or timer instead of a long blocking sleep.
- The new fw_update sysfs attribute is always writable and unvalidated—you should specify appropriate file permissions and validate input values before changing the controller state.
- You’ve added CONFIG_MHI_WWAN_DTR in the Makefile but didn’t provide a corresponding Kconfig entry—add a Kconfig definition so the new DTR driver can be enabled properly.

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.

opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Oct 9, 2025
[ Upstream commit 528eb4e19ec0df30d0c9ae4074ce945667dde919 ]

When igc_led_setup() fails, igc_probe() fails and triggers kernel panic
in free_netdev() since unregister_netdev() is not called. [1]
This behavior can be tested using fault-injection framework, especially
the failslab feature. [2]

Since LED support is not mandatory, treat LED setup failures as
non-fatal and continue probe with a warning message, consequently
avoiding the kernel panic.

[1]
 kernel BUG at net/core/dev.c:12047!
 Oops: invalid opcode: 0000 [#1] SMP NOPTI
 CPU: 0 UID: 0 PID: 937 Comm: repro-igc-led-e Not tainted 6.17.0-rc4-enjuk-tnguy-00865-gc4940196ab02 deepin-community#64 PREEMPT(voluntary)
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
 RIP: 0010:free_netdev+0x278/0x2b0
 [...]
 Call Trace:
  <TASK>
  igc_probe+0x370/0x910
  local_pci_probe+0x3a/0x80
  pci_device_probe+0xd1/0x200
 [...]

[2]
 #!/bin/bash -ex

 FAILSLAB_PATH=/sys/kernel/debug/failslab/
 DEVICE=0000:00:05.0
 START_ADDR=$(grep " igc_led_setup" /proc/kallsyms \
         | awk '{printf("0x%s", $1)}')
 END_ADDR=$(printf "0x%x" $((START_ADDR + 0x100)))

 echo $START_ADDR > $FAILSLAB_PATH/require-start
 echo $END_ADDR > $FAILSLAB_PATH/require-end
 echo 1 > $FAILSLAB_PATH/times
 echo 100 > $FAILSLAB_PATH/probability
 echo N > $FAILSLAB_PATH/ignore-gfp-wait

 echo $DEVICE > /sys/bus/pci/drivers/igc/bind

Fixes: ea57870 ("igc: Add support for LEDs on i225/i226")
Signed-off-by: Kohei Enju <enjuk@amazon.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Vitaly Lifshits <vitaly.lifshits@intel.com>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Tested-by: Mor Bar-Gabay <morx.bar.gabay@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit bec504867acc7315de9cd96ef9161fa52a25abe8)
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.

5 participants