100 Commits
Author SHA1 Message Date
Jennifer Berringer 41616099a8 tpm_ffa_crb: access tpm service over FF-A direct message request v2
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit a85b55ee64a5da58c6e2c69e2648023189210eae
Author: Yeoreum Yun <yeoreum.yun@arm.com>
Date:   Tue, 15 Apr 2025 19:50:12 +0100

    tpm_ffa_crb: access tpm service over FF-A direct message request v2

    For secure partition with multi service, tpm_ffa_crb can access tpm
    service with direct message request v2 interface according to chapter 3.3,
    TPM Service Command Response Buffer Interface Over FF-A specificationi v1.0 BET.

    This patch reflects this spec to access tpm service over
    FF-A direct message request v2 ABI.

    Acked-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-19 13:59:35 -04:00
Jennifer Berringer b8fcbdf742 hwmon: spd5118: Add I3C support
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit 9cd3db0cda4741befa6de8af94eb371b9ec6d057
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:53 +0000

    hwmon: spd5118: Add I3C support

    Add a regmap config and a probe function to support I3C-based
    communication with SPD5118 devices.

    On an I3C bus, SPD5118 devices are enumerated via SETAASA and always
    require an ACPI or device tree entry. Device matching is hence through
    the OF match tables only and does not need an I3C class match table. The
    device identity is verified in the type registers before proceeding to
    the common probe function.

    Acked-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-12-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:06 -04:00
Jennifer Berringer 58a66d6af1 hwmon: spd5118: Remove 16-bit addressing
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit 7bf5a11dde2c957bf6751f6ba28fef66e848ac6d
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:52 +0000

    hwmon: spd5118: Remove 16-bit addressing

    The intent of introducing 16-bit addressing was to support I3C, but it
    turns out that I3C does not require reading the Legacy Mode register,
    nor any specific encoding for page translation. The testing of 16-bit
    code was limited and there are no known users for this feature. Remove
    the sections that support 16-bit addressing and prepare the driver to
    support I3C appropriately.

    Suggested-by: Guenter Roeck <linux@roeck-us.net>
    Acked-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-11-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:06 -04:00
Jennifer Berringer ee21e7ef71 i3c: dw-i3c-master: Add ACPI ID for Tegra410
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit 97d7cfb62a215ed5c64c6e7772545be4afab167f
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:51 +0000

    i3c: dw-i3c-master: Add ACPI ID for Tegra410

    Update variable names to generic names and add Tegra410 ACPI ID to
    support the I3C controller in Tegra410, which is a DesignWare I3C host
    controller.

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-10-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:06 -04:00
Jennifer Berringer ceabcd2bce i3c: dw-i3c-master: Add ACPI core clock frequency quirk
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit 0fd9549975b5b8186a78b654e02518113cc2ac93
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:50 +0000

    i3c: dw-i3c-master: Add ACPI core clock frequency quirk

    Some ACPI-enumerated devices like Tegra410 do not expose the controller
    core clock through the clk framework. Unlike device tree, ACPI on Arm does
    not model clock providers. The hardware is expected to have its clocks
    enabled by firmware before the OS takes over.

    Make the core clock optional and allow selected ACPI devices to provide the
    core clock rate through the "clock-frequency" _DSD property when the core
    clock is absent.

    Resolve device quirks before acquiring the core clock so platforms without
    the ACPI skip-clock quirk still fail probe immediately when the clock is
    missing, before any MMIO access.

    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-9-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 2ad09a58c9 i3c: dw-i3c-master: Add SETAASA as supported CCC
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit fc6963aad560aebeb926e677aa26746c42c6223b
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:49 +0000

    i3c: dw-i3c-master: Add SETAASA as supported CCC

    Add SETAASA and SETHID to the supported list of CCC commands for
    DesignWare I3C host controller.

    SETAASA is a broadcast command that assigns predefined static addresses
    to all I3C devices on the bus.

    SETHID is to stop HID bit flipping by the SPD Hub to which the SPD devices
    are connected. It is a prerequisite command to be sent before SETAASA as
    recommended by JESD300-5 and JESD403 sideband bus specifications.

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-8-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 0f0debfd0c i3c: master: match I3C device through DT and ACPI
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit 3456baa2110c1fa31e7609ace50117346b99c3d4
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:48 +0000

    i3c: master: match I3C device through DT and ACPI

    SETAASA-based devices cannot always be identified by PID or DCR; the
    standard I3C id_table matching may not be applicable. Allow such devices to
    match through Device Tree or ACPI.

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-7-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 9f1efe5d60 i3c: master: Add support for devices without PID
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit a1dd42fb82fa71bf4cb6462b4803b55d844c1286
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:47 +0000

    i3c: master: Add support for devices without PID

    Devices using SETAASA for address assignment are not required to have
    a 48-bit PID according to the I3C specification. Allow such devices to
    register and use the static address where PID was required.

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-6-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 1489e051e4 i3c: master: Add support for devices using SETAASA
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit bbaf8733b84846897d2d3b997ce650dd2d2539a4
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:46 +0000

    i3c: master: Add support for devices using SETAASA

    Add support for devices using SETAASA, such as SPD5118 and SPD5108
    attached to DDR5 memory modules that do not support ENTDAA. Follow the
    guidelines proposed by the MIPI Discovery and Configuration
    Specification [1] for discovering such devices.

    SETAASA (Set All Addresses to Static Address) differs from standard I3C
    address assignment that uses ENTDAA or SETDASA to assign dynamic
    addresses. Devices using SETAASA assign their pre-defined static addresses
    as their dynamic addresses during DAA, and it is not mandatory for these
    devices to implement standard CCC commands like GETPID, GETDCR, or GETBCR.
    For such devices, it is generally recommended to issue SETHID (specified
    by JEDEC JESD300) as a prerequisite for SETAASA to stop HID bit flipping.

    [1] https://www.mipi.org/mipi-disco-for-i3c-download

    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://www.mipi.org/mipi-disco-for-i3c-download
    Link: https://patch.msgid.link/20260728065955.809445-5-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer a6c09fcb56 i3c: master: Support ACPI enumeration of child devices
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit b46a4b3c5d1e312e74e5364a04c283a5c88e0916
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:45 +0000

    i3c: master: Support ACPI enumeration of child devices

    Although the existing subsystem allows host controllers to register
    through the ACPI table, it was not possible to describe I3C or I2C
    devices when using ACPI. This is because the driver relied on the reg
    property to retrieve the PID, static address, etc., whereas ACPI uses
    _ADR or serial resources to describe such devices.

    Read _ADR and LVR from ACPI resources and extract the data as per the
    ACPI specification for an I3C bus. Also read mipi-i3c-static-address as
    per the MIPI DISCO specifications [1] to get the static address to be
    used.

    Enable describing I3C or I2C devices in the ACPI table. This is required
    if the device uses a static address or if it needs device-specific
    properties.

    [1] https://www.mipi.org/mipi-disco-for-i3c-download

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-4-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer aaf658672f i3c: master: Use unified device property interface
JIRA: https://issues.redhat.com/browse/RHEL-143335
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit ee170021bee17124c13f42813607bca553a6b48a
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:44 +0000

    i3c: master: Use unified device property interface

    Replace all OF-specific functions with unified device property functions
    as a prerequisite to support both ACPI and device tree.

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-3-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 7ec4b64028 dt-bindings: i3c: Add mipi-i3c-static-method to support SETAASA
JIRA: https://issues.redhat.com/browse/RHEL-143335

Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git

commit 81e7c27b0d5cb3029fc01374c3a96019d3a9e673
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Tue, 28 Jul 2026 06:59:43 +0000

    dt-bindings: i3c: Add mipi-i3c-static-method to support SETAASA

    Add the 'mipi-i3c-static-method' property mentioned in the MIPI I3C
    Discovery and Configuration Specification [1] to specify which discovery
    method an I3C device supports during bus initialization. The property is
    a bitmap, where a bit value of 1 indicates support for that method, and 0
    indicates lack of support.

    Bit 0: SETDASA CCC (Direct)
    Bit 1: SETAASA CCC (Broadcast)
    Bit 2: Other CCC (vendor / standards extension)
    All other bits are reserved.

    It is specifically needed when an I3C device requires SETAASA for the
    address assignment. SETDASA will be supported by default if this property
    is absent, which means for now the property just serves as a flag to
    enable SETAASA, but keep the property as a bitmap to align with the
    specifications.

    [1] https://www.mipi.org/mipi-disco-for-i3c-download

    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
    Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
    Link: https://patch.msgid.link/20260728065955.809445-2-akhilrajeev@nvidia.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer c08289dcab i3c: master: Expose the APIs to support I3C hub
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 8d8afa428318a623aa674c3f90550475ad3e6ccd
Author: Aman Kumar Pandey <aman.kumarpandey@nxp.com>
Date:   Fri, 12 Jun 2026 16:48:09 +0530

    i3c: master: Expose the APIs to support I3C hub

    Change the below internal static functions to APIs to allow new I3C hub
    driver to use them

    1) i3c_dev_enable_ibi_locked()
    2) i3c_dev_disable_ibi_locked()
    3) i3c_dev_request_ibi_locked()
    4) i3c_dev_free_ibi_locked()
    5) i3c_master_reattach_i3c_dev_locked()

    Signed-off-by: Aman Kumar Pandey <aman.kumarpandey@nxp.com>
    Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260612111816.3688240-3-lakshay.piplani@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 38e3244288 i3c: master: rename i3c_master_reattach_i3c_dev() to *_locked
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 79c41666b397df9218b6e7555663b298a88e2b56
Author: Lakshay Piplani <lakshay.piplani@nxp.com>
Date:   Fri, 12 Jun 2026 16:48:08 +0530

    i3c: master: rename i3c_master_reattach_i3c_dev() to *_locked

    Rename i3c_master_reattach_i3c_dev() to *_locked() to make the locking
    requirement explicit and consistent with other I3C core helpers that
    require the bus lock to be held by the caller.

    Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260612111816.3688240-2-lakshay.piplani@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 7d7b4a4d12 i3c: master: Use unsigned int for dev_nack_retry_count consistently
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 225b76e2a711dc061ec337befba49dd3ee75e534
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue, 16 Jun 2026 14:37:52 +0300

    i3c: master: Use unsigned int for dev_nack_retry_count consistently

    Use unsigned int for dev_nack_retry_count across the core and
    controller drivers to match the type of master->dev_nack_retry_count.

    Update the sysfs store path to use kstrtouint() and adjust the
     ->set_dev_nack_retry() callback prototype and callers accordingly.

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260616113752.196140-4-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer 0e802b930b i3c: master: Add missing runtime PM get in dev_nack_retry_count_store()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 79ce29e100ab3de0cad66eb48d32a7de4043e2ae
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue, 16 Jun 2026 14:37:51 +0300

    i3c: master: Add missing runtime PM get in dev_nack_retry_count_store()

    Ensure the device is runtime resumed while updating the retry
    configuration to avoid accessing the controller while suspended.

    Call i3c_master_rpm_get() before accessing the controller in
    dev_nack_retry_count_store() and release it with
    i3c_master_rpm_put() afterwards.

    Fixes: 990c149c61ee4 ("i3c: master: Introduce optional Runtime PM support")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260616113752.196140-3-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:05 -04:00
Jennifer Berringer ac9673b446 i3c: master: Update dev_nack_retry_count under maintenance lock
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit ab5f9c5cb527c03790a92142ad368881a9100aaf
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue, 16 Jun 2026 14:37:50 +0300

    i3c: master: Update dev_nack_retry_count under maintenance lock

    Protect master->dev_nack_retry_count against concurrent sysfs updates
    by updating it while holding the bus maintenance lock.

    Consequently, combine adjacent return statements into one.

    For consistency, read dev_nack_retry_count while holding the bus normaluse
    lock.

    Fixes: b58f47eb39268 ("i3c: add sysfs entry and attribute for Device NACK Retry count")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260616113752.196140-2-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 0a42f8ced2 i3c: master: Prevent reuse of dynamic address on device add failure
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit b3ba8383da4d0cff15810e32ea785eceb0a80813
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Fri, 12 Jun 2026 11:01:03 +0300

    i3c: master: Prevent reuse of dynamic address on device add failure

    i3c_master_add_i3c_dev_locked() is called after a device has already
    been assigned a dynamic address.  If the function fails, the address
    remains marked as free and may be reallocated to another device,
    leading to address conflicts on the bus.

    Ensure the address is not marked as free on failure, by updating the
    address slot state to prevent the address from being re-used.

    Emit an error message to inform of the failure.

    Opportunistically remove the !master check because it is impossible.

    Note, directly resetting the device's dynamic address is no longer
    an option, since Direct RSTDAA was deprecated from I3C starting from
    version 1.1 and v1.1 (or later) target devices are meant to NACK it.

    Fixes: 3a379bbcea ("i3c: Add core I3C infrastructure")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260612080107.11606-4-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer e04b9e077d i3c: master: Serialize i3c_set_hotjoin() with the maintenance lock
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 5b130aadc36b6a935b90937dcd67b8ed4ba57831
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Mon, 8 Jun 2026 08:43:06 +0300

    i3c: master: Serialize i3c_set_hotjoin() with the maintenance lock

    i3c_set_hotjoin() dispatches the controller's enable_hotjoin() or
    disable_hotjoin() op and updates master->hotjoin under
    i3c_bus_normaluse_lock(). That lock is a read-side acquisition of
    bus->lock (down_read()), so it does not exclude concurrent callers.

    The hotjoin sysfs attribute can be opened multiple times, and writes
    through different opens are not serialized.  Two concurrent writers
    to "hotjoin" can therefore race in i3c_set_hotjoin(), with the
    controller op and the master->hotjoin store from one call interleaving
    with the other.  The hardware enable/disable state and the value reported
    by hotjoin_show() can end up out of sync.

    Take i3c_bus_maintenance_lock() instead. Toggling Hot Join enable
    changes bus state and is conceptually a maintenance operation, so the
    write-side acquisition of bus->lock is the appropriate lock and
    serializes concurrent callers against each other and against other
    maintenance operations.

    Fixes: 317bacf960 ("i3c: master: add enable(disable) hot join in sys entry")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260608054312.10604-3-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 65532db16d i3c: master: Make hot-join workqueue freezable to block hot-join during suspend
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 527756cb9ebb277dca12fff00af9fbb3b9ec8cc8
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Mon, 8 Jun 2026 08:43:05 +0300

    i3c: master: Make hot-join workqueue freezable to block hot-join during suspend

    The I3C master workqueue (master->wq) is used to defer work that needs
    thread context and the bus maintenance lock, most notably Hot Join
    processing (which calls i3c_master_do_daa() to assign dynamic addresses
    to newly joined devices).

    Currently the workqueue keeps running across system suspend, which can
    race with the suspend path:

     - do_daa() may execute after the controller has been suspended,
       issuing bus transactions on a powered-down or otherwise unusable
       controller.
     - New I3C devices can be enumerated and added to the bus mid-suspend,
       registering driver model objects at a point where the I3C subsystem
       and its consumers are not prepared to handle them.

    Mark the workqueue WQ_FREEZABLE so its workers are frozen for the
    duration of system suspend/hibernate and resumed afterwards. This
    naturally defers any pending or newly queued Hot Join work until the
    system (and the controller) is fully resumed, closing both races
    without adding explicit suspend/resume synchronization in the master
    drivers.

    Update the kerneldoc for struct i3c_master_controller::wq to reflect
    that the workqueue is freezable.

    Fixes: 3a379bbcea ("i3c: Add core I3C infrastructure")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260608054312.10604-2-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer ece7a87e29 i3c: dw-i3c-master: Fix IBI count register selection for versalnet
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 1d78a8fc97c133b8aee54993a83f86b68ed2fdb8
Author: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
Date:   Wed, 1 Apr 2026 14:14:30 +0530

    i3c: dw-i3c-master: Fix IBI count register selection for versalnet

    On DesignWare I3C controllers where IC_HAS_IBI_DATA=0 (such as versalnet),
    the IBI_STS_CNT field (bits [28:24] of QUEUE_STATUS_LEVEL) is hardwired
    to 0. The IBI status entry count is instead reported via IBI_BUF_BLR
    (bits [23:16] of the same register).

    irq_handle_ibis() was unconditionally reading IBI_STS_CNT, causing it to
    always see 0 pending IBIs on versalnet and return early without draining
    the IBI buffer. Since INTR_IBI_THLD_STAT is level-triggered against the
    buffer fill level, this left the interrupt permanently asserted.

    Detect IBI data capability at probe time by writing the IBI data threshold
    field in QUEUE_THLD_CTRL and reading it back. Use the result to select the
    correct register field in irq_handle_ibis().

    Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
    Link: https://patch.msgid.link/20260401084430.436059-1-shubhrajyoti.datta@amd.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer bfafafa82d i3c: dw: Simplify xfer cleanup with __free(kfree)
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 6105f49196158f3e27143444651c9ca9439ac8d4
Author: Felix Gu <ustc.gu@gmail.com>
Date:   Sat, 4 Apr 2026 18:32:31 +0800

    i3c: dw: Simplify xfer cleanup with __free(kfree)

    Convert dw-i3c-master to use __free(kfree) guards for struct dw_i3c_xfer
    allocations. This frees xfer objects automatically on scope exit, and
    removes the now-unused dw_i3c_master_free_xfer() helper.

    Signed-off-by: Felix Gu <ustc.gu@gmail.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260404-dw-i3c-2-v3-2-8f7d146549c1@gmail.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer dbd3aed69a i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 256cc1f1305a8e5dcadf8ca208d04a3acadd26f1
Author: Felix Gu <ustc.gu@gmail.com>
Date:   Sat, 4 Apr 2026 18:32:30 +0800

    i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()

    The dw_i3c_master_i3c_xfers() function allocates memory for the xfer
    structure using dw_i3c_master_alloc_xfer(). If pm_runtime_resume_and_get()
    fails, the function returns without freeing the allocated xfer, resulting
    in a memory leak.

    Since dw_i3c_master_free_xfer() is a thin wrapper around kfree(), use
    the __free(kfree) cleanup attribute to handle the free automatically on
    all exit paths.

    Fixes: 62fe9d06f5 ("i3c: dw: Add power management support")
    Signed-off-by: Felix Gu <ustc.gu@gmail.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260404-dw-i3c-2-v3-1-8f7d146549c1@gmail.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 4cf061f58f i3c: master: dw-i3c: Fix missing reset assertion in remove() callback
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit bef1eef667186cedb0bc6d152464acb3c97d5f72
Author: Felix Gu <ustc.gu@gmail.com>
Date:   Fri, 20 Mar 2026 22:18:02 +0800

    i3c: master: dw-i3c: Fix missing reset assertion in remove() callback

    The reset line acquired during probe is currently left deasserted when
    the driver is unbound.

    Switch to devm_reset_control_get_optional_exclusive_deasserted() to
    ensure the reset is automatically re-asserted by the devres core when
    the driver is removed.

    Fixes: 62fe9d06f5 ("i3c: dw: Add power management support")
    Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Felix Gu <ustc.gu@gmail.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260320-dw-i3c-v3-1-477040c2e3f5@gmail.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 1edb2c8fec i3c: fix missing newline in dev_err messages
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit acfcdff920dcab2b71536f04684e92c7933f7f40
Author: haoyu.lu <hechushiguitu666@gmail.com>
Date:   Tue, 17 Mar 2026 11:40:15 +0800

    i3c: fix missing newline in dev_err messages

    Add missing newline to dev_err messages in:
    - drivers/i3c/master.c
    - drivers/i3c/master/svc-i3c-master.c

    Signed-off-by: haoyu.lu <hechushiguitu666@gmail.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://patch.msgid.link/20260317034015.638-1-hechushiguitu666@gmail.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 29457622b8 i3c: master: Add sysfs option to rescan bus via entdaa
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 8ea0b60bc00d86b5ce33837487f4d16ae212f70a
Author: David Nyström <david.nystrom@est.tech>
Date:   Thu, 19 Feb 2026 21:58:03 +0100

    i3c: master: Add sysfs option to rescan bus via entdaa

    Allow userspace to request dynamic address assignment, which is
    useful for i3cdev devices with broken hot-join support.
    This will assign dynamic addresses to all devices on the I3C bus
    which are currently unassigned.

    Signed-off-by: David Nyström <david.nystrom@est.tech>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Meagan Lloyd <meaganlloyd@linux.microsoft.com>
    Link: https://patch.msgid.link/20260219-i3c_rescan-v6-1-b81d6cc3cb30@est.tech
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 80a35325e9 i3c: master: use kzalloc_flex
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 7f53c556c207600a9cd26798687f2df1c1c1dce2
Author: Rosen Penev <rosenp@gmail.com>
Date:   Wed, 11 Mar 2026 17:15:34 -0700

    i3c: master: use kzalloc_flex

    Simplifies allocations by using a flexible array member in this struct.

    Add __counted_by to get extra runtime analysis.

    Signed-off-by: Rosen Penev <rosenp@gmail.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260312001534.24423-1-rosenp@gmail.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 4108bb5d7b i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit f311a05784634febd299f03476b80f3f18489767
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Fri, 13 Feb 2026 14:00:48 +0800

    i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach

    The DesignWare I3C master controller ACKs IBIs as soon as a valid
    Device Address Table (DAT) entry is present. This can create a race
    between device attachment (after DAA) and the point where the client
    driver enables IBIs via i3c_device_enable_ibi().

    Set DEV_ADDR_TABLE_SIR_REJECT in the DAT entry during
    attach_i3c_dev() and reattach_i3c_dev() so that IBIs are rejected
    by default. The bit is managed thereafter by the existing
    dw_i3c_master_set_sir_enabled() function, which clears it in
    enable_ibi() after ENEC is issued, and restores it in disable_ibi()
    after DISEC.

    Fixes: 1dd728f5d4 ("i3c: master: Add driver for Synopsys DesignWare IP")
    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/53f5b8cbdd8af789ec38b95b02873f32f9182dd6.1770962368.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:04 -04:00
Jennifer Berringer 60426be6a0 i3c: master: dw-i3c: Fix missing of_node for virtual I2C adapter
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit f26ecaa0f0abfe5db173416214098a00d3b7db79
Author: Peter Yin <peteryin.openbmc@gmail.com>
Date:   Mon, 2 Mar 2026 15:56:42 +0800

    i3c: master: dw-i3c: Fix missing of_node for virtual I2C adapter

    The DesignWare I3C master driver creates a virtual I2C adapter to
    provide backward compatibility with I2C devices. However, the current
    implementation does not associate this virtual adapter with any
    Device Tree node.

    Propagate the of_node from the I3C master platform device to the
    virtual I2C adapter's device structure. This ensures that standard
    I2C aliases are correctly resolved and bus numbering remains consistent.

    Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260302075645.1492766-1-peteryin.openbmc@gmail.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer 8cf75580b6 i3c: master: Convert more 'alloc_obj' cases to default GFP_KERNEL arguments
JIRA: https://issues.redhat.com/browse/RHEL-143335

Only the hunk affecting i3c/master.c is included.

commit 32a92f8c89326985e05dce8b22d3f0aa07a3e1bd
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sat Feb 21 20:03:00 2026 -0800

    Convert more 'alloc_obj' cases to default GFP_KERNEL arguments

    This converts some of the visually simpler cases that have been split
    over multiple lines.  I only did the ones that are easy to verify the
    resulting diff by having just that final GFP_KERNEL argument on the next
    line.

    Somebody should probably do a proper coccinelle script for this, but for
    me the trivial script actually resulted in an assertion failure in the
    middle of the script.  I probably had made it a bit _too_ trivial.

    So after fighting that far a while I decided to just do some of the
    syntactically simpler cases with variations of the previous 'sed'
    scripts.

    The more syntactically complex multi-line cases would mostly really want
    whitespace cleanup anyway.

    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer 830222a7f9 i3c: master: Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
JIRA: https://issues.redhat.com/browse/RHEL-143335

Filter the upstream treewide commit to only include the hunks affecting
i3c master.

commit bf4afc53b77aeaa48b5409da5c8da6bb4eff7f43
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sat Feb 21 16:37:42 2026 -0800

    Convert 'alloc_obj' family to use the new default GFP_KERNEL argument

    This was done entirely with mindless brute force, using

        git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' |
            xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/'

    to convert the new alloc_obj() users that had a simple GFP_KERNEL
    argument to just drop that argument.

    Note that due to the extreme simplicity of the scripting, any slightly
    more complex cases spread over multiple lines would not be triggered:
    they definitely exist, but this covers the vast bulk of the cases, and
    the resulting diff is also then easier to check automatically.

    For the same reason the 'flex' versions will be done as a separate
    conversion.

    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer e2b9a5e772 i3c: master: Replace kmalloc with kmalloc_obj for non-scalar types
JIRA: https://issues.redhat.com/browse/RHEL-143335

The upstream commit is treewide but this is filtered to only include the
hunks affecting i3c master.

commit 69050f8d6d075dc01af7a5f2f550a8067510366f
Author: Kees Cook <kees@kernel.org>
Date:   Fri Feb 20 23:49:23 2026 -0800

    treewide: Replace kmalloc with kmalloc_obj for non-scalar types

    This is the result of running the Coccinelle script from
    scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
    avoid scalar types (which need careful case-by-case checking), and
    instead replace kmalloc-family calls that allocate struct or union
    object instances:

    Single allocations:     kmalloc(sizeof(TYPE), ...)
    are replaced with:      kmalloc_obj(TYPE, ...)

    Array allocations:      kmalloc_array(COUNT, sizeof(TYPE), ...)
    are replaced with:      kmalloc_objs(TYPE, COUNT, ...)

    Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...)
    are replaced with:      kmalloc_flex(*PTR, FAM, COUNT, ...)

    (where TYPE may also be *VAR)

    The resulting allocations no longer return "void *", instead returning
    "TYPE *".

    Signed-off-by: Kees Cook <kees@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer 09b9f69235 i3c: dw-i3c-master: fix SIR reject bit mapping for dynamic addresses
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit ed318b3fb4ab317c533d38d160326fa5d7569497
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Tue, 27 Jan 2026 10:05:07 +0800

    i3c: dw-i3c-master: fix SIR reject bit mapping for dynamic addresses

    The IBI_SIR_REQ_REJECT register is a 32-bit bitmap indexed by the
    dynamic address of each I3C slave. The DesignWare controller derives
    the bit index by folding the 7-bit dynamic address into a 5-bit value,
    using the sum of the lower 5 bits and the upper 2 bits, modulo 32.

    The current implementation incorrectly uses the device table index
    when updating the SIR reject mask, which can result in rejecting or
    accepting IBIs for the wrong device.

    Compute the SIR reject bit index directly from the dynamic address,
    as defined by the controller specification, and use it consistently
    when updating the reject mask.

    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/d4ad8161e604156c60327060ad3d339ebf18fe4f.1769479330.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer 57affae68b i3c: dw-i3c-master: convert spinlock usage to scoped guards
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit c7311aa4a71ebbf6e86e3173e04afbad233a3937
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Tue, 27 Jan 2026 10:05:06 +0800

    i3c: dw-i3c-master: convert spinlock usage to scoped guards

    Convert dw-i3c-master to use scoped spinlock guards in place of
    open-coded spin_lock_irqsave()/spin_unlock_irqrestore() pairs to ensure
    locks are always safely released on scope exit.

    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/79020c006c15dda9d057946530f16cfb4650d450.1769479330.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer ffb1df8fae i3c: dw: Fix memory leak in dw_i3c_master_i2c_xfers()
JIRA: https://issues.redhat.com/browse/RHEL-143335
CVE: CVE-2026-45863

commit 2537089413514caaa9a5fdeeac3a34d45100f747
Author: Zilin Guan <zilin@seu.edu.cn>
Date:   Mon, 26 Jan 2026 08:11:21 +0000

    i3c: dw: Fix memory leak in dw_i3c_master_i2c_xfers()

    The dw_i3c_master_i2c_xfers() function allocates memory for the xfer
    structure using dw_i3c_master_alloc_xfer(). If pm_runtime_resume_and_get()
    fails, the function returns without freeing the allocated xfer, resulting
    in a memory leak.

    Add a dw_i3c_master_free_xfer() call to the error path to ensure the
    allocated memory is properly freed.

    Compile tested only. Issue found using a prototype static analysis tool
    and code review.

    Fixes: 62fe9d06f5 ("i3c: dw: Add power management support")
    Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260126081121.644099-1-zilin@seu.edu.cn
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer b78d21f057 i3c: master: Add i3c_master_do_daa_ext() for post-hibernation address recovery
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit c481ef12e713fb7c292d04f53b3532ac0804ab3d
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Fri, 23 Jan 2026 08:33:23 +0200

    i3c: master: Add i3c_master_do_daa_ext() for post-hibernation address recovery

    After system hibernation, I3C Dynamic Addresses may be reassigned at boot
    and no longer match the values recorded before suspend. Introduce
    i3c_master_do_daa_ext() to handle this situation.

    The restore procedure is straightforward: issue a Reset Dynamic Address
    Assignment (RSTDAA), then run the standard DAA sequence. The existing DAA
    logic already supports detecting and updating devices whose dynamic
    addresses differ from previously known values.

    Refactor the DAA path by introducing a shared helper used by both the
    normal i3c_master_do_daa() path and the new extended restore function,
    and correct the kernel-doc in the process.

    Export i3c_master_do_daa_ext() so that master drivers can invoke it from
    their PM restore callbacks.

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260123063325.8210-2-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer c773476873 i3c: dw: Initialize spinlock to avoid upsetting lockdep
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit b58eaa4761ab02fc38c39d674a6bcdd55e00f388
Author: Fredrik Markstrom <fredrik.markstrom@est.tech>
Date:   Fri, 16 Jan 2026 15:29:42 +0100

    i3c: dw: Initialize spinlock to avoid upsetting lockdep

    The devs_lock spinlock introduced when adding support for ibi:s was
    never initialized.

    Fixes: e389b1d72a ("i3c: dw: Add support for in-band interrupts")
    Suggested-by: Jani Nurminen <jani.nurminen@windriver.com>
    Signed-off-by: Fredrik Markstrom <fredrik.markstrom@est.tech>
    Reviewed-by: Ivar Holmqvist <ivar.holmqvist@est.tech>
    Link: https://patch.msgid.link/20260116-i3c_dw_initialize_spinlock-v3-1-cf707b6ed75f@est.tech
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer bc2a536e8d i3c: master: Introduce optional Runtime PM support
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 990c149c61ee45da4fb6372e6b2fdd9808414e7a
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue, 13 Jan 2026 09:27:00 +0200

    i3c: master: Introduce optional Runtime PM support

    Master drivers currently manage Runtime PM individually, but all require
    runtime resume for bus operations.  This can be centralized in common code.

    Add optional Runtime PM support to ensure the parent device is runtime
    resumed before bus operations and auto-suspended afterward.

    Notably, do not call ->bus_cleanup() if runtime resume fails.  Master
    drivers that opt-in to core runtime PM support must take that into account.

    Also provide an option to allow IBIs and hot-joins while runtime suspended.

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260113072702.16268-20-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer 70668ca0ac i3c: master: Replace WARN_ON() with dev_err() in i3c_dev_free_ibi_locked()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 471895799c2f46688792e175ced936ffeb6cdf01
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue, 13 Jan 2026 09:26:45 +0200

    i3c: master: Replace WARN_ON() with dev_err() in i3c_dev_free_ibi_locked()

    IBI disable failures are not indicative of a software bug, so using
    WARN_ON() is not appropriate.  Replace these warnings with dev_err().

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260113072702.16268-5-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer 864bdacd8e i3c: master: Update hot-join flag only on success
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit f0775157b9f9a28ae3eabc8d05b0bc52e8056c80
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue, 13 Jan 2026 09:26:44 +0200

    i3c: master: Update hot-join flag only on success

    To prevent inconsistent state when an error occurs, ensure the hot-join
    flag is updated only when enabling or disabling hot-join succeeds.

    Fixes: 317bacf960 ("i3c: master: add enable(disable) hot join in sys entry")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20260113072702.16268-4-adrian.hunter@intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:03 -04:00
Jennifer Berringer a175010574 i3c: dw: Preserve DAT entry bits when restoring addresses
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit de28e002df2e2d44138174a158883e703e216a06
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Fri, 12 Dec 2025 17:02:58 +0800

    i3c: dw: Preserve DAT entry bits when restoring addresses

    Update dw_i3c_master_restore_addrs() to preserve existing bits in each
    Device Address Table (DAT) entry when restoring addresses. This prevents
    overwriting configuration bits during PM runtime resumes.

    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/46112c0da44110f46709cb0e7a4595e312b95c10.1765529948.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer c982ae7de5 i3c: dw: use FIELD_PREP for device address table macros
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 4cd9d2bf0b56f98347ca1046e4d8acea95bd7ffa
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Fri, 12 Dec 2025 17:02:57 +0800

    i3c: dw: use FIELD_PREP for device address table macros

    Add DEV_ADDR_TABLE_DYNAMIC_MASK / DEV_ADDR_TABLE_DYNAMIC_ADDR(x) for
    dynamic device addresses and DEV_ADDR_TABLE_STATIC_MASK /
    DEV_ADDR_TABLE_STATIC_ADDR(x) for static device addresses in the I3C
    address table. Replace manual shift-and-mask with FIELD_PREP() for both
    dynamic and static addresses for clarity and maintainability.

    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/d72896e510db1870d26a794f131f600c7e42cf00.1765529948.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer c242064720 i3c: dw: Add support for Device NACK Retry configuration
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit ec17f14309481318df4af2a0c7f2aa7da9e7ebcb
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Fri, 12 Dec 2025 17:02:56 +0800

    i3c: dw: Add support for Device NACK Retry configuration

    The DesignWare I3C controller supports automatically retrying transactions
    when a device NACKs. This is useful for slave devices that may be
    temporarily busy and not ready to respond immediately.

    Add new ops to configure all active DAT entry with dev_nack_retry during
    runtime. Returns error when value exceeds hw specified limit.

    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/f09ee67e61d31f0a12a0bf48f01e9057ca9e2fb7.1765529948.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer fb0d99a9ea i3c: add sysfs entry and attribute for Device NACK Retry count
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit b58f47eb392680d4c6626c8b3b1fcf6412a0a02c
Author: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Date:   Fri, 12 Dec 2025 17:02:55 +0800

    i3c: add sysfs entry and attribute for Device NACK Retry count

    Document sysfs attribute dev_nack_retry_cnt that controls the number of
    automatic retries performed by the I3C controller when a target device
    returns a NACK

    Add a `dev_nack_retry_count` sysfs attribute to allow reading and updating
    the device NACK retry count. A new `dev_nack_retry_count` field and an
    optional `set_dev_nack_retry()` callback are added to
    i3c_master_controller. The attribute is created only when the callback is
    implemented.

    Updates are applied under the I3C bus maintenance lock to ensure safe
    hardware reconfiguration.

    Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/3c4b5082bde64024fc383c44bebeef89ad3c7ed3.1765529948.git.adrianhoyin.ng@altera.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 50bd4f5a6c i3c: master: Fix confusing cleanup.h syntax
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit cc3b18f9fedec517e35b973d14670a37290f133c
Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Date:   Mon, 8 Dec 2025 03:07:51 +0100

    i3c: master: Fix confusing cleanup.h syntax

    Initializing automatic __free variables to NULL without need (e.g.
    branches with different allocations), followed by actual allocation is
    in contrary to explicit coding rules guiding cleanup.h:

    "Given that the "__free(...) = NULL" pattern for variables defined at
    the top of the function poses this potential interdependency problem the
    recommendation is to always define and assign variables in one statement
    and not group variable definitions at the top of the function when
    __free() is used."

    Code does not have a bug, but is less readable and uses discouraged
    coding practice, so fix that by moving declaration to the place of
    assignment.

    Not that other existing usage of __free() in this context is a corret
    exception initialized to NULL, because the actual allocation is branched
    in if().

    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
    Link: https://patch.msgid.link/20251208020750.4727-3-krzysztof.kozlowski@oss.qualcomm.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 29fd4b13f1 i3c: master: cleanup callback .priv_xfers()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 41b80d43d9a00a302b5559baa7ebafc28dd54793
Author: Frank Li <Frank.Li@nxp.com>
Date:   Wed, 3 Dec 2025 15:45:51 -0500

    i3c: master: cleanup callback .priv_xfers()

    Remove the .priv_xfers() callback from the framework after all master
    controller drivers have switched to use the new .i3c_xfers() callback.

    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
    Link: https://patch.msgid.link/20251203-i3c_xfer_cleanup_master-v2-2-7dd94d04ee2d@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 702b603e18 i3c: master: switch to use new callback .i3c_xfers() from .priv_xfers()
JIRA: https://issues.redhat.com/browse/RHEL-143335

Conflicts: i3c/master/adi-i3c-master.c i3c/master/renesas-i3c.c
    Dropped hunks for these files which do not exist in this tree.

commit eaa0870387f9ecbd2992ca58e73f3c7768815e8b
Author: Frank Li <Frank.Li@nxp.com>
Date:   Wed, 3 Dec 2025 15:45:50 -0500

    i3c: master: switch to use new callback .i3c_xfers() from .priv_xfers()

    Switch to use the new .i3c_xfers() callback, which supports all I3C
    transfer modes (SDR and HDR). Also replace struct i3c_priv_xfer with the
    new struct i3c_xfer, as i3c_priv_xfer is now an alias of i3c_xfer.

    No functional changes.

    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
    Link: https://patch.msgid.link/20251203-i3c_xfer_cleanup_master-v2-1-7dd94d04ee2d@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 31a4ced757 i3c: document i3c_xfers
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit e01a8baf60af43f6f87a5850dee29cf31377ec25
Author: Alexandre Belloni <alexandre.belloni@bootlin.com>
Date:   Tue, 2 Dec 2025 16:38:03 +0100

    i3c: document i3c_xfers

    i3c_xfers was left undocumented, document it.

    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Link: https://patch.msgid.link/20251202153804.2640623-2-alexandre.belloni@bootlin.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer c8c9499dbd i3c: master: svc: Add basic HDR mode support
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 4e7263b87ca362825beeac669dcbe24aae2c6257
Author: Frank Li <Frank.Li@nxp.com>
Date:   Thu, 6 Nov 2025 12:36:03 -0500

    i3c: master: svc: Add basic HDR mode support

    Add basic HDR mode support for the svs I3C master driver.

    Only support for private transfers and does not support sending CCC
    commands in HDR mode.

    Key differences:
    - HDR uses commands (0x00-0x7F for write, 0x80-0xFF for read) to
    distinguish transfer direction.
    - HDR read/write commands must be written to FIFO before issuing the I3C
    address command. The hardware automatically sends the standard CCC command
    to enter HDR mode.
    - HDR exit pattern must be sent instead of send a stop after transfer
    completion.
    - Read/write data size must be an even number.

    Co-developed-by: Carlos Song <carlos.song@nxp.com>
    Signed-off-by: Carlos Song <carlos.song@nxp.com>
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20251106-i3c_ddr-v11-4-33a6a66ed095@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 4f70f149a4 i3c: master: svc: Replace bool rnw with union for HDR support
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 108420fe2100b0c9cfb2d3598681eab3724247b9
Author: Frank Li <Frank.Li@nxp.com>
Date:   Thu, 6 Nov 2025 12:36:02 -0500

    i3c: master: svc: Replace bool rnw with union for HDR support

    Replace the bool rnw field with a union in preparation for adding HDR
    support. HDR uses a cmd field instead of the rnw bit to indicate read or
    write direction.

    Add helper function svc_cmd_is_read() to check transfer direction.

    Add a local variable 'rnw' in svc_i3c_master_priv_xfers() to avoid
    repeatedly accessing xfers[i].rnw.

    No functional change.

    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20251106-i3c_ddr-v11-3-33a6a66ed095@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 04f984e232 i3c: Switch to use new i3c_xfer from i3c_priv_xfer
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 9280b6ebbf08e53734d34f3bb325c37cddc1422d
Author: Frank Li <Frank.Li@nxp.com>
Date:   Thu, 6 Nov 2025 12:36:01 -0500

    i3c: Switch to use new i3c_xfer from i3c_priv_xfer

    Switch to use i3c_xfer instead of i3c_priv_xfer because framework update to
    support HDR mode. i3c_priv_xfer is now an alias of i3c_xfer.

    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20251106-i3c_ddr-v11-2-33a6a66ed095@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer df610a9b2c i3c: Add HDR API support
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 256a21743d911f94ce92fe28f793cd586f3860b2
Author: Frank Li <Frank.Li@nxp.com>
Date:   Thu, 6 Nov 2025 12:36:00 -0500

    i3c: Add HDR API support

    Rename struct i3c_priv_xfer to struct i3c_xfer, since private xfer in the
    I3C spec refers only to SDR transfers. Ref: i3c spec ver1.2, section 3,
    Technical Overview.

    i3c_xfer will be used for both SDR and HDR.

    Rename enum i3c_hdr_mode to i3c_xfer_mode. Previous definition need match
    CCC GET_CAP1 bit position. Use 31 as SDR transfer mode.

    Add i3c_device_do_xfers() with an xfer mode argument, while keeping
    i3c_device_do_priv_xfers() as a wrapper that calls i3c_device_do_xfers()
    with I3C_SDR for backward compatibility.

    Introduce a 'cmd' field in struct i3c_xfer as an anonymous union with
    'rnw', since HDR mode uses read/write commands instead of the SDR address
    bit.

    Add .i3c_xfers() callback for master controllers. If not implemented, fall
    back to SDR with .priv_xfers(). The .priv_xfers() API can be removed once
    all controllers switch to .i3c_xfers().

    Add 'mode_mask' bitmask to advertise controller capability.

    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://patch.msgid.link/20251106-i3c_ddr-v11-1-33a6a66ed095@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:02 -04:00
Jennifer Berringer 7e15281cc1 i3c: mipi-i3c-hci: Use core helpers for DMA mapping and bounce buffering
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 1c46bfc4f75e7d43261af65b64e7d3dc4a30daa9
Author: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Date:   Fri, 22 Aug 2025 13:56:28 +0300

    i3c: mipi-i3c-hci: Use core helpers for DMA mapping and bounce buffering

    So far only I3C private and I2C transfers have required a bounce buffer
    for DMA transfers when buffer is not DMA'able.

    It was observed that when the device DMA is IOMMU mapped and the receive
    length is not a multiple of DWORDs (32-bit), the last DWORD is padded
    with stale data from the RX FIFO, corrupting 1-3 bytes beyond the
    expected data.

    A similar issue, though less severe, occurs when an I3C target returns
    less data than requested. In this case, the padding does not exceed the
    requested number of bytes, assuming the device DMA is not IOMMU mapped.

    Therefore, all I3C private transfer, CCC command payload and I2C
    transfer receive buffers must be properly sized for the DMA being IOMMU
    mapped. Even if those buffers are already DMA safe, their size may not
    be DWORD aligned.

    To prepare for the device DMA being IOMMU mapped and to address the
    above issue, use helpers from I3C core for DMA mapping and bounce
    buffering for all DMA transfers.

    For now, require bounce buffer only when the buffer is in the
    vmalloc() area to avoid unnecessary copying with CCC commands and
    DMA-safe I2C transfers.

    Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250822105630.2820009-3-jarkko.nikula@linux.intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer ad8ed3a276 i3c: master: svc: skip address resend on repeat START
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 12cbd157344848b1bd726ecadce27532d79b785a
Author: Frank Li <Frank.Li@nxp.com>
Date:   Tue, 29 Apr 2025 01:42:34 -0400

    i3c: master: svc: skip address resend on repeat START

    According to the I3C specification, address arbitration only happens during
    the START. Repeated START do not initiate arbitration, and In-Band
    Interrupts (IBIs) cannot occur at this stage.

    Resending the address upon a NACK in a repeat START is therefore redundant
    and unnecessary. Avoid redundant retries, improving efficiency and ensuring
    protocol compliance.

    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/r/20250429054234.4013929-1-Frank.Li@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer 480d79be68 i3c: master: add WQ_PERCPU to alloc_workqueue users
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit de53ad6ca49e5d73bba72d24b49ec5d40f33ee01
Author: Marco Crivellari <marco.crivellari@suse.com>
Date:   Fri, 7 Nov 2025 14:29:49 +0100

    i3c: master: add WQ_PERCPU to alloc_workqueue users

    Currently if a user enqueues a work item using schedule_delayed_work() the
    used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
    WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
    schedule_work() that is using system_wq and queue_work(), that makes use
    again of WORK_CPU_UNBOUND.
    This lack of consistency cannot be addressed without refactoring the API.

    alloc_workqueue() treats all queues as per-CPU by default, while unbound
    workqueues must opt-in via WQ_UNBOUND.

    This default is suboptimal: most workloads benefit from unbound queues,
    allowing the scheduler to place worker threads where they’re needed and
    reducing noise when CPUs are isolated.

    This continues the effort to refactor workqueue APIs, which began with
    the introduction of new workqueues and a new alloc_workqueue flag in:

    commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
    commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

    This change adds a new WQ_PERCPU flag to explicitly request
    alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified.

    With the introduction of the WQ_PERCPU flag (equivalent to !WQ_UNBOUND),
    any alloc_workqueue() caller that doesn’t explicitly specify WQ_UNBOUND
    must now use WQ_PERCPU.

    Once migration is complete, WQ_UNBOUND can be removed and unbound will
    become the implicit default.

    Suggested-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
    Link: https://patch.msgid.link/20251107132949.184944-1-marco.crivellari@suse.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer f7e7031584 i3c: master: Remove i3c_device_free_ibi from i3c_device_remove
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 5b9481a4157198b93cd6a5e7ad2603682202149d
Author: Jorge Marques <jorge.marques@analog.com>
Date:   Wed, 12 Nov 2025 22:30:00 +0100

    i3c: master: Remove i3c_device_free_ibi from i3c_device_remove

    i3c_device_disable_ibi should be called before i3c_device_free_ibi,
    however, a driver using devm actions cannot yield the call before the
    bus_type.remove(), requiring to use a .remove method that is usually
    discouraged for drivers that uses resources already manage. Since the
    only consumer mctp-i3c.c of this method calls both
    i3c_device_disable_ibi then i3c_device_free_ibi, remove the call from
    the i3c_device_remove (bus_type.remove()).

    Signed-off-by: Jorge Marques <jorge.marques@analog.com>
    Link: https://patch.msgid.link/20251112-ibi-unsafe-v1-1-d8454db22613@analog.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer 4e8be6e41c i3c: fix big-endian FIFO transfers
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit d6ddd9beb1a5c32acb9b80f5c2cd8b17f41371d1
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed, 24 Sep 2025 22:18:33 +0200

    i3c: fix big-endian FIFO transfers

    Short MMIO transfers that are not a multiple of four bytes in size need
    a special case for the final bytes, however the existing implementation
    is not endian-safe and introduces an incorrect byteswap on big-endian
    kernels.

    This usually does not cause problems because most systems are
    little-endian and most transfers are multiple of four bytes long, but
    still needs to be fixed to avoid the extra byteswap.

    Change the special case for both i3c_writel_fifo() and i3c_readl_fifo()
    to use non-byteswapping writesl() and readsl() with a single element
    instead of the byteswapping writel()/readl() that are meant for individual
    MMIO registers. As data is copied between a FIFO and a memory buffer,
    the writesl()/readsl() loops are typically based on __raw_readl()/
    __raw_writel(), resulting in the order of bytes in the FIFO to match
    the order in the buffer, regardless of the CPU endianess.

    The earlier versions in the dw-i3c and i3c-master-cdns had a correct
    implementation, but the generic version that was recently added broke it.

    Fixes: 733b439375b4 ("i3c: master: Add inline i3c_readl_fifo() and i3c_writel_fifo()")
    Cc: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Reviewed-by: Jorge Marques <jorge.marques@analog.com>
    Link: https://lore.kernel.org/r/20250924201837.3691486-1-arnd@kernel.org
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer e6e9361f74 i3c: Remove superfluous FIXME
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 649764145b70a0328fc020fe31fc80594761a707
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Tue, 23 Sep 2025 22:35:58 +0200

    i3c: Remove superfluous FIXME

    I2C adapters can already change timeout and retry parameters via IOCTL.
    This allows for better tuning to workloads compared to per-adapter
    defaults. So, the FIXME is not needed.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250923203557.18298-2-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer 2138b45e55 i3c: Fix default I2C adapter timeout value
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 9395b3c412933401a34845d5326afe4011bbd40f
Author: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Date:   Fri, 5 Sep 2025 13:03:20 +0300

    i3c: Fix default I2C adapter timeout value

    Commit 3a379bbcea ("i3c: Add core I3C infrastructure") set the default
    adapter timeout for I2C transfers as 1000 (ms). However that parameter
    is defined in jiffies not in milliseconds.

    With mipi-i3c-hci driver this wasn't visible until commit c0a90eb55a69
    ("i3c: mipi-i3c-hci: use adapter timeout value for I2C transfers").

    Fix this by setting the default timeout as HZ (CONFIG_HZ) not 1000.

    Fixes: 1b84691e7870 ("i3c: dw: use adapter timeout value for I2C transfers")
    Fixes: be27ed672878 ("i3c: master: cdns: use adapter timeout value for I2C transfers")
    Fixes: c0a90eb55a69 ("i3c: mipi-i3c-hci: use adapter timeout value for I2C transfers")
    Fixes: a747e01adad2 ("i3c: master: svc: use adapter timeout value for I2C transfers")
    Fixes: d028219a9f14 ("i3c: master: Add basic driver for the Renesas I3C controller")
    Fixes: 3a379bbcea ("i3c: Add core I3C infrastructure")
    Cc: stable@vger.kernel.org # 6.17
    Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Link: https://lore.kernel.org/r/20250905100320.954536-1-jarkko.nikula@linux.intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer 19b1d48c73 i3c: master: Add helpers for DMA mapping and bounce buffer handling
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit f8d9e56aeb87ce82ce8636cd176cc59b69aa0e41
Author: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Date:   Fri, 22 Aug 2025 13:56:27 +0300

    i3c: master: Add helpers for DMA mapping and bounce buffer handling

    Some I3C controllers such as MIPI I3C HCI may pad the last DWORD (32-bit)
    with stale data from the RX FIFO in DMA transfers if the receive length
    is not DWORD aligned and when the device DMA is IOMMU mapped.

    In such a case, a properly sized bounce buffer is required in order to
    avoid possible data corruption. In a review discussion, proposal was to
    have a common helpers in I3C core for DMA mapping and bounce buffer
    handling.

    Drivers may use the helper i3c_master_dma_map_single() to map a buffer
    for a DMA transfer. It internally allocates a bounce buffer if buffer is
    not DMA'able or when the driver requires it for a transfer.

    Helper i3c_master_dma_unmap_single() does the needed cleanups and
    data copying from the bounce buffer.

    Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250822105630.2820009-2-jarkko.nikula@linux.intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer dbc541491b i3c: add missing include to internal header
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 3b661ca549b9e5bb11d0bc97ada6110aac3282d2
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Thu, 17 Jul 2025 14:00:47 +0200

    i3c: add missing include to internal header

    LKP found a random config which failed to build because IO accessors
    were not defined:

       In file included from drivers/i3c/master.c:21:
       drivers/i3c/internals.h: In function 'i3c_writel_fifo':
    >> drivers/i3c/internals.h:35:9: error: implicit declaration of function 'writesl' [-Werror=implicit-function-declaration]

    Add the proper header to where the IO accessors are used.

    Reported-by: kernel test robot <lkp@intel.com>
    Closes: https://lore.kernel.org/oe-kbuild-all/202507150208.BZDzzJ5E-lkp@intel.com/
    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250717120046.9022-2-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer b9bef4130c i3c: dw: Remove redundant pm_runtime_mark_last_busy() calls
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 5fa62d4ec49a26c5ce747d6b0c205d6b30396bbc
Author: Sakari Ailus <sakari.ailus@linux.intel.com>
Date:   Fri, 4 Jul 2025 10:54:17 +0300

    i3c: dw: Remove redundant pm_runtime_mark_last_busy() calls

    pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(),
    pm_runtime_autosuspend() and pm_request_autosuspend() now include a call
    to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to
    pm_runtime_mark_last_busy().

    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Link: https://lore.kernel.org/r/20250704075417.3218742-1-sakari.ailus@linux.intel.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer 8138873233 i3c: Add more parameters for controllers to the header
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 8acf1f3bae1ea48949458b67d68a72a95c3244a4
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Thu, 24 Jul 2025 11:41:41 +0200

    i3c: Add more parameters for controllers to the header

    Add standard timing value definition from specification.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250724094146.6443-3-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer ca45939003 i3c: Standardize defines for specification parameters
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 9c0609d685b27a0bb392390680207baa820ed118
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Thu, 24 Jul 2025 11:41:40 +0200

    i3c: Standardize defines for specification parameters

    Align existing defines to follow the consistent pattern:
    I3C_BUS_<PARAM>_<MAX|MIN|TYP>_<UNIT>. Prepare the codebase for adding
    new parameters and help avoid duplication.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250724094146.6443-2-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:01 -04:00
Jennifer Berringer 35cfdc9dbe i3c: master: cdns: Use i3c_writel_fifo() and i3c_readl_fifo()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit c20d3fa7049144f519b21616e6020e6939822145
Author: Jorge Marques <jorge.marques@analog.com>
Date:   Tue, 24 Jun 2025 11:06:05 +0200

    i3c: master: cdns: Use i3c_writel_fifo() and i3c_readl_fifo()

    Use common inline i3c_writel_fifo()/i3c_readl_fifo() methods to
    simplify code since the FIFO of controller is a 32bit width.

    Signed-off-by: Jorge Marques <jorge.marques@analog.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250624-i3c-writesl-readsl-v3-2-63ccf0870f01@analog.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer a28c085b33 i3c: master: dw: Use i3c_writel_fifo() and i3c_readl_fifo()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 6e055b1fb2fc72ad937fc75ac109fe904ce56003
Author: Jorge Marques <jorge.marques@analog.com>
Date:   Tue, 24 Jun 2025 11:06:06 +0200

    i3c: master: dw: Use i3c_writel_fifo() and i3c_readl_fifo()

    Use common inline i3c_writel_fifo()/i3c_readl_fifo() methods to
    simplify code since the FIFO of controller is a 32bit width.

    Signed-off-by: Jorge Marques <jorge.marques@analog.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250624-i3c-writesl-readsl-v3-3-63ccf0870f01@analog.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer fefc184298 i3c: master: Add inline i3c_readl_fifo() and i3c_writel_fifo()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 733b439375b494e8a6950ab47d18a4b615b73cb3
Author: Jorge Marques <jorge.marques@analog.com>
Date:   Tue, 24 Jun 2025 11:06:04 +0200

    i3c: master: Add inline i3c_readl_fifo() and i3c_writel_fifo()

    The I3C abstraction expects u8 buffers, but some controllers operate with
    a 32-bit bus width FIFO and cannot flag valid bytes individually. To avoid
    reading or writing outside the buffer bounds, use 32-bit accesses where
    possible and apply memcpy for any remaining bytes

    Signed-off-by: Jorge Marques <jorge.marques@analog.com>
    Suggested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250624-i3c-writesl-readsl-v3-1-63ccf0870f01@analog.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer 0a6b4defd8 i3c: prefix hexadecimal entries in sysfs
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 12aa3e0cb0c6f8d406be00bc9f5d89bfbee7b9d9
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Mon, 7 Jul 2025 13:54:08 +0200

    i3c: prefix hexadecimal entries in sysfs

    Hexadecimal values in sysfs should be prefixed with '0x' like e.g. PCI
    and SCSI already do it. Also ensure the two digit length since BCR and
    DCR are a byte in size.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250707115409.73545-2-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer 9288786653 i3c: dw: replace ENOTSUPP with SUSV4-compliant EOPNOTSUPP
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 566aebedee37789644bcc976fd6d98ccf8de375b
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Sat, 28 Jun 2025 21:20:29 +0200

    i3c: dw: replace ENOTSUPP with SUSV4-compliant EOPNOTSUPP

    Replace non-standard ENOTSUPP with the SUSV4-defined error code
    EOPNOTSUPP to fix below checkpatch warning:
      "ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP"

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250628192027.3932-7-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer 0dd1a1419d i3c: master: replace ENOTSUPP with SUSV4-compliant EOPNOTSUPP
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit d10a4c323883c41cf1b652309e61c48bce248e35
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Sat, 28 Jun 2025 21:20:28 +0200

    i3c: master: replace ENOTSUPP with SUSV4-compliant EOPNOTSUPP

    Replace non-standard ENOTSUPP with the SUSV4-defined error code
    EOPNOTSUPP to fix below checkpatch warning:
      "ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP"

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250628192027.3932-6-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer a754b1dc79 i3c: don't fail if GETHDRCAP is unsupported
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 447270cdb41b1c8c3621bb14b93a6749f942556e
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Fri, 4 Jul 2025 22:44:32 +0200

    i3c: don't fail if GETHDRCAP is unsupported

    'I3C_BCR_HDR_CAP' is still spec v1.0 and has been renamed to 'advanced
    capabilities' in v1.1 onwards. The ST pressure sensor LPS22DF does not
    have HDR, but has the 'advanced cap' bit set. The core still wants to
    get additional information using the CCC 'GETHDRCAP' (or GETCAPS in v1.1
    onwards). Not all controllers support this CCC and will notify the upper
    layers about it. For instantiating the device, we can ignore this
    unsupported CCC as standard communication will work. Without this patch,
    the device will not be instantiated at all.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250704204524.6124-1-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer 76680b75e6 i3c: master: Initialize ret in i3c_i2c_notifier_call()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 290ce8b2d0745e45a3155268184523a8c75996f1
Author: Jorge Marques <jorge.marques@analog.com>
Date:   Sun, 22 Jun 2025 12:11:07 +0200

    i3c: master: Initialize ret in i3c_i2c_notifier_call()

    Set ret to -EINVAL if i3c_i2c_notifier_call() receives an invalid
    action, resolving uninitialized warning.

    Signed-off-by: Jorge Marques <jorge.marques@analog.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250622-i3c-master-ret-uninitialized-v1-1-aabb5625c932@analog.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer b198493627 i3c: dw: use adapter timeout value for I2C transfers
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 1b84691e7870bc5b6a66a1e81abe0eae8359dfce
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Wed, 4 Jun 2025 12:18:27 +0200

    i3c: dw: use adapter timeout value for I2C transfers

    I2C adapters have their own timeout value which can be changed by
    userspace if desired. Use it for I2C transfers. The default is 1Hz, so
    the default behaviour is unchanged.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250604101831.56585-2-wsa+renesas@sang-engineering.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer ca744ae220 i3c: Add NULL pointer check in i3c_master_queue_ibi()
JIRA: https://issues.redhat.com/browse/RHEL-143335
CVE: CVE-2025-23147

commit bd496a44f041da9ef3afe14d1d6193d460424e91
Author: Manjunatha Venkatesh <manjunatha.venkatesh@nxp.com>
Date:   Wed, 26 Mar 2025 18:00:46 +0530

    i3c: Add NULL pointer check in i3c_master_queue_ibi()

    The I3C master driver may receive an IBI from a target device that has not
    been probed yet. In such cases, the master calls `i3c_master_queue_ibi()`
    to queue an IBI work task, leading to "Unable to handle kernel read from
    unreadable memory" and resulting in a kernel panic.

    Typical IBI handling flow:
    1. The I3C master scans target devices and probes their respective drivers.
    2. The target device driver calls `i3c_device_request_ibi()` to enable IBI
       and assigns `dev->ibi = ibi`.
    3. The I3C master receives an IBI from the target device and calls
       `i3c_master_queue_ibi()` to queue the target device driver’s IBI
       handler task.

    However, since target device events are asynchronous to the I3C probe
    sequence, step 3 may occur before step 2, causing `dev->ibi` to be `NULL`,
    leading to a kernel panic.

    Add a NULL pointer check in `i3c_master_queue_ibi()` to prevent accessing
    an uninitialized `dev->ibi`, ensuring stability.

    Fixes: 3a379bbcea ("i3c: Add core I3C infrastructure")
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/lkml/Z9gjGYudiYyl3bSe@lizhi-Precision-Tower-5810/
    Signed-off-by: Manjunatha Venkatesh <manjunatha.venkatesh@nxp.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20250326123047.2797946-1-manjunatha.venkatesh@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer a88317e57c i3c: mipi-i3c-hci: Use I2C DMA-safe api
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit effed5dac8f8b3db006c4971cdd592504afd1c5d
Author: Billy Tsai <billy_tsai@aspeedtech.com>
Date:   Tue, 4 Feb 2025 17:17:02 +0800

    i3c: mipi-i3c-hci: Use I2C DMA-safe api

    Use the i2c_get/put_dma_safe_msg_buf for I2C transfers instead of using
    the I3C-specific API.

    Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
    Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
    Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Link: https://lore.kernel.org/r/20250204091702.4014466-2-billy_tsai@aspeedtech.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 09:47:00 -04:00
Jennifer Berringer 6dd26ffbd8 i3c: Remove the const qualifier from i2c_msg pointer in i2c_xfers API
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 6866c91f8c2327546d850d5a85025fb81e2089bf
Author: Billy Tsai <billy_tsai@aspeedtech.com>
Date:   Tue, 4 Feb 2025 17:17:01 +0800

    i3c: Remove the const qualifier from i2c_msg pointer in i2c_xfers API

    The change is necessary to enable the use of the
    `i2c_get_dma_safe_msg_buf()` API, which requires a non-const
    `struct i2c_msg *` to operate. The `i2c_get_dma_safe_msg_buf()` function
    ensures safe handling of I2C messages when using DMA, making it essential
    for scenarios where DMA transfers are involved. By removing the `const`
    qualifier, this patch allows drivers to prepare and manage DMA-safe
    buffers directly.

    Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
    Link: https://lore.kernel.org/r/20250204091702.4014466-1-billy_tsai@aspeedtech.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 05:48:52 -04:00
Jennifer Berringer a772a483bf i3c: master: Fix missing 'ret' assignment in set_speed()
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit b266e0d4dac00eecdfaf50ec3f708fd0c3b39637
Author: Frank Li <Frank.Li@nxp.com>
Date:   Wed, 8 Jan 2025 17:55:33 -0500

    i3c: master: Fix missing 'ret' assignment in set_speed()

    Fix a probe failure in the i3c master driver that occurs when no i3c
    devices are connected to the bus.

    The issue arises in `i3c_master_bus_init()` where the `ret` value is not
    updated after calling `master->ops->set_speed()`. If no devices are
    present, `ret` remains set to `I3C_ERROR_M2`, causing the code to
    incorrectly proceed to `err_bus_cleanup`.

    Cc: stable@vger.kernel.org
    Fixes: aef79e189b ("i3c: master: support to adjust first broadcast address speed")
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/r/20250108225533.915334-1-Frank.Li@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 05:48:52 -04:00
Jennifer Berringer 996830163e i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock
JIRA: https://issues.redhat.com/browse/RHEL-143335
CVE: CVE-2024-43098

commit 6cf7b65f7029914dc0cd7db86fac9ee5159008c6
Author: Defa Li <defa.li@mediatek.com>
Date:   Thu, 7 Nov 2024 21:25:39 +0800

    i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock

    A deadlock may happen since the i3c_master_register() acquires
    &i3cbus->lock twice. See the log below.
    Use i3cdev->desc->info instead of calling i3c_device_info() to
    avoid acquiring the lock twice.

    v2:
      - Modified the title and commit message

    ============================================
    WARNING: possible recursive locking detected
    6.11.0-mainline
    --------------------------------------------
    init/1 is trying to acquire lock:
    f1ffff80a6a40dc0 (&i3cbus->lock){++++}-{3:3}, at: i3c_bus_normaluse_lock

    but task is already holding lock:
    f1ffff80a6a40dc0 (&i3cbus->lock){++++}-{3:3}, at: i3c_master_register

    other info that might help us debug this:
     Possible unsafe locking scenario:

           CPU0
           ----
      lock(&i3cbus->lock);
      lock(&i3cbus->lock);

     *** DEADLOCK ***

     May be due to missing lock nesting notation

    2 locks held by init/1:
     #0: fcffff809b6798f8 (&dev->mutex){....}-{3:3}, at: __driver_attach
     #1: f1ffff80a6a40dc0 (&i3cbus->lock){++++}-{3:3}, at: i3c_master_register

    stack backtrace:
    CPU: 6 UID: 0 PID: 1 Comm: init
    Call trace:
     dump_backtrace+0xfc/0x17c
     show_stack+0x18/0x28
     dump_stack_lvl+0x40/0xc0
     dump_stack+0x18/0x24
     print_deadlock_bug+0x388/0x390
     __lock_acquire+0x18bc/0x32ec
     lock_acquire+0x134/0x2b0
     down_read+0x50/0x19c
     i3c_bus_normaluse_lock+0x14/0x24
     i3c_device_get_info+0x24/0x58
     i3c_device_uevent+0x34/0xa4
     dev_uevent+0x310/0x384
     kobject_uevent_env+0x244/0x414
     kobject_uevent+0x14/0x20
     device_add+0x278/0x460
     device_register+0x20/0x34
     i3c_master_register_new_i3c_devs+0x78/0x154
     i3c_master_register+0x6a0/0x6d4
     mtk_i3c_master_probe+0x3b8/0x4d8
     platform_probe+0xa0/0xe0
     really_probe+0x114/0x454
     __driver_probe_device+0xa0/0x15c
     driver_probe_device+0x3c/0x1ac
     __driver_attach+0xc4/0x1f0
     bus_for_each_dev+0x104/0x160
     driver_attach+0x24/0x34
     bus_add_driver+0x14c/0x294
     driver_register+0x68/0x104
     __platform_driver_register+0x20/0x30
     init_module+0x20/0xfe4
     do_one_initcall+0x184/0x464
     do_init_module+0x58/0x1ec
     load_module+0xefc/0x10c8
     __arm64_sys_finit_module+0x238/0x33c
     invoke_syscall+0x58/0x10c
     el0_svc_common+0xa8/0xdc
     do_el0_svc+0x1c/0x28
     el0_svc+0x50/0xac
     el0t_64_sync_handler+0x70/0xbc
     el0t_64_sync+0x1a8/0x1ac

    Signed-off-by: Defa Li <defa.li@mediatek.com>
    Link: https://lore.kernel.org/r/20241107132549.25439-1-defa.li@mediatek.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 05:48:34 -04:00
Jennifer Berringer 0f616c1129 i3c: Document I3C_ADDR_SLOT_EXT_STATUS_MASK
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit f6ca73063754950bf3fbad753e3a9557e3aa85e3
Author: Alexandre Belloni <alexandre.belloni@bootlin.com>
Date:   Sat, 2 Nov 2024 14:28:41 +0100

    i3c: Document I3C_ADDR_SLOT_EXT_STATUS_MASK

    As the mask is part of the enum, document it.

    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Link: https://lore.kernel.org/r/20241102132841.2446176-1-alexandre.belloni@bootlin.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 05:48:34 -04:00
Jennifer Berringer d363908954 i3c: master: Fix miss free init_dyn_addr at i3c_master_put_i3c_addrs()
JIRA: https://issues.redhat.com/browse/RHEL-143335
CVE: CVE-2024-56562

commit 3082990592f7c6d7510a9133afa46e31bbe26533
Author: Frank Li <Frank.Li@nxp.com>
Date:   Tue, 1 Oct 2024 12:26:08 -0400

    i3c: master: Fix miss free init_dyn_addr at i3c_master_put_i3c_addrs()

    if (dev->boardinfo && dev->boardinfo->init_dyn_addr)
                                          ^^^ here check "init_dyn_addr"
    	i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, ...)
    						             ^^^^
    							free "dyn_addr"
    Fix copy/paste error "dyn_addr" by replacing it with "init_dyn_addr".

    Cc: stable@kernel.org
    Fixes: 3a379bbcea ("i3c: Add core I3C infrastructure")
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20241001162608.224039-1-Frank.Li@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-14 05:48:15 -04:00
Jennifer Berringer 9d4d8c1b17 i3c: master: Remove i3c_dev_disable_ibi_locked(olddev) on device hotjoin
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 36faa04ce3d9c962b4b29d285ad07ca29e2988e4
Author: Frank Li <Frank.Li@nxp.com>
Date:   Tue, 1 Oct 2024 12:22:32 -0400

    i3c: master: Remove i3c_dev_disable_ibi_locked(olddev) on device hotjoin

    When a new device hotjoins, a new dynamic address is assigned.
    i3c_master_add_i3c_dev_locked() identifies that the device was previously
    attached to the bus and locates the olddev.

    i3c_master_add_i3c_dev_locked()
    {
        ...
        olddev = i3c_master_search_i3c_dev_duplicate(newdev);
        ...
        if (olddev) {
            ...
            i3c_dev_disable_ibi_locked(olddev);
            ^^^^^^
            The olddev should not receive any commands on the i3c bus as it
            does not exist and has been assigned a new address. This will
            result in NACK or timeout. So remove it.
        }

        i3c_dev_free_ibi_locked(olddev);
        ^^^^^^^^
        This function internally calls i3c_dev_disable_ibi_locked() function
        causing to send DISEC command with old Address.

        The olddev should not receive any commands on the i3c bus as it
        does not exist and has been assigned a new address. This will
        result in NACK or timeout. So, update the olddev->ibi->enabled
        flag to false to avoid DISEC with OldAddr.
    }

    Include part of Ravindra Yashvant Shinde's work:
    https://lore.kernel.org/linux-i3c/20240820151917.3904956-1-ravindra.yashvant.shinde@nxp.com/T/#u

    Fixes: 317bacf960 ("i3c: master: add enable(disable) hot join in sys entry")
    Co-developed-by: Ravindra Yashvant Shinde <ravindra.yashvant.shinde@nxp.com>
    Signed-off-by: Ravindra Yashvant Shinde <ravindra.yashvant.shinde@nxp.com>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20241001162232.223724-1-Frank.Li@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:24:45 -04:00
Jennifer Berringer ab952bf3ac i3c: master: Fix dynamic address leak when 'assigned-address' is present
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 851bd21cdb55e727ab29280bc9f6b678164f802a
Author: Frank Li <Frank.Li@nxp.com>
Date:   Mon, 21 Oct 2024 11:45:08 -0400

    i3c: master: Fix dynamic address leak when 'assigned-address' is present

    If the DTS contains 'assigned-address', a dynamic address leak occurs
    during hotjoin events.

    Assume a device have assigned-address 0xb.
      - Device issue Hotjoin
      - Call i3c_master_do_daa()
      - Call driver xxx_do_daa()
      - Call i3c_master_get_free_addr() to get dynamic address 0x9
      - i3c_master_add_i3c_dev_locked(0x9)
      -     expected_dyn_addr  = newdev->boardinfo->init_dyn_addr (0xb);
      -     i3c_master_reattach_i3c_dev(newdev(0xb), old_dyn_addr(0x9));
      -         if (dev->info.dyn_addr != old_dyn_addr &&
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xb != 0x9 -> TRUE
                    (!dev->boardinfo ||
                     ^^^^^^^^^^^^^^^ ->  FALSE
                     dev->info.dyn_addr != dev->boardinfo->init_dyn_addr)) {
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     0xb != 0xb      ->  FALSE
                     ...
                     i3c_bus_set_addr_slot_status(&master->bus, old_dyn_addr,
                                                         I3C_ADDR_SLOT_FREE);
    		 ^^^
                     This will be skipped. So old_dyn_addr never free
                }

      - i3c_master_get_free_addr() will return increased sequence number.

    Remove dev->info.dyn_addr != dev->boardinfo->init_dyn_addr condition check.
    dev->info.dyn_addr should be checked before calling this function because
    i3c_master_setnewda_locked() has already been called and the target device
    has already accepted dyn_addr. It is too late to check if dyn_addr is free
    in i3c_master_reattach_i3c_dev().

    Add check to ensure expected_dyn_addr is free before
    i3c_master_setnewda_locked().

    Fixes: cc3a392d69 ("i3c: master: fix for SETDASA and DAA process")
    Cc: stable@kernel.org
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20241021-i3c_dts_assign-v8-3-4098b8bde01e@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:22:12 -04:00
Jennifer Berringer d259614a7c i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_DESIRED
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 2f552fa280590e61bd3dbe66a7b54b99caa642a4
Author: Frank Li <Frank.Li@nxp.com>
Date:   Mon, 21 Oct 2024 11:45:07 -0400

    i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_DESIRED

    Extend the address status bit to 4 and introduce the
    I3C_ADDR_SLOT_EXT_DESIRED macro to indicate that a device prefers a
    specific address. This is generally set by the 'assigned-address' in the
    device tree source (dts) file.

     ┌────┬─────────────┬───┬─────────┬───┐
     │S/Sr│ 7'h7E RnW=0 │ACK│ ENTDAA  │ T ├────┐
     └────┴─────────────┴───┴─────────┴───┘    │
     ┌─────────────────────────────────────────┘
     │  ┌──┬─────────────┬───┬─────────────────┬────────────────┬───┬─────────┐
     └─►│Sr│7'h7E RnW=1  │ACK│48bit UID BCR DCR│Assign 7bit Addr│PAR│ ACK/NACK│
        └──┴─────────────┴───┴─────────────────┴────────────────┴───┴─────────┘

    Some master controllers (such as HCI) need to prepare the entire above
    transaction before sending it out to the I3C bus. This means that a 7-bit
    dynamic address needs to be allocated before knowing the target device's
    UID information.

    However, some I3C targets may request specific addresses (called as
    "init_dyn_addr"), which is typically specified by the DT-'s
    assigned-address property. Lower addresses having higher IBI priority. If
    it is available, i3c_bus_get_free_addr() preferably return a free address
    that is not in the list of desired addresses (called as "init_dyn_addr").
    This allows the device with the "init_dyn_addr" to switch to its
    "init_dyn_addr" when it hot-joins the I3C bus. Otherwise, if the
    "init_dyn_addr" is already in use by another I3C device, the target device
    will not be able to switch to its desired address.

    If the previous step fails, fallback returning one of the remaining
    unassigned address, regardless of its state in the desired list.

    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20241021-i3c_dts_assign-v8-2-4098b8bde01e@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:20:46 -04:00
Jennifer Berringer 3ff9fb3c85 i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 16aed0a6520ba01b7d22c32e193fc1ec674f92d4
Author: Frank Li <Frank.Li@nxp.com>
Date:   Mon, 21 Oct 2024 11:45:06 -0400

    i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS

    Replace the hardcoded value 2, which indicates 2 bits for I3C address
    status, with the predefined macro I3C_ADDR_SLOT_STATUS_BITS.

    Improve maintainability and extensibility of the code.

    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Link: https://lore.kernel.org/r/20241021-i3c_dts_assign-v8-1-4098b8bde01e@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:19:59 -04:00
Jennifer Berringer 70ec860b6c ACPICA: fix I2C LVR item count in the conversion table
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 2543fbb21642f740288e3c292cab03cd611f35a4
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Wed, 27 May 2026 19:58:29 +0200

    ACPICA: fix I2C LVR item count in the conversion table

    For ACPI_RSC_MOVE8, the 'Value' field in struct acpi_rsconvert_info
    is the item count count and not a bit position like for the
    bitflags. Set 'Value' as '1' to fix this.

    Conversion still works coincidentally with '0' because
    item_count is not reset between table entries, and the previous
    count value was taking effect.

    Link: https://github.com/acpica/acpica/commit/70082dc8fc84
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/6164740.MhkbZ0Pkbq@rafael.j.wysocki

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:03:29 -04:00
Jennifer Berringer 76969782e4 ACPICA: Mention the LVR bits
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 53a3a7723c9eac56c47003291b52f106734eb438
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Wed, 27 May 2026 19:57:52 +0200

    ACPICA: Mention the LVR bits

    Add a comment mentioning the LVR byte position in the type_specific_flag.

    Link: https://github.com/acpica/acpica/commit/014fa9f2dbcc
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/9627007.CDJkKcVGEf@rafael.j.wysocki

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:03:29 -04:00
Jennifer Berringer 5e204972e8 ACPICA: Change LVR to 8 bit value
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit d364d76f3d0ccba6c8b0e3b0df348b4e86a0a72b
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Wed, 27 May 2026 19:57:13 +0200

    ACPICA: Change LVR to 8 bit value

    In the LVR I2C resource entry to acpi_rs_convert_i2c_serial_bus[].

    Link: https://github.com/acpica/acpica/commit/7650d4a889ea
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/3952474.kQq0lBPeGt@rafael.j.wysocki

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:03:29 -04:00
Jennifer Berringer 0aa784aa4e ACPICA: Fetch LVR I2C resource descriptor
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit 468adc6b1ff83431644cf002a1850010d7ff32dd
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Wed, 27 May 2026 19:56:38 +0200

    ACPICA: Fetch LVR I2C resource descriptor

    Add LVR I2C resource entry to acpi_rs_convert_i2c_serial_bus[].

    Link: https://github.com/acpica/acpica/commit/c40411823510
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/23121545.EfDdHjke4D@rafael.j.wysocki

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:03:29 -04:00
Jennifer Berringer 26bf98b14b ACPICA: Add LVR to acrestyp.h
JIRA: https://issues.redhat.com/browse/RHEL-143335

commit f0ee0b0927f78adfd9ba4f57b42a07645b1526a3
Author: Akhil R <akhilrajeev@nvidia.com>
Date:   Wed, 27 May 2026 19:55:57 +0200

    ACPICA: Add LVR to acrestyp.h

    Add a new field called lvr to struct acpi_resource_i2c_serialbus.

    Link: https://github.com/acpica/acpica/commit/e62e74baf7e0
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/2354060.iZASKD2KPV@rafael.j.wysocki

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-08-06 11:03:29 -04:00
Jennifer Berringer 50dc3f62d8 riscv: mm: Fix conflict in arch_tlbbatch_add_pending()
Upstream Status: RHEL Only

JIRA: https://redhat.atlassian.net/browse/RHEL-212287

A conflict between the following two patches caused build failures for
RISC-V:

- d9be2b9b60497 (`riscv: Call secondary mmu notifier when flushing the tlb`)
- 2f4ab3ac10e14 (`mm: support tlbbatch flush for a range of PTEs`)

Torvalds resolved this conflict in merge commit 4a1d8ababde68. This
patch reproduces that change exactly. As a result, the contents of
`arch/riscv/mm/tlbflush.c` now exactly match those of upstream v6.16.

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-17 16:43:35 -04:00
Jennifer Berringer a2f3ab86c4 firmware: arm_ffa: Fix Endpoint Memory Access Descriptor offset calculation
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit b4d961351aa84fdf0148783fb1f3a1391b8a0adb
Author: Sebastian Ene <sebastianene@google.com>
Date:   Thu, 2 Jul 2026 10:38:39 +0000

    firmware: arm_ffa: Fix Endpoint Memory Access Descriptor offset calculation

    Use the descriptor's `ep_mem_offset` to calculate the start of the endpoint
    memory access array and to comply with the FF-A spec instead of defaulting
    to `sizeof(struct ffa_mem_region)`.
    This requires moving `ffa_mem_region_additional_setup()` earlier in the setup
    flow.
    Also, add sanity checks to ensure the calculated descriptor offsets do not
    exceed `max_fragsize`.

    Fixes: 113580530e ("firmware: arm_ffa: Update memory descriptor to support v1.1 format")
    Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
    Signed-off-by: Mostafa Saleh <smostafa@google.com>
    Signed-off-by: Sebastian Ene <sebastianene@google.com>
    Link: https://patch.msgid.link/20260702103848.1647249-3-sebastianene@google.com
    Signed-off-by: Marc Zyngier <maz@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-17 14:54:51 -04:00
Jennifer Berringer c069b514e1 firmware: arm_ffa: Fix out-of-bound writes in ffa_setup_and_transmit()
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit 3383ffb7ef937317361713ffcc21921a7848511a
Author: Mostafa Saleh <smostafa@google.com>
Date:   Thu, 2 Jul 2026 10:38:38 +0000

    firmware: arm_ffa: Fix out-of-bound writes in ffa_setup_and_transmit()

    Sashiko (locally) reports multiple out-of-bound issues in
    ffa_setup_and_transmit:
    1) Writing ep_mem_access->reserved can write out of bounds for FFA
       versions < 1.2 as ffa_emad_size_get() returns 16 bytes in that case
       while reserved has an offset of 24.
       Instead of zeroing fields, memset the struct to zero first based on
       the FFA version.

    2) Make sure there is enough size to write constituents.

    While at it, convert the only sizeof() in the driver that uses a
    type instead of variable.

    Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
    Fixes: 111a833dc5 ("firmware: arm_ffa: Set reserved/MBZ fields to zero in the memory descriptors")
    Signed-off-by: Mostafa Saleh <smostafa@google.com>
    Signed-off-by: Sebastian Ene <sebastianene@google.com>
    Link: https://patch.msgid.link/20260702103848.1647249-2-sebastianene@google.com
    Signed-off-by: Marc Zyngier <maz@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-17 14:54:51 -04:00
Jennifer Berringer 3e8c3fd53c firmware: arm_ffa: Fix NULL dereference in ffa_partition_info_get()
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit 8ae5f8e4836667fcaffdf2e3c6068b0a8b364dd8
Author: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
Date:   Wed, 17 Jun 2026 16:35:00 -0700

    firmware: arm_ffa: Fix NULL dereference in ffa_partition_info_get()

    ffa_partition_info_get() passes uuid_str directly to uuid_parse()
    without a NULL check. When a caller passes NULL, uuid_parse() ->
    __uuid_parse() -> uuid_is_valid() dereferences the pointer, causing
    a kernel panic:

      |  Unable to handle kernel NULL pointer dereference at virtual address
      |  0000000000000040
      |  pc : uuid_parse+0x40/0xac
      |  lr : ffa_partition_info_get+0x1c/0x94 [arm_ffa]

    Add a NULL guard before uuid_parse() so a NULL argument returns
    -ENODEV instead of crashing. Callers are expected to always supply
    a valid partition UUID, so NULL is not a supported input.

    Fixes: d0c0bce831 ("firmware: arm_ffa: Setup in-kernel users of FFA partitions")
    Signed-off-by: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
    Link: https://patch.msgid.link/20260617-ffa_partition_nullptr_fix-v2-1-bc801b4ce34c@oss.qualcomm.com
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-17 14:54:49 -04:00
Jennifer Berringer d438028778 firmware: arm_ffa: Respect firmware advertised RX/TX buffer size limits
JIRA: https://issues.redhat.com/browse/RHEL-183180

commit 53716a4d745f1dac7aff33f3d1494b701eb2f888
Author: Seth Forshee <sforshee@nvidia.com>
Date:   Tue, 2 Jun 2026 21:54:06 +0000

    firmware: arm_ffa: Respect firmware advertised RX/TX buffer size limits

    FFA_FEATURES reports the minimum size and alignment boundary required
    for RXTX_MAP. In FF-A v1.2 and later it can also report a maximum buffer
    size, with zero meaning that no maximum is enforced.

    The driver only used the minimum value and then rounded it up to PAGE_SIZE
    before invoking RXTX_MAP after commit 83210251fd70 ("firmware: arm_ffa:
    Use the correct buffer size during RXTX_MAP"). On systems where PAGE_SIZE
    is larger than the advertised minimum, this can exceed a non-zero maximum
    reported by firmware. Older implementations do not advertise a maximum and
    may also reject the rounded-up size.

    Decode the maximum size and clamp the page-aligned minimum to it when it
    is present. If no maximum is advertised and RXTX_MAP rejects the rounded
    size with INVALID_PARAMETERS, retry with the advertised minimum size.
    Record drv_info->rxtx_bufsz only after RXTX_MAP succeeds so it reflects
    the size registered with firmware.

    While there, also update RXTX_MAP_MIN_BUFSZ() to use FIELD_GET() for
    consistency.

    Fixes: 83210251fd70 ("firmware: arm_ffa: Use the correct buffer size during RXTX_MAP")
    Suggested-by: Sudeep Holla <sudeep.holla@kernel.org>
    Signed-off-by: Seth Forshee <sforshee@nvidia.com>
    Link: https://patch.msgid.link/20260602-b4-ffa-rxtx-map-fixes-v2-1-7cb06508da84@nvidia.com
    (sudeep.holla: Minor rewording subject and commit message)
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-17 14:54:45 -04:00
Jennifer Berringer 1bc194d0a8 firmware: arm_ffa: Treat missing FF-A feature on a platform as a probe miss
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit 18706ea68fc4344049bf693b702cb311a7c27ca7
Author: Sudeep Holla <sudeep.holla@kernel.org>
Date:   Tue, 26 May 2026 11:36:49 +0100

    firmware: arm_ffa: Treat missing FF-A feature on a platform as a probe miss

    When FF-A initialisation is driven from a platform device probe, systems
    that do not implement FF-A can return -EOPNOTSUPP from the early transport
    or version discovery paths. Driver core treats that as a matched probe
    failure and prints:

      |  arm-ffa arm-ffa: probe with driver arm-ffa failed with error -95

    That is noisy for a firmware interface that can be absent on otherwise
    valid systems. Driver core already treats -ENODEV and -ENXIO as quiet
    rejected matches, so translate only the early unsupported discovery cases
    to -ENODEV. Keep later setup failures unchanged so real FF-A
    initialisation problems are still reported as probe failures.

    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Closes: https://lore.kernel.org/all/20260523001148.GA1319283@ax162
    Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Link: https://patch.msgid.link/20260526103649.5684-1-sudeep.holla@kernel.org
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-13 12:09:17 -04:00
Jennifer Berringer 2151016acf firmware: arm_ffa: Honor partition info descriptor size
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit 01b9cae706161a39452a2cce0f281d4369344c51
Author: Jamie Nguyen <jamien@nvidia.com>
Date:   Mon, 18 May 2026 13:31:16 -0700

    firmware: arm_ffa: Honor partition info descriptor size

    FFA_PARTITION_INFO_GET_REGS reports the size of each partition
    information descriptor in x2[63:48]. However, __ffa_partition_info_get_regs()
    walks the returned register payload with a hardcoded 24-byte stride
    (regs += 3), even though the size is already read into buf_sz.

    That works for the FF-A v1.1/v1.2 24-byte descriptor layout, where each
    descriptor consumes three registers. Newer FF-A revisions can extend the
    descriptor while keeping the existing fields at the front. For example, a
    48-byte descriptor consumes six registers, so advancing by only three
    registers desynchronises the parser and can make it read subsequent entries
    from the middle of a descriptor.

    Use the advertised descriptor size to derive the register stride. Validate
    that the size is register-aligned, large enough for the fields parsed by the
    driver, and that the requested number of descriptors fits in the returned
    x3..x17 register window. The driver still copies only the fields it
    understands, but now skips over any trailing descriptor fields correctly.

    Fixes: ba85c644ac ("firmware: arm_ffa: Add support for FFA_PARTITION_INFO_GET_REGS")
    Suggested-by: Sudeep Holla <sudeep.holla@kernel.org>
    Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
    Link: https://patch.msgid.link/20260518203116.42624-1-jamien@nvidia.com
    (sudeep.holla: Minor rewordng of the commit message and subject)
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-13 12:09:01 -04:00
Jennifer Berringer 2e56dea124 firmware: arm_ffa: Defer probe until pKVM is initialized
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit 3acc80a78e45246a87061cbdd46775baa132de83
Author: Sudeep Holla <sudeep.holla@kernel.org>
Date:   Fri, 8 May 2026 18:54:18 +0100

    firmware: arm_ffa: Defer probe until pKVM is initialized

    When protected KVM is enabled, the kernel includes a pKVM FF-A proxy
    that sits in front of the normal FF-A driver. The proxy has to perform
    its own FF-A version negotiation and setup first, so that it can mediate
    subsequent FF-A traffic correctly.

    Defer FF-A core probing until pKVM has completed initialization. This
    keeps the normal driver from negotiating the FF-A version or performing
    other transport setup before the pKVM proxy is ready, and lets the
    driver model retry probing once the protected KVM state required by the
    FF-A transport is available.

    Suggested-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Link: https://patch.msgid.link/20260508-b4-ffa_plat_dev-v1-4-c5a30f8cf7b8@kernel.org
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-13 12:08:47 -04:00
Jennifer Berringer 24c8cf9252 firmware: arm_ffa: Set the core device as FF-A device parent
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit 7fe2ec9fb8e9a78dad8d6b1e551cb4d126e36f1e
Author: Sudeep Holla <sudeep.holla@kernel.org>
Date:   Fri, 8 May 2026 18:54:17 +0100

    firmware: arm_ffa: Set the core device as FF-A device parent

    Pass a parent device into ffa_device_register() and use the synthetic
    arm-ffa platform device as the parent for each registered FF-A device.

    This keeps the enumerated FF-A partition devices anchored below the FF-A
    core device in the driver model, matching the platform-driver conversion
    of the core transport.

    Suggested-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Link: https://patch.msgid.link/20260508-b4-ffa_plat_dev-v1-3-c5a30f8cf7b8@kernel.org
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-13 12:08:32 -04:00
Jennifer Berringer 7e357efacc firmware: arm_ffa: Register core as a platform driver
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit e659fc8e537c7a21d5d693d6f30d8852f2fa8d91
Author: Sudeep Holla <sudeep.holla@kernel.org>
Date:   Fri, 8 May 2026 18:54:16 +0100

    firmware: arm_ffa: Register core as a platform driver

    Move the FF-A core bring-up and teardown paths into platform driver
    probe and remove callbacks, and register a synthetic arm-ffa platform
    device to bind the driver.

    This makes the FF-A core lifetime follow the driver model while keeping
    the device creation internal to the FF-A core. Use normal platform driver
    registration so the probe path has standard driver-core semantics.

    The synthetic platform device is a temporary bridge until ACPI and
    devicetree describe the FF-A core device or object. Once those firmware
    description paths are defined, the internal platform device creation can
    be dropped and the driver can bind to the firmware-described device
    directly.

    Since the transport selection now happens from the platform probe path,
    drop the __init annotation from ffa_transport_init().

    Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Link: https://patch.msgid.link/20260508-b4-ffa_plat_dev-v1-2-c5a30f8cf7b8@kernel.org
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-13 12:07:20 -04:00
Jennifer Berringer b5c4f3dfa5 Revert "firmware: arm_ffa: Change initcall level of ffa_init() to rootfs_initcall"
JIRA: https://issues.redhat.com/browse/RHEL-179031

commit cc7e8f21b9f0c229d68cf19a837cba82b5ac2d87
Author: Yeoreum Yun <yeoreum.yun@arm.com>
Date:   Fri, 8 May 2026 18:54:15 +0100

    Revert "firmware: arm_ffa: Change initcall level of ffa_init() to rootfs_initcall"

    This reverts commit 0e0546eabcd6c19765a8dbf5b5db3723e7b0ea75, which was
    added to address ordering issues with the IMA LSM initialisation where
    the TPM would not be fully ready by the time IMA wanted it. This has
    been resolved within IMA by retrying setup during late_initcall_sync if
    the TPM is not available at first.

    Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
    Link: https://patch.msgid.link/20260508-b4-ffa_plat_dev-v1-1-c5a30f8cf7b8@kernel.org
    Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
2026-07-13 12:06:39 -04:00